@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
@@ -17,7 +17,7 @@ interface AgentUsage {
17
17
  cost?: number;
18
18
  }
19
19
  interface AgentUsageTotal extends AgentUsage {
20
- /** 四项之和。投影时不再手工求和。 */
20
+ /** 四项之和。派生时不再手工求和。 */
21
21
  total: number;
22
22
  /** 累计成本(USD)。无成本数据时为 0。 */
23
23
  cost: number;
@@ -50,14 +50,14 @@ interface Turn {
50
50
  toolCalls: InternalToolCall[];
51
51
  /** 本 turn message_end 的 token 增量(聚合得 usage 总量)。 */
52
52
  usageDelta?: AgentUsage;
53
- /** turn_end 是否已到达。false=正在进行;true=已闭合。 */
53
+ /** turn_end 是否已到达。false=正在进行;true=已结束。 */
54
54
  closed: boolean;
55
55
  /** turn_end 到达时的墙钟时间戳(Date.now(),ms)。 */
56
56
  closedTs?: number;
57
57
  }
58
58
  /**
59
59
  * 引擎事件(10 种,协议 event.params.event 逐字序列化——「事件与 handle 序列化逐字
60
- * 兼容」不变量 3 的类型面)。语义锚点 = pi(ACP 词汇对照见 core execution/assembly/types.ts 注释)。
60
+ * 兼容」不变量 3 的类型范围)。语义锚点 = pi(ACP 词汇对照见 core execution/assembly/types.ts 注释)。
61
61
  *
62
62
  * activity = 纯活性信号:双侧 reducer no-op、不开 turn、不写状态、不落 journal
63
63
  * (core event-journal-wiring 对其豁免 append),只承诺「引擎活跃时周期性出现」——供宿主
@@ -106,6 +106,20 @@ type AgentEvent = {
106
106
  type: EventName<"armed">;
107
107
  schemaEnvVar: string;
108
108
  extensionPkg: string;
109
+ } | {
110
+ type: EventName<"auto_retry">;
111
+ /** start = 失败尝试结束即将重跑;end = 重试波次收束(成功或最终失败)。 */
112
+ phase: "start" | "end";
113
+ /** 重试波次序号(pi 原生 _retryAttempt,1 起)。 */
114
+ attempt: number;
115
+ /** start 独有:重试上限与退避等待(pi _prepareRetry 发射事实)。 */
116
+ maxAttempts?: number;
117
+ delayMs?: number;
118
+ /** start 携带被重试的错误文本;end 失败波携带最终错误(成功波缺省)。 */
119
+ errorMessage?: string;
120
+ /** end 独有:该波重试最终是否恢复(true = 后续尝试成功,false = 重试耗尽)。 */
121
+ success?: boolean;
122
+ finalError?: string;
109
123
  };
110
124
  /**
111
125
  * 事件类型词表(协议事件全集 10 种,运行时 SSOT):schema 事件 `type.enum` 从本表
@@ -115,7 +129,7 @@ type AgentEvent = {
115
129
  * 每个成员必须带一行 `// noop-safe: <论证>`:未知成员宽容语义四行①(ADR-0071)的
116
130
  * 逐变体登记——旧宿主 reducer 遇未知 event.type 走 default 分支零写入,标记后写
117
131
  * 「本变体被丢弃时状态无损」的一行论证(no-op 安全性属运行时消费语义,不可静态
118
- * 判定——守卫只查标记存在不查内容,落点 contract-closure.test.ts「noop-safe 标记守卫」)。
132
+ * 判定——检查只查标记存在不查内容,落点 contract-closure.test.ts「noop-safe 标记检查」)。
119
133
  *
120
134
  * 编译锁(漏改任一侧 typecheck 红,且错误指向漏点):
121
135
  * ① union 侧——成员 type 必须经 `EventName<"x">` 取名(约束 = 本词表):union 加
@@ -123,13 +137,13 @@ type AgentEvent = {
123
137
  * ② 词表侧——`satisfies readonly AgentEvent["type"][]`:词表加成员不加 union
124
138
  * → 错误直接落在词表漏改的成员行;
125
139
  * ③ 兜底——成员绕过 EventName 约束裸加字面量 → _EventVocabSyncLock 爆红。
126
- * 新增事件变体的同步面分两层,漏改任一处 typecheck 均红且精确指路(验收 A1 演练
127
- * 实证):协议面两笔(词表 + union)即协议面全同步——schema enum 与遍历型测试断言
128
- * 自动跟随;同仓消费面另有两处编译期同步点——journal-replay reducer case(穷尽
140
+ * 新增事件变体的同步点分两层,漏改任一处 typecheck 均红且精确指路(验收 A1 演练
141
+ * 实证):协议范围两笔(词表 + union)即协议范围全同步——schema enum 与遍历型测试断言
142
+ * 自动跟随;同仓消费方另有两处编译期同步点——journal-replay reducer case(穷尽
129
143
  * switch never 检查)与 contract-closure 构造冒烟(Record<AgentEventTypeName,…>
130
144
  * 漏键爆红)。不 bump 版本、不改任何引擎(演进政策 additive 面,判据全文见头注)。
131
145
  */
132
- declare const AGENT_EVENT_TYPE_NAMES: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
146
+ declare const AGENT_EVENT_TYPE_NAMES: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed", "auto_retry"];
133
147
  /** 词表派生的事件名联合(编译锁②/③的词表侧源;schema enum 与测试取值同源)。 */
