@zhushanwen/subagent-engine-sdk 0.11.0 → 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-QBXDEF4N.js → chunk-7R6HYT2A.js} +25 -1
- package/dist/{chunk-YFSNX3N3.js → chunk-U5MBAKS5.js} +19 -5
- package/dist/{contract-types-BUHUMF9R.d.cts → contract-types-C1scOS_M.d.cts} +201 -4
- package/dist/{contract-types-BUHUMF9R.d.ts → contract-types-C1scOS_M.d.ts} +201 -4
- 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 +52 -6
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +18 -2
- 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 +13 -2
package/dist/index.cjs
CHANGED
|
@@ -6598,6 +6598,10 @@ __export(src_exports, {
|
|
|
6598
6598
|
ENGINE_TRANSPORT_ERROR_RECOVERY: () => ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
6599
6599
|
EngineSdkError: () => EngineSdkError,
|
|
6600
6600
|
ExecutionNestingContext: () => ExecutionNestingContext,
|
|
6601
|
+
FAILURE_CAUSE_CLOSED_KINDS: () => FAILURE_CAUSE_CLOSED_KINDS,
|
|
6602
|
+
FAILURE_CAUSE_KINDS_BY_CLASS: () => FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
6603
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK: () => FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
6604
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK: () => FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
6601
6605
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: () => FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
6602
6606
|
HANDSHAKE_TIMEOUT_MS: () => HANDSHAKE_TIMEOUT_MS,
|
|
6603
6607
|
HOST_TIMEOUT_ABORT_REASON: () => HOST_TIMEOUT_ABORT_REASON,
|
|
@@ -6625,8 +6629,11 @@ __export(src_exports, {
|
|
|
6625
6629
|
ZCODE_HOST_DB_SUFFIX: () => ZCODE_HOST_DB_SUFFIX,
|
|
6626
6630
|
ZCODE_ISOLATED_DB_SEGMENTS: () => ZCODE_ISOLATED_DB_SEGMENTS,
|
|
6627
6631
|
ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS: () => ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS,
|
|
6632
|
+
_EventVocabSyncLock: () => _EventVocabSyncLock,
|
|
6628
6633
|
abortWithFallback: () => abortWithFallback,
|
|
6634
|
+
addUsage: () => addUsage,
|
|
6629
6635
|
aggregateUsage: () => aggregateUsage,
|
|
6636
|
+
appendErrorFact: () => appendErrorFact,
|
|
6630
6637
|
armEngineSelfDestruct: () => armEngineSelfDestruct,
|
|
6631
6638
|
assertChatConversationSupported: () => assertChatConversationSupported,
|
|
6632
6639
|
assertNotNestedSpawn: () => assertNotNestedSpawn,
|
|
@@ -6640,6 +6647,7 @@ __export(src_exports, {
|
|
|
6640
6647
|
configureLoggerSink: () => configureLoggerSink,
|
|
6641
6648
|
createReplayRecord: () => createReplayRecord,
|
|
6642
6649
|
createUiChannelRegistry: () => createUiChannelRegistry,
|
|
6650
|
+
emptyTurn: () => emptyTurn,
|
|
6643
6651
|
engineConversationUnsupportedError: () => engineConversationUnsupportedError,
|
|
6644
6652
|
engineProtocolMismatchError: () => engineProtocolMismatchError,
|
|
6645
6653
|
engineSetModelUnsupportedError: () => engineSetModelUnsupportedError,
|
|
@@ -6936,9 +6944,28 @@ var AGENT_EVENT_TYPE_NAMES = [
|
|
|
6936
6944
|
// noop-safe: 纯活性信号,双侧 reducer 恒 no-op(协议语义见 AgentEvent 头注),丢弃零差异
|
|
6937
6945
|
"error",
|
|
6938
6946
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 lastError 诊断留痕,已写状态不回滚
|
|
6939
|
-
"armed"
|
|
6947
|
+
"armed",
|
|
6940
6948
|
// noop-safe: 旧宿主无武装等待窗消费点(fail-fast 属宿主新增逻辑),丢弃仅缺武装留痕,schema 强制第一道防线(引擎自查断言)不受损
|
|
6949
|
+
"auto_retry"
|
|
6950
|
+
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺重试边界留痕(journal 不可查失败尝试轨迹),轮成败判定与 turns/usage 计账不受损(P5 计账锚在引擎侧收尾快照,不依赖宿主消费本帧)
|
|
6941
6951
|
];
|
|
6952
|
+
var _EventVocabSyncLock = true;
|
|
6953
|
+
var FAILURE_CAUSE_CLOSED_KINDS = [
|
|
6954
|
+
"rate_limited",
|
|
6955
|
+
"protocol_unsupported",
|
|
6956
|
+
"turn_budget_exhausted",
|
|
6957
|
+
"timeout",
|
|
6958
|
+
"no_deliverable",
|
|
6959
|
+
"cancelled"
|
|
6960
|
+
];
|
|
6961
|
+
var FAILURE_CAUSE_KIND_VOCAB_LOCK = true;
|
|
6962
|
+
var FAILURE_CAUSE_KINDS_BY_CLASS = {
|
|
6963
|
+
provider: ["rate_limited", "protocol_unsupported"],
|
|
6964
|
+
harness: ["turn_budget_exhausted", "timeout"],
|
|
6965
|
+
agent: ["no_deliverable"],
|
|
6966
|
+
user: ["cancelled"]
|
|
6967
|
+
};
|
|
6968
|
+
var FAILURE_CAUSE_KINDS_BY_CLASS_LOCK = true;
|
|
6942
6969
|
|
|
6943
6970
|
// src/protocol/schema.ts
|
|
6944
6971
|
var ANY_JSON = {};
|
|
@@ -7475,7 +7502,8 @@ function createReplayRecord() {
|
|
|
7475
7502
|
turns: [emptyTurn()],
|
|
7476
7503
|
turnCount: 0,
|
|
7477
7504
|
totalTokens: 0,
|
|
7478
|
-
lastError: void 0
|
|
7505
|
+
lastError: void 0,
|
|
7506
|
+
errors: []
|
|
7479
7507
|
};
|
|
7480
7508
|
}
|
|
7481
7509
|
function currentTurn(record) {
|
|
@@ -7569,7 +7597,11 @@ function applyTurnEnd(record) {
|
|
|
7569
7597
|
turn.closed = true;
|
|
7570
7598
|
turn.closedTs = Date.now();
|
|
7571
7599
|
record.turnCount += 1;
|
|
7572
|
-
|
|
7600
|
+
}
|
|
7601
|
+
function appendErrorFact(record, message) {
|
|
7602
|
+
if (!message) return;
|
|
7603
|
+
(record.errors ??= []).push({ message, at: Date.now() });
|
|
7604
|
+
record.lastError = message;
|
|
7573
7605
|
}
|
|
7574
7606
|
function applyMessageEnd(record, event) {
|
|
7575
7607
|
if (event.usage) {
|
|
@@ -7578,11 +7610,11 @@ function applyMessageEnd(record, event) {
|
|
|
7578
7610
|
record.totalTokens += (event.usage.input ?? 0) + (event.usage.output ?? 0) + (event.usage.cacheRead ?? 0) + (event.usage.cacheWrite ?? 0);
|
|
7579
7611
|
}
|
|
7580
7612
|
if (event.error) {
|
|
7581
|
-
record
|
|
7613
|
+
appendErrorFact(record, event.error);
|
|
7582
7614
|
}
|
|
7583
7615
|
}
|
|
7584
7616
|
function applyErrorEvent(record, event) {
|
|
7585
|
-
record
|
|
7617
|
+
appendErrorFact(record, event.message);
|
|
7586
7618
|
}
|
|
7587
7619
|
function updateFromEvent(record, event) {
|
|
7588
7620
|
switch (event.type) {
|
|
@@ -7602,7 +7634,7 @@ function updateFromEvent(record, event) {
|
|
|
7602
7634
|
// ── message_end:usage 增量累加 + totalTokens 累加 ──
|
|
7603
7635
|
case "message_end":
|
|
7604
7636
|
return applyMessageEnd(record, event);
|
|
7605
|
-
// ── error
|
|
7637
|
+
// ── error:appendErrorFact 入账(errors 只追加 + lastError 派生)──
|
|
7606
7638
|
case "error":
|
|
7607
7639
|
return applyErrorEvent(record, event);
|
|
7608
7640
|
// ── compaction:不产生数据(不变)──
|
|
@@ -7616,6 +7648,12 @@ function updateFromEvent(record, event) {
|
|
|
7616
7648
|
// 双侧 reducer no-op 义务的 SDK 侧)
|
|
7617
7649
|
case "armed":
|
|
7618
7650
|
return;
|
|
7651
|
+
// ── auto_retry:pi 原生重试边界帧([subagent-observability §3.3.1 P5])——
|
|
7652
|
+
// 观测面(journal 留痕失败尝试轨迹),不进 record 派生视图:失败尝试的
|
|
7653
|
+
// turns/usage 切片与 retryAttempts 计数由引擎收尾快照一次产出(outcome
|
|
7654
|
+
// 字段承载),reducer 写入会让失败尝试静默混进 turns 聚合,恰违背 P5 计账。
|
|
7655
|
+
case "auto_retry":
|
|
7656
|
+
return;
|
|
7619
7657
|
default: {
|
|
7620
7658
|
const _exhaustive = event;
|
|
7621
7659
|
return _exhaustive;
|
|
@@ -8481,6 +8519,10 @@ function runEngineCliEntry(opts) {
|
|
|
8481
8519
|
ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
8482
8520
|
EngineSdkError,
|
|
8483
8521
|
ExecutionNestingContext,
|
|
8522
|
+
FAILURE_CAUSE_CLOSED_KINDS,
|
|
8523
|
+
FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
8524
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
8525
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
8484
8526
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
8485
8527
|
HANDSHAKE_TIMEOUT_MS,
|
|
8486
8528
|
HOST_TIMEOUT_ABORT_REASON,
|
|
@@ -8508,8 +8550,11 @@ function runEngineCliEntry(opts) {
|
|
|
8508
8550
|
ZCODE_HOST_DB_SUFFIX,
|
|
8509
8551
|
ZCODE_ISOLATED_DB_SEGMENTS,
|
|
8510
8552
|
ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS,
|
|
8553
|
+
_EventVocabSyncLock,
|
|
8511
8554
|
abortWithFallback,
|
|
8555
|
+
addUsage,
|
|
8512
8556
|
aggregateUsage,
|
|
8557
|
+
appendErrorFact,
|
|
8513
8558
|
armEngineSelfDestruct,
|
|
8514
8559
|
assertChatConversationSupported,
|
|
8515
8560
|
assertNotNestedSpawn,
|
|
@@ -8523,6 +8568,7 @@ function runEngineCliEntry(opts) {
|
|
|
8523
8568
|
configureLoggerSink,
|
|
8524
8569
|
createReplayRecord,
|
|
8525
8570
|
createUiChannelRegistry,
|
|
8571
|
+
emptyTurn,
|
|
8526
8572
|
engineConversationUnsupportedError,
|
|
8527
8573
|
engineProtocolMismatchError,
|
|
8528
8574
|
engineSetModelUnsupportedError,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReverseChannel, 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, SubagentControlClosedReason, SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.cjs';
|
|
2
|
-
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-
|
|
3
|
-
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-
|
|
4
|
-
export {
|
|
2
|
+
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';
|
|
3
|
+
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';
|
|
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
|
export { SCHEMA_EMULATION_TAIL_CHARS, StructuredOutputResult, buildSchemaEmulationSegment, extractAndValidateStructuredOutput } from './schema-emulation.cjs';
|
|
6
6
|
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, NestedSpawnRejectedError, SpawnEnv, assertNotNestedSpawn, buildNestedSpawnEnv } from './nesting-guard.cjs';
|
|
7
7
|
export { CoreLogger, LogLevel, LoggerSink, configureLoggerSink, getLogger, resetLoggerSinkForTests } from './logger.cjs';
|
|
8
8
|
export { DEFAULT_KILL_GRACE_MS, DEFAULT_NATIVE_INTERRUPT_GRACE_MS, HOST_TIMEOUT_ABORT_REASON, KillChainOptions, KillableChild, PidChainOptions, abortWithFallback, killChain, killPidChain, probePidAlive, safeKill, synthesizeTimeoutOutcome } from './kill-chain.cjs';
|
|
9
|
-
export { ReplayRecordView, aggregateUsage, createReplayRecord, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent } from './journal-replay.cjs';
|
|
9
|
+
export { ErrorFact, ReplayRecordView, addUsage, aggregateUsage, appendErrorFact, createReplayRecord, emptyTurn, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent } from './journal-replay.cjs';
|
|
10
10
|
export { TAIJI_DATA_DIR_ENV, resetDataDirWarnForTests, resolveEngineDataDir } from './data-dir.cjs';
|
|
11
11
|
export { resolveEngineDir, resolveEnginesRoot, resolveJournalPath, resolvePoolDir, sanitizeSeg } from './paths.cjs';
|
|
12
12
|
export { UiMethod, UiRequest, UiRequestHandler, UiResponse, isUiResponse } from './ui-types.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReverseChannel, 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, SubagentControlClosedReason, SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.js';
|
|
2
|
-
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-
|
|
3
|
-
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-
|
|
4
|
-
export {
|
|
2
|
+
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';
|
|
3
|
+
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';
|
|
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
|
export { SCHEMA_EMULATION_TAIL_CHARS, StructuredOutputResult, buildSchemaEmulationSegment, extractAndValidateStructuredOutput } from './schema-emulation.js';
|
|
6
6
|
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, NestedSpawnRejectedError, SpawnEnv, assertNotNestedSpawn, buildNestedSpawnEnv } from './nesting-guard.js';
|
|
7
7
|
export { CoreLogger, LogLevel, LoggerSink, configureLoggerSink, getLogger, resetLoggerSinkForTests } from './logger.js';
|
|
8
8
|
export { DEFAULT_KILL_GRACE_MS, DEFAULT_NATIVE_INTERRUPT_GRACE_MS, HOST_TIMEOUT_ABORT_REASON, KillChainOptions, KillableChild, PidChainOptions, abortWithFallback, killChain, killPidChain, probePidAlive, safeKill, synthesizeTimeoutOutcome } from './kill-chain.js';
|
|
9
|
-
export { ReplayRecordView, aggregateUsage, createReplayRecord, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent } from './journal-replay.js';
|
|
9
|
+
export { ErrorFact, ReplayRecordView, addUsage, aggregateUsage, appendErrorFact, createReplayRecord, emptyTurn, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent } from './journal-replay.js';
|
|
10
10
|
export { TAIJI_DATA_DIR_ENV, resetDataDirWarnForTests, resolveEngineDataDir } from './data-dir.js';
|
|
11
11
|
export { resolveEngineDir, resolveEnginesRoot, resolveJournalPath, resolvePoolDir, sanitizeSeg } from './paths.js';
|
|
12
12
|
export { UiMethod, UiRequest, UiRequestHandler, UiResponse, isUiResponse } from './ui-types.js';
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,10 @@ import {
|
|
|
72
72
|
import {
|
|
73
73
|
AGENT_EVENT_TYPE_NAMES,
|
|
74
74
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
75
|
+
FAILURE_CAUSE_CLOSED_KINDS,
|
|
76
|
+
FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
77
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
78
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
75
79
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
76
80
|
PROTOCOL_METHODS,
|
|
77
81
|
REVERSE_CHANNELS,
|
|
@@ -79,6 +83,7 @@ import {
|
|
|
79
83
|
SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
80
84
|
SUBAGENT_CONTROL_FRAME_KINDS,
|
|
81
85
|
SUBAGENT_CONTROL_PROTOCOL_VERSION,
|
|
86
|
+
_EventVocabSyncLock,
|
|
82
87
|
errorResponseFrameSchema,
|
|
83
88
|
isSubagentControlClosedReason,
|
|
84
89
|
isSubagentControlFrameKind,
|
|
@@ -88,7 +93,7 @@ import {
|
|
|
88
93
|
reverseRequestFrameSchema,
|
|
89
94
|
runSessionParamsSchema,
|
|
90
95
|
successResponseFrameSchema
|
|
91
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-7R6HYT2A.js";
|
|
92
97
|
import {
|
|
93
98
|
isNotificationFrame,
|
|
94
99
|
isRequestFrame,
|
|
@@ -157,13 +162,16 @@ import {
|
|
|
157
162
|
resetLoggerSinkForTests
|
|
158
163
|
} from "./chunk-NXNNXGTY.js";
|
|
159
164
|
import {
|
|
165
|
+
addUsage,
|
|
160
166
|
aggregateUsage,
|
|
167
|
+
appendErrorFact,
|
|
161
168
|
createReplayRecord,
|
|
169
|
+
emptyTurn,
|
|
162
170
|
eventsToSessionView,
|
|
163
171
|
sessionIdFromHandle,
|
|
164
172
|
toReplayedTurn,
|
|
165
173
|
updateFromEvent
|
|
166
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-U5MBAKS5.js";
|
|
167
175
|
import "./chunk-JSBRDJBE.js";
|
|
168
176
|
|
|
169
177
|
// src/identity-env.ts
|
|
@@ -228,6 +236,10 @@ export {
|
|
|
228
236
|
ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
229
237
|
EngineSdkError,
|
|
230
238
|
ExecutionNestingContext,
|
|
239
|
+
FAILURE_CAUSE_CLOSED_KINDS,
|
|
240
|
+
FAILURE_CAUSE_KINDS_BY_CLASS,
|
|
241
|
+
FAILURE_CAUSE_KINDS_BY_CLASS_LOCK,
|
|
242
|
+
FAILURE_CAUSE_KIND_VOCAB_LOCK,
|
|
231
243
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
232
244
|
HANDSHAKE_TIMEOUT_MS,
|
|
233
245
|
HOST_TIMEOUT_ABORT_REASON,
|
|
@@ -255,8 +267,11 @@ export {
|
|
|
255
267
|
ZCODE_HOST_DB_SUFFIX,
|
|
256
268
|
ZCODE_ISOLATED_DB_SEGMENTS,
|
|
257
269
|
ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS,
|
|
270
|
+
_EventVocabSyncLock,
|
|
258
271
|
abortWithFallback,
|
|
272
|
+
addUsage,
|
|
259
273
|
aggregateUsage,
|
|
274
|
+
appendErrorFact,
|
|
260
275
|
armEngineSelfDestruct,
|
|
261
276
|
assertChatConversationSupported,
|
|
262
277
|
assertNotNestedSpawn,
|
|
@@ -270,6 +285,7 @@ export {
|
|
|
270
285
|
configureLoggerSink,
|
|
271
286
|
createReplayRecord,
|
|
272
287
|
createUiChannelRegistry,
|
|
288
|
+
emptyTurn,
|
|
273
289
|
engineConversationUnsupportedError,
|
|
274
290
|
engineProtocolMismatchError,
|
|
275
291
|
engineSetModelUnsupportedError,
|
package/dist/journal-io.d.cts
CHANGED
package/dist/journal-io.d.ts
CHANGED
package/dist/journal-replay.cjs
CHANGED
|
@@ -20,8 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/journal-replay.ts
|
|
21
21
|
var journal_replay_exports = {};
|
|
22
22
|
__export(journal_replay_exports, {
|
|
23
|
+
addUsage: () => addUsage,
|
|
23
24
|
aggregateUsage: () => aggregateUsage,
|
|
25
|
+
appendErrorFact: () => appendErrorFact,
|
|
24
26
|
createReplayRecord: () => createReplayRecord,
|
|
27
|
+
emptyTurn: () => emptyTurn,
|
|
25
28
|
eventsToSessionView: () => eventsToSessionView,
|
|
26
29
|
sessionIdFromHandle: () => sessionIdFromHandle,
|
|
27
30
|
toReplayedTurn: () => toReplayedTurn,
|
|
@@ -60,7 +63,8 @@ function createReplayRecord() {
|
|
|
60
63
|
turns: [emptyTurn()],
|
|
61
64
|
turnCount: 0,
|
|
62
65
|
totalTokens: 0,
|
|
63
|
-
lastError: void 0
|
|
66
|
+
lastError: void 0,
|
|
67
|
+
errors: []
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
70
|
function currentTurn(record) {
|
|
@@ -154,7 +158,11 @@ function applyTurnEnd(record) {
|
|
|
154
158
|
turn.closed = true;
|
|
155
159
|
turn.closedTs = Date.now();
|
|
156
160
|
record.turnCount += 1;
|
|
157
|
-
|
|
161
|
+
}
|
|
162
|
+
function appendErrorFact(record, message) {
|
|
163
|
+
if (!message) return;
|
|
164
|
+
(record.errors ??= []).push({ message, at: Date.now() });
|
|
165
|
+
record.lastError = message;
|
|
158
166
|
}
|
|
159
167
|
function applyMessageEnd(record, event) {
|
|
160
168
|
if (event.usage) {
|
|
@@ -163,11 +171,11 @@ function applyMessageEnd(record, event) {
|
|
|
163
171
|
record.totalTokens += (event.usage.input ?? 0) + (event.usage.output ?? 0) + (event.usage.cacheRead ?? 0) + (event.usage.cacheWrite ?? 0);
|
|
164
172
|
}
|
|
165
173
|
if (event.error) {
|
|
166
|
-
record
|
|
174
|
+
appendErrorFact(record, event.error);
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
function applyErrorEvent(record, event) {
|
|
170
|
-
record
|
|
178
|
+
appendErrorFact(record, event.message);
|
|
171
179
|
}
|
|
172
180
|
function updateFromEvent(record, event) {
|
|
173
181
|
switch (event.type) {
|
|
@@ -187,7 +195,7 @@ function updateFromEvent(record, event) {
|
|
|
187
195
|
// ── message_end:usage 增量累加 + totalTokens 累加 ──
|
|
188
196
|
case "message_end":
|
|
189
197
|
return applyMessageEnd(record, event);
|
|
190
|
-
// ── error
|
|
198
|
+
// ── error:appendErrorFact 入账(errors 只追加 + lastError 派生)──
|
|
191
199
|
case "error":
|
|
192
200
|
return applyErrorEvent(record, event);
|
|
193
201
|
// ── compaction:不产生数据(不变)──
|
|
@@ -201,6 +209,12 @@ function updateFromEvent(record, event) {
|
|
|
201
209
|
// 双侧 reducer no-op 义务的 SDK 侧)
|
|
202
210
|
case "armed":
|
|
203
211
|
return;
|
|
212
|
+
// ── auto_retry:pi 原生重试边界帧([subagent-observability §3.3.1 P5])——
|
|
213
|
+
// 观测面(journal 留痕失败尝试轨迹),不进 record 派生视图:失败尝试的
|
|
214
|
+
// turns/usage 切片与 retryAttempts 计数由引擎收尾快照一次产出(outcome
|
|
215
|
+
// 字段承载),reducer 写入会让失败尝试静默混进 turns 聚合,恰违背 P5 计账。
|
|
216
|
+
case "auto_retry":
|
|
217
|
+
return;
|
|
204
218
|
default: {
|
|
205
219
|
const _exhaustive = event;
|
|
206
220
|
return _exhaustive;
|
|
@@ -255,8 +269,11 @@ function sessionIdFromHandle(handle) {
|
|
|
255
269
|
}
|
|
256
270
|
// Annotate the CommonJS export names for ESM import in node:
|
|
257
271
|
0 && (module.exports = {
|
|
272
|
+
addUsage,
|
|
258
273
|
aggregateUsage,
|
|
274
|
+
appendErrorFact,
|
|
259
275
|
createReplayRecord,
|
|
276
|
+
emptyTurn,
|
|
260
277
|
eventsToSessionView,
|
|
261
278
|
sessionIdFromHandle,
|
|
262
279
|
toReplayedTurn,
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { T as Turn, a as AgentUsageTotal, A as AgentEvent, S as SessionView, E as EngineHandleData, R as ReplayedTurn } from './contract-types-
|
|
1
|
+
import { T as Turn, a as AgentUsage, b as AgentUsageTotal, A as AgentEvent, S as SessionView, E as EngineHandleData, R as ReplayedTurn } from './contract-types-C1scOS_M.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 轮失败事实(subagent-observability §3.3.5:失败事实只追加进 errors 数组,
|
|
5
|
+
* lastError 由「最后一个非空轮失败」派生——数组只追加且空串不入账,
|
|
6
|
+
* 尾项即最后一个非空失败)。事实源记录,append-only,不因后续轮终清除。
|
|
7
|
+
*/
|
|
8
|
+
interface ErrorFact {
|
|
9
|
+
/** 错误消息原文(空串 / 缺席不入账——无信息失败事实不占位)。 */
|
|
10
|
+
message: string;
|
|
11
|
+
/** 事实落账墙钟(Date.now(),ms)。 */
|
|
12
|
+
at: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* reducer 的 record 视图(core ExecutionRecord 的结构子集:reducer 只触碰这五个字段)。
|
|
5
16
|
* core ExecutionRecord 满足本视图(W2 断言挂靠点);SDK 内自持 createReplayRecord 产出。
|
|
6
17
|
*/
|
|
7
18
|
interface ReplayRecordView {
|
|
@@ -9,19 +20,42 @@ interface ReplayRecordView {
|
|
|
9
20
|
turnCount: number;
|
|
10
21
|
totalTokens: number;
|
|
11
22
|
lastError: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* 轮失败事实只追加数组(§3.3.5)。缺省 undefined 视为空(磁盘重建的旧 record
|
|
25
|
+
* 兼容——reducer 以 `??=` 兜底初始化,不要求构造方预置)。
|
|
26
|
+
*/
|
|
27
|
+
errors?: ErrorFact[];
|
|
12
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 累加两个 AgentUsage(field-wise)。prev 为空时返回 next 的拷贝。
|
|
31
|
+
* 供 message_end 把 usage 增量并入 turn.usageDelta。
|
|
32
|
+
*/
|
|
33
|
+
declare function addUsage(prev: AgentUsage | undefined, next: AgentUsage): AgentUsage;
|
|
34
|
+
/** 创建一个空 turn(text/thinking 空,无 toolCalls,未结束)。 */
|
|
35
|
+
declare function emptyTurn(): Turn;
|
|
13
36
|
/** 重放场景的 record 构造(对齐 core eventsToSessionView 内 createRecord 后的 reducer 视图)。 */
|
|
14
37
|
declare function createReplayRecord(): ReplayRecordView;
|
|
38
|
+
/**
|
|
39
|
+
* [§3.3.5] 轮失败事实入账单点:append ErrorFact + lastError 派生刷新(唯一写点)。
|
|
40
|
+
* 空串 / 缺席不入账(无信息失败事实不占位);`??=` 兜底磁盘重建的旧 record
|
|
41
|
+
* (无 errors 字段,缺省 undefined 视为空)。lastError = 最后追加的非空 message
|
|
42
|
+
* ——数组 append-only 且项非空,尾项即「最后一个非空轮失败」。
|
|
43
|
+
*
|
|
44
|
+
* [subagent-observability u3] 导出给 core 轮终写点(record-store-rounds 失败轮
|
|
45
|
+
* settlement)复用——u2 移交的「markRoundIdle 直写 rec.lastError 绕过 errors 数组」
|
|
46
|
+
* 收编:轮终失败事实与流内 error 事件走同一入账通道,写点单点(双写漂移防线)。
|
|
47
|
+
*/
|
|
48
|
+
declare function appendErrorFact(record: ReplayRecordView, message: string | undefined | null): void;
|
|
15
49
|
/**
|
|
16
50
|
* 从 AgentEvent 更新 record。所有数据收敛进 record.turns[]。
|
|
17
51
|
* - text/thinking:流式累积进 currentTurn()(完整内容,非切片)
|
|
18
52
|
* - tool_start/end:push 进 currentTurn().toolCalls(含完整 result)
|
|
19
53
|
* tool_end 跨 turn 扫描找 running 同名 toolCall(兜底滞后事件)
|
|
20
54
|
* - turn_end:结束当前 turn,记 closedTs(真实墙钟,供 getEventLog);
|
|
21
|
-
*
|
|
55
|
+
* 不再清 lastError(§3.3.5——error → turn_end 序后 lastError 仍可读)
|
|
22
56
|
* - message_end:usage 增量存进末 turn.usageDelta(直接写末 turn,不开新 turn);
|
|
23
57
|
* totalTokens 累加
|
|
24
|
-
* - error
|
|
58
|
+
* - error:经 appendErrorFact 入账(errors 只追加 + lastError 派生刷新)
|
|
25
59
|
*
|
|
26
60
|
* 唯一写点——replay 与 live 共用(重放等价性的实现体)。
|
|
27
61
|
*
|
|
@@ -42,4 +76,4 @@ declare function eventsToSessionView(events: readonly AgentEvent[], engineId: st
|
|
|
42
76
|
/** handle.sessionRef 的 sessionId 提取(引擎自定义键,运行时 guard)。 */
|
|
43
77
|
declare function sessionIdFromHandle(handle: EngineHandleData): string | undefined;
|
|
44
78
|
|
|
45
|
-
export { type ReplayRecordView, aggregateUsage, createReplayRecord, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent };
|
|
79
|
+
export { type ErrorFact, type ReplayRecordView, addUsage, aggregateUsage, appendErrorFact, createReplayRecord, emptyTurn, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent };
|
package/dist/journal-replay.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { T as Turn, a as AgentUsageTotal, A as AgentEvent, S as SessionView, E as EngineHandleData, R as ReplayedTurn } from './contract-types-
|
|
1
|
+
import { T as Turn, a as AgentUsage, b as AgentUsageTotal, A as AgentEvent, S as SessionView, E as EngineHandleData, R as ReplayedTurn } from './contract-types-C1scOS_M.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 轮失败事实(subagent-observability §3.3.5:失败事实只追加进 errors 数组,
|
|
5
|
+
* lastError 由「最后一个非空轮失败」派生——数组只追加且空串不入账,
|
|
6
|
+
* 尾项即最后一个非空失败)。事实源记录,append-only,不因后续轮终清除。
|
|
7
|
+
*/
|
|
8
|
+
interface ErrorFact {
|
|
9
|
+
/** 错误消息原文(空串 / 缺席不入账——无信息失败事实不占位)。 */
|
|
10
|
+
message: string;
|
|
11
|
+
/** 事实落账墙钟(Date.now(),ms)。 */
|
|
12
|
+
at: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* reducer 的 record 视图(core ExecutionRecord 的结构子集:reducer 只触碰这五个字段)。
|
|
5
16
|
* core ExecutionRecord 满足本视图(W2 断言挂靠点);SDK 内自持 createReplayRecord 产出。
|
|
6
17
|
*/
|
|
7
18
|
interface ReplayRecordView {
|
|
@@ -9,19 +20,42 @@ interface ReplayRecordView {
|
|
|
9
20
|
turnCount: number;
|
|
10
21
|
totalTokens: number;
|
|
11
22
|
lastError: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* 轮失败事实只追加数组(§3.3.5)。缺省 undefined 视为空(磁盘重建的旧 record
|
|
25
|
+
* 兼容——reducer 以 `??=` 兜底初始化,不要求构造方预置)。
|
|
26
|
+
*/
|
|
27
|
+
errors?: ErrorFact[];
|
|
12
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 累加两个 AgentUsage(field-wise)。prev 为空时返回 next 的拷贝。
|
|
31
|
+
* 供 message_end 把 usage 增量并入 turn.usageDelta。
|
|
32
|
+
*/
|
|
33
|
+
declare function addUsage(prev: AgentUsage | undefined, next: AgentUsage): AgentUsage;
|
|
34
|
+
/** 创建一个空 turn(text/thinking 空,无 toolCalls,未结束)。 */
|
|
35
|
+
declare function emptyTurn(): Turn;
|
|
13
36
|
/** 重放场景的 record 构造(对齐 core eventsToSessionView 内 createRecord 后的 reducer 视图)。 */
|
|
14
37
|
declare function createReplayRecord(): ReplayRecordView;
|
|
38
|
+
/**
|
|
39
|
+
* [§3.3.5] 轮失败事实入账单点:append ErrorFact + lastError 派生刷新(唯一写点)。
|
|
40
|
+
* 空串 / 缺席不入账(无信息失败事实不占位);`??=` 兜底磁盘重建的旧 record
|
|
41
|
+
* (无 errors 字段,缺省 undefined 视为空)。lastError = 最后追加的非空 message
|
|
42
|
+
* ——数组 append-only 且项非空,尾项即「最后一个非空轮失败」。
|
|
43
|
+
*
|
|
44
|
+
* [subagent-observability u3] 导出给 core 轮终写点(record-store-rounds 失败轮
|
|
45
|
+
* settlement)复用——u2 移交的「markRoundIdle 直写 rec.lastError 绕过 errors 数组」
|
|
46
|
+
* 收编:轮终失败事实与流内 error 事件走同一入账通道,写点单点(双写漂移防线)。
|
|
47
|
+
*/
|
|
48
|
+
declare function appendErrorFact(record: ReplayRecordView, message: string | undefined | null): void;
|
|
15
49
|
/**
|
|
16
50
|
* 从 AgentEvent 更新 record。所有数据收敛进 record.turns[]。
|
|
17
51
|
* - text/thinking:流式累积进 currentTurn()(完整内容,非切片)
|
|
18
52
|
* - tool_start/end:push 进 currentTurn().toolCalls(含完整 result)
|
|
19
53
|
* tool_end 跨 turn 扫描找 running 同名 toolCall(兜底滞后事件)
|
|
20
54
|
* - turn_end:结束当前 turn,记 closedTs(真实墙钟,供 getEventLog);
|
|
21
|
-
*
|
|
55
|
+
* 不再清 lastError(§3.3.5——error → turn_end 序后 lastError 仍可读)
|
|
22
56
|
* - message_end:usage 增量存进末 turn.usageDelta(直接写末 turn,不开新 turn);
|
|
23
57
|
* totalTokens 累加
|
|
24
|
-
* - error
|
|
58
|
+
* - error:经 appendErrorFact 入账(errors 只追加 + lastError 派生刷新)
|
|
25
59
|
*
|
|
26
60
|
* 唯一写点——replay 与 live 共用(重放等价性的实现体)。
|
|
27
61
|
*
|
|
@@ -42,4 +76,4 @@ declare function eventsToSessionView(events: readonly AgentEvent[], engineId: st
|
|
|
42
76
|
/** handle.sessionRef 的 sessionId 提取(引擎自定义键,运行时 guard)。 */
|
|
43
77
|
declare function sessionIdFromHandle(handle: EngineHandleData): string | undefined;
|
|
44
78
|
|
|
45
|
-
export { type ReplayRecordView, aggregateUsage, createReplayRecord, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent };
|
|
79
|
+
export { type ErrorFact, type ReplayRecordView, addUsage, aggregateUsage, appendErrorFact, createReplayRecord, emptyTurn, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent };
|
package/dist/journal-replay.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
+
addUsage,
|
|
2
3
|
aggregateUsage,
|
|
4
|
+
appendErrorFact,
|
|
3
5
|
createReplayRecord,
|
|
6
|
+
emptyTurn,
|
|
4
7
|
eventsToSessionView,
|
|
5
8
|
sessionIdFromHandle,
|
|
6
9
|
toReplayedTurn,
|
|
7
10
|
updateFromEvent
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-U5MBAKS5.js";
|
|
9
12
|
import "./chunk-JSBRDJBE.js";
|
|
10
13
|
export {
|
|
14
|
+
addUsage,
|
|
11
15
|
aggregateUsage,
|
|
16
|
+
appendErrorFact,
|
|
12
17
|
createReplayRecord,
|
|
18
|
+
emptyTurn,
|
|
13
19
|
eventsToSessionView,
|
|
14
20
|
sessionIdFromHandle,
|
|
15
21
|
toReplayedTurn,
|
package/dist/kill-chain.d.cts
CHANGED
package/dist/kill-chain.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as ModelRef,
|
|
1
|
+
import { M as ModelRef, e as EngineCapabilities, g as ModelCatalogEntry, c as AgentCallOpts, f as ResumeAnchor, E as EngineHandleData, P as ProbeReport, d as AgentOutcome, S as SessionView } from './contract-types-C1scOS_M.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 正向方法名联合(恰好 10 个;PROTOCOL_METHODS 常量数组与之同源互证)。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as ModelRef,
|
|
1
|
+
import { M as ModelRef, e as EngineCapabilities, g as ModelCatalogEntry, c as AgentCallOpts, f as ResumeAnchor, E as EngineHandleData, P as ProbeReport, d as AgentOutcome, S as SessionView } from './contract-types-C1scOS_M.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 正向方法名联合(恰好 10 个;PROTOCOL_METHODS 常量数组与之同源互证)。
|
package/dist/port-contract.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as SetModelParams, a as SetModelResult } from './methods-
|
|
1
|
+
import { c as AgentCallOpts, E as EngineHandleData, e as EngineCapabilities, P as ProbeReport, A as AgentEvent, f as ResumeAnchor, d as AgentOutcome, S as SessionView } from './contract-types-C1scOS_M.cjs';
|
|
2
|
+
import { S as SetModelParams, a as SetModelResult } from './methods-BzvzcCrB.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎侧子集 + 协议 ctx 还原字段(model/
|
package/dist/port-contract.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as SetModelParams, a as SetModelResult } from './methods-
|
|
1
|
+
import { c as AgentCallOpts, E as EngineHandleData, e as EngineCapabilities, P as ProbeReport, A as AgentEvent, f as ResumeAnchor, d as AgentOutcome, S as SessionView } from './contract-types-C1scOS_M.js';
|
|
2
|
+
import { S as SetModelParams, a as SetModelResult } from './methods-CPMc4cvF.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎侧子集 + 协议 ctx 还原字段(model/
|