@zhushanwen/subagent-engine-sdk 0.10.1 → 0.12.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 (62) 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-LM7P7OTA.js → chunk-7R6HYT2A.js} +60 -4
  4. package/dist/{chunk-JZN76I3S.js → chunk-NVF3PADP.js} +29 -1
  5. package/dist/{chunk-NTOLHLCL.js → chunk-QGXILDWB.js} +1 -1
  6. package/dist/{chunk-CNCFMPEH.js → chunk-TJMS3YOR.js} +1 -1
  7. package/dist/{chunk-SGAIDL63.js → chunk-U5MBAKS5.js} +21 -7
  8. package/dist/cli-entry.d.cts +1 -1
  9. package/dist/cli-entry.d.ts +1 -1
  10. package/dist/{contract-types-jSa1g28F.d.cts → contract-types-C1scOS_M.d.cts} +218 -21
  11. package/dist/{contract-types-jSa1g28F.d.ts → contract-types-C1scOS_M.d.ts} +218 -21
  12. package/dist/env.cjs +5 -10
  13. package/dist/env.d.cts +6 -17
  14. package/dist/env.d.ts +6 -17
  15. package/dist/env.js +1 -1
  16. package/dist/{error-codes-f-UO4a8D.d.cts → error-codes-CgcjlmeD.d.cts} +42 -6
  17. package/dist/{error-codes-DnFru4L4.d.ts → error-codes-o4rNd1Ee.d.ts} +42 -6
  18. package/dist/index.cjs +178 -103
  19. package/dist/index.d.cts +29 -41
  20. package/dist/index.d.ts +29 -41
  21. package/dist/index.js +54 -57
  22. package/dist/journal-io.d.cts +1 -1
  23. package/dist/journal-io.d.ts +1 -1
  24. package/dist/journal-replay.cjs +24 -7
  25. package/dist/journal-replay.d.cts +41 -7
  26. package/dist/journal-replay.d.ts +41 -7
  27. package/dist/journal-replay.js +7 -1
  28. package/dist/kill-chain.d.cts +5 -5
  29. package/dist/kill-chain.d.ts +5 -5
  30. package/dist/kill-chain.js +2 -2
  31. package/dist/logger.d.cts +1 -1
  32. package/dist/logger.d.ts +1 -1
  33. package/dist/logs/stderr-rotation.d.cts +4 -4
  34. package/dist/logs/stderr-rotation.d.ts +4 -4
  35. package/dist/{methods-BLxg4ZFr.d.cts → methods-BzvzcCrB.d.cts} +5 -5
  36. package/dist/{methods-C2zvZqhP.d.ts → methods-CPMc4cvF.d.ts} +5 -5
  37. package/dist/node-executor.cjs +1 -1
  38. package/dist/node-executor.d.cts +4 -4
  39. package/dist/node-executor.d.ts +4 -4
  40. package/dist/node-executor.js +2 -2
  41. package/dist/port-contract.d.cts +9 -9
  42. package/dist/port-contract.d.ts +9 -9
  43. package/dist/protocol/index.cjs +103 -5
  44. package/dist/protocol/index.d.cts +59 -16
  45. package/dist/protocol/index.d.ts +59 -16
  46. package/dist/protocol/index.js +30 -2
  47. package/dist/server/index.cjs +1 -1
  48. package/dist/server/index.d.cts +10 -10
  49. package/dist/server/index.d.ts +10 -10
  50. package/dist/server/index.js +1 -1
  51. package/dist/spawn.cjs +32 -3
  52. package/dist/spawn.d.cts +34 -8
  53. package/dist/spawn.d.ts +34 -8
  54. package/dist/spawn.js +5 -3
  55. package/dist/ui-types.d.cts +2 -2
  56. package/dist/ui-types.d.ts +2 -2
  57. package/package.json +13 -2
  58. package/dist/chunk-GSW3DMN6.js +0 -39
  59. package/dist/relay-env.cjs +0 -71
  60. package/dist/relay-env.d.cts +0 -37
  61. package/dist/relay-env.d.ts +0 -37
  62. package/dist/relay-env.js +0 -23
@@ -1,4 +1,4 @@
1
- import { A as AgentEvent, d as EngineCapabilities } from './contract-types-jSa1g28F.js';
1
+ import { A as AgentEvent, e as EngineCapabilities } from './contract-types-C1scOS_M.js';
2
2
 
3
3
  /** 协议错误对象(error 帧载荷与反向请求错误应答共用形态)。 */
