@oh-my-dsh/dsh-better-subagent 0.5.2 → 0.5.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/README.md +4 -4
- package/docs/DEVELOPMENT.md +6 -4
- package/package.json +16 -16
- package/src/child-exit-guard.js +3 -1
- package/src/prompt.js +3 -2
- package/src/subagents.js +19 -15
- package/src/wait-subagent.js +39 -15
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="https://www.npmjs.com/package/@oh-my-dsh/dsh-better-subagent"><img src="https://img.shields.io/npm/v/%40oh-my-dsh%2Fdsh-better-subagent.svg" alt="npm 版本"></a>
|
|
14
14
|
<a href="LICENSE"><img alt="Apache-2.0" src="https://img.shields.io/github/license/omdsh-dev/dsh-better-subagent?color=blue"></a>
|
|
15
|
-
<a href="package.json"><img alt="DSH 0.2.2-rc.
|
|
15
|
+
<a href="package.json"><img alt="DSH 0.2.2-rc.3" src="https://img.shields.io/badge/DSH-0.2.2--rc.3-4B32C3"></a>
|
|
16
16
|
<a href="https://github.com/omdsh-dev/dsh-better-dsh"><img alt="Part of Better DSH" src="https://img.shields.io/badge/part%20of-dsh--better--dsh-2F80B7"></a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
44
|
# 只安装这个插件
|
|
45
|
-
dsh plugin --profile <profile> add @oh-my-dsh/dsh-better-subagent@0.5.
|
|
45
|
+
dsh plugin --profile <profile> add @oh-my-dsh/dsh-better-subagent@0.5.4
|
|
46
46
|
|
|
47
47
|
# 或安装 Better DSH(会自动带上所有独立插件)
|
|
48
|
-
dsh plugin --profile <profile> add dsh-better-dsh@0.
|
|
48
|
+
dsh plugin --profile <profile> add dsh-better-dsh@0.11.7
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
> 安装 / 升级 / 换包后必须重启对应 profile;只刷新网页不够。
|
|
@@ -57,7 +57,7 @@ dsh plugin --profile <profile> add dsh-better-dsh@0.10.1
|
|
|
57
57
|
| 稳定行 id | `dsh-better-subagent` |
|
|
58
58
|
| 入口 / 工具 | `wait_subagent` · `/better-subagent/api/*` · 子代理设置页 |
|
|
59
59
|
| 设置 | `childExitGuard`、`delegation.prompt`、`tiers.*`、两个 CLI 后端、`trustedHosts` |
|
|
60
|
-
| npm 包 | `@oh-my-dsh/dsh-better-subagent@0.5.
|
|
60
|
+
| npm 包 | `@oh-my-dsh/dsh-better-subagent@0.5.4` |
|
|
61
61
|
| 仓库 | https://github.com/omdsh-dev/dsh-better-subagent |
|
|
62
62
|
|
|
63
63
|
## 设置
|
package/docs/DEVELOPMENT.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
- 纯 ESM、无构建步骤;宿主入口 `src/index.js`,浏览器入口 `src/client.js`。
|
|
8
8
|
- `package.json` 的 `dsh.bundle.patch` 指向 `cordis.patch.yml`;`dsh.client.platform = "web"`。
|
|
9
9
|
- `files` 白名单:`src`、`docs`、`cordis.patch.yml`、`README.md`、`LICENSE`、`third-party`。测试、脚本、设计 Spec、凭据、临时 profile 都不进发布包。
|
|
10
|
-
- 依赖:运行时只直接 import `@deepseek-ai/schemastery`;其余 DSH
|
|
10
|
+
- 依赖:运行时只直接 import `@deepseek-ai/schemastery`;其余 DSH 包是 peer 范围(`>=0.2.2-rc.2 <0.3.0`),由宿主运行环境提供,服务全部经 `ctx` 获取。
|
|
11
11
|
- 浏览器半边只 `require('react')`,不 import 任何 DSH client 包;样式全部使用宿主主题 token(`--dsw-alias-*`),不写 DOM。
|
|
12
12
|
|
|
13
13
|
## 2. 宿主行与配置
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
|
|
51
51
|
## 4. CLI 桥(`src/subagents.js` + `src/cli-adapter.js` + `src/cli/*`)
|
|
52
52
|
|
|
53
|
-
- 不注册第二个 spawn/fork registry;CLI 子代理仍是原生 `subagents.startActivation({provider:'spawn', childId, ...})`,只是 `agentOptions.provider` 是内部 synthetic route。
|
|
53
|
+
- 不注册第二个 spawn/fork registry;CLI 子代理仍是原生 `subagents.startActivation({provider:'spawn', childId, parent, prompt, ...})`,只是 `agentOptions.provider` 是内部 synthetic route。rc.2 的 spec 是扁平对象,返回 `{childId, name}`;工具结果只回传 `{kind:'activation', name}`。
|
|
54
54
|
- 内部 route 历史固定为 `apollo-cli-codex` / `apollo-cli-claude`;不要为新包名重命名,否则旧会话不可续接。
|
|
55
55
|
- 拦截点:
|
|
56
56
|
- `ctx.tools.guard`:内部 route 保留、禁用范围明确拒绝、fork 拒绝;
|
|
57
57
|
- `ctx.tools.execute`:`subagent` + `provider=codex|claude` 短路创建;`list_subagent_models` 合并 CLI 目录;
|
|
58
58
|
- `ctx.on('tools/result')`:未被调用方接受的 child 回收(drain + 删 KV)。
|
|
59
|
-
- 创建流程:模型/effort 白名单校验 → 父当前目录解析(`workingDirectory.ensure`)→ `resolveExecutable` 预检 → `<executable> --version` 版本预检(`src/cli/version.js`:Codex 基线 `0.162.1`,Claude 基线 `2.1.300`;无法执行/无法识别/过旧都给出点名可执行文件与安装/升级方式的可操作错误)→ 先落 KV 再 `startActivation` →
|
|
59
|
+
- 创建流程:模型/effort 白名单校验 → 父当前目录解析(`workingDirectory.ensure`)→ `resolveExecutable` 预检 → `<executable> --version` 版本预检(`src/cli/version.js`:Codex 基线 `0.162.1`,Claude 基线 `2.1.300`;无法执行/无法识别/过旧都给出点名可执行文件与安装/升级方式的可操作错误)→ 先落 KV 再 `startActivation` → 已发布 activation 在失败/取消时 `dispose()`,再删记录;预发布失败由 rc.2 manager 回滚。`ctx.cliVersionProbe` 是测试 seam;真实运行时用 `execFile`,无 shell。
|
|
60
60
|
- 每个 adapter:一轮一个子进程;`delivered` 在 spawn 前落 KV;`remoteId` 第一行事件即落盘;`parse` 失败/非零退出/缺完成标志都抛错且不自动重试;`dispose()` 等待进程句柄退出。没有 `subprocess` 服务或 spawn 未发布时回滚 `started/delivered`。
|
|
61
61
|
- 身份 KV(`src/cli-sessions.js`):命名空间前缀 `apollo_cli_` + `sha256(profile.dir)[:16]`,version 1,`sessions` 表,`per-record`。**包名变化不重命名/复制/清空**。
|
|
62
62
|
- 权限/模型/effort 与父子归属在启动前失败;缺 CLI 或版本不兼容给可操作诊断,不回退到另一后端。
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
|
|
66
66
|
旧实现的缺陷:`settled` 只按 childId 缓存 `subagent/end`,当同一 child 被续接(新 activation 或 resident 新回合)时会把旧 end 当成本轮完成。
|
|
67
67
|
|
|
68
|
+
参数先经 `ctx.subagents.resolveName(parent, ref, signal)` 解析:rc.2 的 `list_agents` 和原生 `subagent` 结果都以树内名字为句柄,单个无法匹配的 token 仍按 durable id 处理。解析后再校验是否为当前 Agent 的直接子代理,输出行回显调用方给的名字。
|
|
69
|
+
|
|
68
70
|
现实现只依据宿主可证明的事实:
|
|
69
71
|
|
|
70
72
|
1. 监听 `subagent/start` / `subagent/end`,记录每个 child 最近的 activation `runId`;
|
|
@@ -85,7 +87,7 @@
|
|
|
85
87
|
## 6. 子代理退出守卫(`src/child-exit-guard.js`)
|
|
86
88
|
|
|
87
89
|
- 只由 volatile `childExitGuard`(默认 false)控制;
|
|
88
|
-
- 只听 `agent/turn-stopping`,只收集 `subagents.
|
|
90
|
+
- 只听 `agent/turn-stopping`,只收集 `subagents.listDescendants(agent.id)` 中 `depth === 1` 且 **live status === running** 的直接子代理;
|
|
89
91
|
- 只做一次 `agent.steer(buildChildGuardMessage(children))`;
|
|
90
92
|
- 查询/注入异常 → 告警并放行(fail open);`payload.signal.aborted` 直接返回;
|
|
91
93
|
- 不看 jobs、不 import Apollo、不扩大权限。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-dsh/dsh-better-subagent",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Standalone DSH plugin: Codex/Claude continuable CLI subagents, wait_subagent, child exit guard and model tiers. Pure ESM, no build step.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=24.9.0",
|
|
19
|
-
"dsh": "0.2.2-rc.
|
|
19
|
+
"dsh": ">=0.2.2-rc.2 <0.3.0"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"test": "node --test",
|
|
@@ -46,23 +46,23 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@deepseek-ai/schemastery": "~3.19.0",
|
|
49
|
-
"dsh-better-ptc": "0.2.
|
|
49
|
+
"dsh-better-ptc": "0.2.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
53
|
-
"@deepseek-ai/dsh-agent": "0.2.2-rc.
|
|
54
|
-
"@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.
|
|
55
|
-
"@deepseek-ai/dsh-llm": "0.2.2-rc.
|
|
56
|
-
"@deepseek-ai/dsh-session": "0.2.2-rc.
|
|
57
|
-
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.
|
|
58
|
-
"@deepseek-ai/dsh-session-query": "0.2.2-rc.
|
|
59
|
-
"@deepseek-ai/dsh-storage": "0.2.2-rc.
|
|
60
|
-
"@deepseek-ai/dsh-storage-json": "0.2.2-rc.
|
|
61
|
-
"@deepseek-ai/dsh-subagent": "0.2.2-rc.
|
|
62
|
-
"@deepseek-ai/dsh-subprocess": "0.2.2-rc.
|
|
63
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.
|
|
64
|
-
"@deepseek-ai/dsh-tools": "0.2.2-rc.
|
|
65
|
-
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.
|
|
53
|
+
"@deepseek-ai/dsh-agent": ">=0.2.2-rc.2 <0.3.0",
|
|
54
|
+
"@deepseek-ai/dsh-agent-preset-registry": ">=0.2.2-rc.2 <0.3.0",
|
|
55
|
+
"@deepseek-ai/dsh-llm": ">=0.2.2-rc.2 <0.3.0",
|
|
56
|
+
"@deepseek-ai/dsh-session": ">=0.2.2-rc.2 <0.3.0",
|
|
57
|
+
"@deepseek-ai/dsh-session-projection": ">=0.2.2-rc.2 <0.3.0",
|
|
58
|
+
"@deepseek-ai/dsh-session-query": ">=0.2.2-rc.2 <0.3.0",
|
|
59
|
+
"@deepseek-ai/dsh-storage": ">=0.2.2-rc.2 <0.3.0",
|
|
60
|
+
"@deepseek-ai/dsh-storage-json": ">=0.2.2-rc.2 <0.3.0",
|
|
61
|
+
"@deepseek-ai/dsh-subagent": ">=0.2.2-rc.2 <0.3.0",
|
|
62
|
+
"@deepseek-ai/dsh-subprocess": ">=0.2.2-rc.2 <0.3.0",
|
|
63
|
+
"@deepseek-ai/dsh-system-prompt": ">=0.2.2-rc.2 <0.3.0",
|
|
64
|
+
"@deepseek-ai/dsh-tools": ">=0.2.2-rc.2 <0.3.0",
|
|
65
|
+
"@deepseek-ai/dsh-working-directory": ">=0.2.2-rc.2 <0.3.0",
|
|
66
66
|
"react": "^18.2.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
package/src/child-exit-guard.js
CHANGED
|
@@ -62,7 +62,9 @@ export function buildChildGuardMessage(children) {
|
|
|
62
62
|
*/
|
|
63
63
|
export async function collectRunningChildren(ctx, agent) {
|
|
64
64
|
const running = []
|
|
65
|
-
|
|
65
|
+
// rc.2 removed listChildren; depth-one descendants are this Agent's direct
|
|
66
|
+
// children in the same stable catalog order.
|
|
67
|
+
for (const entry of (await ctx.subagents.listDescendants(agent.id)).filter((candidate) => candidate.depth === 1)) {
|
|
66
68
|
if (ctx.agents.get(entry.id)?.status === 'running') running.push(entry)
|
|
67
69
|
}
|
|
68
70
|
return running
|
package/src/prompt.js
CHANGED
|
@@ -36,7 +36,8 @@ const DELEGATION_HEAD = `## Delegation
|
|
|
36
36
|
|
|
37
37
|
const FANOUT_PTC = '- For repeated same-shaped work, dispatch all subagents inside one run_code program, then collect them with wait_subagent.'
|
|
38
38
|
|
|
39
|
-
const DELEGATION_TAIL = `- Waiting is done with wait_subagent only: do independent work first, then pass every id you need to a single wait_subagent call and let it block. Do not end the turn to wait for a notification unless nothing else is left to do.
|
|
39
|
+
const DELEGATION_TAIL = `- Waiting for delegated subagents is done with wait_subagent only: do independent work first, then pass every subagent name (or durable id) you need to a single wait_subagent call and let it block. Do not end the turn to wait for a notification unless nothing else is left to do.
|
|
40
|
+
- list_agents shows the tree with names; send_message targets a name, and wait_subagent accepts the name returned by subagent.
|
|
40
41
|
- send_message is for new information or a correction, never for asking about progress, nudging, or checking in. Do not poll list_agents in place of waiting, and do not interrupt_agent a normally running subagent; intervene only for substantive new information, a clear failure or blockage, or a user request to stop.
|
|
41
42
|
- A wait_subagent timeout while a subagent is still running is not a failure: wait again or do independent work. Do not re-dispatch or take over solely because it is taking a long time.
|
|
42
43
|
- The main agent owns integration, review, and final verification. Subagent reports are leads, not evidence: check the actual changes yourself.
|
|
@@ -81,7 +82,7 @@ export function renderCliCatalog(config) {
|
|
|
81
82
|
return [
|
|
82
83
|
'Better Subagent CLI subagents: subagent also accepts provider="codex" or provider="claude"; model and reasoning_effort default to Better Subagent settings (list_subagent_models with that provider shows allowed values).',
|
|
83
84
|
'They always run in the background, start in cwd (default: current directory) with permissions from Better Subagent settings; subagent_fork and agent_preset are unsupported.',
|
|
84
|
-
'Control them
|
|
85
|
+
'Control them through list_agents names with send_message; wait_subagent accepts the name returned by subagent, and interrupt_agent is disabled in the engineering presets.',
|
|
85
86
|
catalog,
|
|
86
87
|
].join('\n')
|
|
87
88
|
}
|
package/src/subagents.js
CHANGED
|
@@ -122,24 +122,28 @@ export async function startCliSubagent(ctx, config, sessions, args, exec) {
|
|
|
122
122
|
model: selected.model, effort: selected.effort, delivered: [], started: false,
|
|
123
123
|
}
|
|
124
124
|
await sessions.put(record)
|
|
125
|
+
let created
|
|
125
126
|
try {
|
|
126
127
|
exec.signal.throwIfAborted()
|
|
127
128
|
const maxDepth = ctx.subagents.resolveMaxDepth()
|
|
128
|
-
|
|
129
|
+
created = await ctx.subagents.startActivation({
|
|
129
130
|
provider: 'spawn', label: args.description, childId: id, signal: exec.signal,
|
|
130
131
|
delivery: 'parent',
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
...(maxDepth === undefined ? {} : { maxDepth }),
|
|
135
|
-
},
|
|
132
|
+
parent, prompt: [{ type: 'text', text: args.prompt }], cwd,
|
|
133
|
+
agentOptions: { provider: CLI_ROUTES[cli], model: selected.model, reasoningEffort: selected.effort },
|
|
134
|
+
...(maxDepth === undefined ? {} : { maxDepth }),
|
|
136
135
|
})
|
|
137
136
|
exec.signal.throwIfAborted()
|
|
138
|
-
|
|
137
|
+
// rc.2's native subagent tool returns the tree name, not the durable id.
|
|
138
|
+
return { kind: 'activation', name: created.name ?? created.childId, childId: created.childId, activation: created }
|
|
139
139
|
} catch (error) {
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
|
|
140
|
+
// rc.2 rolls back pre-admission failures in the manager. A published
|
|
141
|
+
// activation still needs explicit disposal for the post-admission abort race.
|
|
142
|
+
if (created !== undefined) {
|
|
143
|
+
try { await created.dispose() } catch (disposeError) {
|
|
144
|
+
ctx.logger?.warn?.(`Better Subagent could not dispose canceled CLI child ${id}: ${disposeError.message}`)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
143
147
|
await sessions.delete(id)
|
|
144
148
|
throw error
|
|
145
149
|
}
|
|
@@ -154,8 +158,7 @@ export function installCliRouting(ctx, config, sessions) {
|
|
|
154
158
|
const reclaim = (entry) => {
|
|
155
159
|
if (entry.cleanup) return entry.cleanup
|
|
156
160
|
const task = (async () => {
|
|
157
|
-
await
|
|
158
|
-
await sessions.delete(entry.id)
|
|
161
|
+
try { await entry.activation?.dispose() } finally { await sessions.delete(entry.id) }
|
|
159
162
|
})()
|
|
160
163
|
entry.cleanup = task
|
|
161
164
|
cleanups.add(task)
|
|
@@ -168,7 +171,7 @@ export function installCliRouting(ctx, config, sessions) {
|
|
|
168
171
|
const entry = unpublished.get(key)
|
|
169
172
|
if (!entry) return
|
|
170
173
|
unpublished.delete(key)
|
|
171
|
-
if (!result.isError && result.value?.kind === 'activation' && result.value.
|
|
174
|
+
if (!result.isError && result.value?.kind === 'activation' && result.value.name === entry.name) return
|
|
172
175
|
void reclaim(entry)
|
|
173
176
|
})
|
|
174
177
|
ctx.tools.guard((exec) => {
|
|
@@ -191,8 +194,9 @@ export function installCliRouting(ctx, config, sessions) {
|
|
|
191
194
|
if (exec.name === 'subagent' && cliName(args.provider)) {
|
|
192
195
|
const signal = AbortSignal.any([exec.signal, lifetime.signal])
|
|
193
196
|
const creation = (async () => {
|
|
194
|
-
const
|
|
195
|
-
|
|
197
|
+
const created = await startCliSubagent(ctx, config, sessions, args, { ...exec, signal })
|
|
198
|
+
const { activation, childId, ...value } = created
|
|
199
|
+
unpublished.set(exec.token ?? exec, { parent: exec.agent, id: childId, name: value.name, activation })
|
|
196
200
|
return success(value)
|
|
197
201
|
})()
|
|
198
202
|
creating.add(creation)
|
package/src/wait-subagent.js
CHANGED
|
@@ -201,7 +201,7 @@ export function installWaitTool(ctx) {
|
|
|
201
201
|
type: 'array',
|
|
202
202
|
items: { type: 'string' },
|
|
203
203
|
minItems: 1,
|
|
204
|
-
description: '
|
|
204
|
+
description: 'Names returned by subagent/list_agents, or durable ids.',
|
|
205
205
|
},
|
|
206
206
|
timeout_ms: {
|
|
207
207
|
type: 'integer',
|
|
@@ -218,43 +218,67 @@ export function installWaitTool(ctx) {
|
|
|
218
218
|
async execute(args, exec) {
|
|
219
219
|
// Dedupe preserving input order; the schema already enforces a
|
|
220
220
|
// non-empty array, the guard below only covers malformed direct calls.
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
221
|
+
const refs = [...new Set(Array.isArray(args.subagent_id) ? args.subagent_id : [])]
|
|
222
|
+
if (refs.length === 0) return 'subagent_id must be a non-empty array of subagent names or ids.'
|
|
223
223
|
const parent = exec.agent
|
|
224
224
|
if (parent === undefined) throw new Error('wait_subagent requires a calling agent (exec.agent was undefined)')
|
|
225
225
|
|
|
226
|
-
// Verify every
|
|
227
|
-
// waiting for nobody (the contract the single-id version had).
|
|
226
|
+
// Verify every reference resolves to one of this agent's direct children —
|
|
227
|
+
// fail fast, waiting for nobody (the contract the single-id version had).
|
|
228
228
|
let entries
|
|
229
229
|
try {
|
|
230
|
-
|
|
230
|
+
// rc.2 removed listChildren; a depth-one slice of the descendant walk
|
|
231
|
+
// is the same direct-child catalog without loading child Agents.
|
|
232
|
+
entries = (await ctx.subagents.listDescendants(parent.id, exec.signal))
|
|
233
|
+
.filter((entry) => entry.depth === 1)
|
|
231
234
|
} catch (error) {
|
|
232
|
-
return '
|
|
235
|
+
return 'subagent listing failed: ' + (error && error.message ? error.message : String(error))
|
|
233
236
|
}
|
|
234
237
|
const known = new Set(entries.map((entry) => entry.id))
|
|
235
|
-
const
|
|
238
|
+
const resolved = []
|
|
239
|
+
const unknown = []
|
|
240
|
+
for (const ref of refs) {
|
|
241
|
+
let id
|
|
242
|
+
try {
|
|
243
|
+
// rc.2 names are the model-facing handles; a single token that is not
|
|
244
|
+
// a tree name is returned as a durable id, so both continue to work.
|
|
245
|
+
id = await ctx.subagents.resolveName(parent, ref, exec.signal)
|
|
246
|
+
} catch {
|
|
247
|
+
unknown.push(ref)
|
|
248
|
+
continue
|
|
249
|
+
}
|
|
250
|
+
if (!known.has(id)) {
|
|
251
|
+
unknown.push(ref)
|
|
252
|
+
continue
|
|
253
|
+
}
|
|
254
|
+
if (!resolved.some((entry) => entry.id === id)) resolved.push({ ref, id })
|
|
255
|
+
}
|
|
236
256
|
if (unknown.length > 0) {
|
|
237
|
-
return `unknown subagent ${unknown.map((
|
|
257
|
+
return `unknown subagent ${unknown.map((ref) => `"${ref}"`).join(', ')}: not a direct child of this agent (list_agents shows your children; only depth-1 children can be awaited).`
|
|
238
258
|
}
|
|
259
|
+
const ids = resolved.map((entry) => entry.id)
|
|
260
|
+
const labels = new Map(resolved.map((entry) => [entry.id, entry.ref]))
|
|
261
|
+
const displayOf = (id) => labels.get(id) ?? id
|
|
239
262
|
|
|
240
263
|
const startedAt = Date.now()
|
|
241
264
|
const capMs = typeof args.timeout_ms === 'number' && args.timeout_ms > 0 ? Math.max(args.timeout_ms, MIN_TIMEOUT_MS) : undefined
|
|
242
265
|
|
|
243
266
|
const lineOf = (id, outcome) => {
|
|
244
|
-
|
|
245
|
-
if (outcome.kind === '
|
|
267
|
+
const display = displayOf(id)
|
|
268
|
+
if (outcome.kind === 'aborted') return `wait for subagent ${display} was aborted by user interruption; the child may still be running.`
|
|
269
|
+
if (outcome.kind === 'timedOut') return `timed out waiting for subagent ${display}; it is still running. You will be notified when it finishes — you can wait_subagent it again or continue with other work.`
|
|
246
270
|
if (outcome.kind === 'notStarted') {
|
|
247
|
-
return `subagent ${
|
|
271
|
+
return `subagent ${display} has not started after ${Math.round(START_GRACE_MS / 1000)}s (status: ${statusOf(id)}). It may still be spinning up — call wait_subagent again, or continue with other work; you will be notified when it finishes.`
|
|
248
272
|
}
|
|
249
273
|
if (outcome.kind === 'unconfirmed') {
|
|
250
|
-
return `subagent ${
|
|
274
|
+
return `subagent ${display} is not running, but its current turn state could not be confirmed (session state unavailable). Call wait_subagent again, or inspect it with list_agents before continuing.`
|
|
251
275
|
}
|
|
252
276
|
if (outcome.kind === 'endedEarlier') {
|
|
253
|
-
return `subagent ${
|
|
277
|
+
return `subagent ${display} already finished its last turn (${outcome.reason?.kind ?? 'completed'}) and has no queued input; no new settlement was observed during this wait (its earlier notice was delivered before it). Use send_message to continue it if needed.`
|
|
254
278
|
}
|
|
255
279
|
// Real settlement: short done line; the framework's settlement notice
|
|
256
280
|
// carries the closing message — nothing to consume or deduplicate.
|
|
257
|
-
return DONE(
|
|
281
|
+
return DONE(display, outcome.info && outcome.info.stopReason)
|
|
258
282
|
}
|
|
259
283
|
|
|
260
284
|
/**
|