@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
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { a as AgentEvent, b as AgentFailureKind, d as AgentOutcomeUsage, f as AgentUsageTotal, g as AssertMutuallyAssignable, j as InternalToolCall, R as ReplayedTurn, T as ToolCall, l as ToolCallEntry, m as ToolCallResult, n as Turn, W as WorktreeHandle } from '../contract-types-sSlgppBC.js';
|
|
1
|
+
export { E as ENGINE_ERROR_CODE_PREFIX, a as ENGINE_PROTOCOL_ERROR_CODES, b as ENGINE_TIMEOUT_RECOVERY, c as EngineProtocolErrorCode, d as EngineSdkError, e as ErrorResponseFrame, f as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, g as ResponseFrame, h as ReverseRequestFrame, i as ReverseResponseResult, S as STDOUT_TAIL_ECHO_CHARS, j as SuccessResponseFrame, k as assertChatConversationSupported, l as engineConversationUnsupportedError, m as engineProtocolMismatchError, n as engineTimeoutDetail, o as isEngineErrorPassthroughCode, p as isEngineProtocolErrorCode, q as isNotificationFrame, r as isRequestFrame, s as isResponseFrame, t as isReverseRequestFrame, u as schemaEmulationFailedDetail } from '../error-codes-D5YlWaBx.js';
|
|
2
|
+
import { E as EngineCapabilities, M as ModelCatalogEntry, A as AgentCallOpts, i as ResumeAnchor, h as EngineHandleData, P as ProbeReport, c as AgentOutcome, S as SessionView } from '../contract-types-C71Sqq8d.js';
|
|
3
|
+
export { a as AgentEvent, b as AgentFailureKind, d as AgentOutcomeUsage, e as AgentUsage, f as AgentUsageTotal, g as AssertMutuallyAssignable, I as InternalToolCall, R as ReplayedTurn, T as ToolCall, j as ToolCallEntry, k as ToolCallResult, l as Turn, W as WorktreeHandle } from '../contract-types-C71Sqq8d.js';
|
|
5
4
|
import { UiRequest, UiResponse } from '../ui-types.js';
|
|
6
5
|
|
|
7
6
|
/** 协议版本(引擎包 manifest `xyz-agent.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
@@ -32,24 +31,25 @@ declare const ENGINE_EVENT_COALESCE_ENV = "XYZ_ENGINE_EVENT_COALESCE";
|
|
|
32
31
|
declare const ENGINE_EVENT_COALESCE_DEFAULT = "0";
|
|
33
32
|
/**
|
|
34
33
|
* 反向请求超时二分(帧④注释,R9-2):
|
|
35
|
-
* - 数据面类(host/log / host/streamDelta / host/
|
|
36
|
-
* host/childSpawned / host/childStateChanged
|
|
37
|
-
*
|
|
38
|
-
* - 人机交互类(host/askUser / host/permission):不设统一超时——core 先回 {ack:true},
|
|
34
|
+
* - 数据面类(host/log / host/streamDelta / host/handleReady /
|
|
35
|
+
* host/childSpawned / host/childStateChanged):10s 未答 = 引擎故障;
|
|
36
|
+
* - 人机交互类(host/askUser):不设统一超时——core 先回 {ack:true},
|
|
39
37
|
* 结果异步到达;按 ADR-0047「静默 ≠ 卡死」用无进展检测/用户取消,不据此判引擎故障。
|
|
40
38
|
*/
|
|
41
39
|
type ReverseRequestTimeoutClass = "data-plane" | "interaction";
|
|
42
40
|
|
|
43
|
-
/**
|
|
44
|
-
|
|
41
|
+
/**
|
|
42
|
+
* 正向方法名联合(恰好 9 个;PROTOCOL_METHODS 常量数组与之同源互证)。
|
|
43
|
+
* [H1] `interact` 成员已随 chat-run 统一退役(docs/architecture/subagent-chat-run-unification.md
|
|
44
|
+
* §3.3 D5:续聊轮统一为「新 run + resume 锚点」,U5 删除)。
|
|
45
|
+
*/
|
|
46
|
+
type ProtocolMethod = "initialize" | "probe" | "run" | "cancel" | "read" | "listModels" | "validateModel" | "dispose" | "ping";
|
|
45
47
|
/** 方法名全集(运行时顺序化枚举;与 ProtocolMethod 的同源关系由测试断言)。 */
|
|
46
|
-
declare const PROTOCOL_METHODS: readonly ["initialize", "probe", "run", "cancel", "
|
|
48
|
+
declare const PROTOCOL_METHODS: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
47
49
|
/**
|
|
48
50
|
* run 上下文(RunContext 字段映射的协议承载,设计 §3.3 RunContext 映射表)。
|
|
49
51
|
*/
|
|
50
52
|
interface RunContextParams {
|
|
51
|
-
/** 隔离池归属(journal 归属错 = 缺失后果)。 */
|
|
52
|
-
poolKey: string;
|
|
53
53
|
/** 任务工作目录(worktree 隔离时 = worktree 路径)。 */
|
|
54
54
|
cwd: string;
|
|
55
55
|
/** 请求模型 ref(未传 = 引擎缺省模型)。 */
|
|
@@ -65,19 +65,35 @@ interface RunContextParams {
|
|
|
65
65
|
};
|
|
66
66
|
/** 事件粒度请求(引擎按 capabilities.eventGranularity 实际能力执行)。 */
|
|
67
67
|
streamMode?: "stream" | "coarse";
|
|
68
|
+
/**
|
|
69
|
+
* [F6] 根 session id——pi 引擎 relay 归属键 SESSION_ID 的权威来源(生产三来源
|
|
70
|
+
* ①本字段 ②宿主 env ③根进程 env 中,宿主派发恒走①)。additive 可选:旧引擎忽略
|
|
71
|
+
* 未知字段,undefined 不上 wire。
|
|
72
|
+
*/
|
|
73
|
+
sessionRootId?: string;
|
|
74
|
+
/**
|
|
75
|
+
* [Option C 协议化] 权威 subagent session 目录——宿主以 getSubagentSessionDir
|
|
76
|
+
* (agentDir, rootCwd) 推导(宿主单一权威,Fix Gate B S6:引擎本地推导与宿主布局
|
|
77
|
+
* 三处不等价 → 跨重启续聊链断裂)。引擎用它组装 pi `--session-dir`,不自推导;
|
|
78
|
+
* 缺省(独立运行/测试)走引擎内 [LEGACY] fallback。additive 可选:旧引擎忽略
|
|
79
|
+
* 未知字段,undefined 不上 wire。
|
|
80
|
+
*/
|
|
81
|
+
sessionDir?: string;
|
|
68
82
|
}
|
|
69
83
|
/**
|
|
70
|
-
* [
|
|
71
|
-
*
|
|
84
|
+
* [H1] run 的 resume 会话形态参数(设计 docs/architecture/subagent-chat-run-unification.md
|
|
85
|
+
* §3.3 D3 + §5 U1/U6 行):原 RunChatParams(v1.x chat 会话形态参数)的泛化改名终态,
|
|
86
|
+
* 载荷同形(recordId + resume 锚点,ResumeAnchor 不变),仅键名从「chat 会话形态」
|
|
87
|
+
* 泛化为「resume 续聊」。
|
|
72
88
|
* - recordId:core 预建 record 的关联键(引擎据此回填 handle.sessionRef、上报
|
|
73
|
-
* host/childSpawned|childStateChanged
|
|
89
|
+
* host/childSpawned|childStateChanged 的 record 键形态);
|
|
74
90
|
* - resume:冷续锚点(重开已 idle 的 session 续聊;缺省 = 新 session)。对照
|
|
75
91
|
* core SpawnResumeOpts——sessionFile 经 anchor.sessionRef 携带,model/
|
|
76
92
|
* thinkingLevel 防漂移覆盖走既有 task/ctx 字段,不双写。
|
|
77
|
-
*
|
|
78
|
-
*
|
|
93
|
+
* [H1 U6 已切换] `chat` 键整体退役(读写端同批切换,无「写新读旧」窗口),本键为
|
|
94
|
+
* 唯一会话形态参数。载荷 schema 权威 = runSessionParamsSchema(schema.ts)。
|
|
79
95
|
*/
|
|
80
|
-
interface
|
|
96
|
+
interface RunResumeParams {
|
|
81
97
|
recordId: string;
|
|
82
98
|
resume?: ResumeAnchor;
|
|
83
99
|
}
|
|
@@ -109,11 +125,11 @@ interface RunParams {
|
|
|
109
125
|
task: AgentCallOpts;
|
|
110
126
|
ctx: RunContextParams;
|
|
111
127
|
/**
|
|
112
|
-
* [
|
|
113
|
-
*
|
|
114
|
-
* 帧级 schema params
|
|
128
|
+
* [H1 U6 终态] resume 续聊参数(唯一会话形态键;原 v1.x `chat` 键已随键切换退役,
|
|
129
|
+
* 见 RunResumeParams)。缺省 = 一次性任务形态(向后兼容:旧引擎忽略未知字段,
|
|
130
|
+
* 帧级 schema params 不做深校验)。additive 可选:undefined 不上 wire。
|
|
115
131
|
*/
|
|
116
|
-
|
|
132
|
+
resume?: RunResumeParams;
|
|
117
133
|
}
|
|
118
134
|
/** run 终态应答(期间事件经 event 通知;长运行方法,应答到达即终态)。 */
|
|
119
135
|
interface RunResult {
|
|
@@ -131,10 +147,6 @@ interface CancelParams {
|
|
|
131
147
|
interface CancelResult {
|
|
132
148
|
ok: true;
|
|
133
149
|
}
|
|
134
|
-
interface InteractParams {
|
|
135
|
-
handle: EngineHandleData;
|
|
136
|
-
action: InteractAction;
|
|
137
|
-
}
|
|
138
150
|
interface ReadParams {
|
|
139
151
|
handle: EngineHandleData;
|
|
140
152
|
/** 数据根必填:存量池时代引擎自算池/journal 相对 dbPath 的定位需要它(设计钉死)。 */
|
|
@@ -174,7 +186,6 @@ interface ProtocolParamsMap {
|
|
|
174
186
|
probe: ProbeParams;
|
|
175
187
|
run: RunParams;
|
|
176
188
|
cancel: CancelParams;
|
|
177
|
-
interact: InteractParams;
|
|
178
189
|
read: ReadParams;
|
|
179
190
|
listModels: ListModelsParams;
|
|
180
191
|
validateModel: ValidateModelParams;
|
|
@@ -187,7 +198,6 @@ interface ProtocolResultMap {
|
|
|
187
198
|
probe: ProbeReport;
|
|
188
199
|
run: RunResult;
|
|
189
200
|
cancel: CancelResult;
|
|
190
|
-
interact: InteractResult;
|
|
191
201
|
read: SessionView;
|
|
192
202
|
listModels: ListModelsResult;
|
|
193
203
|
validateModel: ValidateModelResult;
|
|
@@ -195,13 +205,17 @@ interface ProtocolResultMap {
|
|
|
195
205
|
ping: PingResult;
|
|
196
206
|
}
|
|
197
207
|
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
|
|
208
|
+
/**
|
|
209
|
+
* 反向通道名联合(恰好 6 个;REVERSE_CHANNELS 常量数组与之同源互证)。
|
|
210
|
+
*/
|
|
211
|
+
type ReverseChannel = "host/log" | "host/askUser" | "host/streamDelta" | "host/handleReady" | "host/childSpawned" | "host/childStateChanged";
|
|
212
|
+
/**
|
|
213
|
+
* 通道名全集(运行时顺序化枚举;与 ReverseChannel 的同源关系由测试断言)。
|
|
214
|
+
*/
|
|
215
|
+
declare const REVERSE_CHANNELS: readonly ["host/log", "host/askUser", "host/streamDelta", "host/handleReady", "host/childSpawned", "host/childStateChanged"];
|
|
201
216
|
/**
|
|
202
217
|
* 超时二分归属(10s 数据面 / 不设统一超时的人机交互面)。实现归 W2 EngineClient;
|
|
203
218
|
* 引擎侧自灭计时(W12)复用同表——已 ack 的 askUser 等待不计入 in-flight(R9-2)。
|
|
204
|
-
* host/roundLifecycle 属数据面(终态回执语义:宿主必须确认收到,10s 未答 = 引擎故障)。
|
|
205
219
|
*/
|
|
206
220
|
declare const REVERSE_CHANNEL_TIMEOUT_CLASS: Record<ReverseChannel, ReverseRequestTimeoutClass>;
|
|
207
221
|
/** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用面)。 */
|
|
@@ -219,61 +233,24 @@ interface HostAskUserParams {
|
|
|
219
233
|
}
|
|
220
234
|
/** host/askUser 的最终结果(ack 两阶段第二阶段,异步应答帧②的 result)。 */
|
|
221
235
|
type HostAskUserResult = UiResponse;
|
|
222
|
-
/**
|
|
223
|
-
* host/permission:权限询问(引擎请求宿主裁决工具执行)。
|
|
224
|
-
* v1 骨架字段(设计未钉死载荷细节,细化归各引擎提取设计;W2 实装 core 应答端时
|
|
225
|
-
* 若需扩展走 additive 演进)。
|
|
226
|
-
*/
|
|
227
|
-
interface HostPermissionParams {
|
|
228
|
-
runId: string;
|
|
229
|
-
toolName: string;
|
|
230
|
-
args?: unknown;
|
|
231
|
-
/** 请求方向引擎给出的原因/说明(展示用)。 */
|
|
232
|
-
reason?: string;
|
|
233
|
-
}
|
|
234
|
-
/** host/permission 两阶段结果。 */
|
|
235
|
-
type HostPermissionResult = {
|
|
236
|
-
approved: boolean;
|
|
237
|
-
} | {
|
|
238
|
-
unsupported: true;
|
|
239
|
-
};
|
|
240
236
|
/**
|
|
241
237
|
* host/streamDelta:UI 实时通道(双通道之一;与 event 通知并行的渲染加速面)。
|
|
242
238
|
*
|
|
243
|
-
* [
|
|
244
|
-
*
|
|
245
|
-
* run 帧分配);
|
|
246
|
-
* - interact 发起的续聊轮:**recordId** 关联(续聊轮无独立 runId——InteractParams/
|
|
247
|
-
* InteractResult 均不含,recordId 经 handle.sessionRef 送达引擎)。
|
|
248
|
-
* 两键互斥(undefined 孪生位防双填),消费侧经 isHostStreamDeltaParams 收窄。
|
|
239
|
+
* 关联键恒为 runId(runId 由 core 在 run 帧分配);[H1] chat 续聊轮经 resume run
|
|
240
|
+
* 复用 runId 关联(原 recordId 关联键随 interact 面退役删除)。
|
|
249
241
|
*/
|
|
250
|
-
|
|
242
|
+
interface HostStreamDeltaParams {
|
|
251
243
|
runId: string;
|
|
252
|
-
recordId?: undefined;
|
|
253
244
|
delta: string;
|
|
254
|
-
} | {
|
|
255
|
-
recordId: string;
|
|
256
|
-
runId?: undefined;
|
|
257
|
-
delta: string;
|
|
258
|
-
};
|
|
259
|
-
/** streamDelta 载荷结构判定(关联键互斥 + delta 形状;消费侧共用,防双侧各写一份)。 */
|
|
260
|
-
declare function isHostStreamDeltaParams(value: unknown): value is HostStreamDeltaParams;
|
|
261
|
-
/**
|
|
262
|
-
* host/poolResolved:journal 落盘路径单一权威(契约:必须在首个事件 emit 前调用——
|
|
263
|
-
* 否则 journal 归属错)。载荷 = core onPoolResolved(poolKey) 的 runId 关联形态。
|
|
264
|
-
*/
|
|
265
|
-
interface HostPoolResolvedParams {
|
|
266
|
-
runId: string;
|
|
267
|
-
poolKey: string;
|
|
268
245
|
}
|
|
269
246
|
/**
|
|
270
247
|
* host/handleReady:运行中句柄回填(core onHandleReady 语义:session/create 应答后、
|
|
271
248
|
* 早于 run resolve;AGENTS.md 关键规则 9「重开 session 仍可见」的前提)。
|
|
249
|
+
* [池抽象降级 2026-09-13] 原 poolKey 字段已随协议面 poolKey 退役删除。
|
|
272
250
|
*/
|
|
273
251
|
interface HostHandleReadyParams {
|
|
274
252
|
runId: string;
|
|
275
253
|
sessionRef: Record<string, string>;
|
|
276
|
-
poolKey: string;
|
|
277
254
|
}
|
|
278
255
|
/**
|
|
279
256
|
* host/childSpawned:引擎内一次性子进程 pid 上报。
|
|
@@ -298,95 +275,6 @@ interface HostChildStateChangedParams {
|
|
|
298
275
|
exitCode?: number;
|
|
299
276
|
signal?: string;
|
|
300
277
|
}
|
|
301
|
-
/**
|
|
302
|
-
* 轮次关联键(D1-A 裁定的类型面):run 域轮 = runId(v1 现状);interact 续聊轮 =
|
|
303
|
-
* recordId(经 handle.sessionRef)。undefined 孪生位保证两键互斥。
|
|
304
|
-
*/
|
|
305
|
-
interface RoundKeyedByRun {
|
|
306
|
-
runId: string;
|
|
307
|
-
recordId?: undefined;
|
|
308
|
-
}
|
|
309
|
-
interface RoundKeyedByRecord {
|
|
310
|
-
recordId: string;
|
|
311
|
-
runId?: undefined;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* 轮次终态相位(事件即 record 回写载体——chat 域 record 处置由相位一一映射,
|
|
315
|
-
* 设计 D2 裁决表 conversation 行:settled/idle 轮收口不终态、failed 标 failed):
|
|
316
|
-
* - settled:轮收敛(输出完整)。消费点 = settled-watchdog disarm + D3 abort
|
|
317
|
-
* 收敛判据(cancel 受理后等本事件,超 CANCEL_SETTLE_GRACE_MS 走杀链);
|
|
318
|
-
* - idle:轮收口 + 会话进 idle 稳态(core 侧 doFinalizeRoundToIdle + idle 定时器
|
|
319
|
-
* 锚点)。settled 与 idle 是两个锚点:watchdog 在 settled 即解除,idle 管置闲;
|
|
320
|
-
* - failed:轮异常终止(引擎自知失败,如 EPIPE 兜底耗尽)——error 如实上报,
|
|
321
|
-
* record 标 failed(与 run 域 AgentOutcome.error 的「失败收口」语义对齐)。
|
|
322
|
-
* usage 为本轮 message_end 增量(interact 续聊轮无 event 通知通道,用量经本帧回填)。
|
|
323
|
-
* 不设 seq:stdio NDJSON 单连接有序 + 数据面应答确认,无重排/重放面(与 event
|
|
324
|
-
* 通知的 seq 对照——后者镜像进程内事件流基线,本帧无基线可镜像)。
|
|
325
|
-
*/
|
|
326
|
-
interface RoundSettledPhase {
|
|
327
|
-
phase: "settled";
|
|
328
|
-
usage?: AgentUsage;
|
|
329
|
-
}
|
|
330
|
-
interface RoundIdlePhase {
|
|
331
|
-
phase: "idle";
|
|
332
|
-
usage?: AgentUsage;
|
|
333
|
-
/** 冷续锚点回填(session 滚动/compaction 后锚点可能变化,宿主按帧刷新)。 */
|
|
334
|
-
anchor?: ResumeAnchor;
|
|
335
|
-
}
|
|
336
|
-
interface RoundFailedPhase {
|
|
337
|
-
phase: "failed";
|
|
338
|
-
/** 失败原因(结构对齐协议 error 帧——code/message/recovery 可操作闭环)。 */
|
|
339
|
-
error: ProtocolError;
|
|
340
|
-
anchor?: ResumeAnchor;
|
|
341
|
-
}
|
|
342
|
-
/** 相位联合(消费侧 switch(phase) 判别用)。 */
|
|
343
|
-
type RoundLifecyclePhase = RoundSettledPhase | RoundIdlePhase | RoundFailedPhase;
|
|
344
|
-
/** host/roundLifecycle 载荷:关联键(run|record)× 相位(settled|idle|failed)。 */
|
|
345
|
-
type HostRoundLifecycleParams = (RoundKeyedByRun & RoundSettledPhase) | (RoundKeyedByRun & RoundIdlePhase) | (RoundKeyedByRun & RoundFailedPhase) | (RoundKeyedByRecord & RoundSettledPhase) | (RoundKeyedByRecord & RoundIdlePhase) | (RoundKeyedByRecord & RoundFailedPhase);
|
|
346
|
-
/**
|
|
347
|
-
* roundLifecycle 载荷结构判定:关联键互斥 + phase 词表 + 各相位专属形状
|
|
348
|
-
* (failed 必含 error.code/message)。引擎侧发帧前自检与 core 侧消费共用,
|
|
349
|
-
* 防两侧各写一份判别(与 isHostStreamDeltaParams 同理)。
|
|
350
|
-
*/
|
|
351
|
-
declare function isHostRoundLifecycleParams(value: unknown): value is HostRoundLifecycleParams;
|
|
352
|
-
/** 通道 → 载荷类型映射。 */
|
|
353
|
-
interface ReverseChannelParamsMap {
|
|
354
|
-
"host/log": HostLogParams;
|
|
355
|
-
"host/askUser": HostAskUserParams;
|
|
356
|
-
"host/permission": HostPermissionParams;
|
|
357
|
-
"host/streamDelta": HostStreamDeltaParams;
|
|
358
|
-
"host/poolResolved": HostPoolResolvedParams;
|
|
359
|
-
"host/handleReady": HostHandleReadyParams;
|
|
360
|
-
"host/childSpawned": HostChildSpawnedParams;
|
|
361
|
-
"host/childStateChanged": HostChildStateChangedParams;
|
|
362
|
-
"host/roundLifecycle": HostRoundLifecycleParams;
|
|
363
|
-
}
|
|
364
|
-
/** 通道 → 异步/同步结果类型映射(ack 两阶段通道的第二阶段 result)。 */
|
|
365
|
-
interface ReverseChannelResultMap {
|
|
366
|
-
"host/log": {
|
|
367
|
-
ok: true;
|
|
368
|
-
};
|
|
369
|
-
"host/askUser": HostAskUserResult;
|
|
370
|
-
"host/permission": HostPermissionResult;
|
|
371
|
-
"host/streamDelta": {
|
|
372
|
-
ok: true;
|
|
373
|
-
};
|
|
374
|
-
"host/poolResolved": {
|
|
375
|
-
ok: true;
|
|
376
|
-
};
|
|
377
|
-
"host/handleReady": {
|
|
378
|
-
ok: true;
|
|
379
|
-
};
|
|
380
|
-
"host/childSpawned": {
|
|
381
|
-
ok: true;
|
|
382
|
-
};
|
|
383
|
-
"host/childStateChanged": {
|
|
384
|
-
ok: true;
|
|
385
|
-
};
|
|
386
|
-
"host/roundLifecycle": {
|
|
387
|
-
ok: true;
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
278
|
|
|
391
279
|
/** 协议错误对象 schema。 */
|
|
392
280
|
declare const protocolErrorSchema: {
|
|
@@ -424,7 +312,7 @@ declare const requestFrameSchema: {
|
|
|
424
312
|
};
|
|
425
313
|
readonly method: {
|
|
426
314
|
readonly type: "string";
|
|
427
|
-
readonly enum: readonly ["initialize", "probe", "run", "cancel", "
|
|
315
|
+
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
428
316
|
};
|
|
429
317
|
readonly params: {};
|
|
430
318
|
};
|
|
@@ -506,7 +394,7 @@ declare const notificationFrameSchema: {
|
|
|
506
394
|
readonly properties: {
|
|
507
395
|
readonly type: {
|
|
508
396
|
readonly type: "string";
|
|
509
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "error"];
|
|
397
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error"];
|
|
510
398
|
};
|
|
511
399
|
};
|
|
512
400
|
};
|
|
@@ -527,7 +415,7 @@ declare const reverseRequestFrameSchema: {
|
|
|
527
415
|
};
|
|
528
416
|
readonly method: {
|
|
529
417
|
readonly type: "string";
|
|
530
|
-
readonly enum: readonly ["host/log", "host/askUser", "host/
|
|
418
|
+
readonly enum: readonly ["host/log", "host/askUser", "host/streamDelta", "host/handleReady", "host/childSpawned", "host/childStateChanged"];
|
|
531
419
|
};
|
|
532
420
|
readonly params: {};
|
|
533
421
|
};
|
|
@@ -546,7 +434,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
546
434
|
};
|
|
547
435
|
readonly method: {
|
|
548
436
|
readonly type: "string";
|
|
549
|
-
readonly enum: readonly ["initialize", "probe", "run", "cancel", "
|
|
437
|
+
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
550
438
|
};
|
|
551
439
|
readonly params: {};
|
|
552
440
|
};
|
|
@@ -626,7 +514,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
626
514
|
readonly properties: {
|
|
627
515
|
readonly type: {
|
|
628
516
|
readonly type: "string";
|
|
629
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "error"];
|
|
517
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error"];
|
|
630
518
|
};
|
|
631
519
|
};
|
|
632
520
|
};
|
|
@@ -646,7 +534,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
646
534
|
};
|
|
647
535
|
readonly method: {
|
|
648
536
|
readonly type: "string";
|
|
649
|
-
readonly enum: readonly ["host/log", "host/askUser", "host/
|
|
537
|
+
readonly enum: readonly ["host/log", "host/askUser", "host/streamDelta", "host/handleReady", "host/childSpawned", "host/childStateChanged"];
|
|
650
538
|
};
|
|
651
539
|
readonly params: {};
|
|
652
540
|
};
|
|
@@ -679,7 +567,42 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
679
567
|
* 不得出现。词表覆盖常见拼写(子串匹配,非精确枚举)。
|
|
680
568
|
*/
|
|
681
569
|
declare const FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: readonly ["apikey", "api_key", "token", "credential", "password", "secret"];
|
|
682
|
-
/**
|
|
683
|
-
|
|
570
|
+
/**
|
|
571
|
+
* run.params 的会话形态参数载荷 schema(draft-07 深载荷片段)。设计权威源:
|
|
572
|
+
* docs/architecture/subagent-chat-run-unification.md §3.3 D3 + §5 U1/U6 行。
|
|
573
|
+
*
|
|
574
|
+
* [H1 U6 已切换] 键切换单批完成后本 schema 面向唯一键 `resume`(RunResumeParams:
|
|
575
|
+
* recordId + 可选 ResumeAnchor),形状不变。帧级 schema(requestFrameSchema.params)
|
|
576
|
+
* 刻意不做深校验(见本文件头注释),本片段供消费方(引擎读端结构化报错 / 测试正负
|
|
577
|
+
* 样本)按需深校验。
|
|
578
|
+
*/
|
|
579
|
+
declare const runSessionParamsSchema: {
|
|
580
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
581
|
+
readonly title: "EngineRunSessionParams";
|
|
582
|
+
readonly type: "object";
|
|
583
|
+
readonly additionalProperties: false;
|
|
584
|
+
readonly required: readonly ["recordId"];
|
|
585
|
+
readonly properties: {
|
|
586
|
+
readonly recordId: {
|
|
587
|
+
readonly type: "string";
|
|
588
|
+
};
|
|
589
|
+
readonly resume: {
|
|
590
|
+
readonly type: "object";
|
|
591
|
+
readonly additionalProperties: false;
|
|
592
|
+
readonly required: readonly ["sessionRef"];
|
|
593
|
+
readonly properties: {
|
|
594
|
+
readonly sessionRef: {
|
|
595
|
+
readonly type: "object";
|
|
596
|
+
readonly additionalProperties: {
|
|
597
|
+
readonly type: "string";
|
|
598
|
+
};
|
|
599
|
+
};
|
|
600
|
+
readonly journalPath: {
|
|
601
|
+
readonly type: "string";
|
|
602
|
+
};
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
};
|
|
684
607
|
|
|
685
|
-
export { AgentCallOpts, AgentOutcome,
|
|
608
|
+
export { AgentCallOpts, AgentOutcome, CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, type CancelParams, type CancelResult, type DisposeParams, type DisposeResult, ENGINE_EVENT_COALESCE_DEFAULT, ENGINE_EVENT_COALESCE_ENV, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, EngineCapabilities, EngineHandleData, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, type InitializeParams, type InitializeResult, type ListModelsParams, type ListModelsResult, ModelCatalogEntry, PROTOCOL_METHODS, type PingParams, type PingResult, type ProbeParams, ProbeReport, type ProtocolMethod, type ProtocolParamsMap, type ProtocolResultMap, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReadParams, ResumeAnchor, type ReverseChannel, type ReverseRequestTimeoutClass, type RunContextParams, type RunParams, type RunResult, type RunResumeParams, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, SessionView, type ValidateModelParams, type ValidateModelResult, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
|
package/dist/protocol/index.js
CHANGED
|
@@ -3,11 +3,8 @@ import {
|
|
|
3
3
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
4
4
|
PROTOCOL_METHODS,
|
|
5
5
|
REVERSE_CHANNELS,
|
|
6
|
-
REVERSE_CHANNEL_NAMES,
|
|
7
6
|
REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
8
7
|
errorResponseFrameSchema,
|
|
9
|
-
isHostRoundLifecycleParams,
|
|
10
|
-
isHostStreamDeltaParams,
|
|
11
8
|
isNotificationFrame,
|
|
12
9
|
isRequestFrame,
|
|
13
10
|
isResponseFrame,
|
|
@@ -16,8 +13,9 @@ import {
|
|
|
16
13
|
protocolErrorSchema,
|
|
17
14
|
requestFrameSchema,
|
|
18
15
|
reverseRequestFrameSchema,
|
|
16
|
+
runSessionParamsSchema,
|
|
19
17
|
successResponseFrameSchema
|
|
20
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-TW2FAMAJ.js";
|
|
21
19
|
import {
|
|
22
20
|
CANCEL_SETTLE_GRACE_MS,
|
|
23
21
|
CRASH_REBUILD_BACKOFF_MS,
|
|
@@ -42,7 +40,7 @@ import {
|
|
|
42
40
|
isEngineProtocolErrorCode,
|
|
43
41
|
isProtocolVersionCompatible,
|
|
44
42
|
schemaEmulationFailedDetail
|
|
45
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-WS4WAZVR.js";
|
|
46
44
|
import "../chunk-JSBRDJBE.js";
|
|
47
45
|
export {
|
|
48
46
|
CANCEL_SETTLE_GRACE_MS,
|
|
@@ -60,7 +58,6 @@ export {
|
|
|
60
58
|
HANDSHAKE_TIMEOUT_MS,
|
|
61
59
|
PROTOCOL_METHODS,
|
|
62
60
|
REVERSE_CHANNELS,
|
|
63
|
-
REVERSE_CHANNEL_NAMES,
|
|
64
61
|
REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
65
62
|
REVERSE_REQUEST_TIMEOUT_MS,
|
|
66
63
|
STDERR_TAIL_CHARS,
|
|
@@ -73,8 +70,6 @@ export {
|
|
|
73
70
|
errorResponseFrameSchema,
|
|
74
71
|
isEngineErrorPassthroughCode,
|
|
75
72
|
isEngineProtocolErrorCode,
|
|
76
|
-
isHostRoundLifecycleParams,
|
|
77
|
-
isHostStreamDeltaParams,
|
|
78
73
|
isNotificationFrame,
|
|
79
74
|
isProtocolVersionCompatible,
|
|
80
75
|
isRequestFrame,
|
|
@@ -84,6 +79,7 @@ export {
|
|
|
84
79
|
protocolErrorSchema,
|
|
85
80
|
requestFrameSchema,
|
|
86
81
|
reverseRequestFrameSchema,
|
|
82
|
+
runSessionParamsSchema,
|
|
87
83
|
schemaEmulationFailedDetail,
|
|
88
84
|
successResponseFrameSchema
|
|
89
85
|
};
|
package/dist/ui-types.cjs
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,4 +19,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
15
19
|
|
|
16
20
|
// src/ui-types.ts
|
|
17
21
|
var ui_types_exports = {};
|
|
22
|
+
__export(ui_types_exports, {
|
|
23
|
+
isUiResponse: () => isUiResponse
|
|
24
|
+
});
|
|
18
25
|
module.exports = __toCommonJS(ui_types_exports);
|
|
26
|
+
function isUiResponse(value) {
|
|
27
|
+
if (typeof value !== "object" || value === null) return false;
|
|
28
|
+
const v = value;
|
|
29
|
+
return typeof v.value === "string" || typeof v.confirmed === "boolean" || v.cancelled === true || v.ack === true;
|
|
30
|
+
}
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
isUiResponse
|
|
34
|
+
});
|
package/dist/ui-types.d.cts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* fire-and-forget 类:notify/setStatus/setWidget/setTitle/set_editor_text(纯展示/写入)。
|
|
4
4
|
* (string & {}) 兜底:Pi 未来新增 method 或未知 method 走字符串字面量类型。 */
|
|
5
5
|
type UiMethod = "select" | "confirm" | "input" | "editor" | "notify" | "setStatus" | "setWidget" | "setTitle" | "set_editor_text" | (string & {});
|
|
6
|
-
/** UI
|
|
6
|
+
/** UI 请求(引擎侧构造后经 host/askUser 送达宿主 handler)。
|
|
7
7
|
*
|
|
8
8
|
* method 是判别字段,决定排队策略(dialog 排队)和业务路由(channel 分发)。
|
|
9
|
-
* method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1
|
|
10
|
-
* ExtensionUiRequest 平铺构造)。channel/channelPayload 由
|
|
9
|
+
* method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1,由引擎侧
|
|
10
|
+
* ui-request-queue 从 ExtensionUiRequest 平铺构造)。channel/channelPayload 由
|
|
11
|
+
* parseChannel 填充。
|
|
11
12
|
*
|
|
12
13
|
* 契约来源:.fix-plans/00-master-summary.md §二 2.2。 */
|
|
13
14
|
interface UiRequest {
|
|
@@ -35,8 +36,10 @@ interface UiRequest {
|
|
|
35
36
|
/** channel 解析后的结构化 payload(已 JSON.parse)。
|
|
36
37
|
* ask_user: {questions, allowCancel};gui_widget: {component};无 channel: undefined。 */
|
|
37
38
|
channelPayload?: unknown;
|
|
38
|
-
/** 内部元数据字段:发起该 UI 请求的子进程 pid
|
|
39
|
-
* child.pid
|
|
39
|
+
/** 内部元数据字段:发起该 UI 请求的子进程 pid(由引擎侧 ui-request-queue 从
|
|
40
|
+
* child.pid 填入——session-runner 已随协议化重构删除,填充点现住 pi 引擎包)。
|
|
41
|
+
* L2 队列据此关联 rejectChildDialogs(子进程退出时批量取消,见
|
|
42
|
+
* notifyChildProcessExited 的接线链)。
|
|
40
43
|
* 下划线前缀表示内部字段,非 Pi 协议字段,不参与 stdin 回写。 */
|
|
41
44
|
_childPid?: number;
|
|
42
45
|
}
|
|
@@ -54,9 +57,13 @@ type UiResponse = {
|
|
|
54
57
|
} | {
|
|
55
58
|
ack: true;
|
|
56
59
|
};
|
|
60
|
+
/** UiResponse 载荷结构判定(四成员判别;形态对齐 reverse-channels 的
|
|
61
|
+
* isHostStreamDeltaParams 先例)。消费方:引擎侧应答落位前守卫,防宿主畸形帧
|
|
62
|
+
* 静默流入 UI 队列(S7:askUser 应答跨界无守卫)。 */
|
|
63
|
+
declare function isUiResponse(value: unknown): value is UiResponse;
|
|
57
64
|
/** UI 请求 handler 签名(单函数,按 req.method 内部路由)。
|
|
58
65
|
* 实现方负责:channel 业务路由(ask_user → AskUserComponent)+ 默认转发(ctx.ui.*)。
|
|
59
66
|
* 抛错由调用方(DialogGlobalQueue / session-runner)兜底为 {cancelled:true}。 */
|
|
60
67
|
type UiRequestHandler = (req: UiRequest) => Promise<UiResponse>;
|
|
61
68
|
|
|
62
|
-
export type
|
|
69
|
+
export { type UiMethod, type UiRequest, type UiRequestHandler, type UiResponse, isUiResponse };
|
package/dist/ui-types.d.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* fire-and-forget 类:notify/setStatus/setWidget/setTitle/set_editor_text(纯展示/写入)。
|
|
4
4
|
* (string & {}) 兜底:Pi 未来新增 method 或未知 method 走字符串字面量类型。 */
|
|
5
5
|
type UiMethod = "select" | "confirm" | "input" | "editor" | "notify" | "setStatus" | "setWidget" | "setTitle" | "set_editor_text" | (string & {});
|
|
6
|
-
/** UI
|
|
6
|
+
/** UI 请求(引擎侧构造后经 host/askUser 送达宿主 handler)。
|
|
7
7
|
*
|
|
8
8
|
* method 是判别字段,决定排队策略(dialog 排队)和业务路由(channel 分发)。
|
|
9
|
-
* method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1
|
|
10
|
-
* ExtensionUiRequest 平铺构造)。channel/channelPayload 由
|
|
9
|
+
* method 特定字段按 method 可选出现(与 ExtensionUiRequest 1:1,由引擎侧
|
|
10
|
+
* ui-request-queue 从 ExtensionUiRequest 平铺构造)。channel/channelPayload 由
|
|
11
|
+
* parseChannel 填充。
|
|
11
12
|
*
|
|
12
13
|
* 契约来源:.fix-plans/00-master-summary.md §二 2.2。 */
|
|
13
14
|
interface UiRequest {
|
|
@@ -35,8 +36,10 @@ interface UiRequest {
|
|
|
35
36
|
/** channel 解析后的结构化 payload(已 JSON.parse)。
|
|
36
37
|
* ask_user: {questions, allowCancel};gui_widget: {component};无 channel: undefined。 */
|
|
37
38
|
channelPayload?: unknown;
|
|
38
|
-
/** 内部元数据字段:发起该 UI 请求的子进程 pid
|
|
39
|
-
* child.pid
|
|
39
|
+
/** 内部元数据字段:发起该 UI 请求的子进程 pid(由引擎侧 ui-request-queue 从
|
|
40
|
+
* child.pid 填入——session-runner 已随协议化重构删除,填充点现住 pi 引擎包)。
|
|
41
|
+
* L2 队列据此关联 rejectChildDialogs(子进程退出时批量取消,见
|
|
42
|
+
* notifyChildProcessExited 的接线链)。
|
|
40
43
|
* 下划线前缀表示内部字段,非 Pi 协议字段,不参与 stdin 回写。 */
|
|
41
44
|
_childPid?: number;
|
|
42
45
|
}
|
|
@@ -54,9 +57,13 @@ type UiResponse = {
|
|
|
54
57
|
} | {
|
|
55
58
|
ack: true;
|
|
56
59
|
};
|
|
60
|
+
/** UiResponse 载荷结构判定(四成员判别;形态对齐 reverse-channels 的
|
|
61
|
+
* isHostStreamDeltaParams 先例)。消费方:引擎侧应答落位前守卫,防宿主畸形帧
|
|
62
|
+
* 静默流入 UI 队列(S7:askUser 应答跨界无守卫)。 */
|
|
63
|
+
declare function isUiResponse(value: unknown): value is UiResponse;
|
|
57
64
|
/** UI 请求 handler 签名(单函数,按 req.method 内部路由)。
|
|
58
65
|
* 实现方负责:channel 业务路由(ask_user → AskUserComponent)+ 默认转发(ctx.ui.*)。
|
|
59
66
|
* 抛错由调用方(DialogGlobalQueue / session-runner)兜底为 {cancelled:true}。 */
|
|
60
67
|
type UiRequestHandler = (req: UiRequest) => Promise<UiResponse>;
|
|
61
68
|
|
|
62
|
-
export type
|
|
69
|
+
export { type UiMethod, type UiRequest, type UiRequestHandler, type UiResponse, isUiResponse };
|
package/dist/ui-types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/subagent-engine-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Engine-side SDK for the subagent engine protocol: NDJSON stdio contract types, engine primitives (schema emulation, nesting guard, kill chain, journal replay projection, data-dir/paths resolution) — the shared contract root between subagent-core and engine CLI packages (engines import SDK only, never core)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/cli-entry.ts
CHANGED
|
@@ -51,7 +51,12 @@ export function runEngineCliEntry(opts: RunEngineCliEntryOptions): void {
|
|
|
51
51
|
log(level, component, message, data) {
|
|
52
52
|
// stderr 兜底先落(反向通道未就绪/失败时日志不丢);host/log 为数据面反向请求
|
|
53
53
|
// (10s 应答分类),失败吞掉——日志面不能拖垮主链路。
|
|
54
|
-
|
|
54
|
+
// debug 不写 stderr:对齐 logger.ts CONSOLE_SINK 的「debug no-op」语义——
|
|
55
|
+
// 引擎 stderr 落宿主 [rpc:stderr] 全量 ERROR 级链路,debug 刷屏会淹没真异常
|
|
56
|
+
// (常态路径的分级降噪依赖此跳过);host/log 反向请求仍全级别透传。
|
|
57
|
+
if (level !== "debug") {
|
|
58
|
+
process.stderr.write(`[${level}] [${component}] ${message}${data !== undefined ? ` ${JSON.stringify(data)}` : ""}\n`);
|
|
59
|
+
}
|
|
55
60
|
void server.reverseRequest("host/log", { level, component, message }).catch(() => undefined);
|
|
56
61
|
},
|
|
57
62
|
});
|
package/src/data-dir.ts
CHANGED
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
// warn-once 语义(回退非权威通道必须可观测),与 core 版行为逐字对齐。
|
|
13
13
|
//
|
|
14
14
|
// 通道调查结论(2026-08-25,P2 实测证据链,自 core 版头部保留):
|
|
15
|
-
// - runtime spawn pi 主会话时 RpcClient
|
|
16
|
-
// XYZ_
|
|
15
|
+
// - runtime spawn pi 主会话时 RpcClient 出站 env 从 runtime process.env 继承
|
|
16
|
+
// XYZ_ 前缀白名单变量(调查当时经私有 buildSafeEnv,现已被 buildPiOutboundEnv
|
|
17
|
+
// → buildOutboundChildEnv 共享构建器取代),且显式设置 PI_CODING_AGENT_DIR;
|
|
17
18
|
// - dev 模式 Electron main 设置 XYZ_AGENT_DATA_DIR(apps/electron/main/main.ts:122),
|
|
18
19
|
// 经 process-control.ts:262 透传给 runtime → 透传链成立;
|
|
19
20
|
// - prod 默认路径(~/.xyz-agent 缺省)下 runtime 进程 env 中**没有**该变量
|