Merge pull request #8351 from deepseek-harness/feat/cua-windows/input-complete

feat(cua-windows): support single-key events and held-input mouse movement
This commit is contained in:
Huo Yaoyuan authored and GitHub committed 2026-11-12 17:54:21 +08:00
commit deb030335d
16 files changed
+48 -40

No files matched your search

@@ -46,6 +46,7 @@ Available at app or window level depending on the platform.
- typeText(text: string) -> ActionResult — type literal text at the app's current focus; line endings send Return and tabs send Tab.
- paste(text: string, options?: { format?: 'text' | 'html' }) -> ActionResult — deliver text or HTML through the app's Paste command, restoring prior clipboard contents unless another writer changes them; a Paste failure is surfaced without substituting typeText, and PASTE_NOT_CONSUMED means inspect before any retry.
- 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.
Raw tools use { method, params }: include appHandle for app calls and windowId for window calls, and use snapshotId with elementId for element routes. getAccessibilityTree maps to getState; getWindow has no raw method; getWindows maps to listWindows; getScreenshot maps to screenshot; cua.getState maps to listApps; every other named operation uses the same method name.
@@ -8,6 +8,7 @@ function operationGuidance(treeAdvice: string): string {
const methodDetails = new Map<string, string>([
['cua.listApps', 'Each row represents one running process. To select one of several instances with the same name or bundle ID, pass String(row.pid) to cua.getApp.'],
['cua.findApps', 'Running installation matches include their process ID. Stopped matches have no pid.'],
['sendKeyEvent', "Send 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients."],
['getAccessibilityTree', `macOS accepts maxElements up to 100000 and maxDepth up to 512. If the tree is truncated, select a narrower window or raise the reported limit on the next read. ${treeAdvice} Use element ids from the file only while that observation is current.`],
['mouseMove', 'Default hover requires both AXShowAlternateUI and AXShowDefaultUI on an enabled element or ancestor. Without that route, HOVER_UNAVAILABLE is returned before sending input. Physical movement requires an unobscured foreground target. Explain any necessary activation and observe the target again.'],
['click', 'click is a Window method: select a window with const win = await app.getWindow(windowId), then call win.click(target). For a background control’s default action, use app.invoke(id). For a mouse click on a background app, call app.activate() first and re-read the target. Both target forms send mouse-down and mouse-up events. click(id) uses the center of the full element bounds. If that center is outside the window, take a fresh win.getScreenshot() and use click([x, y]) on a visible part of the control in screenshot pixels. A background app can ignore the events even when dispatched is true. Verify the expected effect, such as a changed selection, before typing or retrying.'],
@@ -15,8 +16,6 @@ function operationGuidance(treeAdvice: string): string {
return `${PLATFORM_GUIDANCE}
${COMMON_GUIDANCE.replace(/^- ([\w.]+)\(.*$/gm, (entry, method: string) => {
if (method === 'pressKey') return `${entry}
- sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients.`
const detail = methodDetails.get(method)
return detail ? `${entry} ${detail}` : entry
})}`
@@ -39,7 +39,9 @@ it('states the macOS accessibility, keyboard, and mouse levels', () => {
const pressKey = GUIDANCE.split('\n').find(line => line.startsWith('- pressKey('))
expect(GUIDANCE).toContain("sendKeyEvent(key: string, direction: 'down' | 'up')")
expect(GUIDANCE).toContain('returns, throws, or the user pauses')
expect(COMMON_GUIDANCE).not.toContain('sendKeyEvent(')
const sharedKeyEvent = COMMON_GUIDANCE.split('\n').find(line => line.startsWith('- sendKeyEvent('))
expect(sharedKeyEvent).toBeDefined()
expect(GUIDANCE.split('\n').find(line => line.startsWith('- sendKeyEvent('))).toContain(sharedKeyEvent)
expect(pressKey).toBe(COMMON_GUIDANCE.split('\n').find(line => line.startsWith('- pressKey(')))
expect(GUIDANCE).toContain('W down, D down, D up, W up')
const hover = GUIDANCE.split('\n').find(line => line.startsWith('- mouseMove('))
@@ -60,13 +62,13 @@ it('enumerates every available method once in its catalog entry', () => {
'app.show(', 'window.show(',
...accessibilityNames.map(name => `${name}(`),
...windowNames.filter(name => name !== 'windowId').map(name => `${name}(`),
...['typeText', 'paste', 'pressKey'].map(name => `${name}(`),
...['typeText', 'paste', 'pressKey', 'sendKeyEvent'].map(name => `${name}(`),
]
for (const catalog of [COMMON_GUIDANCE, GUIDANCE]) {
for (const catalog of [COMMON_GUIDANCE, GUIDANCE, PROGRAM_GUIDANCE]) {
for (const signature of signatures) expect(catalog.split('\n').filter(line => line.startsWith(`- ${signature}`))).toHaveLength(1)
}
expect(signatures).toHaveLength(24)
expect(new Set(signatures.map(signature => signature.slice(signature.indexOf('.') + 1, -1))).size).toBe(23)
expect(signatures).toHaveLength(25)
expect(new Set(signatures.map(signature => signature.slice(signature.indexOf('.') + 1, -1))).size).toBe(24)
expect(COMMON_GUIDANCE).toContain('app.appHandle')
expect(COMMON_GUIDANCE).toContain('window.windowId')
})
@@ -9,8 +9,8 @@
en: a1211ae1bdb841b5
zh: 47b1b00b712658c5
/deepseek-ai-dsh-cua-windows/summary:
en: 3d01094229f39847
zh: 6ef07286fab57de1
en: 81514122b1550aae
zh: 05cfa346553c5283
/deepseek-ai-dsh-cua-windows/table-of-contents:
en: 8ee204b4021505b9
zh: 67040b79fcd9643b
@@ -45,8 +45,8 @@
en: db3e2957041fafbb
zh: 34f953887dff37f7
/deepseek-ai-dsh-cua-windows/known-limitations-and-deferred-work:
en: 3770ae4e72857d1f
zh: 93471f443c5a9284
en: 93e47def8054cd3f
zh: 20c19872c775ea98
/deepseek-ai-dsh-cua-windows/known-limitations-and-deferred-work/dev-note:
en: 0a1253c6f7b5e8b9
zh: 9f56528562c7c914
+2 -2
View File
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
## Summary
Discover Windows applications, obtain consent, then inspect and operate their windows through the shared [Computer Use API](../cua/README.md). Application selection, window selection, accessibility observation, and foreground activation are separate actions. Use this page for Windows-specific semantics and safe interaction rules.
Discover Windows applications, obtain consent, then inspect and operate their windows through the shared [Computer Use API](../cua/README.md). Simulated keyboard and mouse input are available, including typing, pasting, key presses, individual key events, pointer movement, clicking, scrolling, and dragging. Application selection, window selection, accessibility observation, and foreground activation are separate actions. Use this page for Windows-specific semantics and safe interaction rules.
## Table of Contents
@@ -82,7 +82,7 @@ Inspected results append to model history. Retaining an App, Window, or returned
- The helper does not check each key or button release during cleanup. If an input remains held after a failure, release it manually before continuing.
- Helper identity hashes only the exe. Different DLLs with the same apphost can reuse the old service. Stop Hosts using the same output directory before rebuilding to avoid locked files.
- The Windows handshake requires a positive `maxClickHoldMs`. With zero, it fails with `INVALID_CONFIG` before ordinary clicks or status queries can run.
- `findApps`, application launch, app-level accessibility, and held-key `sendKeyEvent` are unavailable. Ask the user to open the required application or window.
- `findApps`, application launch, and app-level accessibility are unavailable. Ask the user to open the required application or window.
- Applications with `isRunning: false` can be discovered, but the current `getApp` flow attempts an unsupported launch and fails with `UNSUPPORTED`. Open a window before selecting such an application.
- Observation and input require an accessible, unlocked interactive Windows session. Screenshots require Windows Graphics Capture support; a listed window can still be unavailable for capture or input.
- Application consent does not offer an **Always allow** grant. Another conversation needs its own consent.
@@ -9,7 +9,7 @@ kind: "package-reference"
## 概述
通过共享的 [Computer Use API](../cua/README.zh.md) 发现 Windows 应用、获取授权,然后观察和操作应用窗口。选择应用、选择窗口、读取辅助功能树和前台激活是彼此独立的动作。本页说明 Windows 平台的接口语义与安全交互规范。
通过共享的 [Computer Use API](../cua/README.zh.md) 发现 Windows 应用、获取授权,然后观察和操作应用窗口。模拟键盘和鼠标输入已可用,支持文本输入、粘贴、按键、独立按下与抬起事件、鼠标移动、点击、滚动和拖拽。选择应用、选择窗口、读取辅助功能树和前台激活是彼此独立的动作。本页说明 Windows 平台的接口语义与安全交互规范。
## 目录
@@ -82,7 +82,7 @@ kind: "package-reference"
- 清理输入时,helper 不检查每个按键或鼠标按钮的释放结果。操作失败后如有按键或按钮仍处于按下状态,请先手动释放。
- helper 的身份摘要只覆盖 exe。同一 apphost 搭配不同 DLL 时可能复用旧服务。重新构建前请先关闭使用同一输出目录的 Host,避免文件被占用。
- Windows 握手要求 `maxClickHoldMs` 为正整数。设为 0 会使连接以 `INVALID_CONFIG` 失败,连普通点击和状态查询也不可用。
- 不支持 `findApps`、启动应用、应用级辅助功能和持续按键 `sendKeyEvent`。请让用户打开所需应用或窗口。
- 不支持 `findApps`、启动应用和应用级辅助功能。请让用户打开所需应用或窗口。
- 可以发现 `isRunning: false` 的应用,但当前 `getApp` 流程会尝试未支持的启动操作,并以 `UNSUPPORTED` 失败。选择这类应用前应先打开窗口。
- 观察和输入需要可访问、未锁定的交互式 Windows 会话。截图需要 Windows Graphics Capture 支持;列出的窗口仍可能无法截图或接收输入。
- 应用授权不提供 **Always allow(始终允许)** 选项。其他会话需要分别获得授权。
@@ -20,9 +20,9 @@ internal sealed class DesktopExecutor(MtaDispatcher mta, StaDispatcher sta) : IA
private readonly ClipboardPaste clipboard = new();
private readonly SemaphoreSlim queue = new(1);
private static object ActionResult(nint before) => new
private static object ActionResult(nint before, bool dispatched = true) => new
{
dispatched = true,
dispatched,
foregroundChanged = before == 0 || Win32.GetForegroundWindow() == 0 ? (bool?)null : before != Win32.GetForegroundWindow(),
};
private static string String(JsonElement value, string key) => value.GetProperty(key).GetString()!;
@@ -139,7 +139,11 @@ internal sealed class DesktopExecutor(MtaDispatcher mta, StaDispatcher sta) : IA
return ActionResult(foreground);
}
case "sendKeyEvent":
throw new NativeFailure("UNSUPPORTED", "Held key events are not supported on current platform.");
{
var target = Selected(app, parameters, context);
var dispatched = Input.KeyEvent(app, target, String(parameters, "key"), String(parameters, "direction"), context);
return ActionResult(foreground, dispatched);
}
case "paste":
{
var target = Selected(app, parameters, context);
@@ -10,9 +10,7 @@ internal static class Input
private const ushort VkControl = 0x11;
private const ushort VkAlt = 0x12;
private const ushort VkLeftWin = 0x5B;
private const ushort VkRightWin = 0x5C;
private static readonly int[] ModifierKeys = [VkShift, VkControl, VkAlt, VkLeftWin, VkRightWin];
private static ushort Modifier(string name) => name switch
{
"shift" => VkShift, "ctrl" => VkControl, "alt" => VkAlt, "win" => VkLeftWin,
@@ -32,16 +30,9 @@ internal static class Input
private static void Release(Win32.Input input) => Win32.SendInput(1, [input], Marshal.SizeOf<Win32.Input>());
private static void RequireIdleModifiers()
{
if (ModifierKeys.Concat([0x01, 0x02, 0x04, 0x05, 0x06]).Any(key => (Win32.GetAsyncKeyState(key) & 0x8000) != 0))
throw new NativeFailure("INPUT_BUSY", "A modifier or mouse button is already held; wait for the user to release it before sending input");
}
private static void WithModifiers(IEnumerable<string> modifiers, Action action)
{
var keys = modifiers.Select(KeyChord.NormalizeModifier).Select(Modifier).Distinct().ToArray();
RequireIdleModifiers();
var attempted = new List<ushort>();
try
{
@@ -51,9 +42,11 @@ internal static class Input
finally { foreach (var key in attempted.AsEnumerable().Reverse()) Release(Keyboard(key, flags: 2u | (key == VkLeftWin ? 1u : 0))); }
}
private static (ushort Key, bool Extended, string[] Modifiers) ResolveKey(string name)
private static (ushort Key, bool Extended, string[] Modifiers) ResolveKey(string name, bool includeModifiers = false)
{
var key = name.ToLowerInvariant();
if (includeModifiers && key is ("shift" or "ctrl" or "control" or "alt" or "win" or "fn"))
return (Modifier(KeyChord.NormalizeModifier(key)), key == "win", []);
if (key.StartsWith("kp_", StringComparison.Ordinal))
{
var keypad = key[3..];
@@ -90,6 +83,18 @@ internal static class Input
return ((ushort)(mapped & 0xFF), false, modifiers.ToArray());
}
internal static bool KeyEvent(AppState app, WindowState window, string name, string direction, RequestContext context)
{
Windows.RequireForeground(app, window, context);
var key = ResolveKey(name, includeModifiers: true);
if (key.Modifiers.Length != 0)
throw new NativeFailure("UNSUPPORTED", "This key requires modifiers in the target keyboard layout; send each modifier and the base key separately");
var down = direction == "down";
if (((Win32.GetAsyncKeyState(key.Key) & 0x8000) != 0) == down) return false;
Send(Keyboard(key.Key, flags: (key.Extended ? 1u : 0) | (down ? 0u : 2u)));
return true;
}
internal static void Press(AppState app, WindowState window, string key, string[] modifiers, RequestContext context)
{
Windows.RequireForeground(app, window, context);
@@ -107,11 +112,9 @@ internal static class Input
internal static async Task Type(AppState app, WindowState window, string text, RequestContext context)
{
if (text.Contains('\0')) throw new NativeFailure("INVALID_ARGUMENT", "Text input cannot contain NUL");
RequireIdleModifiers();
for (var index = 0; index < text.Length; index++)
{
Windows.RequireForeground(app, window, context);
RequireIdleModifiers();
var character = text[index];
if (character is '\r' or '\n' or '\t')
{
@@ -154,7 +157,6 @@ internal static class Input
{
var point = WindowState.Point(window.RequireObservation(app, context), x, y);
Hit(app, window, point, context);
RequireIdleModifiers();
if (!Win32.GetCursorPos(out var before)) throw new NativeFailure("INPUT_UNAVAILABLE", "The current pointer position is unavailable");
Send(Move(point));
return new { dispatched = true, hoverRoute = "system-pointer", systemPointerMoved = before.X != point.X || before.Y != point.Y };
@@ -184,7 +186,6 @@ internal static class Input
var flags = Button(button);
var keys = modifiers.Select(KeyChord.NormalizeModifier).Select(Modifier).Distinct().ToArray();
Hit(app, window, point, context);
RequireIdleModifiers();
var attempted = new List<ushort>();
var buttonAttempted = false;
try
@@ -215,7 +216,6 @@ internal static class Input
{
var point = WindowState.Point(window.RequireObservation(app, context), x, y);
Hit(app, window, point, context);
RequireIdleModifiers();
uint lines = 1, columns = 1;
if (deltaY != 0 && (!Win32.SystemParametersInfo(0x0068, 0, out lines, 0) || lines == uint.MaxValue || lines == 0)
|| deltaX != 0 && (!Win32.SystemParametersInfo(0x006C, 0, out columns, 0) || columns == 0))
@@ -235,7 +235,6 @@ internal static class Input
Hit(app, window, from, context);
var flags = Button(button);
var keys = modifiers.Select(KeyChord.NormalizeModifier).Select(Modifier).Distinct().ToArray();
RequireIdleModifiers();
var attempted = new List<ushort>();
var buttonAttempted = false;
try
@@ -2,7 +2,7 @@
import { COMMON_GUIDANCE } from '@deepseek-ai/dsh-cua/guidance'
/** Windows operation levels, application selectors, and input availability. */
export const PLATFORM_GUIDANCE = 'Windows: accessibility tree operations are available only at window level. Simulated mouse and keyboard input are incomplete and should not be used yet. Window screenshots remain available. pressKey, click, and drag accept ctrl (or control), alt, and shift. Only click and drag accept win.'
export const PLATFORM_GUIDANCE = 'Windows: accessibility tree operations are available only at window level. Simulated mouse and keyboard input are available at window level. Supported modifiers: ctrl, alt, shift, win. control is an alias for ctrl.'
const methodDetails = new Map<string, string>([
['cua.getApp', 'Windows accepts an exact AUMID returned by listApps or an existing absolute .exe path, including an executable absent from listApps. Display names and PIDs are not alternative selectors. Selection uses the existing application consent flow and starts the application only when it is not running.'],
@@ -15,7 +15,7 @@ const CAPABILITIES: CuaStartupCapabilities = {
methods: [
'getCapabilities', 'listApps', 'getApp', 'activate', 'show', 'listWindows', 'getState',
'listActions', 'performAction', 'invoke', 'mouseMove', 'click', 'setValue', 'selectText',
'typeText', 'paste', 'pressKey', 'scroll', 'drag', 'screenshot',
'typeText', 'paste', 'pressKey', 'sendKeyEvent', 'scroll', 'drag', 'screenshot',
],
appLevelAccessibility: false,
keyboard: ['window'],
@@ -46,9 +46,10 @@ it('uses an absolute fixture without compiling and disposes the Host runtime', a
expect(native.architecture).not.toHaveBeenCalled()
expect(backend.getGuidance('raw')).toBe(GUIDANCE)
expect(backend.getGuidance('standalone')).toBe(GUIDANCE)
expect(backend.getGuidance('raw')).toContain('Only click and drag accept win.')
expect(backend.permissionParameters('requestPermission', 'accessibility', 'en')).toEqual({ permission: 'accessibility' })
expect(backend.capabilities).toMatchObject({ platform: 'windows', appLevelAccessibility: false, keyboard: ['window'] })
expect(backend.capabilities.methods).toContain('sendKeyEvent')
expect(backend.sendKeyEvent).toBeUndefined()
const channel = { marker: 'native stream' }
native.connect.mockReturnValue(channel)
const options = { ...config, helperPath: backend.helperPath, cwd: process.cwd() }
@@ -51,6 +51,7 @@ Available at app or window level depending on the platform.
- typeText(text: string) -> ActionResult — type literal text at the app's current focus; line endings send Return and tabs send Tab.
- paste(text: string, options?: { format?: 'text' | 'html' }) -> ActionResult — deliver text or HTML through the app's Paste command, restoring prior clipboard contents unless another writer changes them; a Paste failure is surfaced without substituting typeText, and PASTE_NOT_CONSUMED means inspect before any retry.
- 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.
Raw tools use { method, params }: include appHandle for app calls and windowId for window calls, and use snapshotId with elementId for element routes. getAccessibilityTree maps to getState; getWindow has no raw method; getWindows maps to listWindows; getScreenshot maps to screenshot; cua.getState maps to listApps; every other named operation uses the same method name.`
@@ -81,7 +81,7 @@ Available at app or window level depending on the platform.
- typeText(text: string) -> ActionResult — type literal text at the app's current focus; line endings send Return and tabs send Tab.
- paste(text: string, options?: { format?: 'text' | 'html' }) -> ActionResult — deliver text or HTML through the app's Paste command, restoring prior clipboard contents unless another writer changes them; a Paste failure is surfaced without substituting typeText, and PASTE_NOT_CONSUMED means inspect before any retry.
- 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 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients.
- sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. Send 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients.
Raw tools use { method, params }: include appHandle for app calls and windowId for window calls, and use snapshotId with elementId for element routes. getAccessibilityTree maps to getState; getWindow has no raw method; getWindows maps to listWindows; getScreenshot maps to screenshot; cua.getState maps to listApps; every other named operation uses the same method name.
@@ -83,7 +83,7 @@ Available at app or window level depending on the platform.
- typeText(text: string) -> ActionResult — type literal text at the app's current focus; line endings send Return and tabs send Tab.
- paste(text: string, options?: { format?: 'text' | 'html' }) -> ActionResult — deliver text or HTML through the app's Paste command, restoring prior clipboard contents unless another writer changes them; a Paste failure is surfaced without substituting typeText, and PASTE_NOT_CONSUMED means inspect before any retry.
- 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 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients.
- sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. Send 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients.
Raw tools use { method, params }: include appHandle for app calls and windowId for window calls, and use snapshotId with elementId for element routes. getAccessibilityTree maps to getState; getWindow has no raw method; getWindows maps to listWindows; getScreenshot maps to screenshot; cua.getState maps to listApps; every other named operation uses the same method name.
@@ -79,6 +79,7 @@ Available at app or window level depending on the platform.
- typeText(text: string) -> ActionResult — type literal text at the app's current focus; line endings send Return and tabs send Tab.
- paste(text: string, options?: { format?: 'text' | 'html' }) -> ActionResult — deliver text or HTML through the app's Paste command, restoring prior clipboard contents unless another writer changes them; a Paste failure is surfaced without substituting typeText, and PASTE_NOT_CONSUMED means inspect before any retry.
- 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.
Raw tools use { method, params }: include appHandle for app calls and windowId for window calls, and use snapshotId with elementId for element routes. getAccessibilityTree maps to getState; getWindow has no raw method; getWindows maps to listWindows; getScreenshot maps to screenshot; cua.getState maps to listApps; every other named operation uses the same method name.
@@ -83,7 +83,7 @@ Available at app or window level depending on the platform.
- typeText(text: string) -> ActionResult — type literal text at the app's current focus; line endings send Return and tabs send Tab.
- paste(text: string, options?: { format?: 'text' | 'html' }) -> ActionResult — deliver text or HTML through the app's Paste command, restoring prior clipboard contents unless another writer changes them; a Paste failure is surfaced without substituting typeText, and PASTE_NOT_CONSUMED means inspect before any retry.
- 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 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients.
- sendKeyEvent(key: string, direction: 'down' | 'up') -> ActionResult — send one key-down or key-up event; key accepts a single key name, including a modifier. Send 'down' to hold a key across tool calls in one program, for example W down, D down, D up, W up. Holding a key on a physical keyboard can produce repeated key-down events after a delay. To send one such repeat for a non-modifier key this run already holds, send 'down' again. Each call posts one event. A control can filter repeats. Use the app's response to decide whether and when to repeat or release the key. When this program returns, throws, or the user pauses it, macOS releases only its remaining keys at their original recipients.
Raw tools use { method, params }: include appHandle for app calls and windowId for window calls, and use snapshotId with elementId for element routes. getAccessibilityTree maps to getState; getWindow has no raw method; getWindows maps to listWindows; getScreenshot maps to screenshot; cua.getState maps to listApps; every other named operation uses the same method name.