@zhushanwen/subagent-engine-sdk 0.7.1 → 0.8.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/best-effort.cjs +9 -1
- package/dist/best-effort.js +2 -2
- package/dist/{chunk-X24IVQKJ.js → chunk-3FVBDH3X.js} +3 -2
- package/dist/{chunk-YL5W5EMV.js → chunk-AF2ETADP.js} +1 -1
- package/dist/chunk-D36ZIQQK.js +28 -0
- package/dist/{chunk-W23PAAGX.js → chunk-DIIYVO4O.js} +1 -27
- package/dist/{chunk-RCT7L777.js → chunk-F7VDVSBZ.js} +1 -1
- package/dist/{chunk-HERD6RIR.js → chunk-MQPASWMA.js} +2 -2
- package/dist/{chunk-75QEMUGV.js → chunk-NXNNXGTY.js} +10 -1
- package/dist/{chunk-EJMF63R5.js → chunk-QMEHSKNR.js} +1 -1
- package/dist/{chunk-J4G2MXDS.js → chunk-VE3NVT7K.js} +1 -1
- package/dist/cli-entry.cjs +9 -1
- package/dist/cli-entry.js +2 -2
- package/dist/{contract-types-DiWyGRXr.d.cts → contract-types-DqOD58r-.d.cts} +7 -12
- package/dist/{contract-types-DiWyGRXr.d.ts → contract-types-DqOD58r-.d.ts} +7 -12
- package/dist/data-dir.cjs +10 -2
- package/dist/data-dir.js +2 -2
- package/dist/env.cjs +9 -1
- package/dist/env.d.cts +6 -6
- package/dist/env.d.ts +6 -6
- package/dist/env.js +2 -2
- package/dist/error-codes-C3oVToMr.d.cts +311 -0
- package/dist/error-codes-CiDwaODz.d.ts +311 -0
- package/dist/index.cjs +41 -3
- package/dist/index.d.cts +31 -3
- package/dist/index.d.ts +31 -3
- package/dist/index.js +62 -31
- package/dist/journal-io.d.cts +1 -1
- package/dist/journal-io.d.ts +1 -1
- package/dist/journal-replay.d.cts +1 -1
- package/dist/journal-replay.d.ts +1 -1
- package/dist/kill-chain.cjs +9 -1
- package/dist/kill-chain.d.cts +1 -1
- package/dist/kill-chain.d.ts +1 -1
- package/dist/kill-chain.js +2 -2
- package/dist/logger.cjs +11 -1
- package/dist/logger.js +1 -1
- package/dist/port-contract.d.cts +12 -6
- package/dist/port-contract.d.ts +12 -6
- package/dist/protocol/index.cjs +1 -1
- package/dist/protocol/index.d.cts +4 -296
- package/dist/protocol/index.d.ts +4 -296
- package/dist/protocol/index.js +7 -5
- package/dist/server/index.cjs +217 -0
- package/dist/server/index.d.cts +146 -0
- package/dist/server/index.d.ts +146 -0
- package/dist/server/index.js +143 -0
- package/dist/spawn.cjs +9 -1
- package/dist/spawn.js +3 -3
- package/package.json +12 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export { A as AGENT_EVENT_TYPE_NAMES, c as AgentEventTypeName, d as AgentFailureKind, f as AgentOutcomeUsage, g as AgentUsage, h as AgentUsageTotal, i as AssertMutuallyAssignable, k as EngineProcessModel, I as InternalToolCall, R as ReplayedTurn, T as ToolCall, m as ToolCallEntry, n as ToolCallResult, o as Turn, W as WorktreeHandle } from '../contract-types-DiWyGRXr.cjs';
|
|
1
|
+
export { C as CancelParams, b as CancelResult, D as DisposeParams, c as DisposeResult, d as ENGINE_ERROR_CODE_PREFIX, e as ENGINE_PROTOCOL_ERROR_CODES, f as ENGINE_TIMEOUT_RECOVERY, g as EngineProtocolErrorCode, E as EngineSdkError, h as ErrorResponseFrame, i as EventNotificationParams, a as InitializeParams, I as InitializeResult, L as ListModelsParams, j as ListModelsResult, N as NotificationFrame, P as PROTOCOL_METHODS, k as PingParams, l as PingResult, m as ProbeParams, n as ProtocolError, o as ProtocolMethod, p as ProtocolParamsMap, q as ProtocolResultMap, r as ReadParams, s as RequestFrame, t as ResponseFrame, u as ReverseRequestFrame, v as ReverseResponseResult, R as RunContextParams, w as RunParams, x as RunResult, y as RunResumeParams, S as STDOUT_TAIL_ECHO_CHARS, z as SuccessResponseFrame, V as ValidateModelParams, A as ValidateModelResult, B as assertChatConversationSupported, F as engineConversationUnsupportedError, G as engineProtocolMismatchError, H as engineTimeoutDetail, J as isEngineErrorPassthroughCode, K as isEngineProtocolErrorCode, M as isNotificationFrame, O as isRequestFrame, Q as isResponseFrame, T as isReverseRequestFrame, U as schemaEmulationFailedDetail } from '../error-codes-C3oVToMr.cjs';
|
|
3
2
|
import { UiRequest, UiResponse } from '../ui-types.cjs';
|
|
3
|
+
export { f as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, g as AgentEventTypeName, h as AgentFailureKind, c as AgentOutcome, i as AgentOutcomeUsage, j as AgentUsage, a as AgentUsageTotal, k as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, l as EngineProcessModel, I as InternalToolCall, M as ModelCatalogEntry, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, m as ToolCall, n as ToolCallEntry, o as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-DqOD58r-.cjs';
|
|
4
4
|
|
|
5
5
|
/** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
6
6
|
declare const ENGINE_PROTOCOL_VERSION = 1;
|
|
@@ -34,246 +34,6 @@ declare const STDERR_TAIL_CHARS = 400;
|
|
|
34
34
|
*/
|
|
35
35
|
type ReverseRequestTimeoutClass = "data-plane" | "interaction";
|
|
36
36
|
|
|
37
|
-
/** 协议错误对象(error 帧载荷与反向请求错误应答共用形态)。 */
|
|
38
|
-
interface ProtocolError {
|
|
39
|
-
/** 错误码(error-codes.ts 词表 + 其余 engine_* 引擎自报透传)。 */
|
|
40
|
-
code: string;
|
|
41
|
-
/** 人类可读详情。 */
|
|
42
|
-
message: string;
|
|
43
|
-
/** 恢复指引:指向具体下一步(命令 / 配置路径 / 升级动作),非安慰性文案。 */
|
|
44
|
-
recovery: string;
|
|
45
|
-
/** 结构化附参(如 engine_protocol_mismatch 的双方版本)。 */
|
|
46
|
-
data?: Record<string, unknown>;
|
|
47
|
-
}
|
|
48
|
-
interface RequestFrame {
|
|
49
|
-
id: number;
|
|
50
|
-
method: string;
|
|
51
|
-
params: unknown;
|
|
52
|
-
}
|
|
53
|
-
interface SuccessResponseFrame {
|
|
54
|
-
id: number | string;
|
|
55
|
-
result: unknown;
|
|
56
|
-
}
|
|
57
|
-
interface ErrorResponseFrame {
|
|
58
|
-
id: number | string;
|
|
59
|
-
error: ProtocolError;
|
|
60
|
-
}
|
|
61
|
-
type ResponseFrame = SuccessResponseFrame | ErrorResponseFrame;
|
|
62
|
-
/** event 通知载荷:runId 关联在途 run;seq 单调递增(基线①结构等价断言对象)。 */
|
|
63
|
-
interface EventNotificationParams {
|
|
64
|
-
runId: string;
|
|
65
|
-
seq: number;
|
|
66
|
-
event: AgentEvent;
|
|
67
|
-
}
|
|
68
|
-
interface NotificationFrame {
|
|
69
|
-
method: "event";
|
|
70
|
-
params: EventNotificationParams;
|
|
71
|
-
}
|
|
72
|
-
interface ReverseRequestFrame {
|
|
73
|
-
id: string;
|
|
74
|
-
method: string;
|
|
75
|
-
params: unknown;
|
|
76
|
-
}
|
|
77
|
-
/** 反向请求的应答(core → 引擎,沿 ResponseFrame 通道回传;id = 反向请求 id 原样)。 */
|
|
78
|
-
type ReverseResponseResult =
|
|
79
|
-
/** 数据面类:处理确认。 */
|
|
80
|
-
{
|
|
81
|
-
ok: true;
|
|
82
|
-
}
|
|
83
|
-
/** 人机交互类(askUser)两阶段第一阶段:已受理,结果异步到达(R9-2)。 */
|
|
84
|
-
| {
|
|
85
|
-
ack: true;
|
|
86
|
-
}
|
|
87
|
-
/** 未实现或宿主未知的通道(宽容语义③:由 askUser 语境泛化到全通道——宿主对未知 host/* 通道回 unsupported,引擎自行降级)。 */
|
|
88
|
-
| {
|
|
89
|
-
unsupported: true;
|
|
90
|
-
};
|
|
91
|
-
/** ① 请求:有数字 id + method + params,且无 result/error(与②应答区分)。 */
|
|
92
|
-
declare function isRequestFrame(frame: unknown): frame is RequestFrame;
|
|
93
|
-
/** ② 应答:有 id(number|string)且 result/error 二选一。 */
|
|
94
|
-
declare function isResponseFrame(frame: unknown): frame is ResponseFrame;
|
|
95
|
-
/** ③ 通知:无 id,method === "event",params 含 runId/seq/event。 */
|
|
96
|
-
declare function isNotificationFrame(frame: unknown): frame is NotificationFrame;
|
|
97
|
-
/** ④ 反向请求:有字符串 id + host/* method + params(与①的区别 = id 形态与 method 前缀)。 */
|
|
98
|
-
declare function isReverseRequestFrame(frame: unknown): frame is ReverseRequestFrame;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* 正向方法名联合(恰好 9 个;PROTOCOL_METHODS 常量数组与之同源互证)。
|
|
102
|
-
* [H1] `interact` 成员已随 chat-run 统一退役(docs/architecture/subagent-chat-run-unification.md
|
|
103
|
-
* §3.3 D5:续聊轮统一为「新 run + resume 锚点」,U5 删除)。
|
|
104
|
-
*/
|
|
105
|
-
type ProtocolMethod = "initialize" | "probe" | "run" | "cancel" | "read" | "listModels" | "validateModel" | "dispose" | "ping";
|
|
106
|
-
/** 方法名全集(运行时顺序化枚举;与 ProtocolMethod 的同源关系由测试断言)。 */
|
|
107
|
-
declare const PROTOCOL_METHODS: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
108
|
-
/**
|
|
109
|
-
* run 上下文(RunContext 字段映射的协议承载,设计 §3.3 RunContext 映射表)。
|
|
110
|
-
*/
|
|
111
|
-
interface RunContextParams {
|
|
112
|
-
/** 任务工作目录(worktree 隔离时 = worktree 路径)。缺省不上 wire——引擎侧
|
|
113
|
-
* 回退自身进程 cwd(spawn 继承语义)。 */
|
|
114
|
-
cwd?: string;
|
|
115
|
-
/** 请求模型 ref(未传 = 引擎缺省模型)。 */
|
|
116
|
-
model?: string;
|
|
117
|
-
/** 上下文模型 ref(与 run 模型分离的 ctx 模型)。 */
|
|
118
|
-
ctxModel?: string;
|
|
119
|
-
/** fallback 留痕(引擎回填 outcome.engineFallback 的种子)。 */
|
|
120
|
-
engineFallback?: {
|
|
121
|
-
from: string;
|
|
122
|
-
reason: string;
|
|
123
|
-
};
|
|
124
|
-
/** 事件粒度请求(引擎按 capabilities.eventGranularity 实际能力执行)。 */
|
|
125
|
-
streamMode?: "stream" | "coarse";
|
|
126
|
-
/**
|
|
127
|
-
* [F6] 根 session id——pi 引擎 relay 归属键 SESSION_ID 的权威来源(生产三来源
|
|
128
|
-
* ①本字段 ②宿主 env ③根进程 env 中,宿主派发恒走①)。additive 可选:旧引擎忽略
|
|
129
|
-
* 未知字段,undefined 不上 wire。
|
|
130
|
-
*/
|
|
131
|
-
sessionRootId?: string;
|
|
132
|
-
/**
|
|
133
|
-
* [Option C 协议化] 权威 subagent session 目录——宿主以 getSubagentSessionDir
|
|
134
|
-
* (agentDir, rootCwd) 推导(宿主单一权威,Fix Gate B S6:引擎本地推导与宿主布局
|
|
135
|
-
* 三处不等价 → 跨重启续聊链断裂)。引擎用它组装 pi `--session-dir`,不自推导;
|
|
136
|
-
* 缺省(独立运行/测试)走引擎内 [LEGACY] fallback。additive 可选:旧引擎忽略
|
|
137
|
-
* 未知字段,undefined 不上 wire。
|
|
138
|
-
*/
|
|
139
|
-
sessionDir?: string;
|
|
140
|
-
/**
|
|
141
|
-
* [D2 扩展加载显式化] 孙进程显式加载的扩展路径集(pi 引擎侧逐项拼
|
|
142
|
-
* `--extension` argv)。per-host 常量而非 per-run 变量,故落 ctx。宿主侧来源
|
|
143
|
-
* 双形态:taiji 宿主 = extension-service 下发的白名单收窄集(经 pi-host 注入);
|
|
144
|
-
* 独立 pi = subagent-workflow 自身 optional peerDep 解析回退。additive 可选:
|
|
145
|
-
* 旧引擎忽略未知字段,undefined 不上 wire。
|
|
146
|
-
*/
|
|
147
|
-
extensionPaths?: string[];
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* [H1] run 的 resume 会话形态参数(设计 docs/architecture/subagent-chat-run-unification.md
|
|
151
|
-
* §3.3 D3 + §5 U1/U6 行):原 RunChatParams(v1.x chat 会话形态参数)的泛化改名终态,
|
|
152
|
-
* 载荷同形(recordId + resume 锚点,ResumeAnchor 不变),仅键名从「chat 会话形态」
|
|
153
|
-
* 泛化为「resume 续聊」。
|
|
154
|
-
* - recordId:core 预建 record 的关联键(引擎据此回填 handle.sessionRef、上报
|
|
155
|
-
* host/childSpawned|childStateChanged 的 record 键形态);
|
|
156
|
-
* - resume:冷续锚点(重开已 idle 的 session 续聊;缺省 = 新 session)。对照
|
|
157
|
-
* core SpawnResumeOpts——sessionFile 经 anchor.sessionRef 携带,model/
|
|
158
|
-
* thinkingLevel 防漂移覆盖走既有 task/ctx 字段,不双写。
|
|
159
|
-
* [H1 U6 已切换] `chat` 键整体退役(读写端同批切换,无「写新读旧」窗口),本键为
|
|
160
|
-
* 唯一会话形态参数。载荷 schema 权威 = runSessionParamsSchema(schema.ts)。
|
|
161
|
-
*/
|
|
162
|
-
interface RunResumeParams {
|
|
163
|
-
recordId: string;
|
|
164
|
-
resume?: ResumeAnchor;
|
|
165
|
-
}
|
|
166
|
-
/** initialize 参数(engineConfig = L3 显式配置 engines.<id>.config 透传,不放凭据)。 */
|
|
167
|
-
interface InitializeParams {
|
|
168
|
-
protocolVersion: number;
|
|
169
|
-
hostInfo: {
|
|
170
|
-
name: string;
|
|
171
|
-
version: string;
|
|
172
|
-
dataRoot: string;
|
|
173
|
-
};
|
|
174
|
-
engineConfig: Record<string, string>;
|
|
175
|
-
}
|
|
176
|
-
/** initialize 应答(仅诊断面:capabilities/models 与 manifest 不一致 → warn,不参与判据)。 */
|
|
177
|
-
interface InitializeResult {
|
|
178
|
-
protocolVersion: number;
|
|
179
|
-
engineId: string;
|
|
180
|
-
engineVersion: string;
|
|
181
|
-
adapterVersion: string;
|
|
182
|
-
capabilities: EngineCapabilities;
|
|
183
|
-
/** 模型目录(诊断面;省略/null = 无枚举面语义)。 */
|
|
184
|
-
models?: ModelCatalogEntry[] | null;
|
|
185
|
-
}
|
|
186
|
-
interface ProbeParams {
|
|
187
|
-
force?: boolean;
|
|
188
|
-
}
|
|
189
|
-
interface RunParams {
|
|
190
|
-
runId: string;
|
|
191
|
-
task: AgentCallOpts;
|
|
192
|
-
ctx: RunContextParams;
|
|
193
|
-
/**
|
|
194
|
-
* [H1 U6 终态] resume 续聊参数(唯一会话形态键;原 v1.x `chat` 键已随键切换退役,
|
|
195
|
-
* 见 RunResumeParams)。缺省 = 一次性任务形态(向后兼容:旧引擎忽略未知字段,
|
|
196
|
-
* 帧级 schema params 不做深校验)。additive 可选:undefined 不上 wire。
|
|
197
|
-
*/
|
|
198
|
-
resume?: RunResumeParams;
|
|
199
|
-
}
|
|
200
|
-
/** run 终态应答(期间事件经 event 通知;长运行方法,应答到达即终态)。 */
|
|
201
|
-
interface RunResult {
|
|
202
|
-
handle: EngineHandleData;
|
|
203
|
-
outcome: AgentOutcome;
|
|
204
|
-
}
|
|
205
|
-
interface CancelParams {
|
|
206
|
-
runId: string;
|
|
207
|
-
reason: string;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* cancel 应答(受理确认)。终态本体由该 run 的 run 终态应答承载(abort 合成终态经
|
|
211
|
-
* event/终态应答到达);引擎须 CANCEL_SETTLE_GRACE_MS(3s)内收敛,超时 core 走杀链。
|
|
212
|
-
*/
|
|
213
|
-
interface CancelResult {
|
|
214
|
-
ok: true;
|
|
215
|
-
}
|
|
216
|
-
interface ReadParams {
|
|
217
|
-
handle: EngineHandleData;
|
|
218
|
-
/** 数据根(core 每次 read 都发送——remote-engine 构造注入的数据目录)。两引擎
|
|
219
|
-
* server 现行均不消费该字段:定位走 handle.data(journalPath 等)或引擎自身
|
|
220
|
-
* 数据目录。保留为协议帧字段(历史:存量池时代引擎自算池/journal 相对 dbPath
|
|
221
|
-
* 的定位需要它)。 */
|
|
222
|
-
dataDir: string;
|
|
223
|
-
}
|
|
224
|
-
interface ListModelsParams {
|
|
225
|
-
/** 占位空参(帧形状一致性;未来诊断参数在此扩展)。 */
|
|
226
|
-
_placeholder?: never;
|
|
227
|
-
}
|
|
228
|
-
interface ListModelsResult {
|
|
229
|
-
/** 数组 = 有枚举面;null = 无枚举面(buildCoreAlignedHint 语义,与 manifest 省略对齐)。 */
|
|
230
|
-
models: ModelCatalogEntry[] | null;
|
|
231
|
-
}
|
|
232
|
-
interface ValidateModelParams {
|
|
233
|
-
modelRef?: string;
|
|
234
|
-
}
|
|
235
|
-
interface ValidateModelResult {
|
|
236
|
-
canonicalRef: string;
|
|
237
|
-
}
|
|
238
|
-
interface DisposeParams {
|
|
239
|
-
/** 占位空参(帧形状一致性;幂等语义)。 */
|
|
240
|
-
_placeholder?: never;
|
|
241
|
-
}
|
|
242
|
-
interface DisposeResult {
|
|
243
|
-
ok: true;
|
|
244
|
-
}
|
|
245
|
-
interface PingParams {
|
|
246
|
-
/** 占位空参(帧形状一致性)。 */
|
|
247
|
-
_placeholder?: never;
|
|
248
|
-
}
|
|
249
|
-
interface PingResult {
|
|
250
|
-
pong: true;
|
|
251
|
-
}
|
|
252
|
-
/** 方法 → params 类型映射。 */
|
|
253
|
-
interface ProtocolParamsMap {
|
|
254
|
-
initialize: InitializeParams;
|
|
255
|
-
probe: ProbeParams;
|
|
256
|
-
run: RunParams;
|
|
257
|
-
cancel: CancelParams;
|
|
258
|
-
read: ReadParams;
|
|
259
|
-
listModels: ListModelsParams;
|
|
260
|
-
validateModel: ValidateModelParams;
|
|
261
|
-
dispose: DisposeParams;
|
|
262
|
-
ping: PingParams;
|
|
263
|
-
}
|
|
264
|
-
/** 方法 → result 类型映射。 */
|
|
265
|
-
interface ProtocolResultMap {
|
|
266
|
-
initialize: InitializeResult;
|
|
267
|
-
probe: ProbeReport;
|
|
268
|
-
run: RunResult;
|
|
269
|
-
cancel: CancelResult;
|
|
270
|
-
read: SessionView;
|
|
271
|
-
listModels: ListModelsResult;
|
|
272
|
-
validateModel: ValidateModelResult;
|
|
273
|
-
dispose: DisposeResult;
|
|
274
|
-
ping: PingResult;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
37
|
/**
|
|
278
38
|
* 反向通道名联合(恰好 6 个;REVERSE_CHANNELS 常量数组与之同源互证)。
|
|
279
39
|
*/
|
|
@@ -345,58 +105,6 @@ interface HostChildStateChangedParams {
|
|
|
345
105
|
signal?: string;
|
|
346
106
|
}
|
|
347
107
|
|
|
348
|
-
/** 协议核心错误码(引擎 error 帧 + core 同步拦截共用的固定词表)。 */
|
|
349
|
-
declare const ENGINE_PROTOCOL_ERROR_CODES: readonly ["engine_not_found", "engine_protocol_mismatch", "engine_capability_unsupported", "engine_capability_mismatch", "engine_model_unknown", "engine_model_mismatch", "engine_handshake_timeout", "engine_crashed", "engine_probe_failed"];
|
|
350
|
-
type EngineProtocolErrorCode = (typeof ENGINE_PROTOCOL_ERROR_CODES)[number];
|
|
351
|
-
/** unknown → 协议错误码收窄(外部输入携带错误码时的运行时 guard;其余 engine_* 走透传)。 */
|
|
352
|
-
declare function isEngineProtocolErrorCode(value: unknown): value is EngineProtocolErrorCode;
|
|
353
|
-
/** 其余引擎自报错误码的前缀契约(透传面;core 不解释文案)。 */
|
|
354
|
-
declare const ENGINE_ERROR_CODE_PREFIX = "engine_";
|
|
355
|
-
declare function isEngineErrorPassthroughCode(value: string): boolean;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* 结构化引擎错误(message 恒为 `<code>: <detail>` 前缀格式——AgentOutcome.error 与
|
|
359
|
-
* 协议 error 帧共用的错误码前缀约定);recovery 指向恢复动作。
|
|
360
|
-
* toStructured() 产出即协议 ProtocolError 形态(error 帧载荷直用)。
|
|
361
|
-
*/
|
|
362
|
-
declare class EngineSdkError extends Error {
|
|
363
|
-
readonly code: string;
|
|
364
|
-
readonly recovery: string;
|
|
365
|
-
readonly data?: Record<string, unknown>;
|
|
366
|
-
constructor(code: string, detail: string, recovery: string, data?: Record<string, unknown>);
|
|
367
|
-
/** 协议 error 帧载荷投影。 */
|
|
368
|
-
toStructured(): ProtocolError;
|
|
369
|
-
}
|
|
370
|
-
declare function engineProtocolMismatchError(engineVersion: number): EngineSdkError;
|
|
371
|
-
/**
|
|
372
|
-
* 引擎 conversation 位拒绝的具名错误([modeless 波2] 语义:无 resume 续聊通道的
|
|
373
|
-
* 引擎,message 续聊资格被拒——manifest conversation 能力轴消费;[modeless 波5
|
|
374
|
-
* 收尾] core capability-gate 的显式参数分支随派发参数删除退役,本构造器消费方 =
|
|
375
|
-
* 引擎侧 resume gate(assertChatConversationSupported)与 message 资格门)。
|
|
376
|
-
* 文案契约:错误码 engine_capability_unsupported + 「换引擎续聊 / 修 manifest /
|
|
377
|
-
* 升级引擎包」恢复指引,两侧一致防漂移。
|
|
378
|
-
*/
|
|
379
|
-
declare function engineConversationUnsupportedError(engineId: string): EngineSdkError;
|
|
380
|
-
/**
|
|
381
|
-
* resume 会话形态(run.params.resume——唯一会话形态键)派发前的同步 gate:
|
|
382
|
-
* manifest conversation 位 unsupported 即抛 engineConversationUnsupportedError
|
|
383
|
-
* ——进程/record 创建前同步拒(A6 方向防御:manifest/实装漂移时引擎侧自拒,
|
|
384
|
-
* 与 core capability-gate 同一能力位,防两侧判据漂移)。[modeless 波2] 协议
|
|
385
|
-
* task 的 conversation 键已删,本 gate 只对 resume 形态键生效。
|
|
386
|
-
*/
|
|
387
|
-
declare function assertChatConversationSupported(engineId: string, capabilities: Pick<EngineCapabilities, "conversation">): void;
|
|
388
|
-
/** stdout 尾部回显上限(engine_timeout / engine_run_failed 的错误规格载体系数)。 */
|
|
389
|
-
declare const STDOUT_TAIL_ECHO_CHARS = 2000;
|
|
390
|
-
/** engine_timeout 的恢复指引(kill-chain 超时杀链收尾文案)。 */
|
|
391
|
-
declare const ENGINE_TIMEOUT_RECOVERY: string;
|
|
392
|
-
/**
|
|
393
|
-
* engine_timeout 的 outcome.error 文案:含 stdout 尾部 2000 字 + 恢复指引
|
|
394
|
-
* (kill-chain synthesizeTimeoutOutcome 消费;与 core errors.ts engineTimeoutDetail 逐字等价)。
|
|
395
|
-
*/
|
|
396
|
-
declare function engineTimeoutDetail(stdoutTail: string): string;
|
|
397
|
-
/** schema_emulation_failed 的终报文案(宿主编排层「重试一次仍失败」后消费)。 */
|
|
398
|
-
declare function schemaEmulationFailedDetail(error: string, tail: string): string;
|
|
399
|
-
|
|
400
108
|
/** 协议错误对象 schema。 */
|
|
401
109
|
declare const protocolErrorSchema: {
|
|
402
110
|
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
@@ -718,7 +426,7 @@ declare const runSessionParamsSchema: {
|
|
|
718
426
|
readonly type: "string";
|
|
719
427
|
};
|
|
720
428
|
};
|
|
721
|
-
readonly
|
|
429
|
+
readonly eventsPath: {
|
|
722
430
|
readonly type: "string";
|
|
723
431
|
};
|
|
724
432
|
};
|
|
@@ -726,4 +434,4 @@ declare const runSessionParamsSchema: {
|
|
|
726
434
|
};
|
|
727
435
|
};
|
|
728
436
|
|
|
729
|
-
export {
|
|
437
|
+
export { CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReverseChannel, type ReverseRequestTimeoutClass, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export { A as AGENT_EVENT_TYPE_NAMES, c as AgentEventTypeName, d as AgentFailureKind, f as AgentOutcomeUsage, g as AgentUsage, h as AgentUsageTotal, i as AssertMutuallyAssignable, k as EngineProcessModel, I as InternalToolCall, R as ReplayedTurn, T as ToolCall, m as ToolCallEntry, n as ToolCallResult, o as Turn, W as WorktreeHandle } from '../contract-types-DiWyGRXr.js';
|
|
1
|
+
export { C as CancelParams, b as CancelResult, D as DisposeParams, c as DisposeResult, d as ENGINE_ERROR_CODE_PREFIX, e as ENGINE_PROTOCOL_ERROR_CODES, f as ENGINE_TIMEOUT_RECOVERY, g as EngineProtocolErrorCode, E as EngineSdkError, h as ErrorResponseFrame, i as EventNotificationParams, a as InitializeParams, I as InitializeResult, L as ListModelsParams, j as ListModelsResult, N as NotificationFrame, P as PROTOCOL_METHODS, k as PingParams, l as PingResult, m as ProbeParams, n as ProtocolError, o as ProtocolMethod, p as ProtocolParamsMap, q as ProtocolResultMap, r as ReadParams, s as RequestFrame, t as ResponseFrame, u as ReverseRequestFrame, v as ReverseResponseResult, R as RunContextParams, w as RunParams, x as RunResult, y as RunResumeParams, S as STDOUT_TAIL_ECHO_CHARS, z as SuccessResponseFrame, V as ValidateModelParams, A as ValidateModelResult, B as assertChatConversationSupported, F as engineConversationUnsupportedError, G as engineProtocolMismatchError, H as engineTimeoutDetail, J as isEngineErrorPassthroughCode, K as isEngineProtocolErrorCode, M as isNotificationFrame, O as isRequestFrame, Q as isResponseFrame, T as isReverseRequestFrame, U as schemaEmulationFailedDetail } from '../error-codes-CiDwaODz.js';
|
|
3
2
|
import { UiRequest, UiResponse } from '../ui-types.js';
|
|
3
|
+
export { f as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, g as AgentEventTypeName, h as AgentFailureKind, c as AgentOutcome, i as AgentOutcomeUsage, j as AgentUsage, a as AgentUsageTotal, k as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, l as EngineProcessModel, I as InternalToolCall, M as ModelCatalogEntry, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, m as ToolCall, n as ToolCallEntry, o as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-DqOD58r-.js';
|
|
4
4
|
|
|
5
5
|
/** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
6
6
|
declare const ENGINE_PROTOCOL_VERSION = 1;
|
|
@@ -34,246 +34,6 @@ declare const STDERR_TAIL_CHARS = 400;
|
|
|
34
34
|
*/
|
|
35
35
|
type ReverseRequestTimeoutClass = "data-plane" | "interaction";
|
|
36
36
|
|
|
37
|
-
/** 协议错误对象(error 帧载荷与反向请求错误应答共用形态)。 */
|
|
38
|
-
interface ProtocolError {
|
|
39
|
-
/** 错误码(error-codes.ts 词表 + 其余 engine_* 引擎自报透传)。 */
|
|
40
|
-
code: string;
|
|
41
|
-
/** 人类可读详情。 */
|
|
42
|
-
message: string;
|
|
43
|
-
/** 恢复指引:指向具体下一步(命令 / 配置路径 / 升级动作),非安慰性文案。 */
|
|
44
|
-
recovery: string;
|
|
45
|
-
/** 结构化附参(如 engine_protocol_mismatch 的双方版本)。 */
|
|
46
|
-
data?: Record<string, unknown>;
|
|
47
|
-
}
|
|
48
|
-
interface RequestFrame {
|
|
49
|
-
id: number;
|
|
50
|
-
method: string;
|
|
51
|
-
params: unknown;
|
|
52
|
-
}
|
|
53
|
-
interface SuccessResponseFrame {
|
|
54
|
-
id: number | string;
|
|
55
|
-
result: unknown;
|
|
56
|
-
}
|
|
57
|
-
interface ErrorResponseFrame {
|
|
58
|
-
id: number | string;
|
|
59
|
-
error: ProtocolError;
|
|
60
|
-
}
|
|
61
|
-
type ResponseFrame = SuccessResponseFrame | ErrorResponseFrame;
|
|
62
|
-
/** event 通知载荷:runId 关联在途 run;seq 单调递增(基线①结构等价断言对象)。 */
|
|
63
|
-
interface EventNotificationParams {
|
|
64
|
-
runId: string;
|
|
65
|
-
seq: number;
|
|
66
|
-
event: AgentEvent;
|
|
67
|
-
}
|
|
68
|
-
interface NotificationFrame {
|
|
69
|
-
method: "event";
|
|
70
|
-
params: EventNotificationParams;
|
|
71
|
-
}
|
|
72
|
-
interface ReverseRequestFrame {
|
|
73
|
-
id: string;
|
|
74
|
-
method: string;
|
|
75
|
-
params: unknown;
|
|
76
|
-
}
|
|
77
|
-
/** 反向请求的应答(core → 引擎,沿 ResponseFrame 通道回传;id = 反向请求 id 原样)。 */
|
|
78
|
-
type ReverseResponseResult =
|
|
79
|
-
/** 数据面类:处理确认。 */
|
|
80
|
-
{
|
|
81
|
-
ok: true;
|
|
82
|
-
}
|
|
83
|
-
/** 人机交互类(askUser)两阶段第一阶段:已受理,结果异步到达(R9-2)。 */
|
|
84
|
-
| {
|
|
85
|
-
ack: true;
|
|
86
|
-
}
|
|
87
|
-
/** 未实现或宿主未知的通道(宽容语义③:由 askUser 语境泛化到全通道——宿主对未知 host/* 通道回 unsupported,引擎自行降级)。 */
|
|
88
|
-
| {
|
|
89
|
-
unsupported: true;
|
|
90
|
-
};
|
|
91
|
-
/** ① 请求:有数字 id + method + params,且无 result/error(与②应答区分)。 */
|
|
92
|
-
declare function isRequestFrame(frame: unknown): frame is RequestFrame;
|
|
93
|
-
/** ② 应答:有 id(number|string)且 result/error 二选一。 */
|
|
94
|
-
declare function isResponseFrame(frame: unknown): frame is ResponseFrame;
|
|
95
|
-
/** ③ 通知:无 id,method === "event",params 含 runId/seq/event。 */
|
|
96
|
-
declare function isNotificationFrame(frame: unknown): frame is NotificationFrame;
|
|
97
|
-
/** ④ 反向请求:有字符串 id + host/* method + params(与①的区别 = id 形态与 method 前缀)。 */
|
|
98
|
-
declare function isReverseRequestFrame(frame: unknown): frame is ReverseRequestFrame;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* 正向方法名联合(恰好 9 个;PROTOCOL_METHODS 常量数组与之同源互证)。
|
|
102
|
-
* [H1] `interact` 成员已随 chat-run 统一退役(docs/architecture/subagent-chat-run-unification.md
|
|
103
|
-
* §3.3 D5:续聊轮统一为「新 run + resume 锚点」,U5 删除)。
|
|
104
|
-
*/
|
|
105
|
-
type ProtocolMethod = "initialize" | "probe" | "run" | "cancel" | "read" | "listModels" | "validateModel" | "dispose" | "ping";
|
|
106
|
-
/** 方法名全集(运行时顺序化枚举;与 ProtocolMethod 的同源关系由测试断言)。 */
|
|
107
|
-
declare const PROTOCOL_METHODS: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
108
|
-
/**
|
|
109
|
-
* run 上下文(RunContext 字段映射的协议承载,设计 §3.3 RunContext 映射表)。
|
|
110
|
-
*/
|
|
111
|
-
interface RunContextParams {
|
|
112
|
-
/** 任务工作目录(worktree 隔离时 = worktree 路径)。缺省不上 wire——引擎侧
|
|
113
|
-
* 回退自身进程 cwd(spawn 继承语义)。 */
|
|
114
|
-
cwd?: string;
|
|
115
|
-
/** 请求模型 ref(未传 = 引擎缺省模型)。 */
|
|
116
|
-
model?: string;
|
|
117
|
-
/** 上下文模型 ref(与 run 模型分离的 ctx 模型)。 */
|
|
118
|
-
ctxModel?: string;
|
|
119
|
-
/** fallback 留痕(引擎回填 outcome.engineFallback 的种子)。 */
|
|
120
|
-
engineFallback?: {
|
|
121
|
-
from: string;
|
|
122
|
-
reason: string;
|
|
123
|
-
};
|
|
124
|
-
/** 事件粒度请求(引擎按 capabilities.eventGranularity 实际能力执行)。 */
|
|
125
|
-
streamMode?: "stream" | "coarse";
|
|
126
|
-
/**
|
|
127
|
-
* [F6] 根 session id——pi 引擎 relay 归属键 SESSION_ID 的权威来源(生产三来源
|
|
128
|
-
* ①本字段 ②宿主 env ③根进程 env 中,宿主派发恒走①)。additive 可选:旧引擎忽略
|
|
129
|
-
* 未知字段,undefined 不上 wire。
|
|
130
|
-
*/
|
|
131
|
-
sessionRootId?: string;
|
|
132
|
-
/**
|
|
133
|
-
* [Option C 协议化] 权威 subagent session 目录——宿主以 getSubagentSessionDir
|
|
134
|
-
* (agentDir, rootCwd) 推导(宿主单一权威,Fix Gate B S6:引擎本地推导与宿主布局
|
|
135
|
-
* 三处不等价 → 跨重启续聊链断裂)。引擎用它组装 pi `--session-dir`,不自推导;
|
|
136
|
-
* 缺省(独立运行/测试)走引擎内 [LEGACY] fallback。additive 可选:旧引擎忽略
|
|
137
|
-
* 未知字段,undefined 不上 wire。
|
|
138
|
-
*/
|
|
139
|
-
sessionDir?: string;
|
|
140
|
-
/**
|
|
141
|
-
* [D2 扩展加载显式化] 孙进程显式加载的扩展路径集(pi 引擎侧逐项拼
|
|
142
|
-
* `--extension` argv)。per-host 常量而非 per-run 变量,故落 ctx。宿主侧来源
|
|
143
|
-
* 双形态:taiji 宿主 = extension-service 下发的白名单收窄集(经 pi-host 注入);
|
|
144
|
-
* 独立 pi = subagent-workflow 自身 optional peerDep 解析回退。additive 可选:
|
|
145
|
-
* 旧引擎忽略未知字段,undefined 不上 wire。
|
|
146
|
-
*/
|
|
147
|
-
extensionPaths?: string[];
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* [H1] run 的 resume 会话形态参数(设计 docs/architecture/subagent-chat-run-unification.md
|
|
151
|
-
* §3.3 D3 + §5 U1/U6 行):原 RunChatParams(v1.x chat 会话形态参数)的泛化改名终态,
|
|
152
|
-
* 载荷同形(recordId + resume 锚点,ResumeAnchor 不变),仅键名从「chat 会话形态」
|
|
153
|
-
* 泛化为「resume 续聊」。
|
|
154
|
-
* - recordId:core 预建 record 的关联键(引擎据此回填 handle.sessionRef、上报
|
|
155
|
-
* host/childSpawned|childStateChanged 的 record 键形态);
|
|
156
|
-
* - resume:冷续锚点(重开已 idle 的 session 续聊;缺省 = 新 session)。对照
|
|
157
|
-
* core SpawnResumeOpts——sessionFile 经 anchor.sessionRef 携带,model/
|
|
158
|
-
* thinkingLevel 防漂移覆盖走既有 task/ctx 字段,不双写。
|
|
159
|
-
* [H1 U6 已切换] `chat` 键整体退役(读写端同批切换,无「写新读旧」窗口),本键为
|
|
160
|
-
* 唯一会话形态参数。载荷 schema 权威 = runSessionParamsSchema(schema.ts)。
|
|
161
|
-
*/
|
|
162
|
-
interface RunResumeParams {
|
|
163
|
-
recordId: string;
|
|
164
|
-
resume?: ResumeAnchor;
|
|
165
|
-
}
|
|
166
|
-
/** initialize 参数(engineConfig = L3 显式配置 engines.<id>.config 透传,不放凭据)。 */
|
|
167
|
-
interface InitializeParams {
|
|
168
|
-
protocolVersion: number;
|
|
169
|
-
hostInfo: {
|
|
170
|
-
name: string;
|
|
171
|
-
version: string;
|
|
172
|
-
dataRoot: string;
|
|
173
|
-
};
|
|
174
|
-
engineConfig: Record<string, string>;
|
|
175
|
-
}
|
|
176
|
-
/** initialize 应答(仅诊断面:capabilities/models 与 manifest 不一致 → warn,不参与判据)。 */
|
|
177
|
-
interface InitializeResult {
|
|
178
|
-
protocolVersion: number;
|
|
179
|
-
engineId: string;
|
|
180
|
-
engineVersion: string;
|
|
181
|
-
adapterVersion: string;
|
|
182
|
-
capabilities: EngineCapabilities;
|
|
183
|
-
/** 模型目录(诊断面;省略/null = 无枚举面语义)。 */
|
|
184
|
-
models?: ModelCatalogEntry[] | null;
|
|
185
|
-
}
|
|
186
|
-
interface ProbeParams {
|
|
187
|
-
force?: boolean;
|
|
188
|
-
}
|
|
189
|
-
interface RunParams {
|
|
190
|
-
runId: string;
|
|
191
|
-
task: AgentCallOpts;
|
|
192
|
-
ctx: RunContextParams;
|
|
193
|
-
/**
|
|
194
|
-
* [H1 U6 终态] resume 续聊参数(唯一会话形态键;原 v1.x `chat` 键已随键切换退役,
|
|
195
|
-
* 见 RunResumeParams)。缺省 = 一次性任务形态(向后兼容:旧引擎忽略未知字段,
|
|
196
|
-
* 帧级 schema params 不做深校验)。additive 可选:undefined 不上 wire。
|
|
197
|
-
*/
|
|
198
|
-
resume?: RunResumeParams;
|
|
199
|
-
}
|
|
200
|
-
/** run 终态应答(期间事件经 event 通知;长运行方法,应答到达即终态)。 */
|
|
201
|
-
interface RunResult {
|
|
202
|
-
handle: EngineHandleData;
|
|
203
|
-
outcome: AgentOutcome;
|
|
204
|
-
}
|
|
205
|
-
interface CancelParams {
|
|
206
|
-
runId: string;
|
|
207
|
-
reason: string;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* cancel 应答(受理确认)。终态本体由该 run 的 run 终态应答承载(abort 合成终态经
|
|
211
|
-
* event/终态应答到达);引擎须 CANCEL_SETTLE_GRACE_MS(3s)内收敛,超时 core 走杀链。
|
|
212
|
-
*/
|
|
213
|
-
interface CancelResult {
|
|
214
|
-
ok: true;
|
|
215
|
-
}
|
|
216
|
-
interface ReadParams {
|
|
217
|
-
handle: EngineHandleData;
|
|
218
|
-
/** 数据根(core 每次 read 都发送——remote-engine 构造注入的数据目录)。两引擎
|
|
219
|
-
* server 现行均不消费该字段:定位走 handle.data(journalPath 等)或引擎自身
|
|
220
|
-
* 数据目录。保留为协议帧字段(历史:存量池时代引擎自算池/journal 相对 dbPath
|
|
221
|
-
* 的定位需要它)。 */
|
|
222
|
-
dataDir: string;
|
|
223
|
-
}
|
|
224
|
-
interface ListModelsParams {
|
|
225
|
-
/** 占位空参(帧形状一致性;未来诊断参数在此扩展)。 */
|
|
226
|
-
_placeholder?: never;
|
|
227
|
-
}
|
|
228
|
-
interface ListModelsResult {
|
|
229
|
-
/** 数组 = 有枚举面;null = 无枚举面(buildCoreAlignedHint 语义,与 manifest 省略对齐)。 */
|
|
230
|
-
models: ModelCatalogEntry[] | null;
|
|
231
|
-
}
|
|
232
|
-
interface ValidateModelParams {
|
|
233
|
-
modelRef?: string;
|
|
234
|
-
}
|
|
235
|
-
interface ValidateModelResult {
|
|
236
|
-
canonicalRef: string;
|
|
237
|
-
}
|
|
238
|
-
interface DisposeParams {
|
|
239
|
-
/** 占位空参(帧形状一致性;幂等语义)。 */
|
|
240
|
-
_placeholder?: never;
|
|
241
|
-
}
|
|
242
|
-
interface DisposeResult {
|
|
243
|
-
ok: true;
|
|
244
|
-
}
|
|
245
|
-
interface PingParams {
|
|
246
|
-
/** 占位空参(帧形状一致性)。 */
|
|
247
|
-
_placeholder?: never;
|
|
248
|
-
}
|
|
249
|
-
interface PingResult {
|
|
250
|
-
pong: true;
|
|
251
|
-
}
|
|
252
|
-
/** 方法 → params 类型映射。 */
|
|
253
|
-
interface ProtocolParamsMap {
|
|
254
|
-
initialize: InitializeParams;
|
|
255
|
-
probe: ProbeParams;
|
|
256
|
-
run: RunParams;
|
|
257
|
-
cancel: CancelParams;
|
|
258
|
-
read: ReadParams;
|
|
259
|
-
listModels: ListModelsParams;
|
|
260
|
-
validateModel: ValidateModelParams;
|
|
261
|
-
dispose: DisposeParams;
|
|
262
|
-
ping: PingParams;
|
|
263
|
-
}
|
|
264
|
-
/** 方法 → result 类型映射。 */
|
|
265
|
-
interface ProtocolResultMap {
|
|
266
|
-
initialize: InitializeResult;
|
|
267
|
-
probe: ProbeReport;
|
|
268
|
-
run: RunResult;
|
|
269
|
-
cancel: CancelResult;
|
|
270
|
-
read: SessionView;
|
|
271
|
-
listModels: ListModelsResult;
|
|
272
|
-
validateModel: ValidateModelResult;
|
|
273
|
-
dispose: DisposeResult;
|
|
274
|
-
ping: PingResult;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
37
|
/**
|
|
278
38
|
* 反向通道名联合(恰好 6 个;REVERSE_CHANNELS 常量数组与之同源互证)。
|
|
279
39
|
*/
|
|
@@ -345,58 +105,6 @@ interface HostChildStateChangedParams {
|
|
|
345
105
|
signal?: string;
|
|
346
106
|
}
|
|
347
107
|
|
|
348
|
-
/** 协议核心错误码(引擎 error 帧 + core 同步拦截共用的固定词表)。 */
|
|
349
|
-
declare const ENGINE_PROTOCOL_ERROR_CODES: readonly ["engine_not_found", "engine_protocol_mismatch", "engine_capability_unsupported", "engine_capability_mismatch", "engine_model_unknown", "engine_model_mismatch", "engine_handshake_timeout", "engine_crashed", "engine_probe_failed"];
|
|
350
|
-
type EngineProtocolErrorCode = (typeof ENGINE_PROTOCOL_ERROR_CODES)[number];
|
|
351
|
-
/** unknown → 协议错误码收窄(外部输入携带错误码时的运行时 guard;其余 engine_* 走透传)。 */
|
|
352
|
-
declare function isEngineProtocolErrorCode(value: unknown): value is EngineProtocolErrorCode;
|
|
353
|
-
/** 其余引擎自报错误码的前缀契约(透传面;core 不解释文案)。 */
|
|
354
|
-
declare const ENGINE_ERROR_CODE_PREFIX = "engine_";
|
|
355
|
-
declare function isEngineErrorPassthroughCode(value: string): boolean;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* 结构化引擎错误(message 恒为 `<code>: <detail>` 前缀格式——AgentOutcome.error 与
|
|
359
|
-
* 协议 error 帧共用的错误码前缀约定);recovery 指向恢复动作。
|
|
360
|
-
* toStructured() 产出即协议 ProtocolError 形态(error 帧载荷直用)。
|
|
361
|
-
*/
|
|
362
|
-
declare class EngineSdkError extends Error {
|
|
363
|
-
readonly code: string;
|
|
364
|
-
readonly recovery: string;
|
|
365
|
-
readonly data?: Record<string, unknown>;
|
|
366
|
-
constructor(code: string, detail: string, recovery: string, data?: Record<string, unknown>);
|
|
367
|
-
/** 协议 error 帧载荷投影。 */
|
|
368
|
-
toStructured(): ProtocolError;
|
|
369
|
-
}
|
|
370
|
-
declare function engineProtocolMismatchError(engineVersion: number): EngineSdkError;
|
|
371
|
-
/**
|
|
372
|
-
* 引擎 conversation 位拒绝的具名错误([modeless 波2] 语义:无 resume 续聊通道的
|
|
373
|
-
* 引擎,message 续聊资格被拒——manifest conversation 能力轴消费;[modeless 波5
|
|
374
|
-
* 收尾] core capability-gate 的显式参数分支随派发参数删除退役,本构造器消费方 =
|
|
375
|
-
* 引擎侧 resume gate(assertChatConversationSupported)与 message 资格门)。
|
|
376
|
-
* 文案契约:错误码 engine_capability_unsupported + 「换引擎续聊 / 修 manifest /
|
|
377
|
-
* 升级引擎包」恢复指引,两侧一致防漂移。
|
|
378
|
-
*/
|
|
379
|
-
declare function engineConversationUnsupportedError(engineId: string): EngineSdkError;
|
|
380
|
-
/**
|
|
381
|
-
* resume 会话形态(run.params.resume——唯一会话形态键)派发前的同步 gate:
|
|
382
|
-
* manifest conversation 位 unsupported 即抛 engineConversationUnsupportedError
|
|
383
|
-
* ——进程/record 创建前同步拒(A6 方向防御:manifest/实装漂移时引擎侧自拒,
|
|
384
|
-
* 与 core capability-gate 同一能力位,防两侧判据漂移)。[modeless 波2] 协议
|
|
385
|
-
* task 的 conversation 键已删,本 gate 只对 resume 形态键生效。
|
|
386
|
-
*/
|
|
387
|
-
declare function assertChatConversationSupported(engineId: string, capabilities: Pick<EngineCapabilities, "conversation">): void;
|
|
388
|
-
/** stdout 尾部回显上限(engine_timeout / engine_run_failed 的错误规格载体系数)。 */
|
|
389
|
-
declare const STDOUT_TAIL_ECHO_CHARS = 2000;
|
|
390
|
-
/** engine_timeout 的恢复指引(kill-chain 超时杀链收尾文案)。 */
|
|
391
|
-
declare const ENGINE_TIMEOUT_RECOVERY: string;
|
|
392
|
-
/**
|
|
393
|
-
* engine_timeout 的 outcome.error 文案:含 stdout 尾部 2000 字 + 恢复指引
|
|
394
|
-
* (kill-chain synthesizeTimeoutOutcome 消费;与 core errors.ts engineTimeoutDetail 逐字等价)。
|
|
395
|
-
*/
|
|
396
|
-
declare function engineTimeoutDetail(stdoutTail: string): string;
|
|
397
|
-
/** schema_emulation_failed 的终报文案(宿主编排层「重试一次仍失败」后消费)。 */
|
|
398
|
-
declare function schemaEmulationFailedDetail(error: string, tail: string): string;
|
|
399
|
-
|
|
400
108
|
/** 协议错误对象 schema。 */
|
|
401
109
|
declare const protocolErrorSchema: {
|
|
402
110
|
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
@@ -718,7 +426,7 @@ declare const runSessionParamsSchema: {
|
|
|
718
426
|
readonly type: "string";
|
|
719
427
|
};
|
|
720
428
|
};
|
|
721
|
-
readonly
|
|
429
|
+
readonly eventsPath: {
|
|
722
430
|
readonly type: "string";
|
|
723
431
|
};
|
|
724
432
|
};
|
|
@@ -726,4 +434,4 @@ declare const runSessionParamsSchema: {
|
|
|
726
434
|
};
|
|
727
435
|
};
|
|
728
436
|
|
|
729
|
-
export {
|
|
437
|
+
export { CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReverseChannel, type ReverseRequestTimeoutClass, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
|