@zhushanwen/subagent-engine-sdk 0.11.0 → 0.12.1
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-2L3I2TWJ.js → chunk-2JLFRKHK.js} +5 -1
- package/dist/{chunk-QBXDEF4N.js → chunk-7R6HYT2A.js} +25 -1
- package/dist/{chunk-YFSNX3N3.js → chunk-U5MBAKS5.js} +19 -5
- package/dist/{contract-types-BUHUMF9R.d.ts → contract-types-C1scOS_M.d.cts} +201 -4
- package/dist/{contract-types-BUHUMF9R.d.cts → contract-types-C1scOS_M.d.ts} +201 -4
- package/dist/env.cjs +5 -1
- package/dist/env.js +1 -1
- package/dist/{error-codes-D_aPibUt.d.cts → error-codes-CgcjlmeD.d.cts} +1 -1
- package/dist/{error-codes-DrNf0gwT.d.ts → error-codes-o4rNd1Ee.d.ts} +1 -1
- package/dist/index.cjs +57 -7
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +19 -3
- package/dist/journal-io.d.cts +1 -1
- package/dist/journal-io.d.ts +1 -1
- package/dist/journal-replay.cjs +22 -5
- package/dist/journal-replay.d.cts +39 -5
- package/dist/journal-replay.d.ts +39 -5
- package/dist/journal-replay.js +7 -1
- package/dist/kill-chain.d.cts +1 -1
- package/dist/kill-chain.d.ts +1 -1
- package/dist/{methods-CHiDwvRK.d.cts → methods-BzvzcCrB.d.cts} +1 -1
- package/dist/{methods-BdIH3FwS.d.ts → methods-CPMc4cvF.d.ts} +1 -1
- package/dist/port-contract.d.cts +2 -2
- package/dist/port-contract.d.ts +2 -2
- package/dist/protocol/index.cjs +30 -1
- package/dist/protocol/index.d.cts +5 -5
- package/dist/protocol/index.d.ts +5 -5
- package/dist/protocol/index.js +11 -1
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/package.json +14 -3
|
@@ -16,7 +16,11 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
16
16
|
// 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
|
|
17
17
|
// 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
|
|
18
18
|
"TAIJI_PRESET_FALLBACK_FROM",
|
|
19
|
-
"TAIJI_PRESET_FALLBACK_TO"
|
|
19
|
+
"TAIJI_PRESET_FALLBACK_TO",
|
|
20
|
+
// runtime 实例标识(connection-datasync-ssot §6.1,env 名 SSOT = shared
|
|
21
|
+
// RUNTIME_ID_ENV):supervisor 每次 spawn 签发的生命周期标志,只有 runtime 自身
|
|
22
|
+
// 消费;引擎一跳继承陈旧值 = 后代进程持有已死实例标识,出站剥除
|
|
23
|
+
"TAIJI_RUNTIME_ID"
|
|
20
24
|
];
|
|
21
25
|
var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
22
26
|
"TAIJI_AGENT_DATA_DIR",
|
|
@@ -77,9 +77,28 @@ var AGENT_EVENT_TYPE_NAMES = [
|
|
|
77
77
|
// noop-safe: 纯活性信号,双侧 reducer 恒 no-op(协议语义见 AgentEvent 头注),丢弃零差异
|
|
78
78
|
"error",
|
|
79
79
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 lastError 诊断留痕,已写状态不回滚
|
|
80
|
-
"armed"
|
|
80
|
+
"armed",
|
|
81
81
|
// noop-safe: 旧宿主无武装等待窗消费点(fail-fast 属宿主新增逻辑),丢弃仅缺武装留痕,schema 强制第一道防线(引擎自查断言)不受损
|
|
82
|
+
"auto_retry"
|
|
83
|
+
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺重试边界留痕(journal 不可查失败尝试轨迹),轮成败判定与 turns/usage 计账不受损(P5 计账锚在引擎侧收尾快照,不依赖宿主消费本帧)
|
|
82
84
|
];
|
|
85
|
+
var _EventVocabSyncLock = true;
|
|
86
|
+
var FAILURE_CAUSE_CLOSED_KINDS = [
|
|
87
|
+
"rate_limited",
|
|
88
|
+
"protocol_unsupported",
|
|
89
|
+
"turn_budget_exhausted",
|
|
90
|
+
"timeout",
|
|
91
|
+
"no_deliverable",
|
|
92
|
+
"cancelled"
|
|
93
|
+
];
|
|
94
|
+
var FAILURE_CAUSE_KIND_VOCAB_LOCK = true;
|
|
95
|
+
var FAILURE_CAUSE_KINDS_BY_CLASS = {
|
|
96
|
+
provider: ["rate_limited", "protocol_unsupported"],
|
|
97
|
+
harness: ["turn_budget_exhausted", "timeout"],
|
|
98
|
+
agent: ["no_deliverable"],
|
|
99
|
+
user: ["cancelled"]
|
|
100
|
+
};
|
|
101
|
+
var FAILURE_CAUSE_KINDS_BY_CLASS_LOCK = true;
|
|
83
102
|
|
|
84
103
|
// src/protocol/schema.ts
|
|
85
104
|
var ANY_JSON = {};
|
|
@@ -220,6 +239,11 @@ export {
|
|
|
220
239
|
SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
221
240
|
isSubagentControlClosedReason,
|
|
222
241
|
AGENT_EVENT_TYPE_NAMES,
|
|
242
|
+
_EventVocabSyncLock,
|
|
243
|
+
FAILURE_CAUSE_CLOSED_KINDS,
|
|
244
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
245
|
+
FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
246
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
223
247
|
protocolErrorSchema,
|
|
224
248
|
requestFrameSchema,
|
|
225
249
|
successResponseFrameSchema,
|
|
@@ -31,7 +31,8 @@ function createReplayRecord() {
|
|
|
31
31
|
turns: [emptyTurn()],
|
|
32
32
|
turnCount: 0,
|
|
33
33
|
totalTokens: 0,
|
|
34
|
-
lastError: void 0
|
|
34
|
+
lastError: void 0,
|
|
35
|
+
errors: []
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
function currentTurn(record) {
|
|
@@ -125,7 +126,11 @@ function applyTurnEnd(record) {
|
|
|
125
126
|
turn.closed = true;
|
|
126
127
|
turn.closedTs = Date.now();
|
|
127
128
|
record.turnCount += 1;
|
|
128
|
-
|
|
129
|
+
}
|
|
130
|
+
function appendErrorFact(record, message) {
|
|
131
|
+
if (!message) return;
|
|
132
|
+
(record.errors ??= []).push({ message, at: Date.now() });
|
|
133
|
+
record.lastError = message;
|
|
129
134
|
}
|
|
130
135
|
function applyMessageEnd(record, event) {
|
|
131
136
|
if (event.usage) {
|
|
@@ -134,11 +139,11 @@ function applyMessageEnd(record, event) {
|
|
|
134
139
|
record.totalTokens += (event.usage.input ?? 0) + (event.usage.output ?? 0) + (event.usage.cacheRead ?? 0) + (event.usage.cacheWrite ?? 0);
|
|
135
140
|
}
|
|
136
141
|
if (event.error) {
|
|
137
|
-
record
|
|
142
|
+
appendErrorFact(record, event.error);
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
function applyErrorEvent(record, event) {
|
|
141
|
-
record
|
|
146
|
+
appendErrorFact(record, event.message);
|
|
142
147
|
}
|
|
143
148
|
function updateFromEvent(record, event) {
|
|
144
149
|
switch (event.type) {
|
|
@@ -158,7 +163,7 @@ function updateFromEvent(record, event) {
|
|
|
158
163
|
// ── message_end:usage 增量累加 + totalTokens 累加 ──
|
|
159
164
|
case "message_end":
|
|
160
165
|
return applyMessageEnd(record, event);
|
|
161
|
-
// ── error
|
|
166
|
+
// ── error:appendErrorFact 入账(errors 只追加 + lastError 派生)──
|
|
162
167
|
case "error":
|
|
163
168
|
return applyErrorEvent(record, event);
|
|
164
169
|
// ── compaction:不产生数据(不变)──
|
|
@@ -172,6 +177,12 @@ function updateFromEvent(record, event) {
|
|
|
172
177
|
// 双侧 reducer no-op 义务的 SDK 侧)
|
|
173
178
|
case "armed":
|
|
174
179
|
return;
|
|
180
|
+
// ── auto_retry:pi 原生重试边界帧([subagent-observability §3.3.1 P5])——
|
|
181
|
+
// 观测面(journal 留痕失败尝试轨迹),不进 record 派生视图:失败尝试的
|
|
182
|
+
// turns/usage 切片与 retryAttempts 计数由引擎收尾快照一次产出(outcome
|
|
183
|
+
// 字段承载),reducer 写入会让失败尝试静默混进 turns 聚合,恰违背 P5 计账。
|
|
184
|
+
case "auto_retry":
|
|
185
|
+
return;
|
|
175
186
|
default: {
|
|
176
187
|
const _exhaustive = event;
|
|
177
188
|
return _exhaustive;
|
|
@@ -226,7 +237,10 @@ function sessionIdFromHandle(handle) {
|
|
|
226
237
|
}
|
|
227
238
|
|
|
228
239
|
export {
|
|
240
|
+
addUsage,
|
|
241
|
+
emptyTurn,
|
|
229
242
|
createReplayRecord,
|
|
243
|
+
appendErrorFact,
|
|
230
244
|
updateFromEvent,
|
|
231
245
|
toReplayedTurn,
|
|
232
246
|
aggregateUsage,
|
|
@@ -106,6 +106,20 @@ type AgentEvent = {
|
|
|
106
106
|
type: EventName<"armed">;
|
|
107
107
|
schemaEnvVar: string;
|
|
108
108
|
extensionPkg: string;
|
|
109
|
+
} | {
|
|
110
|
+
type: EventName<"auto_retry">;
|
|
111
|
+
/** start = 失败尝试结束即将重跑;end = 重试波次收束(成功或最终失败)。 */
|
|
112
|
+
phase: "start" | "end";
|
|
113
|
+
/** 重试波次序号(pi 原生 _retryAttempt,1 起)。 */
|
|
114
|
+
attempt: number;
|
|
115
|
+
/** start 独有:重试上限与退避等待(pi _prepareRetry 发射事实)。 */
|
|
116
|
+
maxAttempts?: number;
|
|
117
|
+
delayMs?: number;
|
|
118
|
+
/** start 携带被重试的错误文本;end 失败波携带最终错误(成功波缺省)。 */
|
|
119
|
+
errorMessage?: string;
|
|
120
|
+
/** end 独有:该波重试最终是否恢复(true = 后续尝试成功,false = 重试耗尽)。 */
|
|
121
|
+
success?: boolean;
|
|
122
|
+
finalError?: string;
|
|
109
123
|
};
|
|
110
124
|
/**
|
|
111
125
|
* 事件类型词表(协议事件全集 10 种,运行时 SSOT):schema 事件 `type.enum` 从本表
|
|
@@ -129,7 +143,7 @@ type AgentEvent = {
|
|
|
129
143
|
* switch never 检查)与 contract-closure 构造冒烟(Record<AgentEventTypeName,…>
|
|
130
144
|
* 漏键爆红)。不 bump 版本、不改任何引擎(演进政策 additive 面,判据全文见头注)。
|
|
131
145
|
*/
|
|
132
|
-
declare const AGENT_EVENT_TYPE_NAMES: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
146
|
+
declare const AGENT_EVENT_TYPE_NAMES: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed", "auto_retry"];
|
|
133
147
|
/** 词表派生的事件名联合(编译锁②/③的词表侧源;schema enum 与测试取值同源)。 */
|
|
134
148
|
type AgentEventTypeName = (typeof AGENT_EVENT_TYPE_NAMES)[number];
|
|
135
149
|
/**
|
|
@@ -138,6 +152,7 @@ type AgentEventTypeName = (typeof AGENT_EVENT_TYPE_NAMES)[number];
|
|
|
138
152
|
* 结构与运行时语义零变化。
|
|
139
153
|
*/
|
|
140
154
|
type EventName<T extends AgentEventTypeName> = T;
|
|
155
|
+
declare const _EventVocabSyncLock: AssertMutuallyAssignable<AgentEvent["type"], AgentEventTypeName>;
|
|
141
156
|
/**
|
|
142
157
|
* EngineHandle 的持久化形态(JSON v1)。协议 run 终态应答 / read 的
|
|
143
158
|
* handle 载荷(引擎不持有宿主运行时引用,data 即全部)。
|
|
@@ -298,7 +313,139 @@ interface ProbeReport {
|
|
|
298
313
|
recovery: string;
|
|
299
314
|
};
|
|
300
315
|
}
|
|
301
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* [subagent-observability §3.3.2] 失败分类权威契约(五维正交,原位替换
|
|
318
|
+
* AgentFailureKind 三值词表——本文件是引擎协议词表家址)。
|
|
319
|
+
*
|
|
320
|
+
* 由收尾边沿(判定链)一次产出并写入轮收条,下游只读不可替换(三硬规则①②——
|
|
321
|
+
* 只有知道事实的层能填 class;写入后观察性事实降级 observations,不改写 cause)。
|
|
322
|
+
* 跨进程 wire 载体 = shared `SubagentRecord.lastRound.failure`(type-only re-export,
|
|
323
|
+
* 判别联合逐字序列化)。消费锚:轮应答恢复指引(§3.3.7)、run 终局 failedMembers[].cause
|
|
324
|
+
* (§3.3.8——序列化为 `"<class>.<kind>"` 点拼字符串,retryable/retryAfterMs 不进终局
|
|
325
|
+
* 事件、由成员轮收条承载)。
|
|
326
|
+
*
|
|
327
|
+
* cause 优先级(分类边沿裁决序,严格递减):provider 事实 > harness 预算/契约 >
|
|
328
|
+
* agent 行为 > engine 崩溃 > unknown(未分类形态不产 FailureCause,落引擎停因原值)。
|
|
329
|
+
*/
|
|
330
|
+
type FailureCauseClass = "provider" | "harness" | "agent" | "engine" | "user";
|
|
331
|
+
/**
|
|
332
|
+
* retryable 三态(§3.3.2 硬规则③,与重试规则 extension 的 verdict 同词表):
|
|
333
|
+
* true = 等待后重发可恢复;
|
|
334
|
+
* false = 重发必然同样失败;
|
|
335
|
+
* "conditional" = 条件恢复——等限额重置窗口或人/账户先动作(执行层对 conditional
|
|
336
|
+
* 不自动重试,呈现层如实展示)。
|
|
337
|
+
*/
|
|
338
|
+
type FailureRetryability = true | false | "conditional";
|
|
339
|
+
/**
|
|
340
|
+
* FailureCause 公共字段面(class×kind 判别联合各成员共享)。
|
|
341
|
+
* retryable — 三态({@link FailureRetryability});429 不全可重试,禁止仅按
|
|
342
|
+
* HTTP 状态码判可重试(provider 业务码层裁决,§3.3.2 码表硬约束);
|
|
343
|
+
* retryAfterMs — 恢复等待毫秒(错误文本内重置时间字样提取——pi 消息模型不暴露
|
|
344
|
+
* HTTP 头,头通道结构性不可得,设计 §3.3.2 单文本通道),
|
|
345
|
+
* 皆无 → 缺省 unknown(undefined,不产假 0);
|
|
346
|
+
* raw — 分类输入的原始错误文本(取证链:分类不丢原文)。
|
|
347
|
+
*/
|
|
348
|
+
interface FailureCauseFields {
|
|
349
|
+
retryable: FailureRetryability;
|
|
350
|
+
retryAfterMs?: number;
|
|
351
|
+
raw: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* class×kind 合法组合矩阵(判别联合构造性成立——非法组合写不出来):
|
|
355
|
+
* provider.rate_limited / provider.protocol_unsupported / harness.turn_budget_exhausted /
|
|
356
|
+
* harness.timeout / agent.no_deliverable / user.cancelled / engine.*(`engine_${string}`
|
|
357
|
+
* 引擎自报透传族,开放前缀面——对齐 RunErrorCode 的 engine_ 透传契约,core 不解释文案)。
|
|
358
|
+
*
|
|
359
|
+
* kind 是封闭登记词表:新增成员同 commit 登记下方 {@link FAILURE_CAUSE_CLOSED_KINDS}
|
|
360
|
+
* (解析词表纪律),漏登记由 {@link FAILURE_CAUSE_KIND_VOCAB_LOCK} 编译锁拦截。
|
|
361
|
+
*/
|
|
362
|
+
type FailureCause = (FailureCauseFields & {
|
|
363
|
+
class: "provider";
|
|
364
|
+
kind: "rate_limited" | "protocol_unsupported";
|
|
365
|
+
}) | (FailureCauseFields & {
|
|
366
|
+
class: "harness";
|
|
367
|
+
kind: "turn_budget_exhausted" | "timeout";
|
|
368
|
+
/**
|
|
369
|
+
* [subagent-observability §3.3.9/UC-10] turn 预算耗尽事实(limiter abort 边沿
|
|
370
|
+
* 一次产出):used = abort 时轮数、limit = 显式 maxTurns 上界。undefined =
|
|
371
|
+
* 极端竞窗下收尾边沿只有 aborted 停因而 limiter 快照缺席(防御性同判形态,
|
|
372
|
+
* 事实不足不产结构——轮失败事实不受影响)。与 §3.3.6 查询侧 budget 分轴
|
|
373
|
+
* 结构({maxTurns, ...})同构的 {used, limit} 形态。仅 turn_budget_exhausted
|
|
374
|
+
* 承载;timeout(§3.3.6 超时轮失败分类,宿主结算点产出——timeoutMs 墙钟预算
|
|
375
|
+
* 耗尽是宿主独有事实,引擎收尾边沿只有「宿主取消 vs 引擎异常」两源判别)
|
|
376
|
+
* 不落本字段。
|
|
377
|
+
*/
|
|
378
|
+
budget?: {
|
|
379
|
+
used: number;
|
|
380
|
+
limit: number;
|
|
381
|
+
};
|
|
382
|
+
}) | (FailureCauseFields & {
|
|
383
|
+
class: "agent";
|
|
384
|
+
kind: "no_deliverable";
|
|
385
|
+
}) | (FailureCauseFields & {
|
|
386
|
+
class: "user";
|
|
387
|
+
kind: "cancelled";
|
|
388
|
+
}) | (FailureCauseFields & {
|
|
389
|
+
class: "engine";
|
|
390
|
+
kind: `engine_${string}`;
|
|
391
|
+
});
|
|
392
|
+
/**
|
|
393
|
+
* FailureCause.kind 闭合成员词表(运行时枚举完整性测试锚;engine 透传族
|
|
394
|
+
* `engine_${string}` 开放前缀面不进闭合表——逐成员断言见 failure-cause-vocabulary.test.ts)。
|
|
395
|
+
* 新增 kind 成员 = 联合与本元组同 commit 同批(编译锁双向拦截漏改)。
|
|
396
|
+
*/
|
|
397
|
+
declare const FAILURE_CAUSE_CLOSED_KINDS: readonly ["rate_limited", "protocol_unsupported", "turn_budget_exhausted", "timeout", "no_deliverable", "cancelled"];
|
|
398
|
+
/**
|
|
399
|
+
* 词表编译锁(双向):kind 联合闭合面 ⊆ 且 ⊇ FAILURE_CAUSE_CLOSED_KINDS。
|
|
400
|
+
* 联合扩值漏登元组(或元组多配联合外值)→ 本赋值 tsc 红,错误指向漏改侧。
|
|
401
|
+
*/
|
|
402
|
+
declare const FAILURE_CAUSE_KIND_VOCAB_LOCK: AssertMutuallyAssignable<Exclude<FailureCause["kind"], `engine_${string}`>, (typeof FAILURE_CAUSE_CLOSED_KINDS)[number]>;
|
|
403
|
+
/**
|
|
404
|
+
* per-class kind 合法值域(运行时可用——重试规则条目的 kind 字段按 class 校验的
|
|
405
|
+
* 唯一依据;消费方 = shared validateRetryRuleFields / retry-rules extension 侧镜像)。
|
|
406
|
+
* engine 透传族是 `engine_${string}` 开放前缀面(无闭合枚举),不进本表——engine 规则
|
|
407
|
+
* 的 kind 校验走前缀形态判定,由各消费方按 {@link FailureCause} 的 `engine_${string}`
|
|
408
|
+
* 契约自行落地。
|
|
409
|
+
*
|
|
410
|
+
* 词表编译锁:每个 class 的成员元组与 {@link FailureCause} 判别联合的对应 kind 联合
|
|
411
|
+
* 双向可赋值——判别联合扩值漏登本表(或本表多配联合外值)→ 对应行 tsc 红。
|
|
412
|
+
*/
|
|
413
|
+
declare const FAILURE_CAUSE_KINDS_BY_CLASS: {
|
|
414
|
+
readonly provider: readonly ["rate_limited", "protocol_unsupported"];
|
|
415
|
+
readonly harness: readonly ["turn_budget_exhausted", "timeout"];
|
|
416
|
+
readonly agent: readonly ["no_deliverable"];
|
|
417
|
+
readonly user: readonly ["cancelled"];
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* per-class 词表编译锁(双向):本表各 class 成员元组 ↔ 判别联合对应 kind 联合。
|
|
421
|
+
* 任一 class 漏登/多配 → 本赋值 tsc 红,错误指向漏改侧。
|
|
422
|
+
*/
|
|
423
|
+
declare const FAILURE_CAUSE_KINDS_BY_CLASS_LOCK: AssertMutuallyAssignable<{
|
|
424
|
+
provider: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["provider"][number];
|
|
425
|
+
harness: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["harness"][number];
|
|
426
|
+
agent: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["agent"][number];
|
|
427
|
+
user: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["user"][number];
|
|
428
|
+
}, {
|
|
429
|
+
provider: Extract<FailureCause, {
|
|
430
|
+
class: "provider";
|
|
431
|
+
}>["kind"];
|
|
432
|
+
harness: Extract<FailureCause, {
|
|
433
|
+
class: "harness";
|
|
434
|
+
}>["kind"];
|
|
435
|
+
agent: Extract<FailureCause, {
|
|
436
|
+
class: "agent";
|
|
437
|
+
}>["kind"];
|
|
438
|
+
user: Extract<FailureCause, {
|
|
439
|
+
class: "user";
|
|
440
|
+
}>["kind"];
|
|
441
|
+
}>;
|
|
442
|
+
/**
|
|
443
|
+
* @deprecated [subagent-observability §3.3.2,ADR-0158 终态] 三值分诊词表已由
|
|
444
|
+
* {@link FailureCause} 取代(class×kind 封闭矩阵 + retryable 三态)。本类型保留为
|
|
445
|
+
* 历史解析兼容、不删——旧 record 帧与历史 journal 的 failureKind 解析仍依赖该
|
|
446
|
+
* 通道(设计 §3.4「历史解析兼容保留项」);新写入方失败分类一律产 FailureCause,
|
|
447
|
+
* 产出侧分类器 classifyFailureKind 已退役。
|
|
448
|
+
*/
|
|
302
449
|
type AgentFailureKind = "stale_context" | "schema_deterministic" | "unknown";
|
|
303
450
|
/**
|
|
304
451
|
* AgentOutcome.usage 字段型(← core orchestration/models/types.ts AgentUsage 结构等价;
|
|
@@ -333,10 +480,28 @@ interface WorktreeHandle {
|
|
|
333
480
|
* 一次引擎执行的终态(协议 run 终态应答的 outcome 载荷)。锚定 core
|
|
334
481
|
* orchestration AgentResult 并追加引擎层字段(engineId / exitCode)。
|
|
335
482
|
*/
|
|
483
|
+
/** [subagent-observability §3.3.3] 轮终停因引擎原值三态(引擎收尾边沿事实;宿主
|
|
484
|
+
* ROUND_TERMINAL_STOP_REASONS 词表的协议侧同源镜像)。 */
|
|
485
|
+
type EngineStopReason = "stop" | "error" | "aborted";
|
|
336
486
|
interface AgentOutcome {
|
|
337
487
|
content: string;
|
|
338
|
-
/**
|
|
488
|
+
/**
|
|
489
|
+
* 失败分诊标签(历史解析兼容残留)。
|
|
490
|
+
* @deprecated [subagent-observability §3.4,ADR-0158] 新写入方失败分类一律产
|
|
491
|
+
* {@link FailureCause}(下方 failure 字段);本字段随 {@link AgentFailureKind} 保留为
|
|
492
|
+
* 旧 record 帧与历史 journal 的解析兼容。产出侧残留仅引擎送达错误码前缀确定性分诊
|
|
493
|
+
* (pi 引擎 output-collector,[D5-③ 改轨]);缺省 = undefined(字段缺位),
|
|
494
|
+
* 不承载重试判定(重试判定在 FailureCause.retryable 三态)。
|
|
495
|
+
*/
|
|
339
496
|
failureKind?: AgentFailureKind;
|
|
497
|
+
/**
|
|
498
|
+
* [subagent-observability §3.3.8] 失败分类(收尾边沿一次产出——CollectedOutcome.failure
|
|
499
|
+
* 经引擎适配层 toOutcome 透传上协议)。run 终局成员交付结算消费本字段点拼
|
|
500
|
+
* `"<class>.<kind>"` 进 failedMembers[].cause;缺省 = 未分类(cause 回落
|
|
501
|
+
* error 前缀协议码 / "unknown")。可选 = 读取面对旧格式应答放行(字段落地前
|
|
502
|
+
* 的引擎缺省,写侧契约由引擎适配层承担)。
|
|
503
|
+
*/
|
|
504
|
+
failure?: FailureCause;
|
|
340
505
|
/** native 引擎直传 / 仿真层 ajv 产出(D4 硬分流:native 路径宿主不做二次校验)。 */
|
|
341
506
|
parsedOutput?: unknown;
|
|
342
507
|
usage?: AgentOutcomeUsage;
|
|
@@ -372,6 +537,38 @@ interface AgentOutcome {
|
|
|
372
537
|
* 仅诊断引用——文件受引擎侧尺寸轮转与过期清理管辖,读侧不得假设其永存。
|
|
373
538
|
*/
|
|
374
539
|
stderrTeePath?: string;
|
|
540
|
+
/**
|
|
541
|
+
* [subagent-observability §3.3.3] 轮终停因引擎原值(收尾边沿事实一次产出,值域
|
|
542
|
+
* 三态与宿主 ROUND_TERMINAL_STOP_REASONS 同源)。宿主 one-shot 轮收条
|
|
543
|
+
* rec.lastRound.engineStopReason 的数据源——「正常收尾」派生判据(stop 且无失败
|
|
544
|
+
* 分类 = completed)依赖本事实。additive 可选(宪法判据③同 stderrTeePath 先例):
|
|
545
|
+
* 旧引擎缺省 = 宿主回落派生展示词,零行为差。
|
|
546
|
+
*/
|
|
547
|
+
engineStopReason?: EngineStopReason;
|
|
548
|
+
/**
|
|
549
|
+
* [subagent-observability §3.3.3 P5] 本 run 内 pi 原生重试的失败尝试计数
|
|
550
|
+
* (auto_retry_start 帧数;引擎 >0 时上报)。宿主轮收条 lastRound.retryAttempts
|
|
551
|
+
* 的数据源——重试轨迹可观测(失败尝试不静默计入 turns/usage)。additive 可选:
|
|
552
|
+
* 旧引擎/无重试缺省不落键。
|
|
553
|
+
*/
|
|
554
|
+
retryAttempts?: number;
|
|
555
|
+
/**
|
|
556
|
+
* [subagent-observability §3.3.1/§3.3.3] 本轮被人类接管收尾的标注(引擎判定链
|
|
557
|
+
* prompt-ack 命中 handled 时产出,值恒 "handled")。宿主轮收条
|
|
558
|
+
* lastRound.promptDisposition 的数据源——被接管轮不产失败分类、结清走 no_result、
|
|
559
|
+
* 通知走接管分支、run 聚合按未交付非失败计。additive 可选(宪法判据③同
|
|
560
|
+
* engineStopReason 先例):旧引擎缺省 = 无接管标注,零行为差。
|
|
561
|
+
*/
|
|
562
|
+
promptDisposition?: "handled";
|
|
563
|
+
/**
|
|
564
|
+
* [subagent-observability §3.3.2/§3.3.10] 观察性事实数组(引擎产出侧摘要,如
|
|
565
|
+
* 「结构化输出未调用」)。宿主轮收条 lastRound.observations 的
|
|
566
|
+
* 数据源——查询出口 list lastRound.observations 直读。additive 可选:旧引擎
|
|
567
|
+
* 缺省不落键。注意承载分源:交付谓词缺项(deliverables 未满足)在 worker 脚本
|
|
568
|
+
* 侧执行,不经本字段——落脚本结果 observations / run 终局帧 partialMembers /
|
|
569
|
+
* workflow_control 成员行 missingDeliverables 三面(§3.3.10 分源表述)。
|
|
570
|
+
*/
|
|
571
|
+
observations?: string[];
|
|
375
572
|
}
|
|
376
573
|
/**
|
|
377
574
|
* 引擎模型目录条目(manifest `modelCatalog.models` 条目形态,设计 §3.4 示例)。
|
|
@@ -464,4 +661,4 @@ interface AgentCallOpts {
|
|
|
464
661
|
permissionMode?: string;
|
|
465
662
|
}
|
|
466
663
|
|
|
467
|
-
export { type AgentEvent as A, type EngineHandleData as E, type InternalToolCall as I, type ModelRef as M, type ProbeReport as P, type ReplayedTurn as R, type SessionView as S, type Turn as T, type WorktreeHandle as W, type
|
|
664
|
+
export { type AgentEvent as A, type EngineHandleData as E, FAILURE_CAUSE_CLOSED_KINDS as F, type InternalToolCall as I, type ModelRef as M, type ProbeReport as P, type ReplayedTurn as R, type SessionView as S, type Turn as T, type WorktreeHandle as W, _EventVocabSyncLock as _, type AgentUsage as a, type AgentUsageTotal as b, type AgentCallOpts as c, type AgentOutcome as d, type EngineCapabilities as e, type ResumeAnchor as f, type ModelCatalogEntry as g, AGENT_EVENT_TYPE_NAMES as h, type AgentEventTypeName as i, type AgentFailureKind as j, type AgentOutcomeUsage as k, type AssertMutuallyAssignable as l, type EngineProcessModel as m, type EngineStopReason as n, FAILURE_CAUSE_KINDS_BY_CLASS as o, FAILURE_CAUSE_KINDS_BY_CLASS_LOCK as p, FAILURE_CAUSE_KIND_VOCAB_LOCK as q, type FailureCause as r, type FailureCauseClass as s, type FailureRetryability as t, type ToolCall as u, type ToolCallEntry as v, type ToolCallResult as w };
|
|
@@ -106,6 +106,20 @@ type AgentEvent = {
|
|
|
106
106
|
type: EventName<"armed">;
|
|
107
107
|
schemaEnvVar: string;
|
|
108
108
|
extensionPkg: string;
|
|
109
|
+
} | {
|
|
110
|
+
type: EventName<"auto_retry">;
|
|
111
|
+
/** start = 失败尝试结束即将重跑;end = 重试波次收束(成功或最终失败)。 */
|
|
112
|
+
phase: "start" | "end";
|
|
113
|
+
/** 重试波次序号(pi 原生 _retryAttempt,1 起)。 */
|
|
114
|
+
attempt: number;
|
|
115
|
+
/** start 独有:重试上限与退避等待(pi _prepareRetry 发射事实)。 */
|
|
116
|
+
maxAttempts?: number;
|
|
117
|
+
delayMs?: number;
|
|
118
|
+
/** start 携带被重试的错误文本;end 失败波携带最终错误(成功波缺省)。 */
|
|
119
|
+
errorMessage?: string;
|
|
120
|
+
/** end 独有:该波重试最终是否恢复(true = 后续尝试成功,false = 重试耗尽)。 */
|
|
121
|
+
success?: boolean;
|
|
122
|
+
finalError?: string;
|
|
109
123
|
};
|
|
110
124
|
/**
|
|
111
125
|
* 事件类型词表(协议事件全集 10 种,运行时 SSOT):schema 事件 `type.enum` 从本表
|
|
@@ -129,7 +143,7 @@ type AgentEvent = {
|
|
|
129
143
|
* switch never 检查)与 contract-closure 构造冒烟(Record<AgentEventTypeName,…>
|
|
130
144
|
* 漏键爆红)。不 bump 版本、不改任何引擎(演进政策 additive 面,判据全文见头注)。
|
|
131
145
|
*/
|
|
132
|
-
declare const AGENT_EVENT_TYPE_NAMES: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
146
|
+
declare const AGENT_EVENT_TYPE_NAMES: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed", "auto_retry"];
|
|
133
147
|
/** 词表派生的事件名联合(编译锁②/③的词表侧源;schema enum 与测试取值同源)。 */
|
|
134
148
|
type AgentEventTypeName = (typeof AGENT_EVENT_TYPE_NAMES)[number];
|
|
135
149
|
/**
|
|
@@ -138,6 +152,7 @@ type AgentEventTypeName = (typeof AGENT_EVENT_TYPE_NAMES)[number];
|
|
|
138
152
|
* 结构与运行时语义零变化。
|
|
139
153
|
*/
|
|
140
154
|
type EventName<T extends AgentEventTypeName> = T;
|
|
155
|
+
declare const _EventVocabSyncLock: AssertMutuallyAssignable<AgentEvent["type"], AgentEventTypeName>;
|
|
141
156
|
/**
|
|
142
157
|
* EngineHandle 的持久化形态(JSON v1)。协议 run 终态应答 / read 的
|
|
143
158
|
* handle 载荷(引擎不持有宿主运行时引用,data 即全部)。
|
|
@@ -298,7 +313,139 @@ interface ProbeReport {
|
|
|
298
313
|
recovery: string;
|
|
299
314
|
};
|
|
300
315
|
}
|
|
301
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* [subagent-observability §3.3.2] 失败分类权威契约(五维正交,原位替换
|
|
318
|
+
* AgentFailureKind 三值词表——本文件是引擎协议词表家址)。
|
|
319
|
+
*
|
|
320
|
+
* 由收尾边沿(判定链)一次产出并写入轮收条,下游只读不可替换(三硬规则①②——
|
|
321
|
+
* 只有知道事实的层能填 class;写入后观察性事实降级 observations,不改写 cause)。
|
|
322
|
+
* 跨进程 wire 载体 = shared `SubagentRecord.lastRound.failure`(type-only re-export,
|
|
323
|
+
* 判别联合逐字序列化)。消费锚:轮应答恢复指引(§3.3.7)、run 终局 failedMembers[].cause
|
|
324
|
+
* (§3.3.8——序列化为 `"<class>.<kind>"` 点拼字符串,retryable/retryAfterMs 不进终局
|
|
325
|
+
* 事件、由成员轮收条承载)。
|
|
326
|
+
*
|
|
327
|
+
* cause 优先级(分类边沿裁决序,严格递减):provider 事实 > harness 预算/契约 >
|
|
328
|
+
* agent 行为 > engine 崩溃 > unknown(未分类形态不产 FailureCause,落引擎停因原值)。
|
|
329
|
+
*/
|
|
330
|
+
type FailureCauseClass = "provider" | "harness" | "agent" | "engine" | "user";
|
|
331
|
+
/**
|
|
332
|
+
* retryable 三态(§3.3.2 硬规则③,与重试规则 extension 的 verdict 同词表):
|
|
333
|
+
* true = 等待后重发可恢复;
|
|
334
|
+
* false = 重发必然同样失败;
|
|
335
|
+
* "conditional" = 条件恢复——等限额重置窗口或人/账户先动作(执行层对 conditional
|
|
336
|
+
* 不自动重试,呈现层如实展示)。
|
|
337
|
+
*/
|
|
338
|
+
type FailureRetryability = true | false | "conditional";
|
|
339
|
+
/**
|
|
340
|
+
* FailureCause 公共字段面(class×kind 判别联合各成员共享)。
|
|
341
|
+
* retryable — 三态({@link FailureRetryability});429 不全可重试,禁止仅按
|
|
342
|
+
* HTTP 状态码判可重试(provider 业务码层裁决,§3.3.2 码表硬约束);
|
|
343
|
+
* retryAfterMs — 恢复等待毫秒(错误文本内重置时间字样提取——pi 消息模型不暴露
|
|
344
|
+
* HTTP 头,头通道结构性不可得,设计 §3.3.2 单文本通道),
|
|
345
|
+
* 皆无 → 缺省 unknown(undefined,不产假 0);
|
|
346
|
+
* raw — 分类输入的原始错误文本(取证链:分类不丢原文)。
|
|
347
|
+
*/
|
|
348
|
+
interface FailureCauseFields {
|
|
349
|
+
retryable: FailureRetryability;
|
|
350
|
+
retryAfterMs?: number;
|
|
351
|
+
raw: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* class×kind 合法组合矩阵(判别联合构造性成立——非法组合写不出来):
|
|
355
|
+
* provider.rate_limited / provider.protocol_unsupported / harness.turn_budget_exhausted /
|
|
356
|
+
* harness.timeout / agent.no_deliverable / user.cancelled / engine.*(`engine_${string}`
|
|
357
|
+
* 引擎自报透传族,开放前缀面——对齐 RunErrorCode 的 engine_ 透传契约,core 不解释文案)。
|
|
358
|
+
*
|
|
359
|
+
* kind 是封闭登记词表:新增成员同 commit 登记下方 {@link FAILURE_CAUSE_CLOSED_KINDS}
|
|
360
|
+
* (解析词表纪律),漏登记由 {@link FAILURE_CAUSE_KIND_VOCAB_LOCK} 编译锁拦截。
|
|
361
|
+
*/
|
|
362
|
+
type FailureCause = (FailureCauseFields & {
|
|
363
|
+
class: "provider";
|
|
364
|
+
kind: "rate_limited" | "protocol_unsupported";
|
|
365
|
+
}) | (FailureCauseFields & {
|
|
366
|
+
class: "harness";
|
|
367
|
+
kind: "turn_budget_exhausted" | "timeout";
|
|
368
|
+
/**
|
|
369
|
+
* [subagent-observability §3.3.9/UC-10] turn 预算耗尽事实(limiter abort 边沿
|
|
370
|
+
* 一次产出):used = abort 时轮数、limit = 显式 maxTurns 上界。undefined =
|
|
371
|
+
* 极端竞窗下收尾边沿只有 aborted 停因而 limiter 快照缺席(防御性同判形态,
|
|
372
|
+
* 事实不足不产结构——轮失败事实不受影响)。与 §3.3.6 查询侧 budget 分轴
|
|
373
|
+
* 结构({maxTurns, ...})同构的 {used, limit} 形态。仅 turn_budget_exhausted
|
|
374
|
+
* 承载;timeout(§3.3.6 超时轮失败分类,宿主结算点产出——timeoutMs 墙钟预算
|
|
375
|
+
* 耗尽是宿主独有事实,引擎收尾边沿只有「宿主取消 vs 引擎异常」两源判别)
|
|
376
|
+
* 不落本字段。
|
|
377
|
+
*/
|
|
378
|
+
budget?: {
|
|
379
|
+
used: number;
|
|
380
|
+
limit: number;
|
|
381
|
+
};
|
|
382
|
+
}) | (FailureCauseFields & {
|
|
383
|
+
class: "agent";
|
|
384
|
+
kind: "no_deliverable";
|
|
385
|
+
}) | (FailureCauseFields & {
|
|
386
|
+
class: "user";
|
|
387
|
+
kind: "cancelled";
|
|
388
|
+
}) | (FailureCauseFields & {
|
|
389
|
+
class: "engine";
|
|
390
|
+
kind: `engine_${string}`;
|
|
391
|
+
});
|
|
392
|
+
/**
|
|
393
|
+
* FailureCause.kind 闭合成员词表(运行时枚举完整性测试锚;engine 透传族
|
|
394
|
+
* `engine_${string}` 开放前缀面不进闭合表——逐成员断言见 failure-cause-vocabulary.test.ts)。
|
|
395
|
+
* 新增 kind 成员 = 联合与本元组同 commit 同批(编译锁双向拦截漏改)。
|
|
396
|
+
*/
|
|
397
|
+
declare const FAILURE_CAUSE_CLOSED_KINDS: readonly ["rate_limited", "protocol_unsupported", "turn_budget_exhausted", "timeout", "no_deliverable", "cancelled"];
|
|
398
|
+
/**
|
|
399
|
+
* 词表编译锁(双向):kind 联合闭合面 ⊆ 且 ⊇ FAILURE_CAUSE_CLOSED_KINDS。
|
|
400
|
+
* 联合扩值漏登元组(或元组多配联合外值)→ 本赋值 tsc 红,错误指向漏改侧。
|
|
401
|
+
*/
|
|
402
|
+
declare const FAILURE_CAUSE_KIND_VOCAB_LOCK: AssertMutuallyAssignable<Exclude<FailureCause["kind"], `engine_${string}`>, (typeof FAILURE_CAUSE_CLOSED_KINDS)[number]>;
|
|
403
|
+
/**
|
|
404
|
+
* per-class kind 合法值域(运行时可用——重试规则条目的 kind 字段按 class 校验的
|
|
405
|
+
* 唯一依据;消费方 = shared validateRetryRuleFields / retry-rules extension 侧镜像)。
|
|
406
|
+
* engine 透传族是 `engine_${string}` 开放前缀面(无闭合枚举),不进本表——engine 规则
|
|
407
|
+
* 的 kind 校验走前缀形态判定,由各消费方按 {@link FailureCause} 的 `engine_${string}`
|
|
408
|
+
* 契约自行落地。
|
|
409
|
+
*
|
|
410
|
+
* 词表编译锁:每个 class 的成员元组与 {@link FailureCause} 判别联合的对应 kind 联合
|
|
411
|
+
* 双向可赋值——判别联合扩值漏登本表(或本表多配联合外值)→ 对应行 tsc 红。
|
|
412
|
+
*/
|
|
413
|
+
declare const FAILURE_CAUSE_KINDS_BY_CLASS: {
|
|
414
|
+
readonly provider: readonly ["rate_limited", "protocol_unsupported"];
|
|
415
|
+
readonly harness: readonly ["turn_budget_exhausted", "timeout"];
|
|
416
|
+
readonly agent: readonly ["no_deliverable"];
|
|
417
|
+
readonly user: readonly ["cancelled"];
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* per-class 词表编译锁(双向):本表各 class 成员元组 ↔ 判别联合对应 kind 联合。
|
|
421
|
+
* 任一 class 漏登/多配 → 本赋值 tsc 红,错误指向漏改侧。
|
|
422
|
+
*/
|
|
423
|
+
declare const FAILURE_CAUSE_KINDS_BY_CLASS_LOCK: AssertMutuallyAssignable<{
|
|
424
|
+
provider: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["provider"][number];
|
|
425
|
+
harness: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["harness"][number];
|
|
426
|
+
agent: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["agent"][number];
|
|
427
|
+
user: (typeof FAILURE_CAUSE_KINDS_BY_CLASS)["user"][number];
|
|
428
|
+
}, {
|
|
429
|
+
provider: Extract<FailureCause, {
|
|
430
|
+
class: "provider";
|
|
431
|
+
}>["kind"];
|
|
432
|
+
harness: Extract<FailureCause, {
|
|
433
|
+
class: "harness";
|
|
434
|
+
}>["kind"];
|
|
435
|
+
agent: Extract<FailureCause, {
|
|
436
|
+
class: "agent";
|
|
437
|
+
}>["kind"];
|
|
438
|
+
user: Extract<FailureCause, {
|
|
439
|
+
class: "user";
|
|
440
|
+
}>["kind"];
|
|
441
|
+
}>;
|
|
442
|
+
/**
|
|
443
|
+
* @deprecated [subagent-observability §3.3.2,ADR-0158 终态] 三值分诊词表已由
|
|
444
|
+
* {@link FailureCause} 取代(class×kind 封闭矩阵 + retryable 三态)。本类型保留为
|
|
445
|
+
* 历史解析兼容、不删——旧 record 帧与历史 journal 的 failureKind 解析仍依赖该
|
|
446
|
+
* 通道(设计 §3.4「历史解析兼容保留项」);新写入方失败分类一律产 FailureCause,
|
|
447
|
+
* 产出侧分类器 classifyFailureKind 已退役。
|
|
448
|
+
*/
|
|
302
449
|
type AgentFailureKind = "stale_context" | "schema_deterministic" | "unknown";
|
|
303
450
|
/**
|
|
304
451
|
* AgentOutcome.usage 字段型(← core orchestration/models/types.ts AgentUsage 结构等价;
|
|
@@ -333,10 +480,28 @@ interface WorktreeHandle {
|
|
|
333
480
|
* 一次引擎执行的终态(协议 run 终态应答的 outcome 载荷)。锚定 core
|
|
334
481
|
* orchestration AgentResult 并追加引擎层字段(engineId / exitCode)。
|
|
335
482
|
*/
|
|
483
|
+
/** [subagent-observability §3.3.3] 轮终停因引擎原值三态(引擎收尾边沿事实;宿主
|
|
484
|
+
* ROUND_TERMINAL_STOP_REASONS 词表的协议侧同源镜像)。 */
|
|
485
|
+
type EngineStopReason = "stop" | "error" | "aborted";
|
|
336
486
|
interface AgentOutcome {
|
|
337
487
|
content: string;
|
|
338
|
-
/**
|
|
488
|
+
/**
|
|
489
|
+
* 失败分诊标签(历史解析兼容残留)。
|
|
490
|
+
* @deprecated [subagent-observability §3.4,ADR-0158] 新写入方失败分类一律产
|
|
491
|
+
* {@link FailureCause}(下方 failure 字段);本字段随 {@link AgentFailureKind} 保留为
|
|
492
|
+
* 旧 record 帧与历史 journal 的解析兼容。产出侧残留仅引擎送达错误码前缀确定性分诊
|
|
493
|
+
* (pi 引擎 output-collector,[D5-③ 改轨]);缺省 = undefined(字段缺位),
|
|
494
|
+
* 不承载重试判定(重试判定在 FailureCause.retryable 三态)。
|
|
495
|
+
*/
|
|
339
496
|
failureKind?: AgentFailureKind;
|
|
497
|
+
/**
|
|
498
|
+
* [subagent-observability §3.3.8] 失败分类(收尾边沿一次产出——CollectedOutcome.failure
|
|
499
|
+
* 经引擎适配层 toOutcome 透传上协议)。run 终局成员交付结算消费本字段点拼
|
|
500
|
+
* `"<class>.<kind>"` 进 failedMembers[].cause;缺省 = 未分类(cause 回落
|
|
501
|
+
* error 前缀协议码 / "unknown")。可选 = 读取面对旧格式应答放行(字段落地前
|
|
502
|
+
* 的引擎缺省,写侧契约由引擎适配层承担)。
|
|
503
|
+
*/
|
|
504
|
+
failure?: FailureCause;
|
|
340
505
|
/** native 引擎直传 / 仿真层 ajv 产出(D4 硬分流:native 路径宿主不做二次校验)。 */
|
|
341
506
|
parsedOutput?: unknown;
|
|
342
507
|
usage?: AgentOutcomeUsage;
|
|
@@ -372,6 +537,38 @@ interface AgentOutcome {
|
|
|
372
537
|
* 仅诊断引用——文件受引擎侧尺寸轮转与过期清理管辖,读侧不得假设其永存。
|
|
373
538
|
*/
|
|
374
539
|
stderrTeePath?: string;
|
|
540
|
+
/**
|
|
541
|
+
* [subagent-observability §3.3.3] 轮终停因引擎原值(收尾边沿事实一次产出,值域
|
|
542
|
+
* 三态与宿主 ROUND_TERMINAL_STOP_REASONS 同源)。宿主 one-shot 轮收条
|
|
543
|
+
* rec.lastRound.engineStopReason 的数据源——「正常收尾」派生判据(stop 且无失败
|
|
544
|
+
* 分类 = completed)依赖本事实。additive 可选(宪法判据③同 stderrTeePath 先例):
|
|
545
|
+
* 旧引擎缺省 = 宿主回落派生展示词,零行为差。
|
|
546
|
+
*/
|
|
547
|
+
engineStopReason?: EngineStopReason;
|
|
548
|
+
/**
|
|
549
|
+
* [subagent-observability §3.3.3 P5] 本 run 内 pi 原生重试的失败尝试计数
|
|
550
|
+
* (auto_retry_start 帧数;引擎 >0 时上报)。宿主轮收条 lastRound.retryAttempts
|
|
551
|
+
* 的数据源——重试轨迹可观测(失败尝试不静默计入 turns/usage)。additive 可选:
|
|
552
|
+
* 旧引擎/无重试缺省不落键。
|
|
553
|
+
*/
|
|
554
|
+
retryAttempts?: number;
|
|
555
|
+
/**
|
|
556
|
+
* [subagent-observability §3.3.1/§3.3.3] 本轮被人类接管收尾的标注(引擎判定链
|
|
557
|
+
* prompt-ack 命中 handled 时产出,值恒 "handled")。宿主轮收条
|
|
558
|
+
* lastRound.promptDisposition 的数据源——被接管轮不产失败分类、结清走 no_result、
|
|
559
|
+
* 通知走接管分支、run 聚合按未交付非失败计。additive 可选(宪法判据③同
|
|
560
|
+
* engineStopReason 先例):旧引擎缺省 = 无接管标注,零行为差。
|
|
561
|
+
*/
|
|
562
|
+
promptDisposition?: "handled";
|
|
563
|
+
/**
|
|
564
|
+
* [subagent-observability §3.3.2/§3.3.10] 观察性事实数组(引擎产出侧摘要,如
|
|
565
|
+
* 「结构化输出未调用」)。宿主轮收条 lastRound.observations 的
|
|
566
|
+
* 数据源——查询出口 list lastRound.observations 直读。additive 可选:旧引擎
|
|
567
|
+
* 缺省不落键。注意承载分源:交付谓词缺项(deliverables 未满足)在 worker 脚本
|
|
568
|
+
* 侧执行,不经本字段——落脚本结果 observations / run 终局帧 partialMembers /
|
|
569
|
+
* workflow_control 成员行 missingDeliverables 三面(§3.3.10 分源表述)。
|
|
570
|
+
*/
|
|
571
|
+
observations?: string[];
|
|
375
572
|
}
|
|
376
573
|
/**
|
|
377
574
|
* 引擎模型目录条目(manifest `modelCatalog.models` 条目形态,设计 §3.4 示例)。
|
|
@@ -464,4 +661,4 @@ interface AgentCallOpts {
|
|
|
464
661
|
permissionMode?: string;
|
|
465
662
|
}
|
|
466
663
|
|
|
467
|
-
export { type AgentEvent as A, type EngineHandleData as E, type InternalToolCall as I, type ModelRef as M, type ProbeReport as P, type ReplayedTurn as R, type SessionView as S, type Turn as T, type WorktreeHandle as W, type
|
|
664
|
+
export { type AgentEvent as A, type EngineHandleData as E, FAILURE_CAUSE_CLOSED_KINDS as F, type InternalToolCall as I, type ModelRef as M, type ProbeReport as P, type ReplayedTurn as R, type SessionView as S, type Turn as T, type WorktreeHandle as W, _EventVocabSyncLock as _, type AgentUsage as a, type AgentUsageTotal as b, type AgentCallOpts as c, type AgentOutcome as d, type EngineCapabilities as e, type ResumeAnchor as f, type ModelCatalogEntry as g, AGENT_EVENT_TYPE_NAMES as h, type AgentEventTypeName as i, type AgentFailureKind as j, type AgentOutcomeUsage as k, type AssertMutuallyAssignable as l, type EngineProcessModel as m, type EngineStopReason as n, FAILURE_CAUSE_KINDS_BY_CLASS as o, FAILURE_CAUSE_KINDS_BY_CLASS_LOCK as p, FAILURE_CAUSE_KIND_VOCAB_LOCK as q, type FailureCause as r, type FailureCauseClass as s, type FailureRetryability as t, type ToolCall as u, type ToolCallEntry as v, type ToolCallResult as w };
|
package/dist/env.cjs
CHANGED
|
@@ -97,7 +97,11 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
97
97
|
// 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
|
|
98
98
|
// 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
|
|
99
99
|
"TAIJI_PRESET_FALLBACK_FROM",
|
|
100
|
-
"TAIJI_PRESET_FALLBACK_TO"
|
|
100
|
+
"TAIJI_PRESET_FALLBACK_TO",
|
|
101
|
+
// runtime 实例标识(connection-datasync-ssot §6.1,env 名 SSOT = shared
|
|
102
|
+
// RUNTIME_ID_ENV):supervisor 每次 spawn 签发的生命周期标志,只有 runtime 自身
|
|
103
|
+
// 消费;引擎一跳继承陈旧值 = 后代进程持有已死实例标识,出站剥除
|
|
104
|
+
"TAIJI_RUNTIME_ID"
|
|
101
105
|
];
|
|
102
106
|
var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
103
107
|
"TAIJI_AGENT_DATA_DIR",
|