134
148
  type AgentEventTypeName = (typeof AGENT_EVENT_TYPE_NAMES)[number];
135
149
  /**
@@ -138,6 +152,7 @@ type AgentEventTypeName = (typeof AGENT_EVENT_TYPE_NAMES)[number];
138
152
  * 结构与运行时语义零变化。
139
153
  */
140
154
  type EventName<T extends AgentEventTypeName> = T;
155
+ declare const _EventVocabSyncLock: AssertMutuallyAssignable<AgentEvent["type"], AgentEventTypeName>;
141
156
  /**
142
157
  * EngineHandle 的持久化形态(JSON v1)。协议 run 终态应答 / read 的
143
158
  * handle 载荷(引擎不持有宿主运行时引用,data 即全部)。
@@ -160,7 +175,7 @@ interface EngineHandleData {
160
175
  adapterVersion: string;
161
176
  }
162
177
  /**
163
- * [v1.x] 冷续 resume 锚点——EngineHandleData 定位键的投影子集(诊断字段
178
+ * [v1.x] 冷续 resume 锚点——EngineHandleData 定位键的派生子集(诊断字段
164
179
  * v/engineVersion/adapterVersion 不属锚点语义,不随锚点走)。消费点:
165
180
  * - run.params.resume(宿主 → 引擎:冷续重开已 idle 的 session,pi 消费
166
181
  * sessionRef.sessionFile —— 对照 core SpawnResumeOpts.sessionFile 的锚点面)。
@@ -199,7 +214,7 @@ interface SessionView {
199
214
  * 用户覆盖记账共用的模型指向形状(设计 subagent-model-switch §6.2/§7.3)。
200
215
  *
201
216
  * 刻意用结构化对象而非现役 wire 的字符串 canonical ref(`ctx.model` = "provider/id"):
202
- * 切换操作的原生输入面就是「provider 选了哪个模型」两个独立选择(前端模型选择器 /
217
+ * 切换操作的原生输入范围就是「provider 选了哪个模型」两个独立选择(前端模型选择器 /
203
218
  * runtime `model.switch` 均平铺 provider/modelId),字符串拼接形态会在协议两侧各做一次
204
219
  * 拆/拼(拆分规则 = provider 含 '/' 时无法无歧义反转),结构化形状让拆装只发生在宿主
205
220
  * 编排层单点(U2 组帧时拼 canonical ref、读回执时拆 ref)。
@@ -230,7 +245,7 @@ type EngineProcessModel = "per-window" | "shared-service";
230
245
  * 引擎能力声明(11 必填位 + 1 可选位 setModel)。三级:native / emulated / unsupported。
231
246
  * 声明的是本仓 subagent 链路实际接通的能力,不是引擎 RPC 层的理论能力。
232
247
  * 同步权威 = manifest(注册期直读);握手应答仅诊断(§3.3「同步成员清单」)。
233
- * 进程形态声明是独立字段(上方 EngineProcessModel——manifest 契约面,不在本
248
+ * 进程形态声明是独立字段(上方 EngineProcessModel——manifest 契约范围,不在本
234
249
  * 接口内),两套字段服务不同裁决(任务能力 vs 宿主实例管理)。
235
250
  */
