@zhushanwen/subagent-engine-sdk 0.8.0 → 0.10.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-F7VDVSBZ.js → chunk-CNCFMPEH.js} +1 -1
- package/dist/{chunk-MQPASWMA.js → chunk-HSNDUHFH.js} +1 -1
- package/dist/{chunk-SFNTX7Q3.js → chunk-JZN76I3S.js} +31 -12
- package/dist/{chunk-DIIYVO4O.js → chunk-LM7P7OTA.js} +2 -1
- package/dist/{chunk-3WC36CHI.js → chunk-NTOLHLCL.js} +1 -1
- package/dist/{contract-types-DqOD58r-.d.cts → contract-types-jSa1g28F.d.cts} +37 -2
- package/dist/{contract-types-DqOD58r-.d.ts → contract-types-jSa1g28F.d.ts} +37 -2
- package/dist/error-codes-DnFru4L4.d.ts +150 -0
- package/dist/error-codes-f-UO4a8D.d.cts +150 -0
- package/dist/index.cjs +38 -15
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +15 -9
- 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 +26 -0
- 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/{error-codes-CiDwaODz.d.ts → methods-BLxg4ZFr.d.cts} +46 -120
- package/dist/{error-codes-C3oVToMr.d.cts → methods-C2zvZqhP.d.ts} +46 -120
- package/dist/node-executor.cjs +26 -0
- package/dist/node-executor.js +2 -2
- package/dist/port-contract.d.cts +11 -1
- package/dist/port-contract.d.ts +11 -1
- package/dist/protocol/index.cjs +38 -15
- package/dist/protocol/index.d.cts +20 -8
- package/dist/protocol/index.d.ts +20 -8
- package/dist/protocol/index.js +12 -6
- package/dist/server/index.cjs +26 -0
- package/dist/server/index.d.cts +4 -3
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.js +1 -1
- package/dist/spawn.cjs +28 -0
- package/dist/spawn.js +3 -3
- package/package.json +1 -1
|
@@ -1,76 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** 协议错误对象(error 帧载荷与反向请求错误应答共用形态)。 */
|
|
4
|
-
interface ProtocolError {
|
|
5
|
-
/** 错误码(error-codes.ts 词表 + 其余 engine_* 引擎自报透传)。 */
|
|
6
|
-
code: string;
|
|
7
|
-
/** 人类可读详情。 */
|
|
8
|
-
message: string;
|
|
9
|
-
/** 恢复指引:指向具体下一步(命令 / 配置路径 / 升级动作),非安慰性文案。 */
|
|
10
|
-
recovery: string;
|
|
11
|
-
/** 结构化附参(如 engine_protocol_mismatch 的双方版本)。 */
|
|
12
|
-
data?: Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
interface RequestFrame {
|
|
15
|
-
id: number;
|
|
16
|
-
method: string;
|
|
17
|
-
params: unknown;
|
|
18
|
-
}
|
|
19
|
-
interface SuccessResponseFrame {
|
|
20
|
-
id: number | string;
|
|
21
|
-
result: unknown;
|
|
22
|
-
}
|
|
23
|
-
interface ErrorResponseFrame {
|
|
24
|
-
id: number | string;
|
|
25
|
-
error: ProtocolError;
|
|
26
|
-
}
|
|
27
|
-
type ResponseFrame = SuccessResponseFrame | ErrorResponseFrame;
|
|
28
|
-
/** event 通知载荷:runId 关联在途 run;seq 单调递增(基线①结构等价断言对象)。 */
|
|
29
|
-
interface EventNotificationParams {
|
|
30
|
-
runId: string;
|
|
31
|
-
seq: number;
|
|
32
|
-
event: AgentEvent;
|
|
33
|
-
}
|
|
34
|
-
interface NotificationFrame {
|
|
35
|
-
method: "event";
|
|
36
|
-
params: EventNotificationParams;
|
|
37
|
-
}
|
|
38
|
-
interface ReverseRequestFrame {
|
|
39
|
-
id: string;
|
|
40
|
-
method: string;
|
|
41
|
-
params: unknown;
|
|
42
|
-
}
|
|
43
|
-
/** 反向请求的应答(core → 引擎,沿 ResponseFrame 通道回传;id = 反向请求 id 原样)。 */
|
|
44
|
-
type ReverseResponseResult =
|
|
45
|
-
/** 数据面类:处理确认。 */
|
|
46
|
-
{
|
|
47
|
-
ok: true;
|
|
48
|
-
}
|
|
49
|
-
/** 人机交互类(askUser)两阶段第一阶段:已受理,结果异步到达(R9-2)。 */
|
|
50
|
-
| {
|
|
51
|
-
ack: true;
|
|
52
|
-
}
|
|
53
|
-
/** 未实现或宿主未知的通道(宽容语义③:由 askUser 语境泛化到全通道——宿主对未知 host/* 通道回 unsupported,引擎自行降级)。 */
|
|
54
|
-
| {
|
|
55
|
-
unsupported: true;
|
|
56
|
-
};
|
|
57
|
-
/** ① 请求:有数字 id + method + params,且无 result/error(与②应答区分)。 */
|
|
58
|
-
declare function isRequestFrame(frame: unknown): frame is RequestFrame;
|
|
59
|
-
/** ② 应答:有 id(number|string)且 result/error 二选一。 */
|
|
60
|
-
declare function isResponseFrame(frame: unknown): frame is ResponseFrame;
|
|
61
|
-
/** ③ 通知:无 id,method === "event",params 含 runId/seq/event。 */
|
|
62
|
-
declare function isNotificationFrame(frame: unknown): frame is NotificationFrame;
|
|
63
|
-
/** ④ 反向请求:有字符串 id + host/* method + params(与①的区别 = id 形态与 method 前缀)。 */
|
|
64
|
-
declare function isReverseRequestFrame(frame: unknown): frame is ReverseRequestFrame;
|
|
1
|
+
import { M as ModelRef, d as EngineCapabilities, f as ModelCatalogEntry, b as AgentCallOpts, e as ResumeAnchor, E as EngineHandleData, P as ProbeReport, c as AgentOutcome, S as SessionView } from './contract-types-jSa1g28F.js';
|
|
65
2
|
|
|
66
3
|
/**
|
|
67
|
-
* 正向方法名联合(恰好
|
|
4
|
+
* 正向方法名联合(恰好 10 个;PROTOCOL_METHODS 常量数组与之同源互证)。
|
|
68
5
|
* [H1] `interact` 成员已随 chat-run 统一退役(docs/architecture/subagent-chat-run-unification.md
|
|
69
6
|
* §3.3 D5:续聊轮统一为「新 run + resume 锚点」,U5 删除)。
|
|
7
|
+
* [subagent-model-switch] `setModel` 为执行中模型热切换方法(capabilities.setModel
|
|
8
|
+
* 位门控;消费点 = 宿主发送前预检,位不支持不发调用)。
|
|
70
9
|
*/
|
|
71
|
-
type ProtocolMethod = "initialize" | "probe" | "run" | "cancel" | "read" | "listModels" | "validateModel" | "dispose" | "ping";
|
|
10
|
+
type ProtocolMethod = "initialize" | "probe" | "run" | "cancel" | "read" | "listModels" | "validateModel" | "dispose" | "ping" | "setModel";
|
|
72
11
|
/** 方法名全集(运行时顺序化枚举;与 ProtocolMethod 的同源关系由测试断言)。 */
|
|
73
|
-
declare const PROTOCOL_METHODS: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
12
|
+
declare const PROTOCOL_METHODS: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping", "setModel"];
|
|
74
13
|
/**
|
|
75
14
|
* run 上下文(RunContext 字段映射的协议承载,设计 §3.3 RunContext 映射表)。
|
|
76
15
|
*/
|
|
@@ -231,6 +170,43 @@ interface PingParams {
|
|
|
231
170
|
interface PingResult {
|
|
232
171
|
pong: true;
|
|
233
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* [subagent-model-switch §7.3] setModel 参数——RunParams 同级的 run 定向方法
|
|
175
|
+
* (params 以 runId 寻址活跃子进程,对照 cancel)。
|
|
176
|
+
*
|
|
177
|
+
* 语义(引擎侧实装义务,权威 = 设计 §7.3):定位活跃子进程 → 转发 pi 原生
|
|
178
|
+
* `set_model` → 读应答 → get_state 回读生效值 → 应答。请求 model 是**目标意图**
|
|
179
|
+
* (pi 部分模型族会静默替换成同族模型),生效值以应答 effectiveModel 为准。
|
|
180
|
+
* 失败经 error 帧,分型值域 = SET_MODEL_ERROR_CODES 三型
|
|
181
|
+
* (engine_model_not_in_snapshot / engine_credential_missing / engine_state_readback_failed);
|
|
182
|
+
* 目标 run 无活跃子进程(定位时 / 命令写入 / 读应答 / 回读四个竞态窗口内退出——
|
|
183
|
+
* 同一处置)按「无活进程」形态应答 = error 帧 `SET_MODEL_NOT_ACTIVE_CODE`
|
|
184
|
+
* (engine_run_not_active,宿主转纯记账路径,§7.5 子进程已退出行)。
|
|
185
|
+
*
|
|
186
|
+
* 无 thinkingLevel 参数(D5 裁决 M1-1):热切档位由 pi set_model 按新模型档位表
|
|
187
|
+
* 联动重设管辖(生效值以应答 effectiveThinkingLevel 为准);用户显式档位经覆盖
|
|
188
|
+
* 记账在下一轮 spawn 由解析链裁决(§6.2 跨轮档位以解析链为准)。未来引擎真支持
|
|
189
|
+
* 档位热切时走 additive 演进(新增可选参数)。
|
|
190
|
+
*
|
|
191
|
+
* 消费链:U2 宿主编排经 EnginePort 调用(capabilities.setModel='native' 预检通过后);
|
|
192
|
+
* U3 pi 引擎实装;U5 run 级聚合逐成员转发复用同一方法。
|
|
193
|
+
*/
|
|
194
|
+
interface SetModelParams {
|
|
195
|
+
/** 目标 run 的 id(RunParams.runId 同源——引擎以它定位活跃子进程)。 */
|
|
196
|
+
runId: string;
|
|
197
|
+
/** 目标模型 ref(provider + modelId;宿主编排层负责与 canonical ref 目录互校)。 */
|
|
198
|
+
model: ModelRef;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* [subagent-model-switch §7.3] setModel 应答——**回读生效值**(get_state 同源读回,
|
|
202
|
+
* 非命令应答转述;同族替换时 effectiveModel ≠ 请求 model)。
|
|
203
|
+
*/
|
|
204
|
+
interface SetModelResult {
|
|
205
|
+
/** 生效模型 ref(pi 子进程活状态读回)。 */
|
|
206
|
+
effectiveModel: ModelRef;
|
|
207
|
+
/** 生效 thinking 档位(pi set_model 联动重设后的实际档位)。 */
|
|
208
|
+
effectiveThinkingLevel: string;
|
|
209
|
+
}
|
|
234
210
|
/** 方法 → params 类型映射。 */
|
|
235
211
|
interface ProtocolParamsMap {
|
|
236
212
|
initialize: InitializeParams;
|
|
@@ -242,6 +218,7 @@ interface ProtocolParamsMap {
|
|
|
242
218
|
validateModel: ValidateModelParams;
|
|
243
219
|
dispose: DisposeParams;
|
|
244
220
|
ping: PingParams;
|
|
221
|
+
setModel: SetModelParams;
|
|
245
222
|
}
|
|
246
223
|
/** 方法 → result 类型映射。 */
|
|
247
224
|
interface ProtocolResultMap {
|
|
@@ -254,58 +231,7 @@ interface ProtocolResultMap {
|
|
|
254
231
|
validateModel: ValidateModelResult;
|
|
255
232
|
dispose: DisposeResult;
|
|
256
233
|
ping: PingResult;
|
|
234
|
+
setModel: SetModelResult;
|
|
257
235
|
}
|
|
258
236
|
|
|
259
|
-
|
|
260
|
-
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"];
|
|
261
|
-
type EngineProtocolErrorCode = (typeof ENGINE_PROTOCOL_ERROR_CODES)[number];
|
|
262
|
-
/** unknown → 协议错误码收窄(外部输入携带错误码时的运行时 guard;其余 engine_* 走透传)。 */
|
|
263
|
-
declare function isEngineProtocolErrorCode(value: unknown): value is EngineProtocolErrorCode;
|
|
264
|
-
/** 其余引擎自报错误码的前缀契约(透传面;core 不解释文案)。 */
|
|
265
|
-
declare const ENGINE_ERROR_CODE_PREFIX = "engine_";
|
|
266
|
-
declare function isEngineErrorPassthroughCode(value: string): boolean;
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* 结构化引擎错误(message 恒为 `<code>: <detail>` 前缀格式——AgentOutcome.error 与
|
|
270
|
-
* 协议 error 帧共用的错误码前缀约定);recovery 指向恢复动作。
|
|
271
|
-
* toStructured() 产出即协议 ProtocolError 形态(error 帧载荷直用)。
|
|
272
|
-
*/
|
|
273
|
-
declare class EngineSdkError extends Error {
|
|
274
|
-
readonly code: string;
|
|
275
|
-
readonly recovery: string;
|
|
276
|
-
readonly data?: Record<string, unknown>;
|
|
277
|
-
constructor(code: string, detail: string, recovery: string, data?: Record<string, unknown>);
|
|
278
|
-
/** 协议 error 帧载荷投影。 */
|
|
279
|
-
toStructured(): ProtocolError;
|
|
280
|
-
}
|
|
281
|
-
declare function engineProtocolMismatchError(engineVersion: number): EngineSdkError;
|
|
282
|
-
/**
|
|
283
|
-
* 引擎 conversation 位拒绝的具名错误([modeless 波2] 语义:无 resume 续聊通道的
|
|
284
|
-
* 引擎,message 续聊资格被拒——manifest conversation 能力轴消费;[modeless 波5
|
|
285
|
-
* 收尾] core capability-gate 的显式参数分支随派发参数删除退役,本构造器消费方 =
|
|
286
|
-
* 引擎侧 resume gate(assertChatConversationSupported)与 message 资格门)。
|
|
287
|
-
* 文案契约:错误码 engine_capability_unsupported + 「换引擎续聊 / 修 manifest /
|
|
288
|
-
* 升级引擎包」恢复指引,两侧一致防漂移。
|
|
289
|
-
*/
|
|
290
|
-
declare function engineConversationUnsupportedError(engineId: string): EngineSdkError;
|
|
291
|
-
/**
|
|
292
|
-
* resume 会话形态(run.params.resume——唯一会话形态键)派发前的同步 gate:
|
|
293
|
-
* manifest conversation 位 unsupported 即抛 engineConversationUnsupportedError
|
|
294
|
-
* ——进程/record 创建前同步拒(A6 方向防御:manifest/实装漂移时引擎侧自拒,
|
|
295
|
-
* 与 core capability-gate 同一能力位,防两侧判据漂移)。[modeless 波2] 协议
|
|
296
|
-
* task 的 conversation 键已删,本 gate 只对 resume 形态键生效。
|
|
297
|
-
*/
|
|
298
|
-
declare function assertChatConversationSupported(engineId: string, capabilities: Pick<EngineCapabilities, "conversation">): void;
|
|
299
|
-
/** stdout 尾部回显上限(engine_timeout / engine_run_failed 的错误规格载体系数)。 */
|
|
300
|
-
declare const STDOUT_TAIL_ECHO_CHARS = 2000;
|
|
301
|
-
/** engine_timeout 的恢复指引(kill-chain 超时杀链收尾文案)。 */
|
|
302
|
-
declare const ENGINE_TIMEOUT_RECOVERY: string;
|
|
303
|
-
/**
|
|
304
|
-
* engine_timeout 的 outcome.error 文案:含 stdout 尾部 2000 字 + 恢复指引
|
|
305
|
-
* (kill-chain synthesizeTimeoutOutcome 消费;与 core errors.ts engineTimeoutDetail 逐字等价)。
|
|
306
|
-
*/
|
|
307
|
-
declare function engineTimeoutDetail(stdoutTail: string): string;
|
|
308
|
-
/** schema_emulation_failed 的终报文案(宿主编排层「重试一次仍失败」后消费)。 */
|
|
309
|
-
declare function schemaEmulationFailedDetail(error: string, tail: string): string;
|
|
310
|
-
|
|
311
|
-
export { type ValidateModelResult as A, assertChatConversationSupported as B, type CancelParams as C, type DisposeParams as D, EngineSdkError as E, engineConversationUnsupportedError as F, engineProtocolMismatchError as G, engineTimeoutDetail as H, type InitializeResult as I, isEngineErrorPassthroughCode as J, isEngineProtocolErrorCode as K, type ListModelsParams as L, isNotificationFrame as M, type NotificationFrame as N, isRequestFrame as O, PROTOCOL_METHODS as P, isResponseFrame as Q, type RunContextParams as R, STDOUT_TAIL_ECHO_CHARS as S, isReverseRequestFrame as T, schemaEmulationFailedDetail as U, type ValidateModelParams as V, type InitializeParams as a, type CancelResult as b, type DisposeResult as c, ENGINE_ERROR_CODE_PREFIX as d, ENGINE_PROTOCOL_ERROR_CODES as e, ENGINE_TIMEOUT_RECOVERY as f, type EngineProtocolErrorCode as g, type ErrorResponseFrame as h, type EventNotificationParams as i, type ListModelsResult as j, type PingParams as k, type PingResult as l, type ProbeParams as m, type ProtocolError as n, type ProtocolMethod as o, type ProtocolParamsMap as p, type ProtocolResultMap as q, type ReadParams as r, type RequestFrame as s, type ResponseFrame as t, type ReverseRequestFrame as u, type ReverseResponseResult as v, type RunParams as w, type RunResult as x, type RunResumeParams as y, type SuccessResponseFrame as z };
|
|
237
|
+
export { type CancelParams as C, type DisposeParams as D, type InitializeResult as I, type ListModelsParams as L, PROTOCOL_METHODS as P, type RunContextParams as R, type SetModelParams as S, type ValidateModelParams as V, type SetModelResult as a, type InitializeParams as b, type CancelResult as c, type DisposeResult as d, type ListModelsResult as e, type PingParams as f, type PingResult as g, type ProbeParams as h, type ProtocolMethod as i, type ProtocolParamsMap as j, type ProtocolResultMap as k, type ReadParams as l, type RunParams as m, type RunResult as n, type RunResumeParams as o, type ValidateModelResult as p };
|
package/dist/node-executor.cjs
CHANGED
|
@@ -30,6 +30,32 @@ module.exports = __toCommonJS(node_executor_exports);
|
|
|
30
30
|
var import_node_child_process = require("child_process");
|
|
31
31
|
|
|
32
32
|
// src/protocol/error-codes.ts
|
|
33
|
+
var SET_MODEL_ERROR_CODES = [
|
|
34
|
+
/** 目标模型不在当前进程快照(子进程模型快照冻结于 spawn 时刻——模型本身有效,
|
|
35
|
+
* 下一轮 spawn 现取目录即可用;宿主按「写覆盖意图」处置,设计 §7.2 快照型失败行)。 */
|
|
36
|
+
"engine_model_not_in_snapshot",
|
|
37
|
+
/** 凭据校验失败(子进程 set_model checkAuth 抛错——宿主预检通过后 registry 态漂移
|
|
38
|
+
* 的权威兜底;宿主按校验型失败处置,设计 §7.5 凭据行)。 */
|
|
39
|
+
"engine_credential_missing",
|
|
40
|
+
/** 命令已发出(set_model 可能已执行)但读应答 / get_state 回读无回执、生效值未知
|
|
41
|
+
* (非进程退出情形——退出归无活进程路径;宿主按「写覆盖意图 + 错误应答」处置,
|
|
42
|
+
* 设计 §7.5 回读失败行)。 */
|
|
43
|
+
"engine_state_readback_failed"
|
|
44
|
+
];
|
|
45
|
+
var SET_MODEL_NOT_ACTIVE_CODE = "engine_run_not_active";
|
|
46
|
+
var ENGINE_PROTOCOL_ERROR_CODES = [
|
|
47
|
+
"engine_not_found",
|
|
48
|
+
"engine_protocol_mismatch",
|
|
49
|
+
"engine_capability_unsupported",
|
|
50
|
+
"engine_capability_mismatch",
|
|
51
|
+
"engine_model_unknown",
|
|
52
|
+
"engine_model_mismatch",
|
|
53
|
+
"engine_handshake_timeout",
|
|
54
|
+
"engine_crashed",
|
|
55
|
+
"engine_probe_failed",
|
|
56
|
+
...SET_MODEL_ERROR_CODES,
|
|
57
|
+
SET_MODEL_NOT_ACTIVE_CODE
|
|
58
|
+
];
|
|
33
59
|
var EngineSdkError = class extends Error {
|
|
34
60
|
code;
|
|
35
61
|
recovery;
|
package/dist/node-executor.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
probeNodeExecutor,
|
|
5
5
|
resetEngineNodeProbeCache,
|
|
6
6
|
resolveEngineNodeLaunch
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-NTOLHLCL.js";
|
|
8
|
+
import "./chunk-JZN76I3S.js";
|
|
9
9
|
import "./chunk-JSBRDJBE.js";
|
|
10
10
|
export {
|
|
11
11
|
ENGINE_NODE_ENV,
|
package/dist/port-contract.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-
|
|
1
|
+
import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-jSa1g28F.cjs';
|
|
2
|
+
import { S as SetModelParams, a as SetModelResult } from './methods-BLxg4ZFr.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
|
|
@@ -125,6 +126,15 @@ interface EnginePort {
|
|
|
125
126
|
validateModel?(modelRef: string | undefined): {
|
|
126
127
|
canonicalRef: string;
|
|
127
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* [subagent-model-switch §7.3] 可选面:执行中模型热切换(协议 setModel 正向方法的
|
|
131
|
+
* 进程内承载)。实现引擎须 capabilities.setModel = 'native' 同批声明(位与方法
|
|
132
|
+
* 成对进出——capabilities 注释的消费点登记);server 分发行在位非 native 时回
|
|
133
|
+
* engineSetModelUnsupportedError 结构化错误(契约行为 = 明确错误而非崩)。
|
|
134
|
+
* 实现语义 = 定位活跃子进程 → 命令写入 → 读应答 → 状态回读 → 应答生效值
|
|
135
|
+
* (SetModelResult),竞态窗口处置见设计 §7.3。
|
|
136
|
+
*/
|
|
137
|
+
setModel?(params: SetModelParams): Promise<SetModelResult>;
|
|
128
138
|
dispose?(): Promise<void>;
|
|
129
139
|
}
|
|
130
140
|
/** ctx.ctxModel("provider/id" canonical 词形)→ EngineCtxModel。 */
|
package/dist/port-contract.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-
|
|
1
|
+
import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-jSa1g28F.js';
|
|
2
|
+
import { S as SetModelParams, a as SetModelResult } from './methods-C2zvZqhP.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
|
|
@@ -125,6 +126,15 @@ interface EnginePort {
|
|
|
125
126
|
validateModel?(modelRef: string | undefined): {
|
|
126
127
|
canonicalRef: string;
|
|
127
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* [subagent-model-switch §7.3] 可选面:执行中模型热切换(协议 setModel 正向方法的
|
|
131
|
+
* 进程内承载)。实现引擎须 capabilities.setModel = 'native' 同批声明(位与方法
|
|
132
|
+
* 成对进出——capabilities 注释的消费点登记);server 分发行在位非 native 时回
|
|
133
|
+
* engineSetModelUnsupportedError 结构化错误(契约行为 = 明确错误而非崩)。
|
|
134
|
+
* 实现语义 = 定位活跃子进程 → 命令写入 → 读应答 → 状态回读 → 应答生效值
|
|
135
|
+
* (SetModelResult),竞态窗口处置见设计 §7.3。
|
|
136
|
+
*/
|
|
137
|
+
setModel?(params: SetModelParams): Promise<SetModelResult>;
|
|
128
138
|
dispose?(): Promise<void>;
|
|
129
139
|
}
|
|
130
140
|
/** ctx.ctxModel("provider/id" canonical 词形)→ EngineCtxModel。 */
|
package/dist/protocol/index.cjs
CHANGED
|
@@ -22,8 +22,6 @@ var protocol_exports = {};
|
|
|
22
22
|
__export(protocol_exports, {
|
|
23
23
|
AGENT_EVENT_TYPE_NAMES: () => AGENT_EVENT_TYPE_NAMES,
|
|
24
24
|
CANCEL_SETTLE_GRACE_MS: () => CANCEL_SETTLE_GRACE_MS,
|
|
25
|
-
CRASH_REBUILD_BACKOFF_MS: () => CRASH_REBUILD_BACKOFF_MS,
|
|
26
|
-
CRASH_REBUILD_MAX_ATTEMPTS: () => CRASH_REBUILD_MAX_ATTEMPTS,
|
|
27
25
|
ENGINE_ERROR_CODE_PREFIX: () => ENGINE_ERROR_CODE_PREFIX,
|
|
28
26
|
ENGINE_PROTOCOL_ERROR_CODES: () => ENGINE_PROTOCOL_ERROR_CODES,
|
|
29
27
|
ENGINE_PROTOCOL_SCHEMAS: () => ENGINE_PROTOCOL_SCHEMAS,
|
|
@@ -36,12 +34,17 @@ __export(protocol_exports, {
|
|
|
36
34
|
REVERSE_CHANNELS: () => REVERSE_CHANNELS,
|
|
37
35
|
REVERSE_CHANNEL_TIMEOUT_CLASS: () => REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
38
36
|
REVERSE_REQUEST_TIMEOUT_MS: () => REVERSE_REQUEST_TIMEOUT_MS,
|
|
37
|
+
SET_MODEL_ERROR_CODES: () => SET_MODEL_ERROR_CODES,
|
|
38
|
+
SET_MODEL_NOT_ACTIVE_CODE: () => SET_MODEL_NOT_ACTIVE_CODE,
|
|
39
|
+
SET_MODEL_REQUEST_TIMEOUT_MS: () => SET_MODEL_REQUEST_TIMEOUT_MS,
|
|
40
|
+
SET_MODEL_STAGE_TIMEOUT_MS: () => SET_MODEL_STAGE_TIMEOUT_MS,
|
|
39
41
|
STDERR_TAIL_CHARS: () => STDERR_TAIL_CHARS,
|
|
40
42
|
STDOUT_TAIL_ECHO_CHARS: () => STDOUT_TAIL_ECHO_CHARS,
|
|
41
43
|
SUPPORTED_PROTOCOL_RANGE: () => SUPPORTED_PROTOCOL_RANGE,
|
|
42
44
|
assertChatConversationSupported: () => assertChatConversationSupported,
|
|
43
45
|
engineConversationUnsupportedError: () => engineConversationUnsupportedError,
|
|
44
46
|
engineProtocolMismatchError: () => engineProtocolMismatchError,
|
|
47
|
+
engineSetModelUnsupportedError: () => engineSetModelUnsupportedError,
|
|
45
48
|
engineTimeoutDetail: () => engineTimeoutDetail,
|
|
46
49
|
errorResponseFrameSchema: () => errorResponseFrameSchema,
|
|
47
50
|
isEngineErrorPassthroughCode: () => isEngineErrorPassthroughCode,
|
|
@@ -70,15 +73,8 @@ function isProtocolVersionCompatible(version) {
|
|
|
70
73
|
var REVERSE_REQUEST_TIMEOUT_MS = 1e4;
|
|
71
74
|
var HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
72
75
|
var CANCEL_SETTLE_GRACE_MS = 3e3;
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var CRASH_REBUILD_BACKOFF_STEP_2_MS = 2e3;
|
|
76
|
-
var CRASH_REBUILD_BACKOFF_STEP_3_MS = 4e3;
|
|
77
|
-
var CRASH_REBUILD_BACKOFF_MS = [
|
|
78
|
-
CRASH_REBUILD_BACKOFF_STEP_1_MS,
|
|
79
|
-
CRASH_REBUILD_BACKOFF_STEP_2_MS,
|
|
80
|
-
CRASH_REBUILD_BACKOFF_STEP_3_MS
|
|
81
|
-
];
|
|
76
|
+
var SET_MODEL_STAGE_TIMEOUT_MS = 3e3;
|
|
77
|
+
var SET_MODEL_REQUEST_TIMEOUT_MS = 1e4;
|
|
82
78
|
var STDERR_TAIL_CHARS = 400;
|
|
83
79
|
|
|
84
80
|
// src/protocol/frames.ts
|
|
@@ -113,7 +109,8 @@ var PROTOCOL_METHODS = [
|
|
|
113
109
|
"listModels",
|
|
114
110
|
"validateModel",
|
|
115
111
|
"dispose",
|
|
116
|
-
"ping"
|
|
112
|
+
"ping",
|
|
113
|
+
"setModel"
|
|
117
114
|
];
|
|
118
115
|
|
|
119
116
|
// src/protocol/reverse-channels.ts
|
|
@@ -135,6 +132,19 @@ var REVERSE_CHANNEL_TIMEOUT_CLASS = {
|
|
|
135
132
|
};
|
|
136
133
|
|
|
137
134
|
// src/protocol/error-codes.ts
|
|
135
|
+
var SET_MODEL_ERROR_CODES = [
|
|
136
|
+
/** 目标模型不在当前进程快照(子进程模型快照冻结于 spawn 时刻——模型本身有效,
|
|
137
|
+
* 下一轮 spawn 现取目录即可用;宿主按「写覆盖意图」处置,设计 §7.2 快照型失败行)。 */
|
|
138
|
+
"engine_model_not_in_snapshot",
|
|
139
|
+
/** 凭据校验失败(子进程 set_model checkAuth 抛错——宿主预检通过后 registry 态漂移
|
|
140
|
+
* 的权威兜底;宿主按校验型失败处置,设计 §7.5 凭据行)。 */
|
|
141
|
+
"engine_credential_missing",
|
|
142
|
+
/** 命令已发出(set_model 可能已执行)但读应答 / get_state 回读无回执、生效值未知
|
|
143
|
+
* (非进程退出情形——退出归无活进程路径;宿主按「写覆盖意图 + 错误应答」处置,
|
|
144
|
+
* 设计 §7.5 回读失败行)。 */
|
|
145
|
+
"engine_state_readback_failed"
|
|
146
|
+
];
|
|
147
|
+
var SET_MODEL_NOT_ACTIVE_CODE = "engine_run_not_active";
|
|
138
148
|
var ENGINE_PROTOCOL_ERROR_CODES = [
|
|
139
149
|
"engine_not_found",
|
|
140
150
|
"engine_protocol_mismatch",
|
|
@@ -144,7 +154,9 @@ var ENGINE_PROTOCOL_ERROR_CODES = [
|
|
|
144
154
|
"engine_model_mismatch",
|
|
145
155
|
"engine_handshake_timeout",
|
|
146
156
|
"engine_crashed",
|
|
147
|
-
"engine_probe_failed"
|
|
157
|
+
"engine_probe_failed",
|
|
158
|
+
...SET_MODEL_ERROR_CODES,
|
|
159
|
+
SET_MODEL_NOT_ACTIVE_CODE
|
|
148
160
|
];
|
|
149
161
|
function isEngineProtocolErrorCode(value) {
|
|
150
162
|
return typeof value === "string" && ENGINE_PROTOCOL_ERROR_CODES.includes(value);
|
|
@@ -194,6 +206,14 @@ function assertChatConversationSupported(engineId, capabilities) {
|
|
|
194
206
|
throw engineConversationUnsupportedError(engineId);
|
|
195
207
|
}
|
|
196
208
|
}
|
|
209
|
+
function engineSetModelUnsupportedError(engineId, declared) {
|
|
210
|
+
return new EngineSdkError(
|
|
211
|
+
"engine_capability_unsupported",
|
|
212
|
+
`engine '${engineId}' does not support hot model switching (capabilities.setModel = ${declared ?? "unsupported (undeclared)"}); the host pre-check (design \xA77.2 step 2) must not dispatch setModel to it`,
|
|
213
|
+
`Route the switch to an engine that declares capabilities.setModel = 'native', or record the override for the next run instead. If this engine actually supports hot switching, fix the manifest capabilities declaration.`,
|
|
214
|
+
{ engineId, capability: "setModel", declared: declared ?? "unsupported" }
|
|
215
|
+
);
|
|
216
|
+
}
|
|
197
217
|
var DETAIL_ECHO_MAX_CHARS = 200;
|
|
198
218
|
var STDOUT_TAIL_ECHO_CHARS = 2e3;
|
|
199
219
|
function truncate(text, max) {
|
|
@@ -363,8 +383,6 @@ var runSessionParamsSchema = {
|
|
|
363
383
|
0 && (module.exports = {
|
|
364
384
|
AGENT_EVENT_TYPE_NAMES,
|
|
365
385
|
CANCEL_SETTLE_GRACE_MS,
|
|
366
|
-
CRASH_REBUILD_BACKOFF_MS,
|
|
367
|
-
CRASH_REBUILD_MAX_ATTEMPTS,
|
|
368
386
|
ENGINE_ERROR_CODE_PREFIX,
|
|
369
387
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
370
388
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
@@ -377,12 +395,17 @@ var runSessionParamsSchema = {
|
|
|
377
395
|
REVERSE_CHANNELS,
|
|
378
396
|
REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
379
397
|
REVERSE_REQUEST_TIMEOUT_MS,
|
|
398
|
+
SET_MODEL_ERROR_CODES,
|
|
399
|
+
SET_MODEL_NOT_ACTIVE_CODE,
|
|
400
|
+
SET_MODEL_REQUEST_TIMEOUT_MS,
|
|
401
|
+
SET_MODEL_STAGE_TIMEOUT_MS,
|
|
380
402
|
STDERR_TAIL_CHARS,
|
|
381
403
|
STDOUT_TAIL_ECHO_CHARS,
|
|
382
404
|
SUPPORTED_PROTOCOL_RANGE,
|
|
383
405
|
assertChatConversationSupported,
|
|
384
406
|
engineConversationUnsupportedError,
|
|
385
407
|
engineProtocolMismatchError,
|
|
408
|
+
engineSetModelUnsupportedError,
|
|
386
409
|
engineTimeoutDetail,
|
|
387
410
|
errorResponseFrameSchema,
|
|
388
411
|
isEngineErrorPassthroughCode,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_TIMEOUT_RECOVERY, d as EngineProtocolErrorCode, E 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 SET_MODEL_ERROR_CODES, j as SET_MODEL_NOT_ACTIVE_CODE, k as STDOUT_TAIL_ECHO_CHARS, l as SetModelErrorCode, m as SuccessResponseFrame, n as assertChatConversationSupported, o as engineConversationUnsupportedError, p as engineProtocolMismatchError, q as engineSetModelUnsupportedError, r as engineTimeoutDetail, s as isEngineErrorPassthroughCode, t as isEngineProtocolErrorCode, u as isNotificationFrame, v as isRequestFrame, w as isResponseFrame, x as isReverseRequestFrame, y as schemaEmulationFailedDetail } from '../error-codes-f-UO4a8D.cjs';
|
|
2
|
+
export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from '../methods-BLxg4ZFr.cjs';
|
|
2
3
|
import { UiRequest, UiResponse } from '../ui-types.cjs';
|
|
3
|
-
export {
|
|
4
|
+
export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-jSa1g28F.cjs';
|
|
4
5
|
|
|
5
6
|
/** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
6
7
|
declare const ENGINE_PROTOCOL_VERSION = 1;
|
|
@@ -20,9 +21,20 @@ declare const REVERSE_REQUEST_TIMEOUT_MS = 10000;
|
|
|
20
21
|
declare const HANDSHAKE_TIMEOUT_MS = 10000;
|
|
21
22
|
/** cancel 后引擎收敛终态的窗口(ms);超时 core 走杀链。 */
|
|
22
23
|
declare const CANCEL_SETTLE_GRACE_MS = 3000;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* setModel 引擎侧单阶段控制窗(ms):pi 实现等子进程 `set_model` 应答、等
|
|
26
|
+
* `get_state` 回读各占一窗(设计 subagent-model-switch §7.3——命令与回读全程带
|
|
27
|
+
* 存活检查,超时上限复用现役取消收敛窗量级:控制面单请求 = 秒级)。窗满且进程
|
|
28
|
+
* 仍存活 → `engine_state_readback_failed`;窗满时进程已退出 → 无活进程形态
|
|
29
|
+
* (`SET_MODEL_NOT_ACTIVE_CODE`)——两种处置不可混淆。
|
|
30
|
+
*/
|
|
31
|
+
declare const SET_MODEL_STAGE_TIMEOUT_MS = 3000;
|
|
32
|
+
/**
|
|
33
|
+
* setModel 正向方法的宿主侧单请求上界(ms):≥ 引擎侧两阶段最坏时延
|
|
34
|
+
* (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据面单请求
|
|
35
|
+
* REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制面单请求必须秒级有界——宿主不悬挂)。
|
|
36
|
+
*/
|
|
37
|
+
declare const SET_MODEL_REQUEST_TIMEOUT_MS = 10000;
|
|
26
38
|
/** stderr 内存环形缓冲保留的尾部字符数(engine_crashed 帧携带崩溃现场)。 */
|
|
27
39
|
declare const STDERR_TAIL_CHARS = 400;
|
|
28
40
|
/**
|
|
@@ -141,7 +153,7 @@ declare const requestFrameSchema: {
|
|
|
141
153
|
};
|
|
142
154
|
readonly method: {
|
|
143
155
|
readonly type: "string";
|
|
144
|
-
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
156
|
+
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping", "setModel"];
|
|
145
157
|
};
|
|
146
158
|
readonly params: {};
|
|
147
159
|
};
|
|
@@ -263,7 +275,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
263
275
|
};
|
|
264
276
|
readonly method: {
|
|
265
277
|
readonly type: "string";
|
|
266
|
-
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
278
|
+
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping", "setModel"];
|
|
267
279
|
};
|
|
268
280
|
readonly params: {};
|
|
269
281
|
};
|
|
@@ -434,4 +446,4 @@ declare const runSessionParamsSchema: {
|
|
|
434
446
|
};
|
|
435
447
|
};
|
|
436
448
|
|
|
437
|
-
export { CANCEL_SETTLE_GRACE_MS,
|
|
449
|
+
export { CANCEL_SETTLE_GRACE_MS, 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, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_TIMEOUT_RECOVERY, d as EngineProtocolErrorCode, E 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 SET_MODEL_ERROR_CODES, j as SET_MODEL_NOT_ACTIVE_CODE, k as STDOUT_TAIL_ECHO_CHARS, l as SetModelErrorCode, m as SuccessResponseFrame, n as assertChatConversationSupported, o as engineConversationUnsupportedError, p as engineProtocolMismatchError, q as engineSetModelUnsupportedError, r as engineTimeoutDetail, s as isEngineErrorPassthroughCode, t as isEngineProtocolErrorCode, u as isNotificationFrame, v as isRequestFrame, w as isResponseFrame, x as isReverseRequestFrame, y as schemaEmulationFailedDetail } from '../error-codes-DnFru4L4.js';
|
|
2
|
+
export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from '../methods-C2zvZqhP.js';
|
|
2
3
|
import { UiRequest, UiResponse } from '../ui-types.js';
|
|
3
|
-
export {
|
|
4
|
+
export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from '../contract-types-jSa1g28F.js';
|
|
4
5
|
|
|
5
6
|
/** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
6
7
|
declare const ENGINE_PROTOCOL_VERSION = 1;
|
|
@@ -20,9 +21,20 @@ declare const REVERSE_REQUEST_TIMEOUT_MS = 10000;
|
|
|
20
21
|
declare const HANDSHAKE_TIMEOUT_MS = 10000;
|
|
21
22
|
/** cancel 后引擎收敛终态的窗口(ms);超时 core 走杀链。 */
|
|
22
23
|
declare const CANCEL_SETTLE_GRACE_MS = 3000;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* setModel 引擎侧单阶段控制窗(ms):pi 实现等子进程 `set_model` 应答、等
|
|
26
|
+
* `get_state` 回读各占一窗(设计 subagent-model-switch §7.3——命令与回读全程带
|
|
27
|
+
* 存活检查,超时上限复用现役取消收敛窗量级:控制面单请求 = 秒级)。窗满且进程
|
|
28
|
+
* 仍存活 → `engine_state_readback_failed`;窗满时进程已退出 → 无活进程形态
|
|
29
|
+
* (`SET_MODEL_NOT_ACTIVE_CODE`)——两种处置不可混淆。
|
|
30
|
+
*/
|
|
31
|
+
declare const SET_MODEL_STAGE_TIMEOUT_MS = 3000;
|
|
32
|
+
/**
|
|
33
|
+
* setModel 正向方法的宿主侧单请求上界(ms):≥ 引擎侧两阶段最坏时延
|
|
34
|
+
* (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据面单请求
|
|
35
|
+
* REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制面单请求必须秒级有界——宿主不悬挂)。
|
|
36
|
+
*/
|
|
37
|
+
declare const SET_MODEL_REQUEST_TIMEOUT_MS = 10000;
|
|
26
38
|
/** stderr 内存环形缓冲保留的尾部字符数(engine_crashed 帧携带崩溃现场)。 */
|
|
27
39
|
declare const STDERR_TAIL_CHARS = 400;
|
|
28
40
|
/**
|
|
@@ -141,7 +153,7 @@ declare const requestFrameSchema: {
|
|
|
141
153
|
};
|
|
142
154
|
readonly method: {
|
|
143
155
|
readonly type: "string";
|
|
144
|
-
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
156
|
+
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping", "setModel"];
|
|
145
157
|
};
|
|
146
158
|
readonly params: {};
|
|
147
159
|
};
|
|
@@ -263,7 +275,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
263
275
|
};
|
|
264
276
|
readonly method: {
|
|
265
277
|
readonly type: "string";
|
|
266
|
-
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping"];
|
|
278
|
+
readonly enum: readonly ["initialize", "probe", "run", "cancel", "read", "listModels", "validateModel", "dispose", "ping", "setModel"];
|
|
267
279
|
};
|
|
268
280
|
readonly params: {};
|
|
269
281
|
};
|
|
@@ -434,4 +446,4 @@ declare const runSessionParamsSchema: {
|
|
|
434
446
|
};
|
|
435
447
|
};
|
|
436
448
|
|
|
437
|
-
export { CANCEL_SETTLE_GRACE_MS,
|
|
449
|
+
export { CANCEL_SETTLE_GRACE_MS, 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, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
|
package/dist/protocol/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
reverseRequestFrameSchema,
|
|
13
13
|
runSessionParamsSchema,
|
|
14
14
|
successResponseFrameSchema
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-LM7P7OTA.js";
|
|
16
16
|
import {
|
|
17
17
|
isNotificationFrame,
|
|
18
18
|
isRequestFrame,
|
|
@@ -21,8 +21,6 @@ import {
|
|
|
21
21
|
} from "../chunk-D36ZIQQK.js";
|
|
22
22
|
import {
|
|
23
23
|
CANCEL_SETTLE_GRACE_MS,
|
|
24
|
-
CRASH_REBUILD_BACKOFF_MS,
|
|
25
|
-
CRASH_REBUILD_MAX_ATTEMPTS,
|
|
26
24
|
ENGINE_ERROR_CODE_PREFIX,
|
|
27
25
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
28
26
|
ENGINE_PROTOCOL_VERSION,
|
|
@@ -30,24 +28,27 @@ import {
|
|
|
30
28
|
EngineSdkError,
|
|
31
29
|
HANDSHAKE_TIMEOUT_MS,
|
|
32
30
|
REVERSE_REQUEST_TIMEOUT_MS,
|
|
31
|
+
SET_MODEL_ERROR_CODES,
|
|
32
|
+
SET_MODEL_NOT_ACTIVE_CODE,
|
|
33
|
+
SET_MODEL_REQUEST_TIMEOUT_MS,
|
|
34
|
+
SET_MODEL_STAGE_TIMEOUT_MS,
|
|
33
35
|
STDERR_TAIL_CHARS,
|
|
34
36
|
STDOUT_TAIL_ECHO_CHARS,
|
|
35
37
|
SUPPORTED_PROTOCOL_RANGE,
|
|
36
38
|
assertChatConversationSupported,
|
|
37
39
|
engineConversationUnsupportedError,
|
|
38
40
|
engineProtocolMismatchError,
|
|
41
|
+
engineSetModelUnsupportedError,
|
|
39
42
|
engineTimeoutDetail,
|
|
40
43
|
isEngineErrorPassthroughCode,
|
|
41
44
|
isEngineProtocolErrorCode,
|
|
42
45
|
isProtocolVersionCompatible,
|
|
43
46
|
schemaEmulationFailedDetail
|
|
44
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-JZN76I3S.js";
|
|
45
48
|
import "../chunk-JSBRDJBE.js";
|
|
46
49
|
export {
|
|
47
50
|
AGENT_EVENT_TYPE_NAMES,
|
|
48
51
|
CANCEL_SETTLE_GRACE_MS,
|
|
49
|
-
CRASH_REBUILD_BACKOFF_MS,
|
|
50
|
-
CRASH_REBUILD_MAX_ATTEMPTS,
|
|
51
52
|
ENGINE_ERROR_CODE_PREFIX,
|
|
52
53
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
53
54
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
@@ -60,12 +61,17 @@ export {
|
|
|
60
61
|
REVERSE_CHANNELS,
|
|
61
62
|
REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
62
63
|
REVERSE_REQUEST_TIMEOUT_MS,
|
|
64
|
+
SET_MODEL_ERROR_CODES,
|
|
65
|
+
SET_MODEL_NOT_ACTIVE_CODE,
|
|
66
|
+
SET_MODEL_REQUEST_TIMEOUT_MS,
|
|
67
|
+
SET_MODEL_STAGE_TIMEOUT_MS,
|
|
63
68
|
STDERR_TAIL_CHARS,
|
|
64
69
|
STDOUT_TAIL_ECHO_CHARS,
|
|
65
70
|
SUPPORTED_PROTOCOL_RANGE,
|
|
66
71
|
assertChatConversationSupported,
|
|
67
72
|
engineConversationUnsupportedError,
|
|
68
73
|
engineProtocolMismatchError,
|
|
74
|
+
engineSetModelUnsupportedError,
|
|
69
75
|
engineTimeoutDetail,
|
|
70
76
|
errorResponseFrameSchema,
|
|
71
77
|
isEngineErrorPassthroughCode,
|
package/dist/server/index.cjs
CHANGED
|
@@ -51,6 +51,32 @@ function toErrorMessage(e) {
|
|
|
51
51
|
var ENGINE_PROTOCOL_VERSION = 1;
|
|
52
52
|
|
|
53
53
|
// src/protocol/error-codes.ts
|
|
54
|
+
var SET_MODEL_ERROR_CODES = [
|
|
55
|
+
/** 目标模型不在当前进程快照(子进程模型快照冻结于 spawn 时刻——模型本身有效,
|
|
56
|
+
* 下一轮 spawn 现取目录即可用;宿主按「写覆盖意图」处置,设计 §7.2 快照型失败行)。 */
|
|
57
|
+
"engine_model_not_in_snapshot",
|
|
58
|
+
/** 凭据校验失败(子进程 set_model checkAuth 抛错——宿主预检通过后 registry 态漂移
|
|
59
|
+
* 的权威兜底;宿主按校验型失败处置,设计 §7.5 凭据行)。 */
|
|
60
|
+
"engine_credential_missing",
|
|
61
|
+
/** 命令已发出(set_model 可能已执行)但读应答 / get_state 回读无回执、生效值未知
|
|
62
|
+
* (非进程退出情形——退出归无活进程路径;宿主按「写覆盖意图 + 错误应答」处置,
|
|
63
|
+
* 设计 §7.5 回读失败行)。 */
|
|
64
|
+
"engine_state_readback_failed"
|
|
65
|
+
];
|
|
66
|
+
var SET_MODEL_NOT_ACTIVE_CODE = "engine_run_not_active";
|
|
67
|
+
var ENGINE_PROTOCOL_ERROR_CODES = [
|
|
68
|
+
"engine_not_found",
|
|
69
|
+
"engine_protocol_mismatch",
|
|
70
|
+
"engine_capability_unsupported",
|
|
71
|
+
"engine_capability_mismatch",
|
|
72
|
+
"engine_model_unknown",
|
|
73
|
+
"engine_model_mismatch",
|
|
74
|
+
"engine_handshake_timeout",
|
|
75
|
+
"engine_crashed",
|
|
76
|
+
"engine_probe_failed",
|
|
77
|
+
...SET_MODEL_ERROR_CODES,
|
|
78
|
+
SET_MODEL_NOT_ACTIVE_CODE
|
|
79
|
+
];
|
|
54
80
|
var EngineSdkError = class extends Error {
|
|
55
81
|
code;
|
|
56
82
|
recovery;
|