@zhushanwen/subagent-engine-sdk 0.6.1 → 0.7.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/best-effort.d.cts +1 -1
- package/dist/best-effort.d.ts +1 -1
- package/dist/{chunk-W3BKI2BP.js → chunk-3WC36CHI.js} +1 -1
- package/dist/{chunk-CNQTJJF5.js → chunk-HERD6RIR.js} +12 -1
- package/dist/{chunk-QOEXD2FT.js → chunk-RCT7L777.js} +36 -1
- package/dist/{chunk-WMDMXP2F.js → chunk-SFNTX7Q3.js} +0 -4
- package/dist/{chunk-AIG5LSGK.js → chunk-SGAIDL63.js} +5 -0
- package/dist/{chunk-63ZNJHM5.js → chunk-W23PAAGX.js} +3 -1
- package/dist/{contract-types-DaULkdpG.d.cts → contract-types-DiWyGRXr.d.cts} +78 -13
- package/dist/{contract-types-DaULkdpG.d.ts → contract-types-DiWyGRXr.d.ts} +78 -13
- package/dist/index.cjs +89 -8
- package/dist/index.d.cts +39 -5
- package/dist/index.d.ts +39 -5
- package/dist/index.js +45 -10
- package/dist/journal-io.d.cts +1 -1
- package/dist/journal-io.d.ts +1 -1
- package/dist/journal-replay.cjs +5 -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.cjs +38 -2
- package/dist/kill-chain.d.cts +38 -3
- package/dist/kill-chain.d.ts +38 -3
- package/dist/kill-chain.js +8 -5
- package/dist/node-executor.js +2 -2
- package/dist/port-contract.d.cts +9 -4
- package/dist/port-contract.d.ts +9 -4
- package/dist/protocol/index.cjs +3 -7
- package/dist/protocol/index.d.cts +132 -12
- package/dist/protocol/index.d.ts +132 -12
- package/dist/protocol/index.js +2 -6
- package/dist/spawn.cjs +81 -5
- package/dist/spawn.d.cts +13 -2
- package/dist/spawn.d.ts +13 -2
- package/dist/spawn.js +6 -1
- package/package.json +1 -1
- package/dist/error-codes-C9BOUI5H.d.ts +0 -118
- package/dist/error-codes-CFTOAxva.d.cts +0 -118
package/dist/kill-chain.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { a as AgentCallOpts, e as AgentOutcome } from './contract-types-DaULkdpG.cjs';
|
|
1
|
+
import { a as AgentCallOpts, e as AgentOutcome } from './contract-types-DiWyGRXr.cjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* 可杀子进程的结构形状(Node ChildProcess 的结构子集)。
|
|
@@ -47,6 +46,42 @@ interface KillChainOptions {
|
|
|
47
46
|
* @returns 'terminated' = SIGTERM 优雅退出(或进程已自行退出);'killed' = 走了 SIGKILL。
|
|
48
47
|
*/
|
|
49
48
|
declare function killChain(child: KillableChild, opts: KillChainOptions): Promise<"terminated" | "killed">;
|
|
49
|
+
/**
|
|
50
|
+
* 发信号兜底包裹:进程恰在退出态检查与 kill 之间自退时,ChildProcess.kill 可能抛
|
|
51
|
+
* (zsub 实测经验)——幂等吞掉并 debug 留痕,不阻断杀链语义(对已退进程信号本就是
|
|
52
|
+
* no-op)。收口自 zcode launcher 的内联实现(对齐点②:单一权威)。
|
|
53
|
+
*/
|
|
54
|
+
declare function safeKill(child: KillableChild, signal: NodeJS.Signals): void;
|
|
55
|
+
/**
|
|
56
|
+
* 单 pid 存活探针(`process.kill(pid, 0)`)。
|
|
57
|
+
*
|
|
58
|
+
* 返回三态:true = 存活;false = 已死(ESRCH);undefined = 不可判定(EPERM =
|
|
59
|
+
* 进程存在但属他人 / 探针异常)——undefined 按存活保守处理(杀链对已死进程发信号
|
|
60
|
+
* 本就是 no-op,误判存活只多一次空信号,误判死亡会漏杀)。
|
|
61
|
+
*/
|
|
62
|
+
declare function probePidAlive(pid: number): boolean | undefined;
|
|
63
|
+
/** killPidChain 参数形状。 */
|
|
64
|
+
interface PidChainOptions {
|
|
65
|
+
/**
|
|
66
|
+
* SIGTERM 优雅窗口(ms)。缺省 DEFAULT_KILL_GRACE_MS。回收场景的调用方通常
|
|
67
|
+
* 已先行优雅停止(cancel 帧 SIGTERM),本窗只是宿主侧升级兜底,量级沿用组杀
|
|
68
|
+
* 收割惯例(5s)。
|
|
69
|
+
*/
|
|
70
|
+
graceMs?: number;
|
|
71
|
+
/** SIGKILL 升级时的 warn 留痕语境(如 `run run-a topology kill`)。不传则静默升级。 */
|
|
72
|
+
note?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* [D9-2 半径收窄原语] run 级 pid 杀链:SIGTERM → graceMs → 仍存活则 SIGKILL,
|
|
76
|
+
* **只打单 pid,绝不组杀**(宿主对引擎孙进程只持镜像 pid、不持 ChildProcess——
|
|
77
|
+
* 引擎以 detached:true 自成进程组,孙进程在其组内而非自任组长,负 pid 组杀不可达;
|
|
78
|
+
* 本原语逐 pid 退化单杀,语义 = 「该 run 的进程拓扑」而非引擎组)。
|
|
79
|
+
*
|
|
80
|
+
* fire-and-forget:宿主非进程持有方,无 exit 事件可等(对齐 core reaper 的
|
|
81
|
+
* killProcessTree 形态——升级 timer unref,不阻塞调用方;收尸由 OS 完成)。
|
|
82
|
+
* 对已死 pid 全程 no-op(信号幂等吞掉)。
|
|
83
|
+
*/
|
|
84
|
+
declare function killPidChain(pid: number, opts?: PidChainOptions): void;
|
|
50
85
|
/**
|
|
51
86
|
* 合成 engine_timeout 终态(宿主超时杀链走完后的 AgentOutcome)。
|
|
52
87
|
* 含 stdout 尾部 2000 字 + 恢复指引(§3.3.3 第 6 行);exitCode: null = 被信号杀死
|
|
@@ -71,4 +106,4 @@ declare function abortWithFallback(child: KillableChild, signal: AbortSignal, tr
|
|
|
71
106
|
nativeGraceMs?: number;
|
|
72
107
|
}): Promise<"terminated" | "killed">;
|
|
73
108
|
|
|
74
|
-
export { DEFAULT_KILL_GRACE_MS, DEFAULT_NATIVE_INTERRUPT_GRACE_MS, HOST_TIMEOUT_ABORT_REASON, type KillChainOptions, type KillableChild, abortWithFallback, killChain, synthesizeTimeoutOutcome };
|
|
109
|
+
export { DEFAULT_KILL_GRACE_MS, DEFAULT_NATIVE_INTERRUPT_GRACE_MS, HOST_TIMEOUT_ABORT_REASON, type KillChainOptions, type KillableChild, type PidChainOptions, abortWithFallback, killChain, killPidChain, probePidAlive, safeKill, synthesizeTimeoutOutcome };
|
package/dist/kill-chain.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { a as AgentCallOpts, e as AgentOutcome } from './contract-types-DaULkdpG.js';
|
|
1
|
+
import { a as AgentCallOpts, e as AgentOutcome } from './contract-types-DiWyGRXr.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* 可杀子进程的结构形状(Node ChildProcess 的结构子集)。
|
|
@@ -47,6 +46,42 @@ interface KillChainOptions {
|
|
|
47
46
|
* @returns 'terminated' = SIGTERM 优雅退出(或进程已自行退出);'killed' = 走了 SIGKILL。
|
|
48
47
|
*/
|
|
49
48
|
declare function killChain(child: KillableChild, opts: KillChainOptions): Promise<"terminated" | "killed">;
|
|
49
|
+
/**
|
|
50
|
+
* 发信号兜底包裹:进程恰在退出态检查与 kill 之间自退时,ChildProcess.kill 可能抛
|
|
51
|
+
* (zsub 实测经验)——幂等吞掉并 debug 留痕,不阻断杀链语义(对已退进程信号本就是
|
|
52
|
+
* no-op)。收口自 zcode launcher 的内联实现(对齐点②:单一权威)。
|
|
53
|
+
*/
|
|
54
|
+
declare function safeKill(child: KillableChild, signal: NodeJS.Signals): void;
|
|
55
|
+
/**
|
|
56
|
+
* 单 pid 存活探针(`process.kill(pid, 0)`)。
|
|
57
|
+
*
|
|
58
|
+
* 返回三态:true = 存活;false = 已死(ESRCH);undefined = 不可判定(EPERM =
|
|
59
|
+
* 进程存在但属他人 / 探针异常)——undefined 按存活保守处理(杀链对已死进程发信号
|
|
60
|
+
* 本就是 no-op,误判存活只多一次空信号,误判死亡会漏杀)。
|
|
61
|
+
*/
|
|
62
|
+
declare function probePidAlive(pid: number): boolean | undefined;
|
|
63
|
+
/** killPidChain 参数形状。 */
|
|
64
|
+
interface PidChainOptions {
|
|
65
|
+
/**
|
|
66
|
+
* SIGTERM 优雅窗口(ms)。缺省 DEFAULT_KILL_GRACE_MS。回收场景的调用方通常
|
|
67
|
+
* 已先行优雅停止(cancel 帧 SIGTERM),本窗只是宿主侧升级兜底,量级沿用组杀
|
|
68
|
+
* 收割惯例(5s)。
|
|
69
|
+
*/
|
|
70
|
+
graceMs?: number;
|
|
71
|
+
/** SIGKILL 升级时的 warn 留痕语境(如 `run run-a topology kill`)。不传则静默升级。 */
|
|
72
|
+
note?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* [D9-2 半径收窄原语] run 级 pid 杀链:SIGTERM → graceMs → 仍存活则 SIGKILL,
|
|
76
|
+
* **只打单 pid,绝不组杀**(宿主对引擎孙进程只持镜像 pid、不持 ChildProcess——
|
|
77
|
+
* 引擎以 detached:true 自成进程组,孙进程在其组内而非自任组长,负 pid 组杀不可达;
|
|
78
|
+
* 本原语逐 pid 退化单杀,语义 = 「该 run 的进程拓扑」而非引擎组)。
|
|
79
|
+
*
|
|
80
|
+
* fire-and-forget:宿主非进程持有方,无 exit 事件可等(对齐 core reaper 的
|
|
81
|
+
* killProcessTree 形态——升级 timer unref,不阻塞调用方;收尸由 OS 完成)。
|
|
82
|
+
* 对已死 pid 全程 no-op(信号幂等吞掉)。
|
|
83
|
+
*/
|
|
84
|
+
declare function killPidChain(pid: number, opts?: PidChainOptions): void;
|
|
50
85
|
/**
|
|
51
86
|
* 合成 engine_timeout 终态(宿主超时杀链走完后的 AgentOutcome)。
|
|
52
87
|
* 含 stdout 尾部 2000 字 + 恢复指引(§3.3.3 第 6 行);exitCode: null = 被信号杀死
|
|
@@ -71,4 +106,4 @@ declare function abortWithFallback(child: KillableChild, signal: AbortSignal, tr
|
|
|
71
106
|
nativeGraceMs?: number;
|
|
72
107
|
}): Promise<"terminated" | "killed">;
|
|
73
108
|
|
|
74
|
-
export { DEFAULT_KILL_GRACE_MS, DEFAULT_NATIVE_INTERRUPT_GRACE_MS, HOST_TIMEOUT_ABORT_REASON, type KillChainOptions, type KillableChild, abortWithFallback, killChain, synthesizeTimeoutOutcome };
|
|
109
|
+
export { DEFAULT_KILL_GRACE_MS, DEFAULT_NATIVE_INTERRUPT_GRACE_MS, HOST_TIMEOUT_ABORT_REASON, type KillChainOptions, type KillableChild, type PidChainOptions, abortWithFallback, killChain, killPidChain, probePidAlive, safeKill, synthesizeTimeoutOutcome };
|
package/dist/kill-chain.js
CHANGED
|
@@ -4,20 +4,23 @@ import {
|
|
|
4
4
|
HOST_TIMEOUT_ABORT_REASON,
|
|
5
5
|
abortWithFallback,
|
|
6
6
|
killChain,
|
|
7
|
+
killPidChain,
|
|
8
|
+
probePidAlive,
|
|
9
|
+
safeKill,
|
|
7
10
|
synthesizeTimeoutOutcome
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RCT7L777.js";
|
|
9
12
|
import "./chunk-PYO3YR7W.js";
|
|
10
|
-
import
|
|
11
|
-
STDOUT_TAIL_ECHO_CHARS
|
|
12
|
-
} from "./chunk-WMDMXP2F.js";
|
|
13
|
+
import "./chunk-SFNTX7Q3.js";
|
|
13
14
|
import "./chunk-75QEMUGV.js";
|
|
14
15
|
import "./chunk-JSBRDJBE.js";
|
|
15
16
|
export {
|
|
16
17
|
DEFAULT_KILL_GRACE_MS,
|
|
17
18
|
DEFAULT_NATIVE_INTERRUPT_GRACE_MS,
|
|
18
19
|
HOST_TIMEOUT_ABORT_REASON,
|
|
19
|
-
STDOUT_TAIL_ECHO_CHARS,
|
|
20
20
|
abortWithFallback,
|
|
21
21
|
killChain,
|
|
22
|
+
killPidChain,
|
|
23
|
+
probePidAlive,
|
|
24
|
+
safeKill,
|
|
22
25
|
synthesizeTimeoutOutcome
|
|
23
26
|
};
|
package/dist/node-executor.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
probeNodeExecutor,
|
|
5
5
|
resetEngineNodeProbeCache,
|
|
6
6
|
resolveEngineNodeLaunch
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-3WC36CHI.js";
|
|
8
|
+
import "./chunk-SFNTX7Q3.js";
|
|
9
9
|
import "./chunk-JSBRDJBE.js";
|
|
10
10
|
export {
|
|
11
11
|
ENGINE_NODE_ENV,
|
package/dist/port-contract.d.cts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { a as AgentCallOpts, j as EngineHandleData, E as EngineCapabilities, P as ProbeReport, b as AgentEvent,
|
|
1
|
+
import { a as AgentCallOpts, j as EngineHandleData, E as EngineCapabilities, P as ProbeReport, b as AgentEvent, l as ResumeAnchor, e as AgentOutcome, S as SessionView } from './contract-types-DiWyGRXr.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
|
|
5
|
-
* cwd
|
|
5
|
+
* cwd——SDK 契约把它们从 task 移到 run.params.ctx,进程内接口合回单对象;
|
|
6
6
|
* server.ts 做 ctx→task 还原,与 core RemoteEngine.toSdkTaskSubset 镜像)。
|
|
7
7
|
*/
|
|
8
8
|
type EngineAgentCallOpts = AgentCallOpts & {
|
|
9
9
|
model?: string;
|
|
10
10
|
cwd?: string;
|
|
11
|
-
schemaEnv?: string;
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
13
|
* 引擎进程内的 ctxModel 形态(core ModelInfo 的结构等价镜像——仅 id/provider 被引擎
|
|
@@ -45,7 +44,6 @@ interface RunContext {
|
|
|
45
44
|
onEvent?: (event: AgentEvent) => void;
|
|
46
45
|
ctxModel?: EngineCtxModel;
|
|
47
46
|
stream?: EngineStream;
|
|
48
|
-
schemaEnv?: string;
|
|
49
47
|
engineFallback?: {
|
|
50
48
|
from: string;
|
|
51
49
|
reason: string;
|
|
@@ -62,6 +60,13 @@ interface RunContext {
|
|
|
62
60
|
* [LEGACY] fallback(独立运行/测试形态)。
|
|
63
61
|
*/
|
|
64
62
|
sessionDir?: string;
|
|
63
|
+
/**
|
|
64
|
+
* [D2 扩展加载显式化] 孙进程显式加载的扩展路径集(协议 run.params.ctx.extensionPaths
|
|
65
|
+
* 的进程内还原)——pi 引擎侧逐项拼 `--extension` argv,取代已废弃的 argv 镜像
|
|
66
|
+
* 机制(镜像前提「引擎进程从主 pi 进程 spawn」已不存在,协议化后引擎进程 argv
|
|
67
|
+
* 恒无扩展 flag)。additive 可选:宿主缺省不传。
|
|
68
|
+
*/
|
|
69
|
+
extensionPaths?: string[];
|
|
65
70
|
onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef">) => void;
|
|
66
71
|
/** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
|
|
67
72
|
onChildSpawned?: (child: {
|
package/dist/port-contract.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { a as AgentCallOpts, j as EngineHandleData, E as EngineCapabilities, P as ProbeReport, b as AgentEvent,
|
|
1
|
+
import { a as AgentCallOpts, j as EngineHandleData, E as EngineCapabilities, P as ProbeReport, b as AgentEvent, l as ResumeAnchor, e as AgentOutcome, S as SessionView } from './contract-types-DiWyGRXr.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
|
|
5
|
-
* cwd
|
|
5
|
+
* cwd——SDK 契约把它们从 task 移到 run.params.ctx,进程内接口合回单对象;
|
|
6
6
|
* server.ts 做 ctx→task 还原,与 core RemoteEngine.toSdkTaskSubset 镜像)。
|
|
7
7
|
*/
|
|
8
8
|
type EngineAgentCallOpts = AgentCallOpts & {
|
|
9
9
|
model?: string;
|
|
10
10
|
cwd?: string;
|
|
11
|
-
schemaEnv?: string;
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
13
|
* 引擎进程内的 ctxModel 形态(core ModelInfo 的结构等价镜像——仅 id/provider 被引擎
|
|
@@ -45,7 +44,6 @@ interface RunContext {
|
|
|
45
44
|
onEvent?: (event: AgentEvent) => void;
|
|
46
45
|
ctxModel?: EngineCtxModel;
|
|
47
46
|
stream?: EngineStream;
|
|
48
|
-
schemaEnv?: string;
|
|
49
47
|
engineFallback?: {
|
|
50
48
|
from: string;
|
|
51
49
|
reason: string;
|
|
@@ -62,6 +60,13 @@ interface RunContext {
|
|
|
62
60
|
* [LEGACY] fallback(独立运行/测试形态)。
|
|
63
61
|
*/
|
|
64
62
|
sessionDir?: string;
|
|
63
|
+
/**
|
|
64
|
+
* [D2 扩展加载显式化] 孙进程显式加载的扩展路径集(协议 run.params.ctx.extensionPaths
|
|
65
|
+
* 的进程内还原)——pi 引擎侧逐项拼 `--extension` argv,取代已废弃的 argv 镜像
|
|
66
|
+
* 机制(镜像前提「引擎进程从主 pi 进程 spawn」已不存在,协议化后引擎进程 argv
|
|
67
|
+
* 恒无扩展 flag)。additive 可选:宿主缺省不传。
|
|
68
|
+
*/
|
|
69
|
+
extensionPaths?: string[];
|
|
65
70
|
onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef">) => void;
|
|
66
71
|
/** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
|
|
67
72
|
onChildSpawned?: (child: {
|
package/dist/protocol/index.cjs
CHANGED
|
@@ -25,8 +25,6 @@ __export(protocol_exports, {
|
|
|
25
25
|
CRASH_REBUILD_BACKOFF_MS: () => CRASH_REBUILD_BACKOFF_MS,
|
|
26
26
|
CRASH_REBUILD_MAX_ATTEMPTS: () => CRASH_REBUILD_MAX_ATTEMPTS,
|
|
27
27
|
ENGINE_ERROR_CODE_PREFIX: () => ENGINE_ERROR_CODE_PREFIX,
|
|
28
|
-
ENGINE_EVENT_COALESCE_DEFAULT: () => ENGINE_EVENT_COALESCE_DEFAULT,
|
|
29
|
-
ENGINE_EVENT_COALESCE_ENV: () => ENGINE_EVENT_COALESCE_ENV,
|
|
30
28
|
ENGINE_PROTOCOL_ERROR_CODES: () => ENGINE_PROTOCOL_ERROR_CODES,
|
|
31
29
|
ENGINE_PROTOCOL_SCHEMAS: () => ENGINE_PROTOCOL_SCHEMAS,
|
|
32
30
|
ENGINE_PROTOCOL_VERSION: () => ENGINE_PROTOCOL_VERSION,
|
|
@@ -82,8 +80,6 @@ var CRASH_REBUILD_BACKOFF_MS = [
|
|
|
82
80
|
CRASH_REBUILD_BACKOFF_STEP_3_MS
|
|
83
81
|
];
|
|
84
82
|
var STDERR_TAIL_CHARS = 400;
|
|
85
|
-
var ENGINE_EVENT_COALESCE_ENV = "TAIJI_ENGINE_EVENT_COALESCE";
|
|
86
|
-
var ENGINE_EVENT_COALESCE_DEFAULT = "0";
|
|
87
83
|
|
|
88
84
|
// src/protocol/frames.ts
|
|
89
85
|
function isRecord(v) {
|
|
@@ -229,8 +225,10 @@ var AGENT_EVENT_TYPE_NAMES = [
|
|
|
229
225
|
// noop-safe: 事件无载荷且现行 reducer 即直接 return——丢弃与处理零差异
|
|
230
226
|
"activity",
|
|
231
227
|
// noop-safe: 纯活性信号,双侧 reducer 恒 no-op(协议语义见 AgentEvent 头注),丢弃零差异
|
|
232
|
-
"error"
|
|
228
|
+
"error",
|
|
233
229
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 lastError 诊断留痕,已写状态不回滚
|
|
230
|
+
"armed"
|
|
231
|
+
// noop-safe: 旧宿主无武装等待窗消费点(fail-fast 属宿主新增逻辑),丢弃仅缺武装留痕,schema 强制第一道防线(引擎自查断言)不受损
|
|
234
232
|
];
|
|
235
233
|
|
|
236
234
|
// src/protocol/schema.ts
|
|
@@ -368,8 +366,6 @@ var runSessionParamsSchema = {
|
|
|
368
366
|
CRASH_REBUILD_BACKOFF_MS,
|
|
369
367
|
CRASH_REBUILD_MAX_ATTEMPTS,
|
|
370
368
|
ENGINE_ERROR_CODE_PREFIX,
|
|
371
|
-
ENGINE_EVENT_COALESCE_DEFAULT,
|
|
372
|
-
ENGINE_EVENT_COALESCE_ENV,
|
|
373
369
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
374
370
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
375
371
|
ENGINE_PROTOCOL_VERSION,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { A as AGENT_EVENT_TYPE_NAMES, b as AgentEvent, c as AgentEventTypeName, d as AgentFailureKind, f as AgentOutcomeUsage, g as AgentUsage, h as AgentUsageTotal, i as AssertMutuallyAssignable, I as InternalToolCall, R as ReplayedTurn, T as ToolCall, l as ToolCallEntry, m as ToolCallResult, n as Turn, W as WorktreeHandle } from '../contract-types-DaULkdpG.cjs';
|
|
1
|
+
import { b as AgentEvent, E as EngineCapabilities, M as ModelCatalogEntry, a as AgentCallOpts, l as ResumeAnchor, j as EngineHandleData, P as ProbeReport, e as AgentOutcome, S as SessionView } from '../contract-types-DiWyGRXr.cjs';
|
|
2
|
+
export { A as AGENT_EVENT_TYPE_NAMES, c as AgentEventTypeName, d as AgentFailureKind, f as AgentOutcomeUsage, g as AgentUsage, h as AgentUsageTotal, i as AssertMutuallyAssignable, k as EngineProcessModel, I as InternalToolCall, R as ReplayedTurn, T as ToolCall, m as ToolCallEntry, n as ToolCallResult, o as Turn, W as WorktreeHandle } from '../contract-types-DiWyGRXr.cjs';
|
|
4
3
|
import { UiRequest, UiResponse } from '../ui-types.cjs';
|
|
5
4
|
|
|
6
5
|
/** 协议版本(引擎包 manifest `taiji.subagentEngine.protocol` 与 initialize 应答同值)。 */
|
|
@@ -26,9 +25,6 @@ declare const CRASH_REBUILD_MAX_ATTEMPTS = 3;
|
|
|
26
25
|
declare const CRASH_REBUILD_BACKOFF_MS: readonly [1000, 2000, 4000];
|
|
27
26
|
/** stderr 内存环形缓冲保留的尾部字符数(engine_crashed 帧携带崩溃现场)。 */
|
|
28
27
|
declare const STDERR_TAIL_CHARS = 400;
|
|
29
|
-
/** 事件合并开关 env 名(设计级默认关闭 = 值 "0";A1 要求事件逐字段等价,合并不可开)。 */
|
|
30
|
-
declare const ENGINE_EVENT_COALESCE_ENV = "TAIJI_ENGINE_EVENT_COALESCE";
|
|
31
|
-
declare const ENGINE_EVENT_COALESCE_DEFAULT = "0";
|
|
32
28
|
/**
|
|
33
29
|
* 反向请求超时二分(帧④注释,R9-2):
|
|
34
30
|
* - 数据面类(host/log / host/streamDelta / host/handleReady /
|
|
@@ -38,6 +34,69 @@ declare const ENGINE_EVENT_COALESCE_DEFAULT = "0";
|
|
|
38
34
|
*/
|
|
39
35
|
type ReverseRequestTimeoutClass = "data-plane" | "interaction";
|
|
40
36
|
|
|
37
|
+
/** 协议错误对象(error 帧载荷与反向请求错误应答共用形态)。 */
|
|
38
|
+
interface ProtocolError {
|
|
39
|
+
/** 错误码(error-codes.ts 词表 + 其余 engine_* 引擎自报透传)。 */
|
|
40
|
+
code: string;
|
|
41
|
+
/** 人类可读详情。 */
|
|
42
|
+
message: string;
|
|
43
|
+
/** 恢复指引:指向具体下一步(命令 / 配置路径 / 升级动作),非安慰性文案。 */
|
|
44
|
+
recovery: string;
|
|
45
|
+
/** 结构化附参(如 engine_protocol_mismatch 的双方版本)。 */
|
|
46
|
+
data?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
interface RequestFrame {
|
|
49
|
+
id: number;
|
|
50
|
+
method: string;
|
|
51
|
+
params: unknown;
|
|
52
|
+
}
|
|
53
|
+
interface SuccessResponseFrame {
|
|
54
|
+
id: number | string;
|
|
55
|
+
result: unknown;
|
|
56
|
+
}
|
|
57
|
+
interface ErrorResponseFrame {
|
|
58
|
+
id: number | string;
|
|
59
|
+
error: ProtocolError;
|
|
60
|
+
}
|
|
61
|
+
type ResponseFrame = SuccessResponseFrame | ErrorResponseFrame;
|
|
62
|
+
/** event 通知载荷:runId 关联在途 run;seq 单调递增(基线①结构等价断言对象)。 */
|
|
63
|
+
interface EventNotificationParams {
|
|
64
|
+
runId: string;
|
|
65
|
+
seq: number;
|
|
66
|
+
event: AgentEvent;
|
|
67
|
+
}
|
|
68
|
+
interface NotificationFrame {
|
|
69
|
+
method: "event";
|
|
70
|
+
params: EventNotificationParams;
|
|
71
|
+
}
|
|
72
|
+
interface ReverseRequestFrame {
|
|
73
|
+
id: string;
|
|
74
|
+
method: string;
|
|
75
|
+
params: unknown;
|
|
76
|
+
}
|
|
77
|
+
/** 反向请求的应答(core → 引擎,沿 ResponseFrame 通道回传;id = 反向请求 id 原样)。 */
|
|
78
|
+
type ReverseResponseResult =
|
|
79
|
+
/** 数据面类:处理确认。 */
|
|
80
|
+
{
|
|
81
|
+
ok: true;
|
|
82
|
+
}
|
|
83
|
+
/** 人机交互类(askUser)两阶段第一阶段:已受理,结果异步到达(R9-2)。 */
|
|
84
|
+
| {
|
|
85
|
+
ack: true;
|
|
86
|
+
}
|
|
87
|
+
/** 未实现或宿主未知的通道(宽容语义③:由 askUser 语境泛化到全通道——宿主对未知 host/* 通道回 unsupported,引擎自行降级)。 */
|
|
88
|
+
| {
|
|
89
|
+
unsupported: true;
|
|
90
|
+
};
|
|
91
|
+
/** ① 请求:有数字 id + method + params,且无 result/error(与②应答区分)。 */
|
|
92
|
+
declare function isRequestFrame(frame: unknown): frame is RequestFrame;
|
|
93
|
+
/** ② 应答:有 id(number|string)且 result/error 二选一。 */
|
|
94
|
+
declare function isResponseFrame(frame: unknown): frame is ResponseFrame;
|
|
95
|
+
/** ③ 通知:无 id,method === "event",params 含 runId/seq/event。 */
|
|
96
|
+
declare function isNotificationFrame(frame: unknown): frame is NotificationFrame;
|
|
97
|
+
/** ④ 反向请求:有字符串 id + host/* method + params(与①的区别 = id 形态与 method 前缀)。 */
|
|
98
|
+
declare function isReverseRequestFrame(frame: unknown): frame is ReverseRequestFrame;
|
|
99
|
+
|
|
41
100
|
/**
|
|
42
101
|
* 正向方法名联合(恰好 9 个;PROTOCOL_METHODS 常量数组与之同源互证)。
|
|
43
102
|
* [H1] `interact` 成员已随 chat-run 统一退役(docs/architecture/subagent-chat-run-unification.md
|
|
@@ -55,8 +114,6 @@ interface RunContextParams {
|
|
|
55
114
|
cwd?: string;
|
|
56
115
|
/** 请求模型 ref(未传 = 引擎缺省模型)。 */
|
|
57
116
|
model?: string;
|
|
58
|
-
/** 结构化输出 schema 的 env 注入形态(schemaEnv 降级通道)。 */
|
|
59
|
-
schemaEnv?: string;
|
|
60
117
|
/** 上下文模型 ref(与 run 模型分离的 ctx 模型)。 */
|
|
61
118
|
ctxModel?: string;
|
|
62
119
|
/** fallback 留痕(引擎回填 outcome.engineFallback 的种子)。 */
|
|
@@ -80,6 +137,14 @@ interface RunContextParams {
|
|
|
80
137
|
* 未知字段,undefined 不上 wire。
|
|
81
138
|
*/
|
|
82
139
|
sessionDir?: string;
|
|
140
|
+
/**
|
|
141
|
+
* [D2 扩展加载显式化] 孙进程显式加载的扩展路径集(pi 引擎侧逐项拼
|
|
142
|
+
* `--extension` argv)。per-host 常量而非 per-run 变量,故落 ctx。宿主侧来源
|
|
143
|
+
* 双形态:taiji 宿主 = extension-service 下发的白名单收窄集(经 pi-host 注入);
|
|
144
|
+
* 独立 pi = subagent-workflow 自身 optional peerDep 解析回退。additive 可选:
|
|
145
|
+
* 旧引擎忽略未知字段,undefined 不上 wire。
|
|
146
|
+
*/
|
|
147
|
+
extensionPaths?: string[];
|
|
83
148
|
}
|
|
84
149
|
/**
|
|
85
150
|
* [H1] run 的 resume 会话形态参数(设计 docs/architecture/subagent-chat-run-unification.md
|
|
@@ -150,7 +215,10 @@ interface CancelResult {
|
|
|
150
215
|
}
|
|
151
216
|
interface ReadParams {
|
|
152
217
|
handle: EngineHandleData;
|
|
153
|
-
/**
|
|
218
|
+
/** 数据根(core 每次 read 都发送——remote-engine 构造注入的数据目录)。两引擎
|
|
219
|
+
* server 现行均不消费该字段:定位走 handle.data(journalPath 等)或引擎自身
|
|
220
|
+
* 数据目录。保留为协议帧字段(历史:存量池时代引擎自算池/journal 相对 dbPath
|
|
221
|
+
* 的定位需要它)。 */
|
|
154
222
|
dataDir: string;
|
|
155
223
|
}
|
|
156
224
|
interface ListModelsParams {
|
|
@@ -277,6 +345,58 @@ interface HostChildStateChangedParams {
|
|
|
277
345
|
signal?: string;
|
|
278
346
|
}
|
|
279
347
|
|
|
348
|
+
/** 协议核心错误码(引擎 error 帧 + core 同步拦截共用的固定词表)。 */
|
|
349
|
+
declare const ENGINE_PROTOCOL_ERROR_CODES: readonly ["engine_not_found", "engine_protocol_mismatch", "engine_capability_unsupported", "engine_capability_mismatch", "engine_model_unknown", "engine_model_mismatch", "engine_handshake_timeout", "engine_crashed", "engine_probe_failed"];
|
|
350
|
+
type EngineProtocolErrorCode = (typeof ENGINE_PROTOCOL_ERROR_CODES)[number];
|
|
351
|
+
/** unknown → 协议错误码收窄(外部输入携带错误码时的运行时 guard;其余 engine_* 走透传)。 */
|
|
352
|
+
declare function isEngineProtocolErrorCode(value: unknown): value is EngineProtocolErrorCode;
|
|
353
|
+
/** 其余引擎自报错误码的前缀契约(透传面;core 不解释文案)。 */
|
|
354
|
+
declare const ENGINE_ERROR_CODE_PREFIX = "engine_";
|
|
355
|
+
declare function isEngineErrorPassthroughCode(value: string): boolean;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* 结构化引擎错误(message 恒为 `<code>: <detail>` 前缀格式——AgentOutcome.error 与
|
|
359
|
+
* 协议 error 帧共用的错误码前缀约定);recovery 指向恢复动作。
|
|
360
|
+
* toStructured() 产出即协议 ProtocolError 形态(error 帧载荷直用)。
|
|
361
|
+
*/
|
|
362
|
+
declare class EngineSdkError extends Error {
|
|
363
|
+
readonly code: string;
|
|
364
|
+
readonly recovery: string;
|
|
365
|
+
readonly data?: Record<string, unknown>;
|
|
366
|
+
constructor(code: string, detail: string, recovery: string, data?: Record<string, unknown>);
|
|
367
|
+
/** 协议 error 帧载荷投影。 */
|
|
368
|
+
toStructured(): ProtocolError;
|
|
369
|
+
}
|
|
370
|
+
declare function engineProtocolMismatchError(engineVersion: number): EngineSdkError;
|
|
371
|
+
/**
|
|
372
|
+
* 引擎 conversation 位拒绝的具名错误([modeless 波2] 语义:无 resume 续聊通道的
|
|
373
|
+
* 引擎,message 续聊资格被拒——manifest conversation 能力轴消费;[modeless 波5
|
|
374
|
+
* 收尾] core capability-gate 的显式参数分支随派发参数删除退役,本构造器消费方 =
|
|
375
|
+
* 引擎侧 resume gate(assertChatConversationSupported)与 message 资格门)。
|
|
376
|
+
* 文案契约:错误码 engine_capability_unsupported + 「换引擎续聊 / 修 manifest /
|
|
377
|
+
* 升级引擎包」恢复指引,两侧一致防漂移。
|
|
378
|
+
*/
|
|
379
|
+
declare function engineConversationUnsupportedError(engineId: string): EngineSdkError;
|
|
380
|
+
/**
|
|
381
|
+
* resume 会话形态(run.params.resume——唯一会话形态键)派发前的同步 gate:
|
|
382
|
+
* manifest conversation 位 unsupported 即抛 engineConversationUnsupportedError
|
|
383
|
+
* ——进程/record 创建前同步拒(A6 方向防御:manifest/实装漂移时引擎侧自拒,
|
|
384
|
+
* 与 core capability-gate 同一能力位,防两侧判据漂移)。[modeless 波2] 协议
|
|
385
|
+
* task 的 conversation 键已删,本 gate 只对 resume 形态键生效。
|
|
386
|
+
*/
|
|
387
|
+
declare function assertChatConversationSupported(engineId: string, capabilities: Pick<EngineCapabilities, "conversation">): void;
|
|
388
|
+
/** stdout 尾部回显上限(engine_timeout / engine_run_failed 的错误规格载体系数)。 */
|
|
389
|
+
declare const STDOUT_TAIL_ECHO_CHARS = 2000;
|
|
390
|
+
/** engine_timeout 的恢复指引(kill-chain 超时杀链收尾文案)。 */
|
|
391
|
+
declare const ENGINE_TIMEOUT_RECOVERY: string;
|
|
392
|
+
/**
|
|
393
|
+
* engine_timeout 的 outcome.error 文案:含 stdout 尾部 2000 字 + 恢复指引
|
|
394
|
+
* (kill-chain synthesizeTimeoutOutcome 消费;与 core errors.ts engineTimeoutDetail 逐字等价)。
|
|
395
|
+
*/
|
|
396
|
+
declare function engineTimeoutDetail(stdoutTail: string): string;
|
|
397
|
+
/** schema_emulation_failed 的终报文案(宿主编排层「重试一次仍失败」后消费)。 */
|
|
398
|
+
declare function schemaEmulationFailedDetail(error: string, tail: string): string;
|
|
399
|
+
|
|
280
400
|
/** 协议错误对象 schema。 */
|
|
281
401
|
declare const protocolErrorSchema: {
|
|
282
402
|
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
@@ -395,7 +515,7 @@ declare const notificationFrameSchema: {
|
|
|
395
515
|
readonly properties: {
|
|
396
516
|
readonly type: {
|
|
397
517
|
readonly type: "string";
|
|
398
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error"];
|
|
518
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
399
519
|
};
|
|
400
520
|
};
|
|
401
521
|
};
|
|
@@ -515,7 +635,7 @@ declare const ENGINE_PROTOCOL_SCHEMAS: {
|
|
|
515
635
|
readonly properties: {
|
|
516
636
|
readonly type: {
|
|
517
637
|
readonly type: "string";
|
|
518
|
-
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error"];
|
|
638
|
+
readonly enum: readonly ["tool_start", "tool_end", "text_delta", "thinking_delta", "turn_end", "message_end", "compaction", "activity", "error", "armed"];
|
|
519
639
|
};
|
|
520
640
|
};
|
|
521
641
|
};
|
|
@@ -606,4 +726,4 @@ declare const runSessionParamsSchema: {
|
|
|
606
726
|
};
|
|
607
727
|
};
|
|
608
728
|
|
|
609
|
-
export { AgentCallOpts, AgentOutcome, CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, type CancelParams, type CancelResult, type DisposeParams, type DisposeResult,
|
|
729
|
+
export { AgentCallOpts, AgentEvent, AgentOutcome, CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, type CancelParams, type CancelResult, type DisposeParams, type DisposeResult, ENGINE_ERROR_CODE_PREFIX, ENGINE_PROTOCOL_ERROR_CODES, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, ENGINE_TIMEOUT_RECOVERY, EngineCapabilities, EngineHandleData, type EngineProtocolErrorCode, EngineSdkError, type ErrorResponseFrame, type EventNotificationParams, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, type HostAskUserParams, type HostAskUserResult, type HostChildSpawnedParams, type HostChildStateChangedParams, type HostHandleReadyParams, type HostLogParams, type HostStreamDeltaParams, type InitializeParams, type InitializeResult, type ListModelsParams, type ListModelsResult, ModelCatalogEntry, type NotificationFrame, PROTOCOL_METHODS, type PingParams, type PingResult, type ProbeParams, ProbeReport, type ProtocolError, type ProtocolMethod, type ProtocolParamsMap, type ProtocolResultMap, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, type ReadParams, type RequestFrame, type ResponseFrame, ResumeAnchor, type ReverseChannel, type ReverseRequestFrame, type ReverseRequestTimeoutClass, type ReverseResponseResult, type RunContextParams, type RunParams, type RunResult, type RunResumeParams, STDERR_TAIL_CHARS, STDOUT_TAIL_ECHO_CHARS, SUPPORTED_PROTOCOL_RANGE, SessionView, type SuccessResponseFrame, type ValidateModelParams, type ValidateModelResult, assertChatConversationSupported, engineConversationUnsupportedError, engineProtocolMismatchError, engineTimeoutDetail, errorResponseFrameSchema, isEngineErrorPassthroughCode, isEngineProtocolErrorCode, isNotificationFrame, isProtocolVersionCompatible, isRequestFrame, isResponseFrame, isReverseRequestFrame, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, schemaEmulationFailedDetail, successResponseFrameSchema };
|