diff --git a/packages/experimental/cua/README.i18n.yaml b/packages/experimental/cua/README.i18n.yaml index 6d828d4c41..3fa64fe298 100644 --- a/packages/experimental/cua/README.i18n.yaml +++ b/packages/experimental/cua/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 7b30b973a849247d /deepseek-ai-dsh-experimental-cua/use-this-package: - en: 2bd2072854d093d5 - zh: 752716da235b53d8 + en: ecfefc8c313586d1 + zh: 263af55e29462082 /deepseek-ai-dsh-experimental-cua/use-this-package/connect-an-external-execution-environment: en: dc2f1cd930a6b6ba zh: 12b4f57fa745afbf diff --git a/packages/experimental/cua/README.md b/packages/experimental/cua/README.md index e975e3cfbd..d15ca4770c 100644 --- a/packages/experimental/cua/README.md +++ b/packages/experimental/cua/README.md @@ -47,6 +47,8 @@ The dump command checks profile composition without a model request. For a real The [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-experimental-cua) lists all fields. Native tool calls use `{method, params}`; the complete method-specific schema is exposed to the model. For example, `getApp` returns the `appHandle` needed by `listWindows`, `getState` and input operations. +Key chords use `+` between modifiers and the key. Use `+` for the plus key, `cmd++` for Command-plus, or the key name `plus`; an unfinished chord such as `cmd+` is rejected. + ### Connect an external execution environment To run through persistent PTC, add `--patch packages/experimental/cua/examples/persistent-ptc.cordis.yml` after the macOS overlay. This provider keeps variables for the live Agent and runs without a file sandbox. The caller imports the bridge and supplies the current authorized `tools.cua` binding. This integration snippet assumes an execution host has supplied `tools`; the package does not install a global object or keep variables alive: diff --git a/packages/experimental/cua/README.zh.md b/packages/experimental/cua/README.zh.md index 2fbf4a8bf4..d4232b6cc7 100644 --- a/packages/experimental/cua/README.zh.md +++ b/packages/experimental/cua/README.zh.md @@ -47,6 +47,8 @@ pnpm dsh headless --patch packages/experimental/cua/examples/macos.cordis.yml -- [配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-experimental-cua)列出全部字段。原生工具调用使用 `{method, params}`,模型可以看到每个方法的完整参数定义。例如,`getApp` 返回 `listWindows`、`getState` 和输入操作所需的 `appHandle`。 +组合键用 `+` 分隔修饰键与按键。加号键写作 `+`,Command 加号写作 `cmd++`,也可以使用键名 `plus`;`cmd+` 这类缺少按键的输入会被拒绝。 + ### 接入外部执行环境 使用 persistent PTC 时,在 macOS 配置后追加 `--patch packages/experimental/cua/examples/persistent-ptc.cordis.yml`。该 provider 为存活的 Agent 保留变量,不启用文件沙箱。调用方导入适配模块,并提供当前执行中已授权的 `tools.cua` 绑定。下面的接入代码假设执行宿主已提供 `tools`;本包不安装全局对象,也不负责保留变量: diff --git a/packages/experimental/cua/src/api.ts b/packages/experimental/cua/src/api.ts index d7e774086e..beeaa53f80 100644 --- a/packages/experimental/cua/src/api.ts +++ b/packages/experimental/cua/src/api.ts @@ -7,7 +7,11 @@ export type * from './types.ts' function keyChord(chord: string): { key: string; modifiers: string[] } { const parts = chord.split('+') - const key = parts.pop() + let key = parts.pop() + if (key === '' && parts.at(-1) === '') { + key = '+' + parts.pop() + } if (!key) throw new Error('A key chord must end with a key name') const names: Record = { cmd: 'command', command: 'command', super: 'command', Super_L: 'command', Super_R: 'command', diff --git a/packages/experimental/cua/src/types.ts b/packages/experimental/cua/src/types.ts index 92dbc2b167..c66a2eb0b2 100644 --- a/packages/experimental/cua/src/types.ts +++ b/packages/experimental/cua/src/types.ts @@ -155,7 +155,7 @@ export interface CuaApp extends CuaSurface { paste(text: string): Promise /** * Send a key/chord at current focus. - * @param key - xdotool-style chord such as super+c or shift+Tab. + * @param key - xdotool-style chord such as super+c, shift+Tab, + or cmd++; plus is also a key name. * @returns dispatch evidence. */ pressKey(key: string): Promise diff --git a/packages/experimental/cua/tests/api.spec.ts b/packages/experimental/cua/tests/api.spec.ts index f878a53ac9..248486257c 100644 --- a/packages/experimental/cua/tests/api.spec.ts +++ b/packages/experimental/cua/tests/api.spec.ts @@ -326,6 +326,8 @@ describe('input actions', () => { ['negative drag point', app => app.drag([0, 0], [-1, 3])], ['empty chord', app => app.pressKey('')], ['missing key', app => app.pressKey('super+')], + ['empty plus modifier', app => app.pressKey('++')], + ['extra plus delimiter', app => app.pressKey('cmd+++')], ['unknown modifier', app => app.pressKey('unknown+a')], ] it.each(invalidActions)('rejects %s without invoking native input', async (_label, run) => { @@ -336,6 +338,19 @@ describe('input actions', () => { expect(f.dispatch).toHaveBeenCalledTimes(calls) }) + it.each<[string, string, string[]]>([ + ['+', '+', []], + ['cmd++', '+', ['command']], + ['ctrl+shift++', '+', ['control', 'shift']], + ['cmd+plus', 'plus', ['command']], + ['plus', 'plus', []], + ])('dispatches the plus-key chord %s', async (chord, key, modifiers) => { + const f = fixture() + const app = await f.api.getApp('Editor') + await app.pressKey(chord) + expect(f.dispatch).toHaveBeenLastCalledWith({ method: 'pressKey', params: { appHandle: 'app-17', key, modifiers } }) + }) + it('passes literal text and keys to the selected app identity', async () => { const f = fixture() const app = await f.api.getApp('Editor')