@zhushanwen/subagent-engine-sdk 0.10.0 → 0.11.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.
Files changed (67) hide show
  1. package/dist/{chunk-AF2ETADP.js → chunk-2L3I2TWJ.js} +5 -10
  2. package/dist/{chunk-HSNDUHFH.js → chunk-3MCOZY3Z.js} +32 -4
  3. package/dist/{chunk-JZN76I3S.js → chunk-NVF3PADP.js} +29 -1
  4. package/dist/{chunk-LM7P7OTA.js → chunk-QBXDEF4N.js} +35 -3
  5. package/dist/{chunk-NTOLHLCL.js → chunk-QGXILDWB.js} +1 -1
  6. package/dist/{chunk-CT3FEBDO.js → chunk-QOFFM5YW.js} +7 -1
  7. package/dist/{chunk-CNCFMPEH.js → chunk-TJMS3YOR.js} +1 -1
  8. package/dist/{chunk-SGAIDL63.js → chunk-YFSNX3N3.js} +2 -2
  9. package/dist/cli-entry.d.cts +1 -1
  10. package/dist/cli-entry.d.ts +1 -1
  11. package/dist/{contract-types-jSa1g28F.d.cts → contract-types-BUHUMF9R.d.cts} +17 -17
  12. package/dist/{contract-types-jSa1g28F.d.ts → contract-types-BUHUMF9R.d.ts} +17 -17
  13. package/dist/env.cjs +5 -10
  14. package/dist/env.d.cts +6 -17
  15. package/dist/env.d.ts +6 -17
  16. package/dist/env.js +1 -1
  17. package/dist/{error-codes-f-UO4a8D.d.cts → error-codes-D_aPibUt.d.cts} +42 -6
  18. package/dist/{error-codes-DnFru4L4.d.ts → error-codes-DrNf0gwT.d.ts} +42 -6
  19. package/dist/index.cjs +133 -97
  20. package/dist/index.d.cts +29 -41
  21. package/dist/index.d.ts +29 -41
  22. package/dist/index.js +42 -59
  23. package/dist/journal-io.d.cts +1 -1
  24. package/dist/journal-io.d.ts +1 -1
  25. package/dist/journal-replay.cjs +2 -2
  26. package/dist/journal-replay.d.cts +4 -4
  27. package/dist/journal-replay.d.ts +4 -4
  28. package/dist/journal-replay.js +1 -1
  29. package/dist/kill-chain.d.cts +5 -5
  30. package/dist/kill-chain.d.ts +5 -5
  31. package/dist/kill-chain.js +2 -2
  32. package/dist/logger.d.cts +1 -1
  33. package/dist/logger.d.ts +1 -1
  34. package/dist/logs/stderr-rotation.d.cts +4 -4
  35. package/dist/logs/stderr-rotation.d.ts +4 -4
  36. package/dist/{methods-C2zvZqhP.d.ts → methods-BdIH3FwS.d.ts} +5 -5
  37. package/dist/{methods-BLxg4ZFr.d.cts → methods-CHiDwvRK.d.cts} +5 -5
  38. package/dist/node-executor.cjs +1 -1
  39. package/dist/node-executor.d.cts +4 -4
  40. package/dist/node-executor.d.ts +4 -4
  41. package/dist/node-executor.js +2 -2
  42. package/dist/port-contract.d.cts +9 -9
  43. package/dist/port-contract.d.ts +9 -9
  44. package/dist/protocol/index.cjs +73 -4
  45. package/dist/protocol/index.d.cts +57 -14
  46. package/dist/protocol/index.d.ts +57 -14
  47. package/dist/protocol/index.js +20 -2
  48. package/dist/server/index.cjs +1 -1
  49. package/dist/server/index.d.cts +10 -10
  50. package/dist/server/index.d.ts +10 -10
  51. package/dist/server/index.js +1 -1
  52. package/dist/spawn.cjs +32 -3
  53. package/dist/spawn.d.cts +34 -8
  54. package/dist/spawn.d.ts +34 -8
  55. package/dist/spawn.js +5 -3
  56. package/dist/ui-types.d.cts +2 -2
  57. package/dist/ui-types.d.ts +2 -2
  58. package/dist/zcode-db-paths.cjs +9 -2
  59. package/dist/zcode-db-paths.d.cts +11 -1
  60. package/dist/zcode-db-paths.d.ts +11 -1
  61. package/dist/zcode-db-paths.js +5 -3
  62. package/package.json +2 -2
  63. package/dist/chunk-GSW3DMN6.js +0 -39
  64. package/dist/relay-env.cjs +0 -71
  65. package/dist/relay-env.d.cts +0 -37
  66. package/dist/relay-env.d.ts +0 -37
  67. package/dist/relay-env.js +0 -23
@@ -1,8 +1,8 @@
1
- import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-jSa1g28F.cjs';
2
- import { S as SetModelParams, a as SetModelResult } from './methods-BLxg4ZFr.cjs';
1
+ import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-BUHUMF9R.cjs';
2
+ import { S as SetModelParams, a as SetModelResult } from './methods-CHiDwvRK.cjs';
3
3
 
4
4
  /**
5
- * 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
5
+ * 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎侧子集 + 协议 ctx 还原字段(model/
6
6
  * cwd——SDK 契约把它们从 task 移到 run.params.ctx,进程内接口合回单对象;
7
7
  * server.ts 做 ctx→task 还原,与 core RemoteEngine.toSdkTaskSubset 镜像)。
8
8
  */
@@ -12,7 +12,7 @@ type EngineAgentCallOpts = AgentCallOpts & {
12
12
  };
13
13
  /**
14
14
  * 引擎进程内的 ctxModel 形态(core ModelInfo 的结构等价镜像——仅 id/provider 被引擎
15
- * 消费,name/reasoning 等字段透传保留防测试/未来消费面漂移)。
15
+ * 消费,name/reasoning 等字段透传保留防测试/未来消费方漂移)。
16
16
  */
