@zhushanwen/subagent-engine-sdk 0.5.0 → 0.5.1

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 (82) hide show
  1. package/dist/{chunk-7I4XGL5J.js → chunk-BBWUC2EE.js} +2 -2
  2. package/dist/{chunk-3K2P2CM2.js → chunk-CNQTJJF5.js} +1 -1
  3. package/dist/{chunk-DSQ7JQKM.js → chunk-GSW3DMN6.js} +5 -5
  4. package/dist/{chunk-BBVZK5DL.js → chunk-M3SZTDNQ.js} +20 -20
  5. package/dist/{chunk-HYES77BR.js → chunk-MSAJXIP4.js} +2 -2
  6. package/dist/{chunk-WORT4PG7.js → chunk-QOEXD2FT.js} +1 -1
  7. package/dist/{chunk-3IBT7MTB.js → chunk-W3BKI2BP.js} +3 -3
  8. package/dist/{chunk-F5JZMK74.js → chunk-WMDMXP2F.js} +2 -2
  9. package/dist/{chunk-GT6YLLN4.js → chunk-X24IVQKJ.js} +5 -5
  10. package/dist/{chunk-365AUV6N.js → chunk-YE472JOO.js} +2 -2
  11. package/dist/data-dir.cjs +6 -6
  12. package/dist/data-dir.d.cts +4 -4
  13. package/dist/data-dir.d.ts +4 -4
  14. package/dist/data-dir.js +3 -3
  15. package/dist/env.cjs +20 -20
  16. package/dist/env.d.cts +5 -5
  17. package/dist/env.d.ts +5 -5
  18. package/dist/env.js +1 -1
  19. package/dist/{error-codes-OvQlqiQw.d.ts → error-codes-DMGeUUUm.d.ts} +4 -3
  20. package/dist/{error-codes-SA5fGtx_.d.cts → error-codes-pT7RYTqQ.d.cts} +4 -3
  21. package/dist/index.cjs +42 -42
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +12 -12
  25. package/dist/kill-chain.d.cts +1 -1
  26. package/dist/kill-chain.d.ts +1 -1
  27. package/dist/kill-chain.js +2 -2
  28. package/dist/logs/stderr-rotation.cjs +2 -2
  29. package/dist/logs/stderr-rotation.d.cts +1 -1
  30. package/dist/logs/stderr-rotation.d.ts +1 -1
  31. package/dist/logs/stderr-rotation.js +1 -1
  32. package/dist/nesting-guard.cjs +2 -2
  33. package/dist/nesting-guard.d.cts +2 -2
  34. package/dist/nesting-guard.d.ts +2 -2
  35. package/dist/nesting-guard.js +1 -1
  36. package/dist/node-executor.cjs +2 -2
  37. package/dist/node-executor.d.cts +5 -5
  38. package/dist/node-executor.d.ts +5 -5
  39. package/dist/node-executor.js +2 -2
  40. package/dist/protocol/index.cjs +2 -2
  41. package/dist/protocol/index.d.cts +3 -3
  42. package/dist/protocol/index.d.ts +3 -3
  43. package/dist/protocol/index.js +1 -1
  44. package/dist/relay-env.cjs +5 -5
  45. package/dist/relay-env.d.cts +5 -5
  46. package/dist/relay-env.d.ts +5 -5
  47. package/dist/relay-env.js +1 -1
  48. package/dist/spawn.cjs +1 -1
  49. package/dist/spawn.d.cts +2 -2
  50. package/dist/spawn.d.ts +2 -2
  51. package/dist/spawn.js +1 -1
  52. package/dist/ui-channels.cjs +2 -2
  53. package/dist/ui-channels.js +1 -1
  54. package/package.json +2 -4
  55. package/src/best-effort.ts +0 -37
  56. package/src/cli-entry.ts +0 -82
  57. package/src/data-dir.ts +0 -89
  58. package/src/env.ts +0 -272
  59. package/src/error-message.ts +0 -22
  60. package/src/index.ts +0 -63
  61. package/src/journal-io.ts +0 -82
  62. package/src/journal-replay.ts +0 -436
  63. package/src/kill-chain.ts +0 -265
  64. package/src/logger.ts +0 -105
  65. package/src/logs/stderr-rotation.ts +0 -166
  66. package/src/nesting-guard.ts +0 -140
  67. package/src/node-executor.ts +0 -272
  68. package/src/paths.ts +0 -48
  69. package/src/port-contract.ts +0 -150
  70. package/src/protocol/contract-types.ts +0 -378
  71. package/src/protocol/engine-protocol.ts +0 -92
  72. package/src/protocol/error-codes.ts +0 -179
  73. package/src/protocol/frames.ts +0 -143
  74. package/src/protocol/index.ts +0 -12
  75. package/src/protocol/methods.ts +0 -237
  76. package/src/protocol/reverse-channels.ts +0 -123
  77. package/src/protocol/schema.ts +0 -185
  78. package/src/relay-env.ts +0 -60
  79. package/src/schema-emulation.ts +0 -192
  80. package/src/spawn.ts +0 -246
  81. package/src/ui-channels.ts +0 -219
  82. package/src/ui-types.ts +0 -101
