@zhushanwen/subagent-engine-sdk 0.10.1 → 0.12.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-AF2ETADP.js → chunk-2L3I2TWJ.js} +5 -10
- package/dist/{chunk-HSNDUHFH.js → chunk-3MCOZY3Z.js} +32 -4
- package/dist/{chunk-LM7P7OTA.js → chunk-7R6HYT2A.js} +60 -4
- package/dist/{chunk-JZN76I3S.js → chunk-NVF3PADP.js} +29 -1
- package/dist/{chunk-NTOLHLCL.js → chunk-QGXILDWB.js} +1 -1
- package/dist/{chunk-CNCFMPEH.js → chunk-TJMS3YOR.js} +1 -1
- package/dist/{chunk-SGAIDL63.js → chunk-U5MBAKS5.js} +21 -7
- package/dist/cli-entry.d.cts +1 -1
- package/dist/cli-entry.d.ts +1 -1
- package/dist/{contract-types-jSa1g28F.d.cts → contract-types-C1scOS_M.d.cts} +218 -21
- package/dist/{contract-types-jSa1g28F.d.ts → contract-types-C1scOS_M.d.ts} +218 -21
- package/dist/env.cjs +5 -10
- package/dist/env.d.cts +6 -17
- package/dist/env.d.ts +6 -17
- package/dist/env.js +1 -1
- package/dist/{error-codes-f-UO4a8D.d.cts → error-codes-CgcjlmeD.d.cts} +42 -6
- package/dist/{error-codes-DnFru4L4.d.ts → error-codes-o4rNd1Ee.d.ts} +42 -6
- package/dist/index.cjs +178 -103
- package/dist/index.d.cts +29 -41
- package/dist/index.d.ts +29 -41
- package/dist/index.js +54 -57
- package/dist/journal-io.d.cts +1 -1
- package/dist/journal-io.d.ts +1 -1
- package/dist/journal-replay.cjs +24 -7
- package/dist/journal-replay.d.cts +41 -7
- package/dist/journal-replay.d.ts +41 -7
- package/dist/journal-replay.js +7 -1
- package/dist/kill-chain.d.cts +5 -5
- package/dist/kill-chain.d.ts +5 -5
- package/dist/kill-chain.js +2 -2
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logs/stderr-rotation.d.cts +4 -4
- package/dist/logs/stderr-rotation.d.ts +4 -4
- package/dist/{methods-BLxg4ZFr.d.cts → methods-BzvzcCrB.d.cts} +5 -5
- package/dist/{methods-C2zvZqhP.d.ts → methods-CPMc4cvF.d.ts} +5 -5
- package/dist/node-executor.cjs +1 -1
- package/dist/node-executor.d.cts +4 -4
- package/dist/node-executor.d.ts +4 -4
- package/dist/node-executor.js +2 -2
- package/dist/port-contract.d.cts +9 -9
- package/dist/port-contract.d.ts +9 -9
- package/dist/protocol/index.cjs +103 -5
- package/dist/protocol/index.d.cts +59 -16
- package/dist/protocol/index.d.ts +59 -16
- package/dist/protocol/index.js +30 -2
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +10 -10
- package/dist/server/index.d.ts +10 -10
- package/dist/server/index.js +1 -1
- package/dist/spawn.cjs +32 -3
- package/dist/spawn.d.cts +34 -8
- package/dist/spawn.d.ts +34 -8
- package/dist/spawn.js +5 -3
- package/dist/ui-types.d.cts +2 -2
- package/dist/ui-types.d.ts +2 -2
- package/package.json +13 -2
- package/dist/chunk-GSW3DMN6.js +0 -39
- package/dist/relay-env.cjs +0 -71
- package/dist/relay-env.d.cts +0 -37
- package/dist/relay-env.d.ts +0 -37
- package/dist/relay-env.js +0 -23
package/dist/protocol/index.cjs
CHANGED
|
@@ -26,8 +26,16 @@ __export(protocol_exports, {
|
|
|
26
26
|
ENGINE_PROTOCOL_ERROR_CODES: () => ENGINE_PROTOCOL_ERROR_CODES,
|
|
27
27
|
ENGINE_PROTOCOL_SCHEMAS: () => ENGINE_PROTOCOL_SCHEMAS,
|
|
28
28
|
ENGINE_PROTOCOL_VERSION: () => ENGINE_PROTOCOL_VERSION,
|
|
29
|
+
ENGINE_SPAWN_DELIVERY_ERROR_CODES: () => ENGINE_SPAWN_DELIVERY_ERROR_CODES,
|
|
30
|
+
ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY: () => ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
|
|
29
31
|
ENGINE_TIMEOUT_RECOVERY: () => ENGINE_TIMEOUT_RECOVERY,
|
|
32
|
+
ENGINE_TRANSPORT_ERROR_CODES: () => ENGINE_TRANSPORT_ERROR_CODES,
|
|
33
|
+
ENGINE_TRANSPORT_ERROR_RECOVERY: () => ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
30
34
|
EngineSdkError: () => EngineSdkError,
|
|
35
|
+
FAILURE_CAUSE_CLOSED_KINDS: () => FAILURE_CAUSE_CLOSED_KINDS,
|
|
36
|
+
FAILURE_CAUSE_KINDS_BY_CLASS: () => FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
37
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK: () => FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
38
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK: () => FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
31
39
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: () => FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
32
40
|
HANDSHAKE_TIMEOUT_MS: () => HANDSHAKE_TIMEOUT_MS,
|
|
33
41
|
PROTOCOL_METHODS: () => PROTOCOL_METHODS,
|
|
@@ -40,7 +48,11 @@ __export(protocol_exports, {
|
|
|
40
48
|
SET_MODEL_STAGE_TIMEOUT_MS: () => SET_MODEL_STAGE_TIMEOUT_MS,
|
|
41
49
|
STDERR_TAIL_CHARS: () => STDERR_TAIL_CHARS,
|
|
42
50
|
STDOUT_TAIL_ECHO_CHARS: () => STDOUT_TAIL_ECHO_CHARS,
|
|
51
|
+
SUBAGENT_CONTROL_CLOSED_REASONS: () => SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
52
|
+
SUBAGENT_CONTROL_FRAME_KINDS: () => SUBAGENT_CONTROL_FRAME_KINDS,
|
|
53
|
+
SUBAGENT_CONTROL_PROTOCOL_VERSION: () => SUBAGENT_CONTROL_PROTOCOL_VERSION,
|
|
43
54
|
SUPPORTED_PROTOCOL_RANGE: () => SUPPORTED_PROTOCOL_RANGE,
|
|
55
|
+
_EventVocabSyncLock: () => _EventVocabSyncLock,
|
|
44
56
|
assertChatConversationSupported: () => assertChatConversationSupported,
|
|
45
57
|
engineConversationUnsupportedError: () => engineConversationUnsupportedError,
|
|
46
58
|
engineProtocolMismatchError: () => engineProtocolMismatchError,
|
|
@@ -54,6 +66,8 @@ __export(protocol_exports, {
|
|
|
54
66
|
isRequestFrame: () => isRequestFrame,
|
|
55
67
|
isResponseFrame: () => isResponseFrame,
|
|
56
68
|
isReverseRequestFrame: () => isReverseRequestFrame,
|
|
69
|
+
isSubagentControlClosedReason: () => isSubagentControlClosedReason,
|
|
70
|
+
isSubagentControlFrameKind: () => isSubagentControlFrameKind,
|
|
57
71
|
notificationFrameSchema: () => notificationFrameSchema,
|
|
58
72
|
protocolErrorSchema: () => protocolErrorSchema,
|
|
59
73
|
requestFrameSchema: () => requestFrameSchema,
|
|
@@ -132,6 +146,30 @@ var REVERSE_CHANNEL_TIMEOUT_CLASS = {
|
|
|
132
146
|
};
|
|
133
147
|
|
|
134
148
|
// src/protocol/error-codes.ts
|
|
149
|
+
var ENGINE_SPAWN_DELIVERY_ERROR_CODES = [
|
|
150
|
+
"engine_prompt_not_delivered",
|
|
151
|
+
"engine_prompt_rejected",
|
|
152
|
+
"engine_spawn_handshake_timeout"
|
|
153
|
+
];
|
|
154
|
+
var ENGINE_TRANSPORT_ERROR_CODES = [
|
|
155
|
+
"engine_transport_unavailable",
|
|
156
|
+
"engine_transport_lost",
|
|
157
|
+
"engine_open_timeout",
|
|
158
|
+
"engine_frame_too_large",
|
|
159
|
+
"engine_backpressure_overflow"
|
|
160
|
+
];
|
|
161
|
+
var ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY = {
|
|
162
|
+
engine_prompt_not_delivered: "The task never reached the child pi (zero stdout after the prompt write, or the engine stdin was unavailable). Re-run the task; if it recurs, inspect the engine/pi logs (the failure carries the delivery diagnostics) and the runtime log.",
|
|
163
|
+
engine_prompt_rejected: "The child pi explicitly rejected the prompt command (success:false). Check the pi-side reason carried in the error detail (busy/queue/extension takeover states are reported by pi itself), then re-run.",
|
|
164
|
+
engine_spawn_handshake_timeout: "The engine spawn handshake did not complete in time. Check the runtime log for a spawn/handshake stall, then restart taiji and re-run the task."
|
|
165
|
+
};
|
|
166
|
+
var ENGINE_TRANSPORT_ERROR_RECOVERY = {
|
|
167
|
+
engine_transport_unavailable: "The runtime control socket is unreachable (connect or hello failed). The runtime side is failing explicitly instead of silently falling back to local spawn \u2014 restart taiji and re-run the task.",
|
|
168
|
+
engine_transport_lost: "The control connection to the runtime was lost mid-flight (runtime restart or crash). In-flight requests were rejected; restart taiji (or wait for the runtime to come back) and re-run the task \u2014 the connection is not retried in place.",
|
|
169
|
+
engine_open_timeout: "The runtime did not finish opening the engine channel in time (spawn/attribution stalled). Check the runtime log (engine opened / kill decision lines), then re-run the task.",
|
|
170
|
+
engine_frame_too_large: "A single frame exceeded the control-plane size limit and the channel was closed without truncation. Shrink the task/result payload (e.g. point the agent at files instead of inlining them) and re-run.",
|
|
171
|
+
engine_backpressure_overflow: "The control-plane write queue overflowed (engine consumed frames too slowly) and the overflowed scope was torn down without dropping frames silently. Re-run the task; if it recurs, reduce concurrent subagent fan-out."
|
|
172
|
+
};
|
|
135
173
|
var SET_MODEL_ERROR_CODES = [
|
|
136
174
|
/** 目标模型不在当前进程快照(子进程模型快照冻结于 spawn 时刻——模型本身有效,
|
|
137
175
|
* 下一轮 spawn 现取目录即可用;宿主按「写覆盖意图」处置,设计 §7.2 快照型失败行)。 */
|
|
@@ -176,7 +214,7 @@ var EngineSdkError = class extends Error {
|
|
|
176
214
|
this.recovery = recovery;
|
|
177
215
|
this.data = data;
|
|
178
216
|
}
|
|
179
|
-
/** 协议 error
|
|
217
|
+
/** 协议 error 帧载荷派生视图。 */
|
|
180
218
|
toStructured() {
|
|
181
219
|
return { code: this.code, message: this.message, recovery: this.recovery, data: this.data };
|
|
182
220
|
}
|
|
@@ -227,12 +265,39 @@ function schemaEmulationFailedDetail(error, tail) {
|
|
|
227
265
|
return `structured output emulation failed after tolerant extraction and one host-side retry: ${error}. Raw output tail: ${truncate(tail, DETAIL_ECHO_MAX_CHARS)}. Recovery: retry with a strengthened prompt or relax the schema; if it still fails switch to a schema-native engine (engine: pi).`;
|
|
228
266
|
}
|
|
229
267
|
|
|
268
|
+
// src/protocol/control-protocol.ts
|
|
269
|
+
var SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
|
|
270
|
+
var SUBAGENT_CONTROL_FRAME_KINDS = {
|
|
271
|
+
hello: "hello",
|
|
272
|
+
helloOk: "hello_ok",
|
|
273
|
+
helloReject: "hello_reject",
|
|
274
|
+
engineOpen: "engine_open",
|
|
275
|
+
engineOpened: "engine_opened",
|
|
276
|
+
engineOpenFailed: "engine_open_failed",
|
|
277
|
+
engineFrame: "engine_frame",
|
|
278
|
+
engineClose: "engine_close",
|
|
279
|
+
engineClosed: "engine_closed",
|
|
280
|
+
error: "error"
|
|
281
|
+
};
|
|
282
|
+
function isSubagentControlFrameKind(value) {
|
|
283
|
+
return typeof value === "string" && Object.values(SUBAGENT_CONTROL_FRAME_KINDS).includes(value);
|
|
284
|
+
}
|
|
285
|
+
var SUBAGENT_CONTROL_CLOSED_REASONS = {
|
|
286
|
+
engineExit: "engine_exit",
|
|
287
|
+
engineSignal: "engine_signal",
|
|
288
|
+
killedByControl: "killed_by_control",
|
|
289
|
+
openTimeout: "open_timeout"
|
|
290
|
+
};
|
|
291
|
+
function isSubagentControlClosedReason(value) {
|
|
292
|
+
return typeof value === "string" && Object.values(SUBAGENT_CONTROL_CLOSED_REASONS).includes(value);
|
|
293
|
+
}
|
|
294
|
+
|
|
230
295
|
// src/protocol/contract-types.ts
|
|
231
296
|
var AGENT_EVENT_TYPE_NAMES = [
|
|
232
297
|
"tool_start",
|
|
233
298
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 tool 起始占位(显示降级),turn 结构不受损
|
|
234
299
|
"tool_end",
|
|
235
|
-
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn
|
|
300
|
+
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn 收尾由 turn_end/message_end 承担
|
|
236
301
|
"text_delta",
|
|
237
302
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺正文增量,不产生半解析状态
|
|
238
303
|
"thinking_delta",
|
|
@@ -240,16 +305,35 @@ var AGENT_EVENT_TYPE_NAMES = [
|
|
|
240
305
|
"turn_end",
|
|
241
306
|
// noop-safe: 旧宿主 default 分支零写入——丢弃则该 turn 滞留进行态,journal 重放仍按序重建
|
|
242
307
|
"message_end",
|
|
243
|
-
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage
|
|
308
|
+
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage 聚合与结束计量,已累积内容不回滚
|
|
244
309
|
"compaction",
|
|
245
310
|
// noop-safe: 事件无载荷且现行 reducer 即直接 return——丢弃与处理零差异
|
|
246
311
|
"activity",
|
|
247
312
|
// noop-safe: 纯活性信号,双侧 reducer 恒 no-op(协议语义见 AgentEvent 头注),丢弃零差异
|
|
248
313
|
"error",
|
|
249
314
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 lastError 诊断留痕,已写状态不回滚
|
|
250
|
-
"armed"
|
|
315
|
+
"armed",
|
|
251
316
|
// noop-safe: 旧宿主无武装等待窗消费点(fail-fast 属宿主新增逻辑),丢弃仅缺武装留痕,schema 强制第一道防线(引擎自查断言)不受损
|
|
317
|
+
"auto_retry"
|
|
318
|
+
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺重试边界留痕(journal 不可查失败尝试轨迹),轮成败判定与 turns/usage 计账不受损(P5 计账锚在引擎侧收尾快照,不依赖宿主消费本帧)
|
|
252
319
|
];
|
|
320
|
+
var _EventVocabSyncLock = true;
|
|
321
|
+
var FAILURE_CAUSE_CLOSED_KINDS = [
|
|
322
|
+
"rate_limited",
|
|
323
|
+
"protocol_unsupported",
|
|
324
|
+
"turn_budget_exhausted",
|
|
325
|
+
"timeout",
|
|
326
|
+
"no_deliverable",
|
|
327
|
+
"cancelled"
|
|
328
|
+
];
|
|
329
|
+
var FAILURE_CAUSE_KIND_VOCAB_LOCK = true;
|
|
330
|
+
var FAILURE_CAUSE_KINDS_BY_CLASS = {
|
|
331
|
+
provider: ["rate_limited", "protocol_unsupported"],
|
|
332
|
+
harness: ["turn_budget_exhausted", "timeout"],
|
|
333
|
+
agent: ["no_deliverable"],
|
|
334
|
+
user: ["cancelled"]
|
|
335
|
+
};
|
|
336
|
+
var FAILURE_CAUSE_KINDS_BY_CLASS_LOCK = true;
|
|
253
337
|
|
|
254
338
|
// src/protocol/schema.ts
|
|
255
339
|
var ANY_JSON = {};
|
|
@@ -322,7 +406,7 @@ var notificationFrameSchema = {
|
|
|
322
406
|
type: {
|
|
323
407
|
type: "string",
|
|
324
408
|
// 事件 enum 从词表 SSOT 派生(U2 词表锁:union⟷词表互证后,此处不再
|
|
325
|
-
//
|
|
409
|
+
// 手写字面量集合——手写即漂移点,问题点 1 的第三处同步点)
|
|
326
410
|
enum: [...AGENT_EVENT_TYPE_NAMES]
|
|
327
411
|
}
|
|
328
412
|
}
|
|
@@ -387,8 +471,16 @@ var runSessionParamsSchema = {
|
|
|
387
471
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
388
472
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
389
473
|
ENGINE_PROTOCOL_VERSION,
|
|
474
|
+
ENGINE_SPAWN_DELIVERY_ERROR_CODES,
|
|
475
|
+
ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
|
|
390
476
|
ENGINE_TIMEOUT_RECOVERY,
|
|
477
|
+
ENGINE_TRANSPORT_ERROR_CODES,
|
|
478
|
+
ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
391
479
|
EngineSdkError,
|
|
480
|
+
FAILURE_CAUSE_CLOSED_KINDS,
|
|
481
|
+
FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
482
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
483
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
392
484
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
393
485
|
HANDSHAKE_TIMEOUT_MS,
|
|
394
486
|
PROTOCOL_METHODS,
|
|
@@ -401,7 +493,11 @@ var runSessionParamsSchema = {
|
|
|
401
493
|
SET_MODEL_STAGE_TIMEOUT_MS,
|
|
402
494
|
STDERR_TAIL_CHARS,
|
|
403
495
|
STDOUT_TAIL_ECHO_CHARS,
|
|
496
|
+
SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
497
|
+
SUBAGENT_CONTROL_FRAME_KINDS,
|
|
498
|
+
SUBAGENT_CONTROL_PROTOCOL_VERSION,
|
|
404
499
|
SUPPORTED_PROTOCOL_RANGE,
|
|
500
|
+
_EventVocabSyncLock,
|
|
405
501
|
assertChatConversationSupported,
|
|
406
502
|
engineConversationUnsupportedError,
|
|
407
503
|
engineProtocolMismatchError,
|
|
@@ -415,6 +511,8 @@ var runSessionParamsSchema = {
|
|
|
415
511
|
isRequestFrame,
|
|
416
512
|
isResponseFrame,
|
|
417
513
|
isReverseRequestFrame,
|
|
514
|
+
isSubagentControlClosedReason,
|
|
515
|
+
isSubagentControlFrameKind,
|
|
418
516
|
notificationFrameSchema,
|
|
419
517
|
protocolErrorSchema,
|
|
420
518
|
requestFrameSchema,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as
|
|
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-
|
|
1
|
+
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_SPAWN_DELIVERY_ERROR_CODES, d as ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY, e as ENGINE_TIMEOUT_RECOVERY, f as ENGINE_TRANSPORT_ERROR_CODES, g as ENGINE_TRANSPORT_ERROR_RECOVERY, h as EngineProtocolErrorCode, E as EngineSdkError, i as EngineSpawnDeliveryErrorCode, j as EngineTransportErrorCode, k as ErrorResponseFrame, l as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, m as ResponseFrame, n as ReverseRequestFrame, o as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, p as SET_MODEL_NOT_ACTIVE_CODE, q as STDOUT_TAIL_ECHO_CHARS, r as SetModelErrorCode, s as SuccessResponseFrame, t as assertChatConversationSupported, u as engineConversationUnsupportedError, v as engineProtocolMismatchError, w as engineSetModelUnsupportedError, x as engineTimeoutDetail, y as isEngineErrorPassthroughCode, z as isEngineProtocolErrorCode, A as isNotificationFrame, B as isRequestFrame, C as isResponseFrame, D as isReverseRequestFrame, F as schemaEmulationFailedDetail } from '../error-codes-CgcjlmeD.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-BzvzcCrB.cjs';
|
|
3
3
|
import { UiRequest, UiResponse } from '../ui-types.cjs';
|
|
4
|
-
export {
|
|
4
|
+
export { h as AGENT_EVENT_TYPE_NAMES, c as AgentCallOpts, A as AgentEvent, i as AgentEventTypeName, j as AgentFailureKind, d as AgentOutcome, k as AgentOutcomeUsage, a as AgentUsage, b as AgentUsageTotal, l as AssertMutuallyAssignable, e as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, n as EngineStopReason, F as FAILURE_CAUSE_CLOSED_KINDS, o as FAILURE_CAUSE_KINDS_BY_CLASS, p as FAILURE_CAUSE_KINDS_BY_CLASS_LOCK, q as FAILURE_CAUSE_KIND_VOCAB_LOCK, r as FailureCause, s as FailureCauseClass, t as FailureRetryability, I as InternalToolCall, g as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, f as ResumeAnchor, S as SessionView, u as ToolCall, v as ToolCallEntry, w as ToolCallResult, T as Turn, W as WorktreeHandle, _ as _EventVocabSyncLock } from '../contract-types-C1scOS_M.cjs';
|
|
5
5
|
|
|
6
6
|
/** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
7
7
|
declare const ENGINE_PROTOCOL_VERSION = 1;
|
|
@@ -15,7 +15,7 @@ declare const SUPPORTED_PROTOCOL_RANGE: {
|
|
|
15
15
|
};
|
|
16
16
|
/** 版本兼容判定(core 握手判据;引擎侧对称用于拒绝过旧/过新宿主)。 */
|
|
17
17
|
declare function isProtocolVersionCompatible(version: number): boolean;
|
|
18
|
-
/**
|
|
18
|
+
/** 正向数据范围反向请求(帧④数据范围类)未应答容忍时长:10s 未答 = 引擎故障 → 杀进程 + 在途 run 失败。 */
|
|
19
19
|
declare const REVERSE_REQUEST_TIMEOUT_MS = 10000;
|
|
20
20
|
/** initialize 握手超时(ms):超时 → engine_handshake_timeout,该引擎不可用。 */
|
|
21
21
|
declare const HANDSHAKE_TIMEOUT_MS = 10000;
|
|
@@ -24,22 +24,22 @@ declare const CANCEL_SETTLE_GRACE_MS = 3000;
|
|
|
24
24
|
/**
|
|
25
25
|
* setModel 引擎侧单阶段控制窗(ms):pi 实现等子进程 `set_model` 应答、等
|
|
26
26
|
* `get_state` 回读各占一窗(设计 subagent-model-switch §7.3——命令与回读全程带
|
|
27
|
-
*
|
|
27
|
+
* 存活检查,超时上限复用现役取消收敛窗量级:控制范围单请求 = 秒级)。窗满且进程
|
|
28
28
|
* 仍存活 → `engine_state_readback_failed`;窗满时进程已退出 → 无活进程形态
|
|
29
29
|
* (`SET_MODEL_NOT_ACTIVE_CODE`)——两种处置不可混淆。
|
|
30
30
|
*/
|
|
31
31
|
declare const SET_MODEL_STAGE_TIMEOUT_MS = 3000;
|
|
32
32
|
/**
|
|
33
33
|
* setModel 正向方法的宿主侧单请求上界(ms):≥ 引擎侧两阶段最坏时延
|
|
34
|
-
* (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 =
|
|
35
|
-
* REVERSE_REQUEST_TIMEOUT_MS 的 10s
|
|
34
|
+
* (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据范围单请求
|
|
35
|
+
* REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制范围单请求必须秒级有界——宿主不悬挂)。
|
|
36
36
|
*/
|
|
37
37
|
declare const SET_MODEL_REQUEST_TIMEOUT_MS = 10000;
|
|
38
38
|
/** stderr 内存环形缓冲保留的尾部字符数(engine_crashed 帧携带崩溃现场)。 */
|
|
39
39
|
declare const STDERR_TAIL_CHARS = 400;
|
|
40
40
|
/**
|
|
41
41
|
* 反向请求超时二分(帧④注释,R9-2):
|
|
42
|
-
* -
|
|
42
|
+
* - 数据范围类(host/log / host/streamDelta / host/handleReady /
|
|
43
43
|
* host/childSpawned / host/childStateChanged):10s 未答 = 引擎故障;
|
|
44
44
|
* - 人机交互类(host/askUser):不设统一超时——core 先回 {ack:true},
|
|
45
45
|
* 结果异步到达;按 ADR-0047「静默 ≠ 卡死」用无进展检测/用户取消,不据此判引擎故障。
|
|
@@ -55,11 +55,11 @@ type ReverseChannel = "host/log" | "host/askUser" | "host/streamDelta" | "host/h
|
|
|
55
55
|
*/
|
|
56
56
|
declare const REVERSE_CHANNELS: readonly ["host/log", "host/askUser", "host/streamDelta", "host/handleReady", "host/childSpawned", "host/childStateChanged"];
|
|
57
57
|
/**
|
|
58
|
-
* 超时二分归属(10s
|
|
58
|
+
* 超时二分归属(10s 数据范围 / 不设统一超时的人机交互通道)。实现归 W2 EngineClient;
|
|
59
59
|
* 引擎侧自灭计时(W12)复用同表——已 ack 的 askUser 等待不计入 in-flight(R9-2)。
|
|
60
60
|
*/
|
|
61
61
|
declare const REVERSE_CHANNEL_TIMEOUT_CLASS: Record<ReverseChannel, ReverseRequestTimeoutClass>;
|
|
62
|
-
/** host/log:引擎日志落宿主日志(对齐 core HostServices.log
|
|
62
|
+
/** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用范围)。 */
|
|
63
63
|
interface HostLogParams {
|
|
64
64
|
level: "debug" | "warn" | "error";
|
|
65
65
|
component: string;
|
|
@@ -87,7 +87,7 @@ interface HostStreamDeltaParams {
|
|
|
87
87
|
/**
|
|
88
88
|
* host/handleReady:运行中句柄回填(core onHandleReady 语义:session/create 应答后、
|
|
89
89
|
* 早于 run resolve;AGENTS.md 关键规则 9「重开 session 仍可见」的前提)。
|
|
90
|
-
* [池抽象降级 2026-09-13] 原 poolKey
|
|
90
|
+
* [池抽象降级 2026-09-13] 原 poolKey 字段已随协议范围 poolKey 退役删除。
|
|
91
91
|
*/
|
|
92
92
|
interface HostHandleReadyParams {
|
|
93
93
|
runId: string;
|
|
@@ -103,7 +103,7 @@ interface HostChildSpawnedParams {
|
|
|
103
103
|
recordId: string;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
-
* host/childStateChanged:childSpawned
|
|
106
|
+
* host/childStateChanged:childSpawned 的状态侧(core 侧镜像数据源,
|
|
107
107
|
* hasLiveProcessHandle/isResumable 同步读镜像,不跨进程查询)。
|
|
108
108
|
* **killed 必含**(判据 `child !== undefined && !child.killed`)——类型层 required。
|
|
109
109
|
*/
|
|
@@ -117,6 +117,49 @@ interface HostChildStateChangedParams {
|
|
|
117
117
|
signal?: string;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/** control 协议版本(帧 v 字段;runtime 与 extension 同包分发,未知 v → hello_reject {reason:"version"},D9 版本矩阵)。 */
|
|
121
|
+
declare const SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
|
|
122
|
+
/**
|
|
123
|
+
* 帧 kind 判别值词表(10 成员)。as const 值即字面量类型——类型位置同样可用。
|
|
124
|
+
* 方向语义见文件头帧表:hello/engine_open/engine_frame/engine_close 为 C→R,
|
|
125
|
+
* hello_ok/hello_reject/engine_opened/engine_open_failed/engine_closed/error 为 R→C,
|
|
126
|
+
* engine_frame 双向。
|
|
127
|
+
*/
|
|
128
|
+
declare const SUBAGENT_CONTROL_FRAME_KINDS: {
|
|
129
|
+
readonly hello: "hello";
|
|
130
|
+
readonly helloOk: "hello_ok";
|
|
131
|
+
readonly helloReject: "hello_reject";
|
|
132
|
+
readonly engineOpen: "engine_open";
|
|
133
|
+
readonly engineOpened: "engine_opened";
|
|
134
|
+
readonly engineOpenFailed: "engine_open_failed";
|
|
135
|
+
readonly engineFrame: "engine_frame";
|
|
136
|
+
readonly engineClose: "engine_close";
|
|
137
|
+
readonly engineClosed: "engine_closed";
|
|
138
|
+
readonly error: "error";
|
|
139
|
+
};
|
|
140
|
+
type SubagentControlFrameKind = (typeof SUBAGENT_CONTROL_FRAME_KINDS)[keyof typeof SUBAGENT_CONTROL_FRAME_KINDS];
|
|
141
|
+
/** unknown → control 帧 kind 收窄(外部输入携带 kind 时的运行时 guard)。 */
|
|
142
|
+
declare function isSubagentControlFrameKind(value: unknown): value is SubagentControlFrameKind;
|
|
143
|
+
/**
|
|
144
|
+
* engine_closed 帧 reason 值域(引擎通道终局归因,D8/D10):
|
|
145
|
+
* - engine_exit:引擎进程自行退出(code 承载退出码);
|
|
146
|
+
* - engine_signal:被信号终止(signal 承载信号名);
|
|
147
|
+
* - killed_by_control:runtime 主动杀组(engine_close 有界等待超时 / 背压溢出 /
|
|
148
|
+
* 连接关闭 fan-out 等控制面裁决);
|
|
149
|
+
* - open_timeout:engine_open 超时被 runtime 中止杀组(迟到 engine_opened 丢弃)。
|
|
150
|
+
* 意外退出(engine_exit/engine_signal)→ runtime 无条件 killEngineGroup(D7);
|
|
151
|
+
* runtime transport 把 reason 映射进 onExit info(stderrTail 同帧携带)。
|
|
152
|
+
*/
|
|
153
|
+
declare const SUBAGENT_CONTROL_CLOSED_REASONS: {
|
|
154
|
+
readonly engineExit: "engine_exit";
|
|
155
|
+
readonly engineSignal: "engine_signal";
|
|
156
|
+
readonly killedByControl: "killed_by_control";
|
|
157
|
+
readonly openTimeout: "open_timeout";
|
|
158
|
+
};
|
|
159
|
+
type SubagentControlClosedReason = (typeof SUBAGENT_CONTROL_CLOSED_REASONS)[keyof typeof SUBAGENT_CONTROL_CLOSED_REASONS];
|
|
160
|
+
/** unknown → engine_closed reason 收窄(外部输入携带 reason 时的运行时 guard)。 */
|
|
161
|
+
declare function isSubagentControlClosedReason(value: unknown): value is SubagentControlClosedReason;
|
|
162
|
+
|
|
120
163
|
/** 协议错误对象 schema。 */
|
|
121
164
|
declare const protocolErrorSchema: {
|
|
122
165
|
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
@@ -235,7 +278,7 @@ declare const notificationFrameSchema: {
|
|
|
235
278
|
readonly properties: {
|
|
236
279
|
readonly type: {
|
|
237
280
|
readonly type: "string";
|
|
238
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
281
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed", "auto_retry"];
|
|
239
282
|
};
|
|
240
283
|
};
|
|
241
284
|
};
|
|
@@ -355,7 +398,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
355
398
|
readonly properties: {
|
|
356
399
|
readonly type: {
|
|
357
400
|
readonly type: "string";
|
|
358
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
401
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed", "auto_retry"];
|
|
359
402
|
};
|
|
360
403
|
};
|
|
361
404
|
};
|
|
@@ -404,7 +447,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
404
447
|
};
|
|
405
448
|
};
|
|
406
449
|
/**
|
|
407
|
-
*
|
|
450
|
+
* 协议范围凭据禁区键名(不变量 5 的测试断言依据):帧 schema 与深载荷 TS 类型范围
|
|
408
451
|
* 不得出现。词表覆盖常见拼写(子串匹配,非精确枚举)。
|
|
409
452
|
*/
|
|
410
453
|
declare const FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: readonly ["apikey", "api_key", "token", "credential", "password", "secret"];
|
|
@@ -446,4 +489,4 @@ declare const runSessionParamsSchema: {
|
|
|
446
489
|
};
|
|
447
490
|
};
|
|
448
491
|
|
|
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 };
|
|
492
|
+
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, SUBAGENT_CONTROL_CLOSED_REASONS, SUBAGENT_CONTROL_FRAME_KINDS, SUBAGENT_CONTROL_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_RANGE, type SubagentControlClosedReason, type SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as
|
|
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-
|
|
1
|
+
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_SPAWN_DELIVERY_ERROR_CODES, d as ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY, e as ENGINE_TIMEOUT_RECOVERY, f as ENGINE_TRANSPORT_ERROR_CODES, g as ENGINE_TRANSPORT_ERROR_RECOVERY, h as EngineProtocolErrorCode, E as EngineSdkError, i as EngineSpawnDeliveryErrorCode, j as EngineTransportErrorCode, k as ErrorResponseFrame, l as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, m as ResponseFrame, n as ReverseRequestFrame, o as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, p as SET_MODEL_NOT_ACTIVE_CODE, q as STDOUT_TAIL_ECHO_CHARS, r as SetModelErrorCode, s as SuccessResponseFrame, t as assertChatConversationSupported, u as engineConversationUnsupportedError, v as engineProtocolMismatchError, w as engineSetModelUnsupportedError, x as engineTimeoutDetail, y as isEngineErrorPassthroughCode, z as isEngineProtocolErrorCode, A as isNotificationFrame, B as isRequestFrame, C as isResponseFrame, D as isReverseRequestFrame, F as schemaEmulationFailedDetail } from '../error-codes-o4rNd1Ee.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-CPMc4cvF.js';
|
|
3
3
|
import { UiRequest, UiResponse } from '../ui-types.js';
|
|
4
|
-
export {
|
|
4
|
+
export { h as AGENT_EVENT_TYPE_NAMES, c as AgentCallOpts, A as AgentEvent, i as AgentEventTypeName, j as AgentFailureKind, d as AgentOutcome, k as AgentOutcomeUsage, a as AgentUsage, b as AgentUsageTotal, l as AssertMutuallyAssignable, e as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, n as EngineStopReason, F as FAILURE_CAUSE_CLOSED_KINDS, o as FAILURE_CAUSE_KINDS_BY_CLASS, p as FAILURE_CAUSE_KINDS_BY_CLASS_LOCK, q as FAILURE_CAUSE_KIND_VOCAB_LOCK, r as FailureCause, s as FailureCauseClass, t as FailureRetryability, I as InternalToolCall, g as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, f as ResumeAnchor, S as SessionView, u as ToolCall, v as ToolCallEntry, w as ToolCallResult, T as Turn, W as WorktreeHandle, _ as _EventVocabSyncLock } from '../contract-types-C1scOS_M.js';
|
|
5
5
|
|
|
6
6
|
/** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
7
7
|
declare const ENGINE_PROTOCOL_VERSION = 1;
|
|
@@ -15,7 +15,7 @@ declare const SUPPORTED_PROTOCOL_RANGE: {
|
|
|
15
15
|
};
|
|
16
16
|
/** 版本兼容判定(core 握手判据;引擎侧对称用于拒绝过旧/过新宿主)。 */
|
|
17
17
|
declare function isProtocolVersionCompatible(version: number): boolean;
|
|
18
|
-
/**
|
|
18
|
+
/** 正向数据范围反向请求(帧④数据范围类)未应答容忍时长:10s 未答 = 引擎故障 → 杀进程 + 在途 run 失败。 */
|
|
19
19
|
declare const REVERSE_REQUEST_TIMEOUT_MS = 10000;
|
|
20
20
|
/** initialize 握手超时(ms):超时 → engine_handshake_timeout,该引擎不可用。 */
|
|
21
21
|
declare const HANDSHAKE_TIMEOUT_MS = 10000;
|
|
@@ -24,22 +24,22 @@ declare const CANCEL_SETTLE_GRACE_MS = 3000;
|
|
|
24
24
|
/**
|
|
25
25
|
* setModel 引擎侧单阶段控制窗(ms):pi 实现等子进程 `set_model` 应答、等
|
|
26
26
|
* `get_state` 回读各占一窗(设计 subagent-model-switch §7.3——命令与回读全程带
|
|
27
|
-
*
|
|
27
|
+
* 存活检查,超时上限复用现役取消收敛窗量级:控制范围单请求 = 秒级)。窗满且进程
|
|
28
28
|
* 仍存活 → `engine_state_readback_failed`;窗满时进程已退出 → 无活进程形态
|
|
29
29
|
* (`SET_MODEL_NOT_ACTIVE_CODE`)——两种处置不可混淆。
|
|
30
30
|
*/
|
|
31
31
|
declare const SET_MODEL_STAGE_TIMEOUT_MS = 3000;
|
|
32
32
|
/**
|
|
33
33
|
* setModel 正向方法的宿主侧单请求上界(ms):≥ 引擎侧两阶段最坏时延
|
|
34
|
-
* (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 =
|
|
35
|
-
* REVERSE_REQUEST_TIMEOUT_MS 的 10s
|
|
34
|
+
* (2 × SET_MODEL_STAGE_TIMEOUT_MS)+ 协议余量;量级锚 = 数据范围单请求
|
|
35
|
+
* REVERSE_REQUEST_TIMEOUT_MS 的 10s 先例(控制范围单请求必须秒级有界——宿主不悬挂)。
|
|
36
36
|
*/
|
|
37
37
|
declare const SET_MODEL_REQUEST_TIMEOUT_MS = 10000;
|
|
38
38
|
/** stderr 内存环形缓冲保留的尾部字符数(engine_crashed 帧携带崩溃现场)。 */
|
|
39
39
|
declare const STDERR_TAIL_CHARS = 400;
|
|
40
40
|
/**
|
|
41
41
|
* 反向请求超时二分(帧④注释,R9-2):
|
|
42
|
-
* -
|
|
42
|
+
* - 数据范围类(host/log / host/streamDelta / host/handleReady /
|
|
43
43
|
* host/childSpawned / host/childStateChanged):10s 未答 = 引擎故障;
|
|
44
44
|
* - 人机交互类(host/askUser):不设统一超时——core 先回 {ack:true},
|
|
45
45
|
* 结果异步到达;按 ADR-0047「静默 ≠ 卡死」用无进展检测/用户取消,不据此判引擎故障。
|
|
@@ -55,11 +55,11 @@ type ReverseChannel = "host/log" | "host/askUser" | "host/streamDelta" | "host/h
|
|
|
55
55
|
*/
|
|
56
56
|
declare const REVERSE_CHANNELS: readonly ["host/log", "host/askUser", "host/streamDelta", "host/handleReady", "host/childSpawned", "host/childStateChanged"];
|
|
57
57
|
/**
|
|
58
|
-
* 超时二分归属(10s
|
|
58
|
+
* 超时二分归属(10s 数据范围 / 不设统一超时的人机交互通道)。实现归 W2 EngineClient;
|
|
59
59
|
* 引擎侧自灭计时(W12)复用同表——已 ack 的 askUser 等待不计入 in-flight(R9-2)。
|
|
60
60
|
*/
|
|
61
61
|
declare const REVERSE_CHANNEL_TIMEOUT_CLASS: Record<ReverseChannel, ReverseRequestTimeoutClass>;
|
|
62
|
-
/** host/log:引擎日志落宿主日志(对齐 core HostServices.log
|
|
62
|
+
/** host/log:引擎日志落宿主日志(对齐 core HostServices.log 调用范围)。 */
|
|
63
63
|
interface HostLogParams {
|
|
64
64
|
level: "debug" | "warn" | "error";
|
|
65
65
|
component: string;
|
|
@@ -87,7 +87,7 @@ interface HostStreamDeltaParams {
|
|
|
87
87
|
/**
|
|
88
88
|
* host/handleReady:运行中句柄回填(core onHandleReady 语义:session/create 应答后、
|
|
89
89
|
* 早于 run resolve;AGENTS.md 关键规则 9「重开 session 仍可见」的前提)。
|
|
90
|
-
* [池抽象降级 2026-09-13] 原 poolKey
|
|
90
|
+
* [池抽象降级 2026-09-13] 原 poolKey 字段已随协议范围 poolKey 退役删除。
|
|
91
91
|
*/
|
|
92
92
|
interface HostHandleReadyParams {
|
|
93
93
|
runId: string;
|
|
@@ -103,7 +103,7 @@ interface HostChildSpawnedParams {
|
|
|
103
103
|
recordId: string;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
-
* host/childStateChanged:childSpawned
|
|
106
|
+
* host/childStateChanged:childSpawned 的状态侧(core 侧镜像数据源,
|
|
107
107
|
* hasLiveProcessHandle/isResumable 同步读镜像,不跨进程查询)。
|
|
108
108
|
* **killed 必含**(判据 `child !== undefined && !child.killed`)——类型层 required。
|
|
109
109
|
*/
|
|
@@ -117,6 +117,49 @@ interface HostChildStateChangedParams {
|
|
|
117
117
|
signal?: string;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/** control 协议版本(帧 v 字段;runtime 与 extension 同包分发,未知 v → hello_reject {reason:"version"},D9 版本矩阵)。 */
|
|
121
|
+
declare const SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
|
|
122
|
+
/**
|
|
123
|
+
* 帧 kind 判别值词表(10 成员)。as const 值即字面量类型——类型位置同样可用。
|
|
124
|
+
* 方向语义见文件头帧表:hello/engine_open/engine_frame/engine_close 为 C→R,
|
|
125
|
+
* hello_ok/hello_reject/engine_opened/engine_open_failed/engine_closed/error 为 R→C,
|
|
126
|
+
* engine_frame 双向。
|
|
127
|
+
*/
|
|
128
|
+
declare const SUBAGENT_CONTROL_FRAME_KINDS: {
|
|
129
|
+
readonly hello: "hello";
|
|
130
|
+
readonly helloOk: "hello_ok";
|
|
131
|
+
readonly helloReject: "hello_reject";
|
|
132
|
+
readonly engineOpen: "engine_open";
|
|
133
|
+
readonly engineOpened: "engine_opened";
|
|
134
|
+
readonly engineOpenFailed: "engine_open_failed";
|
|
135
|
+
readonly engineFrame: "engine_frame";
|
|
136
|
+
readonly engineClose: "engine_close";
|
|
137
|
+
readonly engineClosed: "engine_closed";
|
|
138
|
+
readonly error: "error";
|
|
139
|
+
};
|
|
140
|
+
type SubagentControlFrameKind = (typeof SUBAGENT_CONTROL_FRAME_KINDS)[keyof typeof SUBAGENT_CONTROL_FRAME_KINDS];
|
|
141
|
+
/** unknown → control 帧 kind 收窄(外部输入携带 kind 时的运行时 guard)。 */
|
|
142
|
+
declare function isSubagentControlFrameKind(value: unknown): value is SubagentControlFrameKind;
|
|
143
|
+
/**
|
|
144
|
+
* engine_closed 帧 reason 值域(引擎通道终局归因,D8/D10):
|
|
145
|
+
* - engine_exit:引擎进程自行退出(code 承载退出码);
|
|
146
|
+
* - engine_signal:被信号终止(signal 承载信号名);
|
|
147
|
+
* - killed_by_control:runtime 主动杀组(engine_close 有界等待超时 / 背压溢出 /
|
|
148
|
+
* 连接关闭 fan-out 等控制面裁决);
|
|
149
|
+
* - open_timeout:engine_open 超时被 runtime 中止杀组(迟到 engine_opened 丢弃)。
|
|
150
|
+
* 意外退出(engine_exit/engine_signal)→ runtime 无条件 killEngineGroup(D7);
|
|
151
|
+
* runtime transport 把 reason 映射进 onExit info(stderrTail 同帧携带)。
|
|
152
|
+
*/
|
|
153
|
+
declare const SUBAGENT_CONTROL_CLOSED_REASONS: {
|
|
154
|
+
readonly engineExit: "engine_exit";
|
|
155
|
+
readonly engineSignal: "engine_signal";
|
|
156
|
+
readonly killedByControl: "killed_by_control";
|
|
157
|
+
readonly openTimeout: "open_timeout";
|
|
158
|
+
};
|
|
159
|
+
type SubagentControlClosedReason = (typeof SUBAGENT_CONTROL_CLOSED_REASONS)[keyof typeof SUBAGENT_CONTROL_CLOSED_REASONS];
|
|
160
|
+
/** unknown → engine_closed reason 收窄(外部输入携带 reason 时的运行时 guard)。 */
|
|
161
|
+
declare function isSubagentControlClosedReason(value: unknown): value is SubagentControlClosedReason;
|
|
162
|
+
|
|
120
163
|
/** 协议错误对象 schema。 */
|
|
121
164
|
declare const protocolErrorSchema: {
|
|
122
165
|
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
@@ -235,7 +278,7 @@ declare const notificationFrameSchema: {
|
|
|
235
278
|
readonly properties: {
|
|
236
279
|
readonly type: {
|
|
237
280
|
readonly type: "string";
|
|
238
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
281
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed", "auto_retry"];
|
|
239
282
|
};
|
|
240
283
|
};
|
|
241
284
|
};
|
|
@@ -355,7 +398,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
355
398
|
readonly properties: {
|
|
356
399
|
readonly type: {
|
|
357
400
|
readonly type: "string";
|
|
358
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
401
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed", "auto_retry"];
|
|
359
402
|
};
|
|
360
403
|
};
|
|
361
404
|
};
|
|
@@ -404,7 +447,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
404
447
|
};
|
|
405
448
|
};
|
|
406
449
|
/**
|
|
407
|
-
*
|
|
450
|
+
* 协议范围凭据禁区键名(不变量 5 的测试断言依据):帧 schema 与深载荷 TS 类型范围
|
|
408
451
|
* 不得出现。词表覆盖常见拼写(子串匹配,非精确枚举)。
|
|
409
452
|
*/
|
|
410
453
|
declare const FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: readonly ["apikey", "api_key", "token", "credential", "password", "secret"];
|
|
@@ -446,4 +489,4 @@ declare const runSessionParamsSchema: {
|
|
|
446
489
|
};
|
|
447
490
|
};
|
|
448
491
|
|
|
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 };
|
|
492
|
+
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, SUBAGENT_CONTROL_CLOSED_REASONS, SUBAGENT_CONTROL_FRAME_KINDS, SUBAGENT_CONTROL_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_RANGE, type SubagentControlClosedReason, type SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema };
|
package/dist/protocol/index.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENT_EVENT_TYPE_NAMES,
|
|
3
3
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
4
|
+
FAILURE_CAUSE_CLOSED_KINDS,
|
|
5
|
+
FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
6
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
7
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
4
8
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
5
9
|
PROTOCOL_METHODS,
|
|
6
10
|
REVERSE_CHANNELS,
|
|
7
11
|
REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
12
|
+
SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
13
|
+
SUBAGENT_CONTROL_FRAME_KINDS,
|
|
14
|
+
SUBAGENT_CONTROL_PROTOCOL_VERSION,
|
|
15
|
+
_EventVocabSyncLock,
|
|
8
16
|
errorResponseFrameSchema,
|
|
17
|
+
isSubagentControlClosedReason,
|
|
18
|
+
isSubagentControlFrameKind,
|
|
9
19
|
notificationFrameSchema,
|
|
10
20
|
protocolErrorSchema,
|
|
11
21
|
requestFrameSchema,
|
|
12
22
|
reverseRequestFrameSchema,
|
|
13
23
|
runSessionParamsSchema,
|
|
14
24
|
successResponseFrameSchema
|
|
15
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-7R6HYT2A.js";
|
|
16
26
|
import {
|
|
17
27
|
isNotificationFrame,
|
|
18
28
|
isRequestFrame,
|
|
@@ -24,7 +34,11 @@ import {
|
|
|
24
34
|
ENGINE_ERROR_CODE_PREFIX,
|
|
25
35
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
26
36
|
ENGINE_PROTOCOL_VERSION,
|
|
37
|
+
ENGINE_SPAWN_DELIVERY_ERROR_CODES,
|
|
38
|
+
ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
|
|
27
39
|
ENGINE_TIMEOUT_RECOVERY,
|
|
40
|
+
ENGINE_TRANSPORT_ERROR_CODES,
|
|
41
|
+
ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
28
42
|
EngineSdkError,
|
|
29
43
|
HANDSHAKE_TIMEOUT_MS,
|
|
30
44
|
REVERSE_REQUEST_TIMEOUT_MS,
|
|
@@ -44,7 +58,7 @@ import {
|
|
|
44
58
|
isEngineProtocolErrorCode,
|
|
45
59
|
isProtocolVersionCompatible,
|
|
46
60
|
schemaEmulationFailedDetail
|
|
47
|
-
} from "../chunk-
|
|
61
|
+
} from "../chunk-NVF3PADP.js";
|
|
48
62
|
import "../chunk-JSBRDJBE.js";
|
|
49
63
|
export {
|
|
50
64
|
AGENT_EVENT_TYPE_NAMES,
|
|
@@ -53,8 +67,16 @@ export {
|
|
|
53
67
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
54
68
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
55
69
|
ENGINE_PROTOCOL_VERSION,
|
|
70
|
+
ENGINE_SPAWN_DELIVERY_ERROR_CODES,
|
|
71
|
+
ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
|
|
56
72
|
ENGINE_TIMEOUT_RECOVERY,
|
|
73
|
+
ENGINE_TRANSPORT_ERROR_CODES,
|
|
74
|
+
ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
57
75
|
EngineSdkError,
|
|
76
|
+
FAILURE_CAUSE_CLOSED_KINDS,
|
|
77
|
+
FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
78
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
79
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
58
80
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
59
81
|
HANDSHAKE_TIMEOUT_MS,
|
|
60
82
|
PROTOCOL_METHODS,
|
|
@@ -67,7 +89,11 @@ export {
|
|
|
67
89
|
SET_MODEL_STAGE_TIMEOUT_MS,
|
|
68
90
|
STDERR_TAIL_CHARS,
|
|
69
91
|
STDOUT_TAIL_ECHO_CHARS,
|
|
92
|
+
SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
93
|
+
SUBAGENT_CONTROL_FRAME_KINDS,
|
|
94
|
+
SUBAGENT_CONTROL_PROTOCOL_VERSION,
|
|
70
95
|
SUPPORTED_PROTOCOL_RANGE,
|
|
96
|
+
_EventVocabSyncLock,
|
|
71
97
|
assertChatConversationSupported,
|
|
72
98
|
engineConversationUnsupportedError,
|
|
73
99
|
engineProtocolMismatchError,
|
|
@@ -81,6 +107,8 @@ export {
|
|
|
81
107
|
isRequestFrame,
|
|
82
108
|
isResponseFrame,
|
|
83
109
|
isReverseRequestFrame,
|
|
110
|
+
isSubagentControlClosedReason,
|
|
111
|
+
isSubagentControlFrameKind,
|
|
84
112
|
notificationFrameSchema,
|
|
85
113
|
protocolErrorSchema,
|
|
86
114
|
requestFrameSchema,
|
package/dist/server/index.cjs
CHANGED
|
@@ -88,7 +88,7 @@ var EngineSdkError = class extends Error {
|
|
|
88
88
|
this.recovery = recovery;
|
|
89
89
|
this.data = data;
|
|
90
90
|
}
|
|
91
|
-
/** 协议 error
|
|
91
|
+
/** 协议 error 帧载荷派生视图。 */
|
|
92
92
|
toStructured() {
|
|
93
93
|
return { code: this.code, message: this.message, recovery: this.recovery, data: this.data };
|
|
94
94
|
}
|