Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/operations/desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ Default user data:

For screen, keyboard, or mouse automation, grant the app that actually runs AgentDock the required permissions under **System Settings → Privacy & Security**.

### Verify desktop automation readiness

The [Desktop Skill](https://github.com/uvwt/agentdock-skills/tree/main/skills/desktop)
provides `skill_action=status` or `skill_action=observe` with `action=preflight`.
Run the installed Skill through AgentDock's `exec_command` path using the exact
Skill reference returned by `agentdock_context`. Checks from a separate SSH or
terminal process do not prove the AgentDock process has permission.

When the installed Skill returns `readiness`, it reports `screen_capture`,
`apple_events`, and `accessibility` separately as `passed`, `failed`, or
`not_checked`. Screen capture must produce a PNG header with nonzero
dimensions. Accessibility checks read actual window properties from the
frontmost application. Listing System Events processes alone cannot establish
AX access. Temporary preflight captures are removed and window names are not
returned.

All three checks run by default. Skipping one with `check_screenshot=false`,
`check_applescript=false`, or `check_accessibility=false` leaves it unverified
and makes overall `ok` false. These checks read state without injecting input;
a pass does not guarantee every target application or input action succeeds.
If an older Skill omits `readiness` or `accessibility_ok`, update it or treat
Accessibility as unverified.

If Apple Events passes but real AX reading fails, verify Accessibility
permission for the current AgentDock process and an active graphical session.
After an update, permission switches may refer to an older code identity.
Reauthorize the current process and repeat the real check. A System Events
restart can interrupt other automation and requires user confirmation.
Preflight does not reset TCC, change permissions, or restart system processes.

The graphical app can update AgentDock directly. Command-line installations can use:

```bash
Expand Down
38 changes: 38 additions & 0 deletions docs/reference/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,44 @@ AgentDock exposes tools to connected AI clients over MCP. The tools visible on a
| `session_observe` | Inspect long-running command sessions |
| `session_act` | Send input to or stop command sessions |

### Replay command output after a disconnect

When the connected runtime's `session_observe` schema includes `action=read`,
use it to retrieve output with independent client-owned byte offsets. Older
runtimes only expose `list` and `status`; inspect `tools/list` before using this
action.

Start a command with `exec_command` and `execution_mode=async`, then read its
returned session:

```json
{
"action": "read",
"session_id": "session-...",
"stdout_offset": 0,
"stderr_offset": 0,
"max_output_bytes": 65536
}
```

After receiving a page, pass its `stdout_next_offset` and `stderr_next_offset`
as the next request's offsets. Retry the same offsets if a response is lost.
Each stream has its own page limit. Read requires `max_output_bytes` of at
least four bytes and preserves UTF-8 page boundaries. After the process exits,
continue until both `stdout_truncated` and `stderr_truncated` are false.

`*_missed_bytes` report output evicted before the requested offset, or bytes
skipped when the offset starts inside a UTF-8 character. Offsets count raw
process bytes before JSON encoding. The first read starts at zero by default
and can include output already returned by `exec_command`.

Read leaves the legacy observation cursors and completed session intact.
Output remains in memory, bounded to four MiB per stream; completed sessions
are eligible for eviction after one hour or when the existing session count
limit is reached. An AgentDock restart loses those sessions. The existing
`status` and mutation actions keep their behavior and can consume output or
remove the session, so use `read` consistently for retryable observation.

## Skills, Plugins, and external MCP

| Tool | Purpose | Main actions |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ sh /tmp/agentdock-install.sh --register-service

需要屏幕、键盘或鼠标自动化时,只给实际运行 AgentDock 的应用授予 **系统设置 → 隐私与安全性** 中对应的权限。

### 验证桌面自动化是否可用

[Desktop Skill](https://github.com/uvwt/agentdock-skills/tree/main/skills/desktop)
支持 `skill_action=status`,或 `skill_action=observe` 搭配 `action=preflight`。
使用 `agentdock_context` 返回的准确 Skill 引用,通过 AgentDock 的
`exec_command` 执行已安装的 Skill。单独从 SSH 或终端检查通过,不能证明
AgentDock 进程拥有权限。

当已安装的 Skill 返回 `readiness` 时,分别用 `passed`、`failed`、`not_checked`
报告 `screen_capture`、`apple_events` 和 `accessibility`。截图必须产生尺寸
非零的 PNG 文件头;Accessibility 检查实际读取前台应用的窗口属性。仅列出
System Events 进程不能证明 AX 可用。临时检查截图会删除,窗口名称不会返回。

三项默认全部检查。用 `check_screenshot=false`、`check_applescript=false` 或
`check_accessibility=false` 跳过任一项时,该项仍未验证,整体 `ok` 为 `false`。
这些检查只读取状态,不注入输入;通过不代表每个目标应用或输入动作都会成功。
旧 Skill 若没有 `readiness` 或 `accessibility_ok`,应更新 Skill,或将
Accessibility 视为未验证。

Apple Events 通过但真实 AX 读取失败时,检查当前 AgentDock 进程的辅助功能授权
和活动图形会话。升级后系统权限开关可能仍关联旧的代码身份;重新授权当前进程,
再做真实检查。重启 System Events 可能中断其他自动化,应先获得用户确认。
Preflight 不重置 TCC、不修改权限、不重启系统进程。

图形客户端可以直接更新。命令行安装也可以使用:

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ AgentDock 通过 MCP 向 AI 客户端提供工具。具体连接能看到哪些
| `session_observe` | 查看长时间运行的命令会话 |
| `session_act` | 向命令会话输入内容或终止会话 |

### 断线后重读命令输出

当当前运行端的 `session_observe` Schema 包含 `action=read` 时,可以使用客户端
独立保存的字节偏移读取输出。旧版只提供 `list` 和 `status`,调用前先检查
`tools/list`。

通过 `exec_command` 的 `execution_mode=async` 启动命令,再读取返回的会话:

```json
{
"action": "read",
"session_id": "session-...",
"stdout_offset": 0,
"stderr_offset": 0,
"max_output_bytes": 65536
}
```

收到一页后,把结果中的 `stdout_next_offset` 和 `stderr_next_offset` 作为下次
请求的偏移;响应丢失时重试原偏移。每条输出流分别受分页上限约束;`read` 要求
`max_output_bytes` 至少为 4,并保持 UTF-8 字符分页边界。命令退出后继续读取,
直到 `stdout_truncated` 和 `stderr_truncated` 都为 `false`。

`*_missed_bytes` 表示请求位置之前的输出已被淘汰,或偏移落在 UTF-8 字符中间而
跳过了部分字节。偏移按 JSON 编码前的原始进程输出字节计算。首次读取默认从零
开始,可能包含 `exec_command` 已返回的输出。

`read` 不推进旧的观察游标,也不删除已完成会话。每条输出流仍只保留最多 4 MiB;
已完成会话在一小时后或触及既有会话数量上限时可能被淘汰。会话只存在于内存,
AgentDock 重启后不保留。既有 `status` 和写入、停止等动作仍可能消费输出或删除
会话;需要支持重试时,应持续使用 `read` 观察。

## Skill、Plugin 与外部 MCP

| 工具 | 用途 | 主要 action |
Expand Down