@zhushanwen/subagent-engine-sdk 0.2.1 → 0.4.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-A75XDJIC.js → chunk-AIG5LSGK.js} +3 -0
- package/dist/{chunk-ZXEAW25V.js → chunk-BBVZK5DL.js} +1 -4
- package/dist/chunk-EUSM6ZX4.js +10 -0
- package/dist/{chunk-LEOBWKRM.js → chunk-FJT23P7T.js} +1 -1
- package/dist/{chunk-N3RL6OVM.js → chunk-J4G2MXDS.js} +3 -1
- package/dist/{chunk-ZOFFJNJD.js → chunk-LKPVN3N6.js} +1 -1
- package/dist/{chunk-RULLX6C6.js → chunk-LQR73V67.js} +2 -0
- package/dist/{chunk-YFSN3D5N.js → chunk-TW2FAMAJ.js} +24 -32
- package/dist/{chunk-PPEPBVCC.js → chunk-WS4WAZVR.js} +1 -1
- package/dist/cli-entry.cjs +3 -1
- package/dist/cli-entry.js +1 -1
- package/dist/{contract-types-sSlgppBC.d.cts → contract-types-C71Sqq8d.d.cts} +31 -43
- package/dist/{contract-types-sSlgppBC.d.ts → contract-types-C71Sqq8d.d.ts} +31 -43
- package/dist/env.cjs +1 -4
- package/dist/env.d.cts +4 -1
- package/dist/env.d.ts +4 -1
- package/dist/env.js +1 -1
- package/dist/{error-codes-Dhss2Kmk.d.ts → error-codes-CiOO3PMg.d.cts} +7 -7
- package/dist/{error-codes-DHco5-i_.d.cts → error-codes-D5YlWaBx.d.ts} +7 -7
- package/dist/index.cjs +45 -41
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +16 -15
- package/dist/journal-io.d.cts +1 -1
- package/dist/journal-io.d.ts +1 -1
- package/dist/journal-replay.cjs +3 -0
- package/dist/journal-replay.d.cts +1 -1
- package/dist/journal-replay.d.ts +1 -1
- package/dist/journal-replay.js +1 -1
- package/dist/kill-chain.d.cts +2 -2
- package/dist/kill-chain.d.ts +2 -2
- package/dist/kill-chain.js +2 -2
- package/dist/node-executor.js +2 -2
- package/dist/port-contract.cjs +3 -0
- package/dist/port-contract.d.cts +45 -11
- package/dist/port-contract.d.ts +45 -11
- package/dist/port-contract.js +3 -1
- package/dist/protocol/index.cjs +26 -36
- package/dist/protocol/index.d.cts +95 -172
- package/dist/protocol/index.d.ts +95 -172
- package/dist/protocol/index.js +4 -8
- package/dist/ui-types.cjs +16 -0
- package/dist/ui-types.d.cts +13 -6
- package/dist/ui-types.d.ts +13 -6
- package/dist/ui-types.js +7 -1
- package/package.json +1 -1
- package/src/cli-entry.ts +6 -1
- package/src/data-dir.ts +3 -2
- package/src/env.ts +4 -4
- package/src/journal-replay.ts +4 -0
- package/src/nesting-guard.ts +1 -1
- package/src/paths.ts +1 -1
- package/src/port-contract.ts +44 -11
- package/src/protocol/contract-types.ts +36 -35
- package/src/protocol/engine-protocol.ts +22 -12
- package/src/protocol/error-codes.ts +7 -6
- package/src/protocol/frames.ts +1 -3
- package/src/protocol/methods.ts +38 -30
- package/src/protocol/reverse-channels.ts +21 -172
- package/src/protocol/schema.ts +34 -3
- package/src/ui-types.ts +22 -5
- package/dist/chunk-2DIMPZCQ.js +0 -0
|
@@ -164,6 +164,9 @@ function updateFromEvent(record, event) {
|
|
|
164
164
|
// ── compaction:不产生数据(不变)──
|
|
165
165
|
case "compaction":
|
|
166
166
|
return;
|
|
167
|
+
// ── activity:纯活性信号,reducer no-op(协议语义见 contract-types)──
|
|
168
|
+
case "activity":
|
|
169
|
+
return;
|
|
167
170
|
default: {
|
|
168
171
|
const _exhaustive = event;
|
|
169
172
|
return _exhaustive;
|
|
@@ -14,10 +14,7 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
14
14
|
"XYZ_RUNTIME_TOKEN",
|
|
15
15
|
"XYZ_AGENT_API_KEY",
|
|
16
16
|
"XYZ_SUBAGENT_RELAY_SESSION_ID",
|
|
17
|
-
"XYZ_SUBAGENT_RELAY_RECORD_ID"
|
|
18
|
-
"XYZ_SUBAGENT_RELAY_STDIN",
|
|
19
|
-
"XYZ_SUBAGENT_RELAY_STDOUT",
|
|
20
|
-
"XYZ_SUBAGENT_RELAY_STDERR"
|
|
17
|
+
"XYZ_SUBAGENT_RELAY_RECORD_ID"
|
|
21
18
|
];
|
|
22
19
|
var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
23
20
|
"XYZ_AGENT_DATA_DIR",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/ui-types.ts
|
|
2
|
+
function isUiResponse(value) {
|
|
3
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4
|
+
const v = value;
|
|
5
|
+
return typeof v.value === "string" || typeof v.confirmed === "boolean" || v.cancelled === true || v.ack === true;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
isUiResponse
|
|
10
|
+
};
|
|
@@ -11,8 +11,10 @@ function runEngineCliEntry(opts) {
|
|
|
11
11
|
const server = opts.server;
|
|
12
12
|
configureLoggerSink({
|
|
13
13
|
log(level, component, message, data) {
|
|
14
|
-
|
|
14
|
+
if (level !== "debug") {
|
|
15
|
+
process.stderr.write(`[${level}] [${component}] ${message}${data !== void 0 ? ` ${JSON.stringify(data)}` : ""}
|
|
15
16
|
`);
|
|
17
|
+
}
|
|
16
18
|
void server.reverseRequest("host/log", { level, component, message }).catch(() => void 0);
|
|
17
19
|
}
|
|
18
20
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/port-contract.ts
|
|
2
|
+
var SHARED_POOL_KEY = "shared";
|
|
2
3
|
function parseCtxModel(ref) {
|
|
3
4
|
if (ref === void 0 || ref.trim() === "") return void 0;
|
|
4
5
|
const slash = ref.indexOf("/");
|
|
@@ -7,5 +8,6 @@ function parseCtxModel(ref) {
|
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export {
|
|
11
|
+
SHARED_POOL_KEY,
|
|
10
12
|
parseCtxModel
|
|
11
13
|
};
|
|
@@ -26,7 +26,6 @@ var PROTOCOL_METHODS = [
|
|
|
26
26
|
"probe",
|
|
27
27
|
"run",
|
|
28
28
|
"cancel",
|
|
29
|
-
"interact",
|
|
30
29
|
"read",
|
|
31
30
|
"listModels",
|
|
32
31
|
"validateModel",
|
|
@@ -38,44 +37,19 @@ var PROTOCOL_METHODS = [
|
|
|
38
37
|
var REVERSE_CHANNELS = [
|
|
39
38
|
"host/log",
|
|
40
39
|
"host/askUser",
|
|
41
|
-
"host/permission",
|
|
42
40
|
"host/streamDelta",
|
|
43
|
-
"host/poolResolved",
|
|
44
41
|
"host/handleReady",
|
|
45
42
|
"host/childSpawned",
|
|
46
|
-
"host/childStateChanged"
|
|
47
|
-
"host/roundLifecycle"
|
|
43
|
+
"host/childStateChanged"
|
|
48
44
|
];
|
|
49
45
|
var REVERSE_CHANNEL_TIMEOUT_CLASS = {
|
|
50
46
|
"host/log": "data-plane",
|
|
51
47
|
"host/streamDelta": "data-plane",
|
|
52
|
-
"host/poolResolved": "data-plane",
|
|
53
48
|
"host/handleReady": "data-plane",
|
|
54
49
|
"host/childSpawned": "data-plane",
|
|
55
50
|
"host/childStateChanged": "data-plane",
|
|
56
|
-
"host/
|
|
57
|
-
"host/askUser": "interaction",
|
|
58
|
-
"host/permission": "interaction"
|
|
51
|
+
"host/askUser": "interaction"
|
|
59
52
|
};
|
|
60
|
-
function isHostStreamDeltaParams(value) {
|
|
61
|
-
if (typeof value !== "object" || value === null) return false;
|
|
62
|
-
const v = value;
|
|
63
|
-
const hasRunId = typeof v.runId === "string";
|
|
64
|
-
const hasRecordId = typeof v.recordId === "string";
|
|
65
|
-
if (hasRunId === hasRecordId) return false;
|
|
66
|
-
return typeof v.delta === "string";
|
|
67
|
-
}
|
|
68
|
-
function isHostRoundLifecycleParams(value) {
|
|
69
|
-
if (typeof value !== "object" || value === null) return false;
|
|
70
|
-
const v = value;
|
|
71
|
-
const hasRunId = typeof v.runId === "string";
|
|
72
|
-
const hasRecordId = typeof v.recordId === "string";
|
|
73
|
-
if (hasRunId === hasRecordId) return false;
|
|
74
|
-
if (v.phase === "settled" || v.phase === "idle") return true;
|
|
75
|
-
if (v.phase !== "failed") return false;
|
|
76
|
-
const err = v.error;
|
|
77
|
-
return typeof err === "object" && err !== null && typeof err.code === "string" && typeof err.message === "string";
|
|
78
|
-
}
|
|
79
53
|
|
|
80
54
|
// src/protocol/schema.ts
|
|
81
55
|
var ANY_JSON = {};
|
|
@@ -155,6 +129,7 @@ var notificationFrameSchema = {
|
|
|
155
129
|
"turn_end",
|
|
156
130
|
"message_end",
|
|
157
131
|
"compaction",
|
|
132
|
+
"activity",
|
|
158
133
|
"error"
|
|
159
134
|
]
|
|
160
135
|
}
|
|
@@ -192,7 +167,26 @@ var FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS = [
|
|
|
192
167
|
"password",
|
|
193
168
|
"secret"
|
|
194
169
|
];
|
|
195
|
-
var
|
|
170
|
+
var runSessionParamsSchema = {
|
|
171
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
172
|
+
title: "EngineRunSessionParams",
|
|
173
|
+
type: "object",
|
|
174
|
+
additionalProperties: false,
|
|
175
|
+
required: ["recordId"],
|
|
176
|
+
properties: {
|
|
177
|
+
recordId: { type: "string" },
|
|
178
|
+
resume: {
|
|
179
|
+
type: "object",
|
|
180
|
+
additionalProperties: false,
|
|
181
|
+
required: ["sessionRef"],
|
|
182
|
+
properties: {
|
|
183
|
+
// ResumeAnchor.sessionRef = Record<string, string>(引擎定位键值对)
|
|
184
|
+
sessionRef: { type: "object", additionalProperties: { type: "string" } },
|
|
185
|
+
journalPath: { type: "string" }
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
196
190
|
|
|
197
191
|
export {
|
|
198
192
|
isRequestFrame,
|
|
@@ -202,8 +196,6 @@ export {
|
|
|
202
196
|
PROTOCOL_METHODS,
|
|
203
197
|
REVERSE_CHANNELS,
|
|
204
198
|
REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
205
|
-
isHostStreamDeltaParams,
|
|
206
|
-
isHostRoundLifecycleParams,
|
|
207
199
|
protocolErrorSchema,
|
|
208
200
|
requestFrameSchema,
|
|
209
201
|
successResponseFrameSchema,
|
|
@@ -212,5 +204,5 @@ export {
|
|
|
212
204
|
reverseRequestFrameSchema,
|
|
213
205
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
214
206
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
215
|
-
|
|
207
|
+
runSessionParamsSchema
|
|
216
208
|
};
|
|
@@ -70,7 +70,7 @@ function engineProtocolMismatchError(engineVersion) {
|
|
|
70
70
|
function engineConversationUnsupportedError(engineId) {
|
|
71
71
|
return new EngineSdkError(
|
|
72
72
|
"engine_capability_unsupported",
|
|
73
|
-
`engine '${engineId}' \u4E0D\u652F\u6301
|
|
73
|
+
`engine '${engineId}' \u4E0D\u652F\u6301 resume \u7EED\u804A\uFF08capabilities.conversation = 'unsupported'\uFF0Cmanifest \u65E0 conversation gate \u4F4D\uFF09`,
|
|
74
74
|
`\u53BB\u6389 conversation \u53C2\u6570\uFF08\u4E00\u6B21\u6027\u4EFB\u52A1\u9ED8\u8BA4\u5F62\u6001\uFF09\uFF0C\u6216\u4FEE manifest capabilities / \u5347\u7EA7\u5F15\u64CE\u5305\uFF08\u82E5\u5F15\u64CE\u5B9E\u9645\u652F\u6301\u8BE5\u80FD\u529B\uFF09`,
|
|
75
75
|
{ engineId, capability: "conversation", declared: "unsupported" }
|
|
76
76
|
);
|
package/dist/cli-entry.cjs
CHANGED
|
@@ -92,8 +92,10 @@ function runEngineCliEntry(opts) {
|
|
|
92
92
|
const server = opts.server;
|
|
93
93
|
configureLoggerSink({
|
|
94
94
|
log(level, component, message, data) {
|
|
95
|
-
|
|
95
|
+
if (level !== "debug") {
|
|
96
|
+
process.stderr.write(`[${level}] [${component}] ${message}${data !== void 0 ? ` ${JSON.stringify(data)}` : ""}
|
|
96
97
|
`);
|
|
98
|
+
}
|
|
97
99
|
void server.reverseRequest("host/log", { level, component, message }).catch(() => void 0);
|
|
98
100
|
}
|
|
99
101
|
});
|
package/dist/cli-entry.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* const _assert: _CoreSdkAgentEvent = true;
|
|
8
8
|
*/
|
|
9
9
|
type AssertMutuallyAssignable<A, B> = [A] extends [B] ? [B] extends [A] ? true : never : never;
|
|
10
|
-
/** token 用量(message_end 单条消息增量)。← core execution/types.ts AgentUsage。 */
|
|
10
|
+
/** token 用量(message_end 单条消息增量)。← core execution/assembly/types.ts AgentUsage。 */
|
|
11
11
|
interface AgentUsage {
|
|
12
12
|
input: number;
|
|
13
13
|
output: number;
|
|
@@ -56,8 +56,12 @@ interface Turn {
|
|
|
56
56
|
closedTs?: number;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* 引擎事件(
|
|
60
|
-
* 兼容」不变量 3 的类型面)。语义锚点 = pi(ACP 词汇对照见 core execution/types.ts 注释)。
|
|
59
|
+
* 引擎事件(9 种,协议 event.params.event 逐字序列化——「事件与 handle 序列化逐字
|
|
60
|
+
* 兼容」不变量 3 的类型面)。语义锚点 = pi(ACP 词汇对照见 core execution/assembly/types.ts 注释)。
|
|
61
|
+
*
|
|
62
|
+
* activity = 纯活性信号:双侧 reducer no-op、不开 turn、不写状态、不落 journal
|
|
63
|
+
* (core journal-wiring 对其豁免 append),只承诺「引擎活跃时周期性出现」——供宿主
|
|
64
|
+
* 无进展守护刷新判活(长工具执行期)。节流属生产者实现细节,不进协议承诺。
|
|
61
65
|
*/
|
|
62
66
|
type AgentEvent = {
|
|
63
67
|
type: "tool_start";
|
|
@@ -84,12 +88,14 @@ type AgentEvent = {
|
|
|
84
88
|
error?: string;
|
|
85
89
|
} | {
|
|
86
90
|
type: "compaction";
|
|
91
|
+
} | {
|
|
92
|
+
type: "activity";
|
|
87
93
|
} | {
|
|
88
94
|
type: "error";
|
|
89
95
|
message: string;
|
|
90
96
|
};
|
|
91
97
|
/**
|
|
92
|
-
* EngineHandle 的持久化形态(JSON v1)。协议 run 终态应答 /
|
|
98
|
+
* EngineHandle 的持久化形态(JSON v1)。协议 run 终态应答 / read 的
|
|
93
99
|
* handle 载荷(引擎不持有宿主运行时引用,data 即全部)。
|
|
94
100
|
*/
|
|
95
101
|
interface EngineHandleData {
|
|
@@ -98,9 +104,11 @@ interface EngineHandleData {
|
|
|
98
104
|
engineId: string;
|
|
99
105
|
/** 引擎自定义定位键值。pi = { recordId?, sessionFile? };zcode = { sessionId, dbPath }。 */
|
|
100
106
|
sessionRef: Record<string, string>;
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
/**
|
|
108
|
+
* journal 绝对路径(read 第②级数据源;宿主读前校验前缀白名单)。缺省 = 无 journal。
|
|
109
|
+
* [池抽象降级 2026-09-13] 原 poolKey 字段已删除——两引擎 poolKey 恒 'shared'
|
|
110
|
+
* (SDK SHARED_POOL_KEY),journal 固定落 engines/<engineId>/shared/,字段零信息量。
|
|
111
|
+
*/
|
|
104
112
|
journalPath?: string;
|
|
105
113
|
/** probe 实测版本(漂移排查锚点)。 */
|
|
106
114
|
engineVersion?: string;
|
|
@@ -109,18 +117,15 @@ interface EngineHandleData {
|
|
|
109
117
|
}
|
|
110
118
|
/**
|
|
111
119
|
* [v1.x] 冷续 resume 锚点——EngineHandleData 定位键的投影子集(诊断字段
|
|
112
|
-
* v/engineVersion/adapterVersion
|
|
113
|
-
* - run.params.
|
|
114
|
-
* sessionRef.sessionFile —— 对照 core SpawnResumeOpts.sessionFile
|
|
115
|
-
*
|
|
116
|
-
* 宿主据此刷新冷续依据——pi 定位键形态同 EngineHandleData.sessionRef 注释)。
|
|
120
|
+
* v/engineVersion/adapterVersion 不属锚点语义,不随锚点走)。消费点:
|
|
121
|
+
* - run.params.resume(宿主 → 引擎:冷续重开已 idle 的 session,pi 消费
|
|
122
|
+
* sessionRef.sessionFile —— 对照 core SpawnResumeOpts.sessionFile 的锚点面)。
|
|
123
|
+
* [H1 U6 已切换] 键切换单批完成(读写端同批),锚点仅经 resume 键携带。
|
|
117
124
|
* 类型层与 EngineHandleData 定位形态的对照由测试断言(Pick 可赋值闭包)锁定。
|
|
118
125
|
*/
|
|
119
126
|
interface ResumeAnchor {
|
|
120
127
|
/** 引擎定位键(pi = { recordId?, sessionFile? };zcode = { sessionId, dbPath })。 */
|
|
121
128
|
sessionRef: Record<string, string>;
|
|
122
|
-
/** 隔离池定位(锚点补全 handle 重建所需;pi 无池化恒 'shared')。 */
|
|
123
|
-
poolKey: string;
|
|
124
129
|
/** journal 绝对路径(read 降级链第②级数据源;无 journal 缺省)。 */
|
|
125
130
|
journalPath?: string;
|
|
126
131
|
}
|
|
@@ -155,8 +160,16 @@ interface EngineCapabilities {
|
|
|
155
160
|
schemaEnforcement: "native" | "emulated";
|
|
156
161
|
/** 注意区分「引擎 RPC 层有此能力」与「subagent 链路已接通」。 */
|
|
157
162
|
steer: "native" | "emulated" | "unsupported";
|
|
158
|
-
/**
|
|
159
|
-
|
|
163
|
+
/**
|
|
164
|
+
* [H1 D5 语义收窄] resume 能力位(chat 续聊 = 新 run + resume 锚点的承载前提;
|
|
165
|
+
* 原名字沿用——conversation 位保留、语义从「interact 长驻控制面」收窄为
|
|
166
|
+
* 「resume 续聊能力」,gate 判据与消费方不变)。
|
|
167
|
+
* [U6 / 永久会话模型 §3.2.6 要点 4] 新值 "cold" = 冷恢复会话:resume 读通道取
|
|
168
|
+
* 结构化历史 + 新 session 注入(无热 steering)。gate 判据仍是 `=== "unsupported"`
|
|
169
|
+
* 拒绝——"cold" 在 gate 面与 "native" 等价放行,差异只在续聊形态(新 session
|
|
170
|
+
* 注入 vs 原地续写)。
|
|
171
|
+
*/
|
|
172
|
+
conversation: "native" | "cold" | "unsupported";
|
|
160
173
|
/** 决定 persona 路由策略(file/flag/prompt 通道)。 */
|
|
161
174
|
personaInjection: "file" | "flag" | "prompt";
|
|
162
175
|
/** 粗粒度引擎:GUI 显示降级为阶段态。 */
|
|
@@ -190,31 +203,6 @@ interface ProbeReport {
|
|
|
190
203
|
recovery: string;
|
|
191
204
|
};
|
|
192
205
|
}
|
|
193
|
-
/**
|
|
194
|
-
* interact 的 action(交互控制面)。interrupt: true = steer(抢占)/ false|缺省 =
|
|
195
|
-
* followUp(排队);不支持抢占的引擎忽略。
|
|
196
|
-
*/
|
|
197
|
-
type InteractAction = {
|
|
198
|
-
kind: "message";
|
|
199
|
-
payload: string;
|
|
200
|
-
interrupt?: boolean;
|
|
201
|
-
} | {
|
|
202
|
-
kind: "close";
|
|
203
|
-
payload?: {
|
|
204
|
-
force: boolean;
|
|
205
|
-
};
|
|
206
|
-
} | {
|
|
207
|
-
kind: "cancel";
|
|
208
|
-
};
|
|
209
|
-
/** interact 的结果(失败码 = engine_session_not_resumable / engine_capability_unsupported 等)。 */
|
|
210
|
-
type InteractResult = {
|
|
211
|
-
ok: true;
|
|
212
|
-
delivered: true;
|
|
213
|
-
} | {
|
|
214
|
-
ok: false;
|
|
215
|
-
code: string;
|
|
216
|
-
message: string;
|
|
217
|
-
};
|
|
218
206
|
/** 失败分诊结构化标签。unknown(含缺省)= 可重试(语义守恒)。 */
|
|
219
207
|
type AgentFailureKind = "stale_context" | "schema_deterministic" | "unknown";
|
|
220
208
|
/**
|
|
@@ -237,7 +225,7 @@ interface ToolCallEntry {
|
|
|
237
225
|
/** Args preview string. */
|
|
238
226
|
input: string;
|
|
239
227
|
}
|
|
240
|
-
/** worktree 句柄(结构等价副本;core 权威定义在 execution/types.ts:349)。 */
|
|
228
|
+
/** worktree 句柄(结构等价副本;core 权威定义在 execution/assembly/types.ts:349)。 */
|
|
241
229
|
interface WorktreeHandle {
|
|
242
230
|
/** checkout 目录(子 agent 工作目录)。 */
|
|
243
231
|
readonly path: string;
|
|
@@ -349,4 +337,4 @@ interface AgentCallOpts {
|
|
|
349
337
|
permissionMode?: string;
|
|
350
338
|
}
|
|
351
339
|
|
|
352
|
-
export type { AgentCallOpts as A, EngineCapabilities as E,
|
|
340
|
+
export type { AgentCallOpts as A, EngineCapabilities as E, InternalToolCall as I, ModelCatalogEntry as M, ProbeReport as P, ReplayedTurn as R, SessionView as S, ToolCall as T, WorktreeHandle as W, AgentEvent as a, AgentFailureKind as b, AgentOutcome as c, AgentOutcomeUsage as d, AgentUsage as e, AgentUsageTotal as f, AssertMutuallyAssignable as g, EngineHandleData as h, ResumeAnchor as i, ToolCallEntry as j, ToolCallResult as k, Turn as l };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* const _assert: _CoreSdkAgentEvent = true;
|
|
8
8
|
*/
|
|
9
9
|
type AssertMutuallyAssignable<A, B> = [A] extends [B] ? [B] extends [A] ? true : never : never;
|
|
10
|
-
/** token 用量(message_end 单条消息增量)。← core execution/types.ts AgentUsage。 */
|
|
10
|
+
/** token 用量(message_end 单条消息增量)。← core execution/assembly/types.ts AgentUsage。 */
|
|
11
11
|
interface AgentUsage {
|
|
12
12
|
input: number;
|
|
13
13
|
output: number;
|
|
@@ -56,8 +56,12 @@ interface Turn {
|
|
|
56
56
|
closedTs?: number;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* 引擎事件(
|
|
60
|
-
* 兼容」不变量 3 的类型面)。语义锚点 = pi(ACP 词汇对照见 core execution/types.ts 注释)。
|
|
59
|
+
* 引擎事件(9 种,协议 event.params.event 逐字序列化——「事件与 handle 序列化逐字
|
|
60
|
+
* 兼容」不变量 3 的类型面)。语义锚点 = pi(ACP 词汇对照见 core execution/assembly/types.ts 注释)。
|
|
61
|
+
*
|
|
62
|
+
* activity = 纯活性信号:双侧 reducer no-op、不开 turn、不写状态、不落 journal
|
|
63
|
+
* (core journal-wiring 对其豁免 append),只承诺「引擎活跃时周期性出现」——供宿主
|
|
64
|
+
* 无进展守护刷新判活(长工具执行期)。节流属生产者实现细节,不进协议承诺。
|
|
61
65
|
*/
|
|
62
66
|
type AgentEvent = {
|
|
63
67
|
type: "tool_start";
|
|
@@ -84,12 +88,14 @@ type AgentEvent = {
|
|
|
84
88
|
error?: string;
|
|
85
89
|
} | {
|
|
86
90
|
type: "compaction";
|
|
91
|
+
} | {
|
|
92
|
+
type: "activity";
|
|
87
93
|
} | {
|
|
88
94
|
type: "error";
|
|
89
95
|
message: string;
|
|
90
96
|
};
|
|
91
97
|
/**
|
|
92
|
-
* EngineHandle 的持久化形态(JSON v1)。协议 run 终态应答 /
|
|
98
|
+
* EngineHandle 的持久化形态(JSON v1)。协议 run 终态应答 / read 的
|
|
93
99
|
* handle 载荷(引擎不持有宿主运行时引用,data 即全部)。
|
|
94
100
|
*/
|
|
95
101
|
interface EngineHandleData {
|
|
@@ -98,9 +104,11 @@ interface EngineHandleData {
|
|
|
98
104
|
engineId: string;
|
|
99
105
|
/** 引擎自定义定位键值。pi = { recordId?, sessionFile? };zcode = { sessionId, dbPath }。 */
|
|
100
106
|
sessionRef: Record<string, string>;
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
/**
|
|
108
|
+
* journal 绝对路径(read 第②级数据源;宿主读前校验前缀白名单)。缺省 = 无 journal。
|
|
109
|
+
* [池抽象降级 2026-09-13] 原 poolKey 字段已删除——两引擎 poolKey 恒 'shared'
|
|
110
|
+
* (SDK SHARED_POOL_KEY),journal 固定落 engines/<engineId>/shared/,字段零信息量。
|
|
111
|
+
*/
|
|
104
112
|
journalPath?: string;
|
|
105
113
|
/** probe 实测版本(漂移排查锚点)。 */
|
|
106
114
|
engineVersion?: string;
|
|
@@ -109,18 +117,15 @@ interface EngineHandleData {
|
|
|
109
117
|
}
|
|
110
118
|
/**
|
|
111
119
|
* [v1.x] 冷续 resume 锚点——EngineHandleData 定位键的投影子集(诊断字段
|
|
112
|
-
* v/engineVersion/adapterVersion
|
|
113
|
-
* - run.params.
|
|
114
|
-
* sessionRef.sessionFile —— 对照 core SpawnResumeOpts.sessionFile
|
|
115
|
-
*
|
|
116
|
-
* 宿主据此刷新冷续依据——pi 定位键形态同 EngineHandleData.sessionRef 注释)。
|
|
120
|
+
* v/engineVersion/adapterVersion 不属锚点语义,不随锚点走)。消费点:
|
|
121
|
+
* - run.params.resume(宿主 → 引擎:冷续重开已 idle 的 session,pi 消费
|
|
122
|
+
* sessionRef.sessionFile —— 对照 core SpawnResumeOpts.sessionFile 的锚点面)。
|
|
123
|
+
* [H1 U6 已切换] 键切换单批完成(读写端同批),锚点仅经 resume 键携带。
|
|
117
124
|
* 类型层与 EngineHandleData 定位形态的对照由测试断言(Pick 可赋值闭包)锁定。
|
|
118
125
|
*/
|
|
119
126
|
interface ResumeAnchor {
|
|
120
127
|
/** 引擎定位键(pi = { recordId?, sessionFile? };zcode = { sessionId, dbPath })。 */
|
|
121
128
|
sessionRef: Record<string, string>;
|
|
122
|
-
/** 隔离池定位(锚点补全 handle 重建所需;pi 无池化恒 'shared')。 */
|
|
123
|
-
poolKey: string;
|
|
124
129
|
/** journal 绝对路径(read 降级链第②级数据源;无 journal 缺省)。 */
|
|
125
130
|
journalPath?: string;
|
|
126
131
|
}
|
|
@@ -155,8 +160,16 @@ interface EngineCapabilities {
|
|
|
155
160
|
schemaEnforcement: "native" | "emulated";
|
|
156
161
|
/** 注意区分「引擎 RPC 层有此能力」与「subagent 链路已接通」。 */
|
|
157
162
|
steer: "native" | "emulated" | "unsupported";
|
|
158
|
-
/**
|
|
159
|
-
|
|
163
|
+
/**
|
|
164
|
+
* [H1 D5 语义收窄] resume 能力位(chat 续聊 = 新 run + resume 锚点的承载前提;
|
|
165
|
+
* 原名字沿用——conversation 位保留、语义从「interact 长驻控制面」收窄为
|
|
166
|
+
* 「resume 续聊能力」,gate 判据与消费方不变)。
|
|
167
|
+
* [U6 / 永久会话模型 §3.2.6 要点 4] 新值 "cold" = 冷恢复会话:resume 读通道取
|
|
168
|
+
* 结构化历史 + 新 session 注入(无热 steering)。gate 判据仍是 `=== "unsupported"`
|
|
169
|
+
* 拒绝——"cold" 在 gate 面与 "native" 等价放行,差异只在续聊形态(新 session
|
|
170
|
+
* 注入 vs 原地续写)。
|
|
171
|
+
*/
|
|
172
|
+
conversation: "native" | "cold" | "unsupported";
|
|
160
173
|
/** 决定 persona 路由策略(file/flag/prompt 通道)。 */
|
|
161
174
|
personaInjection: "file" | "flag" | "prompt";
|
|
162
175
|
/** 粗粒度引擎:GUI 显示降级为阶段态。 */
|
|
@@ -190,31 +203,6 @@ interface ProbeReport {
|
|
|
190
203
|
recovery: string;
|
|
191
204
|
};
|
|
192
205
|
}
|
|
193
|
-
/**
|
|
194
|
-
* interact 的 action(交互控制面)。interrupt: true = steer(抢占)/ false|缺省 =
|
|
195
|
-
* followUp(排队);不支持抢占的引擎忽略。
|
|
196
|
-
*/
|
|
197
|
-
type InteractAction = {
|
|
198
|
-
kind: "message";
|
|
199
|
-
payload: string;
|
|
200
|
-
interrupt?: boolean;
|
|
201
|
-
} | {
|
|
202
|
-
kind: "close";
|
|
203
|
-
payload?: {
|
|
204
|
-
force: boolean;
|
|
205
|
-
};
|
|
206
|
-
} | {
|
|
207
|
-
kind: "cancel";
|
|
208
|
-
};
|
|
209
|
-
/** interact 的结果(失败码 = engine_session_not_resumable / engine_capability_unsupported 等)。 */
|
|
210
|
-
type InteractResult = {
|
|
211
|
-
ok: true;
|
|
212
|
-
delivered: true;
|
|
213
|
-
} | {
|
|
214
|
-
ok: false;
|
|
215
|
-
code: string;
|
|
216
|
-
message: string;
|
|
217
|
-
};
|
|
218
206
|
/** 失败分诊结构化标签。unknown(含缺省)= 可重试(语义守恒)。 */
|
|
219
207
|
type AgentFailureKind = "stale_context" | "schema_deterministic" | "unknown";
|
|
220
208
|
/**
|
|
@@ -237,7 +225,7 @@ interface ToolCallEntry {
|
|
|
237
225
|
/** Args preview string. */
|
|
238
226
|
input: string;
|
|
239
227
|
}
|
|
240
|
-
/** worktree 句柄(结构等价副本;core 权威定义在 execution/types.ts:349)。 */
|
|
228
|
+
/** worktree 句柄(结构等价副本;core 权威定义在 execution/assembly/types.ts:349)。 */
|
|
241
229
|
interface WorktreeHandle {
|
|
242
230
|
/** checkout 目录(子 agent 工作目录)。 */
|
|
243
231
|
readonly path: string;
|
|
@@ -349,4 +337,4 @@ interface AgentCallOpts {
|
|
|
349
337
|
permissionMode?: string;
|
|
350
338
|
}
|
|
351
339
|
|
|
352
|
-
export type { AgentCallOpts as A, EngineCapabilities as E,
|
|
340
|
+
export type { AgentCallOpts as A, EngineCapabilities as E, InternalToolCall as I, ModelCatalogEntry as M, ProbeReport as P, ReplayedTurn as R, SessionView as S, ToolCall as T, WorktreeHandle as W, AgentEvent as a, AgentFailureKind as b, AgentOutcome as c, AgentOutcomeUsage as d, AgentUsage as e, AgentUsageTotal as f, AssertMutuallyAssignable as g, EngineHandleData as h, ResumeAnchor as i, ToolCallEntry as j, ToolCallResult as k, Turn as l };
|
package/dist/env.cjs
CHANGED
|
@@ -87,10 +87,7 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
87
87
|
"XYZ_RUNTIME_TOKEN",
|
|
88
88
|
"XYZ_AGENT_API_KEY",
|
|
89
89
|
"XYZ_SUBAGENT_RELAY_SESSION_ID",
|
|
90
|
-
"XYZ_SUBAGENT_RELAY_RECORD_ID"
|
|
91
|
-
"XYZ_SUBAGENT_RELAY_STDIN",
|
|
92
|
-
"XYZ_SUBAGENT_RELAY_STDOUT",
|
|
93
|
-
"XYZ_SUBAGENT_RELAY_STDERR"
|
|
90
|
+
"XYZ_SUBAGENT_RELAY_RECORD_ID"
|
|
94
91
|
];
|
|
95
92
|
var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
96
93
|
"XYZ_AGENT_DATA_DIR",
|
package/dist/env.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** L2 manifest 放行的保留前缀拒绝表(镜像 shared SSOT,勿单独改动)。 */
|
|
2
2
|
declare const ENGINE_ENV_PREFIXES: readonly string[];
|
|
3
|
-
/** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。
|
|
3
|
+
/** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。
|
|
4
|
+
* 互引(场景域分化,勿互混):dev 装配器(apps/electron/scripts/dev-instance-lib.mjs
|
|
5
|
+
* `LEAK_ENV_KEYS`)仍剥 RELAY_STD* 三键——dev 宿主进程环境防泄漏口径独立于引擎
|
|
6
|
+
* spawn 面;本清单(引擎侧)已退役同名三键,写入方已清零。 */
|
|
4
7
|
declare const ENGINE_ENV_DENY_LIST: readonly string[];
|
|
5
8
|
/** L0 注入的全部基础设施键(守卫断言:与 ENGINE_ENV_DENY_LIST 交集 = ∅)。 */
|
|
6
9
|
declare const ENGINE_ENV_L0_INFRA_KEYS: readonly string[];
|
package/dist/env.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** L2 manifest 放行的保留前缀拒绝表(镜像 shared SSOT,勿单独改动)。 */
|
|
2
2
|
declare const ENGINE_ENV_PREFIXES: readonly string[];
|
|
3
|
-
/** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。
|
|
3
|
+
/** L1 deny + 显式剥除键集(镜像 shared SSOT,勿单独改动)。
|
|
4
|
+
* 互引(场景域分化,勿互混):dev 装配器(apps/electron/scripts/dev-instance-lib.mjs
|
|
5
|
+
* `LEAK_ENV_KEYS`)仍剥 RELAY_STD* 三键——dev 宿主进程环境防泄漏口径独立于引擎
|
|
6
|
+
* spawn 面;本清单(引擎侧)已退役同名三键,写入方已清零。 */
|
|
4
7
|
declare const ENGINE_ENV_DENY_LIST: readonly string[];
|
|
5
8
|
/** L0 注入的全部基础设施键(守卫断言:与 ENGINE_ENV_DENY_LIST 交集 = ∅)。 */
|
|
6
9
|
declare const ENGINE_ENV_L0_INFRA_KEYS: readonly string[];
|
package/dist/env.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AgentEvent, E as EngineCapabilities } from './contract-types-
|
|
1
|
+
import { a as AgentEvent, E as EngineCapabilities } from './contract-types-C71Sqq8d.cjs';
|
|
2
2
|
|
|
3
3
|
/** 协议错误对象(error 帧载荷与反向请求错误应答共用形态)。 */
|
|
4
4
|
interface ProtocolError {
|
|
@@ -46,7 +46,7 @@ type ReverseResponseResult =
|
|
|
46
46
|
{
|
|
47
47
|
ok: true;
|
|
48
48
|
}
|
|
49
|
-
/** 人机交互类(askUser
|
|
49
|
+
/** 人机交互类(askUser)两阶段第一阶段:已受理,结果异步到达(R9-2)。 */
|
|
50
50
|
| {
|
|
51
51
|
ack: true;
|
|
52
52
|
}
|
|
@@ -54,7 +54,6 @@ type ReverseResponseResult =
|
|
|
54
54
|
| {
|
|
55
55
|
unsupported: true;
|
|
56
56
|
};
|
|
57
|
-
type AnyFrame = RequestFrame | ResponseFrame | NotificationFrame | ReverseRequestFrame;
|
|
58
57
|
/** ① 请求:有数字 id + method + params,且无 result/error(与②应答区分)。 */
|
|
59
58
|
declare function isRequestFrame(frame: unknown): frame is RequestFrame;
|
|
60
59
|
/** ② 应答:有 id(number|string)且 result/error 二选一。 */
|
|
@@ -88,15 +87,16 @@ declare class EngineSdkError extends Error {
|
|
|
88
87
|
}
|
|
89
88
|
declare function engineProtocolMismatchError(engineVersion: number): EngineSdkError;
|
|
90
89
|
/**
|
|
91
|
-
* [v1.x]
|
|
92
|
-
* 验收 A6:manifest 无 conversation gate 位的引擎收到
|
|
90
|
+
* [v1.x] resume 会话形态(run.params.resume)的 gate 拒绝具名错误(chat-domain
|
|
91
|
+
* 设计 §3.2 D1-A + 验收 A6:manifest 无 conversation gate 位的引擎收到
|
|
92
|
+
* conversation 请求 → 同步拒;[H1] 文案随 D5 语义收窄——续聊 = resume 续聊)。
|
|
93
93
|
* 文案契约对齐 core capability-gate.ts conversation 分支(错误码
|
|
94
94
|
* engine_capability_unsupported + 「去掉参数 / 修 manifest / 升级引擎包」恢复指引)
|
|
95
95
|
* ——W3 chat 路由切协议客户端时以本构造器替换 core 内联文案,保持两侧一致。
|
|
96
96
|
*/
|
|
97
97
|
declare function engineConversationUnsupportedError(engineId: string): EngineSdkError;
|
|
98
98
|
/**
|
|
99
|
-
* [v1.x]
|
|
99
|
+
* [v1.x] resume 会话形态(run.params.resume / task.conversation=true)派发前的同步 gate:
|
|
100
100
|
* manifest conversation 位 unsupported 即抛 engineConversationUnsupportedError——
|
|
101
101
|
* 进程/record 创建前同步拒(A6:run 域不受影响,仅 chat 面被拦)。
|
|
102
102
|
* 判据单源:core 侧 capability-gate.assertTaskShapeSupported 的 conversation 分支
|
|
@@ -115,4 +115,4 @@ declare function engineTimeoutDetail(stdoutTail: string): string;
|
|
|
115
115
|
/** schema_emulation_failed 的终报文案(宿主编排层「重试一次仍失败」后消费)。 */
|
|
116
116
|
declare function schemaEmulationFailedDetail(error: string, tail: string): string;
|
|
117
117
|
|
|
118
|
-
export {
|
|
118
|
+
export { ENGINE_ERROR_CODE_PREFIX as E, type NotificationFrame as N, type ProtocolError as P, type RequestFrame as R, STDOUT_TAIL_ECHO_CHARS as S, ENGINE_PROTOCOL_ERROR_CODES as a, ENGINE_TIMEOUT_RECOVERY as b, type EngineProtocolErrorCode as c, EngineSdkError as d, type ErrorResponseFrame as e, type EventNotificationParams as f, type ResponseFrame as g, type ReverseRequestFrame as h, type ReverseResponseResult as i, type SuccessResponseFrame as j, assertChatConversationSupported as k, engineConversationUnsupportedError as l, engineProtocolMismatchError as m, engineTimeoutDetail as n, isEngineErrorPassthroughCode as o, isEngineProtocolErrorCode as p, isNotificationFrame as q, isRequestFrame as r, isResponseFrame as s, isReverseRequestFrame as t, schemaEmulationFailedDetail as u };
|