@armadra/agent 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/CHANGELOG.zh-CN.md +59 -0
- package/README.md +168 -575
- package/README.zh-CN.md +165 -596
- package/dist/agent/queue.d.ts +9 -0
- package/dist/agent/queue.js +27 -0
- package/dist/agent/session-subagent.d.ts +1 -0
- package/dist/agent/session-subagent.js +9 -0
- package/dist/agent/session.d.ts +11 -0
- package/dist/agent/session.js +29 -2
- package/dist/agent/subagent-background.d.ts +75 -0
- package/dist/agent/subagent-background.js +209 -0
- package/dist/agent/subagent-direct.d.ts +5 -2
- package/dist/agent/subagent-direct.js +34 -1
- package/dist/agent/subagent-registry.d.ts +26 -6
- package/dist/agent/subagent-registry.js +66 -94
- package/dist/agent/types-w5.d.ts +11 -1
- package/dist/agent/types.d.ts +12 -0
- package/dist/agents/builtin.js +0 -1
- package/dist/agents/external.js +0 -1
- package/dist/agents/parse.js +4 -3
- package/dist/agents/result.d.ts +7 -1
- package/dist/agents/result.js +20 -1
- package/dist/agents/task-control.d.ts +13 -2
- package/dist/agents/task-record.d.ts +16 -4
- package/dist/agents/task-record.js +32 -0
- package/dist/agents/types.d.ts +5 -1
- package/dist/ai/apis/chatgpt-rate-limits.js +7 -2
- package/dist/ai/providers/discovered-cache.d.ts +10 -4
- package/dist/ai/providers/discovered-cache.js +30 -14
- package/dist/ai/types.d.ts +2 -1
- package/dist/auth/chatgpt/backend-client.d.ts +6 -5
- package/dist/auth/chatgpt/backend-client.js +8 -7
- package/dist/bundle/ama.cjs +2034 -552
- package/dist/cli/compose-agents.d.ts +2 -1
- package/dist/cli/compose-agents.js +11 -2
- package/dist/cli/subcommands/models-discover.d.ts +1 -0
- package/dist/cli/subcommands/models-discover.js +12 -2
- package/dist/config/json-schema.js +10 -2
- package/dist/config/key-docs.js +9 -2
- package/dist/config/merge.d.ts +1 -1
- package/dist/config/merge.js +20 -3
- package/dist/config/schema-w5.js +4 -2
- package/dist/config/schema.js +4 -0
- package/dist/config/settings-registry.js +5 -0
- package/dist/config/types-w5.d.ts +10 -0
- package/dist/config/types-w5.js +2 -0
- package/dist/config/types.d.ts +5 -1
- package/dist/drivers/runner.js +29 -2
- package/dist/git/info.d.ts +19 -0
- package/dist/git/info.js +64 -8
- package/dist/i18n/catalog.d.ts +58 -8
- package/dist/i18n/messages/agents.d.ts +60 -0
- package/dist/i18n/messages/agents.js +62 -2
- package/dist/i18n/messages/config-keys.d.ts +8 -0
- package/dist/i18n/messages/config-keys.js +18 -10
- package/dist/i18n/messages/config.d.ts +8 -0
- package/dist/i18n/messages/interactive-startup.d.ts +0 -16
- package/dist/i18n/messages/interactive-startup.js +0 -16
- package/dist/i18n/messages/interactive-view.d.ts +8 -0
- package/dist/i18n/messages/interactive-view.js +10 -0
- package/dist/i18n/messages/interactive.d.ts +33 -16
- package/dist/i18n/messages/interactive.js +31 -0
- package/dist/i18n/messages/print.d.ts +4 -0
- package/dist/i18n/messages/print.js +4 -0
- package/dist/i18n/messages/report.d.ts +8 -0
- package/dist/i18n/messages/report.js +12 -4
- package/dist/i18n/messages/settings.d.ts +8 -0
- package/dist/i18n/messages/settings.js +8 -0
- package/dist/i18n/messages/subcommands-config.d.ts +4 -0
- package/dist/i18n/messages/subcommands-config.js +4 -0
- package/dist/i18n/messages/subcommands.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/modes/commands-core.js +19 -4
- package/dist/modes/interactive/agent-bar.d.ts +3 -1
- package/dist/modes/interactive/agent-bar.js +12 -5
- package/dist/modes/interactive/agent-ui.d.ts +21 -3
- package/dist/modes/interactive/agent-ui.js +82 -12
- package/dist/modes/interactive/agent-view.d.ts +9 -0
- package/dist/modes/interactive/agent-view.js +28 -4
- package/dist/modes/interactive/approval-dock.d.ts +51 -0
- package/dist/modes/interactive/approval-dock.js +112 -0
- package/dist/modes/interactive/approval-ui.d.ts +43 -0
- package/dist/modes/interactive/approval-ui.js +64 -0
- package/dist/modes/interactive/commands.js +4 -1
- package/dist/modes/interactive/event-notices.d.ts +6 -1
- package/dist/modes/interactive/event-notices.js +7 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -2
- package/dist/modes/interactive/interactive-mode.js +46 -39
- package/dist/modes/interactive/interrupt-send.d.ts +25 -0
- package/dist/modes/interactive/interrupt-send.js +32 -0
- package/dist/modes/interactive/key-dispatch.d.ts +29 -5
- package/dist/modes/interactive/key-dispatch.js +97 -8
- package/dist/modes/interactive/line/line-mode.d.ts +1 -0
- package/dist/modes/interactive/line/line-mode.js +34 -7
- package/dist/modes/interactive/run-indicator.d.ts +34 -2
- package/dist/modes/interactive/run-indicator.js +62 -8
- package/dist/modes/interactive/session-events.js +5 -1
- package/dist/modes/interactive/startup-header.d.ts +29 -14
- package/dist/modes/interactive/startup-header.js +93 -59
- package/dist/modes/interactive/startup-logo.d.ts +83 -0
- package/dist/modes/interactive/startup-logo.js +183 -0
- package/dist/modes/interactive/status-area.d.ts +18 -0
- package/dist/modes/interactive/status-area.js +67 -1
- package/dist/modes/interactive/status-bar.d.ts +13 -2
- package/dist/modes/interactive/status-bar.js +60 -17
- package/dist/modes/interactive/status-line.d.ts +11 -8
- package/dist/modes/interactive/status-line.js +52 -39
- package/dist/modes/interactive/status-quota.d.ts +58 -0
- package/dist/modes/interactive/status-quota.js +155 -0
- package/dist/modes/interactive/subagent-view.d.ts +1 -0
- package/dist/modes/interactive/subagent-view.js +8 -0
- package/dist/modes/interactive/task-background.d.ts +31 -0
- package/dist/modes/interactive/task-background.js +68 -0
- package/dist/modes/interactive/tool-view.d.ts +7 -1
- package/dist/modes/interactive/tool-view.js +24 -1
- package/dist/modes/print/print-mode.d.ts +11 -0
- package/dist/modes/print/print-mode.js +36 -1
- package/dist/modes/rpc/commands.d.ts +4 -1
- package/dist/modes/rpc/commands.js +24 -2
- package/dist/rpc.d.ts +20 -0
- package/dist/rpc.js +3 -0
- package/dist/tools/task-ctl.d.ts +2 -0
- package/dist/tools/task-ctl.js +7 -2
- package/dist/tools/task.d.ts +11 -0
- package/dist/tools/task.js +20 -2
- package/dist/tools/types.d.ts +6 -0
- package/dist/tui/components/editor.d.ts +2 -0
- package/dist/tui/components/editor.js +4 -0
- package/dist/tui/components/loader.d.ts +5 -1
- package/dist/tui/components/loader.js +18 -5
- package/dist/tui/keybindings.d.ts +15 -3
- package/dist/tui/keybindings.js +15 -3
- package/docs/agents.md +52 -28
- package/docs/en/host-api.md +5 -1
- package/docs/en/providers.md +1 -1
- package/docs/en/rpc.md +28 -14
- package/docs/en/sessions.md +3 -1
- package/docs/en/tui.md +106 -70
- package/docs/host-api.md +5 -1
- package/docs/providers.md +4 -2
- package/docs/rpc.md +28 -14
- package/docs/session-format.md +1 -1
- package/docs/sessions.md +2 -1
- package/docs/tui-design.md +42 -29
- package/docs/tui.md +106 -70
- package/package.json +1 -1
package/docs/agents.md
CHANGED
|
@@ -38,7 +38,7 @@ model: fast # inherit(缺省)| fast | strong(models.aliases)| provider/m
|
|
|
38
38
|
thinking: low
|
|
39
39
|
max-turns: 20 # 缺省 30
|
|
40
40
|
isolation: none # none(缺省)| worktree
|
|
41
|
-
background: false
|
|
41
|
+
background: false # 不写 = 按 config subagents.background
|
|
42
42
|
runner: ama # ama(缺省)| claude | codex | acp:<程序>
|
|
43
43
|
---
|
|
44
44
|
|
|
@@ -60,16 +60,16 @@ runner: ama # ama(缺省)| claude | codex | acp:<程序>
|
|
|
60
60
|
|
|
61
61
|
### `task` 参数
|
|
62
62
|
|
|
63
|
-
| 参数 | 说明
|
|
64
|
-
| ------------------------------------------------ |
|
|
65
|
-
| `prompt` | 必填,完整的任务说明
|
|
66
|
-
| `agent` | 类型名,缺省 `general`;也可以是外部 Agent(见「外部 Agent」节)
|
|
67
|
-
| `description` | 显示用的短标签
|
|
68
|
-
| `background` | `true`:立即返回 `taskId
|
|
69
|
-
| `taskId` | 续聊:向已有任务的子会话追加一条消息(忽略 `agent` / `tools` / `model`)
|
|
70
|
-
| `isolation` | `worktree`:在独立 git worktree 里运行
|
|
71
|
-
| `budgetUsd` | 外部 Agent 的美元预算
|
|
72
|
-
| `tools` / `model` / `thinkingLevel` / `maxTurns` | 保留的高级参数(描述里不展开)
|
|
63
|
+
| 参数 | 说明 |
|
|
64
|
+
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
65
|
+
| `prompt` | 必填,完整的任务说明 |
|
|
66
|
+
| `agent` | 类型名,缺省 `general`;也可以是外部 Agent(见「外部 Agent」节) |
|
|
67
|
+
| `description` | 显示用的短标签 |
|
|
68
|
+
| `background` | `true`:立即返回 `taskId`,完成后父会话收到通知;`false`:等结果。缺省取类型的 `background`,类型没写时按 `subagents.background`(见下文「前台与后台」) |
|
|
69
|
+
| `taskId` | 续聊:向已有任务的子会话追加一条消息(忽略 `agent` / `tools` / `model`) |
|
|
70
|
+
| `isolation` | `worktree`:在独立 git worktree 里运行 |
|
|
71
|
+
| `budgetUsd` | 外部 Agent 的美元预算 |
|
|
72
|
+
| `tools` / `model` / `thinkingLevel` / `maxTurns` | 保留的高级参数(描述里不展开) |
|
|
73
73
|
|
|
74
74
|
同一条回复里的多个 `task` **并行**执行,由会话的任务池限流(`subagents.maxConcurrent`,缺省 4);排队超过
|
|
75
75
|
`subagents.maxPending`(缺省 16)直接报错,提示模型不要重试。并行且会写文件的任务请用 `isolation: "worktree"`。
|
|
@@ -79,9 +79,31 @@ runner: ama # ama(缺省)| claude | codex | acp:<程序>
|
|
|
79
79
|
全文写到会话目录的 `outputs/<会话 id>-<taskId>.md`(内存会话写到系统临时目录)。轮数用尽且最后一步停在工具结果上时,
|
|
80
80
|
ama 以「不允许调用工具」再跑一轮要最终报告,结果前加 `[Turn limit reached; …]`,状态 `max_turns`。
|
|
81
81
|
|
|
82
|
+
### 前台与后台
|
|
83
|
+
|
|
84
|
+
是否后台的优先级:调用参数 `background` > 类型定义的 `background:` > config `subagents.background`。
|
|
85
|
+
`subagents.background` 缺省 `auto`:交互界面、RPC、ACP 下后台(模型需要结果才写 `background: false`),`-p` 下前台;
|
|
86
|
+
`always` / `never` 固定。两种缺省对应两版 `task` 工具描述,会话内不变,不影响缓存前缀稳定。
|
|
87
|
+
|
|
88
|
+
前台任务运行中可以转后台,任务不中断,`task` 工具调用立即返回一段固定英文结果(含 `taskId` 与输出文件),完成后照常发
|
|
89
|
+
`<task-notification>`:
|
|
90
|
+
|
|
91
|
+
- 交互界面:`Ctrl+B` / `/tasks bg [id]` / Agent 栏里按 `b`(见 [tui.md](tui.md)「子 Agent」);
|
|
92
|
+
- RPC:`background_task { taskId? }`([rpc.md](rpc.md)),SDK:`session.backgroundTask(taskId?)`,返回实际转了的 `taskId`;
|
|
93
|
+
不给 `taskId` 时转全部前台运行中任务,正在 `task_ctl wait` 的等待也一并打断;
|
|
94
|
+
- 自动:`subagents.autoBackgroundAfterMs` 大于 0 时,前台任务运行超过该毫秒数自动转后台(缺省 0 关闭)。
|
|
95
|
+
|
|
96
|
+
转后台发 `subagent_background { taskId, parentToolCallId, reason }` 事件(`user` / `timeout` / `host`)。
|
|
97
|
+
父会话 `Esc` 中断只连带中止仍在前台的任务,后台任务不受影响;停止后台任务用 `task_ctl stop` 或 `/tasks stop`。
|
|
98
|
+
|
|
99
|
+
`-p` 下(缺省前台)显式 `background: true` 仍生效:主回合结束后若还有任务在跑或通知待投递,stderr 一行提示,等它们结束、
|
|
100
|
+
跑完通知回合再输出,输出的文本是最后一条助手回复;等待受 `--max-turns` / `--max-cost` / `limits.*` 约束(到限停止等待、
|
|
101
|
+
退出码 8),`Ctrl+C` / SIGTERM 照常中止(未结束的任务随会话关闭被停止,退出码 130 / 143)。`--output-format json` 的结果带
|
|
102
|
+
`tasks`(同 `getStats().tasks`)。
|
|
103
|
+
|
|
82
104
|
### 后台任务与 `task_ctl`
|
|
83
105
|
|
|
84
|
-
|
|
106
|
+
后台任务立即返回 `taskId` 与输出文件路径。任务完成后,ama 在父会话空闲时投递一条 user 消息(`origin: "task"`)
|
|
85
107
|
并开始新回合;父正忙则等这一轮结束再投递,不打断。多条通知按完成顺序到达:
|
|
86
108
|
|
|
87
109
|
```text
|
|
@@ -95,13 +117,13 @@ ama 以「不允许调用工具」再跑一轮要最终报告,结果前加 `[T
|
|
|
95
117
|
|
|
96
118
|
`task_ctl` 的动作:
|
|
97
119
|
|
|
98
|
-
| `action` | 说明
|
|
99
|
-
| -------- |
|
|
100
|
-
| `list` | 列出本会话的任务:编号、类型、状态、轮数、token、耗时、是否后台、描述
|
|
101
|
-
| `wait` | 等任务结束(`timeoutMs` 缺省 30 000,最多 600 000
|
|
102
|
-
| `stop` | 停止任务,返回终态
|
|
103
|
-
| `output` | 运行中返回已有输出,结束后返回最终文本(同样有 50 KB 上限)
|
|
104
|
-
| `send` | 向任务追加一条消息并放到后台运行(等价于 `task{taskId, prompt, background:true}`)
|
|
120
|
+
| `action` | 说明 |
|
|
121
|
+
| -------- | ------------------------------------------------------------------------------------------------------- |
|
|
122
|
+
| `list` | 列出本会话的任务:编号、类型、状态、轮数、token、耗时、是否后台、描述 |
|
|
123
|
+
| `wait` | 等任务结束(`timeoutMs` 缺省 30 000,最多 600 000);超时说明仍在运行;被转后台时立即返回并说明不必再等 |
|
|
124
|
+
| `stop` | 停止任务,返回终态 |
|
|
125
|
+
| `output` | 运行中返回已有输出,结束后返回最终文本(同样有 50 KB 上限) |
|
|
126
|
+
| `send` | 向任务追加一条消息并放到后台运行(等价于 `task{taskId, prompt, background:true}`) |
|
|
105
127
|
|
|
106
128
|
### 续聊、保留与 resume
|
|
107
129
|
|
|
@@ -122,20 +144,22 @@ worktree 里的编辑不记进父会话的检查点。注意:worktree 不共
|
|
|
122
144
|
|
|
123
145
|
### 事件与统计
|
|
124
146
|
|
|
125
|
-
RPC / SDK 事件 `subagent_start` / `subagent_update` / `subagent_end` 见 [rpc.md](rpc.md)「子 Agent 事件」。
|
|
147
|
+
RPC / SDK 事件 `subagent_start` / `subagent_update` / `subagent_background` / `subagent_end` 见 [rpc.md](rpc.md)「子 Agent 事件」。
|
|
126
148
|
`getStats().tasks` 给出任务总数、运行中数量与按状态的计数;子会话的缓存命中与重计费仍汇总在 `cache.subagents`。
|
|
127
149
|
RPC `get_tasks` / `get_agents` 返回任务快照与可用类型(来源、定义文件路径)。交互界面的 `/tasks`、`/agents` 与 task 工具行的折叠显示见 [tui.md](tui.md)「子 Agent」。
|
|
128
150
|
|
|
129
151
|
### 配置
|
|
130
152
|
|
|
131
|
-
| 键 | 说明
|
|
132
|
-
| --------------------------------- |
|
|
133
|
-
| `subagents.maxConcurrent` | 同时运行的子 Agent,缺省 4
|
|
134
|
-
| `subagents.maxPending` | 排队上限,缺省 16
|
|
135
|
-
| `subagents.defaultModel` | 子 Agent 缺省模型,不设继承父会话
|
|
136
|
-
| `
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
153
|
+
| 键 | 说明 |
|
|
154
|
+
| --------------------------------- | -------------------------------------------------------------------------------- |
|
|
155
|
+
| `subagents.maxConcurrent` | 同时运行的子 Agent,缺省 4 |
|
|
156
|
+
| `subagents.maxPending` | 排队上限,缺省 16 |
|
|
157
|
+
| `subagents.defaultModel` | 子 Agent 缺省模型,不设继承父会话 |
|
|
158
|
+
| `subagents.background` | `auto`(缺省)\| `always` \| `never`,见「前台与后台」;用户 / 项目 / 宿主级都认 |
|
|
159
|
+
| `subagents.autoBackgroundAfterMs` | 前台任务运行超过该毫秒数自动转后台,缺省 0(关闭);用户 / 项目级都认 |
|
|
160
|
+
| `agents.dirs` | 追加的定义目录 |
|
|
161
|
+
| `agents.<类型>.model` | 某个类型的模型(如让 `explore` 用便宜模型) |
|
|
162
|
+
| `models.aliases.fast` / `.strong` | 定义文件里 `model: fast / strong` 的映射 |
|
|
139
163
|
|
|
140
164
|
### 限制
|
|
141
165
|
|
package/docs/en/host-api.md
CHANGED
|
@@ -164,4 +164,8 @@ Return `"warm"` / `"stop"` (a Promise is fine). `"stop"` skips the request and s
|
|
|
164
164
|
|
|
165
165
|
## Embedding in Armadra
|
|
166
166
|
|
|
167
|
-
Armadra starts ama with a profile: `ama --profile <path>`. The profile's `host` points to its adapter (`ama-armadra.cjs`) and also carries instructions, skillDirs, hooksFile, authFile, sessionDir and `trustProject`. The adapter returns `undefined` when `ARMADRA_NODE_ID` is missing, so the same profile behaves as plain ama outside the canvas.
|
|
167
|
+
Armadra starts ama with a profile: `ama --profile <path>`. The profile's `host` points to its adapter (`ama-armadra.cjs`) and also carries instructions, skillDirs, hooksFile, authFile, sessionDir and `trustProject`. The adapter returns `undefined` when `ARMADRA_NODE_ID` is missing, so the same profile behaves as plain ama outside the canvas.
|
|
168
|
+
|
|
169
|
+
Interface defaults with a profile: `ui.quietStartup: "header"` and `ui.statusLine: "compact"` (the last line is the status bar, which the host parses by `·`). The agent bar (`ui.agentBar`) is no longer off by default; it is `auto` as in a standalone terminal. A host that shows sub-tasks itself and does not want the bar writes `{ "ui": { "agentBar": "off" } }` into the config file its profile's `config` points to.
|
|
170
|
+
|
|
171
|
+
Contract details are in [docs/design/coordinator-agent.md](https://github.com/yovinchen/Armadra/blob/main/docs/design/coordinator-agent.md) in the Armadra repository.
|
package/docs/en/providers.md
CHANGED
|
@@ -170,7 +170,7 @@ ama auth logout chatgpt # siwc revokes the refresh token first, t
|
|
|
170
170
|
| Quota | only known when exceeded (429); set a weekly cap for ama under ChatGPT → Settings → Usage → App limits | response headers, `codex.rate_limits` events, `ama auth status` queries `wham/usage` |
|
|
171
171
|
| Logout | calls `revocation_endpoint`, then deletes locally | deletes locally only |
|
|
172
172
|
|
|
173
|
-
**Model list**: `chatgpt` has no built-in model table (`chatgpt/<slug>` accepts any slug). After a successful `ama auth login chatgpt`, ama deletes the old cache and calls the model list endpoint once (siwc `GET /v1/models`, codex `GET /models?client_version=…`; read-only, no usage consumed; failures are silent and the output suggests `ama models discover chatgpt` instead) and caches the slugs and display names available to the account, with the flavor and a timestamp, in `<dataDir>/models/discovered/chatgpt.json` — an empty list is written as well when no model comes back, so no cache from the other sign-in method is left behind; `ama models discover chatgpt` rewrites the cache and `ama auth logout chatgpt` deletes it. When the registry is assembled the cache is merged into providers whose model table is empty,
|
|
173
|
+
**Model list**: `chatgpt` has no built-in model table (`chatgpt/<slug>` accepts any slug). After a successful `ama auth login chatgpt`, ama deletes the old cache and calls the model list endpoint once (siwc `GET /v1/models`, codex `GET /models?client_version=…`; read-only, no usage consumed; failures are silent and the output suggests `ama models discover chatgpt` instead) and caches the slugs and display names available to the account, with the flavor and a timestamp, in `<dataDir>/models/discovered/chatgpt.json` — an empty list is written as well when no model comes back, so no cache from the other sign-in method is left behind; `ama models discover chatgpt` rewrites the cache and `ama auth logout chatgpt` deletes it. When the registry is assembled the cache is merged into providers whose model table is empty, and the context window, input modalities and reasoning efforts reported by the backend (codex reports them; siwc entries are read the same way when present) are cached and take precedence over the models.dev snapshot — the subscription backend's effective window (such as 272k) can be far smaller than the API window models.dev lists, and the compaction threshold follows the backend window; fields the backend leaves out (such as the output limit) come from models.dev, and when neither has a context window a conservative 128k is used. A cache written by an older version without windows keeps using models.dev until `ama models discover chatgpt` refreshes it. This way the `/model` picker and `ama models list` show the models; a cache whose flavor differs from the current sign-in counts as stale and is not merged (the picker suggests discovering again). Slugs missing from the cache still work with `--model chatgpt/<slug>`.
|
|
174
174
|
|
|
175
175
|
**codex `client_version`**: the codex backend filters models by `client_version` (each model has a minimum client version; omitting the parameter is a 400), and ama sends a Codex CLI version (default `0.160.0`), not its own version. If codex returns no models at login or discover time, that version is most likely too old: set a newer Codex CLI version with `ama config set auth.chatgpt.codexClientVersion <version>` (user level) or the environment variable `AMA_CHATGPT_CODEX_CLIENT_VERSION` (takes precedence), then run `ama models discover chatgpt`. Inference requests carry no version.
|
|
176
176
|
|
package/docs/en/rpc.md
CHANGED
|
@@ -41,16 +41,18 @@ A command has the shape `{ "id"?: string, "type": <command name>, ...parameters
|
|
|
41
41
|
|
|
42
42
|
### Prompts
|
|
43
43
|
|
|
44
|
-
| Command | Parameters
|
|
45
|
-
| ------------- |
|
|
46
|
-
| `prompt` | `message: string`, `images?: ImageBlock[]`, `streamingBehavior?: "steer" \| "followUp"` | `{ disposition: "started" \| "queued" \| "handled" }` |
|
|
47
|
-
| `steer` | `message`, `images
|
|
48
|
-
| `follow_up` | `message`, `images?`
|
|
49
|
-
| `abort` | —
|
|
50
|
-
| `clear_queue` | —
|
|
44
|
+
| Command | Parameters | `data` |
|
|
45
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
|
46
|
+
| `prompt` | `message: string`, `images?: ImageBlock[]`, `streamingBehavior?: "steer" \| "followUp"`, `interrupt?: boolean` | `{ disposition: "started" \| "queued" \| "handled" }` |
|
|
47
|
+
| `steer` | `message`, `images?`, `interrupt?: boolean` | Same as above |
|
|
48
|
+
| `follow_up` | `message`, `images?` | Same as above |
|
|
49
|
+
| `abort` | — | `{}` (answered once idle again; the queue is not cleared) |
|
|
50
|
+
| `clear_queue` | — | `{ steering: string[], followUp: string[] }` (the cleared text) |
|
|
51
51
|
|
|
52
52
|
Prompt commands **do not wait for the run to finish**: they are answered as soon as the session starts running (`before_agent_start` / `agent_start`), or the message is queued or handled (for example a slash command, or a hook block); progress arrives as events. Sending `prompt` while running without `streamingBehavior` fails with `code: "busy"`; with `steer` / `followUp` it is queued. Run failures after the response are reported as `{"type":"notification","level":"error","message":…}`.
|
|
53
53
|
|
|
54
|
+
**Interrupt and send now**: with `interrupt: true` on `prompt` / `steer` (it takes precedence over `streamingBehavior`), a running session first takes the queued steers, stops the current turn (the model stream is cut, running tools finish as interrupted so every tool call has exactly one `aborted by user` result, and the interrupted assistant message is persisted with `stopReason: "aborted"`), then immediately starts a new turn with "queued steers… + this message" (joined by blank lines) and answers `{ disposition: "started" }`; the new user message has `origin: "interrupt"`. followUp messages stay queued and are delivered after the new turn; background sub-agents are not affected. When idle it is the same as leaving it out. A non-boolean `interrupt` → `invalid_arguments`; running with both the message and the queued steers empty → `invalid_arguments` (nothing is interrupted). Event order: `queue_update` (steers taken) → the old turn's `message_end` (aborted) → `agent_settled` → `agent_start` → the response → the new user `message_end` … (golden record `test/fixtures/rpc/interrupt.out.jsonl`). The new request starts with every message of the interrupted request, so the cache keeps hitting. In the SDK: `session.prompt(text, { interrupt: true })` / `session.steer(text, { interrupt: true })`.
|
|
55
|
+
|
|
54
56
|
### State
|
|
55
57
|
|
|
56
58
|
| Command | Parameters | `data` |
|
|
@@ -171,7 +173,18 @@ After a session switch the server re-subscribes to events and sends `session_sta
|
|
|
171
173
|
- Errors: `invalid_arguments` (out-of-range parameters, `before` not a turn id on this branch, `before` together with
|
|
172
174
|
`since`) and `task_not_found`.
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
### Background sub-agents (wave 7)
|
|
177
|
+
|
|
178
|
+
| Command | Parameters | `data` |
|
|
179
|
+
| ----------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
180
|
+
| `background_task` | `taskId?` | `{ backgrounded: string[] }`: the task ids actually moved. Without `taskId`, every running foreground task; an empty list for finished, already-background or unknown tasks; a non-string `taskId` → `invalid_arguments` |
|
|
181
|
+
|
|
182
|
+
A moved foreground task is not interrupted: its `task` call returns at once with `tool_execution_end` (the result text starts with
|
|
183
|
+
`[task tN] Moved to the background`, `details.status: "running"`), followed by `subagent_background`; when the task ends you get
|
|
184
|
+
`subagent_end` as usual and, once the parent session is idle, the notification message with `origin: "task"`. Same semantics as
|
|
185
|
+
`Ctrl+B` in the interactive UI.
|
|
186
|
+
|
|
187
|
+
44 commands in total; their names are the keys of `RpcCommandMap`.
|
|
175
188
|
|
|
176
189
|
## Events
|
|
177
190
|
|
|
@@ -216,13 +229,14 @@ There is also the non-session event `{"type":"notification","level":"info"|"warn
|
|
|
216
229
|
|
|
217
230
|
Sub-agents started by `task` / `task_ctl` (ama sub-sessions and external agents share the same events, see [agents.md](../agents.md), Chinese):
|
|
218
231
|
|
|
219
|
-
| Event
|
|
220
|
-
|
|
|
221
|
-
| `subagent_start`
|
|
222
|
-
| `subagent_update`
|
|
223
|
-
| `
|
|
232
|
+
| Event | Fields |
|
|
233
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
234
|
+
| `subagent_start` | `taskId`, `parentToolCallId`, `agent`, `runner` (`ama` / `claude` / `codex` / `acp:<program>`), `description`, `background`, `model?`, `sessionFile?`, `cwd`; sent again when the same `taskId` is continued |
|
|
235
|
+
| `subagent_update` | `taskId`, `kind: tool \| text \| turn`, `toolName?`, `textDelta?` (merged over ≥ 250 ms), `turn`, `usage?` |
|
|
236
|
+
| `subagent_background` | `taskId`, `parentToolCallId`, `reason: user \| timeout \| host` (a foreground task moved to the background: by hand in the interactive UI, when `subagents.autoBackgroundAfterMs` elapses, or by an RPC / SDK call; wave 7) |
|
|
237
|
+
| `subagent_end` | `taskId`, `status: completed \| failed \| aborted \| max_turns \| interrupted`, `usage?`, `cache?`, `outputFile?`, `worktree?: { branch, changed }` |
|
|
224
238
|
|
|
225
|
-
Approvals of sub-sessions and external agents are sent to this connection as `permission_request` as usual, with an optional `context` marking the origin (since wave 6, approvals of this session's own tool calls also carry `context.toolCallId`, the id of the tool call that triggered the approval, which traces use to compute approval wait time; external agent requests do not carry it): `depth` (1 = from a task sub-agent), `taskId` (the originating task), `origin` (permission requests from external agents: `agent`, `sessionId` (the external CLI's own session id), `toolCall: { title, kind, locations?, inputSummary? }`, `options`). Dialogs use it to show `[task:<agent>]` or `[claude · session abc1]`. For external agent requests `toolName` is `agent:<id>` and the answer applies to this one request only ("allow for this session" is remembered by the external agent itself); the first run of an external agent in a session additionally gets one confirmation with `toolName: "task"`, `input: { agent, mode, note }` (`context.taskId`). `test/fixtures/rpc/external.out.jsonl` is the golden record of the three approvals of `task(agent="acp:ama")` (the task tool, the first run, the child ama's bash), updated by `src/agents/external-rpc.test.ts` with `UPDATE_GOLDEN=1`. After a background task completes, the parent session receives a user message with `origin: "task"` (`<task-notification …>…</task-notification>`) and starts a new turn as usual. Task and type lists are returned by `get_tasks` / `get_agents` (shapes `TaskInfo` / `AgentInfo`; empty without the task tool), with data from the current session's `taskRegistryView(sessionId)` / `sessionAgents(sessionId)` (`src/agent/subagent-registry.ts`). `get_agents` also includes external agents (`installed` / `version` come from PATH and a `--version` probe, cached asynchronously when the session is created and refreshed when external tasks end or host injections change; before the cache is ready there is only the type catalog, see `cachedAgentInfos` in `src/agents/external.ts`). `test/fixtures/rpc/subagent.out.jsonl` is the golden record of a foreground `task(agent="explore")` plus `get_tasks` / `get_agents` (keeping only responses, `tool_execution_*`, `subagent_*` and `agent_settled`), updated by `src/agent/subagent-rpc.test.ts` with `UPDATE_GOLDEN=1`.
|
|
239
|
+
Approvals of sub-sessions and external agents are sent to this connection as `permission_request` as usual, with an optional `context` marking the origin (since wave 6, approvals of this session's own tool calls also carry `context.toolCallId`, the id of the tool call that triggered the approval, which traces use to compute approval wait time; external agent requests do not carry it): `depth` (1 = from a task sub-agent), `taskId` (the originating task), `origin` (permission requests from external agents: `agent`, `sessionId` (the external CLI's own session id), `toolCall: { title, kind, locations?, inputSummary? }`, `options`). Dialogs use it to show `[task:<agent>]` or `[claude · session abc1]`. For external agent requests `toolName` is `agent:<id>` and the answer applies to this one request only ("allow for this session" is remembered by the external agent itself); the first run of an external agent in a session additionally gets one confirmation with `toolName: "task"`, `input: { agent, mode, note }` (`context.taskId`). `test/fixtures/rpc/external.out.jsonl` is the golden record of the three approvals of `task(agent="acp:ama")` (the task tool, the first run, the child ama's bash), updated by `src/agents/external-rpc.test.ts` with `UPDATE_GOLDEN=1`. After a background task completes, the parent session receives a user message with `origin: "task"` (`<task-notification …>…</task-notification>`) and starts a new turn as usual. Task and type lists are returned by `get_tasks` / `get_agents` (shapes `TaskInfo` / `AgentInfo`; empty without the task tool), with data from the current session's `taskRegistryView(sessionId)` / `sessionAgents(sessionId)` (`src/agent/subagent-registry.ts`). `get_agents` also includes external agents (`installed` / `version` come from PATH and a `--version` probe, cached asynchronously when the session is created and refreshed when external tasks end or host injections change; before the cache is ready there is only the type catalog, see `cachedAgentInfos` in `src/agents/external.ts`). `test/fixtures/rpc/subagent.out.jsonl` is the golden record of a foreground `task(agent="explore")` plus `get_tasks` / `get_agents` (keeping only responses, `tool_execution_*`, `subagent_*` and `agent_settled`), updated by `src/agent/subagent-rpc.test.ts` with `UPDATE_GOLDEN=1`. `test/fixtures/rpc/background.out.jsonl` is the golden record of `background_task` moving a running foreground `task` to the background, the task ending and its notification turn, updated by `src/modes/rpc/rpc-background.test.ts`.
|
|
226
240
|
|
|
227
241
|
### Throughput telemetry (wave 5)
|
|
228
242
|
|
package/docs/en/sessions.md
CHANGED
|
@@ -51,7 +51,9 @@ Top 5 tool calls
|
|
|
51
51
|
| Errors / retries | Assistant messages with `stopReason: "error"`; `context_edit{reason:"retry"}` (failed attempts removed by automatic retry) |
|
|
52
52
|
| Channel | The `channel` of the latest `model_change` with the same provider / model as the request |
|
|
53
53
|
|
|
54
|
-
`task` sub-sessions are separate files and count under their own cwd.
|
|
54
|
+
`task` sub-sessions are separate files and count under their own cwd. The notification message a parent session receives when a
|
|
55
|
+
background task finishes (`origin: "task"`) also starts a turn and counts under the parent; when `-p` waits for background tasks,
|
|
56
|
+
those notification turns are written to the same session file.
|
|
55
57
|
|
|
56
58
|
### Performance and index
|
|
57
59
|
|