4
4
  interface ProtocolError {
@@ -42,7 +42,7 @@ interface ReverseRequestFrame {
42
42
  }
43
43
  /** 反向请求的应答(core → 引擎,沿 ResponseFrame 通道回传;id = 反向请求 id 原样)。 */
44
44
  type ReverseResponseResult =
45
- /** 数据面类:处理确认。 */
45
+ /** 数据范围类:处理确认。 */
46
46
  {
47
47
  ok: true;
48
48
  }
@@ -63,6 +63,42 @@ declare function isNotificationFrame(frame: unknown): frame is NotificationFrame
63
63
  /** ④ 反向请求:有字符串 id + host/* method + params(与①的区别 = id 形态与 method 前缀)。 */
64
64
  declare function isReverseRequestFrame(frame: unknown): frame is ReverseRequestFrame;
65
65
 
66
+ /**
67
+ * 引擎进程侧 spawn/送达窗口错误码(M1/M2 送达回执,设计 D10「engine 侧」)。
68
+ * 消费方 = pi-subagent-cli(u-m2-engine-ack 接线):
69
+ * - prompt_not_delivered:prompt 写入后零 stdout(零输出判定)/ stdin 不可用 / EPIPE——
70
+ * 任务从未被真实 pi 受理,静默丢失的显式失败形态;
71
+ * - prompt_rejected:pi 对 prompt 命令回 success:false(已送达但被拒绝)——带 pi 的
72
+ * error 文本,与 not_delivered 分型防误诊(D3 不采用合并条目);
73
+ * - spawn_handshake_timeout:引擎 spawn 握手窗口超时——runtime/引擎停在
74
+ * spawn/handshake 的显式失败(control 侧同类失败码 = engine_open_timeout)。
75
+ */
76
+ declare const ENGINE_SPAWN_DELIVERY_ERROR_CODES: readonly ["engine_prompt_not_delivered", "engine_prompt_rejected", "engine_spawn_handshake_timeout"];
77
+ type EngineSpawnDeliveryErrorCode = (typeof ENGINE_SPAWN_DELIVERY_ERROR_CODES)[number];
78
+ /**
79
+ * runtime 控制面传输错误码(M3 control 通道,设计 D8/D10「runtime 侧」)。
80
+ * 消费方 = EngineClient.connectOnce preserve 白名单(u-m3-local:来自
81
+ * RuntimeEngineTransport 的 EngineSdkError 原样保留 code 与 recovery,不再包装成
82
+ * engine_crashed——UC-20 的显式失败不被吞掉)。语义(设计 D5/D8):
83
+ * - transport_unavailable:control socket connect / hello 失败——托管态 runtime 故障
84
+ * 显式可见,不静默回退 local spawn;
85
+ * - transport_lost:control 连接中途丢失(与 engine 自身 crash 区分)——标记不可用、
86
+ * fan-out 该连接全部 in-flight,不在同一连接重试;
87
+ * - open_timeout:engine_open 超时(runtime spawn/归属卡住);
88
+ * - frame_too_large:单帧(含 partial-line 缓冲)超 32MB 上限——不截断、按 channel
89
+ * 归因关闭;
90
+ * - backpressure_overflow:channel(32MB/4096 帧)或连接聚合(256MB)待写队列溢出——
91
+ * 不丢帧、不静默,溢出面(channel/connection)标注在 detail。
92
+ */
93
+ declare const ENGINE_TRANSPORT_ERROR_CODES: readonly ["engine_transport_unavailable", "engine_transport_lost", "engine_open_timeout", "engine_frame_too_large", "engine_backpressure_overflow"];
94
+ type EngineTransportErrorCode = (typeof ENGINE_TRANSPORT_ERROR_CODES)[number];
95
+ /**
96
+ * 引擎侧 spawn/送达错误码的 recovery 文案(键完整性由类型 Record + 测试锁定)。
97
+ * detail 由消费方拼装(诊断五元组 / pi error 文本),文案只给恢复动作。
98
+ */
99
+ declare const ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY: Record<EngineSpawnDeliveryErrorCode, string>;
100
+ /** runtime 控制面传输错误码的 recovery 文案(键完整性由类型 Record + 测试锁定)。 */
101
+ declare const ENGINE_TRANSPORT_ERROR_RECOVERY: Record<EngineTransportErrorCode, string>;
66
102
  /**
67
103
  * setModel 正向方法的错误码三型(引擎 error 帧给出;宿主消费分型)。
68
104
  * 追加进 ENGINE_PROTOCOL_ERROR_CODES 主词表(成员清单单源 = 本数组,主词表 spread)。
@@ -82,7 +118,7 @@ type SetModelErrorCode = (typeof SET_MODEL_ERROR_CODES)[number];
82
118
  * 四个竞态窗口内发现子进程已退出——**同一处置**按无活进程形态应答,引擎回本码
83
119
  * error 帧)。进主词表的依据与 SET_MODEL_ERROR_CODES 三型相同:宿主消费分型
84
120
  * (chat 域转已记账型应答 / run 级聚合落 not-active 成员态,§7.2 处置表),不是
85
- * 「core 不解释文案」的纯透传面。刻意**不进** SET_MODEL_ERROR_CODES:聚合失败
121
+ * 「core 不解释文案」的纯透传逻辑。刻意**不进** SET_MODEL_ERROR_CODES:聚合失败
86
122
  * 名单的分型值域只收「转发失败」三型,无活进程是成员三态之一(not-active),
87
123
  * 不是失败——两值域语义正交。
88
124
  */
@@ -92,7 +128,7 @@ declare const ENGINE_PROTOCOL_ERROR_CODES: readonly ["engine_not_found", "engine
92
128
  type EngineProtocolErrorCode = (typeof ENGINE_PROTOCOL_ERROR_CODES)[number];
93
129
  /** unknown → 协议错误码收窄(外部输入携带错误码时的运行时 guard;其余 engine_* 走透传)。 */
94
130
  declare function isEngineProtocolErrorCode(value: unknown): value is EngineProtocolErrorCode;
95
- /** 其余引擎自报错误码的前缀契约(透传面;core 不解释文案)。 */
131
+ /** 其余引擎自报错误码的前缀契约(透传侧;core 不解释文案)。 */
96
132
  declare const ENGINE_ERROR_CODE_PREFIX = "engine_";
97
133
  declare function isEngineErrorPassthroughCode(value: string): boolean;
98
134
 
@@ -106,7 +142,7 @@ declare class EngineSdkError extends Error {
106
142
  readonly recovery: string;
107
143
  readonly data?: Record<string, unknown>;
108
144
  constructor(code: string, detail: string, recovery: string, data?: Record<string, unknown>);
109
- /** 协议 error 帧载荷投影。 */
145
+ /** 协议 error 帧载荷派生视图。 */
110
146
  toStructured(): ProtocolError;
111
147
  }
112
148
  declare function engineProtocolMismatchError(engineVersion: number): EngineSdkError;
@@ -147,4 +183,4 @@ declare function engineTimeoutDetail(stdoutTail: string): string;
147
183
  /** schema_emulation_failed 的终报文案(宿主编排层「重试一次仍失败」后消费)。 */
148
184
  declare function schemaEmulationFailedDetail(error: string, tail: string): string;
149
185
 
150
- export { EngineSdkError as E, type NotificationFrame as N, type ProtocolError as P, type RequestFrame as R, SET_MODEL_ERROR_CODES as S, ENGINE_ERROR_CODE_PREFIX as a, ENGINE_PROTOCOL_ERROR_CODES as b, ENGINE_TIMEOUT_RECOVERY as c, type EngineProtocolErrorCode as d, type ErrorResponseFrame as e, type EventNotificationParams as f, type ResponseFrame as g, type ReverseRequestFrame as h, type ReverseResponseResult as i, SET_MODEL_NOT_ACTIVE_CODE as j, STDOUT_TAIL_ECHO_CHARS as k, type SetModelErrorCode as l, type SuccessResponseFrame as m, assertChatConversationSupported as n, engineConversationUnsupportedError as o, engineProtocolMismatchError as p, engineSetModelUnsupportedError as q, engineTimeoutDetail as r, isEngineErrorPassthroughCode as s, isEngineProtocolErrorCode as t, isNotificationFrame as u, isRequestFrame as v, isResponseFrame as w, isReverseRequestFrame as x, schemaEmulationFailedDetail as y };
186
+ export { isNotificationFrame as A, isRequestFrame as B, isResponseFrame as C, isReverseRequestFrame as D, EngineSdkError as E, schemaEmulationFailedDetail as F, type NotificationFrame as N, type ProtocolError as P, type RequestFrame as R, SET_MODEL_ERROR_CODES as S, ENGINE_ERROR_CODE_PREFIX as a, ENGINE_PROTOCOL_ERROR_CODES as b, ENGINE_SPAWN_DELIVERY_ERROR_CODES as c, ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY as d, ENGINE_TIMEOUT_RECOVERY as e, ENGINE_TRANSPORT_ERROR_CODES as f, ENGINE_TRANSPORT_ERROR_RECOVERY as g, type EngineProtocolErrorCode as h, type EngineSpawnDeliveryErrorCode as i, type EngineTransportErrorCode as j, type ErrorResponseFrame as k, type EventNotificationParams as l, type ResponseFrame as m, type ReverseRequestFrame as n, type ReverseResponseResult as o, SET_MODEL_NOT_ACTIVE_CODE as p, STDOUT_TAIL_ECHO_CHARS as q, type SetModelErrorCode as r, type SuccessResponseFrame as s, assertChatConversationSupported as t, engineConversationUnsupportedError as u, engineProtocolMismatchError as v, engineSetModelUnsupportedError as w, engineTimeoutDetail as x, isEngineErrorPassthroughCode as y, isEngineProtocolErrorCode as z };
package/dist/index.cjs CHANGED
@@ -6574,6 +6574,8 @@ var src_exports = {};
6574
6574
  __export(src_exports, {
6575
6575
  AGENT_EVENT_TYPE_NAMES: () => AGENT_EVENT_TYPE_NAMES,
6576
6576
  CANCEL_SETTLE_GRACE_MS: () => CANCEL_SETTLE_GRACE_MS,
6577
+ CONTROL_ENV_ROOT_SESSION_ID: () => CONTROL_ENV_ROOT_SESSION_ID,
6578
+ CONTROL_ENV_SOCKET: () => CONTROL_ENV_SOCKET,
6577
6579
  DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS: () => DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS,
6578
6580
  DEFAULT_KILL_GRACE_MS: () => DEFAULT_KILL_GRACE_MS,
6579
6581
  DEFAULT_NATIVE_INTERRUPT_GRACE_MS: () => DEFAULT_NATIVE_INTERRUPT_GRACE_MS,
@@ -6589,25 +6591,24 @@ __export(src_exports, {
6589
6591
  ENGINE_PROTOCOL_ERROR_CODES: () => ENGINE_PROTOCOL_ERROR_CODES,
6590
6592
  ENGINE_PROTOCOL_SCHEMAS: () => ENGINE_PROTOCOL_SCHEMAS,
6591
6593
  ENGINE_PROTOCOL_VERSION: () => ENGINE_PROTOCOL_VERSION,
6594
+ ENGINE_SPAWN_DELIVERY_ERROR_CODES: () => ENGINE_SPAWN_DELIVERY_ERROR_CODES,
6595
+ ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY: () => ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
6592
6596
  ENGINE_TIMEOUT_RECOVERY: () => ENGINE_TIMEOUT_RECOVERY,
6597
+ ENGINE_TRANSPORT_ERROR_CODES: () => ENGINE_TRANSPORT_ERROR_CODES,
6598
+ ENGINE_TRANSPORT_ERROR_RECOVERY: () => ENGINE_TRANSPORT_ERROR_RECOVERY,
6593
6599
  EngineSdkError: () => EngineSdkError,
6594
6600
  ExecutionNestingContext: () => ExecutionNestingContext,
6601
+ FAILURE_CAUSE_CLOSED_KINDS: () => FAILURE_CAUSE_CLOSED_KINDS,
6602
+ FAILURE_CAUSE_KINDS_BY_CLASS: () => FAILURE_CAUSE_KINDS_BY_CLASS,
6603
+ FAILURE_CAUSE_KINDS_BY_CLASS_LOCK: () => FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
6604
+ FAILURE_CAUSE_KIND_VOCAB_LOCK: () => FAILURE_CAUSE_KIND_VOCAB_LOCK,
6595
6605
  FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: () => FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
6596
6606
  HANDSHAKE_TIMEOUT_MS: () => HANDSHAKE_TIMEOUT_MS,
6597
6607
  HOST_TIMEOUT_ABORT_REASON: () => HOST_TIMEOUT_ABORT_REASON,
6598
6608
  NESTED_SPAWN_ENV: () => NESTED_SPAWN_ENV,
6599
6609
  NestedSpawnRejectedError: () => NestedSpawnRejectedError,
6610
+ PI_SUBAGENT_TASK_MAX_CHARS: () => PI_SUBAGENT_TASK_MAX_CHARS,
6600
6611
  PROTOCOL_METHODS: () => PROTOCOL_METHODS,
6601
- RELAY_ENV_NODE: () => RELAY_ENV_NODE,
6602
- RELAY_ENV_RECORD_ID: () => RELAY_ENV_RECORD_ID,
6603
- RELAY_ENV_SCRIPT: () => RELAY_ENV_SCRIPT,
6604
- RELAY_ENV_SESSION_ID: () => RELAY_ENV_SESSION_ID,
6605
- RELAY_ENV_SOCKET: () => RELAY_ENV_SOCKET,
6606
- RELAY_EXIT_CODES: () => RELAY_EXIT_CODES,
6607
- RELAY_FRAME_DIRS: () => RELAY_FRAME_DIRS,
6608
- RELAY_FRAME_KINDS: () => RELAY_FRAME_KINDS,
6609
- RELAY_PROTOCOL_VERSION: () => RELAY_PROTOCOL_VERSION,
6610
- RELAY_REJECT_REASONS: () => RELAY_REJECT_REASONS,
6611
6612
  REVERSE_CHANNELS: () => REVERSE_CHANNELS,
6612
6613
  REVERSE_CHANNEL_TIMEOUT_CLASS: () => REVERSE_CHANNEL_TIMEOUT_CLASS,
6613
6614
  REVERSE_REQUEST_TIMEOUT_MS: () => REVERSE_REQUEST_TIMEOUT_MS,
@@ -6619,14 +6620,20 @@ __export(src_exports, {
6619
6620
  SHARED_POOL_KEY: () => SHARED_POOL_KEY,
6620
6621
  STDERR_TAIL_CHARS: () => STDERR_TAIL_CHARS,
6621
6622
  STDOUT_TAIL_ECHO_CHARS: () => STDOUT_TAIL_ECHO_CHARS,
6623
+ SUBAGENT_CONTROL_CLOSED_REASONS: () => SUBAGENT_CONTROL_CLOSED_REASONS,
6624
+ SUBAGENT_CONTROL_FRAME_KINDS: () => SUBAGENT_CONTROL_FRAME_KINDS,
6625
+ SUBAGENT_CONTROL_PROTOCOL_VERSION: () => SUBAGENT_CONTROL_PROTOCOL_VERSION,
6622
6626
  SUBAGENT_IDENTITY_ENV: () => SUBAGENT_IDENTITY_ENV,
6623
6627
  SUPPORTED_PROTOCOL_RANGE: () => SUPPORTED_PROTOCOL_RANGE,
6624
6628
  TAIJI_DATA_DIR_ENV: () => TAIJI_DATA_DIR_ENV,
6625
6629
  ZCODE_HOST_DB_SUFFIX: () => ZCODE_HOST_DB_SUFFIX,
6626
6630
  ZCODE_ISOLATED_DB_SEGMENTS: () => ZCODE_ISOLATED_DB_SEGMENTS,
6627
6631
  ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS: () => ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS,
6632
+ _EventVocabSyncLock: () => _EventVocabSyncLock,
6628
6633
  abortWithFallback: () => abortWithFallback,
6634
+ addUsage: () => addUsage,
6629
6635
  aggregateUsage: () => aggregateUsage,
6636
+ appendErrorFact: () => appendErrorFact,
6630
6637
  armEngineSelfDestruct: () => armEngineSelfDestruct,
6631
6638
  assertChatConversationSupported: () => assertChatConversationSupported,
6632
6639
  assertNotNestedSpawn: () => assertNotNestedSpawn,
@@ -6640,6 +6647,7 @@ __export(src_exports, {
6640
6647
  configureLoggerSink: () => configureLoggerSink,
6641
6648
  createReplayRecord: () => createReplayRecord,
6642
6649
  createUiChannelRegistry: () => createUiChannelRegistry,
6650
+ emptyTurn: () => emptyTurn,
6643
6651
  engineConversationUnsupportedError: () => engineConversationUnsupportedError,
6644
6652
  engineProtocolMismatchError: () => engineProtocolMismatchError,
6645
6653
  engineSetModelUnsupportedError: () => engineSetModelUnsupportedError,
@@ -6649,17 +6657,20 @@ __export(src_exports, {
6649
6657
  extractAndValidateStructuredOutput: () => extractAndValidateStructuredOutput,
6650
6658
  getLogger: () => getLogger,
6651
6659
  hostKindOf: () => hostKindOf,
6660
+ isControlEnvActive: () => isControlEnvActive,
6652
6661
  isEngineErrorPassthroughCode: () => isEngineErrorPassthroughCode,
6653
6662
  isEngineProtocolErrorCode: () => isEngineProtocolErrorCode,
6654
6663
  isNotificationFrame: () => isNotificationFrame,
6655
6664
  isPidAlive: () => isPidAlive,
6656
6665
  isProtocolVersionCompatible: () => isProtocolVersionCompatible,
6657
- isRelayActive: () => isRelayActive,
6658
6666
  isRequestFrame: () => isRequestFrame,
6659
6667
  isResponseFrame: () => isResponseFrame,
6660
6668
  isReverseRequestFrame: () => isReverseRequestFrame,
6669
+ isSubagentControlClosedReason: () => isSubagentControlClosedReason,
6670
+ isSubagentControlFrameKind: () => isSubagentControlFrameKind,
6661
6671
  isUiResponse: () => isUiResponse,
6662
6672
  killChain: () => killChain,
6673
+ killOwnProcessGroup: () => killOwnProcessGroup,
6663
6674
  killPidChain: () => killPidChain,
6664
6675
  notificationFrameSchema: () => notificationFrameSchema,
6665
6676
  parseChannel: () => parseChannel,
@@ -6668,7 +6679,6 @@ __export(src_exports, {
6668
6679
  probePidAlive: () => probePidAlive,
6669
6680
  protocolErrorSchema: () => protocolErrorSchema,
6670
6681
  pumpNdjsonLines: () => pumpNdjsonLines,
6671
- readRelayForwardEnv: () => readRelayForwardEnv,
6672
6682
  replayJournal: () => replayJournal,
6673
6683
  requestFrameSchema: () => requestFrameSchema,
6674
6684
  resetDataDirWarnForTests: () => resetDataDirWarnForTests,
@@ -6768,6 +6778,30 @@ var REVERSE_CHANNEL_TIMEOUT_CLASS = {
6768
6778
  };
6769
6779
 
6770
6780
  // src/protocol/error-codes.ts
6781
+ var ENGINE_SPAWN_DELIVERY_ERROR_CODES = [
6782
+ "engine_prompt_not_delivered",
6783
+ "engine_prompt_rejected",
6784
+ "engine_spawn_handshake_timeout"
6785
+ ];
6786
+ var ENGINE_TRANSPORT_ERROR_CODES = [
6787
+ "engine_transport_unavailable",
6788
+ "engine_transport_lost",
6789
+ "engine_open_timeout",
6790
+ "engine_frame_too_large",
6791
+ "engine_backpressure_overflow"
6792
+ ];
6793
+ var ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY = {
6794
+ 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.",
6795
+ 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.",
6796
+ 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."
6797
+ };
6798
+ var ENGINE_TRANSPORT_ERROR_RECOVERY = {
6799
+ 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.",
6800
+ 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.",
6801
+ 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.",
6802
+ 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.",
6803
+ 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."
6804
+ };
6771
6805
  var SET_MODEL_ERROR_CODES = [
6772
6806
  /** 目标模型不在当前进程快照(子进程模型快照冻结于 spawn 时刻——模型本身有效,
6773
6807
  * 下一轮 spawn 现取目录即可用;宿主按「写覆盖意图」处置,设计 §7.2 快照型失败行)。 */
@@ -6812,7 +6846,7 @@ var EngineSdkError = class extends Error {
6812
6846
  this.recovery = recovery;
6813
6847
  this.data = data;
6814
6848
  }
6815
- /** 协议 error 帧载荷投影。 */
6849
+ /** 协议 error 帧载荷派生视图。 */
6816
6850
  toStructured() {
6817
6851
  return { code: this.code, message: this.message, recovery: this.recovery, data: this.data };
6818
6852
  }
@@ -6863,12 +6897,39 @@ function schemaEmulationFailedDetail(error, tail) {
6863
6897
  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).`;
6864
6898
  }
6865
6899
 
6900
+ // src/protocol/control-protocol.ts
6901
+ var SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
6902
+ var SUBAGENT_CONTROL_FRAME_KINDS = {
6903
+ hello: "hello",
6904
+ helloOk: "hello_ok",
6905
+ helloReject: "hello_reject",
6906
+ engineOpen: "engine_open",
6907
+ engineOpened: "engine_opened",
6908
+ engineOpenFailed: "engine_open_failed",
6909
+ engineFrame: "engine_frame",
6910
+ engineClose: "engine_close",
6911
+ engineClosed: "engine_closed",
6912
+ error: "error"
6913
+ };
6914
+ function isSubagentControlFrameKind(value) {
6915
+ return typeof value === "string" && Object.values(SUBAGENT_CONTROL_FRAME_KINDS).includes(value);
6916
+ }
6917
+ var SUBAGENT_CONTROL_CLOSED_REASONS = {
6918
+ engineExit: "engine_exit",
6919
+ engineSignal: "engine_signal",
6920
+ killedByControl: "killed_by_control",
6921
+ openTimeout: "open_timeout"
6922
+ };
6923
+ function isSubagentControlClosedReason(value) {
6924
+ return typeof value === "string" && Object.values(SUBAGENT_CONTROL_CLOSED_REASONS).includes(value);
6925
+ }
6926
+
6866
6927
  // src/protocol/contract-types.ts
6867
6928
  var AGENT_EVENT_TYPE_NAMES = [
6868
6929
  "tool_start",
6869
6930
  // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 tool 起始占位(显示降级),turn 结构不受损
6870
6931
  "tool_end",
6871
- // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn 收口由 turn_end/message_end 承担
6932
+ // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn 收尾由 turn_end/message_end 承担
6872
6933
  "text_delta",
6873
6934
  // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺正文增量,不产生半解析状态
6874
6935
  "thinking_delta",
@@ -6876,16 +6937,35 @@ var AGENT_EVENT_TYPE_NAMES = [
6876
6937
  "turn_end",
6877
6938
  // noop-safe: 旧宿主 default 分支零写入——丢弃则该 turn 滞留进行态,journal 重放仍按序重建
6878
6939
  "message_end",
6879
- // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage 聚合与闭合计量,已累积内容不回滚
6940
+ // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage 聚合与结束计量,已累积内容不回滚
6880
6941
  "compaction",
6881
6942
  // noop-safe: 事件无载荷且现行 reducer 即直接 return——丢弃与处理零差异
6882
6943
  "activity",
6883
6944
  // noop-safe: 纯活性信号,双侧 reducer 恒 no-op(协议语义见 AgentEvent 头注),丢弃零差异
6884
6945
  "error",
6885
6946
  // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 lastError 诊断留痕,已写状态不回滚
6886
- "armed"
6947
+ "armed",
6887
6948
  // noop-safe: 旧宿主无武装等待窗消费点(fail-fast 属宿主新增逻辑),丢弃仅缺武装留痕,schema 强制第一道防线(引擎自查断言)不受损
6949
+ "auto_retry"
6950
+ // noop-safe: 旧宿主 default 分支零写入——丢弃仅缺重试边界留痕(journal 不可查失败尝试轨迹),轮成败判定与 turns/usage 计账不受损(P5 计账锚在引擎侧收尾快照,不依赖宿主消费本帧)
6888
6951
  ];
6952
+ var _EventVocabSyncLock = true;
6953
+ var FAILURE_CAUSE_CLOSED_KINDS = [
6954
+ "rate_limited",
6955
+ "protocol_unsupported",
6956
+ "turn_budget_exhausted",
6957
+ "timeout",
6958
+ "no_deliverable",
6959
+ "cancelled"
6960
+ ];
6961
+ var FAILURE_CAUSE_KIND_VOCAB_LOCK = true;
6962
+ var FAILURE_CAUSE_KINDS_BY_CLASS = {
6963
+ provider: ["rate_limited", "protocol_unsupported"],
6964
+ harness: ["turn_budget_exhausted", "timeout"],
6965
+ agent: ["no_deliverable"],
6966
+ user: ["cancelled"]
6967
+ };
6968
+ var FAILURE_CAUSE_KINDS_BY_CLASS_LOCK = true;
6889
6969
 
6890
6970
  // src/protocol/schema.ts
6891
6971
  var ANY_JSON = {};
@@ -6958,7 +7038,7 @@ var notificationFrameSchema = {
6958
7038
  type: {
6959
7039
  type: "string",
6960
7040
  // 事件 enum 从词表 SSOT 派生(U2 词表锁:union⟷词表互证后,此处不再
6961
- // 手写字面量集合——手写即漂移面,病灶 1 的第三处同步点)
7041
+ // 手写字面量集合——手写即漂移点,问题点 1 的第三处同步点)
6962
7042
  enum: [...AGENT_EVENT_TYPE_NAMES]
6963
7043
  }
6964
7044
  }
@@ -7422,7 +7502,8 @@ function createReplayRecord() {
7422
7502
  turns: [emptyTurn()],
7423
7503
  turnCount: 0,
7424
7504
  totalTokens: 0,
7425
- lastError: void 0
7505
+ lastError: void 0,
7506
+ errors: []
7426
7507
  };
7427
7508
  }
7428
7509
  function currentTurn(record) {
@@ -7516,7 +7597,11 @@ function applyTurnEnd(record) {
7516
7597
  turn.closed = true;
7517
7598
  turn.closedTs = Date.now();
7518
7599
  record.turnCount += 1;
7519
- record.lastError = void 0;
7600
+ }
7601
+ function appendErrorFact(record, message) {
7602
+ if (!message) return;
7603
+ (record.errors ??= []).push({ message, at: Date.now() });
7604
+ record.lastError = message;
7520
7605
  }
7521
7606
  function applyMessageEnd(record, event) {
7522
7607
  if (event.usage) {
@@ -7525,11 +7610,11 @@ function applyMessageEnd(record, event) {
7525
7610
  record.totalTokens += (event.usage.input ?? 0) + (event.usage.output ?? 0) + (event.usage.cacheRead ?? 0) + (event.usage.cacheWrite ?? 0);
7526
7611
  }
7527
7612
  if (event.error) {
7528
- record.lastError = event.error;
7613
+ appendErrorFact(record, event.error);
7529
7614
  }
7530
7615
  }
7531
7616
  function applyErrorEvent(record, event) {
7532
- record.lastError = event.message;
7617
+ appendErrorFact(record, event.message);
7533
7618
  }
7534
7619
  function updateFromEvent(record, event) {
7535
7620
  switch (event.type) {
@@ -7543,13 +7628,13 @@ function updateFromEvent(record, event) {
7543
7628
  return applyToolStart(record, event);
7544
7629
  case "tool_end":
7545
7630
  return applyToolEnd(record, event);
7546
- // ── turn_end:闭合当前 turn ──
7631
+ // ── turn_end:结束当前 turn ──
7547
7632
  case "turn_end":
7548
7633
  return applyTurnEnd(record);
7549
7634
  // ── message_end:usage 增量累加 + totalTokens 累加 ──
7550
7635
  case "message_end":
7551
7636
  return applyMessageEnd(record, event);
7552
- // ── error:存 record.lastError ──
7637
+ // ── error:appendErrorFact 入账(errors 只追加 + lastError 派生)──
7553
7638
  case "error":
7554
7639
  return applyErrorEvent(record, event);
7555
7640
  // ── compaction:不产生数据(不变)──
@@ -7559,10 +7644,16 @@ function updateFromEvent(record, event) {
7559
7644
  case "activity":
7560
7645
  return;
7561
7646
  // ── armed:武装确认回执([D3 协议版 P6],协议语义见 contract-types)——监控
7562
- // 信号不进 record 投影,消费方 = 宿主等待门 + run 事件 journal(C3 第④步
7647
+ // 信号不进 record 派生视图,消费方 = 宿主等待门 + run 事件 journal(C3 第④步
7563
7648
  // 双侧 reducer no-op 义务的 SDK 侧)
7564
7649
  case "armed":
7565
7650
  return;
7651
+ // ── auto_retry:pi 原生重试边界帧([subagent-observability §3.3.1 P5])——
7652
+ // 观测面(journal 留痕失败尝试轨迹),不进 record 派生视图:失败尝试的
7653
+ // turns/usage 切片与 retryAttempts 计数由引擎收尾快照一次产出(outcome
7654
+ // 字段承载),reducer 写入会让失败尝试静默混进 turns 聚合,恰违背 P5 计账。
7655
+ case "auto_retry":
7656
+ return;
7566
7657
  default: {
7567
7658
  const _exhaustive = event;
7568
7659
  return _exhaustive;
@@ -7782,8 +7873,6 @@ var ENGINE_ENV_DENY_LIST = [
7782
7873
  "TAIJI_AGENT_PACKAGED",
7783
7874
  "TAIJI_RUNTIME_TOKEN",
7784
7875
  "TAIJI_AGENT_API_KEY",
7785
- "TAIJI_SUBAGENT_RELAY_SESSION_ID",
7786
- "TAIJI_SUBAGENT_RELAY_RECORD_ID",
7787
7876
  // 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
7788
7877
  // 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
7789
7878
  "TAIJI_PRESET_FALLBACK_FROM",
@@ -7794,9 +7883,11 @@ var ENGINE_ENV_L0_INFRA_KEYS = [
7794
7883
  "TAIJI_AGENT_ENGINE_NODE",
7795
7884
  "ELECTRON_RUN_AS_NODE",
7796
7885
  "TAIJI_AGENT_SUBAGENT",
7797
- "TAIJI_SUBAGENT_RELAY_SOCKET",
7798
- "TAIJI_SUBAGENT_RELAY_NODE",
7799
- "TAIJI_SUBAGENT_RELAY_SCRIPT"
7886
+ // [M3] control 两键(键名 SSOT = src/control-env.ts):runtime 注入主 pi 与引擎的
7887
+ // L0 基础设施键,嵌套 task pi 经引擎出站 env 继承同值。刻意不进 ENGINE_ENV_DENY_LIST:
7888
+ // 引擎/嵌套 extension 是合法读者(transport 选择谓词 + engine_open 归属键)。
7889
+ "TAIJI_SUBAGENT_CONTROL_SOCKET",
7890
+ "TAIJI_SUBAGENT_CONTROL_ROOT_SESSION_ID"
7800
7891
  ];
7801
7892
  var ENV_PREFIX_SHAPE_RE = /^[A-Za-z0-9_]+$/;
7802
7893
  function deleteEnvKeysCaseInsensitive(env, names) {
@@ -7850,11 +7941,6 @@ function injectL0InfraKeys(env, opts) {
7850
7941
  if (opts.engineNode !== void 0) env.TAIJI_AGENT_ENGINE_NODE = opts.engineNode;
7851
7942
  if (opts.electronRunAsNode === true) env.ELECTRON_RUN_AS_NODE = "1";
7852
7943
  env.TAIJI_AGENT_SUBAGENT = "1";
7853
- if (opts.relay !== void 0) {
7854
- env.TAIJI_SUBAGENT_RELAY_SOCKET = opts.relay.socket;
7855
- env.TAIJI_SUBAGENT_RELAY_NODE = opts.relay.node;
7856
- env.TAIJI_SUBAGENT_RELAY_SCRIPT = opts.relay.script;
7857
- }
7858
7944
  if (opts.identityEnv !== void 0) {
7859
7945
  for (const [key, value] of Object.entries(opts.identityEnv)) {
7860
7946
  if (value !== void 0) env[key] = value;
@@ -7920,6 +8006,7 @@ var SUBAGENT_IDENTITY_ENV = {
7920
8006
  /** worktree 隔离标志("true" = 是)。 */
7921
8007
  worktree: "PI_SUBAGENT_WORKTREE"
7922
8008
  };
8009
+ var PI_SUBAGENT_TASK_MAX_CHARS = 2e3;
7923
8010
 
7924
8011
  // src/spawn.ts
7925
8012
  var import_node_child_process = require("child_process");
@@ -7973,13 +8060,40 @@ function resolveHostRequestTimeoutMs(opts) {
7973
8060
  }
7974
8061
  return parsed;
7975
8062
  }
7976
- function killOwnProcessGroup() {
8063
+ function killOwnProcessGroup(deps = {}) {
7977
8064
  const pid = process.pid;
8065
+ const kill = deps.killFn ?? ((targetPid, signal) => process.kill(targetPid, signal));
8066
+ if ((deps.platform ?? process.platform) === "win32") {
8067
+ const fallbackSelfKill = (reason) => {
8068
+ logger4.warn(`taskkill self-tree failed (${reason}); falling back to self SIGKILL`);
8069
+ try {
8070
+ kill(pid, "SIGKILL");
8071
+ } catch (err) {
8072
+ logger4.warn(
8073
+ `self SIGKILL fallback failed (${String(err)}); descendant pi may linger until runtime sweep`
8074
+ );
8075
+ }
8076
+ };
8077
+ const spawnFn = deps.spawnFn ?? ((command, args, options) => (0, import_node_child_process.spawn)(command, [...args], options));
8078
+ try {
8079
+ const child = spawnFn("taskkill", ["/PID", String(pid), "/T", "/F"], {
8080
+ stdio: "ignore",
8081
+ windowsHide: true
8082
+ });
8083
+ child.on("error", (err) => {
8084
+ fallbackSelfKill(String(err));
8085
+ });
8086
+ child.unref?.();
8087
+ } catch (err) {
8088
+ fallbackSelfKill(`spawn threw: ${String(err)}`);
8089
+ }
8090
+ return;
8091
+ }
7978
8092
  try {
7979
- process.kill(-pid, "SIGKILL");
8093
+ kill(-pid, "SIGKILL");
7980
8094
  } catch (err) {
7981
8095
  logger4.warn(`process-group kill failed (${String(err)}), falling back to self kill`);
7982
- process.kill(pid, "SIGKILL");
8096
+ kill(pid, "SIGKILL");
7983
8097
  }
7984
8098
  }
7985
8099
  function armEngineSelfDestruct(opts) {
@@ -8275,62 +8389,13 @@ var ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS = [
8275
8389
  "pi-synced-provider-config.json"
8276
8390
  ];
8277
8391
 
8278
- // src/relay-env.ts
8279
- var RELAY_ENV_SOCKET = "TAIJI_SUBAGENT_RELAY_SOCKET";
8280
- var RELAY_ENV_NODE = "TAIJI_SUBAGENT_RELAY_NODE";
8281
- var RELAY_ENV_SCRIPT = "TAIJI_SUBAGENT_RELAY_SCRIPT";
8282
- var RELAY_ENV_SESSION_ID = "TAIJI_SUBAGENT_RELAY_SESSION_ID";
8283
- var RELAY_ENV_RECORD_ID = "TAIJI_SUBAGENT_RELAY_RECORD_ID";
8284
- var RELAY_PROTOCOL_VERSION = 1;
8285
- var RELAY_EXIT_CODES = {
8286
- /** 握手被拒:协议版本不匹配(安装损坏,重装应用)。 */
8287
- VERSION_MISMATCH: 10,
8288
- /** relay socket 不可达(runtime 未运行或已重启)。 */
8289
- SOCKET_UNREACHABLE: 11,
8290
- /** socket 中途断开(runtime 崩溃等)——代理生命线断即退。 */
8291
- SOCKET_CLOSED: 12,
8292
- /** 归属 env(SESSION_ID/RECORD_ID)缺失——防无归属帧污染广播。 */
8293
- MISSING_IDENTITY: 13
8294
- };
8295
- function isRelayActive(env) {
8296
- return Boolean(env[RELAY_ENV_SOCKET] && env[RELAY_ENV_NODE] && env[RELAY_ENV_SCRIPT]);
8297
- }
8298
- function readRelayForwardEnv(env) {
8299
- const socket = env[RELAY_ENV_SOCKET];
8300
- const node = env[RELAY_ENV_NODE];
8301
- const script = env[RELAY_ENV_SCRIPT];
8302
- if (!isRelayActive(env)) return void 0;
8303
- return { socket, node, script };
8392
+ // src/control-env.ts
8393
+ var CONTROL_ENV_SOCKET = "TAIJI_SUBAGENT_CONTROL_SOCKET";
8394
+ var CONTROL_ENV_ROOT_SESSION_ID = "TAIJI_SUBAGENT_CONTROL_ROOT_SESSION_ID";
8395
+ function isControlEnvActive(env) {
8396
+ return Boolean(env[CONTROL_ENV_SOCKET]);
8304
8397
  }
8305
8398
 
8306
- // src/relay-frames.ts
8307
- var RELAY_FRAME_KINDS = {
8308
- handshake: "handshake",
8309
- accept: "accept",
8310
- reject: "reject",
8311
- data: "data",
8312
- exit: "exit",
8313
- /**
8314
- * goodbye(代理 → runtime,v1):代理被宿主终止(SIGTERM/SIGINT)前的预告帧——
8315
- * 宿主侧的正常收割(agent_settled 后杀代理)与异常断连(宿主崩溃/主 pi 死)在
8316
- * runtime 侧都表现为 socket close,无法区分;goodbye 让正常收割显式自报,runtime
8317
- * 据此把后续 close 的日志从 warn(kill-on-disconnect)降级为 info(reaped,正常
8318
- * teardown)。kill 行为本身不变(预告后 child 仍由 runtime 收割)。
8319
- */
8320
- goodbye: "goodbye"
8321
- };
8322
- var RELAY_FRAME_DIRS = {
8323
- down: "down",
8324
- up: "up",
8325
- upStderr: "up-stderr"
8326
- };
8327
- var RELAY_REJECT_REASONS = {
8328
- version: "version",
8329
- identity: "identity",
8330
- duplicate: "duplicate",
8331
- malformed: "malformed"
8332
- };
8333
-
8334
8399
  // src/best-effort.ts
8335
8400
  var logger5 = getLogger("subagents");
8336
8401
  function bestEffort(err, context, level = "debug") {
@@ -8430,6 +8495,8 @@ function runEngineCliEntry(opts) {
8430
8495
  0 && (module.exports = {
8431
8496
  AGENT_EVENT_TYPE_NAMES,
8432
8497
  CANCEL_SETTLE_GRACE_MS,
8498
+ CONTROL_ENV_ROOT_SESSION_ID,
8499
+ CONTROL_ENV_SOCKET,
8433
8500
  DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS,
8434
8501
  DEFAULT_KILL_GRACE_MS,
8435
8502
  DEFAULT_NATIVE_INTERRUPT_GRACE_MS,
@@ -8445,25 +8512,24 @@ function runEngineCliEntry(opts) {
8445
8512
  ENGINE_PROTOCOL_ERROR_CODES,
8446
8513
  ENGINE_PROTOCOL_SCHEMAS,
8447
8514
  ENGINE_PROTOCOL_VERSION,
8515
+ ENGINE_SPAWN_DELIVERY_ERROR_CODES,
8516
+ ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
8448
8517
  ENGINE_TIMEOUT_RECOVERY,
8518
+ ENGINE_TRANSPORT_ERROR_CODES,
8519
+ ENGINE_TRANSPORT_ERROR_RECOVERY,
8449
8520
  EngineSdkError,
8450
8521
  ExecutionNestingContext,
8522
+ FAILURE_CAUSE_CLOSED_KINDS,
8523
+ FAILURE_CAUSE_KINDS_BY_CLASS,
8524
+ FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
8525
+ FAILURE_CAUSE_KIND_VOCAB_LOCK,
8451
8526
  FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
8452
8527
  HANDSHAKE_TIMEOUT_MS,
8453
8528
  HOST_TIMEOUT_ABORT_REASON,
8454
8529
  NESTED_SPAWN_ENV,
8455
8530
  NestedSpawnRejectedError,
8531
+ PI_SUBAGENT_TASK_MAX_CHARS,
8456
8532
  PROTOCOL_METHODS,
8457
- RELAY_ENV_NODE,
8458
- RELAY_ENV_RECORD_ID,
8459
- RELAY_ENV_SCRIPT,
8460
- RELAY_ENV_SESSION_ID,
8461
- RELAY_ENV_SOCKET,
8462
- RELAY_EXIT_CODES,
8463
- RELAY_FRAME_DIRS,
8464
- RELAY_FRAME_KINDS,
8465
- RELAY_PROTOCOL_VERSION,
8466
- RELAY_REJECT_REASONS,
8467
8533
  REVERSE_CHANNELS,
8468
8534
  REVERSE_CHANNEL_TIMEOUT_CLASS,
8469
8535
  REVERSE_REQUEST_TIMEOUT_MS,
@@ -8475,14 +8541,20 @@ function runEngineCliEntry(opts) {
8475
8541
  SHARED_POOL_KEY,
8476
8542
  STDERR_TAIL_CHARS,
8477
8543
  STDOUT_TAIL_ECHO_CHARS,
8544
+ SUBAGENT_CONTROL_CLOSED_REASONS,
8545
+ SUBAGENT_CONTROL_FRAME_KINDS,
8546
+ SUBAGENT_CONTROL_PROTOCOL_VERSION,
8478
8547
  SUBAGENT_IDENTITY_ENV,
8479
8548
  SUPPORTED_PROTOCOL_RANGE,
8480
8549
  TAIJI_DATA_DIR_ENV,
8481
8550
  ZCODE_HOST_DB_SUFFIX,
8482
8551
  ZCODE_ISOLATED_DB_SEGMENTS,
8483
8552
  ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS,
8553
+ _EventVocabSyncLock,
8484
8554
  abortWithFallback,
8555
+ addUsage,
8485
8556
  aggregateUsage,
8557
+ appendErrorFact,
8486
8558
  armEngineSelfDestruct,
8487
8559
  assertChatConversationSupported,
8488
8560
  assertNotNestedSpawn,
@@ -8496,6 +8568,7 @@ function runEngineCliEntry(opts) {
8496
8568
  configureLoggerSink,
8497
8569
  createReplayRecord,
8498
8570
  createUiChannelRegistry,
8571
+ emptyTurn,
8499
8572
  engineConversationUnsupportedError,
8500
8573
  engineProtocolMismatchError,
8501
8574
  engineSetModelUnsupportedError,
@@ -8505,17 +8578,20 @@ function runEngineCliEntry(opts) {
8505
8578
  extractAndValidateStructuredOutput,
8506
8579
  getLogger,
8507
8580
  hostKindOf,
8581
+ isControlEnvActive,
8508
8582
  isEngineErrorPassthroughCode,
8509
8583
  isEngineProtocolErrorCode,
8510
8584
  isNotificationFrame,
8511
8585
  isPidAlive,
8512
8586
  isProtocolVersionCompatible,
8513
- isRelayActive,
8514
8587
  isRequestFrame,
8515
8588
  isResponseFrame,
8516
8589
  isReverseRequestFrame,
8590
+ isSubagentControlClosedReason,
8591
+ isSubagentControlFrameKind,
8517
8592
  isUiResponse,
8518
8593
  killChain,
8594
+ killOwnProcessGroup,
8519
8595
  killPidChain,
8520
8596
  notificationFrameSchema,
8521
8597
  parseChannel,
@@ -8524,7 +8600,6 @@ function runEngineCliEntry(opts) {
8524
8600
  probePidAlive,
8525
8601
  protocolErrorSchema,
8526
8602
  pumpNdjsonLines,
8527
- readRelayForwardEnv,
8528
8603
  replayJournal,
8529
8604
  requestFrameSchema,
8530
8605
  resetDataDirWarnForTests,