-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(cua-driver/macos): set_config accepts {key,value} shape (parity with Win/Linux) #2059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,15 @@ fn def() -> &'static ToolDef { | |
| input_schema: serde_json::json!({ | ||
| "type": "object", | ||
| "properties": { | ||
| "key": { | ||
| "type": "string", | ||
| "description": "Name of a single config field to write ({key, value} shape, \ | ||
| matching the CLI `config set` and the Windows/Linux tools). Pair with `value`. \ | ||
| Equivalent to passing the field directly." | ||
| }, | ||
| "value": { | ||
| "description": "New value for `key`. JSON type depends on the key." | ||
| }, | ||
| "capture_mode": { | ||
| "type": "string", | ||
| "enum": ["som", "vision", "ax"], | ||
|
|
@@ -75,20 +84,36 @@ impl Tool for SetConfigTool { | |
| // sessions don't clobber each other or the persisted default. | ||
| let session_id = args.opt_str("_session_id"); | ||
|
|
||
| // Accept BOTH shapes, matching Windows/Linux + the CLI `config set`: | ||
| // - direct fields: {"capture_scope":"desktop"} | ||
| // - {key, value}: {"key":"capture_scope","value":"desktop"} | ||
| // A direct field wins if both are somehow present. | ||
| let kv: Option<(String, Value)> = args | ||
| .opt_str("key") | ||
| .and_then(|k| args.get("value").map(|v| (k, v.clone()))); | ||
| let kv_str = |name: &str| -> Option<String> { | ||
| kv.as_ref() | ||
| .filter(|(k, _)| k == name) | ||
| .and_then(|(_, v)| v.as_str().map(str::to_owned)) | ||
| }; | ||
| let kv_u64 = |name: &str| -> Option<u64> { | ||
| kv.as_ref().filter(|(k, _)| k == name).and_then(|(_, v)| v.as_u64()) | ||
| }; | ||
|
|
||
| // Validate max_image_dimension up front so both branches share the | ||
| // u32 check and we never half-apply. | ||
| let max_dim: Option<u32> = match args.opt_u64("max_image_dimension") { | ||
| let max_dim: Option<u32> = match args.opt_u64("max_image_dimension").or_else(|| kv_u64("max_image_dimension")) { | ||
| Some(dim) => match u32::try_from(dim) { | ||
| Ok(d) => Some(d), | ||
| Err(_) => return ToolResult::error(format!("max_image_dimension {dim} exceeds u32::MAX")), | ||
| }, | ||
| None => None, | ||
| }; | ||
| let capture_mode = args.opt_str("capture_mode"); | ||
| let capture_mode = args.opt_str("capture_mode").or_else(|| kv_str("capture_mode")); | ||
|
|
||
| // Validate capture_scope up front so both branches share the check and | ||
| // we never half-apply an invalid value. | ||
| let capture_scope = args.opt_str("capture_scope"); | ||
| let capture_scope = args.opt_str("capture_scope").or_else(|| kv_str("capture_scope")); | ||
|
Comment on lines
+87
to
+116
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Handle The new fallback only feeds 🤖 Prompt for AI Agents
Comment on lines
+112
to
+116
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Validate
🤖 Prompt for AI Agents |
||
| if let Some(scope) = capture_scope.as_deref() { | ||
| if scope != "window" && scope != "desktop" { | ||
| return ToolResult::error(format!( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Update the argument table to include
capture_scope,key, andvalue.The new paragraph documents the alternate shape, but the reference table below still omits those inputs, so the docs no longer fully match the tool contract.
🤖 Prompt for AI Agents