@zhushanwen/subagent-engine-sdk 0.2.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.cjs +88 -0
- package/dist/best-effort.d.cts +14 -0
- package/dist/best-effort.d.ts +14 -0
- package/dist/best-effort.js +8 -0
- package/dist/chunk-2DIMPZCQ.js +0 -0
- package/dist/chunk-365AUV6N.js +67 -0
- package/dist/chunk-3K2P2CM2.js +127 -0
- package/dist/chunk-75QEMUGV.js +58 -0
- package/dist/chunk-7I4XGL5J.js +95 -0
- package/dist/chunk-A75XDJIC.js +227 -0
- package/dist/chunk-DSQ7JQKM.js +39 -0
- package/dist/chunk-EJMF63R5.js +19 -0
- package/dist/chunk-GT6YLLN4.js +46 -0
- package/dist/chunk-HYES77BR.js +109 -0
- package/dist/chunk-JSBRDJBE.js +30 -0
- package/dist/chunk-LEOBWKRM.js +128 -0
- package/dist/chunk-N3RL6OVM.js +38 -0
- package/dist/chunk-OPMY4G4M.js +27 -0
- package/dist/chunk-PPEPBVCC.js +120 -0
- package/dist/chunk-PYO3YR7W.js +16 -0
- package/dist/chunk-RDH3ZOV6.js +46 -0
- package/dist/chunk-RULLX6C6.js +11 -0
- package/dist/chunk-X24SFZYW.js +6646 -0
- package/dist/chunk-YFSN3D5N.js +216 -0
- package/dist/chunk-ZOFFJNJD.js +136 -0
- package/dist/chunk-ZXEAW25V.js +132 -0
- package/dist/cli-entry.cjs +119 -0
- package/dist/cli-entry.d.cts +24 -0
- package/dist/cli-entry.d.ts +24 -0
- package/dist/cli-entry.js +8 -0
- package/dist/contract-types-sSlgppBC.d.cts +352 -0
- package/dist/contract-types-sSlgppBC.d.ts +352 -0
- package/dist/data-dir.cjs +117 -0
- package/dist/data-dir.d.cts +20 -0
- package/dist/data-dir.d.ts +20 -0
- package/dist/data-dir.js +12 -0
- package/dist/env.cjs +205 -0
- package/dist/env.d.cts +73 -0
- package/dist/env.d.ts +73 -0
- package/dist/env.js +16 -0
- package/dist/error-codes-DHco5-i_.d.cts +118 -0
- package/dist/error-codes-Dhss2Kmk.d.ts +118 -0
- package/dist/error-message.cjs +40 -0
- package/dist/error-message.d.cts +3 -0
- package/dist/error-message.d.ts +3 -0
- package/dist/error-message.js +7 -0
- package/dist/index.cjs +8375 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +268 -0
- package/dist/journal-io.cjs +70 -0
- package/dist/journal-io.d.cts +12 -0
- package/dist/journal-io.d.ts +12 -0
- package/dist/journal-io.js +7 -0
- package/dist/journal-replay.cjs +256 -0
- package/dist/journal-replay.d.cts +45 -0
- package/dist/journal-replay.d.ts +45 -0
- package/dist/journal-replay.js +17 -0
- package/dist/kill-chain.cjs +221 -0
- package/dist/kill-chain.d.cts +74 -0
- package/dist/kill-chain.d.ts +74 -0
- package/dist/kill-chain.js +23 -0
- package/dist/logger.cjs +84 -0
- package/dist/logger.d.cts +24 -0
- package/dist/logger.d.ts +24 -0
- package/dist/logger.js +11 -0
- package/dist/logs/stderr-rotation.cjs +151 -0
- package/dist/logs/stderr-rotation.d.cts +37 -0
- package/dist/logs/stderr-rotation.d.ts +37 -0
- package/dist/logs/stderr-rotation.js +23 -0
- package/dist/nesting-guard.cjs +95 -0
- package/dist/nesting-guard.d.cts +65 -0
- package/dist/nesting-guard.d.ts +65 -0
- package/dist/nesting-guard.js +15 -0
- package/dist/node-executor.cjs +180 -0
- package/dist/node-executor.d.cts +63 -0
- package/dist/node-executor.d.ts +63 -0
- package/dist/node-executor.js +16 -0
- package/dist/paths.cjs +55 -0
- package/dist/paths.d.cts +8 -0
- package/dist/paths.d.ts +8 -0
- package/dist/paths.js +15 -0
- package/dist/port-contract.cjs +35 -0
- package/dist/port-contract.d.cts +88 -0
- package/dist/port-contract.d.ts +88 -0
- package/dist/port-contract.js +7 -0
- package/dist/protocol/index.cjs +400 -0
- package/dist/protocol/index.d.cts +685 -0
- package/dist/protocol/index.d.ts +685 -0
- package/dist/protocol/index.js +89 -0
- package/dist/relay-env.cjs +71 -0
- package/dist/relay-env.d.cts +37 -0
- package/dist/relay-env.d.ts +37 -0
- package/dist/relay-env.js +23 -0
- package/dist/schema-emulation.cjs +6680 -0
- package/dist/schema-emulation.d.cts +39 -0
- package/dist/schema-emulation.d.ts +39 -0
- package/dist/schema-emulation.js +11 -0
- package/dist/spawn.cjs +200 -0
- package/dist/spawn.d.cts +80 -0
- package/dist/spawn.d.ts +80 -0
- package/dist/spawn.js +16 -0
- package/dist/ui-channels.cjs +120 -0
- package/dist/ui-channels.d.cts +60 -0
- package/dist/ui-channels.d.ts +60 -0
- package/dist/ui-channels.js +9 -0
- package/dist/ui-types.cjs +18 -0
- package/dist/ui-types.d.cts +62 -0
- package/dist/ui-types.d.ts +62 -0
- package/dist/ui-types.js +1 -0
- package/package.json +58 -0
- package/src/best-effort.ts +37 -0
- package/src/cli-entry.ts +77 -0
- package/src/data-dir.ts +88 -0
- package/src/env.ts +265 -0
- package/src/error-message.ts +22 -0
- package/src/index.ts +63 -0
- package/src/journal-io.ts +82 -0
- package/src/journal-replay.ts +432 -0
- package/src/kill-chain.ts +265 -0
- package/src/logger.ts +105 -0
- package/src/logs/stderr-rotation.ts +166 -0
- package/src/nesting-guard.ts +140 -0
- package/src/node-executor.ts +272 -0
- package/src/paths.ts +48 -0
- package/src/port-contract.ts +117 -0
- package/src/protocol/contract-types.ts +378 -0
- package/src/protocol/engine-protocol.ts +81 -0
- package/src/protocol/error-codes.ts +179 -0
- package/src/protocol/frames.ts +145 -0
- package/src/protocol/index.ts +12 -0
- package/src/protocol/methods.ts +229 -0
- package/src/protocol/reverse-channels.ts +274 -0
- package/src/protocol/schema.ts +154 -0
- package/src/relay-env.ts +60 -0
- package/src/schema-emulation.ts +192 -0
- package/src/spawn.ts +246 -0
- package/src/ui-channels.ts +219 -0
- package/src/ui-types.ts +84 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** L0 注入的引擎执行器路径 env(与 relay 的 XYZ_SUBAGENT_RELAY_NODE 不复用)。 */
|
|
2
|
+
declare const ENGINE_NODE_ENV = "XYZ_AGENT_ENGINE_NODE";
|
|
3
|
+
/**
|
|
4
|
+
* 探针:验证执行器能以纯 node 语义执行 JS(先例 = runtime relay-env.ts:47-90)。
|
|
5
|
+
*
|
|
6
|
+
* 为什么需要:打包态 pi 宿主的候选执行器可能是 Electron 二进制——直接当 node 用会
|
|
7
|
+
* 拉起 GUI,必须同 env 注入 ELECTRON_RUN_AS_NODE=1 才是纯 node 模式;探针被证伪则
|
|
8
|
+
* 按矩阵① 报 engine_not_found(带可操作指引),不静默回落 PATH 探测。
|
|
9
|
+
*/
|
|
10
|
+
declare function probeNodeExecutor(execPath: string, isElectron: boolean): Promise<boolean>;
|
|
11
|
+
/** 测试钩子:清探针缓存(生产无调用方;与 relay-env resetRelayNodeProbeCache 同款)。 */
|
|
12
|
+
declare function resetEngineNodeProbeCache(): void;
|
|
13
|
+
/** 宿主形态(矩阵行;EngineClient 的 hostKind 自由字符串经 hostKindOf 归一)。 */
|
|
14
|
+
type EngineNodeHostKind = "pi-extension" | "runtime-sidecar" | "standalone";
|
|
15
|
+
/** resolveEngineNodeLaunch 的可注入项(测试隔离用;生产全部走缺省推导)。 */
|
|
16
|
+
interface EngineNodeLaunchOptions {
|
|
17
|
+
/** 引擎 CLI 入口绝对路径(descriptor command / staged bin 解析结果)。 */
|
|
18
|
+
entryPath: string;
|
|
19
|
+
/** 入口附加参数(descriptor args;缺省 [])。 */
|
|
20
|
+
args?: readonly string[];
|
|
21
|
+
/** 宿主形态。 */
|
|
22
|
+
hostKind: EngineNodeHostKind;
|
|
23
|
+
/** 读取 XYZ_AGENT_ENGINE_NODE 的 env 快照(矩阵① 的注入通道)。 */
|
|
24
|
+
env?: Record<string, string | undefined>;
|
|
25
|
+
/** 宿主 process.execPath(缺省 process.execPath)。 */
|
|
26
|
+
execPath?: string;
|
|
27
|
+
/** 宿主自身是否 Electron(缺省 process.versions.electron !== undefined)。 */
|
|
28
|
+
isElectronHost?: boolean;
|
|
29
|
+
/** 平台覆盖(缺省 process.platform)。 */
|
|
30
|
+
platform?: NodeJS.Platform;
|
|
31
|
+
}
|
|
32
|
+
/** 解析结果:spawn(command, args) 形态 + buildEngineChildEnv 的 electronRunAsNode 输入。 */
|
|
33
|
+
interface EngineNodeLaunch {
|
|
34
|
+
command: string;
|
|
35
|
+
args: string[];
|
|
36
|
+
/** 执行器为 Electron 二进制 → true(L0 注入 ELECTRON_RUN_AS_NODE=1)。 */
|
|
37
|
+
electronRunAsNode: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 宿主 × 平台二维矩阵解析(W9 §2.9)。返回 spawn argv;不直接 spawn——调用方
|
|
41
|
+
* (EngineClient / runtime)持有各自的平台参数(detached / 进程组收割语义)。
|
|
42
|
+
*
|
|
43
|
+
* 判定序(与规格逐行对应):
|
|
44
|
+
* Windows + entry .cmd → cmd.exe /c 显式形态(禁 shell:true 的注入面);
|
|
45
|
+
* pi-extension → 注入执行器(env XYZ_AGENT_ENGINE_NODE),缺失/探针失败 =
|
|
46
|
+
* engine_not_found + 指引;
|
|
47
|
+
* runtime-sidecar → process.execPath(Electron 时 electronRunAsNode,探针先行);
|
|
48
|
+
* standalone → PATH node(探针失败 = engine_not_found + 安装指引);
|
|
49
|
+
* 其余(dev 形态、非 Windows 非 .cmd、无矩阵命中的兜底)→ 直接 spawn 入口本体
|
|
50
|
+
* (shebang `#!/usr/bin/env node` 走 PATH node——引擎 bin 均带 shebang,dev/独立
|
|
51
|
+
* 安装形态与现状一致)。
|
|
52
|
+
*/
|
|
53
|
+
declare function resolveEngineNodeLaunch(opts: EngineNodeLaunchOptions): Promise<EngineNodeLaunch>;
|
|
54
|
+
/**
|
|
55
|
+
* EngineClient 的自由字符串 hostKind('pi' / 'runtime' / …)→ 矩阵行归一:
|
|
56
|
+
* 'runtime*' → runtime-sidecar(②:sidecar execPath 权威);
|
|
57
|
+
* env 已注入 XYZ_AGENT_ENGINE_NODE(打包态 runtime 注入主 pi 进程的通道)→
|
|
58
|
+
* pi-extension(①:必须用注入执行器——pi 宿主自身 execPath 是 pi binary);
|
|
59
|
+
* 其余 → standalone(③:PATH node)。
|
|
60
|
+
*/
|
|
61
|
+
declare function hostKindOf(hostKind: string, env?: Record<string, string | undefined>): EngineNodeHostKind;
|
|
62
|
+
|
|
63
|
+
export { ENGINE_NODE_ENV, type EngineNodeHostKind, type EngineNodeLaunch, type EngineNodeLaunchOptions, hostKindOf, probeNodeExecutor, resetEngineNodeProbeCache, resolveEngineNodeLaunch };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** L0 注入的引擎执行器路径 env(与 relay 的 XYZ_SUBAGENT_RELAY_NODE 不复用)。 */
|
|
2
|
+
declare const ENGINE_NODE_ENV = "XYZ_AGENT_ENGINE_NODE";
|
|
3
|
+
/**
|
|
4
|
+
* 探针:验证执行器能以纯 node 语义执行 JS(先例 = runtime relay-env.ts:47-90)。
|
|
5
|
+
*
|
|
6
|
+
* 为什么需要:打包态 pi 宿主的候选执行器可能是 Electron 二进制——直接当 node 用会
|
|
7
|
+
* 拉起 GUI,必须同 env 注入 ELECTRON_RUN_AS_NODE=1 才是纯 node 模式;探针被证伪则
|
|
8
|
+
* 按矩阵① 报 engine_not_found(带可操作指引),不静默回落 PATH 探测。
|
|
9
|
+
*/
|
|
10
|
+
declare function probeNodeExecutor(execPath: string, isElectron: boolean): Promise<boolean>;
|
|
11
|
+
/** 测试钩子:清探针缓存(生产无调用方;与 relay-env resetRelayNodeProbeCache 同款)。 */
|
|
12
|
+
declare function resetEngineNodeProbeCache(): void;
|
|
13
|
+
/** 宿主形态(矩阵行;EngineClient 的 hostKind 自由字符串经 hostKindOf 归一)。 */
|
|
14
|
+
type EngineNodeHostKind = "pi-extension" | "runtime-sidecar" | "standalone";
|
|
15
|
+
/** resolveEngineNodeLaunch 的可注入项(测试隔离用;生产全部走缺省推导)。 */
|
|
16
|
+
interface EngineNodeLaunchOptions {
|
|
17
|
+
/** 引擎 CLI 入口绝对路径(descriptor command / staged bin 解析结果)。 */
|
|
18
|
+
entryPath: string;
|
|
19
|
+
/** 入口附加参数(descriptor args;缺省 [])。 */
|
|
20
|
+
args?: readonly string[];
|
|
21
|
+
/** 宿主形态。 */
|
|
22
|
+
hostKind: EngineNodeHostKind;
|
|
23
|
+
/** 读取 XYZ_AGENT_ENGINE_NODE 的 env 快照(矩阵① 的注入通道)。 */
|
|
24
|
+
env?: Record<string, string | undefined>;
|
|
25
|
+
/** 宿主 process.execPath(缺省 process.execPath)。 */
|
|
26
|
+
execPath?: string;
|
|
27
|
+
/** 宿主自身是否 Electron(缺省 process.versions.electron !== undefined)。 */
|
|
28
|
+
isElectronHost?: boolean;
|
|
29
|
+
/** 平台覆盖(缺省 process.platform)。 */
|
|
30
|
+
platform?: NodeJS.Platform;
|
|
31
|
+
}
|
|
32
|
+
/** 解析结果:spawn(command, args) 形态 + buildEngineChildEnv 的 electronRunAsNode 输入。 */
|
|
33
|
+
interface EngineNodeLaunch {
|
|
34
|
+
command: string;
|
|
35
|
+
args: string[];
|
|
36
|
+
/** 执行器为 Electron 二进制 → true(L0 注入 ELECTRON_RUN_AS_NODE=1)。 */
|
|
37
|
+
electronRunAsNode: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 宿主 × 平台二维矩阵解析(W9 §2.9)。返回 spawn argv;不直接 spawn——调用方
|
|
41
|
+
* (EngineClient / runtime)持有各自的平台参数(detached / 进程组收割语义)。
|
|
42
|
+
*
|
|
43
|
+
* 判定序(与规格逐行对应):
|
|
44
|
+
* Windows + entry .cmd → cmd.exe /c 显式形态(禁 shell:true 的注入面);
|
|
45
|
+
* pi-extension → 注入执行器(env XYZ_AGENT_ENGINE_NODE),缺失/探针失败 =
|
|
46
|
+
* engine_not_found + 指引;
|
|
47
|
+
* runtime-sidecar → process.execPath(Electron 时 electronRunAsNode,探针先行);
|
|
48
|
+
* standalone → PATH node(探针失败 = engine_not_found + 安装指引);
|
|
49
|
+
* 其余(dev 形态、非 Windows 非 .cmd、无矩阵命中的兜底)→ 直接 spawn 入口本体
|
|
50
|
+
* (shebang `#!/usr/bin/env node` 走 PATH node——引擎 bin 均带 shebang,dev/独立
|
|
51
|
+
* 安装形态与现状一致)。
|
|
52
|
+
*/
|
|
53
|
+
declare function resolveEngineNodeLaunch(opts: EngineNodeLaunchOptions): Promise<EngineNodeLaunch>;
|
|
54
|
+
/**
|
|
55
|
+
* EngineClient 的自由字符串 hostKind('pi' / 'runtime' / …)→ 矩阵行归一:
|
|
56
|
+
* 'runtime*' → runtime-sidecar(②:sidecar execPath 权威);
|
|
57
|
+
* env 已注入 XYZ_AGENT_ENGINE_NODE(打包态 runtime 注入主 pi 进程的通道)→
|
|
58
|
+
* pi-extension(①:必须用注入执行器——pi 宿主自身 execPath 是 pi binary);
|
|
59
|
+
* 其余 → standalone(③:PATH node)。
|
|
60
|
+
*/
|
|
61
|
+
declare function hostKindOf(hostKind: string, env?: Record<string, string | undefined>): EngineNodeHostKind;
|
|
62
|
+
|
|
63
|
+
export { ENGINE_NODE_ENV, type EngineNodeHostKind, type EngineNodeLaunch, type EngineNodeLaunchOptions, hostKindOf, probeNodeExecutor, resetEngineNodeProbeCache, resolveEngineNodeLaunch };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ENGINE_NODE_ENV,
|
|
3
|
+
hostKindOf,
|
|
4
|
+
probeNodeExecutor,
|
|
5
|
+
resetEngineNodeProbeCache,
|
|
6
|
+
resolveEngineNodeLaunch
|
|
7
|
+
} from "./chunk-ZOFFJNJD.js";
|
|
8
|
+
import "./chunk-PPEPBVCC.js";
|
|
9
|
+
import "./chunk-JSBRDJBE.js";
|
|
10
|
+
export {
|
|
11
|
+
ENGINE_NODE_ENV,
|
|
12
|
+
hostKindOf,
|
|
13
|
+
probeNodeExecutor,
|
|
14
|
+
resetEngineNodeProbeCache,
|
|
15
|
+
resolveEngineNodeLaunch
|
|
16
|
+
};
|
package/dist/paths.cjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/paths.ts
|
|
21
|
+
var paths_exports = {};
|
|
22
|
+
__export(paths_exports, {
|
|
23
|
+
resolveEngineDir: () => resolveEngineDir,
|
|
24
|
+
resolveEnginesRoot: () => resolveEnginesRoot,
|
|
25
|
+
resolveJournalPath: () => resolveJournalPath,
|
|
26
|
+
resolvePoolDir: () => resolvePoolDir,
|
|
27
|
+
sanitizeSeg: () => sanitizeSeg
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(paths_exports);
|
|
30
|
+
var import_node_path = require("path");
|
|
31
|
+
var MAX_SEG_CHARS = 80;
|
|
32
|
+
function sanitizeSeg(input) {
|
|
33
|
+
const s = input.replace(/[^A-Za-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
34
|
+
return s.length > 0 ? s.slice(0, MAX_SEG_CHARS) : "default";
|
|
35
|
+
}
|
|
36
|
+
function resolveEnginesRoot(dataDir) {
|
|
37
|
+
return (0, import_node_path.join)(dataDir, "engines");
|
|
38
|
+
}
|
|
39
|
+
function resolveEngineDir(dataDir, engineId) {
|
|
40
|
+
return (0, import_node_path.join)(resolveEnginesRoot(dataDir), sanitizeSeg(engineId));
|
|
41
|
+
}
|
|
42
|
+
function resolvePoolDir(dataDir, engineId, poolKey) {
|
|
43
|
+
return (0, import_node_path.join)(resolveEngineDir(dataDir, sanitizeSeg(engineId)), sanitizeSeg(poolKey));
|
|
44
|
+
}
|
|
45
|
+
function resolveJournalPath(dataDir, engineId, poolKey, taskId) {
|
|
46
|
+
return (0, import_node_path.join)(resolvePoolDir(dataDir, engineId, poolKey), `journal-${sanitizeSeg(taskId)}.jsonl`);
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
resolveEngineDir,
|
|
51
|
+
resolveEnginesRoot,
|
|
52
|
+
resolveJournalPath,
|
|
53
|
+
resolvePoolDir,
|
|
54
|
+
sanitizeSeg
|
|
55
|
+
});
|
package/dist/paths.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** 路径段进入文件系统前的安全编码:路径穿越、分隔符、空白、超长全部归一。 */
|
|
2
|
+
declare function sanitizeSeg(input: string): string;
|
|
3
|
+
declare function resolveEnginesRoot(dataDir: string): string;
|
|
4
|
+
declare function resolveEngineDir(dataDir: string, engineId: string): string;
|
|
5
|
+
declare function resolvePoolDir(dataDir: string, engineId: string, poolKey: string): string;
|
|
6
|
+
declare function resolveJournalPath(dataDir: string, engineId: string, poolKey: string, taskId: string): string;
|
|
7
|
+
|
|
8
|
+
export { resolveEngineDir, resolveEnginesRoot, resolveJournalPath, resolvePoolDir, sanitizeSeg };
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** 路径段进入文件系统前的安全编码:路径穿越、分隔符、空白、超长全部归一。 */
|
|
2
|
+
declare function sanitizeSeg(input: string): string;
|
|
3
|
+
declare function resolveEnginesRoot(dataDir: string): string;
|
|
4
|
+
declare function resolveEngineDir(dataDir: string, engineId: string): string;
|
|
5
|
+
declare function resolvePoolDir(dataDir: string, engineId: string, poolKey: string): string;
|
|
6
|
+
declare function resolveJournalPath(dataDir: string, engineId: string, poolKey: string, taskId: string): string;
|
|
7
|
+
|
|
8
|
+
export { resolveEngineDir, resolveEnginesRoot, resolveJournalPath, resolvePoolDir, sanitizeSeg };
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveEngineDir,
|
|
3
|
+
resolveEnginesRoot,
|
|
4
|
+
resolveJournalPath,
|
|
5
|
+
resolvePoolDir,
|
|
6
|
+
sanitizeSeg
|
|
7
|
+
} from "./chunk-OPMY4G4M.js";
|
|
8
|
+
import "./chunk-JSBRDJBE.js";
|
|
9
|
+
export {
|
|
10
|
+
resolveEngineDir,
|
|
11
|
+
resolveEnginesRoot,
|
|
12
|
+
resolveJournalPath,
|
|
13
|
+
resolvePoolDir,
|
|
14
|
+
sanitizeSeg
|
|
15
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/port-contract.ts
|
|
21
|
+
var port_contract_exports = {};
|
|
22
|
+
__export(port_contract_exports, {
|
|
23
|
+
parseCtxModel: () => parseCtxModel
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(port_contract_exports);
|
|
26
|
+
function parseCtxModel(ref) {
|
|
27
|
+
if (ref === void 0 || ref.trim() === "") return void 0;
|
|
28
|
+
const slash = ref.indexOf("/");
|
|
29
|
+
if (slash <= 0 || slash === ref.length - 1) return void 0;
|
|
30
|
+
return { provider: ref.slice(0, slash), id: ref.slice(slash + 1) };
|
|
31
|
+
}
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
parseCtxModel
|
|
35
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { A as AgentCallOpts, h as EngineHandleData, E as EngineCapabilities, P as ProbeReport, a as AgentEvent, k as ResumeAnchor, c as AgentOutcome, I as InteractAction, i as InteractResult, S as SessionView } from './contract-types-sSlgppBC.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
|
|
5
|
+
* cwd/schemaEnv——SDK 契约把它们从 task 移到 run.params.ctx,进程内接口合回单对象;
|
|
6
|
+
* server.ts 做 ctx→task 还原,与 core RemoteEngine.toSdkTaskSubset 镜像)。
|
|
7
|
+
*/
|
|
8
|
+
type EngineAgentCallOpts = AgentCallOpts & {
|
|
9
|
+
model?: string;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
schemaEnv?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 引擎进程内的 ctxModel 形态(core ModelInfo 的结构等价镜像——仅 id/provider 被引擎
|
|
15
|
+
* 消费,name/reasoning 等字段透传保留防测试/未来消费面漂移)。
|
|
16
|
+
*/
|
|
17
|
+
interface EngineCtxModel {
|
|
18
|
+
id: string;
|
|
19
|
+
provider: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
reasoning?: boolean;
|
|
22
|
+
thinkingLevelMap?: Record<string, unknown>;
|
|
23
|
+
contextWindow?: number;
|
|
24
|
+
}
|
|
25
|
+
/** text_delta streaming 出口(协议 host/streamDelta 的本地承载)。 */
|
|
26
|
+
interface EngineStream {
|
|
27
|
+
onDelta(delta: string): void;
|
|
28
|
+
}
|
|
29
|
+
/** run 的运行期上下文(core RunContext 结构等价镜像;chat? = 会话形态参数,缺省一次性任务)。 */
|
|
30
|
+
interface RunContext {
|
|
31
|
+
taskId: string;
|
|
32
|
+
poolKey: string;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
onEvent?: (event: AgentEvent) => void;
|
|
35
|
+
ctxModel?: EngineCtxModel;
|
|
36
|
+
stream?: EngineStream;
|
|
37
|
+
schemaEnv?: string;
|
|
38
|
+
engineFallback?: {
|
|
39
|
+
from: string;
|
|
40
|
+
reason: string;
|
|
41
|
+
};
|
|
42
|
+
onPoolResolved?: (poolKey: string) => void;
|
|
43
|
+
onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef" | "poolKey">) => void;
|
|
44
|
+
/** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
|
|
45
|
+
onChildSpawned?: (child: {
|
|
46
|
+
pid: number | undefined;
|
|
47
|
+
killed: boolean;
|
|
48
|
+
}) => void;
|
|
49
|
+
/**
|
|
50
|
+
* [v1.x] chat 会话形态参数(协议 run.params.chat 的进程内还原;缺省 = 一次性任务
|
|
51
|
+
* 形态)。recordId = chat 轮次关联键与 interact 定位键;resume 锚点存在 = 冷续
|
|
52
|
+
* (--session 续写原文件),不存在 = 首轮新建。
|
|
53
|
+
*/
|
|
54
|
+
chat?: {
|
|
55
|
+
recordId: string;
|
|
56
|
+
resume?: ResumeAnchor;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
interface EngineHandle {
|
|
60
|
+
readonly data: EngineHandleData;
|
|
61
|
+
}
|
|
62
|
+
interface EngineRunResult {
|
|
63
|
+
handle: EngineHandle;
|
|
64
|
+
outcome: AgentOutcome;
|
|
65
|
+
}
|
|
66
|
+
/** 引擎进程内的引擎契约点(core EnginePort 的结构等价镜像)。 */
|
|
67
|
+
interface EnginePort {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
capabilities(): EngineCapabilities;
|
|
70
|
+
probe(opts?: {
|
|
71
|
+
force?: boolean;
|
|
72
|
+
}): Promise<ProbeReport>;
|
|
73
|
+
run(task: EngineAgentCallOpts, ctx: RunContext): Promise<EngineRunResult>;
|
|
74
|
+
interact(handle: EngineHandle, action: InteractAction): Promise<InteractResult>;
|
|
75
|
+
read(handle: EngineHandle): Promise<SessionView>;
|
|
76
|
+
listModels?(): Array<{
|
|
77
|
+
id: string;
|
|
78
|
+
name?: string;
|
|
79
|
+
}> | null;
|
|
80
|
+
validateModel?(modelRef: string | undefined): {
|
|
81
|
+
canonicalRef: string;
|
|
82
|
+
};
|
|
83
|
+
dispose?(): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
/** ctx.ctxModel("provider/id" canonical 词形)→ EngineCtxModel。 */
|
|
86
|
+
declare function parseCtxModel(ref: string | undefined): EngineCtxModel | undefined;
|
|
87
|
+
|
|
88
|
+
export { type EngineAgentCallOpts, type EngineCtxModel, type EngineHandle, type EnginePort, type EngineRunResult, type EngineStream, type RunContext, parseCtxModel };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { A as AgentCallOpts, h as EngineHandleData, E as EngineCapabilities, P as ProbeReport, a as AgentEvent, k as ResumeAnchor, c as AgentOutcome, I as InteractAction, i as InteractResult, S as SessionView } from './contract-types-sSlgppBC.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
|
|
5
|
+
* cwd/schemaEnv——SDK 契约把它们从 task 移到 run.params.ctx,进程内接口合回单对象;
|
|
6
|
+
* server.ts 做 ctx→task 还原,与 core RemoteEngine.toSdkTaskSubset 镜像)。
|
|
7
|
+
*/
|
|
8
|
+
type EngineAgentCallOpts = AgentCallOpts & {
|
|
9
|
+
model?: string;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
schemaEnv?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 引擎进程内的 ctxModel 形态(core ModelInfo 的结构等价镜像——仅 id/provider 被引擎
|
|
15
|
+
* 消费,name/reasoning 等字段透传保留防测试/未来消费面漂移)。
|
|
16
|
+
*/
|
|
17
|
+
interface EngineCtxModel {
|
|
18
|
+
id: string;
|
|
19
|
+
provider: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
reasoning?: boolean;
|
|
22
|
+
thinkingLevelMap?: Record<string, unknown>;
|
|
23
|
+
contextWindow?: number;
|
|
24
|
+
}
|
|
25
|
+
/** text_delta streaming 出口(协议 host/streamDelta 的本地承载)。 */
|
|
26
|
+
interface EngineStream {
|
|
27
|
+
onDelta(delta: string): void;
|
|
28
|
+
}
|
|
29
|
+
/** run 的运行期上下文(core RunContext 结构等价镜像;chat? = 会话形态参数,缺省一次性任务)。 */
|
|
30
|
+
interface RunContext {
|
|
31
|
+
taskId: string;
|
|
32
|
+
poolKey: string;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
onEvent?: (event: AgentEvent) => void;
|
|
35
|
+
ctxModel?: EngineCtxModel;
|
|
36
|
+
stream?: EngineStream;
|
|
37
|
+
schemaEnv?: string;
|
|
38
|
+
engineFallback?: {
|
|
39
|
+
from: string;
|
|
40
|
+
reason: string;
|
|
41
|
+
};
|
|
42
|
+
onPoolResolved?: (poolKey: string) => void;
|
|
43
|
+
onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef" | "poolKey">) => void;
|
|
44
|
+
/** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
|
|
45
|
+
onChildSpawned?: (child: {
|
|
46
|
+
pid: number | undefined;
|
|
47
|
+
killed: boolean;
|
|
48
|
+
}) => void;
|
|
49
|
+
/**
|
|
50
|
+
* [v1.x] chat 会话形态参数(协议 run.params.chat 的进程内还原;缺省 = 一次性任务
|
|
51
|
+
* 形态)。recordId = chat 轮次关联键与 interact 定位键;resume 锚点存在 = 冷续
|
|
52
|
+
* (--session 续写原文件),不存在 = 首轮新建。
|
|
53
|
+
*/
|
|
54
|
+
chat?: {
|
|
55
|
+
recordId: string;
|
|
56
|
+
resume?: ResumeAnchor;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
interface EngineHandle {
|
|
60
|
+
readonly data: EngineHandleData;
|
|
61
|
+
}
|
|
62
|
+
interface EngineRunResult {
|
|
63
|
+
handle: EngineHandle;
|
|
64
|
+
outcome: AgentOutcome;
|
|
65
|
+
}
|
|
66
|
+
/** 引擎进程内的引擎契约点(core EnginePort 的结构等价镜像)。 */
|
|
67
|
+
interface EnginePort {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
capabilities(): EngineCapabilities;
|
|
70
|
+
probe(opts?: {
|
|
71
|
+
force?: boolean;
|
|
72
|
+
}): Promise<ProbeReport>;
|
|
73
|
+
run(task: EngineAgentCallOpts, ctx: RunContext): Promise<EngineRunResult>;
|
|
74
|
+
interact(handle: EngineHandle, action: InteractAction): Promise<InteractResult>;
|
|
75
|
+
read(handle: EngineHandle): Promise<SessionView>;
|
|
76
|
+
listModels?(): Array<{
|
|
77
|
+
id: string;
|
|
78
|
+
name?: string;
|
|
79
|
+
}> | null;
|
|
80
|
+
validateModel?(modelRef: string | undefined): {
|
|
81
|
+
canonicalRef: string;
|
|
82
|
+
};
|
|
83
|
+
dispose?(): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
/** ctx.ctxModel("provider/id" canonical 词形)→ EngineCtxModel。 */
|
|
86
|
+
declare function parseCtxModel(ref: string | undefined): EngineCtxModel | undefined;
|
|
87
|
+
|
|
88
|
+
export { type EngineAgentCallOpts, type EngineCtxModel, type EngineHandle, type EnginePort, type EngineRunResult, type EngineStream, type RunContext, parseCtxModel };
|