From 3f328850c19eea2ffb6070d81f34fc8c3819f987 Mon Sep 17 00:00:00 2001 From: creatixchu Date: Thu, 19 Nov 2026 12:19:50 +0800 Subject: [PATCH] Record unified held-input behavior and pause release notices --- .../tests/profiles/cua-mcp/expected/held-inputs.json | 12 ++++++++++++ .../tests/profiles/cua-mcp/expected/instructions.txt | 2 +- .../cli/tests/profiles/cua-mcp/expected/reference.md | 2 +- docs/subsystems/computer-use.md | 8 ++++++++ docs/subsystems/computer-use.zh.md | 8 ++++++++ packages/extensions/tool-cordis/src/api-catalog.ts | 6 ++++++ snapshots/sdk/cua-run-code/system-prompt.expected.md | 2 +- .../session/cua-native/system-prompt.expected.md | 2 +- snapshots/session/cua-ptc/system-prompt.expected.md | 2 +- .../cua-run-code-ptc/system-prompt.expected.md | 2 +- snapshots/session/cua-run-code/session.v4.jsonl | 7 ++++--- .../session/cua-run-code/system-prompt.expected.md | 2 +- .../ptc-script-retained/system-prompt.expected.md | 2 +- 13 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 apps/cli/tests/profiles/cua-mcp/expected/held-inputs.json diff --git a/apps/cli/tests/profiles/cua-mcp/expected/held-inputs.json b/apps/cli/tests/profiles/cua-mcp/expected/held-inputs.json new file mode 100644 index 0000000000..099ba2ed86 --- /dev/null +++ b/apps/cli/tests/profiles/cua-mcp/expected/held-inputs.json @@ -0,0 +1,12 @@ +{ + "content": [ + { + "type": "text", + "text": "Input sequence finished.\n" + }, + { + "type": "text", + "text": "\nCUA inputs are still held:\n- Key \"shift\", appHandle \"fixture-app\" (application input).\n- Mouse left, appHandle \"fixture-app\", windowId \"7\" (window input).\n- Key \"w\", appHandle \"fixture-app\" (application input).\nThey remain pressed across programs and turns. Release them explicitly with sendKeyEvent(key, 'up') or toggleMouse(button, 'up') on the same target when no longer needed.\n" + } + ] +} diff --git a/apps/cli/tests/profiles/cua-mcp/expected/instructions.txt b/apps/cli/tests/profiles/cua-mcp/expected/instructions.txt index fe2768f3dc..aaa6234dad 100644 --- a/apps/cli/tests/profiles/cua-mcp/expected/instructions.txt +++ b/apps/cli/tests/profiles/cua-mcp/expected/instructions.txt @@ -1 +1 @@ -DeepSeek Harness Computer Use: observe and operate desktop applications on this machine. Start every conversation by calling cua_get_api_reference: it returns the complete cua API reference, and programs written without it guess the API wrong. Then call cua_run_code with a TypeScript program that uses the global cua object; program state persists across calls on this connection. A call may ask the user for application or pointer consent before it proceeds. Call cua_reset to discard program state. Remaining held keys and mouse buttons are released before each program returns. A system reminder lists inputs automatically released at program end. Explicit downs cannot stay held across MCP calls. +DeepSeek Harness Computer Use: observe and operate desktop applications on this machine. Start every conversation by calling cua_get_api_reference: it returns the complete cua API reference, and programs written without it guess the API wrong. Then call cua_run_code with a TypeScript program that uses the global cua object; program state persists across calls on this connection. A call may ask the user for application or pointer consent before it proceeds. Call cua_reset to discard program state. Explicit key and mouse downs remain held across successful programs; a system reminder lists remaining holds. Explicit up, program failure, request cancellation, reset, and connection closure release owned input. Client pause between completed calls is not observable by this server and does not release input. diff --git a/apps/cli/tests/profiles/cua-mcp/expected/reference.md b/apps/cli/tests/profiles/cua-mcp/expected/reference.md index 167cfd894c..ca24cca04d 100644 --- a/apps/cli/tests/profiles/cua-mcp/expected/reference.md +++ b/apps/cli/tests/profiles/cua-mcp/expected/reference.md @@ -53,7 +53,7 @@ Available at app or window level depending on the platform. - pressKey(key: string, modifiers?: Modifier[]) -> ActionResult — press and release one complete keystroke. For example pressKey('Tab', ['shift']) or pressKey('+'). Key names are platform-defined strings. Pass key and modifiers separately; do not pack them into a chord string. - sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. -In DSH, explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. MCP and other programs outside a DSH turn release remaining input before returning and report which inputs were automatically released. No reminder is added when there is nothing to report. Program failure, user stop, connection closure, and disposal release owned inputs together in reverse dispatch order. pressKey, typeText, click, and complete drag release their own inputs within the operation. +Explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. No reminder is added when none remain. Program failure, a received cancellation, connection closure, and disposal release owned inputs together in reverse dispatch order. A client pause between completed MCP calls is not observable by the server, so held input can remain pressed. pressKey, typeText, click, and complete drag release their own inputs within the operation. click, drag, and pressKey are convenience operations; sendKeyEvent, mouseMove, and toggleMouse are primitive operations. For complex action combinations, decompose convenience operations into sequences of primitive operations supported by the current platform. diff --git a/docs/subsystems/computer-use.md b/docs/subsystems/computer-use.md index b2b9e8d4bd..51fa464352 100644 --- a/docs/subsystems/computer-use.md +++ b/docs/subsystems/computer-use.md @@ -163,6 +163,14 @@ Host control over the dedicated `cua_run_code` environments; registered as `ctx. */ release(agent: Agent): Promise +/** + * Release the Agent's tracked input while retaining its program variables and application grants. + * Providers without held-input state support retain their existing cancellation behavior. + * @param agent - Owner of the input to release. + * @returns Completion after native acknowledgement, or rejection when cleanup is unconfirmed. + */ +releaseInputs(agent: Agent): Promise + /** * Request-image target the provider delivered for a stored screenshot when `screenshotTarget` is configured. * A host that forwards screenshots outside a model request reads the same request version with it, so the diff --git a/docs/subsystems/computer-use.zh.md b/docs/subsystems/computer-use.zh.md index 4405bc3fcc..cd30d15255 100644 --- a/docs/subsystems/computer-use.zh.md +++ b/docs/subsystems/computer-use.zh.md @@ -163,6 +163,14 @@ Host control over the dedicated `cua_run_code` environments; registered as `ctx. */ release(agent: Agent): Promise +/** + * Release the Agent's tracked input while retaining its program variables and application grants. + * Providers without held-input state support retain their existing cancellation behavior. + * @param agent - Owner of the input to release. + * @returns Completion after native acknowledgement, or rejection when cleanup is unconfirmed. + */ +releaseInputs(agent: Agent): Promise + /** * Request-image target the provider delivered for a stored screenshot when `screenshotTarget` is configured. * A host that forwards screenshots outside a model request reads the same request version with it, so the diff --git a/packages/extensions/tool-cordis/src/api-catalog.ts b/packages/extensions/tool-cordis/src/api-catalog.ts index f6385c3ca0..29fa13bf11 100644 --- a/packages/extensions/tool-cordis/src/api-catalog.ts +++ b/packages/extensions/tool-cordis/src/api-catalog.ts @@ -1055,6 +1055,12 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [ returns: 'Completion after the process has exited and its output has drained.', throws: ['When the process cleanup fails.'], }, + { + signature: 'releaseInputs(agent: Agent): Promise', + description: 'Release the Agent\'s tracked input while retaining its program variables and application grants. Providers without held-input state support retain their existing cancellation behavior.', + parameters: [{ name: 'agent', description: 'Owner of the input to release.' }], + returns: 'Completion after native acknowledgement, or rejection when cleanup is unconfirmed.', + }, { signature: 'screenshotRequestTarget(image: ImageAttachmentRef): ImageRequestTarget | undefined', description: 'Request-image target the provider delivered for a stored screenshot when `screenshotTarget` is configured. A host that forwards screenshots outside a model request reads the same request version with it, so the image a caller sees matches the coordinate space the provider mapped.', diff --git a/snapshots/sdk/cua-run-code/system-prompt.expected.md b/snapshots/sdk/cua-run-code/system-prompt.expected.md index 969740e8a0..7b90ddb906 100644 --- a/snapshots/sdk/cua-run-code/system-prompt.expected.md +++ b/snapshots/sdk/cua-run-code/system-prompt.expected.md @@ -87,7 +87,7 @@ Available at app or window level depending on the platform. - pressKey(key: string, modifiers?: Modifier[]) -> ActionResult — press and release one complete keystroke. For example pressKey('Tab', ['shift']) or pressKey('+'). Key names are platform-defined strings. Pass key and modifiers separately; do not pack them into a chord string. - sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. -In DSH, explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. MCP and other programs outside a DSH turn release remaining input before returning and report which inputs were automatically released. No reminder is added when there is nothing to report. Program failure, user stop, connection closure, and disposal release owned inputs together in reverse dispatch order. pressKey, typeText, click, and complete drag release their own inputs within the operation. +Explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. No reminder is added when none remain. Program failure, a received cancellation, connection closure, and disposal release owned inputs together in reverse dispatch order. A client pause between completed MCP calls is not observable by the server, so held input can remain pressed. pressKey, typeText, click, and complete drag release their own inputs within the operation. click, drag, and pressKey are convenience operations; sendKeyEvent, mouseMove, and toggleMouse are primitive operations. For complex action combinations, decompose convenience operations into sequences of primitive operations supported by the current platform. diff --git a/snapshots/session/cua-native/system-prompt.expected.md b/snapshots/session/cua-native/system-prompt.expected.md index f88245aff2..d4064ef6eb 100644 --- a/snapshots/session/cua-native/system-prompt.expected.md +++ b/snapshots/session/cua-native/system-prompt.expected.md @@ -90,7 +90,7 @@ Available at app or window level depending on the platform. - pressKey(key: string, modifiers?: Modifier[]) -> ActionResult — press and release one complete keystroke. For example pressKey('Tab', ['shift']) or pressKey('+'). Key names are platform-defined strings. Pass key and modifiers separately; do not pack them into a chord string. - sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. For example W down, D down, D up, W up. A repeated 'down' for an ordinary held key sends one repeat without adding another hold. -In DSH, explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. MCP and other programs outside a DSH turn release remaining input before returning and report which inputs were automatically released. No reminder is added when there is nothing to report. Program failure, user stop, connection closure, and disposal release owned inputs together in reverse dispatch order. pressKey, typeText, click, and complete drag release their own inputs within the operation. +Explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. No reminder is added when none remain. Program failure, a received cancellation, connection closure, and disposal release owned inputs together in reverse dispatch order. A client pause between completed MCP calls is not observable by the server, so held input can remain pressed. pressKey, typeText, click, and complete drag release their own inputs within the operation. click, drag, and pressKey are convenience operations; sendKeyEvent, mouseMove, and toggleMouse are primitive operations. For complex action combinations, decompose convenience operations into sequences of primitive operations supported by the current platform. diff --git a/snapshots/session/cua-ptc/system-prompt.expected.md b/snapshots/session/cua-ptc/system-prompt.expected.md index 10e7e79a27..a8f33aac4e 100644 --- a/snapshots/session/cua-ptc/system-prompt.expected.md +++ b/snapshots/session/cua-ptc/system-prompt.expected.md @@ -92,7 +92,7 @@ Available at app or window level depending on the platform. - pressKey(key: string, modifiers?: Modifier[]) -> ActionResult — press and release one complete keystroke. For example pressKey('Tab', ['shift']) or pressKey('+'). Key names are platform-defined strings. Pass key and modifiers separately; do not pack them into a chord string. - sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. For example W down, D down, D up, W up. A repeated 'down' for an ordinary held key sends one repeat without adding another hold. -In DSH, explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. MCP and other programs outside a DSH turn release remaining input before returning and report which inputs were automatically released. No reminder is added when there is nothing to report. Program failure, user stop, connection closure, and disposal release owned inputs together in reverse dispatch order. pressKey, typeText, click, and complete drag release their own inputs within the operation. +Explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. No reminder is added when none remain. Program failure, a received cancellation, connection closure, and disposal release owned inputs together in reverse dispatch order. A client pause between completed MCP calls is not observable by the server, so held input can remain pressed. pressKey, typeText, click, and complete drag release their own inputs within the operation. click, drag, and pressKey are convenience operations; sendKeyEvent, mouseMove, and toggleMouse are primitive operations. For complex action combinations, decompose convenience operations into sequences of primitive operations supported by the current platform. diff --git a/snapshots/session/cua-run-code-ptc/system-prompt.expected.md b/snapshots/session/cua-run-code-ptc/system-prompt.expected.md index b950ec6f8d..155346b4eb 100644 --- a/snapshots/session/cua-run-code-ptc/system-prompt.expected.md +++ b/snapshots/session/cua-run-code-ptc/system-prompt.expected.md @@ -88,7 +88,7 @@ Available at app or window level depending on the platform. - pressKey(key: string, modifiers?: Modifier[]) -> ActionResult — press and release one complete keystroke. For example pressKey('Tab', ['shift']) or pressKey('+'). Key names are platform-defined strings. Pass key and modifiers separately; do not pack them into a chord string. - sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. -In DSH, explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. MCP and other programs outside a DSH turn release remaining input before returning and report which inputs were automatically released. No reminder is added when there is nothing to report. Program failure, user stop, connection closure, and disposal release owned inputs together in reverse dispatch order. pressKey, typeText, click, and complete drag release their own inputs within the operation. +Explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. No reminder is added when none remain. Program failure, a received cancellation, connection closure, and disposal release owned inputs together in reverse dispatch order. A client pause between completed MCP calls is not observable by the server, so held input can remain pressed. pressKey, typeText, click, and complete drag release their own inputs within the operation. click, drag, and pressKey are convenience operations; sendKeyEvent, mouseMove, and toggleMouse are primitive operations. For complex action combinations, decompose convenience operations into sequences of primitive operations supported by the current platform. diff --git a/snapshots/session/cua-run-code/session.v4.jsonl b/snapshots/session/cua-run-code/session.v4.jsonl index 36e038510b..00c3bf66a5 100644 --- a/snapshots/session/cua-run-code/session.v4.jsonl +++ b/snapshots/session/cua-run-code/session.v4.jsonl @@ -13,7 +13,7 @@ {"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"tools":"{{tools}}"},"reason":"initial"}} {"type":"request/context","data":{"provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"}} {"type":"session/title","data":{"title":"Use cua_run_code to select test.fixture,","messageSeqs":[9],"source":{"kind":"fallback"}}} -{"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); await app.sendKeyEvent(\\\"w\\\", \\\"down\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:4}}"},"stream":[{"type":"chunk","time":1795057086972,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1795057086972,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); await app.sendKeyEvent(\\\"w\\\", \\\"down\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}}},{"type":"chunk","time":1795057086972,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} +{"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); await app.sendKeyEvent(\\\"w\\\", \\\"down\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:4}}"},"stream":[{"type":"chunk","time":1795061770766,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1795061770766,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); await app.sendKeyEvent(\\\"w\\\", \\\"down\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}}},{"type":"chunk","time":1795061770767,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} {"type":"tool/call","data":{"turn":1,"step":1,"callId":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); await app.sendKeyEvent(\\\"w\\\", \\\"down\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}} {"type":"tool/ptc-dispatch-start","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:1","name":"cua","arguments":{"method":"getCapabilities","params":{}}}} {"type":"tool/ptc-dispatch","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:1","name":"cua","arguments":{"method":"getCapabilities","params":{}},"isError":false,"content":[{"type":"text","text":"{\"sessionLocked\":false,\"permissions\":{\"accessibility\":true,\"screenRecording\":true},\"platform\":\"macos\",\"systemPointer\":false,\"methods\":[\"getCapabilities\",\"getApp\",\"getState\",\"click\",\"screenshot\",\"sendKeyEvent\",\"toggleMouse\"],\"appLevelAccessibility\":true,\"keyboard\":[\"app\"],\"browser\":false,\"coordinateSpace\":\"screenshot-pixels\"}"}]}} @@ -33,7 +33,7 @@ {"type":"agent/inbox/spliced","data":{"target":"next-step","start":0,"removedCount":1,"inserted":[]}} {"type":"step/start","data":{"turn":1,"step":2}} {"type":"user/message","data":{"content":[{"type":"text","text":"\nCUA inputs are still held:\n- Key \"w\", appHandle \"fixture-app\" (application input).\nThey remain pressed across programs and turns. Release them explicitly with sendKeyEvent(key, 'up') or toggleMouse(button, 'up') on the same target when no longer needed.\n"}],"source":{"kind":"cua-held-inputs","form":"notice","summary":"CUA inputs remain held"},"role":"user","id":"{{message:6}}"},"surfaceOp":"append"} -{"type":"assistant/message","data":{"turn":1,"step":2,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua_reuse","name":"cua_run_code","arguments":"{\"code\":\"await app.sendKeyEvent(\\\"w\\\", \\\"up\\\"); globalThis.visits++; await win.getAccessibilityTree(); await win.click(\\\"0\\\"); inspect(JSON.stringify({ visits, app: app.appHandle, window: win.windowId, tree: await win.getAccessibilityTree(), bindings: Object.keys(tools) })); await win.toggleMouse(\\\"left\\\", \\\"down\\\"); await app.sendKeyEvent(\\\"d\\\", \\\"down\\\")\",\"description\":\"Reuse the retained application and window\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:7}}"},"stream":[{"type":"chunk","time":1795057087286,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1795057087286,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua_reuse","name":"cua_run_code","arguments":"{\"code\":\"await app.sendKeyEvent(\\\"w\\\", \\\"up\\\"); globalThis.visits++; await win.getAccessibilityTree(); await win.click(\\\"0\\\"); inspect(JSON.stringify({ visits, app: app.appHandle, window: win.windowId, tree: await win.getAccessibilityTree(), bindings: Object.keys(tools) })); await win.toggleMouse(\\\"left\\\", \\\"down\\\"); await app.sendKeyEvent(\\\"d\\\", \\\"down\\\")\",\"description\":\"Reuse the retained application and window\"}"}}},{"type":"chunk","time":1795057087286,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} +{"type":"assistant/message","data":{"turn":1,"step":2,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua_reuse","name":"cua_run_code","arguments":"{\"code\":\"await app.sendKeyEvent(\\\"w\\\", \\\"up\\\"); globalThis.visits++; await win.getAccessibilityTree(); await win.click(\\\"0\\\"); inspect(JSON.stringify({ visits, app: app.appHandle, window: win.windowId, tree: await win.getAccessibilityTree(), bindings: Object.keys(tools) })); await win.toggleMouse(\\\"left\\\", \\\"down\\\"); await app.sendKeyEvent(\\\"d\\\", \\\"down\\\")\",\"description\":\"Reuse the retained application and window\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:7}}"},"stream":[{"type":"chunk","time":1795061771077,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1795061771077,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua_reuse","name":"cua_run_code","arguments":"{\"code\":\"await app.sendKeyEvent(\\\"w\\\", \\\"up\\\"); globalThis.visits++; await win.getAccessibilityTree(); await win.click(\\\"0\\\"); inspect(JSON.stringify({ visits, app: app.appHandle, window: win.windowId, tree: await win.getAccessibilityTree(), bindings: Object.keys(tools) })); await win.toggleMouse(\\\"left\\\", \\\"down\\\"); await app.sendKeyEvent(\\\"d\\\", \\\"down\\\")\",\"description\":\"Reuse the retained application and window\"}"}}},{"type":"chunk","time":1795061771077,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} {"type":"tool/call","data":{"turn":1,"step":2,"callId":"cua_reuse","name":"cua_run_code","arguments":"{\"code\":\"await app.sendKeyEvent(\\\"w\\\", \\\"up\\\"); globalThis.visits++; await win.getAccessibilityTree(); await win.click(\\\"0\\\"); inspect(JSON.stringify({ visits, app: app.appHandle, window: win.windowId, tree: await win.getAccessibilityTree(), bindings: Object.keys(tools) })); await win.toggleMouse(\\\"left\\\", \\\"down\\\"); await app.sendKeyEvent(\\\"d\\\", \\\"down\\\")\",\"description\":\"Reuse the retained application and window\"}"}} {"type":"tool/ptc-dispatch-start","data":{"rootCallId":"cua_reuse","parentCallId":"cua_reuse","subCallId":"cua_reuse:ptc:1","name":"cua","arguments":{"method":"sendKeyEvent","params":{"appHandle":"fixture-app","key":"w","direction":"up"}}}} {"type":"tool/ptc-dispatch","data":{"rootCallId":"cua_reuse","parentCallId":"cua_reuse","subCallId":"cua_reuse:ptc:1","name":"cua","arguments":{"method":"sendKeyEvent","params":{"appHandle":"fixture-app","key":"w","direction":"up"}},"isError":false,"content":[{"type":"text","text":"{\"dispatched\":true}"}]}} @@ -53,6 +53,7 @@ {"type":"agent/inbox/spliced","data":{"target":"next-step","start":0,"removedCount":1,"inserted":[]}} {"type":"step/start","data":{"turn":1,"step":3}} {"type":"user/message","data":{"content":[{"type":"text","text":"\nCUA inputs are still held:\n- Mouse left, appHandle \"fixture-app\", windowId \"7\" (window input).\n- Key \"d\", appHandle \"fixture-app\" (application input).\nThey remain pressed across programs and turns. Release them explicitly with sendKeyEvent(key, 'up') or toggleMouse(button, 'up') on the same target when no longer needed.\n"}],"source":{"kind":"cua-held-inputs","form":"notice","summary":"CUA inputs remain held"},"role":"user","id":"{{message:9}}"},"surfaceOp":"append"} -{"type":"assistant/message","data":{"turn":1,"step":3,"message":{"role":"assistant","content":[{"type":"text","text":"The retained application and window report Count: 2. The counter persisted across calls, and the program exposes only tools.cua. The screenshot was attached after the first call."}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:10}}"},"stream":[{"type":"chunk","time":1795057087322,"chunk":{"type":"block-start","index":0,"blockType":"text"}},{"type":"chunk","time":1795057087322,"chunk":{"type":"block-end","index":0,"block":{"type":"text","text":"The retained application and window report Count: 2. The counter persisted across calls, and the program exposes only tools.cua. The screenshot was attached after the first call."}}},{"type":"chunk","time":1795057087322,"chunk":{"type":"finish","reason":{"kind":"stop"}}}]},"surfaceOp":"append"} +{"type":"assistant/message","data":{"turn":1,"step":3,"message":{"role":"assistant","content":[{"type":"text","text":"The retained application and window report Count: 2. The counter persisted across calls, and the program exposes only tools.cua. The screenshot was attached after the first call."}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:10}}"},"stream":[{"type":"chunk","time":1795061771116,"chunk":{"type":"block-start","index":0,"blockType":"text"}},{"type":"chunk","time":1795061771116,"chunk":{"type":"block-end","index":0,"block":{"type":"text","text":"The retained application and window report Count: 2. The counter persisted across calls, and the program exposes only tools.cua. The screenshot was attached after the first call."}}},{"type":"chunk","time":1795061771116,"chunk":{"type":"finish","reason":{"kind":"stop"}}}]},"surfaceOp":"append"} {"type":"step/end","data":{"turn":1,"step":3}} {"type":"turn/end","data":{"turn":1,"reason":{"kind":"completed"}}} +{"type":"agent/inbox/spliced","data":{"target":"next-step","start":0,"inserted":[{"content":[{"type":"text","text":"\nCUA inputs were released during cleanup:\n- Key \"d\", appHandle \"fixture-app\" (application input).\n- Mouse left, appHandle \"fixture-app\", windowId \"7\" (window input).\nThese inputs are no longer held.\n"}],"source":{"kind":"cua-inputs-released","form":"notice","summary":"CUA inputs released"},"role":"user","id":"{{message:11}}"}]}} diff --git a/snapshots/session/cua-run-code/system-prompt.expected.md b/snapshots/session/cua-run-code/system-prompt.expected.md index d0d5cf3e23..7acc0f5667 100644 --- a/snapshots/session/cua-run-code/system-prompt.expected.md +++ b/snapshots/session/cua-run-code/system-prompt.expected.md @@ -86,7 +86,7 @@ Available at app or window level depending on the platform. - pressKey(key: string, modifiers?: Modifier[]) -> ActionResult — press and release one complete keystroke. For example pressKey('Tab', ['shift']) or pressKey('+'). Key names are platform-defined strings. Pass key and modifiers separately; do not pack them into a chord string. - sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. -In DSH, explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. MCP and other programs outside a DSH turn release remaining input before returning and report which inputs were automatically released. No reminder is added when there is nothing to report. Program failure, user stop, connection closure, and disposal release owned inputs together in reverse dispatch order. pressKey, typeText, click, and complete drag release their own inputs within the operation. +Explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. No reminder is added when none remain. Program failure, a received cancellation, connection closure, and disposal release owned inputs together in reverse dispatch order. A client pause between completed MCP calls is not observable by the server, so held input can remain pressed. pressKey, typeText, click, and complete drag release their own inputs within the operation. click, drag, and pressKey are convenience operations; sendKeyEvent, mouseMove, and toggleMouse are primitive operations. For complex action combinations, decompose convenience operations into sequences of primitive operations supported by the current platform. diff --git a/snapshots/session/ptc-script-retained/system-prompt.expected.md b/snapshots/session/ptc-script-retained/system-prompt.expected.md index a15bda60c7..37e5d1d56e 100644 --- a/snapshots/session/ptc-script-retained/system-prompt.expected.md +++ b/snapshots/session/ptc-script-retained/system-prompt.expected.md @@ -92,7 +92,7 @@ Available at app or window level depending on the platform. - pressKey(key: string, modifiers?: Modifier[]) -> ActionResult — press and release one complete keystroke. For example pressKey('Tab', ['shift']) or pressKey('+'). Key names are platform-defined strings. Pass key and modifiers separately; do not pack them into a chord string. - sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. For example W down, D down, D up, W up. A repeated 'down' for an ordinary held key sends one repeat without adding another hold. -In DSH, explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. MCP and other programs outside a DSH turn release remaining input before returning and report which inputs were automatically released. No reminder is added when there is nothing to report. Program failure, user stop, connection closure, and disposal release owned inputs together in reverse dispatch order. pressKey, typeText, click, and complete drag release their own inputs within the operation. +Explicit downs from sendKeyEvent and toggleMouse remain held across programs and turns until an explicit up releases them at their original recipient. After a successful run_code or cua_run_code, a system reminder lists any remaining keys and mouse buttons, their targets and input modes. No reminder is added when none remain. Program failure, a received cancellation, connection closure, and disposal release owned inputs together in reverse dispatch order. A client pause between completed MCP calls is not observable by the server, so held input can remain pressed. pressKey, typeText, click, and complete drag release their own inputs within the operation. click, drag, and pressKey are convenience operations; sendKeyEvent, mouseMove, and toggleMouse are primitive operations. For complex action combinations, decompose convenience operations into sequences of primitive operations supported by the current platform.