fix(uixt): fix uixt__input not working and add comprehensive unit tests

- Fix parameter mapping issue where AI model's 'content' parameter wasn't mapped to 'text' field
- Add mapParameterName function to handle parameter name mapping (content->text, key->keycode)
- Add comprehensive unit tests for convertProcessedArgs and mapParameterName functions
- Update existing test cases to match new parameter format (x,y for single coords, from_x,from_y,to_x,to_y for drag)

This resolves the issue where uixt__input action was not working due to parameter name mismatch.
This commit is contained in:
lilong.129
2025-06-07 15:03:29 +08:00
parent 334c0dc141
commit 460570f651
5 changed files with 355 additions and 91 deletions
+16 -3
View File
@@ -301,15 +301,28 @@ func convertProcessedArgs(processedArgs map[string]interface{}, actionType strin
return options.ToMap(), nil
}
// For non-coordinate operations, return the original arguments map
// TODO
// For non-coordinate operations, apply parameter name mapping and return the arguments map
finalArgs := make(map[string]interface{})
for key, value := range processedArgs {
finalArgs[key] = value
// Map parameter names to match ActionOptions field names
mappedKey := mapParameterName(key)
finalArgs[mappedKey] = value
}
return finalArgs, nil
}
// mapParameterName maps UI-TARS parameter names to ActionOptions field names
func mapParameterName(paramName string) string {
switch paramName {
case "content":
return "text" // Map content to text for input operations
case "key":
return "keycode" // Map key to keycode for hotkey operations
default:
return paramName
}
}
// normalizeActionCoordinates normalizes coordinates from various formats to actual pixel coordinates
func normalizeActionCoordinates(coordData interface{}, size types.Size) ([]float64, error) {
switch v := coordData.(type) {