@zhushanwen/subagent-engine-sdk 0.2.1 → 0.4.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.
- package/dist/{chunk-A75XDJIC.js → chunk-AIG5LSGK.js} +3 -0
- package/dist/{chunk-ZXEAW25V.js → chunk-BBVZK5DL.js} +1 -4
- package/dist/chunk-EUSM6ZX4.js +10 -0
- package/dist/{chunk-LEOBWKRM.js → chunk-FJT23P7T.js} +1 -1
- package/dist/{chunk-N3RL6OVM.js → chunk-J4G2MXDS.js} +3 -1
- package/dist/{chunk-ZOFFJNJD.js → chunk-LKPVN3N6.js} +1 -1
- package/dist/{chunk-RULLX6C6.js → chunk-LQR73V67.js} +2 -0
- package/dist/{chunk-YFSN3D5N.js → chunk-TW2FAMAJ.js} +24 -32
- package/dist/{chunk-PPEPBVCC.js → chunk-WS4WAZVR.js} +1 -1
- package/dist/cli-entry.cjs +3 -1
- package/dist/cli-entry.js +1 -1
- package/dist/{contract-types-sSlgppBC.d.cts → contract-types-C71Sqq8d.d.cts} +31 -43
- package/dist/{contract-types-sSlgppBC.d.ts → contract-types-C71Sqq8d.d.ts} +31 -43
- package/dist/env.cjs +1 -4
- package/dist/env.d.cts +4 -1
- package/dist/env.d.ts +4 -1
- package/dist/env.js +1 -1
- package/dist/{error-codes-Dhss2Kmk.d.ts → error-codes-CiOO3PMg.d.cts} +7 -7
- package/dist/{error-codes-DHco5-i_.d.cts → error-codes-D5YlWaBx.d.ts} +7 -7
- package/dist/index.cjs +45 -41
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +16 -15
- package/dist/journal-io.d.cts +1 -1
- package/dist/journal-io.d.ts +1 -1
- package/dist/journal-replay.cjs +3 -0
- package/dist/journal-replay.d.cts +1 -1
- package/dist/journal-replay.d.ts +1 -1
- package/dist/journal-replay.js +1 -1
- package/dist/kill-chain.d.cts +2 -2
- package/dist/kill-chain.d.ts +2 -2
- package/dist/kill-chain.js +2 -2
- package/dist/node-executor.js +2 -2
- package/dist/port-contract.cjs +3 -0
- package/dist/port-contract.d.cts +45 -11
- package/dist/port-contract.d.ts +45 -11
- package/dist/port-contract.js +3 -1
- package/dist/protocol/index.cjs +26 -36
- package/dist/protocol/index.d.cts +95 -172
- package/dist/protocol/index.d.ts +95 -172
- package/dist/protocol/index.js +4 -8
- package/dist/ui-types.cjs +16 -0
- package/dist/ui-types.d.cts +13 -6
- package/dist/ui-types.d.ts +13 -6
- package/dist/ui-types.js +7 -1
- package/package.json +1 -1
- package/src/cli-entry.ts +6 -1
- package/src/data-dir.ts +3 -2
- package/src/env.ts +4 -4
- package/src/journal-replay.ts +4 -0
- package/src/nesting-guard.ts +1 -1
- package/src/paths.ts +1 -1
- package/src/port-contract.ts +44 -11
- package/src/protocol/contract-types.ts +36 -35
- package/src/protocol/engine-protocol.ts +22 -12
- package/src/protocol/error-codes.ts +7 -6
- package/src/protocol/frames.ts +1 -3
- package/src/protocol/methods.ts +38 -30
- package/src/protocol/reverse-channels.ts +21 -172
- package/src/protocol/schema.ts +34 -3
- package/src/ui-types.ts +22 -5
- package/dist/chunk-2DIMPZCQ.js +0 -0
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// src/protocol/reverse-channels.ts
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// 设计 §3.3 方法集表 host/* 行 + impl-plan §2.1「8
|
|
5
|
-
//
|
|
6
|
-
//
|
|
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 个。
|
|
7
12
|
//
|
|
8
13
|
// 应答约定:数据面类回 {ok:true}(REVERSE_REQUEST_TIMEOUT_MS=10s 未答 = 引擎故障 →
|
|
9
14
|
// 杀进程 + 在途 run 失败);人机交互类走 ack 两阶段——先回 {ack:true},结果异步到达
|
|
@@ -12,48 +17,41 @@
|
|
|
12
17
|
|
|
13
18
|
import type { ReverseRequestTimeoutClass } from "./engine-protocol.ts";
|
|
14
19
|
import type { UiRequest, UiResponse } from "../ui-types.ts";
|
|
15
|
-
import type { AgentUsage, ResumeAnchor } from "./contract-types.ts";
|
|
16
|
-
import type { ProtocolError } from "./frames.ts";
|
|
17
20
|
|
|
18
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* 反向通道名联合(恰好 6 个;REVERSE_CHANNELS 常量数组与之同源互证)。
|
|
23
|
+
*/
|
|
19
24
|
export type ReverseChannel =
|
|
20
25
|
| "host/log"
|
|
21
26
|
| "host/askUser"
|
|
22
|
-
| "host/permission"
|
|
23
27
|
| "host/streamDelta"
|
|
24
|
-
| "host/poolResolved"
|
|
25
28
|
| "host/handleReady"
|
|
26
29
|
| "host/childSpawned"
|
|
27
|
-
| "host/childStateChanged"
|
|
28
|
-
| "host/roundLifecycle";
|
|
30
|
+
| "host/childStateChanged";
|
|
29
31
|
|
|
32
|
+
/**
|
|
33
|
+
* 通道名全集(运行时顺序化枚举;与 ReverseChannel 的同源关系由测试断言)。
|
|
34
|
+
*/
|
|
30
35
|
export const REVERSE_CHANNELS = [
|
|
31
36
|
"host/log",
|
|
32
37
|
"host/askUser",
|
|
33
|
-
"host/permission",
|
|
34
38
|
"host/streamDelta",
|
|
35
|
-
"host/poolResolved",
|
|
36
39
|
"host/handleReady",
|
|
37
40
|
"host/childSpawned",
|
|
38
41
|
"host/childStateChanged",
|
|
39
|
-
"host/roundLifecycle",
|
|
40
42
|
] as const satisfies readonly ReverseChannel[];
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* 超时二分归属(10s 数据面 / 不设统一超时的人机交互面)。实现归 W2 EngineClient;
|
|
44
46
|
* 引擎侧自灭计时(W12)复用同表——已 ack 的 askUser 等待不计入 in-flight(R9-2)。
|
|
45
|
-
* host/roundLifecycle 属数据面(终态回执语义:宿主必须确认收到,10s 未答 = 引擎故障)。
|
|
46
47
|
*/
|
|
47
48
|
export const REVERSE_CHANNEL_TIMEOUT_CLASS: Record<ReverseChannel, ReverseRequestTimeoutClass> = {
|
|
48
49
|
"host/log": "data-plane",
|
|
49
50
|
"host/streamDelta": "data-plane",
|
|
50
|
-
"host/poolResolved": "data-plane",
|
|
51
51
|
"host/handleReady": "data-plane",
|
|
52
52
|
"host/childSpawned": "data-plane",
|
|
53
53
|
"host/childStateChanged": "data-plane",
|
|
54
|
-
"host/roundLifecycle": "data-plane",
|
|
55
54
|
"host/askUser": "interaction",
|
|
56
|
-
"host/permission": "interaction",
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
// ============================================================
|
|
@@ -78,64 +76,25 @@ export interface HostAskUserParams {
|
|
|
78
76
|
/** host/askUser 的最终结果(ack 两阶段第二阶段,异步应答帧②的 result)。 */
|
|
79
77
|
export type HostAskUserResult = UiResponse;
|
|
80
78
|
|
|
81
|
-
/**
|
|
82
|
-
* host/permission:权限询问(引擎请求宿主裁决工具执行)。
|
|
83
|
-
* v1 骨架字段(设计未钉死载荷细节,细化归各引擎提取设计;W2 实装 core 应答端时
|
|
84
|
-
* 若需扩展走 additive 演进)。
|
|
85
|
-
*/
|
|
86
|
-
export interface HostPermissionParams {
|
|
87
|
-
runId: string;
|
|
88
|
-
toolName: string;
|
|
89
|
-
args?: unknown;
|
|
90
|
-
/** 请求方向引擎给出的原因/说明(展示用)。 */
|
|
91
|
-
reason?: string;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** host/permission 两阶段结果。 */
|
|
95
|
-
export type HostPermissionResult = { approved: boolean } | { unsupported: true };
|
|
96
|
-
|
|
97
79
|
/**
|
|
98
80
|
* host/streamDelta:UI 实时通道(双通道之一;与 event 通知并行的渲染加速面)。
|
|
99
81
|
*
|
|
100
|
-
* [
|
|
101
|
-
*
|
|
102
|
-
* run 帧分配);
|
|
103
|
-
* - interact 发起的续聊轮:**recordId** 关联(续聊轮无独立 runId——InteractParams/
|
|
104
|
-
* InteractResult 均不含,recordId 经 handle.sessionRef 送达引擎)。
|
|
105
|
-
* 两键互斥(undefined 孪生位防双填),消费侧经 isHostStreamDeltaParams 收窄。
|
|
106
|
-
*/
|
|
107
|
-
export type HostStreamDeltaParams =
|
|
108
|
-
| { runId: string; recordId?: undefined; delta: string }
|
|
109
|
-
| { recordId: string; runId?: undefined; delta: string };
|
|
110
|
-
|
|
111
|
-
/** streamDelta 载荷结构判定(关联键互斥 + delta 形状;消费侧共用,防双侧各写一份)。 */
|
|
112
|
-
export function isHostStreamDeltaParams(value: unknown): value is HostStreamDeltaParams {
|
|
113
|
-
if (typeof value !== "object" || value === null) return false;
|
|
114
|
-
const v = value as Record<string, unknown>;
|
|
115
|
-
const hasRunId = typeof v.runId === "string";
|
|
116
|
-
const hasRecordId = typeof v.recordId === "string";
|
|
117
|
-
// 恰一键:无键 / 双键 / 键非 string 都拒
|
|
118
|
-
if (hasRunId === hasRecordId) return false;
|
|
119
|
-
return typeof v.delta === "string";
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* host/poolResolved:journal 落盘路径单一权威(契约:必须在首个事件 emit 前调用——
|
|
124
|
-
* 否则 journal 归属错)。载荷 = core onPoolResolved(poolKey) 的 runId 关联形态。
|
|
82
|
+
* 关联键恒为 runId(runId 由 core 在 run 帧分配);[H1] chat 续聊轮经 resume run
|
|
83
|
+
* 复用 runId 关联(原 recordId 关联键随 interact 面退役删除)。
|
|
125
84
|
*/
|
|
126
|
-
export interface
|
|
85
|
+
export interface HostStreamDeltaParams {
|
|
127
86
|
runId: string;
|
|
128
|
-
|
|
87
|
+
delta: string;
|
|
129
88
|
}
|
|
130
89
|
|
|
131
90
|
/**
|
|
132
91
|
* host/handleReady:运行中句柄回填(core onHandleReady 语义:session/create 应答后、
|
|
133
92
|
* 早于 run resolve;AGENTS.md 关键规则 9「重开 session 仍可见」的前提)。
|
|
93
|
+
* [池抽象降级 2026-09-13] 原 poolKey 字段已随协议面 poolKey 退役删除。
|
|
134
94
|
*/
|
|
135
95
|
export interface HostHandleReadyParams {
|
|
136
96
|
runId: string;
|
|
137
97
|
sessionRef: Record<string, string>;
|
|
138
|
-
poolKey: string;
|
|
139
98
|
}
|
|
140
99
|
|
|
141
100
|
/**
|
|
@@ -162,113 +121,3 @@ export interface HostChildStateChangedParams {
|
|
|
162
121
|
exitCode?: number;
|
|
163
122
|
signal?: string;
|
|
164
123
|
}
|
|
165
|
-
|
|
166
|
-
// ============================================================
|
|
167
|
-
// [v1.x] host/roundLifecycle:轮次生命周期载荷(chat 域 v1.x 唯一新通道)
|
|
168
|
-
// ============================================================
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* 轮次关联键(D1-A 裁定的类型面):run 域轮 = runId(v1 现状);interact 续聊轮 =
|
|
172
|
-
* recordId(经 handle.sessionRef)。undefined 孪生位保证两键互斥。
|
|
173
|
-
*/
|
|
174
|
-
export interface RoundKeyedByRun {
|
|
175
|
-
runId: string;
|
|
176
|
-
recordId?: undefined;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface RoundKeyedByRecord {
|
|
180
|
-
recordId: string;
|
|
181
|
-
runId?: undefined;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* 轮次终态相位(事件即 record 回写载体——chat 域 record 处置由相位一一映射,
|
|
186
|
-
* 设计 D2 裁决表 conversation 行:settled/idle 轮收口不终态、failed 标 failed):
|
|
187
|
-
* - settled:轮收敛(输出完整)。消费点 = settled-watchdog disarm + D3 abort
|
|
188
|
-
* 收敛判据(cancel 受理后等本事件,超 CANCEL_SETTLE_GRACE_MS 走杀链);
|
|
189
|
-
* - idle:轮收口 + 会话进 idle 稳态(core 侧 doFinalizeRoundToIdle + idle 定时器
|
|
190
|
-
* 锚点)。settled 与 idle 是两个锚点:watchdog 在 settled 即解除,idle 管置闲;
|
|
191
|
-
* - failed:轮异常终止(引擎自知失败,如 EPIPE 兜底耗尽)——error 如实上报,
|
|
192
|
-
* record 标 failed(与 run 域 AgentOutcome.error 的「失败收口」语义对齐)。
|
|
193
|
-
* usage 为本轮 message_end 增量(interact 续聊轮无 event 通知通道,用量经本帧回填)。
|
|
194
|
-
* 不设 seq:stdio NDJSON 单连接有序 + 数据面应答确认,无重排/重放面(与 event
|
|
195
|
-
* 通知的 seq 对照——后者镜像进程内事件流基线,本帧无基线可镜像)。
|
|
196
|
-
*/
|
|
197
|
-
export interface RoundSettledPhase {
|
|
198
|
-
phase: "settled";
|
|
199
|
-
usage?: AgentUsage;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface RoundIdlePhase {
|
|
203
|
-
phase: "idle";
|
|
204
|
-
usage?: AgentUsage;
|
|
205
|
-
/** 冷续锚点回填(session 滚动/compaction 后锚点可能变化,宿主按帧刷新)。 */
|
|
206
|
-
anchor?: ResumeAnchor;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export interface RoundFailedPhase {
|
|
210
|
-
phase: "failed";
|
|
211
|
-
/** 失败原因(结构对齐协议 error 帧——code/message/recovery 可操作闭环)。 */
|
|
212
|
-
error: ProtocolError;
|
|
213
|
-
anchor?: ResumeAnchor;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** 相位联合(消费侧 switch(phase) 判别用)。 */
|
|
217
|
-
export type RoundLifecyclePhase = RoundSettledPhase | RoundIdlePhase | RoundFailedPhase;
|
|
218
|
-
|
|
219
|
-
/** host/roundLifecycle 载荷:关联键(run|record)× 相位(settled|idle|failed)。 */
|
|
220
|
-
export type HostRoundLifecycleParams =
|
|
221
|
-
| (RoundKeyedByRun & RoundSettledPhase)
|
|
222
|
-
| (RoundKeyedByRun & RoundIdlePhase)
|
|
223
|
-
| (RoundKeyedByRun & RoundFailedPhase)
|
|
224
|
-
| (RoundKeyedByRecord & RoundSettledPhase)
|
|
225
|
-
| (RoundKeyedByRecord & RoundIdlePhase)
|
|
226
|
-
| (RoundKeyedByRecord & RoundFailedPhase);
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* roundLifecycle 载荷结构判定:关联键互斥 + phase 词表 + 各相位专属形状
|
|
230
|
-
* (failed 必含 error.code/message)。引擎侧发帧前自检与 core 侧消费共用,
|
|
231
|
-
* 防两侧各写一份判别(与 isHostStreamDeltaParams 同理)。
|
|
232
|
-
*/
|
|
233
|
-
export function isHostRoundLifecycleParams(value: unknown): value is HostRoundLifecycleParams {
|
|
234
|
-
if (typeof value !== "object" || value === null) return false;
|
|
235
|
-
const v = value as Record<string, unknown>;
|
|
236
|
-
const hasRunId = typeof v.runId === "string";
|
|
237
|
-
const hasRecordId = typeof v.recordId === "string";
|
|
238
|
-
if (hasRunId === hasRecordId) return false;
|
|
239
|
-
if (v.phase === "settled" || v.phase === "idle") return true;
|
|
240
|
-
if (v.phase !== "failed") return false;
|
|
241
|
-
const err = v.error;
|
|
242
|
-
return (
|
|
243
|
-
typeof err === "object" &&
|
|
244
|
-
err !== null &&
|
|
245
|
-
typeof (err as Record<string, unknown>).code === "string" &&
|
|
246
|
-
typeof (err as Record<string, unknown>).message === "string"
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/** 通道 → 载荷类型映射。 */
|
|
251
|
-
export interface ReverseChannelParamsMap {
|
|
252
|
-
"host/log": HostLogParams;
|
|
253
|
-
"host/askUser": HostAskUserParams;
|
|
254
|
-
"host/permission": HostPermissionParams;
|
|
255
|
-
"host/streamDelta": HostStreamDeltaParams;
|
|
256
|
-
"host/poolResolved": HostPoolResolvedParams;
|
|
257
|
-
"host/handleReady": HostHandleReadyParams;
|
|
258
|
-
"host/childSpawned": HostChildSpawnedParams;
|
|
259
|
-
"host/childStateChanged": HostChildStateChangedParams;
|
|
260
|
-
"host/roundLifecycle": HostRoundLifecycleParams;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/** 通道 → 异步/同步结果类型映射(ack 两阶段通道的第二阶段 result)。 */
|
|
264
|
-
export interface ReverseChannelResultMap {
|
|
265
|
-
"host/log": { ok: true };
|
|
266
|
-
"host/askUser": HostAskUserResult;
|
|
267
|
-
"host/permission": HostPermissionResult;
|
|
268
|
-
"host/streamDelta": { ok: true };
|
|
269
|
-
"host/poolResolved": { ok: true };
|
|
270
|
-
"host/handleReady": { ok: true };
|
|
271
|
-
"host/childSpawned": { ok: true };
|
|
272
|
-
"host/childStateChanged": { ok: true };
|
|
273
|
-
"host/roundLifecycle": { ok: true };
|
|
274
|
-
}
|
package/src/protocol/schema.ts
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
// 帧校验的目的是行解析器快速拒格式坏帧,不做深校验(深校验成本高于收益,坏载荷
|
|
13
13
|
// 由消费方结构化报错)。
|
|
14
14
|
|
|
15
|
-
import type { ReverseChannel } from "./reverse-channels.ts";
|
|
16
15
|
import { REVERSE_CHANNELS } from "./reverse-channels.ts";
|
|
17
16
|
import { PROTOCOL_METHODS } from "./methods.ts";
|
|
18
17
|
|
|
@@ -103,6 +102,7 @@ export const notificationFrameSchema = {
|
|
|
103
102
|
"turn_end",
|
|
104
103
|
"message_end",
|
|
105
104
|
"compaction",
|
|
105
|
+
"activity",
|
|
106
106
|
"error",
|
|
107
107
|
],
|
|
108
108
|
},
|
|
@@ -150,5 +150,36 @@ export const FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS = [
|
|
|
150
150
|
"secret",
|
|
151
151
|
] as const;
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
// ============================================================
|
|
154
|
+
// [H1] run 会话形态参数载荷 schema(resume 单键校验权威)
|
|
155
|
+
// ============================================================
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* run.params 的会话形态参数载荷 schema(draft-07 深载荷片段)。设计权威源:
|
|
159
|
+
* docs/architecture/subagent-chat-run-unification.md §3.3 D3 + §5 U1/U6 行。
|
|
160
|
+
*
|
|
161
|
+
* [H1 U6 已切换] 键切换单批完成后本 schema 面向唯一键 `resume`(RunResumeParams:
|
|
162
|
+
* recordId + 可选 ResumeAnchor),形状不变。帧级 schema(requestFrameSchema.params)
|
|
163
|
+
* 刻意不做深校验(见本文件头注释),本片段供消费方(引擎读端结构化报错 / 测试正负
|
|
164
|
+
* 样本)按需深校验。
|
|
165
|
+
*/
|
|
166
|
+
export const runSessionParamsSchema = {
|
|
167
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
168
|
+
title: "EngineRunSessionParams",
|
|
169
|
+
type: "object",
|
|
170
|
+
additionalProperties: false,
|
|
171
|
+
required: ["recordId"],
|
|
172
|
+
properties: {
|
|
173
|
+
recordId: { type: "string" },
|
|
174
|
+
resume: {
|
|
175
|
+
type: "object",
|
|
176
|
+
additionalProperties: false,
|
|
177
|
+
required: ["sessionRef"],
|
|
178
|
+
properties: {
|
|
179
|
+
// ResumeAnchor.sessionRef = Record<string, string>(引擎定位键值对)
|
|
180
|
+
sessionRef: { type: "object", additionalProperties: { type: "string" } },
|
|
181
|
+
journalPath: { type: "string" },
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
} as const;
|
package/src/ui-types.ts
CHANGED
|
@@ -28,11 +28,12 @@ export type UiMethod =
|
|
|
28
28
|
| "set_editor_text"
|
|
29
29
|
| (string & {});
|
|
30
30
|
|
|
31
|
-
/** UI
|
|
31
|
+
/** UI 请求(引擎侧构造后经 host/askUser 送达宿主 handler)。
|
|
32
32
|
*
|
|
33
33
|
* method 是判别字段,决定排队策略(dialog 排队)和业务路由(channel 分发)。
|
|
34
|
-
* method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1
|
|
35
|
-
* ExtensionUiRequest 平铺构造)。channel/channelPayload 由
|
|
34
|
+
* method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1,由引擎侧
|
|
35
|
+
* ui-request-queue 从 ExtensionUiRequest 平铺构造)。channel/channelPayload 由
|
|
36
|
+
* parseChannel 填充。
|
|
36
37
|
*
|
|
37
38
|
* 契约来源:.fix-plans/00-master-summary.md §二 2.2。 */
|
|
38
39
|
export interface UiRequest {
|
|
@@ -61,8 +62,10 @@ export interface UiRequest {
|
|
|
61
62
|
/** channel 解析后的结构化 payload(已 JSON.parse)。
|
|
62
63
|
* ask_user: {questions, allowCancel};gui_widget: {component};无 channel: undefined。 */
|
|
63
64
|
channelPayload?: unknown;
|
|
64
|
-
/** 内部元数据字段:发起该 UI 请求的子进程 pid
|
|
65
|
-
* child.pid
|
|
65
|
+
/** 内部元数据字段:发起该 UI 请求的子进程 pid(由引擎侧 ui-request-queue 从
|
|
66
|
+
* child.pid 填入——session-runner 已随协议化重构删除,填充点现住 pi 引擎包)。
|
|
67
|
+
* L2 队列据此关联 rejectChildDialogs(子进程退出时批量取消,见
|
|
68
|
+
* notifyChildProcessExited 的接线链)。
|
|
66
69
|
* 下划线前缀表示内部字段,非 Pi 协议字段,不参与 stdin 回写。 */
|
|
67
70
|
_childPid?: number;
|
|
68
71
|
}
|
|
@@ -78,6 +81,20 @@ export type UiResponse =
|
|
|
78
81
|
| { cancelled: true }
|
|
79
82
|
| { ack: true };
|
|
80
83
|
|
|
84
|
+
/** UiResponse 载荷结构判定(四成员判别;形态对齐 reverse-channels 的
|
|
85
|
+
* isHostStreamDeltaParams 先例)。消费方:引擎侧应答落位前守卫,防宿主畸形帧
|
|
86
|
+
* 静默流入 UI 队列(S7:askUser 应答跨界无守卫)。 */
|
|
87
|
+
export function isUiResponse(value: unknown): value is UiResponse {
|
|
88
|
+
if (typeof value !== "object" || value === null) return false;
|
|
89
|
+
const v = value as Record<string, unknown>;
|
|
90
|
+
return (
|
|
91
|
+
typeof v.value === "string" ||
|
|
92
|
+
typeof v.confirmed === "boolean" ||
|
|
93
|
+
v.cancelled === true ||
|
|
94
|
+
v.ack === true
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
81
98
|
/** UI 请求 handler 签名(单函数,按 req.method 内部路由)。
|
|
82
99
|
* 实现方负责:channel 业务路由(ask_user → AskUserComponent)+ 默认转发(ctx.ui.*)。
|
|
83
100
|
* 抛错由调用方(DialogGlobalQueue / session-runner)兜底为 {cancelled:true}。 */
|
package/dist/chunk-2DIMPZCQ.js
DELETED
|
File without changes
|