@armadra/agent 0.15.1 → 0.16.0
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 +30 -0
- package/CHANGELOG.zh-CN.md +30 -0
- package/dist/agent/recovery-reminder.d.ts +23 -0
- package/dist/agent/recovery-reminder.js +42 -0
- package/dist/agent/reminders.d.ts +10 -4
- package/dist/agent/reminders.js +59 -19
- package/dist/agent/session-plan.js +3 -4
- package/dist/agent/session-settings.d.ts +5 -0
- package/dist/agent/session-settings.js +15 -2
- package/dist/agent/session-subagent.d.ts +5 -0
- package/dist/agent/session-subagent.js +65 -12
- package/dist/agent/session-tools.d.ts +3 -1
- package/dist/agent/session-tools.js +47 -3
- package/dist/agent/subagent-background.js +1 -0
- package/dist/agent/subagent-fork.js +3 -1
- package/dist/agent/subagent-handle.d.ts +22 -0
- package/dist/agent/subagent-handle.js +55 -0
- package/dist/agent/subagent-lifetime.d.ts +35 -0
- package/dist/agent/subagent-lifetime.js +112 -0
- package/dist/agent/subagent-registry.d.ts +23 -15
- package/dist/agent/subagent-registry.js +68 -81
- package/dist/agent/system-prompt.d.ts +8 -0
- package/dist/agent/system-prompt.js +4 -0
- package/dist/agent/types-w5.d.ts +8 -3
- package/dist/agent/types.d.ts +7 -0
- package/dist/agents/builtin.d.ts +1 -1
- package/dist/agents/builtin.js +3 -2
- package/dist/agents/report.d.ts +25 -0
- package/dist/agents/report.js +51 -0
- package/dist/agents/result.d.ts +9 -1
- package/dist/agents/result.js +16 -0
- package/dist/agents/task-control.d.ts +12 -0
- package/dist/agents/task-record.d.ts +24 -1
- package/dist/agents/task-record.js +24 -0
- package/dist/bundle/ama.cjs +3144 -1771
- package/dist/cli/bootstrap.js +14 -7
- package/dist/cli/compose-agents.d.ts +2 -1
- package/dist/cli/compose-agents.js +4 -1
- package/dist/cli/compose-events.d.ts +18 -3
- package/dist/cli/compose-events.js +17 -2
- package/dist/cli/compose-session.d.ts +1 -1
- package/dist/cli/compose-session.js +8 -16
- package/dist/cli/compose.d.ts +8 -0
- package/dist/cli/compose.js +25 -1
- package/dist/cli/deps.d.ts +12 -0
- package/dist/config/json-schema.js +4 -0
- package/dist/config/key-docs.js +3 -1
- package/dist/config/schema-w5.js +3 -0
- package/dist/config/schema.js +12 -1
- package/dist/config/settings-registry.js +4 -0
- package/dist/config/types-w5.d.ts +2 -0
- package/dist/config/types.d.ts +7 -0
- package/dist/drivers/acp/types.d.ts +4 -0
- package/dist/drivers/runner.js +5 -0
- package/dist/drivers/turn.d.ts +7 -0
- package/dist/drivers/turn.js +21 -0
- package/dist/drivers/types.d.ts +6 -0
- package/dist/hooks/dispatcher.d.ts +7 -1
- package/dist/hooks/dispatcher.js +28 -1
- package/dist/hooks/matcher.d.ts +4 -0
- package/dist/hooks/matcher.js +19 -2
- package/dist/host/api-impl.d.ts +8 -0
- package/dist/host/api-impl.js +10 -0
- package/dist/host/resources.d.ts +25 -0
- package/dist/host/resources.js +63 -0
- package/dist/host/types.d.ts +24 -2
- package/dist/host/types.js +9 -2
- package/dist/host.d.ts +1 -0
- package/dist/host.js +2 -0
- package/dist/i18n/catalog.d.ts +26 -0
- package/dist/i18n/messages/approval.d.ts +9 -0
- package/dist/i18n/messages/approval.js +9 -0
- package/dist/i18n/messages/config-keys.d.ts +8 -0
- package/dist/i18n/messages/config-keys.js +8 -0
- package/dist/i18n/messages/config.d.ts +8 -0
- package/dist/i18n/messages/drivers.d.ts +16 -0
- package/dist/i18n/messages/drivers.js +16 -0
- package/dist/i18n/messages/panels.d.ts +15 -0
- package/dist/i18n/messages/panels.js +5 -0
- package/dist/i18n/messages/settings.d.ts +6 -0
- package/dist/i18n/messages/settings.js +6 -0
- package/dist/modes/acp/acp-events.d.ts +3 -0
- package/dist/modes/acp/acp-events.js +21 -0
- package/dist/modes/interactive/agent-bar.d.ts +7 -2
- package/dist/modes/interactive/agent-bar.js +16 -6
- package/dist/modes/interactive/approval-ui.d.ts +2 -0
- package/dist/modes/interactive/approval-ui.js +4 -1
- package/dist/modes/interactive/interactive-mode.js +6 -1
- package/dist/modes/interactive/key-dispatch.d.ts +5 -0
- package/dist/modes/interactive/key-dispatch.js +28 -4
- package/dist/modes/interactive/program-status-ui.d.ts +1 -0
- package/dist/modes/interactive/program-status-ui.js +38 -5
- package/dist/modes/interactive/session-events.js +13 -1
- package/dist/modes/interactive/subagent-view.d.ts +4 -1
- package/dist/modes/interactive/subagent-view.js +26 -6
- package/dist/modes/interactive/tasks-report.d.ts +4 -1
- package/dist/modes/interactive/tasks-report.js +12 -0
- package/dist/modes/rpc/commands.d.ts +10 -1
- package/dist/modes/rpc/commands.js +19 -1
- package/dist/permissions/broker.d.ts +38 -3
- package/dist/permissions/broker.js +118 -7
- package/dist/permissions/pipeline.d.ts +11 -10
- package/dist/permissions/pipeline.js +18 -46
- package/dist/permissions/rules.d.ts +21 -4
- package/dist/permissions/rules.js +43 -9
- package/dist/permissions/session-grants.d.ts +14 -0
- package/dist/permissions/session-grants.js +47 -0
- package/dist/permissions/types.d.ts +18 -0
- package/dist/session/unclean-end.d.ts +47 -0
- package/dist/session/unclean-end.js +153 -0
- package/dist/tools/background-jobs.d.ts +50 -3
- package/dist/tools/background-jobs.js +70 -6
- package/dist/tools/bash-jobs.d.ts +26 -0
- package/dist/tools/bash-jobs.js +165 -0
- package/dist/tools/bash.d.ts +22 -5
- package/dist/tools/bash.js +76 -103
- package/dist/tools/output-accumulator.d.ts +5 -0
- package/dist/tools/output-accumulator.js +9 -0
- package/dist/tools/read-lines.d.ts +2 -0
- package/dist/tools/read-lines.js +4 -0
- package/dist/tools/read-resource.d.ts +24 -0
- package/dist/tools/read-resource.js +129 -0
- package/dist/tools/read.d.ts +7 -2
- package/dist/tools/read.js +16 -5
- package/dist/tools/registry.d.ts +5 -2
- package/dist/tools/registry.js +8 -3
- package/dist/tools/report.d.ts +24 -0
- package/dist/tools/report.js +81 -0
- package/dist/tools/resource-ref.d.ts +90 -0
- package/dist/tools/resource-ref.js +90 -0
- package/dist/tools/task-ctl.d.ts +8 -1
- package/dist/tools/task-ctl.js +31 -5
- package/dist/tools/task.d.ts +2 -0
- package/dist/tools/task.js +3 -0
- package/dist/tools/timers.d.ts +18 -0
- package/dist/tools/timers.js +26 -0
- package/dist/tools/types.d.ts +30 -0
- package/dist/tools/types.js +2 -0
- package/docs/en/guides/permissions.md +14 -0
- package/docs/en/guides/tui.md +21 -21
- package/docs/en/reference/acp.md +15 -14
- package/docs/en/reference/host-api.md +48 -20
- package/docs/en/reference/rpc.md +12 -9
- package/docs/guides/agents.md +83 -22
- package/docs/guides/hooks.md +12 -9
- package/docs/guides/permissions.md +14 -0
- package/docs/guides/tui.md +21 -21
- package/docs/reference/acp.md +15 -14
- package/docs/reference/host-api.md +69 -41
- package/docs/reference/rpc.md +15 -9
- package/docs/reference/session-format.md +29 -11
- package/package.json +1 -1
|
@@ -38,6 +38,8 @@ export declare const en: {
|
|
|
38
38
|
"tools.default": string;
|
|
39
39
|
"tools.maxToolResultChars": string;
|
|
40
40
|
"tools.bashTimeoutMs": string;
|
|
41
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
42
|
+
"tools.bashBackgroundMaxMs": string;
|
|
41
43
|
"tools.disabled": string;
|
|
42
44
|
codemode: string;
|
|
43
45
|
"codemode.mode": string;
|
|
@@ -118,6 +120,7 @@ export declare const en: {
|
|
|
118
120
|
"subagents.forkMaxContextRatio": string;
|
|
119
121
|
"subagents.background": string;
|
|
120
122
|
"subagents.autoBackgroundAfterMs": string;
|
|
123
|
+
"subagents.backgroundMaxMs": string;
|
|
121
124
|
models: string;
|
|
122
125
|
"models.aliases": string;
|
|
123
126
|
"models.aliases.fast": string;
|
|
@@ -142,6 +145,7 @@ export declare const en: {
|
|
|
142
145
|
"codemode.mode": string;
|
|
143
146
|
"ui.ascii": string;
|
|
144
147
|
"ui.statusLine": string;
|
|
148
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
145
149
|
"plan.directory": string;
|
|
146
150
|
"plan.model": string;
|
|
147
151
|
"plan.thinkingLevel": string;
|
|
@@ -307,6 +311,8 @@ export declare const zh: {
|
|
|
307
311
|
"tools.default": string;
|
|
308
312
|
"tools.maxToolResultChars": string;
|
|
309
313
|
"tools.bashTimeoutMs": string;
|
|
314
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
315
|
+
"tools.bashBackgroundMaxMs": string;
|
|
310
316
|
"tools.disabled": string;
|
|
311
317
|
codemode: string;
|
|
312
318
|
"codemode.mode": string;
|
|
@@ -387,6 +393,7 @@ export declare const zh: {
|
|
|
387
393
|
"subagents.forkMaxContextRatio": string;
|
|
388
394
|
"subagents.background": string;
|
|
389
395
|
"subagents.autoBackgroundAfterMs": string;
|
|
396
|
+
"subagents.backgroundMaxMs": string;
|
|
390
397
|
models: string;
|
|
391
398
|
"models.aliases": string;
|
|
392
399
|
"models.aliases.fast": string;
|
|
@@ -411,6 +418,7 @@ export declare const zh: {
|
|
|
411
418
|
"codemode.mode": string;
|
|
412
419
|
"ui.ascii": string;
|
|
413
420
|
"ui.statusLine": string;
|
|
421
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
414
422
|
"plan.directory": string;
|
|
415
423
|
"plan.model": string;
|
|
416
424
|
"plan.thinkingLevel": string;
|
|
@@ -58,6 +58,14 @@ export declare const en: {
|
|
|
58
58
|
warmingNeedsFunction: string;
|
|
59
59
|
runnerNeedsIdStart: string;
|
|
60
60
|
runnerDoneNeedsFunction: string;
|
|
61
|
+
resourceFrozen: string;
|
|
62
|
+
resourceNotObject: string;
|
|
63
|
+
resourceBadScheme: (scheme: string) => string;
|
|
64
|
+
resourceReserved: (scheme: string) => string;
|
|
65
|
+
resourceBadDescribe: (scheme: string) => string;
|
|
66
|
+
resourceNoRead: (scheme: string) => string;
|
|
67
|
+
resourceExists: (scheme: string) => string;
|
|
68
|
+
resourceTooMany: (max: number) => string;
|
|
61
69
|
notAdapter: (label: string) => string;
|
|
62
70
|
versionMismatch: (label: string, found: string, needed: number) => string;
|
|
63
71
|
noCreate: (label: string) => string;
|
|
@@ -117,6 +125,14 @@ export declare const zh: {
|
|
|
117
125
|
warmingNeedsFunction: string;
|
|
118
126
|
runnerNeedsIdStart: string;
|
|
119
127
|
runnerDoneNeedsFunction: string;
|
|
128
|
+
resourceFrozen: string;
|
|
129
|
+
resourceNotObject: string;
|
|
130
|
+
resourceBadScheme: (scheme: string) => string;
|
|
131
|
+
resourceReserved: (scheme: string) => string;
|
|
132
|
+
resourceBadDescribe: (scheme: string) => string;
|
|
133
|
+
resourceNoRead: (scheme: string) => string;
|
|
134
|
+
resourceExists: (scheme: string) => string;
|
|
135
|
+
resourceTooMany: (max: number) => string;
|
|
120
136
|
notAdapter: (label: string) => string;
|
|
121
137
|
versionMismatch: (label: string, found: string, needed: number) => string;
|
|
122
138
|
noCreate: (label: string) => string;
|
|
@@ -59,6 +59,14 @@ export const en = {
|
|
|
59
59
|
warmingNeedsFunction: "cache.onWarmingDecision: needs a function",
|
|
60
60
|
runnerNeedsIdStart: "runners.provide: needs a runner with id and start",
|
|
61
61
|
runnerDoneNeedsFunction: "runners.onDone: needs a function",
|
|
62
|
+
resourceFrozen: "resources.register: resources must be registered inside create(); the list is fixed once the session starts",
|
|
63
|
+
resourceNotObject: "resources.register: the resource must be an object",
|
|
64
|
+
resourceBadScheme: (scheme) => `resources.register: invalid scheme ${scheme} (expected ^[a-z][a-z0-9+.-]{1,31}$)`,
|
|
65
|
+
resourceReserved: (scheme) => `resources.register: scheme ${scheme} is reserved (URLs go through web_fetch, files through read)`,
|
|
66
|
+
resourceBadDescribe: (scheme) => `resources.register: ${scheme} needs a single-line describe of at most 120 characters`,
|
|
67
|
+
resourceNoRead: (scheme) => `resources.register: ${scheme} is missing read()`,
|
|
68
|
+
resourceExists: (scheme) => `resources.register: scheme ${scheme} already exists`,
|
|
69
|
+
resourceTooMany: (max) => `resources.register: at most ${max} resource schemes`,
|
|
62
70
|
notAdapter: (label) => `${label}: not a host adapter module (missing hostApi / create export)`,
|
|
63
71
|
versionMismatch: (label, found, needed) => `${label}: host adapter hostApi=${found}, ama needs ${needed}`,
|
|
64
72
|
noCreate: (label) => `${label}: missing create(api) function`,
|
|
@@ -118,6 +126,14 @@ export const zh = {
|
|
|
118
126
|
warmingNeedsFunction: "cache.onWarmingDecision:需要函数",
|
|
119
127
|
runnerNeedsIdStart: "runners.provide:需要带 id 与 start 的 runner",
|
|
120
128
|
runnerDoneNeedsFunction: "runners.onDone:需要函数",
|
|
129
|
+
resourceFrozen: "resources.register:资源只能在 create() 里注册,会话开始后列表已固定",
|
|
130
|
+
resourceNotObject: "resources.register:资源应为对象",
|
|
131
|
+
resourceBadScheme: (scheme) => `resources.register:scheme 不合法:${scheme}(应匹配 ^[a-z][a-z0-9+.-]{1,31}$)`,
|
|
132
|
+
resourceReserved: (scheme) => `resources.register:scheme ${scheme} 是保留字(URL 走 web_fetch,文件走 read)`,
|
|
133
|
+
resourceBadDescribe: (scheme) => `resources.register:${scheme} 需要单行、不超过 120 字符的 describe`,
|
|
134
|
+
resourceNoRead: (scheme) => `resources.register:${scheme} 缺少 read()`,
|
|
135
|
+
resourceExists: (scheme) => `resources.register:scheme ${scheme} 已存在`,
|
|
136
|
+
resourceTooMany: (max) => `resources.register:最多 ${max} 个资源 scheme`,
|
|
121
137
|
notAdapter: (label) => `${label}: 不是宿主适配器模块(缺少 hostApi / create 导出)`,
|
|
122
138
|
versionMismatch: (label, found, needed) => `${label}: 宿主适配器 hostApi=${found},ama 需要 ${needed}`,
|
|
123
139
|
noCreate: (label) => `${label}: 缺少 create(api) 函数`,
|
|
@@ -120,6 +120,14 @@ export declare const en: {
|
|
|
120
120
|
fullOutput: (path: string) => string;
|
|
121
121
|
noOutput: string;
|
|
122
122
|
title: (id: string) => string;
|
|
123
|
+
/** [#269] 子 Agent 自报的状态与待人决定的问题。 */
|
|
124
|
+
report: {
|
|
125
|
+
ready: string;
|
|
126
|
+
blocked: string;
|
|
127
|
+
failed: string;
|
|
128
|
+
waiting: string;
|
|
129
|
+
};
|
|
130
|
+
needsPerson: (question: string) => string;
|
|
123
131
|
};
|
|
124
132
|
};
|
|
125
133
|
export declare const zh: {
|
|
@@ -231,6 +239,13 @@ export declare const zh: {
|
|
|
231
239
|
fullOutput: (path: string) => string;
|
|
232
240
|
noOutput: string;
|
|
233
241
|
title: (id: string) => string;
|
|
242
|
+
report: {
|
|
243
|
+
ready: string;
|
|
244
|
+
blocked: string;
|
|
245
|
+
failed: string;
|
|
246
|
+
waiting: string;
|
|
247
|
+
};
|
|
248
|
+
needsPerson: (question: string) => string;
|
|
234
249
|
};
|
|
235
250
|
};
|
|
236
251
|
export {};
|
|
@@ -120,6 +120,9 @@ export const en = {
|
|
|
120
120
|
fullOutput: (path) => `Full output: ${path}`,
|
|
121
121
|
noOutput: "(no output yet)",
|
|
122
122
|
title: (id) => `Task ${id}`,
|
|
123
|
+
/** [#269] 子 Agent 自报的状态与待人决定的问题。 */
|
|
124
|
+
report: { ready: "ready", blocked: "blocked", failed: "failed", waiting: "waiting" },
|
|
125
|
+
needsPerson: (question) => `needs a person: ${question}`,
|
|
123
126
|
},
|
|
124
127
|
};
|
|
125
128
|
export const zh = {
|
|
@@ -231,5 +234,7 @@ export const zh = {
|
|
|
231
234
|
fullOutput: (path) => `全文:${path}`,
|
|
232
235
|
noOutput: "(还没有输出)",
|
|
233
236
|
title: (id) => `任务 ${id}`,
|
|
237
|
+
report: { ready: "就绪", blocked: "受阻", failed: "失败", waiting: "等待中" },
|
|
238
|
+
needsPerson: (question) => `待人决定:${question}`,
|
|
234
239
|
},
|
|
235
240
|
};
|
|
@@ -53,6 +53,8 @@ export declare const en: {
|
|
|
53
53
|
"codemode.requireStrict": string;
|
|
54
54
|
"tools.maxToolResultChars": string;
|
|
55
55
|
"tools.bashTimeoutMs": string;
|
|
56
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
57
|
+
"tools.bashBackgroundMaxMs": string;
|
|
56
58
|
"images.resize": string;
|
|
57
59
|
"hooks.timeoutMs": string;
|
|
58
60
|
"compaction.enabled": string;
|
|
@@ -91,6 +93,7 @@ export declare const en: {
|
|
|
91
93
|
"subagents.maxPending": string;
|
|
92
94
|
"subagents.background": string;
|
|
93
95
|
"subagents.autoBackgroundAfterMs": string;
|
|
96
|
+
"subagents.backgroundMaxMs": string;
|
|
94
97
|
"memory.enabled": string;
|
|
95
98
|
"memory.subagents": string;
|
|
96
99
|
};
|
|
@@ -234,6 +237,8 @@ export declare const zh: {
|
|
|
234
237
|
"codemode.requireStrict": string;
|
|
235
238
|
"tools.maxToolResultChars": string;
|
|
236
239
|
"tools.bashTimeoutMs": string;
|
|
240
|
+
"tools.bashAutoBackgroundAfterMs": string;
|
|
241
|
+
"tools.bashBackgroundMaxMs": string;
|
|
237
242
|
"images.resize": string;
|
|
238
243
|
"hooks.timeoutMs": string;
|
|
239
244
|
"compaction.enabled": string;
|
|
@@ -272,6 +277,7 @@ export declare const zh: {
|
|
|
272
277
|
"subagents.maxPending": string;
|
|
273
278
|
"subagents.background": string;
|
|
274
279
|
"subagents.autoBackgroundAfterMs": string;
|
|
280
|
+
"subagents.backgroundMaxMs": string;
|
|
275
281
|
"memory.enabled": string;
|
|
276
282
|
"memory.subagents": string;
|
|
277
283
|
};
|
|
@@ -53,6 +53,8 @@ export const en = {
|
|
|
53
53
|
"codemode.requireStrict": "Codemode needs isolation",
|
|
54
54
|
"tools.maxToolResultChars": "Tool result limit",
|
|
55
55
|
"tools.bashTimeoutMs": "Bash timeout (ms)",
|
|
56
|
+
"tools.bashAutoBackgroundAfterMs": "Bash auto-background after (ms)",
|
|
57
|
+
"tools.bashBackgroundMaxMs": "Bash job lifetime (ms)",
|
|
56
58
|
"images.resize": "Resize images",
|
|
57
59
|
"hooks.timeoutMs": "Hook timeout (ms)",
|
|
58
60
|
"compaction.enabled": "Auto compaction",
|
|
@@ -91,6 +93,7 @@ export const en = {
|
|
|
91
93
|
"subagents.maxPending": "Subagent queue limit",
|
|
92
94
|
"subagents.background": "Subagents in background",
|
|
93
95
|
"subagents.autoBackgroundAfterMs": "Auto-background after (ms)",
|
|
96
|
+
"subagents.backgroundMaxMs": "Background task lifetime (ms)",
|
|
94
97
|
"memory.enabled": "Memory",
|
|
95
98
|
"memory.subagents": "Memory in subagents",
|
|
96
99
|
},
|
|
@@ -228,6 +231,8 @@ export const zh = {
|
|
|
228
231
|
"codemode.requireStrict": "codemode 要求隔离",
|
|
229
232
|
"tools.maxToolResultChars": "工具结果上限",
|
|
230
233
|
"tools.bashTimeoutMs": "bash 超时(毫秒)",
|
|
234
|
+
"tools.bashAutoBackgroundAfterMs": "bash 自动转后台(毫秒)",
|
|
235
|
+
"tools.bashBackgroundMaxMs": "bash 后台任务寿命(毫秒)",
|
|
231
236
|
"images.resize": "图片缩放",
|
|
232
237
|
"hooks.timeoutMs": "Hook 超时(毫秒)",
|
|
233
238
|
"compaction.enabled": "自动压缩",
|
|
@@ -266,6 +271,7 @@ export const zh = {
|
|
|
266
271
|
"subagents.maxPending": "子 Agent 排队上限",
|
|
267
272
|
"subagents.background": "子 Agent 缺省后台",
|
|
268
273
|
"subagents.autoBackgroundAfterMs": "自动转后台(毫秒)",
|
|
274
|
+
"subagents.backgroundMaxMs": "后台任务寿命(毫秒)",
|
|
269
275
|
"memory.enabled": "记忆",
|
|
270
276
|
"memory.subagents": "子 Agent 的记忆",
|
|
271
277
|
},
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* | permission_request(toolCallId 已公布) | tool_call_update(pending) |
|
|
12
12
|
* | permission_resolved(allow / allow_session)| tool_call_update(in_progress) |
|
|
13
13
|
* | tool_execution_end | tool_call_update(completed / failed,`[diff?, text]`,locations[].line) |
|
|
14
|
+
* | subagent_update{kind:"report"} | tool_call_update(只带 `_meta.ama.{taskId, report}`,挂在发起的 task 调用上;[#269]) |
|
|
14
15
|
* | todo_updated | plan |
|
|
15
16
|
* | message_end(助手)/ turn_end | usage_update(上下文用量、窗口、会话累计美元;与上次同值不发) |
|
|
16
17
|
* | permission_mode_changed | current_mode_update + config_option_update |
|
|
@@ -47,6 +48,8 @@ export declare class AcpEventMapper {
|
|
|
47
48
|
};
|
|
48
49
|
/** 模型已发出、尚未执行完的工具调用(按工具名 + 参数匹配的后备)。 */
|
|
49
50
|
private readonly pendingCalls;
|
|
51
|
+
/** [#269] 子 Agent 任务 → 发起它的 task 调用(ama 的 toolCallId)。 */
|
|
52
|
+
private readonly taskParents;
|
|
50
53
|
/** 已经以 `tool_call` 公布、尚未结束的调用:id → title(含 codemode 内层)。 */
|
|
51
54
|
private readonly published;
|
|
52
55
|
/** 挂起的权限请求:requestId → 已公布的 toolCallId。 */
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* | permission_request(toolCallId 已公布) | tool_call_update(pending) |
|
|
12
12
|
* | permission_resolved(allow / allow_session)| tool_call_update(in_progress) |
|
|
13
13
|
* | tool_execution_end | tool_call_update(completed / failed,`[diff?, text]`,locations[].line) |
|
|
14
|
+
* | subagent_update{kind:"report"} | tool_call_update(只带 `_meta.ama.{taskId, report}`,挂在发起的 task 调用上;[#269]) |
|
|
14
15
|
* | todo_updated | plan |
|
|
15
16
|
* | message_end(助手)/ turn_end | usage_update(上下文用量、窗口、会话累计美元;与上次同值不发) |
|
|
16
17
|
* | permission_mode_changed | current_mode_update + config_option_update |
|
|
@@ -46,6 +47,8 @@ export class AcpEventMapper {
|
|
|
46
47
|
extras;
|
|
47
48
|
/** 模型已发出、尚未执行完的工具调用(按工具名 + 参数匹配的后备)。 */
|
|
48
49
|
pendingCalls = [];
|
|
50
|
+
/** [#269] 子 Agent 任务 → 发起它的 task 调用(ama 的 toolCallId)。 */
|
|
51
|
+
taskParents = new Map();
|
|
49
52
|
/** 已经以 `tool_call` 公布、尚未结束的调用:id → title(含 codemode 内层)。 */
|
|
50
53
|
published = new Map();
|
|
51
54
|
/** 挂起的权限请求:requestId → 已公布的 toolCallId。 */
|
|
@@ -188,6 +191,24 @@ export class AcpEventMapper {
|
|
|
188
191
|
this.status(id, "in_progress");
|
|
189
192
|
return;
|
|
190
193
|
}
|
|
194
|
+
case "subagent_start":
|
|
195
|
+
this.taskParents.set(event.taskId, event.parentToolCallId);
|
|
196
|
+
return;
|
|
197
|
+
case "subagent_update": {
|
|
198
|
+
// [#269] 结构化报告只随 _meta 走:不改父 task 调用的状态与内容(后台任务的父调用可能早已结束)
|
|
199
|
+
if (event.kind !== "report" || event.report === undefined)
|
|
200
|
+
return;
|
|
201
|
+
const parent = this.taskParents.get(event.taskId);
|
|
202
|
+
if (parent === undefined)
|
|
203
|
+
return;
|
|
204
|
+
const meta = { taskId: event.taskId, report: event.report };
|
|
205
|
+
this.emit({
|
|
206
|
+
sessionUpdate: "tool_call_update",
|
|
207
|
+
toolCallId: this.wireId(parent),
|
|
208
|
+
_meta: { [ACP_META_KEY]: meta },
|
|
209
|
+
});
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
191
212
|
case "todo_updated":
|
|
192
213
|
this.emit({
|
|
193
214
|
sessionUpdate: "plan",
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
* - 聚焦(`Ctrl+B` / 空输入 `↓` / `/tasks`):列出本会话全部任务,`›` 标当前项,窗口跟着选择滚动,
|
|
16
16
|
* 末行是按键提示(`↑↓ 选择 · Enter 打开 · b 转后台 · x 停止 · Esc 返回`,放不下时丢 b / x 说明)。
|
|
17
17
|
* 按键处理在 agent-ui.ts。
|
|
18
|
-
* - [W7-C]
|
|
18
|
+
* - [W7-C] 等审批的行(含停靠在栏里的后台任务审批)整行警告色;[#269] 子 Agent 留了待人决定的问题
|
|
19
|
+
* (`report.humanAction`)的行同样整行警告色,事实里带状态标签与问题。
|
|
19
20
|
* - 状态来自任务注册表(`TaskInfo`、`live().queued`)、子 Agent 折叠视图的跟踪(轮数、最近工具、用时,界面时钟)
|
|
20
21
|
* 与 `permission_request.context.taskId`(等审批)。
|
|
21
22
|
*/
|
|
22
23
|
import type { SubagentRegistry } from "../../agent/subagent-registry.js";
|
|
23
24
|
import type { SubagentStatus } from "../../agent/types.js";
|
|
24
|
-
import type { TaskInfo } from "../../tools/types.js";
|
|
25
|
+
import type { SubagentReport, TaskInfo } from "../../tools/types.js";
|
|
25
26
|
import { type Component, type Theme } from "../../tui.js";
|
|
26
27
|
import type { SubagentTracker } from "./subagent-view.js";
|
|
27
28
|
export declare const BAR_ROWS = 3;
|
|
@@ -39,6 +40,8 @@ export interface BarRow {
|
|
|
39
40
|
elapsedMs?: number;
|
|
40
41
|
/** 外部 Agent 报告的上下文占用(已格式化,如 `34%`)。 */
|
|
41
42
|
context?: string;
|
|
43
|
+
/** [#269] 子 Agent 自报的状态;有 `humanAction` 时整行警告色。 */
|
|
44
|
+
report?: SubagentReport;
|
|
42
45
|
}
|
|
43
46
|
/** 栏与视图读的任务注册表(当前会话的 `registryOf(sessionId)`;测试给假的)。 */
|
|
44
47
|
export type TaskSource = Pick<SubagentRegistry, "list" | "get" | "live" | "message">;
|
|
@@ -65,6 +68,8 @@ export declare function taskRow(info: TaskInfo, ctx: {
|
|
|
65
68
|
export declare function agentLabel(row: Pick<BarRow, "agent" | "runner">): string;
|
|
66
69
|
/** `运行中 1m05s · 3 轮 · grep`(不带颜色)。 */
|
|
67
70
|
export declare function rowFacts(row: BarRow, withTool?: boolean): string;
|
|
71
|
+
/** [#269] 整行警告色:等审批,或子 Agent 留了待人决定的问题。 */
|
|
72
|
+
export declare function rowAlert(row: Pick<BarRow, "status" | "report">): boolean;
|
|
68
73
|
export declare class AgentBar implements Component {
|
|
69
74
|
private readonly deps;
|
|
70
75
|
/** 聚焦时的选择(undefined = 未聚焦)。 */
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
* - 聚焦(`Ctrl+B` / 空输入 `↓` / `/tasks`):列出本会话全部任务,`›` 标当前项,窗口跟着选择滚动,
|
|
16
16
|
* 末行是按键提示(`↑↓ 选择 · Enter 打开 · b 转后台 · x 停止 · Esc 返回`,放不下时丢 b / x 说明)。
|
|
17
17
|
* 按键处理在 agent-ui.ts。
|
|
18
|
-
* - [W7-C]
|
|
18
|
+
* - [W7-C] 等审批的行(含停靠在栏里的后台任务审批)整行警告色;[#269] 子 Agent 留了待人决定的问题
|
|
19
|
+
* (`report.humanAction`)的行同样整行警告色,事实里带状态标签与问题。
|
|
19
20
|
* - 状态来自任务注册表(`TaskInfo`、`live().queued`)、子 Agent 折叠视图的跟踪(轮数、最近工具、用时,界面时钟)
|
|
20
21
|
* 与 `permission_request.context.taskId`(等审批)。
|
|
21
22
|
*/
|
|
22
23
|
import { formatTaskContext } from "../../agents/task-record.js";
|
|
23
24
|
import { msg } from "../../i18n/index.js";
|
|
24
25
|
import { formatElapsed, truncateToWidth, visibleWidth, } from "../../tui.js";
|
|
26
|
+
import { reportFacts } from "./tasks-report.js";
|
|
25
27
|
export const BAR_ROWS = 3;
|
|
26
28
|
/** 结束后未查看的任务在栏里保留多久。 */
|
|
27
29
|
export const BAR_RETAIN_MS = 10 * 60_000;
|
|
@@ -75,6 +77,9 @@ export function taskRow(info, ctx) {
|
|
|
75
77
|
const context = formatTaskContext(info);
|
|
76
78
|
if (context !== undefined)
|
|
77
79
|
row.context = context;
|
|
80
|
+
const report = info.report ?? state?.report;
|
|
81
|
+
if (report !== undefined)
|
|
82
|
+
row.report = report;
|
|
78
83
|
const tool = state?.tools.at(-1);
|
|
79
84
|
if (tool !== undefined && status !== "queued")
|
|
80
85
|
row.tool = tool;
|
|
@@ -101,10 +106,15 @@ export function rowFacts(row, withTool = true) {
|
|
|
101
106
|
facts.push(msg().agents.turns(row.turns));
|
|
102
107
|
if (row.context !== undefined)
|
|
103
108
|
facts.push(msg().agents.context(row.context));
|
|
109
|
+
facts.push(...reportFacts(row.report));
|
|
104
110
|
if (withTool && row.tool !== undefined && row.status === "running")
|
|
105
111
|
facts.push(row.tool);
|
|
106
112
|
return facts.join(" · ");
|
|
107
113
|
}
|
|
114
|
+
/** [#269] 整行警告色:等审批,或子 Agent 留了待人决定的问题。 */
|
|
115
|
+
export function rowAlert(row) {
|
|
116
|
+
return row.status === "approval" || row.report?.humanAction !== undefined;
|
|
117
|
+
}
|
|
108
118
|
export class AgentBar {
|
|
109
119
|
deps;
|
|
110
120
|
/** 聚焦时的选择(undefined = 未聚焦)。 */
|
|
@@ -246,14 +256,14 @@ export class AgentBar {
|
|
|
246
256
|
const g = t.glyphs;
|
|
247
257
|
const agent = agentLabel(row);
|
|
248
258
|
const lead = focused ? (selected ? t.fg("accent", g.prompt) : " ") + " " : "";
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
const plainId = selected ||
|
|
252
|
-
const id =
|
|
259
|
+
const alert = rowAlert(row);
|
|
260
|
+
const marker = t.fg(alert ? "warning" : statusColor(row.status), g.tool);
|
|
261
|
+
const plainId = selected || alert ? t.bold(row.taskId) : row.taskId;
|
|
262
|
+
const id = alert ? t.fg("warning", plainId) : plainId;
|
|
253
263
|
const description = row.description.replace(/\s+/g, " ").trim();
|
|
254
264
|
const text = `${lead}${marker} ${id} ${t.fg("tool", agent)}` +
|
|
255
265
|
t.fg("dim", " · ") +
|
|
256
|
-
t.fg(
|
|
266
|
+
t.fg(alert ? "warning" : "muted", rowFacts(row)) +
|
|
257
267
|
(description === "" ? "" : ` ${t.fg("dim", description)}`);
|
|
258
268
|
return truncateToWidth(text, width, g.ellipsis);
|
|
259
269
|
}
|
|
@@ -40,6 +40,9 @@ export function createApprovalUi(deps) {
|
|
|
40
40
|
externalRunner: (agent) => agentUi.merge.externalRunner(agent),
|
|
41
41
|
...hooks,
|
|
42
42
|
report: (request, outcome) => {
|
|
43
|
+
// [#271] 被模式切换自动作答的:对话框因撤回而关闭,说明由 session-events 按条数汇总
|
|
44
|
+
if (request.reevaluation?.outcome !== undefined)
|
|
45
|
+
return;
|
|
43
46
|
if (outcome === "deny" || outcome === "cancelled") {
|
|
44
47
|
const text = approvalOutcomeText(request, outcome, taskAgent);
|
|
45
48
|
notice(outcome === "deny" ? "info" : "warn", text);
|
|
@@ -60,5 +63,5 @@ export function createApprovalUi(deps) {
|
|
|
60
63
|
agentUi.dock = dock;
|
|
61
64
|
indicator.docked = () => dock.size > 0;
|
|
62
65
|
const broker = mergingBroker(dock, agentUi.merge, (request) => notice("info", msg().interactive.app.followed(approvalOutcomeText(request, "allow", taskAgent))));
|
|
63
|
-
return { broker, dock };
|
|
66
|
+
return { broker, dock, approvalOpen: () => dialog.isOpen };
|
|
64
67
|
}
|
|
@@ -363,6 +363,8 @@ export function runInteractiveMode(runtime, context, options = {}) {
|
|
|
363
363
|
void session.steer(text).catch(() => undefined);
|
|
364
364
|
}
|
|
365
365
|
// ---- 键位 -----------------------------------------------------------------
|
|
366
|
+
// [#271] 审批对话框打开时 Shift+Tab 仍切模式(approvalUi 晚绑定)
|
|
367
|
+
let approvalOpen = () => false;
|
|
366
368
|
tui.addInputListener(createKeyDispatch({
|
|
367
369
|
keys,
|
|
368
370
|
editor,
|
|
@@ -370,6 +372,7 @@ export function runInteractiveMode(runtime, context, options = {}) {
|
|
|
370
372
|
status,
|
|
371
373
|
session: () => session,
|
|
372
374
|
inactive: () => finished || tui.hasOverlay,
|
|
375
|
+
approvalOpen: () => approvalOpen(),
|
|
373
376
|
busy: () => indicator.busy,
|
|
374
377
|
now,
|
|
375
378
|
showHint,
|
|
@@ -417,11 +420,13 @@ export function runInteractiveMode(runtime, context, options = {}) {
|
|
|
417
420
|
area,
|
|
418
421
|
});
|
|
419
422
|
indicator.agents = () => agentUi.reachable;
|
|
420
|
-
const
|
|
423
|
+
const approvalUi = createApprovalUi({
|
|
421
424
|
...{ theme, keys, tui, editor, indicator, agentUi, notice, render },
|
|
422
425
|
hooks: overlayHooks,
|
|
423
426
|
session: () => session,
|
|
424
427
|
});
|
|
428
|
+
const { broker, dock } = approvalUi;
|
|
429
|
+
approvalOpen = approvalUi.approvalOpen;
|
|
425
430
|
indicator.background = () => blockingTasks(session).length > 0;
|
|
426
431
|
// ---- 启动与退出 -----------------------------------------------------------
|
|
427
432
|
let offSignals = () => undefined;
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
* [打断并发送] 运行中 Enter 缺省排队(steer);`app.message.interrupt`(缺省 `Ctrl+Enter`,回退 `Ctrl+X`)= 打断当前回合并立即
|
|
20
20
|
* 以输入框的文字(连同排队的插话)开新回合(`prompt{interrupt:true}`)。`ui.enterWhileRunning: "interrupt"`
|
|
21
21
|
* 时两者互换。补全打开、有覆盖层(审批 / 选择器)时不触发;斜杠命令照常当命令;空闲时专用键等同 Enter。
|
|
22
|
+
* [#271] 审批对话框打开时(`approvalOpen`)其它键都归对话框,只有 `app.permission.cycle` 里不是 Tab 的键
|
|
23
|
+
* (缺省 Shift+Tab;Tab 留给对话框 / 选择列表)仍循环权限模式;切到 Bypass 照旧先过 `confirmMode`,确认期间
|
|
24
|
+
* 不再响应循环键。切换后会话按新模式重判在等的审批(对话框可能随之收起)。
|
|
22
25
|
*/
|
|
23
26
|
import type { AgentSession } from "../../agent/types.js";
|
|
24
27
|
import type { PermissionMode } from "../../permissions/types.js";
|
|
@@ -47,6 +50,8 @@ export interface KeyDispatchDeps {
|
|
|
47
50
|
session(): AgentSession;
|
|
48
51
|
/** 已退出或有覆盖层(审批 / 选择器)时不处理。 */
|
|
49
52
|
inactive(): boolean;
|
|
53
|
+
/** [#271] 审批对话框正开着:此时仍放行 Shift+Tab 切模式(晚绑定)。 */
|
|
54
|
+
approvalOpen?(): boolean;
|
|
50
55
|
/** 运行或压缩中(Esc 才中断)。 */
|
|
51
56
|
busy(): boolean;
|
|
52
57
|
now(): number;
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
* [打断并发送] 运行中 Enter 缺省排队(steer);`app.message.interrupt`(缺省 `Ctrl+Enter`,回退 `Ctrl+X`)= 打断当前回合并立即
|
|
20
20
|
* 以输入框的文字(连同排队的插话)开新回合(`prompt{interrupt:true}`)。`ui.enterWhileRunning: "interrupt"`
|
|
21
21
|
* 时两者互换。补全打开、有覆盖层(审批 / 选择器)时不触发;斜杠命令照常当命令;空闲时专用键等同 Enter。
|
|
22
|
+
* [#271] 审批对话框打开时(`approvalOpen`)其它键都归对话框,只有 `app.permission.cycle` 里不是 Tab 的键
|
|
23
|
+
* (缺省 Shift+Tab;Tab 留给对话框 / 选择列表)仍循环权限模式;切到 Bypass 照旧先过 `confirmMode`,确认期间
|
|
24
|
+
* 不再响应循环键。切换后会话按新模式重判在等的审批(对话框可能随之收起)。
|
|
22
25
|
*/
|
|
23
26
|
import { msg } from "../../i18n/index.js";
|
|
24
27
|
import { ExitCode } from "../../cli/exit-codes.js";
|
|
@@ -38,6 +41,8 @@ export function createKeyDispatch(deps) {
|
|
|
38
41
|
let busyInputHinted = false;
|
|
39
42
|
/** 底部正显示着进栏落空提示(进栏后撤掉)。 */
|
|
40
43
|
let focusHintShown = false;
|
|
44
|
+
/** [#271] 进入 Bypass 的确认框开着:不再响应循环键。 */
|
|
45
|
+
let confirming = false;
|
|
41
46
|
const doubleEscape = () => {
|
|
42
47
|
switch (esc.press(deps.now(), editor.isEmpty())) {
|
|
43
48
|
case "arm-rewind":
|
|
@@ -93,14 +98,33 @@ export function createKeyDispatch(deps) {
|
|
|
93
98
|
deps.showHint(skipped ? msg().interactive.keys.bypassSkipped(label) : label);
|
|
94
99
|
};
|
|
95
100
|
const cyclePermission = () => {
|
|
101
|
+
if (confirming)
|
|
102
|
+
return;
|
|
96
103
|
const next = nextCycleMode(deps.session().state.permissionMode);
|
|
97
104
|
// 取消进入 Bypass:跳过它继续循环(回到起点 Manual),而不是停在原模式——否则不进 Bypass 就绕不回去
|
|
98
|
-
const settle = (ok) =>
|
|
105
|
+
const settle = (ok) => {
|
|
106
|
+
confirming = false;
|
|
107
|
+
if (ok)
|
|
108
|
+
applyMode(next, false);
|
|
109
|
+
else
|
|
110
|
+
applyMode(nextCycleMode(next), true);
|
|
111
|
+
};
|
|
99
112
|
const answer = deps.confirmMode?.(next) ?? true;
|
|
100
113
|
if (typeof answer === "boolean")
|
|
101
114
|
settle(answer);
|
|
102
|
-
else
|
|
103
|
-
|
|
115
|
+
else {
|
|
116
|
+
confirming = true;
|
|
117
|
+
void answer.then(settle, () => (confirming = false));
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
/** [#271] 审批对话框打开时:只有不是 Tab 的循环键(Shift+Tab)切模式,其余键归对话框。 */
|
|
121
|
+
const cycleOverApproval = (data) => {
|
|
122
|
+
if (deps.approvalOpen?.() !== true || !keys.matches(data, "app.permission.cycle"))
|
|
123
|
+
return false;
|
|
124
|
+
if (keys.matches(data, "tui.editor.complete") || keys.matches(data, "tui.select.confirm"))
|
|
125
|
+
return false;
|
|
126
|
+
cyclePermission();
|
|
127
|
+
return true;
|
|
104
128
|
};
|
|
105
129
|
/**
|
|
106
130
|
* 运行中的「排队 / 打断并发送」:专用键与(`interrupt` 模式下的)Enter。返回 false 交给编辑器
|
|
@@ -168,7 +192,7 @@ export function createKeyDispatch(deps) {
|
|
|
168
192
|
};
|
|
169
193
|
return (data) => {
|
|
170
194
|
if (deps.inactive())
|
|
171
|
-
return
|
|
195
|
+
return cycleOverApproval(data);
|
|
172
196
|
if (editor.isEmpty())
|
|
173
197
|
busyInputHinted = false;
|
|
174
198
|
const is = (action) => keys.matches(data, action);
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* 回合结束 → done;出错 → error(msg = 错误首行);用户中断 → idle;之后用户再按键 → idle
|
|
10
10
|
* 启动 / 切换会话 → idle
|
|
11
11
|
* 子记录:子 Agent 任务 `id=task/<短 id>`、title = 任务描述,working / blocked / done / error(中断为 idle);
|
|
12
|
+
* blocked 的 kind 是 permission(审批)或 question([#269] 子 Agent 用 `report` 留了待人决定的问题,msg = 问题);
|
|
12
13
|
* 下一个主回合开始时清掉已结束的任务记录。退出交互模式前发不带 id 的 `state=clear`(用户主动退出,
|
|
13
14
|
* 不留记录)。
|
|
14
15
|
*
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* 回合结束 → done;出错 → error(msg = 错误首行);用户中断 → idle;之后用户再按键 → idle
|
|
10
10
|
* 启动 / 切换会话 → idle
|
|
11
11
|
* 子记录:子 Agent 任务 `id=task/<短 id>`、title = 任务描述,working / blocked / done / error(中断为 idle);
|
|
12
|
+
* blocked 的 kind 是 permission(审批)或 question([#269] 子 Agent 用 `report` 留了待人决定的问题,msg = 问题);
|
|
12
13
|
* 下一个主回合开始时清掉已结束的任务记录。退出交互模式前发不带 id 的 `state=clear`(用户主动退出,
|
|
13
14
|
* 不留记录)。
|
|
14
15
|
*
|
|
@@ -80,7 +81,7 @@ export class ProgramStatusTracker {
|
|
|
80
81
|
this.approvals.set(event.requestId, { msg: text, ...(taskId ? { taskId } : {}) });
|
|
81
82
|
const task = taskId !== undefined ? this.tasks.get(taskId) : undefined;
|
|
82
83
|
if (task !== undefined)
|
|
83
|
-
Object.assign(task, { state: "blocked", msg: text });
|
|
84
|
+
Object.assign(task, { state: "blocked", kind: "permission", msg: text });
|
|
84
85
|
break;
|
|
85
86
|
}
|
|
86
87
|
case "permission_resolved": {
|
|
@@ -88,8 +89,14 @@ export class ProgramStatusTracker {
|
|
|
88
89
|
this.approvals.delete(event.requestId);
|
|
89
90
|
const task = taskId !== undefined ? this.tasks.get(taskId) : undefined;
|
|
90
91
|
const still = [...this.approvals.values()].some((p) => p.taskId === taskId);
|
|
91
|
-
if (task?.state === "blocked" && !still)
|
|
92
|
-
|
|
92
|
+
if (task?.state === "blocked" && task.kind === "permission" && !still) {
|
|
93
|
+
if (task.question !== undefined)
|
|
94
|
+
Object.assign(task, { state: "blocked", kind: "question", msg: task.question });
|
|
95
|
+
else {
|
|
96
|
+
task.state = "working";
|
|
97
|
+
delete task.kind;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
93
100
|
break;
|
|
94
101
|
}
|
|
95
102
|
case "plan_proposed":
|
|
@@ -111,7 +118,31 @@ export class ProgramStatusTracker {
|
|
|
111
118
|
break;
|
|
112
119
|
case "subagent_update": {
|
|
113
120
|
const task = this.tasks.get(event.taskId);
|
|
114
|
-
if (task
|
|
121
|
+
if (task === undefined)
|
|
122
|
+
break;
|
|
123
|
+
if (event.kind === "report" && event.report !== undefined) {
|
|
124
|
+
// [#269] 子 Agent 留了待人决定的问题:blocked:question,问题即 msg;问题清掉后回 working
|
|
125
|
+
const question = event.report.humanAction;
|
|
126
|
+
const pendingApproval = task.state === "blocked" && task.kind === "permission";
|
|
127
|
+
if (question !== undefined) {
|
|
128
|
+
task.question = flat(question, 80);
|
|
129
|
+
// 审批盖在上面时先显示审批,审批结束后恢复问题
|
|
130
|
+
if (!pendingApproval)
|
|
131
|
+
Object.assign(task, { state: "blocked", kind: "question", msg: task.question });
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
delete task.question;
|
|
135
|
+
if (task.state === "blocked" && task.kind === "question") {
|
|
136
|
+
task.state = "working";
|
|
137
|
+
delete task.kind;
|
|
138
|
+
task.msg = flat(event.report.summary, 80);
|
|
139
|
+
}
|
|
140
|
+
else if (task.state === "working")
|
|
141
|
+
task.msg = flat(event.report.summary, 80);
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
if (task.state === "working" && event.toolName !== undefined)
|
|
115
146
|
task.msg = run.runningTool(event.toolName);
|
|
116
147
|
break;
|
|
117
148
|
}
|
|
@@ -122,7 +153,9 @@ export class ProgramStatusTracker {
|
|
|
122
153
|
const s = event.status;
|
|
123
154
|
task.state =
|
|
124
155
|
s === "completed" ? "done" : s === "aborted" || s === "interrupted" ? "idle" : "error";
|
|
156
|
+
delete task.kind;
|
|
125
157
|
delete task.msg;
|
|
158
|
+
delete task.question;
|
|
126
159
|
break;
|
|
127
160
|
}
|
|
128
161
|
default:
|
|
@@ -158,7 +191,7 @@ export class ProgramStatusTracker {
|
|
|
158
191
|
id: task.id,
|
|
159
192
|
state: task.state,
|
|
160
193
|
title: task.title,
|
|
161
|
-
...(task.state === "blocked" ? { kind: "permission" } : {}),
|
|
194
|
+
...(task.state === "blocked" ? { kind: task.kind ?? "permission" } : {}),
|
|
162
195
|
...(task.msg !== undefined ? { msg: task.msg } : {}),
|
|
163
196
|
});
|
|
164
197
|
}
|