@ai-agent-forge/plugin-subagent-delegate 0.88.14 → 0.88.16

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/MANUAL.md CHANGED
@@ -1,23 +1,19 @@
1
- # subagent-delegate 能力手册(AI 用)
2
-
3
- 多代理编排:把可并行的独立子任务委派给子代理会话执行,主会话保持轻量。子代理有自己的上下文、工具面与模型,结果回传主会话。
4
-
5
- ## 工具速查
6
-
7
- | 工具 | 用途 |
8
- | --- | --- |
9
- | subagent_run | 委派新子代理任务(单次最多 4 个并发) |
10
- | subagent_list | 列出本会话的子代理与状态 |
11
- | subagent_result | 读取(等待)子代理结果 |
12
- | subagent_send / subagent_inbox | 向子代理发消息 / 收信箱 |
13
- | subagent_steer | 运行中转向(补充指令) |
14
- | subagent_cancel / subagent_resume | 取消 / 恢复 |
15
- | subagent_escalate | 子代理向主会话升级问题 |
16
- | subagent_role_set / role_list / role_remove | 角色(系统提示+工具档案)管理 |
17
-
18
- ## 使用原则
19
-
20
- 1. **只委派可独立完成的任务**:明确输入/输出/验收;需要共享实时状态或频繁往返的活自己干。
21
- 2. **角色隔离**:用 `role_set` 定义的角色按"术有专攻"分工(explore/reviewer/design-proposer 等),不要把编码任务给审查角色。
22
- 3. **结果有界**:子代理回报是摘要与结论,不是全量文件内容;需要细节让子代理写文件、主会话按路径读。
23
- 4. 并发上限与队列深度、超时由插件 config 管控(默认 8 并发/任务 5 分钟超时),超限调用会得到结构化错误。
1
+ # subagent-delegate 能力手册(AI 用)
2
+
3
+ 多代理编排:把可并行的独立子任务委派给子代理会话执行,主会话保持轻量。子代理有自己的上下文、工具面与模型,结果回传主会话。
4
+
5
+ ## 工具速查
6
+
7
+ | 工具 | 用途 |
8
+ | --- | --- |
9
+ | subagent_run | 委派新子代理任务(单次最多 8 个并发) |
10
+ | subagent_task | `type`: result 读取(等待)结果 / list 列出本会话子代理 / cancel 取消 / steer 运行中转向 / resume 继续已终态会话 |
11
+ | subagent_message | 子代理侧通信: send 给兄弟发消息 / inbox 收信箱 / escalate 向父会话升级问题 |
12
+ | subagent_role | 角色(系统提示+工具档案)管理: set 注册或更新 / list 查看 / remove 删除 |
13
+
14
+ ## 使用原则
15
+
16
+ 1. **只委派可独立完成的任务**:明确输入/输出/验收;需要共享实时状态或频繁往返的活自己干。
17
+ 2. **角色隔离**:用 `subagent_role`(type `set`)定义的角色按"术有专攻"分工(explore/reviewer/design-proposer 等),不要把编码任务给审查角色。
18
+ 3. **结果有界**:子代理回报是摘要与结论,不是全量文件内容;需要细节让子代理写文件、主会话按路径读。
19
+ 4. 并发上限与队列深度、超时由插件 config 管控(默认 12 并发/任务 10 分钟超时),超限调用会得到结构化错误。
package/README.md CHANGED
@@ -1,54 +1,59 @@
1
- # @agent-forge/plugin-subagent-delegate
2
-
3
- First-party subagent-delegate capability plugin for Agent Forge: the
4
- `subagent_run` / `subagent_result` (and optionally `subagent_resume` /
5
- `subagent_list` / communication tools) model face over the plugin-level
6
- `SubagentRuntime` scheduler, extracted from the host's embedded builtin
7
- capability (D-075 S4, third batch).
8
-
9
- ## Library face vs plugin entry
10
-
11
- - `createSubagentDelegateCapability(api, options?)` — explicit-options
12
- factory for embedders and tests. Adapter/limits/runner spawner/roles are
13
- injected explicitly.
14
- - `./dist/entry.js` (default export) — the manifest-loaded plugin factory. It
15
- maps host services onto the same options:
16
- - `api.host.communication` → `communicationWiring`
17
- - `api.host.turnContext.backgroundDigestSink` / `getTurnCorrelationId`
18
- - `api.host.agentDir` + `api.host.roleAssociations` → role catalog (after an
19
- idempotent factory seed of `<agentDir>/roles/`: `explore`, `reviewer`,
20
- `design-proposer`, `visual-reviewer` — the latter two are the visual
21
- baseline roles (2026-10-04, "术有专攻"): read-only profile narrowed to
22
- `["read"]`, instructions embed the aesthetic baseline assets; see
23
- `docs/plans/视觉保底角色设计注记.md`)
24
- - `api.host.agentDir` → the nested-depth lineage gate source
25
- - auto-pooling is driven by the existing config key `runnerEntryAuto`
26
- - Config channel: hosts declaring `api.host.agentDir` get
27
- `<agentDir>/capabilities/builtin.subagent-delegate.json` merged over the
28
- manifest config (missing file = unconfigured; unreadable/invalid JSON fails
29
- the plugin load).
30
-
31
- ## Bundled modules
32
-
33
- The scheduler (`subagent-runtime`), multi-agent task registry
34
- (`multi-agent-tasks`), runner pool / spawner, remote (wire) and shared
35
- (in-process) adapters, and the self-invocation probe all live in this package
36
- and are re-exported from the index. The wire protocol, stdio channel, task
37
- server, progress face, and mailbox come from `@agent-forge/protocol`;
38
- agent-task contracts, durable service types, and session lineage reading come
39
- from `@agent-forge/plugin-sdk`.
40
-
41
- ## 关闭边界与真实验收
42
-
43
- runner pool 关闭后不再接受任务。在途 hello 被取消,尚未完成的 spawn 返回句柄后直接回收,
44
- 不登记 runner 或再发 create,不触发替代 spawn;已经完成的任务结果保持原样。
45
- spawn 工厂同步失败保留原错并结束本次创建,下一次显式创建可恢复,不会自动重跑原任务。
46
- 真实 pooled 验收先在测试私有 agentDir 通过生产 bootstrap 准备插件依赖,再计时验证模型任务、
47
- 取消和崩溃恢复。准备成功必须有实际 bootstrap 结果,offline/disabled 跳过不算成功。
48
- 详见 `docs/design/冷资源准备与取消边界.md`。
49
-
50
- ## Capabilities
51
-
52
- Requires `session` + `tools`; `agents` is optional (leaf sessions register
53
- their child communication face only). Provides the
54
- `subagent-delegate.agent-task` service (v1).
1
+ # @agent-forge/plugin-subagent-delegate
2
+
3
+ First-party subagent-delegate capability plugin for Agent Forge: the
4
+ four-tool model face (`subagent_run`, `subagent_task`, `subagent_message`,
5
+ `subagent_role`; each merged tool takes a `type` discriminator) over the
6
+ plugin-level `SubagentRuntime` scheduler, extracted from the host's embedded
7
+ builtin capability (D-075 S4, third batch).
8
+
9
+ ## Library face vs plugin entry
10
+
11
+ - `createSubagentDelegateCapability(api, options?)` — explicit-options
12
+ factory for embedders and tests. Adapter/limits/runner spawner/roles are
13
+ injected explicitly.
14
+ - `./dist/entry.js` (default export) — the manifest-loaded plugin factory. It
15
+ maps host services onto the same options:
16
+ - `api.host.communication` → `communicationWiring`
17
+ - `api.host.turnContext.backgroundDigestSink` / `getTurnCorrelationId`
18
+ - `api.host.agentDir` + `api.host.roleAssociations` → role catalog (after an
19
+ idempotent factory seed of `<agentDir>/roles/`: `explore`, `reviewer`,
20
+ `design-proposer`, `visual-reviewer` — the latter two are the visual roles
21
+ (2026-10-04, "术有专攻"): read-only profile narrowed to `["read"]`,
22
+ instructions use a shared work definition and six project-derived methods
23
+ inspired by Chinese aesthetic thought, selected according to intent and
24
+ context rather than a fixed style. The reviewer checks actual observable
25
+ visual presentation, reports only what the evidence supports, and uses
26
+ `fail`, `Unverified` or `pass` according to known violations and required
27
+ evidence; see
28
+ `docs/plans/视觉保底角色设计注记.md`)
29
+ - `api.host.agentDir` → the nested-depth lineage gate source
30
+ - auto-pooling is driven by the existing config key `runnerEntryAuto`
31
+ - Config channel: hosts declaring `api.host.agentDir` get
32
+ `<agentDir>/capabilities/builtin.subagent-delegate.json` merged over the
33
+ manifest config (missing file = unconfigured; unreadable/invalid JSON fails
34
+ the plugin load).
35
+
36
+ ## Bundled modules
37
+
38
+ The scheduler (`subagent-runtime`), multi-agent task registry
39
+ (`multi-agent-tasks`), runner pool / spawner, remote (wire) and shared
40
+ (in-process) adapters, and the self-invocation probe all live in this package
41
+ and are re-exported from the index. The wire protocol, stdio channel, task
42
+ server, progress face, and mailbox come from `@agent-forge/protocol`;
43
+ agent-task contracts, durable service types, and session lineage reading come
44
+ from `@agent-forge/plugin-sdk`.
45
+
46
+ ## 关闭边界与真实验收
47
+
48
+ runner pool 关闭后不再接受任务。在途 hello 被取消,尚未完成的 spawn 返回句柄后直接回收,
49
+ 不登记 runner 或再发 create,不触发替代 spawn;已经完成的任务结果保持原样。
50
+ spawn 工厂同步失败保留原错并结束本次创建,下一次显式创建可恢复,不会自动重跑原任务。
51
+ 真实 pooled 验收先在测试私有 agentDir 通过生产 bootstrap 准备插件依赖,再计时验证模型任务、
52
+ 取消和崩溃恢复。准备成功必须有实际 bootstrap 结果,offline/disabled 跳过不算成功。
53
+ 详见 `docs/design/冷资源准备与取消边界.md`。
54
+
55
+ ## Capabilities
56
+
57
+ Requires `session` + `tools`; `agents` is optional (leaf sessions register
58
+ their child communication face only). Provides the
59
+ `agent-forge.agent-task-scheduler` service (v1).
package/agent-forge.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "packageFormatVersion": 1,
3
3
  "id": "agent-forge.plugin.subagent-delegate",