17
17
  interface EngineCtxModel {
18
18
  id: string;
@@ -30,11 +30,11 @@ interface EngineStream {
30
30
  * journal 固定分组 key(值锚定,**只承载、不透传**):journal 落盘路径
31
31
  * `<dataDir>/engines/<engineId>/<本值>/journal-<taskId>.jsonl` 的第二段,两引擎恒
32
32
  * 本值(pi / zcode 均无池化实现——pi = PI_CODING_AGENT_DIR 全局一份,zcode = 共享
33
- * 宿主 HOME)。[池抽象降级 2026-09-13] poolKey 协议面(RunContext/run.params.ctx/
33
+ * 宿主 HOME)。[池抽象降级 2026-09-13] poolKey 协议范围(RunContext/run.params.ctx/
34
34
  * host/poolResolved 通道/EngineHandleData)已整体退役,本常量不再跨进程透传,仅
35
35
  * 三类消费:① journal 落盘路径构造(core event-journal-wiring);② 存量 record 兼容
36
36
  * (zcode read 旧相对 dbPath 的锚定分支 + 持久化 engineHandle.poolKey 字段——
37
- * record-store 读侧守卫要求非空,值恒本常量);③ 引擎数据目录布局 SSOT paths.ts
37
+ * record-store 读侧检查要求非空,值恒本常量);③ 引擎数据目录布局 SSOT paths.ts
38
38
  * 的签名参数。**值逐字不变**(存量 journal 落盘路径与记录含该值分段,改名不改值)。
39
39
  */
40
40
  declare const SHARED_POOL_KEY = "shared";
@@ -47,7 +47,7 @@ interface RunContext {
47
47
  stream?: EngineStream;
48
48
  /**
49
49
  * [F6] 根 session id(协议 run.params.ctx.sessionRootId 的进程内还原)——pi 引擎
50
- * relay 归属键 SESSION_ID 的权威来源。additive 可选:宿主缺省不传。
50
+ * engine_open 归属键的权威来源。additive 可选:宿主缺省不传。
51
51
  */
52
52
  sessionRootId?: string;
53
53
  /**
@@ -75,7 +75,7 @@ interface RunContext {
75
75
  mode?: string;
76
76
  };
77
77
  onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef">) => void;
78
- /** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
78
+ /** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议范围)。 */
79
79
  onChildSpawned?: (child: {
80
80
  pid: number | undefined;
81
81
  killed: boolean;
@@ -127,7 +127,7 @@ interface EnginePort {
127
127
  canonicalRef: string;
128
128
  };
129
129
  /**
130
- * [subagent-model-switch §7.3] 可选面:执行中模型热切换(协议 setModel 正向方法的
130
+ * [subagent-model-switch §7.3] 可选能力:执行中模型热切换(协议 setModel 正向方法的
131
131
  * 进程内承载)。实现引擎须 capabilities.setModel = 'native' 同批声明(位与方法
132
132
  * 成对进出——capabilities 注释的消费点登记);server 分发行在位非 native 时回
133
133
  * engineSetModelUnsupportedError 结构化错误(契约行为 = 明确错误而非崩)。
@@ -1,8 +1,8 @@
1
- import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-jSa1g28F.js';
2
- import { S as SetModelParams, a as SetModelResult } from './methods-C2zvZqhP.js';
1
+ import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-BUHUMF9R.js';
2
+ import { S as SetModelParams, a as SetModelResult } from './methods-BdIH3FwS.js';
3
3
 
4
4
  /**
5
- * 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
5
+ * 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎侧子集 + 协议 ctx 还原字段(model/
6
6
  * cwd——SDK 契约把它们从 task 移到 run.params.ctx,进程内接口合回单对象;
7
7
  * server.ts 做 ctx→task 还原,与 core RemoteEngine.toSdkTaskSubset 镜像)。
8
8
  */
@@ -12,7 +12,7 @@ type EngineAgentCallOpts = AgentCallOpts & {
12
12
  };
13
13
  /**
14
14
  * 引擎进程内的 ctxModel 形态(core ModelInfo 的结构等价镜像——仅 id/provider 被引擎
15
- * 消费,name/reasoning 等字段透传保留防测试/未来消费面漂移)。
15
+ * 消费,name/reasoning 等字段透传保留防测试/未来消费方漂移)。
16
16
  */
17
17
  interface EngineCtxModel {
18
18
  id: string;
@@ -30,11 +30,11 @@ interface EngineStream {
30
30
  * journal 固定分组 key(值锚定,**只承载、不透传**):journal 落盘路径
31
31
  * `<dataDir>/engines/<engineId>/<本值>/journal-<taskId>.jsonl` 的第二段,两引擎恒
32
32
  * 本值(pi / zcode 均无池化实现——pi = PI_CODING_AGENT_DIR 全局一份,zcode = 共享
33
- * 宿主 HOME)。[池抽象降级 2026-09-13] poolKey 协议面(RunContext/run.params.ctx/
33
+ * 宿主 HOME)。[池抽象降级 2026-09-13] poolKey 协议范围(RunContext/run.params.ctx/
34
34
  * host/poolResolved 通道/EngineHandleData)已整体退役,本常量不再跨进程透传,仅
35
35
  * 三类消费:① journal 落盘路径构造(core event-journal-wiring);② 存量 record 兼容
36
36
  * (zcode read 旧相对 dbPath 的锚定分支 + 持久化 engineHandle.poolKey 字段——
37
- * record-store 读侧守卫要求非空,值恒本常量);③ 引擎数据目录布局 SSOT paths.ts
37
+ * record-store 读侧检查要求非空,值恒本常量);③ 引擎数据目录布局 SSOT paths.ts
38
38
  * 的签名参数。**值逐字不变**(存量 journal 落盘路径与记录含该值分段,改名不改值)。
39
39
  */
40
40
  declare const SHARED_POOL_KEY = "shared";
@@ -47,7 +47,7 @@ interface RunContext {
47
47
  stream?: EngineStream;
48
48
  /**
49
49
  * [F6] 根 session id(协议 run.params.ctx.sessionRootId 的进程内还原)——pi 引擎
50
- * relay 归属键 SESSION_ID 的权威来源。additive 可选:宿主缺省不传。
50
+ * engine_open 归属键的权威来源。additive 可选:宿主缺省不传。
51
51
  */
52
52
  sessionRootId?: string;
53
53
  /**
@@ -75,7 +75,7 @@ interface RunContext {
75
75
  mode?: string;
76
76
  };
77
77
  onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef">) => void;
78
- /** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
78
+ /** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议范围)。 */
79
79
  onChildSpawned?: (child: {
80
80
  pid: number | undefined;
81
81
  killed: boolean;
@@ -127,7 +127,7 @@ interface EnginePort {
127
127
  canonicalRef: string;
128
128
  };
129
129
  /**
130
- * [subagent-model-switch §7.3] 可选面:执行中模型热切换(协议 setModel 正向方法的
130
+ * [subagent-model-switch §7.3] 可选能力:执行中模型热切换(协议 setModel 正向方法的
131
131
  * 进程内承载)。实现引擎须 capabilities.setModel = 'native' 同批声明(位与方法
132
132
  * 成对进出——capabilities 注释的消费点登记);server 分发行在位非 native 时回
133
133
  * engineSetModelUnsupportedError 结构化错误(契约行为 = 明确错误而非崩)。
@@ -26,7 +26,11 @@ __export(protocol_exports, {
26
26
  ENGINE_PROTOCOL_ERROR_CODES: () => ENGINE_PROTOCOL_ERROR_CODES,
27
27
  ENGINE_PROTOCOL_SCHEMAS: () => ENGINE_PROTOCOL_SCHEMAS,
28
28
  ENGINE_PROTOCOL_VERSION: () => ENGINE_PROTOCOL_VERSION,
29
+ ENGINE_SPAWN_DELIVERY_ERROR_CODES: () => ENGINE_SPAWN_DELIVERY_ERROR_CODES,
30
+ ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY: () => ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
29
31
  ENGINE_TIMEOUT_RECOVERY: () => ENGINE_TIMEOUT_RECOVERY,
32
+ ENGINE_TRANSPORT_ERROR_CODES: () => ENGINE_TRANSPORT_ERROR_CODES,
33
+ ENGINE_TRANSPORT_ERROR_RECOVERY: () => ENGINE_TRANSPORT_ERROR_RECOVERY,
30
34
  EngineSdkError: () => EngineSdkError,
31
35
  FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: () => FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
32
36
  HANDSHAKE_TIMEOUT_MS: () => HANDSHAKE_TIMEOUT_MS,
@@ -40,6 +44,9 @@ __export(protocol_exports, {
40
44
  SET_MODEL_STAGE_TIMEOUT_MS: () => SET_MODEL_STAGE_TIMEOUT_MS,
41
45
  STDERR_TAIL_CHARS: () => STDERR_TAIL_CHARS,
42
46
  STDOUT_TAIL_ECHO_CHARS: () => STDOUT_TAIL_ECHO_CHARS,
47
+ SUBAGENT_CONTROL_CLOSED_REASONS: () => SUBAGENT_CONTROL_CLOSED_REASONS,
48
+ SUBAGENT_CONTROL_FRAME_KINDS: () => SUBAGENT_CONTROL_FRAME_KINDS,
49
+ SUBAGENT_CONTROL_PROTOCOL_VERSION: () => SUBAGENT_CONTROL_PROTOCOL_VERSION,
43
50
  SUPPORTED_PROTOCOL_RANGE: () => SUPPORTED_PROTOCOL_RANGE,
44
51
  assertChatConversationSupported: () => assertChatConversationSupported,
45
52
  engineConversationUnsupportedError: () => engineConversationUnsupportedError,
@@ -54,6 +61,8 @@ __export(protocol_exports, {
54
61
  isRequestFrame: () => isRequestFrame,
55
62
  isResponseFrame: () => isResponseFrame,
56
63
  isReverseRequestFrame: () => isReverseRequestFrame,
64
+ isSubagentControlClosedReason: () => isSubagentControlClosedReason,
65
+ isSubagentControlFrameKind: () => isSubagentControlFrameKind,
57
66
  notificationFrameSchema: () => notificationFrameSchema,
58
67
  protocolErrorSchema: () => protocolErrorSchema,
59
68
  requestFrameSchema: () => requestFrameSchema,
@@ -132,6 +141,30 @@ var REVERSE_CHANNEL_TIMEOUT_CLASS = {
132
141
  };
133
142
 
134
143
  // src/protocol/error-codes.ts
144
+ var ENGINE_SPAWN_DELIVERY_ERROR_CODES = [
145
+ "engine_prompt_not_delivered",
146
+ "engine_prompt_rejected",
147
+ "engine_spawn_handshake_timeout"
148
+ ];
149
+ var ENGINE_TRANSPORT_ERROR_CODES = [
150
+ "engine_transport_unavailable",
151
+ "engine_transport_lost",
152
+ "engine_open_timeout",
153
+ "engine_frame_too_large",
154
+ "engine_backpressure_overflow"
155
+ ];
156
+ var ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY = {
157
+ engine_prompt_not_delivered: "The task never reached the child pi (zero stdout after the prompt write, or the engine stdin was unavailable). Re-run the task; if it recurs, inspect the engine/pi logs (the failure carries the delivery diagnostics) and the runtime log.",
158
+ engine_prompt_rejected: "The child pi explicitly rejected the prompt command (success:false). Check the pi-side reason carried in the error detail (busy/queue/extension takeover states are reported by pi itself), then re-run.",
159
+ engine_spawn_handshake_timeout: "The engine spawn handshake did not complete in time. Check the runtime log for a spawn/handshake stall, then restart taiji and re-run the task."
160
+ };
161
+ var ENGINE_TRANSPORT_ERROR_RECOVERY = {
162
+ engine_transport_unavailable: "The runtime control socket is unreachable (connect or hello failed). The runtime side is failing explicitly instead of silently falling back to local spawn \u2014 restart taiji and re-run the task.",
163
+ engine_transport_lost: "The control connection to the runtime was lost mid-flight (runtime restart or crash). In-flight requests were rejected; restart taiji (or wait for the runtime to come back) and re-run the task \u2014 the connection is not retried in place.",
164
+ engine_open_timeout: "The runtime did not finish opening the engine channel in time (spawn/attribution stalled). Check the runtime log (engine opened / kill decision lines), then re-run the task.",
165
+ engine_frame_too_large: "A single frame exceeded the control-plane size limit and the channel was closed without truncation. Shrink the task/result payload (e.g. point the agent at files instead of inlining them) and re-run.",
166
+ engine_backpressure_overflow: "The control-plane write queue overflowed (engine consumed frames too slowly) and the overflowed scope was torn down without dropping frames silently. Re-run the task; if it recurs, reduce concurrent subagent fan-out."
167
+ };
135
168
  var SET_MODEL_ERROR_CODES = [
136
169
  /** 目标模型不在当前进程快照(子进程模型快照冻结于 spawn 时刻——模型本身有效,
137
170
  * 下一轮 spawn 现取目录即可用;宿主按「写覆盖意图」处置,设计 §7.2 快照型失败行)。 */
@@ -176,7 +209,7 @@ var EngineSdkError = class extends Error {
176
209
  this.recovery = recovery;
177
210
  this.data = data;
178
211
  }
179
- /** 协议 error 帧载荷投影。 */
212
+ /** 协议 error 帧载荷派生视图。 */
180
213
  toStructured() {
181
214
  return { code: this.code, message: this.message, recovery: this.recovery, data: this.data };
182
215
  }
@@ -227,12 +260,39 @@ function schemaEmulationFailedDetail(error, tail) {
227
260
  return `structured output emulation failed after tolerant extraction and one host-side retry: ${error}. Raw output tail: ${truncate(tail, DETAIL_ECHO_MAX_CHARS)}. Recovery: retry with a strengthened prompt or relax the schema; if it still fails switch to a schema-native engine (engine: pi).`;
228
261
  }
229
262
 
263
+ // src/protocol/control-protocol.ts
264
+ var SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
265
+ var SUBAGENT_CONTROL_FRAME_KINDS = {
266
+ hello: "hello",
267
+ helloOk: "hello_ok",
268
+ helloReject: "hello_reject",
269
+ engineOpen: "engine_open",
270
+ engineOpened: "engine_opened",
271
+ engineOpenFailed: "engine_open_failed",
272
+ engineFrame: "engine_frame",
273
+ engineClose: "engine_close",
274
+ engineClosed: "engine_closed",
275
+ error: "error"
276
+ };
277
+ function isSubagentControlFrameKind(value) {
278
+ return typeof value === "string" && Object.values(SUBAGENT_CONTROL_FRAME_KINDS).includes(value);
279
+ }
280
+ var SUBAGENT_CONTROL_CLOSED_REASONS = {
281
+ engineExit: "engine_exit",
282
+ engineSignal: "engine_signal",
283
+ killedByControl: "killed_by_control",
284
+ openTimeout: "open_timeout"
285
+ };
286
+ function isSubagentControlClosedReason(value) {
287
+ return typeof value === "string" && Object.values(SUBAGENT_CONTROL_CLOSED_REASONS).includes(value);
288
+ }
289
+
230
290
  // src/protocol/contract-types.ts
231
291
  var AGENT_EVENT_TYPE_NAMES = [
232
292
  "tool_start",
233
293
  // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 tool 起始占位(显示降级),turn 结构不受损
234
294
  "tool_end",
235
- // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn 收口由 turn_end/message_end 承担
295
+ // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn 收尾由 turn_end/message_end 承担
236
296
  "text_delta",
237
297
  // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺正文增量,不产生半解析状态
238
298
  "thinking_delta",
@@ -240,7 +300,7 @@ var AGENT_EVENT_TYPE_NAMES = [
240
300
  "turn_end",
241
301
  // noop-safe: 旧宿主 default 分支零写入——丢弃则该 turn 滞留进行态,journal 重放仍按序重建
242
302
  "message_end",
243
- // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage 聚合与闭合计量,已累积内容不回滚
303
+ // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage 聚合与结束计量,已累积内容不回滚
244
304
  "compaction",
245
305
  // noop-safe: 事件无载荷且现行 reducer 即直接 return——丢弃与处理零差异
246
306
  "activity",
@@ -322,7 +382,7 @@ var notificationFrameSchema = {
322
382
  type: {
323
383
  type: "string",
324
384
  // 事件 enum 从词表 SSOT 派生(U2 词表锁:union⟷词表互证后,此处不再
325
- // 手写字面量集合——手写即漂移面,病灶 1 的第三处同步点)
385
+ // 手写字面量集合——手写即漂移点,问题点 1 的第三处同步点)
326
386
  enum: [...AGENT_EVENT_TYPE_NAMES]
327
387
  }
328
388
  }
@@ -387,7 +447,11 @@ var runSessionParamsSchema = {
387
447
  ENGINE_PROTOCOL_ERROR_CODES,
388
448
  ENGINE_PROTOCOL_SCHEMAS,
389
449
  ENGINE_PROTOCOL_VERSION,
450
+ ENGINE_SPAWN_DELIVERY_ERROR_CODES,
451
+ ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
390
452
  ENGINE_TIMEOUT_RECOVERY,
453
+ ENGINE_TRANSPORT_ERROR_CODES,
454
+ ENGINE_TRANSPORT_ERROR_RECOVERY,
391
455
  EngineSdkError,
392
456
  FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
393
457
  HANDSHAKE_TIMEOUT_MS,
@@ -401,6 +465,9 @@ var runSessionParamsSchema = {
401
465
  SET_MODEL_STAGE_TIMEOUT_MS,
402
466
  STDERR_TAIL_CHARS,
403
467
  STDOUT_TAIL_ECHO_CHARS,
468
+ SUBAGENT_CONTROL_CLOSED_REASONS,
469
+ SUBAGENT_CONTROL_FRAME_KINDS,
470
+ SUBAGENT_CONTROL_PROTOCOL_VERSION,
404
471
  SUPPORTED_PROTOCOL_RANGE,
405
472
  assertChatConversationSupported,
406
473
  engineConversationUnsupportedError,
@@ -415,6 +482,8 @@ var runSessionParamsSchema = {
415
482
  isRequestFrame,
416
483
  isResponseFrame,
417
484
  isReverseRequestFrame,
485
+ isSubagentControlClosedReason,
486
+ isSubagentControlFrameKind,
418
487
  notificationFrameSchema,
419
488
  protocolErrorSchema,
420
489
  requestFrameSchema,
@@ -1,7 +1,7 @@
1
- export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_TIMEOUT_RECOVERY, d as EngineProtocolErrorCode, E as EngineSdkError, e as ErrorResponseFrame, f as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, g as ResponseFrame, h as ReverseRequestFrame, i as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, j as SET_MODEL_NOT_ACTIVE_CODE, k as STDOUT_TAIL_ECHO_CHARS, l as SetModelErrorCode, m as SuccessResponseFrame, n as assertChatConversationSupported, o as engineConversationUnsupportedError, p as engineProtocolMismatchError, q as engineSetModelUnsupportedError, r as engineTimeoutDetail, s as isEngineErrorPassthroughCode, t as isEngineProtocolErrorCode, u as isNotificationFrame, v as isRequestFrame, w as isResponseFrame, x as isReverseRequestFrame, y as schemaEmulationFailedDetail } from '../error-codes-f-UO4a8D.cjs';
2
- export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from '../methods-BLxg4ZFr.cjs';
1
+ export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_SPAWN_DELIVERY_ERROR_CODES, d as ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY, e as ENGINE_TIMEOUT_RECOVERY, f as ENGINE_TRANSPORT_ERROR_CODES, g as ENGINE_TRANSPORT_ERROR_RECOVERY, h as EngineProtocolErrorCode, E as EngineSdkError, i as EngineSpawnDeliveryErrorCode, j as EngineTransportErrorCode, k as ErrorResponseFrame, l as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, m as ResponseFrame, n as ReverseRequestFrame, o as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, p as SET_MODEL_NOT_ACTIVE_CODE, q as STDOUT_TAIL_ECHO_CHARS, r as SetModelErrorCode, s as SuccessResponseFrame, t as assertChatConversationSupported, u as engineConversationUnsupportedError, v as engineProtocolMismatchError, w as engineSetModelUnsupportedError, x as engineTimeoutDetail, y as isEngineErrorPassthroughCode, z as isEngineProtocolErrorCode, A as isNotificationFrame, B as isRequestFrame, C as isResponseFrame, D as isReverseRequestFrame, F as schemaEmulationFailedDetail } from '../error-codes-D_aPibUt.cjs';
2
+ export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from '../methods-CHiDwvRK.cjs';
3
3
  import { UiRequest, UiResponse } from '../ui-types.cjs';
4
- export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-jSa1g28F.cjs';
4
+ export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-BUHUMF9R.cjs';
5
5
 
6
6
  /** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
7
7
  declare const ENGINE_PROTOCOL_VERSION = 1;
@@ -15,7 +15,7 @@ declare const SUPPORTED_PROTOCOL_RANGE: {
15
15
  };
16
16
  /** 版本兼容判定(core 握手判据;引擎侧对称用于拒绝过旧/过新宿主)。 */
17
17
  declare function isProtocolVersionCompatible(version: number): boolean;
18
- /** 正向数据面反向请求(帧④数据面类)未应答容忍时长:10s 未答 = 引擎故障 → 杀进程 + 在途 run 失败。 */
18
+ /** 正向数据范围反向请求(帧④数据范围类)未应答容忍时长:10s 未答 = 引擎故障 → 杀进程 + 在途 run 失败。 */
19
19
  declare const REVERSE_REQUEST_TIMEOUT_MS = 10000;
20
20
  /** initialize 握手超时(ms):超时 → engine_handshake_timeout,该引擎不可用。 */
21
21
  declare const HANDSHAKE_TIMEOUT_MS = 10000;
@@ -24,22 +24,22 @@ declare const CANCEL_SETTLE_GRACE_MS = 3000;
24
24
  /**
25
25
  * setModel 引擎侧单阶段控制窗(ms):pi 实现等子进程 `set_model` 应答、等
26
26
  * `get_state` 回读各占一窗(设计 subagent-model-switch §7.3——命令与回读全程带
27
- * 存活检查,超时上限复用现役取消收敛窗量级:控制面单请求 = 秒级)。窗满且进程
27
+ * 存活检查,超时上限复用现役取消收敛窗量级:控制范围单请求 = 秒级)。窗满且进程
28
28
  * 仍存活 → `engine_state_readback_failed`;窗满时进程已退出 → 无活进程形态
29
29
  * (`SET_MODEL_NOT_ACTIVE_CODE`)——两种处置不可混淆。
30
30
  */
31
31
  declare const SET_MODEL_STAGE_TIMEOUT_MS = 3000;
32
32
  /**
33
33
  * setModel 正向方法的宿主侧单请求上界(ms):≥ 引擎侧两阶段最坏时延
34
- * (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据面单请求
35
- * REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制面单请求必须秒级有界——宿主不悬挂)。
34
+ * (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据范围单请求
35
+ * REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制范围单请求必须秒级有界——宿主不悬挂)。
36
36
  */
37
37
  declare const SET_MODEL_REQUEST_TIMEOUT_MS = 10000;
38
38
  /** stderr 内存环形缓冲保留的尾部字符数(engine_crashed 帧携带崩溃现场)。 */
39
39
  declare const STDERR_TAIL_CHARS = 400;
40
40
  /**
41
41
  * 反向请求超时二分(帧④注释,R9-2):
42
- * - 数据面类(host/log / host/streamDelta / host/handleReady /
42
+ * - 数据范围类(host/log / host/streamDelta / host/handleReady /
43
43
  * host/childSpawned / host/childStateChanged):10s 未答 = 引擎故障;
44
44
  * - 人机交互类(host/askUser):不设统一超时——core 先回 {ack:true},
45
45
  * 结果异步到达;按 ADR-0047「静默 ≠ 卡死」用无进展检测/用户取消,不据此判引擎故障。
@@ -55,11 +55,11 @@ type ReverseChannel = "host/log" | "host/askUser" | "host/streamDelta" | "host/h
55
55
  */
56
56
  declare const REVERSE_CHANNELS: readonly ["host/log", "host/askUser", "host/streamDelta", "host/handleReady", "host/childSpawned", "host/childStateChanged"];
57
57
  /**
58
- * 超时二分归属(10s 数据面 / 不设统一超时的人机交互面)。实现归 W2 EngineClient;
58
+ * 超时二分归属(10s 数据范围 / 不设统一超时的人机交互通道)。实现归 W2 EngineClient;
59
59
  * 引擎侧自灭计时(W12)复用同表——已 ack 的 askUser 等待不计入 in-flight(R9-2)。
60
60
  */
61
61
  declare const REVERSE_CHANNEL_TIMEOUT_CLASS: Record<ReverseChannel, ReverseRequestTimeoutClass>;
62
- /** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用面)。 */
62
+ /** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用范围)。 */
63
63
  interface HostLogParams {
64
64
  level: "debug" | "warn" | "error";
65
65
  component: string;
@@ -87,7 +87,7 @@ interface HostStreamDeltaParams {
87
87
  /**
88
88
  * host/handleReady:运行中句柄回填(core onHandleReady 语义:session/create 应答后、
89
89
  * 早于 run resolve;AGENTS.md 关键规则 9「重开 session 仍可见」的前提)。
90
- * [池抽象降级 2026-09-13] 原 poolKey 字段已随协议面 poolKey 退役删除。
90
+ * [池抽象降级 2026-09-13] 原 poolKey 字段已随协议范围 poolKey 退役删除。
91
91
  */
92
92
  interface HostHandleReadyParams {
93
93
  runId: string;
@@ -103,7 +103,7 @@ interface HostChildSpawnedParams {
103
103
  recordId: string;
104
104
  }
105
105
  /**
106
- * host/childStateChanged:childSpawned 的状态面(core 侧镜像数据源,
106
+ * host/childStateChanged:childSpawned 的状态侧(core 侧镜像数据源,
107
107
  * hasLiveProcessHandle/isResumable 同步读镜像,不跨进程查询)。
108
108
  * **killed 必含**(判据 `child !== undefined && !child.killed`)——类型层 required。
109
109
  */
@@ -117,6 +117,49 @@ interface HostChildStateChangedParams {
117
117
  signal?: string;
118
118
  }
119
119
 
120
+ /** control 协议版本(帧 v 字段;runtime 与 extension 同包分发,未知 v → hello_reject {reason:"version"},D9 版本矩阵)。 */
121
+ declare const SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
122
+ /**
123
+ * 帧 kind 判别值词表(10 成员)。as const 值即字面量类型——类型位置同样可用。
124
+ * 方向语义见文件头帧表:hello/engine_open/engine_frame/engine_close 为 C→R,
125
+ * hello_ok/hello_reject/engine_opened/engine_open_failed/engine_closed/error 为 R→C,
126
+ * engine_frame 双向。
127
+ */
128
+ declare const SUBAGENT_CONTROL_FRAME_KINDS: {
129
+ readonly hello: "hello";
130
+ readonly helloOk: "hello_ok";
131
+ readonly helloReject: "hello_reject";
132
+ readonly engineOpen: "engine_open";
133
+ readonly engineOpened: "engine_opened";
134
+ readonly engineOpenFailed: "engine_open_failed";
135
+ readonly engineFrame: "engine_frame";
136
+ readonly engineClose: "engine_close";
137
+ readonly engineClosed: "engine_closed";
138
+ readonly error: "error";
139
+ };
140
+ type SubagentControlFrameKind = (typeof SUBAGENT_CONTROL_FRAME_KINDS)[keyof typeof SUBAGENT_CONTROL_FRAME_KINDS];
141
+ /** unknown → control 帧 kind 收窄(外部输入携带 kind 时的运行时 guard)。 */
142
+ declare function isSubagentControlFrameKind(value: unknown): value is SubagentControlFrameKind;
143
+ /**
144
+ * engine_closed 帧 reason 值域(引擎通道终局归因,D8/D10):
145
+ * - engine_exit:引擎进程自行退出(code 承载退出码);
146
+ * - engine_signal:被信号终止(signal 承载信号名);
147
+ * - killed_by_control:runtime 主动杀组(engine_close 有界等待超时 / 背压溢出 /
148
+ * 连接关闭 fan-out 等控制面裁决);
149
+ * - open_timeout:engine_open 超时被 runtime 中止杀组(迟到 engine_opened 丢弃)。
150
+ * 意外退出(engine_exit/engine_signal)→ runtime 无条件 killEngineGroup(D7);
151
+ * runtime transport 把 reason 映射进 onExit info(stderrTail 同帧携带)。
152
+ */
153
+ declare const SUBAGENT_CONTROL_CLOSED_REASONS: {
154
+ readonly engineExit: "engine_exit";
155
+ readonly engineSignal: "engine_signal";
156
+ readonly killedByControl: "killed_by_control";
157
+ readonly openTimeout: "open_timeout";
158
+ };
159
+ type SubagentControlClosedReason = (typeof SUBAGENT_CONTROL_CLOSED_REASONS)[keyof typeof SUBAGENT_CONTROL_CLOSED_REASONS];
160
+ /** unknown → engine_closed reason 收窄(外部输入携带 reason 时的运行时 guard)。 */
161
+ declare function isSubagentControlClosedReason(value: unknown): value is SubagentControlClosedReason;
162
+
120
163
  /** 协议错误对象 schema。 */
121
164
  declare const protocolErrorSchema: {
122
165
  readonly $schema: "http://json-schema.org/draft-07/schema#";
@@ -404,7 +447,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
404
447
  };
405
448
  };
406
449
  /**
407
- * 协议面凭据禁区键名(不变量 5 的测试断言依据):帧 schema 与深载荷 TS 类型面
450
+ * 协议范围凭据禁区键名(不变量 5 的测试断言依据):帧 schema 与深载荷 TS 类型范围
408
451
  * 不得出现。词表覆盖常见拼写(子串匹配,非精确枚举)。
409
452
  */
410
453
  declare const FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: readonly ["apikey", "api_key", "token", "credential", "password", "secret"];
@@ -446,4 +489,4 @@ declare const runSessionParamsSchema: {
446
489
  };
447
490
  };
448
491
 
449
- export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReverseChannel, type ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
492
+ export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReverseChannel, type ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUBAGENT_CONTROL_CLOSED_REASONS, SUBAGENT_CONTROL_FRAME_KINDS, SUBAGENT_CONTROL_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_RANGE, type SubagentControlClosedReason, type SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
@@ -1,7 +1,7 @@
1
- export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_TIMEOUT_RECOVERY, d as EngineProtocolErrorCode, E as EngineSdkError, e as ErrorResponseFrame, f as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, g as ResponseFrame, h as ReverseRequestFrame, i as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, j as SET_MODEL_NOT_ACTIVE_CODE, k as STDOUT_TAIL_ECHO_CHARS, l as SetModelErrorCode, m as SuccessResponseFrame, n as assertChatConversationSupported, o as engineConversationUnsupportedError, p as engineProtocolMismatchError, q as engineSetModelUnsupportedError, r as engineTimeoutDetail, s as isEngineErrorPassthroughCode, t as isEngineProtocolErrorCode, u as isNotificationFrame, v as isRequestFrame, w as isResponseFrame, x as isReverseRequestFrame, y as schemaEmulationFailedDetail } from '../error-codes-DnFru4L4.js';
2
- export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from '../methods-C2zvZqhP.js';
1
+ export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_SPAWN_DELIVERY_ERROR_CODES, d as ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY, e as ENGINE_TIMEOUT_RECOVERY, f as ENGINE_TRANSPORT_ERROR_CODES, g as ENGINE_TRANSPORT_ERROR_RECOVERY, h as EngineProtocolErrorCode, E as EngineSdkError, i as EngineSpawnDeliveryErrorCode, j as EngineTransportErrorCode, k as ErrorResponseFrame, l as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, m as ResponseFrame, n as ReverseRequestFrame, o as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, p as SET_MODEL_NOT_ACTIVE_CODE, q as STDOUT_TAIL_ECHO_CHARS, r as SetModelErrorCode, s as SuccessResponseFrame, t as assertChatConversationSupported, u as engineConversationUnsupportedError, v as engineProtocolMismatchError, w as engineSetModelUnsupportedError, x as engineTimeoutDetail, y as isEngineErrorPassthroughCode, z as isEngineProtocolErrorCode, A as isNotificationFrame, B as isRequestFrame, C as isResponseFrame, D as isReverseRequestFrame, F as schemaEmulationFailedDetail } from '../error-codes-DrNf0gwT.js';
2
+ export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from '../methods-BdIH3FwS.js';
3
3
  import { UiRequest, UiResponse } from '../ui-types.js';
4
- export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-jSa1g28F.js';
4
+ export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-BUHUMF9R.js';
5
5
 
6
6
  /** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
7
7
  declare const ENGINE_PROTOCOL_VERSION = 1;
@@ -15,7 +15,7 @@ declare const SUPPORTED_PROTOCOL_RANGE: {
15
15
  };
16
16
  /** 版本兼容判定(core 握手判据;引擎侧对称用于拒绝过旧/过新宿主)。 */
17
17
  declare function isProtocolVersionCompatible(version: number): boolean;
18
- /** 正向数据面反向请求(帧④数据面类)未应答容忍时长:10s 未答 = 引擎故障 → 杀进程 + 在途 run 失败。 */
18
+ /** 正向数据范围反向请求(帧④数据范围类)未应答容忍时长:10s 未答 = 引擎故障 → 杀进程 + 在途 run 失败。 */
19
19
  declare const REVERSE_REQUEST_TIMEOUT_MS = 10000;
20
20
  /** initialize 握手超时(ms):超时 → engine_handshake_timeout,该引擎不可用。 */
21
21
  declare const HANDSHAKE_TIMEOUT_MS = 10000;
@@ -24,22 +24,22 @@ declare const CANCEL_SETTLE_GRACE_MS = 3000;
24
24
  /**
25
25
  * setModel 引擎侧单阶段控制窗(ms):pi 实现等子进程 `set_model` 应答、等
26
26
  * `get_state` 回读各占一窗(设计 subagent-model-switch §7.3——命令与回读全程带
27
- * 存活检查,超时上限复用现役取消收敛窗量级:控制面单请求 = 秒级)。窗满且进程
27
+ * 存活检查,超时上限复用现役取消收敛窗量级:控制范围单请求 = 秒级)。窗满且进程
28
28
  * 仍存活 → `engine_state_readback_failed`;窗满时进程已退出 → 无活进程形态
29
29
  * (`SET_MODEL_NOT_ACTIVE_CODE`)——两种处置不可混淆。
30
30
  */
31
31
  declare const SET_MODEL_STAGE_TIMEOUT_MS = 3000;
32
32
  /**
33
33
  * setModel 正向方法的宿主侧单请求上界(ms):≥ 引擎侧两阶段最坏时延
34
- * (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据面单请求
35
- * REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制面单请求必须秒级有界——宿主不悬挂)。
34
+ * (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据范围单请求
35
+ * REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制范围单请求必须秒级有界——宿主不悬挂)。
36
36
  */
37
37
  declare const SET_MODEL_REQUEST_TIMEOUT_MS = 10000;
38
38
  /** stderr 内存环形缓冲保留的尾部字符数(engine_crashed 帧携带崩溃现场)。 */
39
39
  declare const STDERR_TAIL_CHARS = 400;
40
40
  /**
41
41
  * 反向请求超时二分(帧④注释,R9-2):
42
- * - 数据面类(host/log / host/streamDelta / host/handleReady /
42
+ * - 数据范围类(host/log / host/streamDelta / host/handleReady /
43
43
  * host/childSpawned / host/childStateChanged):10s 未答 = 引擎故障;
44
44
  * - 人机交互类(host/askUser):不设统一超时——core 先回 {ack:true},
45
45
  * 结果异步到达;按 ADR-0047「静默 ≠ 卡死」用无进展检测/用户取消,不据此判引擎故障。
@@ -55,11 +55,11 @@ type ReverseChannel = "host/log" | "host/askUser" | "host/streamDelta" | "host/h
55
55
  */
56
56
  declare const REVERSE_CHANNELS: readonly ["host/log", "host/askUser", "host/streamDelta", "host/handleReady", "host/childSpawned", "host/childStateChanged"];
57
57
  /**
58
- * 超时二分归属(10s 数据面 / 不设统一超时的人机交互面)。实现归 W2 EngineClient;
58
+ * 超时二分归属(10s 数据范围 / 不设统一超时的人机交互通道)。实现归 W2 EngineClient;
59
59
  * 引擎侧自灭计时(W12)复用同表——已 ack 的 askUser 等待不计入 in-flight(R9-2)。
60
60
  */
61
61
  declare const REVERSE_CHANNEL_TIMEOUT_CLASS: Record<ReverseChannel, ReverseRequestTimeoutClass>;
62
- /** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用面)。 */
62
+ /** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用范围)。 */
63
63
  interface HostLogParams {
64
64
  level: "debug" | "warn" | "error";
65
65
  component: string;
@@ -87,7 +87,7 @@ interface HostStreamDeltaParams {
87
87
  /**
88
88
  * host/handleReady:运行中句柄回填(core onHandleReady 语义:session/create 应答后、
89
89
  * 早于 run resolve;AGENTS.md 关键规则 9「重开 session 仍可见」的前提)。
90
- * [池抽象降级 2026-09-13] 原 poolKey 字段已随协议面 poolKey 退役删除。
90
+ * [池抽象降级 2026-09-13] 原 poolKey 字段已随协议范围 poolKey 退役删除。
91
91
  */
92
92
  interface HostHandleReadyParams {
93
93
  runId: string;
@@ -103,7 +103,7 @@ interface HostChildSpawnedParams {
103
103
  recordId: string;
104
104
  }
105
105
  /**
106
- * host/childStateChanged:childSpawned 的状态面(core 侧镜像数据源,
106
+ * host/childStateChanged:childSpawned 的状态侧(core 侧镜像数据源,
107
107
  * hasLiveProcessHandle/isResumable 同步读镜像,不跨进程查询)。
108
108
  * **killed 必含**(判据 `child !== undefined && !child.killed`)——类型层 required。
109
109
  */
@@ -117,6 +117,49 @@ interface HostChildStateChangedParams {
117
117
  signal?: string;
118
118
  }
119
119
 
120
+ /** control 协议版本(帧 v 字段;runtime 与 extension 同包分发,未知 v → hello_reject {reason:"version"},D9 版本矩阵)。 */
121
+ declare const SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
122
+ /**
123
+ * 帧 kind 判别值词表(10 成员)。as const 值即字面量类型——类型位置同样可用。
124
+ * 方向语义见文件头帧表:hello/engine_open/engine_frame/engine_close 为 C→R,
125
+ * hello_ok/hello_reject/engine_opened/engine_open_failed/engine_closed/error 为 R→C,
126
+ * engine_frame 双向。
127
+ */
128
+ declare const SUBAGENT_CONTROL_FRAME_KINDS: {
129
+ readonly hello: "hello";
130
+ readonly helloOk: "hello_ok";
131
+ readonly helloReject: "hello_reject";
132
+ readonly engineOpen: "engine_open";
133
+ readonly engineOpened: "engine_opened";
134
+ readonly engineOpenFailed: "engine_open_failed";
135
+ readonly engineFrame: "engine_frame";
136
+ readonly engineClose: "engine_close";
137
+ readonly engineClosed: "engine_closed";
138
+ readonly error: "error";
139
+ };
140
+ type SubagentControlFrameKind = (typeof SUBAGENT_CONTROL_FRAME_KINDS)[keyof typeof SUBAGENT_CONTROL_FRAME_KINDS];
141
+ /** unknown → control 帧 kind 收窄(外部输入携带 kind 时的运行时 guard)。 */
142
+ declare function isSubagentControlFrameKind(value: unknown): value is SubagentControlFrameKind;
143
+ /**
144
+ * engine_closed 帧 reason 值域(引擎通道终局归因,D8/D10):
145
+ * - engine_exit:引擎进程自行退出(code 承载退出码);
146
+ * - engine_signal:被信号终止(signal 承载信号名);
147
+ * - killed_by_control:runtime 主动杀组(engine_close 有界等待超时 / 背压溢出 /
148
+ * 连接关闭 fan-out 等控制面裁决);
149
+ * - open_timeout:engine_open 超时被 runtime 中止杀组(迟到 engine_opened 丢弃)。
150
+ * 意外退出(engine_exit/engine_signal)→ runtime 无条件 killEngineGroup(D7);
151
+ * runtime transport 把 reason 映射进 onExit info(stderrTail 同帧携带)。
152
+ */
153
+ declare const SUBAGENT_CONTROL_CLOSED_REASONS: {
154
+ readonly engineExit: "engine_exit";
155
+ readonly engineSignal: "engine_signal";
156
+ readonly killedByControl: "killed_by_control";
157
+ readonly openTimeout: "open_timeout";
158
+ };
159
+ type SubagentControlClosedReason = (typeof SUBAGENT_CONTROL_CLOSED_REASONS)[keyof typeof SUBAGENT_CONTROL_CLOSED_REASONS];
160
+ /** unknown → engine_closed reason 收窄(外部输入携带 reason 时的运行时 guard)。 */
161
+ declare function isSubagentControlClosedReason(value: unknown): value is SubagentControlClosedReason;
162
+
120
163
  /** 协议错误对象 schema。 */
121
164
  declare const protocolErrorSchema: {
122
165
  readonly $schema: "http://json-schema.org/draft-07/schema#";
@@ -404,7 +447,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
404
447
  };
405
448
  };
406
449
  /**
407
- * 协议面凭据禁区键名(不变量 5 的测试断言依据):帧 schema 与深载荷 TS 类型面
450
+ * 协议范围凭据禁区键名(不变量 5 的测试断言依据):帧 schema 与深载荷 TS 类型范围
408
451
  * 不得出现。词表覆盖常见拼写(子串匹配,非精确枚举)。
409
452
  */
410
453
  declare const FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: readonly ["apikey", "api_key", "token", "credential", "password", "secret"];
@@ -446,4 +489,4 @@ declare const runSessionParamsSchema: {
446
489
  };
447
490
  };
448
491
 
449
- export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReverseChannel, type ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
492
+ export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReverseChannel, type ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUBAGENT_CONTROL_CLOSED_REASONS, SUBAGENT_CONTROL_FRAME_KINDS, SUBAGENT_CONTROL_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_RANGE, type SubagentControlClosedReason, type SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };