dsh-agent-desktop
把 agent-desktop CLI 封成 DSH 插件,让 Agent 直接调用本机 GUI 工具(不走沙盒子进程)。
插件本身不含 UI 自动化逻辑,只做:参数校验 → 调用 CLI → 解析 JSON 信封 → 返回工具结果。
前置:安装 CLI
npm i -g agent-desktop
Windows 上插件会优先调用 agent-desktop.cmd(避免命中被执行策略拦截的 .ps1)。
工具(9 个)
| 工具 | 说明 |
|---|---|
ad_status |
平台、权限、支持的 surface、CLI 版本 |
ad_list_windows |
列出窗口(可选 app 过滤) |
ad_snapshot |
抓无障碍树;返回 snapshotId / refCount / tree |
ad_find |
在窗口内按 name 子串或 role 搜索元素 |
ad_click |
点击 @snapshot:eN ref |
ad_type |
向元素输入文本 |
ad_press |
发送按键(escape、ctrl+c…) |
ad_launch |
启动应用;activate 可等待窗口 |
ad_close_app |
优雅关闭应用 |
推荐循环
ad_list_windows/ad_snapshot观察- 用返回的
@s…:eN调用ad_click/ad_type - UI 变化后 重新
ad_snapshot(ref 会过期;插件不会自动重试,避免误点)
ad_snapshot 的 render 只打摘要(snapshotId、refCount、前 20 个有名字的元素);完整 tree 在结果的 data 里。
默认不加 --headed,避免抢焦点。需要物理输入时由调用方显式传 headed: true。
安装
dsh plugin add dsh-agent-desktop
本地路径 / tgz:
- DSH → 设置 → 插件管理 → 安装
- 填本仓库绝对路径,或
node tools/release.mjs产出的 tgz - 重启 DSH
配置
| 字段 / 环境变量 | 说明 |
|---|---|
cliPath(插件配置) |
agent-desktop 可执行文件绝对路径 |
AGENT_DESKTOP_CLI |
同上,环境变量 |
未配置时自动探测:%APPDATA%\npm\agent-desktop.cmd、常见 Unix 路径、再查 PATH。
Windows 注意
- 必须走
.cmd;裸agent-desktop可能落到.ps1被策略拦住 - PowerShell 里手动测 CLI 时,ref 要加引号:
agent-desktop click '@s…:e1'(@是 splat) - 不提供打开开始菜单等 shell surface 的工具(跨进程易失效)
开发
node --check lib/index.js
node test/selftest.mjs
node tools/release.mjs
版本:0.1.0 · 协议:MIT