@@ -1,143 +0,0 @@
1
- // src/protocol/frames.ts
2
- //
3
- // 帧型四类(传输 = stdio NDJSON,每行一个 JSON 对象)。设计权威源:
4
- // 设计 §3.3 帧型 + impl-plan §2.1「帧型四类」。
5
- //
6
- // ① 请求(core → 引擎) { id, method, params }
7
- // ② 应答(引擎 → core) { id, result } | { id, error }
8
- // ③ 通知(引擎 → core,无 id) { method: "event", params }
9
- // ④ 反向请求(引擎 → core) { id, method: "host/*", params }(必须应答)
10
- //
11
- // id 形态:正向请求 id = number(core 单调计数);反向请求 id = string(引擎侧命名,
12
- // 如 "rev-1");应答 id = 请求或反向请求 id 原样回传(number | string)。
13
- // 实现面(行解析、请求关联、反向路由)归 W2 EngineClient;本文件只定帧型与判别。
14
-
15
- import type { AgentEvent } from "./contract-types.ts";
16
-
17
- /** 协议错误对象(error 帧载荷与反向请求错误应答共用形态)。 */
18
- export interface ProtocolError {
19
- /** 错误码(error-codes.ts 词表 + 其余 engine_* 引擎自报透传)。 */
20
- code: string;
21
- /** 人类可读详情。 */
22
- message: string;
23
- /** 恢复指引:指向具体下一步(命令 / 配置路径 / 升级动作),非安慰性文案。 */
24
- recovery: string;
25
- /** 结构化附参(如 engine_protocol_mismatch 的双方版本)。 */
26
- data?: Record<string, unknown>;
27
- }
28
-
29
- // ============================================================
30
- // ① 请求(core → 引擎)
31
- // ============================================================
32
-
33
- export interface RequestFrame {
34
- id: number;
35
- method: string;
36
- params: unknown;
37
- }
38
-
39
- // ============================================================
40
- // ② 应答(引擎 → core)
41
- // ============================================================
42
-
43
- export interface SuccessResponseFrame {
44
- id: number | string;
45
- result: unknown;
46
- }
47
-
48
- export interface ErrorResponseFrame {
49
- id: number | string;
50
- error: ProtocolError;
51
- }
52
-
53
- export type ResponseFrame = SuccessResponseFrame | ErrorResponseFrame;
54
-
55
- // ============================================================
56
- // ③ 通知(引擎 → core,无 id)
57
- // ============================================================
58
-
59
- /** event 通知载荷:runId 关联在途 run;seq 单调递增(基线①结构等价断言对象)。 */
60
- export interface EventNotificationParams {
61
- runId: string;
62
- seq: number;
63
- event: AgentEvent;
64
- }
65
-
66
- export interface NotificationFrame {
67
- method: "event";
68
- params: EventNotificationParams;
69
- }
70
-
71
- // ============================================================
72
- // ④ 反向请求(引擎 → core,必须应答)
73
- // ============================================================
74
-
75
- export interface ReverseRequestFrame {
76
- id: string;
77
- method: string;
78
- params: unknown;
79
- }
80
-
81
- /** 反向请求的应答(core → 引擎,沿 ResponseFrame 通道回传;id = 反向请求 id 原样)。 */
82
- export type ReverseResponseResult =
83
- /** 数据面类:处理确认。 */
84
- | { ok: true }
85
- /** 人机交互类(askUser)两阶段第一阶段:已受理,结果异步到达(R9-2)。 */
86
- | { ack: true }
87
- /** 未实现的交互能力(设计:未实现回 unsupported,引擎自行降级)。 */
88
- | { unsupported: true };
89
-
90
- // ============================================================
91
- // 判别守卫(W2 行解析器消费;结构判定,不抛错)
92
- // ============================================================
93
-
94
- function isRecord(v: unknown): v is Record<string, unknown> {
95
- return typeof v === "object" && v !== null;
96
- }
97
-
98
- /** ① 请求:有数字 id + method + params,且无 result/error(与②应答区分)。 */
99
- export function isRequestFrame(frame: unknown): frame is RequestFrame {
100
- return (
101
- isRecord(frame) &&
102
- typeof frame.id === "number" &&
103
- typeof frame.method === "string" &&
104
- "params" in frame &&
105
- !("result" in frame) &&
106
- !("error" in frame)
107
- );
108
- }
109
-
110
- /** ② 应答:有 id(number|string)且 result/error 二选一。 */
111
- export function isResponseFrame(frame: unknown): frame is ResponseFrame {
112
- if (!isRecord(frame) || !("id" in frame)) return false;
113
- const idOk = typeof frame.id === "number" || typeof frame.id === "string";
114
- if (!idOk) return false;
115
- const hasResult = "result" in frame;
116
- const hasError = "error" in frame;
117
- return hasResult !== hasError;
118
- }
119
-
120
- /** ③ 通知:无 id,method === "event",params 含 runId/seq/event。 */
121
- export function isNotificationFrame(frame: unknown): frame is NotificationFrame {
122
- return (
123
- isRecord(frame) &&
124
- !("id" in frame) &&
125
- frame.method === "event" &&
126
- isRecord(frame.params) &&
127
- typeof frame.params.runId === "string" &&
128
- typeof frame.params.seq === "number" &&
129
- isRecord(frame.params.event) &&
130
- typeof frame.params.event.type === "string"
131
- );
132
- }
133
-
134
- /** ④ 反向请求:有字符串 id + host/* method + params(与①的区别 = id 形态与 method 前缀)。 */
135
- export function isReverseRequestFrame(frame: unknown): frame is ReverseRequestFrame {
136
- return (
137
- isRecord(frame) &&
138
- typeof frame.id === "string" &&
139
- typeof frame.method === "string" &&
140
- frame.method.startsWith("host/") &&
141
- "params" in frame
142
- );
143
- }
@@ -1,12 +0,0 @@
1
- // src/protocol/index.ts
2
- //
3
- // 协议面 barrel(契约根公共出口)。W2 协议客户端(EngineClient/RemoteEngine)与
4
- // 各引擎 CLI 包(W5/W7)从本入口消费帧型/方法/通道/错误码/契约类型/JSON Schema。
5
-
6
- export * from "./engine-protocol.ts";
7
- export * from "./frames.ts";
8
- export * from "./methods.ts";
9
- export * from "./reverse-channels.ts";
10
- export * from "./error-codes.ts";
11
- export * from "./contract-types.ts";
12
- export * from "./schema.ts";
@@ -1,237 +0,0 @@
1
- // src/protocol/methods.ts
2
- //
3
- // 9 正向方法(core → 引擎)params/result 逐方法写死(v1)。设计权威源:
4
- // 设计 §3.3 方法集表 + impl-plan §2.1「10 正向方法」([H1] 收敛为 9)。
5
- //
6
- // [v1.x 增量(chat-domain 设计 §3.2 D1-A)]:增量以可选参数形态落在 run.params.chat
7
- // (会话形态参数 + 冷续 resume 锚点),major 不 bump。[H1] chat-run 统一后续聊 =
8
- // 新 run + resume 锚点(docs/architecture/subagent-chat-run-unification.md §3.3 D5/D7),
9
- // 既有 interact 方法已随 U5 删除,方法集收敛为 9 个。
10
- //
11
- // 应答面补充约定(设计 §3.3):initialize 应答仅诊断(与 manifest 不一致 → warn 留痕,
12
- // 不参与同步成员判据;唯一阻断面 = 被 gate 能力位多声明 → engine_capability_mismatch);
13
- // listModels / validateModel 为诊断面(宿主侧同步成员读 manifest,不经本方法);
14
- // dispose 幂等;ping 为健康检查(ADR-0047:静默 ≠ 卡死,不据此杀任务)。
15
-
16
- import type {
17
- AgentCallOpts,
18
- EngineCapabilities,
19
- EngineHandleData,
20
- AgentOutcome,
21
- ModelCatalogEntry,
22
- ProbeReport,
23
- ResumeAnchor,
24
- SessionView,
25
- } from "./contract-types.ts";
26
-
27
- /**
28
- * 正向方法名联合(恰好 9 个;PROTOCOL_METHODS 常量数组与之同源互证)。
29
- * [H1] `interact` 成员已随 chat-run 统一退役(docs/architecture/subagent-chat-run-unification.md
30
- * §3.3 D5:续聊轮统一为「新 run + resume 锚点」,U5 删除)。
31
- */
32
- export type ProtocolMethod =
33
- | "initialize"
34
- | "probe"
35
- | "run"
36
- | "cancel"
37
- | "read"
38
- | "listModels"
39
- | "validateModel"
40
- | "dispose"
41
- | "ping";
42
-
43
- /** 方法名全集(运行时顺序化枚举;与 ProtocolMethod 的同源关系由测试断言)。 */
44
- export const PROTOCOL_METHODS = [
45
- "initialize",
46
- "probe",
47
- "run",
48
- "cancel",
49
- "read",
50
- "listModels",
51
- "validateModel",
52
- "dispose",
53
- "ping",
54
- ] as const satisfies readonly ProtocolMethod[];
55
-
56
- // ============================================================
57
- // run 专用载荷
58
- // ============================================================
59
-
60
- /**
61
- * run 上下文(RunContext 字段映射的协议承载,设计 §3.3 RunContext 映射表)。
62
- */
63
- export interface RunContextParams {
64
- /** 任务工作目录(worktree 隔离时 = worktree 路径)。 */
65
- cwd: string;
66
- /** 请求模型 ref(未传 = 引擎缺省模型)。 */
67
- model?: string;
68
- /** 结构化输出 schema 的 env 注入形态(schemaEnv 降级通道)。 */
69
- schemaEnv?: string;
70
- /** 上下文模型 ref(与 run 模型分离的 ctx 模型)。 */
71
- ctxModel?: string;
72
- /** fallback 留痕(引擎回填 outcome.engineFallback 的种子)。 */
73
- engineFallback?: { from: string; reason: string };
74
- /** 事件粒度请求(引擎按 capabilities.eventGranularity 实际能力执行)。 */
75
- streamMode?: "stream" | "coarse";
76
- /**
77
- * [F6] 根 session id——pi 引擎 relay 归属键 SESSION_ID 的权威来源(生产三来源
78
- * ①本字段 ②宿主 env ③根进程 env 中,宿主派发恒走①)。additive 可选:旧引擎忽略
79
- * 未知字段,undefined 不上 wire。
80
- */
81
- sessionRootId?: string;
82
- /**
83
- * [Option C 协议化] 权威 subagent session 目录——宿主以 getSubagentSessionDir
84
- * (agentDir, rootCwd) 推导(宿主单一权威,Fix Gate B S6:引擎本地推导与宿主布局
85
- * 三处不等价 → 跨重启续聊链断裂)。引擎用它组装 pi `--session-dir`,不自推导;
86
- * 缺省(独立运行/测试)走引擎内 [LEGACY] fallback。additive 可选:旧引擎忽略
87
- * 未知字段,undefined 不上 wire。
88
- */
89
- sessionDir?: string;
90
- }
91
-
92
- // ============================================================
93
- // [H1] run 的 resume 会话形态参数(chat-run 统一终态;原 v1.x chat 键已退役)
94
- // ============================================================
95
-
96
- /**
97
- * [H1] run 的 resume 会话形态参数(设计 docs/architecture/subagent-chat-run-unification.md
98
- * §3.3 D3 + §5 U1/U6 行):原 RunChatParams(v1.x chat 会话形态参数)的泛化改名终态,
99
- * 载荷同形(recordId + resume 锚点,ResumeAnchor 不变),仅键名从「chat 会话形态」
100
- * 泛化为「resume 续聊」。
101
- * - recordId:core 预建 record 的关联键(引擎据此回填 handle.sessionRef、上报
102
- * host/childSpawned|childStateChanged 的 record 键形态);
103
- * - resume:冷续锚点(重开已 idle 的 session 续聊;缺省 = 新 session)。对照
104
- * core SpawnResumeOpts——sessionFile 经 anchor.sessionRef 携带,model/
105
- * thinkingLevel 防漂移覆盖走既有 task/ctx 字段,不双写。
106
- * [H1 U6 已切换] `chat` 键整体退役(读写端同批切换,无「写新读旧」窗口),本键为
107
- * 唯一会话形态参数。载荷 schema 权威 = runSessionParamsSchema(schema.ts)。
108
- */
109
- export interface RunResumeParams {
110
- recordId: string;
111
- resume?: ResumeAnchor;
112
- }
113
-
114
- // ============================================================
115
- // params / result 逐方法映射(方法名 → 载荷)
116
- // ============================================================
117
-
118
- /** initialize 参数(engineConfig = L3 显式配置 engines.<id>.config 透传,不放凭据)。 */
119
- export interface InitializeParams {
120
- protocolVersion: number;
121
- hostInfo: { name: string; version: string; dataRoot: string };
122
- engineConfig: Record<string, string>;
123
- }
124
-
125
- /** initialize 应答(仅诊断面:capabilities/models 与 manifest 不一致 → warn,不参与判据)。 */
126
- export interface InitializeResult {
127
- protocolVersion: number;
128
- engineId: string;
129
- engineVersion: string;
130
- adapterVersion: string;
131
- capabilities: EngineCapabilities;
132
- /** 模型目录(诊断面;省略/null = 无枚举面语义)。 */
133
- models?: ModelCatalogEntry[] | null;
134
- }
135
-
136
- export interface ProbeParams {
137
- force?: boolean;
138
- }
139
-
140
- export interface RunParams {
141
- runId: string;
142
- task: AgentCallOpts;
143
- ctx: RunContextParams;
144
- /**
145
- * [H1 U6 终态] resume 续聊参数(唯一会话形态键;原 v1.x `chat` 键已随键切换退役,
146
- * 见 RunResumeParams)。缺省 = 一次性任务形态(向后兼容:旧引擎忽略未知字段,
147
- * 帧级 schema params 不做深校验)。additive 可选:undefined 不上 wire。
148
- */
149
- resume?: RunResumeParams;
150
- }
151
-
152
- /** run 终态应答(期间事件经 event 通知;长运行方法,应答到达即终态)。 */
153
- export interface RunResult {
154
- handle: EngineHandleData;
155
- outcome: AgentOutcome;
156
- }
157
-
158
- export interface CancelParams {
159
- runId: string;
160
- reason: string;
161
- }
162
-
163
- /**
164
- * cancel 应答(受理确认)。终态本体由该 run 的 run 终态应答承载(abort 合成终态经
165
- * event/终态应答到达);引擎须 CANCEL_SETTLE_GRACE_MS(3s)内收敛,超时 core 走杀链。
166
- */
167
- export interface CancelResult {
168
- ok: true;
169
- }
170
-
171
- export interface ReadParams {
172
- handle: EngineHandleData;
173
- /** 数据根必填:存量池时代引擎自算池/journal 相对 dbPath 的定位需要它(设计钉死)。 */
174
- dataDir: string;
175
- }
176
-
177
- export interface ListModelsParams {
178
- /** 占位空参(帧形状一致性;未来诊断参数在此扩展)。 */
179
- _placeholder?: never;
180
- }
181
-
182
- export interface ListModelsResult {
183
- /** 数组 = 有枚举面;null = 无枚举面(buildCoreAlignedHint 语义,与 manifest 省略对齐)。 */
184
- models: ModelCatalogEntry[] | null;
185
- }
186
-
187
- export interface ValidateModelParams {
188
- modelRef?: string;
189
- }
190
-
191
- export interface ValidateModelResult {
192
- canonicalRef: string;
193
- }
194
-
195
- export interface DisposeParams {
196
- /** 占位空参(帧形状一致性;幂等语义)。 */
197
- _placeholder?: never;
198
- }
199
-
200
- export interface DisposeResult {
201
- ok: true;
202
- }
203
-
204
- export interface PingParams {
205
- /** 占位空参(帧形状一致性)。 */
206
- _placeholder?: never;
207
- }
208
-
209
- export interface PingResult {
210
- pong: true;
211
- }
212
-
213
- /** 方法 → params 类型映射。 */
214
- export interface ProtocolParamsMap {
215
- initialize: InitializeParams;
216
- probe: ProbeParams;
217
- run: RunParams;
218
- cancel: CancelParams;
219
- read: ReadParams;
220
- listModels: ListModelsParams;
221
- validateModel: ValidateModelParams;
222
- dispose: DisposeParams;
223
- ping: PingParams;
224
- }
225
-
226
- /** 方法 → result 类型映射。 */
227
- export interface ProtocolResultMap {
228
- initialize: InitializeResult;
229
- probe: ProbeReport;
230
- run: RunResult;
231
- cancel: CancelResult;
232
- read: SessionView;
233
- listModels: ListModelsResult;
234
- validateModel: ValidateModelResult;
235
- dispose: DisposeResult;
236
- ping: PingResult;
237
- }
@@ -1,123 +0,0 @@
1
- // src/protocol/reverse-channels.ts
2
- //
3
- // 6 反向通道(引擎 → core,帧④,必须应答)载荷与超时二分。设计权威源:
4
- // 设计 §3.3 方法集表 host/* 行 + impl-plan §2.1「8 反向通道」与「反向请求超时二分」。
5
- // [H1] chat 域 v1.x 增量曾新增的第 9 通道(轮次相位帧)已随 chat-run 统一退役
6
- // (docs/architecture/subagent-chat-run-unification.md §3.3 D5,U5 删除)——轮次终态
7
- // 改由 run 应答(agent_settled resolve)承载。
8
- // [池抽象降级 2026-09-13] 原 host/poolResolved 通道(第 8 条)随 poolKey 协议面退役
9
- // 一并删除(两引擎 poolKey 恒 'shared'、journal 落盘路径固定,回调零信息量)。
10
- // [permission 通道退役 2026-09-13] host/permission 骨架删除(两引擎 permissionMode=
11
- // native 零 emit、core 零注入——未接线死通道),通道集收敛为 6 个。
12
- //
13
- // 应答约定:数据面类回 {ok:true}(REVERSE_REQUEST_TIMEOUT_MS=10s 未答 = 引擎故障 →
14
- // 杀进程 + 在途 run 失败);人机交互类走 ack 两阶段——先回 {ack:true},结果异步到达
15
- // (R9-2:已 ack 的等待不计入任何 in-flight 超时;ADR-0047 静默 ≠ 卡死);
16
- // 未实现的交互能力回 {unsupported:true}(引擎自行降级,不重试)。
17
-
18
- import type { ReverseRequestTimeoutClass } from "./engine-protocol.ts";
19
- import type { UiRequest, UiResponse } from "../ui-types.ts";
20
-
21
- /**
22
- * 反向通道名联合(恰好 6 个;REVERSE_CHANNELS 常量数组与之同源互证)。
23
- */
24
- export type ReverseChannel =
25
- | "host/log"
26
- | "host/askUser"
27
- | "host/streamDelta"
28
- | "host/handleReady"
29
- | "host/childSpawned"
30
- | "host/childStateChanged";
31
-
32
- /**
33
- * 通道名全集(运行时顺序化枚举;与 ReverseChannel 的同源关系由测试断言)。
34
- */
35
- export const REVERSE_CHANNELS = [
36
- "host/log",
37
- "host/askUser",
38
- "host/streamDelta",
39
- "host/handleReady",
40
- "host/childSpawned",
41
- "host/childStateChanged",
42
- ] as const satisfies readonly ReverseChannel[];
43
-
44
- /**
45
- * 超时二分归属(10s 数据面 / 不设统一超时的人机交互面)。实现归 W2 EngineClient;
46
- * 引擎侧自灭计时(W12)复用同表——已 ack 的 askUser 等待不计入 in-flight(R9-2)。
47
- */
48
- export const REVERSE_CHANNEL_TIMEOUT_CLASS: Record<ReverseChannel, ReverseRequestTimeoutClass> = {
49
- "host/log": "data-plane",
50
- "host/streamDelta": "data-plane",
51
- "host/handleReady": "data-plane",
52
- "host/childSpawned": "data-plane",
53
- "host/childStateChanged": "data-plane",
54
- "host/askUser": "interaction",
55
- };
56
-
57
- // ============================================================
58
- // 通道载荷(params)
59
- // ============================================================
60
-
61
- /** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用面)。 */
62
- export interface HostLogParams {
63
- level: "debug" | "warn" | "error";
64
- component: string;
65
- message: string;
66
- data?: unknown;
67
- }
68
-
69
- /** host/askUser:UI 请求经反向通道送达宿主(core 壳侧 uiRequestHandler 应答)。 */
70
- export interface HostAskUserParams {
71
- runId: string;
72
- /** Pi extension_ui_request 平铺形态(类型 SSOT = SDK ui-types.ts,core 反向 re-export)。 */
73
- request: UiRequest;
74
- }
75
-
76
- /** host/askUser 的最终结果(ack 两阶段第二阶段,异步应答帧②的 result)。 */
77
- export type HostAskUserResult = UiResponse;
78
-
79
- /**
80
- * host/streamDelta:UI 实时通道(双通道之一;与 event 通知并行的渲染加速面)。
81
- *
82
- * 关联键恒为 runId(runId 由 core 在 run 帧分配);[H1] chat 续聊轮经 resume run
83
- * 复用 runId 关联(原 recordId 关联键随 interact 面退役删除)。
84
- */
85
- export interface HostStreamDeltaParams {
86
- runId: string;
87
- delta: string;
88
- }
89
-
90
- /**
91
- * host/handleReady:运行中句柄回填(core onHandleReady 语义:session/create 应答后、
92
- * 早于 run resolve;AGENTS.md 关键规则 9「重开 session 仍可见」的前提)。
93
- * [池抽象降级 2026-09-13] 原 poolKey 字段已随协议面 poolKey 退役删除。
94
- */
95
- export interface HostHandleReadyParams {
96
- runId: string;
97
- sessionRef: Record<string, string>;
98
- }
99
-
100
- /**
101
- * host/childSpawned:引擎内一次性子进程 pid 上报。
102
- * 用途 = isResumable 镜像谓词 + 诊断留痕;**不供杀链/收割**(v6 已删按 pid 补杀,
103
- * 收割只靠进程组);常驻进程不报(归 dispose)。
104
- */
105
- export interface HostChildSpawnedParams {
106
- pid: number;
107
- recordId: string;
108
- }
109
-
110
- /**
111
- * host/childStateChanged:childSpawned 的状态面(core 侧镜像数据源,
112
- * hasLiveProcessHandle/isResumable 同步读镜像,不跨进程查询)。
113
- * **killed 必含**(判据 `child !== undefined && !child.killed`)——类型层 required。
114
- */
115
- export interface HostChildStateChangedParams {
116
- pid: number;
117
- recordId: string;
118
- state: "running" | "exited";
119
- /** 必含:true = 已被杀/已终止(镜像置死判据)。 */
120
- killed: boolean;
121
- exitCode?: number;
122
- signal?: string;
123
- }