236
251
  interface EngineCapabilities {
@@ -242,7 +257,7 @@ interface EngineCapabilities {
242
257
  * [H1 D5 语义收窄 + modeless] 「怎么续」形态轴兼 message 资格轴:
243
258
  * 位非 'unsupported' = 引擎可续聊(core capability-gate 的 message 资格门消费),
244
259
  * 值区分续聊形态——native(原地续写)/ cold(冷恢复重建 + 新 run + resume 锚点)。
245
- * 原名字沿用——conversation 位保留、语义从「interact 长驻控制面」收窄为
260
+ * 原名字沿用——conversation 位保留、语义从「interact 长驻控制范围」收窄为
246
261
  * 「resume 续聊能力」。[modeless 波2] 会话形态键只剩 run.params.resume(协议
247
262
  * task.conversation 已删),本轴不再是 per-run 模式开关——描述各引擎的真实
248
263
  * 续聊差异(gate 判据仍是 `=== "unsupported"` 拒绝,"cold" 与 "native" 等价
@@ -298,7 +313,139 @@ interface ProbeReport {
298
313
  recovery: string;
299
314
  };
300
315
  }
301
- /** 失败分诊结构化标签。unknown(含缺省)= 可重试(语义守恒)。 */
316
+ /**
317
+ * [subagent-observability §3.3.2] 失败分类权威契约(五维正交,原位替换
318
+ * AgentFailureKind 三值词表——本文件是引擎协议词表家址)。
319
+ *
320
+ * 由收尾边沿(判定链)一次产出并写入轮收条,下游只读不可替换(三硬规则①②——
321
+ * 只有知道事实的层能填 class;写入后观察性事实降级 observations,不改写 cause)。
322
+ * 跨进程 wire 载体 = shared `SubagentRecord.lastRound.failure`(type-only re-export,
323
+ * 判别联合逐字序列化)。消费锚:轮应答恢复指引(§3.3.7)、run 终局 failedMembers[].cause
324
+ * (§3.3.8——序列化为 `"<class>.<kind>"` 点拼字符串,retryable/retryAfterMs 不进终局
325
+ * 事件、由成员轮收条承载)。
326
+ *
327
+ * cause 优先级(分类边沿裁决序,严格递减):provider 事实 > harness 预算/契约 >
328
+ * agent 行为 > engine 崩溃 > unknown(未分类形态不产 FailureCause,落引擎停因原值)。
329
+ */
330
+ type FailureCauseClass = "provider" | "harness" | "agent" | "engine" | "user";
331
+ /**
332
+ * retryable 三态(§3.3.2 硬规则③,与重试规则 extension 的 verdict 同词表):
333
+ * true = 等待后重发可恢复;
334
+ * false = 重发必然同样失败;
335
+ * "conditional" = 条件恢复——等限额重置窗口或人/账户先动作(执行层对 conditional
336
+ * 不自动重试,呈现层如实展示)。
337
+ */
338
+ type FailureRetryability = true | false | "conditional";
339
+ /**
340
+ * FailureCause 公共字段面(class×kind 判别联合各成员共享)。
341
+ * retryable — 三态({@link FailureRetryability});429 不全可重试,禁止仅按
342
+ * HTTP 状态码判可重试(provider 业务码层裁决,§3.3.2 码表硬约束);
343
+ * retryAfterMs — 恢复等待毫秒(错误文本内重置时间字样提取——pi 消息模型不暴露
344
+ * HTTP 头,头通道结构性不可得,设计 §3.3.2 单文本通道),
345
+ * 皆无 → 缺省 unknown(undefined,不产假 0);
346
+ * raw — 分类输入的原始错误文本(取证链:分类不丢原文)。
347
+ */
348
+ interface FailureCauseFields {
349
+ retryable: FailureRetryability;
350
+ retryAfterMs?: number;
351
+ raw: string;
352
+ }
353
+ /**
354
+ * class×kind 合法组合矩阵(判别联合构造性成立——非法组合写不出来):
355
+ * provider.rate_limited / provider.protocol_unsupported / harness.turn_budget_exhausted /
356
+ * harness.timeout / agent.no_deliverable / user.cancelled / engine.*(`engine_${string}`
357
+ * 引擎自报透传族,开放前缀面——对齐 RunErrorCode 的 engine_ 透传契约,core 不解释文案)。
358
+ *
359
+ * kind 是封闭登记词表:新增成员同 commit 登记下方 {@link FAILURE_CAUSE_CLOSED_KINDS}
360
+ * (解析词表纪律),漏登记由 {@link FAILURE_CAUSE_KIND_VOCAB_LOCK} 编译锁拦截。
361
+ */
362
+ type FailureCause = (FailureCauseFields & {
363
+ class: "provider";
364
+ kind: "rate_limited" | "protocol_unsupported";
365
+ }) | (FailureCauseFields & {
366
+ class: "harness";
367
+ kind: "turn_budget_exhausted" | "timeout";
368
+ /**
369
+ * [subagent-observability §3.3.9/UC-10] turn 预算耗尽事实(limiter abort 边沿
370
+ * 一次产出):used = abort 时轮数、limit = 显式 maxTurns 上界。undefined =
371
+ * 极端竞窗下收尾边沿只有 aborted 停因而 limiter 快照缺席(防御性同判形态,
372
+ * 事实不足不产结构——轮失败事实不受影响)。与 §3.3.6 查询侧 budget 分轴
373
+ * 结构({maxTurns, ...})同构的 {used, limit} 形态。仅 turn_budget_exhausted
374
+ * 承载;timeout(§3.3.6 超时轮失败分类,宿主结算点产出——timeoutMs 墙钟预算
375
+ * 耗尽是宿主独有事实,引擎收尾边沿只有「宿主取消 vs 引擎异常」两源判别)
376
+ * 不落本字段。
377
+ */
378
+ budget?: {
379
+ used: number;
380
+ limit: number;
381
+ };
382
+ }) | (FailureCauseFields & {
383
+ class: "agent";
384
+ kind: "no_deliverable";
385
+ }) | (FailureCauseFields & {
386
+ class: "user";
387
+ kind: "cancelled";
388
+ }) | (FailureCauseFields & {
389
+ class: "engine";
390
+ kind: `engine_${string}`;
391
+ });
392
+ /**
393
+ * FailureCause.kind 闭合成员词表(运行时枚举完整性测试锚;engine 透传族
394
+ * `engine_${string}` 开放前缀面不进闭合表——逐成员断言见 failure-cause-vocabulary.test.ts)。
395
+ * 新增 kind 成员 = 联合与本元组同 commit 同批(编译锁双向拦截漏改)。
396
+ */
397
+ declare const FAILURE_CAUSE_CLOSED_KINDS: readonly ["rate_limited", "protocol_unsupported", "turn_budget_exhausted", "timeout", "no_deliverable", "cancelled"];
398
+ /**
399
+ * 词表编译锁(双向):kind 联合闭合面 ⊆ 且 ⊇ FAILURE_CAUSE_CLOSED_KINDS。
400
+ * 联合扩值漏登元组(或元组多配联合外值)→ 本赋值 tsc 红,错误指向漏改侧。
401
+ */
402
+ declare const FAILURE_CAUSE_KIND_VOCAB_LOCK: AssertMutuallyAssignable<Exclude<FailureCause["kind"], `engine_${string}`>, (typeof FAILURE_CAUSE_CLOSED_KINDS)[number]>;
403
+ /**
404
+ * per-class kind 合法值域(运行时可用——重试规则条目的 kind 字段按 class 校验的
405
+ * 唯一依据;消费方 = shared validateRetryRuleFields / retry-rules extension 侧镜像)。
406
+ * engine 透传族是 `engine_${string}` 开放前缀面(无闭合枚举),不进本表——engine 规则
407
+ * 的 kind 校验走前缀形态判定,由各消费方按 {@link FailureCause} 的 `engine_${string}`
408
+ * 契约自行落地。
409
+ *
410
+ * 词表编译锁:每个 class 的成员元组与 {@link FailureCause} 判别联合的对应 kind 联合
411
+ * 双向可赋值——判别联合扩值漏登本表(或本表多配联合外值)→ 对应行 tsc 红。
412
+ */
413
+ declare const FAILURE_CAUSE_KINDS_BY_CLASS: {
414
+ readonly provider: readonly ["rate_limited", "protocol_unsupported"];
415
+ readonly harness: readonly ["turn_budget_exhausted", "timeout"];
416
+ readonly agent: readonly ["no_deliverable"];
417
+ readonly user: readonly ["cancelled"];
418
+ };
419
+ /**
420
+ * per-class 词表编译锁(双向):本表各 class 成员元组 ↔ 判别联合对应 kind 联合。
421
+ * 任一 class 漏登/多配 → 本赋值 tsc 红,错误指向漏改侧。
422
+ */
423
+ declare const FAILURE_CAUSE_KINDS_BY_CLASS_LOCK: AssertMutuallyAssignable<{
424
+ provider: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["provider"][number];
425
+ harness: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["harness"][number];
426
+ agent: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["agent"][number];
427
+ user: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["user"][number];
428
+ }, {
429
+ provider: Extract<FailureCause, {
430
+ class: "provider";
431
+ }>["kind"];
432
+ harness: Extract<FailureCause, {
433
+ class: "harness";
434
+ }>["kind"];
435
+ agent: Extract<FailureCause, {
436
+ class: "agent";
437
+ }>["kind"];
438
+ user: Extract<FailureCause, {
439
+ class: "user";
440
+ }>["kind"];
441
+ }>;
442
+ /**
443
+ * @deprecated [subagent-observability §3.3.2,ADR-0158 终态] 三值分诊词表已由
444
+ * {@link FailureCause} 取代(class×kind 封闭矩阵 + retryable 三态)。本类型保留为
445
+ * 历史解析兼容、不删——旧 record 帧与历史 journal 的 failureKind 解析仍依赖该
446
+ * 通道(设计 §3.4「历史解析兼容保留项」);新写入方失败分类一律产 FailureCause,
447
+ * 产出侧分类器 classifyFailureKind 已退役。
448
+ */
302
449
  type AgentFailureKind = "stale_context" | "schema_deterministic" | "unknown";
303
450
  /**
304
451
  * AgentOutcome.usage 字段型(← core orchestration/models/types.ts AgentUsage 结构等价;
@@ -333,10 +480,28 @@ interface WorktreeHandle {
333
480
  * 一次引擎执行的终态(协议 run 终态应答的 outcome 载荷)。锚定 core
334
481
  * orchestration AgentResult 并追加引擎层字段(engineId / exitCode)。
335
482
  */
483
+ /** [subagent-observability §3.3.3] 轮终停因引擎原值三态(引擎收尾边沿事实;宿主
484
+ * ROUND_TERMINAL_STOP_REASONS 词表的协议侧同源镜像)。 */
485
+ type EngineStopReason = "stop" | "error" | "aborted";
336
486
  interface AgentOutcome {
337
487
  content: string;
338
- /** 失败分诊标签。产出侧 = 引擎;缺省 = unknown = 可重试。 */
488
+ /**
489
+ * 失败分诊标签(历史解析兼容残留)。
490
+ * @deprecated [subagent-observability §3.4,ADR-0158] 新写入方失败分类一律产
491
+ * {@link FailureCause}(下方 failure 字段);本字段随 {@link AgentFailureKind} 保留为
492
+ * 旧 record 帧与历史 journal 的解析兼容。产出侧残留仅引擎送达错误码前缀确定性分诊
493
+ * (pi 引擎 output-collector,[D5-③ 改轨]);缺省 = undefined(字段缺位),
494
+ * 不承载重试判定(重试判定在 FailureCause.retryable 三态)。
495
+ */
339
496
  failureKind?: AgentFailureKind;
497
+ /**
498
+ * [subagent-observability §3.3.8] 失败分类(收尾边沿一次产出——CollectedOutcome.failure
499
+ * 经引擎适配层 toOutcome 透传上协议)。run 终局成员交付结算消费本字段点拼
500
+ * `"<class>.<kind>"` 进 failedMembers[].cause;缺省 = 未分类(cause 回落
501
+ * error 前缀协议码 / "unknown")。可选 = 读取面对旧格式应答放行(字段落地前
502
+ * 的引擎缺省,写侧契约由引擎适配层承担)。
503
+ */
504
+ failure?: FailureCause;
340
505
  /** native 引擎直传 / 仿真层 ajv 产出(D4 硬分流:native 路径宿主不做二次校验)。 */
341
506
  parsedOutput?: unknown;
342
507
  usage?: AgentOutcomeUsage;
@@ -354,7 +519,7 @@ interface AgentOutcome {
354
519
  /** null = 被信号杀死(杀链/abort 合成终态的判据)。 */
355
520
  exitCode?: number | null;
356
521
  /**
357
- * [D5 诊断引用落账] 失败时子进程 stderr tee 文件绝对路径(引擎侧 W11 已有落盘)。
522
+ * [D5 诊断引用写入记录] 失败时子进程 stderr tee 文件绝对路径(引擎侧 W11 已有落盘)。
358
523
  *
359
524
  * 通道裁决(协议演进宪法 ADR-0071 判据链,2026-09-22 一致性审查 P1 修复登记):stderr
360
525
  * tee 路径是引擎产生的诊断事实,宿主不可靠推导(文件名格式/dataDir 解析/轮转
@@ -372,10 +537,42 @@ interface AgentOutcome {
372
537
  * 仅诊断引用——文件受引擎侧尺寸轮转与过期清理管辖,读侧不得假设其永存。
373
538
  */
374
539
  stderrTeePath?: string;
540
+ /**
541
+ * [subagent-observability §3.3.3] 轮终停因引擎原值(收尾边沿事实一次产出,值域
542
+ * 三态与宿主 ROUND_TERMINAL_STOP_REASONS 同源)。宿主 one-shot 轮收条
543
+ * rec.lastRound.engineStopReason 的数据源——「正常收尾」派生判据(stop 且无失败
544
+ * 分类 = completed)依赖本事实。additive 可选(宪法判据③同 stderrTeePath 先例):
545
+ * 旧引擎缺省 = 宿主回落派生展示词,零行为差。
546
+ */
547
+ engineStopReason?: EngineStopReason;
548
+ /**
549
+ * [subagent-observability §3.3.3 P5] 本 run 内 pi 原生重试的失败尝试计数
550
+ * (auto_retry_start 帧数;引擎 >0 时上报)。宿主轮收条 lastRound.retryAttempts
551
+ * 的数据源——重试轨迹可观测(失败尝试不静默计入 turns/usage)。additive 可选:
552
+ * 旧引擎/无重试缺省不落键。
553
+ */
554
+ retryAttempts?: number;
555
+ /**
556
+ * [subagent-observability §3.3.1/§3.3.3] 本轮被人类接管收尾的标注(引擎判定链
557
+ * prompt-ack 命中 handled 时产出,值恒 "handled")。宿主轮收条
558
+ * lastRound.promptDisposition 的数据源——被接管轮不产失败分类、结清走 no_result、
559
+ * 通知走接管分支、run 聚合按未交付非失败计。additive 可选(宪法判据③同
560
+ * engineStopReason 先例):旧引擎缺省 = 无接管标注,零行为差。
561
+ */
562
+ promptDisposition?: "handled";
563
+ /**
564
+ * [subagent-observability §3.3.2/§3.3.10] 观察性事实数组(引擎产出侧摘要,如
565
+ * 「结构化输出未调用」)。宿主轮收条 lastRound.observations 的
566
+ * 数据源——查询出口 list lastRound.observations 直读。additive 可选:旧引擎
567
+ * 缺省不落键。注意承载分源:交付谓词缺项(deliverables 未满足)在 worker 脚本
568
+ * 侧执行,不经本字段——落脚本结果 observations / run 终局帧 partialMembers /
569
+ * workflow_control 成员行 missingDeliverables 三面(§3.3.10 分源表述)。
570
+ */
571
+ observations?: string[];
375
572
  }
376
573
  /**
377
574
  * 引擎模型目录条目(manifest `modelCatalog.models` 条目形态,设计 §3.4 示例)。
378
- * 协议面 = initialize 应答 models? 与 listModels 应答 models 的元素型;
575
+ * 协议范围 = initialize 应答 models? 与 listModels 应答 models 的元素型;
379
576
  * manifest 解析与生成(gen:model-catalog)归 W4/W5 实装。
380
577
  */
381
578
  interface ModelCatalogEntry {
@@ -384,15 +581,15 @@ interface ModelCatalogEntry {
384
581
  canonicalRef?: string;
385
582
  }
386
583
  /**
387
- * 单次 agent 调用的任务声明——引擎面子集(协议 run.params.task;core 全量
388
- * AgentCallOpts 22 字段留 core,core 侧反向 re-export 保消费面)。
584
+ * 单次 agent 调用的任务声明——引擎侧子集(协议 run.params.task;core 全量
585
+ * AgentCallOpts 22 字段留 core,core 侧反向 re-export 保消费方)。
389
586
  *
390
587
  * 字段归属判据(协议演进宪法 ADR-0071 成文,权威源
391
588
  * docs/architecture/subagent-engine-protocolization.md §3.3「协议演进宪法」与
392
589
  * docs/adr/decisions.md ADR-0071;
393
- * 本注释是判据与存量结论的投影,新增字段按决策树依序裁决后在此登记):
590
+ * 本注释是判据与存量结论的派生整理,新增字段按决策树依序裁决后在此登记):
394
591
  * ① 引擎不消费它任务能否正确完成?能 → 宿主自持不上协议(「正确」含满足字段
395
- * 声明携带的约束面——轮次预算/超时等约束被引擎忽略即任务语义受损,视为消费);
592
+ * 声明携带的约束侧——轮次预算/超时等约束被引擎忽略即任务语义受损,视为消费);
396
593
  * ② 描述「任务是什么」(what) 还是「在什么环境跑/怎么跑」(where/how)?
397
594
  * what → task(预算/验收类约束 = 任务自带语义归 task,宿主偏好参数走③);
398
595
  * ③ 引擎能否自行推导该环境值且与宿主恒等?能 → 不上协议(推导权归引擎,设计期
@@ -464,4 +661,4 @@ interface AgentCallOpts {
464
661
  permissionMode?: string;
465
662
  }
466
663
 
467
- export { type AgentEvent as A, type EngineHandleData as E, type InternalToolCall as I, type ModelRef as M, type ProbeReport as P, type ReplayedTurn as R, type SessionView as S, type Turn as T, type WorktreeHandle as W, type AgentUsageTotal as a, type AgentCallOpts as b, type AgentOutcome as c, type EngineCapabilities as d, type ResumeAnchor as e, type ModelCatalogEntry as f, AGENT_EVENT_TYPE_NAMES as g, type AgentEventTypeName as h, type AgentFailureKind as i, type AgentOutcomeUsage as j, type AgentUsage as k, type AssertMutuallyAssignable as l, type EngineProcessModel as m, type ToolCall as n, type ToolCallEntry as o, type ToolCallResult as p };
664
+ export { type AgentEvent as A, type EngineHandleData as E, FAILURE_CAUSE_CLOSED_KINDS as F, type InternalToolCall as I, type ModelRef as M, type ProbeReport as P, type ReplayedTurn as R, type SessionView as S, type Turn as T, type WorktreeHandle as W, _EventVocabSyncLock as _, type AgentUsage as a, type AgentUsageTotal as b, type AgentCallOpts as c, type AgentOutcome as d, type EngineCapabilities as e, type ResumeAnchor as f, type ModelCatalogEntry as g, AGENT_EVENT_TYPE_NAMES as h, type AgentEventTypeName as i, type AgentFailureKind as j, type AgentOutcomeUsage as k, type AssertMutuallyAssignable as l, type EngineProcessModel as m, type EngineStopReason as n, FAILURE_CAUSE_KINDS_BY_CLASS as o, FAILURE_CAUSE_KINDS_BY_CLASS_LOCK as p, FAILURE_CAUSE_KIND_VOCAB_LOCK as q, type FailureCause as r, type FailureCauseClass as s, type FailureRetryability as t, type ToolCall as u, type ToolCallEntry as v, type ToolCallResult as w };
package/dist/env.cjs CHANGED
@@ -94,8 +94,6 @@ var ENGINE_ENV_DENY_LIST = [
94
94
  "TAIJI_AGENT_PACKAGED",
95
95
  "TAIJI_RUNTIME_TOKEN",
96
96
  "TAIJI_AGENT_API_KEY",
97
- "TAIJI_SUBAGENT_RELAY_SESSION_ID",
98
- "TAIJI_SUBAGENT_RELAY_RECORD_ID",
99
97
  // 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
100
98
  // 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
101
99
  "TAIJI_PRESET_FALLBACK_FROM",
@@ -106,9 +104,11 @@ var ENGINE_ENV_L0_INFRA_KEYS = [
106
104
  "TAIJI_AGENT_ENGINE_NODE",
107
105
  "ELECTRON_RUN_AS_NODE",
108
106
  "TAIJI_AGENT_SUBAGENT",
109
- "TAIJI_SUBAGENT_RELAY_SOCKET",
110
- "TAIJI_SUBAGENT_RELAY_NODE",
111
- "TAIJI_SUBAGENT_RELAY_SCRIPT"
107
+ // [M3] control 两键(键名 SSOT = src/control-env.ts):runtime 注入主 pi 与引擎的
108
+ // L0 基础设施键,嵌套 task pi 经引擎出站 env 继承同值。刻意不进 ENGINE_ENV_DENY_LIST:
109
+ // 引擎/嵌套 extension 是合法读者(transport 选择谓词 + engine_open 归属键)。
110
+ "TAIJI_SUBAGENT_CONTROL_SOCKET",
111
+ "TAIJI_SUBAGENT_CONTROL_ROOT_SESSION_ID"
112
112
  ];
113
113
  var ENV_PREFIX_SHAPE_RE = /^[A-Za-z0-9_]+$/;
114
114
  function deleteEnvKeysCaseInsensitive(env, names) {
@@ -162,11 +162,6 @@ function injectL0InfraKeys(env, opts) {
162
162
  if (opts.engineNode !== void 0) env.TAIJI_AGENT_ENGINE_NODE = opts.engineNode;
163
163
  if (opts.electronRunAsNode === true) env.ELECTRON_RUN_AS_NODE = "1";
164
164
  env.TAIJI_AGENT_SUBAGENT = "1";
165
- if (opts.relay !== void 0) {
166
- env.TAIJI_SUBAGENT_RELAY_SOCKET = opts.relay.socket;
167
- env.TAIJI_SUBAGENT_RELAY_NODE = opts.relay.node;
168
- env.TAIJI_SUBAGENT_RELAY_SCRIPT = opts.relay.script;
169
- }
170
165
  if (opts.identityEnv !== void 0) {
171
166
  for (const [key, value] of Object.entries(opts.identityEnv)) {
172
167
  if (value !== void 0) env[key] = value;
package/dist/env.d.cts CHANGED
@@ -1,18 +1,9 @@
1
1
  /** L2 manifest 放行的保留前缀拒绝表(镜像 shared SSOT,勿单独改动)。 */
2
2
  declare const ENGINE_ENV_PREFIXES: readonly string[];
3
- /** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。
4
- * 互引(场景域分化,勿互混):dev 装配器(apps/electron/scripts/dev-instance-lib.mjs
5
- * `LEAK_ENV_KEYS`)仍剥 RELAY_STD* 三键——dev 宿主进程环境防泄漏口径独立于引擎
6
- * spawn 面;本清单(引擎侧)已退役同名三键,写入方已清零。 */
3
+ /** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。 */
7
4
  declare const ENGINE_ENV_DENY_LIST: readonly string[];
8
- /** L0 注入的全部基础设施键(守卫断言:与 ENGINE_ENV_DENY_LIST 交集 = ∅)。 */
5
+ /** L0 注入的全部基础设施键(检查断言:与 ENGINE_ENV_DENY_LIST 交集 = ∅)。 */
9
6
  declare const ENGINE_ENV_L0_INFRA_KEYS: readonly string[];
10
- /** relay 三键形态(宿主 relay 激活时三值同时非空,全有或全无)。 */
11
- interface EngineRelayEnv {
12
- socket: string;
13
- node: string;
14
- script: string;
15
- }
16
7
  /** buildEngineChildEnv 入参。 */
17
8
  interface EngineChildEnvOptions {
18
9
  /** L0:引擎数据根(隔离库/池/journal 都相对它推导;缺 env 且无注入引擎侧须显式报错) */
@@ -21,8 +12,6 @@ interface EngineChildEnvOptions {
21
12
  engineNode?: string;
22
13
  /** L0:执行器为 Electron 二进制 → 注入 ELECTRON_RUN_AS_NODE=1 */
23
14
  electronRunAsNode?: boolean;
24
- /** L0:relay 三键(宿主 relay 激活时传;三键必经 L0——L1 拒绝 TAIJI_SUBAGENT_ 前缀、L2 是 manifest 面,两层都到不了) */
25
- relay?: EngineRelayEnv;
26
15
  /**
27
16
  * L0:引擎宿主(engine-host)进程的 env 透传通道。**注意它不是子代理身份通道**:
28
17
  * 引擎宿主是长驻进程(每窗口一个),而子代理身份(recordId / depth 等)是 per-run 的
@@ -46,9 +35,9 @@ interface EngineChildEnvOptions {
46
35
  *
47
36
  * 层规格(impl-plan §2.12 三层表):
48
37
  * - L0 基础设施键:TAIJI_AGENT_DATA_DIR / TAIJI_AGENT_ENGINE_NODE / ELECTRON_RUN_AS_NODE
49
- * (条件)/ TAIJI_AGENT_SUBAGENT=1 / relay 三键 / identityEnv(injectL0InfraKeys);
38
+ * (条件)/ TAIJI_AGENT_SUBAGENT=1 / identityEnv(injectL0InfraKeys);
50
39
  * - L1 deny + 显式剥除(恒高于 manifest 放行):ENGINE_ENV_DENY_LIST
51
- * (deny 两键 + 凭证键 + 父身份键 + 防御性剥除三死名);
40
+ * (deny 两键 + 凭证键 + 预设回落两键);
52
41
  * - L2 manifest 放行:envPrefixes 声明前缀的 processEnv 键(保留前缀拒绝、
53
42
  * 形态校验、未声明前缀不放行 + warn)(applyManifestAllowlist)。
54
43
  *
@@ -70,7 +59,7 @@ interface BuildOutboundChildEnvOptions {
70
59
  * 消费生命周期标志 / WS 令牌。
71
60
  *
72
61
  * 与 @taiji/shared 版 buildOutboundChildEnv 的刻意差异:**缺省不做白名单过滤**
73
- * (prefixes 省略 = 全量继承父 env + deny 剥除)。理由:SDK 消费面(zsw 宿主 /
62
+ * (prefixes 省略 = 全量继承父 env + deny 剥除)。理由:SDK 消费方(zsw 宿主 /
74
63
  * 引擎 CLI)不可 import shared 的 ENV_WHITELIST_PREFIXES;引擎 spawn 的基座由
75
64
  * 调用方先经 buildEngineChildEnv 组装(其 baseEnv 已是 core 过滤后的),而
76
65
  * ambient 场景(git 需要 GIT_* / proxy / ssh 等)必须保留继承面——deny-by-default
@@ -80,4 +69,4 @@ interface BuildOutboundChildEnvOptions {
80
69
  */
81
70
  declare function buildOutboundChildEnv(opts: BuildOutboundChildEnvOptions): Record<string, string>;
82
71
 
83
- export { type BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, type EngineChildEnvOptions, type EngineRelayEnv, buildEngineChildEnv, buildOutboundChildEnv };
72
+ export { type BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, type EngineChildEnvOptions, buildEngineChildEnv, buildOutboundChildEnv };
package/dist/env.d.ts CHANGED
@@ -1,18 +1,9 @@
1
1
  /** L2 manifest 放行的保留前缀拒绝表(镜像 shared SSOT,勿单独改动)。 */
2
2
  declare const ENGINE_ENV_PREFIXES: readonly string[];
3
- /** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。
4
- * 互引(场景域分化,勿互混):dev 装配器(apps/electron/scripts/dev-instance-lib.mjs
5
- * `LEAK_ENV_KEYS`)仍剥 RELAY_STD* 三键——dev 宿主进程环境防泄漏口径独立于引擎
6
- * spawn 面;本清单(引擎侧)已退役同名三键,写入方已清零。 */
3
+ /** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。 */
7
4
  declare const ENGINE_ENV_DENY_LIST: readonly string[];
8
- /** L0 注入的全部基础设施键(守卫断言:与 ENGINE_ENV_DENY_LIST 交集 = ∅)。 */
5
+ /** L0 注入的全部基础设施键(检查断言:与 ENGINE_ENV_DENY_LIST 交集 = ∅)。 */
9
6
  declare const ENGINE_ENV_L0_INFRA_KEYS: readonly string[];
10
- /** relay 三键形态(宿主 relay 激活时三值同时非空,全有或全无)。 */
11
- interface EngineRelayEnv {
12
- socket: string;
13
- node: string;
14
- script: string;
15
- }
16
7
  /** buildEngineChildEnv 入参。 */
17
8
  interface EngineChildEnvOptions {
18
9
  /** L0:引擎数据根(隔离库/池/journal 都相对它推导;缺 env 且无注入引擎侧须显式报错) */
@@ -21,8 +12,6 @@ interface EngineChildEnvOptions {
21
12
  engineNode?: string;
22
13
  /** L0:执行器为 Electron 二进制 → 注入 ELECTRON_RUN_AS_NODE=1 */
23
14
  electronRunAsNode?: boolean;
24
- /** L0:relay 三键(宿主 relay 激活时传;三键必经 L0——L1 拒绝 TAIJI_SUBAGENT_ 前缀、L2 是 manifest 面,两层都到不了) */
25
- relay?: EngineRelayEnv;
26
15
  /**
27
16
  * L0:引擎宿主(engine-host)进程的 env 透传通道。**注意它不是子代理身份通道**:
28
17
  * 引擎宿主是长驻进程(每窗口一个),而子代理身份(recordId / depth 等)是 per-run 的
@@ -46,9 +35,9 @@ interface EngineChildEnvOptions {
46
35
  *
47
36
  * 层规格(impl-plan §2.12 三层表):
48
37
  * - L0 基础设施键:TAIJI_AGENT_DATA_DIR / TAIJI_AGENT_ENGINE_NODE / ELECTRON_RUN_AS_NODE
49
- * (条件)/ TAIJI_AGENT_SUBAGENT=1 / relay 三键 / identityEnv(injectL0InfraKeys);
38
+ * (条件)/ TAIJI_AGENT_SUBAGENT=1 / identityEnv(injectL0InfraKeys);
50
39
  * - L1 deny + 显式剥除(恒高于 manifest 放行):ENGINE_ENV_DENY_LIST
51
- * (deny 两键 + 凭证键 + 父身份键 + 防御性剥除三死名);
40
+ * (deny 两键 + 凭证键 + 预设回落两键);
52
41
  * - L2 manifest 放行:envPrefixes 声明前缀的 processEnv 键(保留前缀拒绝、
53
42
  * 形态校验、未声明前缀不放行 + warn)(applyManifestAllowlist)。
54
43
  *
@@ -70,7 +59,7 @@ interface BuildOutboundChildEnvOptions {
70
59
  * 消费生命周期标志 / WS 令牌。
71
60
  *
72
61
  * 与 @taiji/shared 版 buildOutboundChildEnv 的刻意差异:**缺省不做白名单过滤**
73
- * (prefixes 省略 = 全量继承父 env + deny 剥除)。理由:SDK 消费面(zsw 宿主 /
62
+ * (prefixes 省略 = 全量继承父 env + deny 剥除)。理由:SDK 消费方(zsw 宿主 /
74
63
  * 引擎 CLI)不可 import shared 的 ENV_WHITELIST_PREFIXES;引擎 spawn 的基座由
75
64
  * 调用方先经 buildEngineChildEnv 组装(其 baseEnv 已是 core 过滤后的),而
76
65
  * ambient 场景(git 需要 GIT_* / proxy / ssh 等)必须保留继承面——deny-by-default
@@ -80,4 +69,4 @@ interface BuildOutboundChildEnvOptions {
80
69
  */
81
70
  declare function buildOutboundChildEnv(opts: BuildOutboundChildEnvOptions): Record<string, string>;
82
71
 
83
- export { type BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, type EngineChildEnvOptions, type EngineRelayEnv, buildEngineChildEnv, buildOutboundChildEnv };
72
+ export { type BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, type EngineChildEnvOptions, buildEngineChildEnv, buildOutboundChildEnv };
package/dist/env.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  ENGINE_ENV_PREFIXES,
5
5
  buildEngineChildEnv,
6
6
  buildOutboundChildEnv
7
- } from "./chunk-AF2ETADP.js";
7
+ } from "./chunk-2L3I2TWJ.js";
8
8
  import "./chunk-NXNNXGTY.js";
9
9
  import "./chunk-JSBRDJBE.js";
10
10
  export {
@@ -1,4 +1,4 @@
1
- import { A as AgentEvent, d as EngineCapabilities } from './contract-types-jSa1g28F.cjs';
1
+ import { A as AgentEvent, e as EngineCapabilities } from './contract-types-C1scOS_M.cjs';
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 };