4
- "pluginVersion": "0.88.14",
4
+ "pluginVersion": "0.88.16",
5
5
  "apiVersion": "1",
6
6
  "minHostVersion": "0.84.4",
7
7
  "platform": {
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 子代理调度器出厂默认值(docs/design/产品默认值清单.md)。
3
+ * 单一定义源:capability manifest(delegate.ts)、runner 装配(subagent-runtime.ts)
4
+ * 与 plugin.json 的 config 声明共用;用户经
5
+ * `<agentDir>/capabilities/builtin.subagent-delegate.json` 覆盖。
6
+ *
7
+ * 2026-10-19 重度并行画像调定:maxConcurrentSubagents 是**每会话**上限(调度器
8
+ * 实例每主会话一个,进程内无全局子代理闸门);12 = 单会话 1.5×8,20 会话理论峰值
9
+ * 240 个并发子代理(G2 实测进程内簿记约 1.1MB/个,200 并发 ≈220MB),实际瓶颈是
10
+ * provider 限流。大小预算(bytes/maxMessages)不是并发,未调。
11
+ */
12
+ export declare const DEFAULT_SUBAGENT_LIMITS: {
13
+ readonly maxConcurrentSubagents: 12;
14
+ readonly maxQueueDepth: 200;
15
+ readonly maxPromptBytes: 65536;
16
+ readonly maxMetadataBytes: 16384;
17
+ readonly maxResultBytes: 524288;
18
+ readonly maxMessages: 2000;
19
+ readonly drainTimeoutMs: 30000;
20
+ readonly maxRetainedRecords: 512;
21
+ };
22
+ /** 单次 `subagent_run` 并行扇出(与 12 并发对齐,避免小任务组被硬拒绝)。 */
23
+ export declare const DEFAULT_SUBAGENT_MAX_TASKS_PER_CALL = 8;
24
+ /** 前台阻塞 drain 预算(10 分钟,减少长编码任务被 5 分钟超时截断)。 */
25
+ export declare const DEFAULT_SUBAGENT_TASK_TIMEOUT_MS = 600000;
26
+ /** 每父会话累计子代理配额(非 resume 提交计数;500 避免长会话超过 500 个子会话后被锁死)。 */
27
+ export declare const DEFAULT_SUBAGENT_MAX_TOTAL_PER_PARENT = 500;
28
+ /** 血缘递归深度硬限(不变;入 manifest config 使用户可见可改)。 */
29
+ export declare const DEFAULT_SUBAGENT_MAX_NESTED_DEPTH = 2;
30
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;CAS1B,CAAC;AACX,sGAAoD;AACpD,eAAO,MAAM,mCAAmC,IAAI,CAAC;AACrD,kGAA8C;AAC9C,eAAO,MAAM,gCAAgC,SAAU,CAAC;AACxD,iIAA2D;AAC3D,eAAO,MAAM,qCAAqC,MAAM,CAAC;AACzD,0FAA8C;AAC9C,eAAO,MAAM,iCAAiC,IAAI,CAAC","sourcesContent":["/**\n * 子代理调度器出厂默认值(docs/design/产品默认值清单.md)。\n * 单一定义源:capability manifest(delegate.ts)、runner 装配(subagent-runtime.ts)\n * 与 plugin.json 的 config 声明共用;用户经\n * `<agentDir>/capabilities/builtin.subagent-delegate.json` 覆盖。\n *\n * 2026-10-19 重度并行画像调定:maxConcurrentSubagents 是**每会话**上限(调度器\n * 实例每主会话一个,进程内无全局子代理闸门);12 = 单会话 1.5×8,20 会话理论峰值\n * 240 个并发子代理(G2 实测进程内簿记约 1.1MB/个,200 并发 ≈220MB),实际瓶颈是\n * provider 限流。大小预算(bytes/maxMessages)不是并发,未调。\n */\nexport const DEFAULT_SUBAGENT_LIMITS = {\n\tmaxConcurrentSubagents: 12,\n\tmaxQueueDepth: 200,\n\tmaxPromptBytes: 65536,\n\tmaxMetadataBytes: 16384,\n\tmaxResultBytes: 524288,\n\tmaxMessages: 2000,\n\tdrainTimeoutMs: 30000,\n\tmaxRetainedRecords: 512,\n} as const;\n/** 单次 `subagent_run` 并行扇出(与 12 并发对齐,避免小任务组被硬拒绝)。 */\nexport const DEFAULT_SUBAGENT_MAX_TASKS_PER_CALL = 8;\n/** 前台阻塞 drain 预算(10 分钟,减少长编码任务被 5 分钟超时截断)。 */\nexport const DEFAULT_SUBAGENT_TASK_TIMEOUT_MS = 600_000;\n/** 每父会话累计子代理配额(非 resume 提交计数;500 避免长会话超过 500 个子会话后被锁死)。 */\nexport const DEFAULT_SUBAGENT_MAX_TOTAL_PER_PARENT = 500;\n/** 血缘递归深度硬限(不变;入 manifest config 使用户可见可改)。 */\nexport const DEFAULT_SUBAGENT_MAX_NESTED_DEPTH = 2;\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 子代理调度器出厂默认值(docs/design/产品默认值清单.md)。
3
+ * 单一定义源:capability manifest(delegate.ts)、runner 装配(subagent-runtime.ts)
4
+ * 与 plugin.json 的 config 声明共用;用户经
5
+ * `<agentDir>/capabilities/builtin.subagent-delegate.json` 覆盖。
6
+ *
7
+ * 2026-10-19 重度并行画像调定:maxConcurrentSubagents 是**每会话**上限(调度器
8
+ * 实例每主会话一个,进程内无全局子代理闸门);12 = 单会话 1.5×8,20 会话理论峰值
9
+ * 240 个并发子代理(G2 实测进程内簿记约 1.1MB/个,200 并发 ≈220MB),实际瓶颈是
10
+ * provider 限流。大小预算(bytes/maxMessages)不是并发,未调。
11
+ */
12
+ export const DEFAULT_SUBAGENT_LIMITS = {
13
+ maxConcurrentSubagents: 12,
14
+ maxQueueDepth: 200,
15
+ maxPromptBytes: 65536,
16
+ maxMetadataBytes: 16384,
17
+ maxResultBytes: 524288,
18
+ maxMessages: 2000,
19
+ drainTimeoutMs: 30000,
20
+ maxRetainedRecords: 512,
21
+ };
22
+ /** 单次 `subagent_run` 并行扇出(与 12 并发对齐,避免小任务组被硬拒绝)。 */
23
+ export const DEFAULT_SUBAGENT_MAX_TASKS_PER_CALL = 8;
24
+ /** 前台阻塞 drain 预算(10 分钟,减少长编码任务被 5 分钟超时截断)。 */
25
+ export const DEFAULT_SUBAGENT_TASK_TIMEOUT_MS = 600_000;
26
+ /** 每父会话累计子代理配额(非 resume 提交计数;500 避免长会话超过 500 个子会话后被锁死)。 */
27
+ export const DEFAULT_SUBAGENT_MAX_TOTAL_PER_PARENT = 500;
28
+ /** 血缘递归深度硬限(不变;入 manifest config 使用户可见可改)。 */
29
+ export const DEFAULT_SUBAGENT_MAX_NESTED_DEPTH = 2;
30
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,sBAAsB,EAAE,EAAE;IAC1B,aAAa,EAAE,GAAG;IAClB,cAAc,EAAE,KAAK;IACrB,gBAAgB,EAAE,KAAK;IACvB,cAAc,EAAE,MAAM;IACtB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,kBAAkB,EAAE,GAAG;CACd,CAAC;AACX,sGAAoD;AACpD,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AACrD,kGAA8C;AAC9C,MAAM,CAAC,MAAM,gCAAgC,GAAG,OAAO,CAAC;AACxD,iIAA2D;AAC3D,MAAM,CAAC,MAAM,qCAAqC,GAAG,GAAG,CAAC;AACzD,0FAA8C;AAC9C,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC","sourcesContent":["/**\n * 子代理调度器出厂默认值(docs/design/产品默认值清单.md)。\n * 单一定义源:capability manifest(delegate.ts)、runner 装配(subagent-runtime.ts)\n * 与 plugin.json 的 config 声明共用;用户经\n * `<agentDir>/capabilities/builtin.subagent-delegate.json` 覆盖。\n *\n * 2026-10-19 重度并行画像调定:maxConcurrentSubagents 是**每会话**上限(调度器\n * 实例每主会话一个,进程内无全局子代理闸门);12 = 单会话 1.5×8,20 会话理论峰值\n * 240 个并发子代理(G2 实测进程内簿记约 1.1MB/个,200 并发 ≈220MB),实际瓶颈是\n * provider 限流。大小预算(bytes/maxMessages)不是并发,未调。\n */\nexport const DEFAULT_SUBAGENT_LIMITS = {\n\tmaxConcurrentSubagents: 12,\n\tmaxQueueDepth: 200,\n\tmaxPromptBytes: 65536,\n\tmaxMetadataBytes: 16384,\n\tmaxResultBytes: 524288,\n\tmaxMessages: 2000,\n\tdrainTimeoutMs: 30000,\n\tmaxRetainedRecords: 512,\n} as const;\n/** 单次 `subagent_run` 并行扇出(与 12 并发对齐,避免小任务组被硬拒绝)。 */\nexport const DEFAULT_SUBAGENT_MAX_TASKS_PER_CALL = 8;\n/** 前台阻塞 drain 预算(10 分钟,减少长编码任务被 5 分钟超时截断)。 */\nexport const DEFAULT_SUBAGENT_TASK_TIMEOUT_MS = 600_000;\n/** 每父会话累计子代理配额(非 resume 提交计数;500 避免长会话超过 500 个子会话后被锁死)。 */\nexport const DEFAULT_SUBAGENT_MAX_TOTAL_PER_PARENT = 500;\n/** 血缘递归深度硬限(不变;入 manifest config 使用户可见可改)。 */\nexport const DEFAULT_SUBAGENT_MAX_NESTED_DEPTH = 2;\n"]}
@@ -7,24 +7,31 @@ export declare const capabilityManifest: {
7
7
  readonly apiVersion: "1-draft";
8
8
  readonly requiredCapabilities: readonly ["session", "tools"];
9
9
  readonly optionalCapabilities: readonly ["agents"];
10
+ readonly provides: readonly [{
11
+ readonly id: "agent-forge.agent-task-scheduler";
12
+ readonly version: 1;
13
+ readonly kind: "service";
14
+ }];
10
15
  /**
11
16
  * 用户可配置默认值(D-044 §6 四层归属的 Profile/capability 配置层):
12
17
  * 经 agent-dir 配置通道 `<agentDir>/capabilities/builtin.subagent-delegate.json`
13
18
  * 浅合并覆盖;宿主显式 options 优先级最高;非法值在装载时 fail fast。
14
19
  */
15
20
  readonly config: {
16
- readonly maxConcurrentSubagents: 8;
21
+ readonly maxConcurrentSubagents: 12;
17
22
  readonly maxQueueDepth: 200;
18
23
  readonly maxPromptBytes: 65536;
19
24
  readonly maxMetadataBytes: 16384;
20
25
  readonly maxResultBytes: 524288;
21
26
  readonly maxMessages: 2000;
22
27
  readonly drainTimeoutMs: 30000;
23
- readonly maxRetainedRecords: 256;
24
- readonly maxTasksPerCall: 4;
25
- readonly taskTimeoutMs: 300000;
28
+ readonly maxRetainedRecords: 512;
29
+ readonly maxTasksPerCall: 8;
30
+ readonly taskTimeoutMs: 600000;
31
+ readonly maxTotalPerParent: 500;
32
+ readonly maxNestedDepth: 2;
26
33
  readonly runnerMaxProcesses: 0;
27
- readonly runnerMaxSessionsPerRunner: 8;
34
+ readonly runnerMaxSessionsPerRunner: 12;
28
35
  readonly runnerIdleTimeoutMs: 300000;
29
36
  readonly runnerSweepIntervalMs: 60000;
30
37
  readonly runnerEntryAuto: false;
@@ -34,7 +41,7 @@ export interface SubagentDelegateCapabilityOptions {
34
41
  /** 宿主可注入调度器 adapter(如 pooled runner adapter);优先级高于配置驱动的 pooled 装配与共享模式。 */
35
42
  adapter?: AgentTaskAdapter;
36
43
  limits?: SubagentRuntimeLimitsV1;
37
- /** 单次工具调用的并行任务上限(默认 4)与单任务 drain 超时(默认 300000ms)。 */
44
+ /** 单次工具调用的并行任务上限(默认 8)与单任务 drain 超时(默认 600000ms)。 */
38
45
  maxTasksPerCall?: number;
39
46
  taskTimeoutMs?: number;
40
47
  /**
@@ -79,7 +86,7 @@ export interface SubagentDelegateCapabilityOptions {
79
86
  /**
80
87
  * Durable 终态持久化(durable replay assembly,2026-10-13 用户裁决):宿主注入
81
88
  * durable 设施(store + writerId,写者租约生命周期由宿主持有),调度器按 `subagent-task:<taskId>` 落库终态
82
- * 信封,`subagent_result` 跨进程重启后仍可读回(日志在 `<agentDir>/durable/`,
89
+ * 信封,`subagent_task`(type `result`)跨进程重启后仍可读回(日志在 `<agentDir>/durable/`,
83
90
  * 独立于 sessions 树,主会话删除/清理不波及)。未注入 = 优雅降级为现状(内存
84
91
  * 记录 + transcript 落盘,`result()` 回 undefined);持久化失败不吞终态——错误经
85
92
  * drain()/dispose() 的 reject 通道暴露(两处调用点都有 catch 臂)。
@@ -130,9 +137,16 @@ export interface SubagentDelegateTaskProjectionV1 {
130
137
  readonly summary?: string;
131
138
  /**
132
139
  * 子会话 escalate 上抛的有界消息(D-060 S4):落在父侧下一次工具结果里(这里或
133
- * `subagent_result`),父回合不被打断;无积压时省略。
140
+ * `subagent_task` type `result`),父回合不被打断;无积压时省略。
134
141
  */
135
142
  readonly escalations?: readonly string[];
143
+ /**
144
+ * 任务层结果(任务级拒绝):子代理以 `subagent_message`(type `refuse`)声明不做该
145
+ * 任务时随自然成功结算附 `taskOutcome: "refused"`——该拒绝是终局声明;无则省略。
146
+ */
147
+ readonly taskOutcome?: "refused";
148
+ /** 拒绝原因;仅与 taskOutcome 同时出现。 */
149
+ readonly refusalReason?: string;
136
150
  /**
137
151
  * 该子会话相关的兄弟消息流量摘录(D-060 裁决 14 父可见性):from/to 命中的最新
138
152
  * 至多 8 条,每条 text 截 256 utf-8 字节;无流量时省略。审计日志在信箱侧,drain
@@ -147,7 +161,7 @@ export interface SubagentDelegateTaskProjectionV1 {
147
161
  export interface SubagentDelegateResultV1 {
148
162
  readonly tasks: readonly SubagentDelegateTaskProjectionV1[];
149
163
  }
150
- /** 后台委派票据(D-060 S6):提交即返回,结果稍后经 subagent_result / 摘要注入获得。 */
164
+ /** 后台委派票据(D-060 S6):提交即返回,结果稍后经 subagent_task(type `result`)/ 摘要注入获得。 */
151
165
  export interface SubagentDelegateBackgroundTaskV1 {
152
166
  readonly taskId: string;
153
167
  }
@@ -156,7 +170,7 @@ export interface SubagentDelegateBackgroundResultV1 {
156
170
  readonly tasks: readonly SubagentDelegateBackgroundTaskV1[];
157
171
  }
158
172
  /**
159
- * `subagent_cancel` 的返回形状(S4 补充裁决,2026-10-01):调度器 `cancelById` 的
173
+ * `subagent_task`(type `cancel`)的返回形状(S4 补充裁决,2026-10-01):调度器 `cancelById` 的
160
174
  * 三态 outcome + 寻址 taskId;cancelled / already_terminal 附调度器最终状态,
161
175
  * not_found 不带 status(不抛异常——未知 taskId 是可表达的正常结果)。
162
176
  */
@@ -220,7 +234,7 @@ export interface SubagentRoleCatalogResolutionV1 {
220
234
  export declare const SESSION_ROLE_STATE_ENTRY: "subagent.roles.state";
221
235
  /**
222
236
  * 快照里的单个角色:与角色文件同构的**平铺定义** + id(文件形态的 id 来自文件名,
223
- * 条目里必须自带)。收窄字段平铺为 model/thinkingLevel/tools/mode/systemPromptAppend,
237
+ * 条目里必须自带)。收窄字段平铺为 model/thinkingLevel/tools/writeScope/mode/systemPromptAppend,
224
238
  * 载入内存时仍归一化为 `SubagentDelegateRoleV1`(profile 嵌套形态)。
225
239
  */
226
240
  export interface SubagentSessionRoleRecordV1 {
@@ -230,7 +244,9 @@ export interface SubagentSessionRoleRecordV1 {
230
244
  readonly model?: string;
231
245
  readonly thinkingLevel?: string;
232
246
  readonly tools?: readonly string[];
247
+ readonly writeScope?: readonly string[];
233
248
  readonly mode?: "readonly" | "full-control";
249
+ readonly webSearch?: "off" | "auto";
234
250
  readonly systemPromptAppend?: string;
235
251
  readonly parentView?: boolean;
236
252
  }
@@ -239,7 +255,7 @@ export interface SubagentSessionRolesStateV1 {
239
255
  readonly version: 1;
240
256
  readonly roles: readonly SubagentSessionRoleRecordV1[];
241
257
  }
242
- /** `subagent_role_list`(无 id)的摘要条目:来源 + 一句话说明 + 收窄面有无。 */
258
+ /** `subagent_role`(type `list`,无 id)的摘要条目:来源 + 一句话说明 + 收窄面有无。 */
243
259
  export interface SubagentRoleListEntryV1 {
244
260
  readonly id: string;
245
261
  readonly origin: "disk" | "session";
@@ -250,20 +266,20 @@ export interface SubagentRoleListEntryV1 {
250
266
  export interface SubagentRoleListResultV1 {
251
267
  readonly roles: readonly SubagentRoleListEntryV1[];
252
268
  }
253
- /** `subagent_role_list({ id })` 的完整定义(含 instructions 与收窄字段,供读-改-写)。 */
269
+ /** `subagent_role`(type `list`,带 `id`)的完整定义(含 instructions 与收窄字段,供读-改-写)。 */
254
270
  export interface SubagentRoleDefinitionViewV1 extends SubagentSessionRoleRecordV1 {
255
271
  readonly origin: "disk" | "session";
256
272
  }
257
273
  export interface SubagentRoleViewResultV1 {
258
274
  readonly role: SubagentRoleDefinitionViewV1;
259
275
  }
260
- /** `subagent_role_set` 的结果:created/updated + 合并后全部可用角色 id(排序)。 */
276
+ /** `subagent_role`(type `set`)的结果:created/updated + 合并后全部可用角色 id(排序)。 */
261
277
  export interface SubagentRoleSetResultV1 {
262
278
  readonly id: string;
263
279
  readonly status: "created" | "updated";
264
280
  readonly roles: readonly string[];
265
281
  }
266
- /** `subagent_role_remove` 的结果:removed + 合并后全部可用角色 id(排序)。 */
282
+ /** `subagent_role`(type `remove`)的结果:removed + 合并后全部可用角色 id(排序)。 */
267
283
  export interface SubagentRoleRemoveResultV1 {
268
284
  readonly id: string;
269
285
  readonly status: "removed";
@@ -344,7 +360,7 @@ export interface SubagentDelegateContextV1 {
344
360
  readonly anchors?: readonly SubagentDelegateContextAnchorV1[];
345
361
  readonly failedAttempts?: readonly SubagentDelegateContextFailedAttemptV1[];
346
362
  }
347
- /** `subagent_result` 的返回形状:两个来源(调度记录 / 持久化 transcript)共用一个有界信封。 */
363
+ /** `subagent_task`(type `result`)的返回形状:两个来源(调度记录 / 持久化 transcript)共用一个有界信封。 */
348
364
  export interface SubagentResultReadResultV1 {
349
365
  readonly found: boolean;
350
366
  readonly source: "record" | "session";
@@ -370,12 +386,16 @@ export interface SubagentResultReadResultV1 {
370
386
  to: string;
371
387
  text: string;
372
388
  }[];
389
+ /** 任务层结果(任务级拒绝);仅调度记录来源携带(transcript 回读无调度记录)。 */
390
+ readonly taskOutcome?: "refused";
391
+ /** 拒绝原因;仅与 taskOutcome 同时出现。 */
392
+ readonly refusalReason?: string;
373
393
  /** taskId 已知但尚未结算(后台委派):稍后再取或带 waitMs 等待。 */
374
394
  readonly knownTask?: true;
375
395
  /** 未结算任务的当前调度器状态(queued/admitted/running)。 */
376
396
  readonly taskStatus?: string;
377
397
  }
378
- /** `subagent_list` 的条目:store 摘要 + 调度器状态富化(有则附)。 */
398
+ /** `subagent_task`(type `list`)的条目:store 摘要 + 调度器状态富化(有则附)。 */
379
399
  export interface SubagentSessionListEntryV1 {
380
400
  readonly sessionId: string;
381
401
  readonly agentRole?: string;