@zhushanwen/subagent-engine-sdk 0.12.0 → 0.13.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-2L3I2TWJ.js → chunk-2JLFRKHK.js} +5 -1
- package/dist/{chunk-YE472JOO.js → chunk-CIEZKW5F.js} +0 -19
- package/dist/env.cjs +5 -1
- package/dist/env.js +1 -1
- package/dist/index.cjs +5 -22
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -6
- package/dist/nesting-guard.cjs +0 -21
- package/dist/nesting-guard.d.cts +2 -18
- package/dist/nesting-guard.d.ts +2 -18
- package/dist/nesting-guard.js +1 -5
- package/package.json +2 -2
|
@@ -16,7 +16,11 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
16
16
|
// 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
|
|
17
17
|
// 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
|
|
18
18
|
"TAIJI_PRESET_FALLBACK_FROM",
|
|
19
|
-
"TAIJI_PRESET_FALLBACK_TO"
|
|
19
|
+
"TAIJI_PRESET_FALLBACK_TO",
|
|
20
|
+
// runtime 实例标识(connection-datasync-ssot §6.1,env 名 SSOT = shared
|
|
21
|
+
// RUNTIME_ID_ENV):supervisor 每次 spawn 签发的生命周期标志,只有 runtime 自身
|
|
22
|
+
// 消费;引擎一跳继承陈旧值 = 后代进程持有已死实例标识,出站剥除
|
|
23
|
+
"TAIJI_RUNTIME_ID"
|
|
20
24
|
];
|
|
21
25
|
var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
22
26
|
"TAIJI_AGENT_DATA_DIR",
|
|
@@ -3,18 +3,6 @@ import { AsyncLocalStorage } from "async_hooks";
|
|
|
3
3
|
var NESTED_SPAWN_ENV = "TAIJI_AGENT_SUBAGENT";
|
|
4
4
|
var NATIVE_NESTED_KEYS = ["CLAUDECODE", "ZSW_NESTED"];
|
|
5
5
|
var NATIVE_NESTED_PREFIXES = ["PI_SUBAGENT_"];
|
|
6
|
-
var NestedSpawnRejectedError = class extends Error {
|
|
7
|
-
code = "nested_spawn_rejected";
|
|
8
|
-
/** 恢复指引:指向具体下一步,非安慰性文案。 */
|
|
9
|
-
recovery;
|
|
10
|
-
constructor() {
|
|
11
|
-
super(
|
|
12
|
-
"nested_spawn_rejected: this process is already a subagent (TAIJI_AGENT_SUBAGENT=1)"
|
|
13
|
-
);
|
|
14
|
-
this.name = "NestedSpawnRejectedError";
|
|
15
|
-
this.recovery = "Subagents must not spawn further subagents (unbounded recursion guard). Do the work directly inside the current task instead of delegating.";
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
6
|
function buildNestedSpawnEnv(baseEnv) {
|
|
19
7
|
const env = {};
|
|
20
8
|
for (const [key, value] of Object.entries(baseEnv)) {
|
|
@@ -25,11 +13,6 @@ function buildNestedSpawnEnv(baseEnv) {
|
|
|
25
13
|
env[NESTED_SPAWN_ENV] = "1";
|
|
26
14
|
return env;
|
|
27
15
|
}
|
|
28
|
-
function assertNotNestedSpawn(env) {
|
|
29
|
-
if (env[NESTED_SPAWN_ENV] === "1") {
|
|
30
|
-
throw new NestedSpawnRejectedError();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
16
|
var ExecutionNestingContext = class {
|
|
34
17
|
als = new AsyncLocalStorage();
|
|
35
18
|
baselineState = null;
|
|
@@ -60,8 +43,6 @@ var ExecutionNestingContext = class {
|
|
|
60
43
|
|
|
61
44
|
export {
|
|
62
45
|
NESTED_SPAWN_ENV,
|
|
63
|
-
NestedSpawnRejectedError,
|
|
64
46
|
buildNestedSpawnEnv,
|
|
65
|
-
assertNotNestedSpawn,
|
|
66
47
|
ExecutionNestingContext
|
|
67
48
|
};
|
package/dist/env.cjs
CHANGED
|
@@ -97,7 +97,11 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
97
97
|
// 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
|
|
98
98
|
// 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
|
|
99
99
|
"TAIJI_PRESET_FALLBACK_FROM",
|
|
100
|
-
"TAIJI_PRESET_FALLBACK_TO"
|
|
100
|
+
"TAIJI_PRESET_FALLBACK_TO",
|
|
101
|
+
// runtime 实例标识(connection-datasync-ssot §6.1,env 名 SSOT = shared
|
|
102
|
+
// RUNTIME_ID_ENV):supervisor 每次 spawn 签发的生命周期标志,只有 runtime 自身
|
|
103
|
+
// 消费;引擎一跳继承陈旧值 = 后代进程持有已死实例标识,出站剥除
|
|
104
|
+
"TAIJI_RUNTIME_ID"
|
|
101
105
|
];
|
|
102
106
|
var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
103
107
|
"TAIJI_AGENT_DATA_DIR",
|
package/dist/env.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -6606,7 +6606,6 @@ __export(src_exports, {
|
|
|
6606
6606
|
HANDSHAKE_TIMEOUT_MS: () => HANDSHAKE_TIMEOUT_MS,
|
|
6607
6607
|
HOST_TIMEOUT_ABORT_REASON: () => HOST_TIMEOUT_ABORT_REASON,
|
|
6608
6608
|
NESTED_SPAWN_ENV: () => NESTED_SPAWN_ENV,
|
|
6609
|
-
NestedSpawnRejectedError: () => NestedSpawnRejectedError,
|
|
6610
6609
|
PI_SUBAGENT_TASK_MAX_CHARS: () => PI_SUBAGENT_TASK_MAX_CHARS,
|
|
6611
6610
|
PROTOCOL_METHODS: () => PROTOCOL_METHODS,
|
|
6612
6611
|
REVERSE_CHANNELS: () => REVERSE_CHANNELS,
|
|
@@ -6636,7 +6635,6 @@ __export(src_exports, {
|
|
|
6636
6635
|
appendErrorFact: () => appendErrorFact,
|
|
6637
6636
|
armEngineSelfDestruct: () => armEngineSelfDestruct,
|
|
6638
6637
|
assertChatConversationSupported: () => assertChatConversationSupported,
|
|
6639
|
-
assertNotNestedSpawn: () => assertNotNestedSpawn,
|
|
6640
6638
|
bestEffort: () => bestEffort,
|
|
6641
6639
|
buildEngineChildEnv: () => buildEngineChildEnv,
|
|
6642
6640
|
buildNestedSpawnEnv: () => buildNestedSpawnEnv,
|
|
@@ -7198,18 +7196,6 @@ var import_node_async_hooks = require("async_hooks");
|
|
|
7198
7196
|
var NESTED_SPAWN_ENV = "TAIJI_AGENT_SUBAGENT";
|
|
7199
7197
|
var NATIVE_NESTED_KEYS = ["CLAUDECODE", "ZSW_NESTED"];
|
|
7200
7198
|
var NATIVE_NESTED_PREFIXES = ["PI_SUBAGENT_"];
|
|
7201
|
-
var NestedSpawnRejectedError = class extends Error {
|
|
7202
|
-
code = "nested_spawn_rejected";
|
|
7203
|
-
/** 恢复指引:指向具体下一步,非安慰性文案。 */
|
|
7204
|
-
recovery;
|
|
7205
|
-
constructor() {
|
|
7206
|
-
super(
|
|
7207
|
-
"nested_spawn_rejected: this process is already a subagent (TAIJI_AGENT_SUBAGENT=1)"
|
|
7208
|
-
);
|
|
7209
|
-
this.name = "NestedSpawnRejectedError";
|
|
7210
|
-
this.recovery = "Subagents must not spawn further subagents (unbounded recursion guard). Do the work directly inside the current task instead of delegating.";
|
|
7211
|
-
}
|
|
7212
|
-
};
|
|
7213
7199
|
function buildNestedSpawnEnv(baseEnv) {
|
|
7214
7200
|
const env = {};
|
|
7215
7201
|
for (const [key, value] of Object.entries(baseEnv)) {
|
|
@@ -7220,11 +7206,6 @@ function buildNestedSpawnEnv(baseEnv) {
|
|
|
7220
7206
|
env[NESTED_SPAWN_ENV] = "1";
|
|
7221
7207
|
return env;
|
|
7222
7208
|
}
|
|
7223
|
-
function assertNotNestedSpawn(env) {
|
|
7224
|
-
if (env[NESTED_SPAWN_ENV] === "1") {
|
|
7225
|
-
throw new NestedSpawnRejectedError();
|
|
7226
|
-
}
|
|
7227
|
-
}
|
|
7228
7209
|
var ExecutionNestingContext = class {
|
|
7229
7210
|
als = new import_node_async_hooks.AsyncLocalStorage();
|
|
7230
7211
|
baselineState = null;
|
|
@@ -7876,7 +7857,11 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
7876
7857
|
// 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
|
|
7877
7858
|
// 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
|
|
7878
7859
|
"TAIJI_PRESET_FALLBACK_FROM",
|
|
7879
|
-
"TAIJI_PRESET_FALLBACK_TO"
|
|
7860
|
+
"TAIJI_PRESET_FALLBACK_TO",
|
|
7861
|
+
// runtime 实例标识(connection-datasync-ssot §6.1,env 名 SSOT = shared
|
|
7862
|
+
// RUNTIME_ID_ENV):supervisor 每次 spawn 签发的生命周期标志,只有 runtime 自身
|
|
7863
|
+
// 消费;引擎一跳继承陈旧值 = 后代进程持有已死实例标识,出站剥除
|
|
7864
|
+
"TAIJI_RUNTIME_ID"
|
|
7880
7865
|
];
|
|
7881
7866
|
var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
7882
7867
|
"TAIJI_AGENT_DATA_DIR",
|
|
@@ -8527,7 +8512,6 @@ function runEngineCliEntry(opts) {
|
|
|
8527
8512
|
HANDSHAKE_TIMEOUT_MS,
|
|
8528
8513
|
HOST_TIMEOUT_ABORT_REASON,
|
|
8529
8514
|
NESTED_SPAWN_ENV,
|
|
8530
|
-
NestedSpawnRejectedError,
|
|
8531
8515
|
PI_SUBAGENT_TASK_MAX_CHARS,
|
|
8532
8516
|
PROTOCOL_METHODS,
|
|
8533
8517
|
REVERSE_CHANNELS,
|
|
@@ -8557,7 +8541,6 @@ function runEngineCliEntry(opts) {
|
|
|
8557
8541
|
appendErrorFact,
|
|
8558
8542
|
armEngineSelfDestruct,
|
|
8559
8543
|
assertChatConversationSupported,
|
|
8560
|
-
assertNotNestedSpawn,
|
|
8561
8544
|
bestEffort,
|
|
8562
8545
|
buildEngineChildEnv,
|
|
8563
8546
|
buildNestedSpawnEnv,
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as E
|
|
|
3
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
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
|
-
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV,
|
|
6
|
+
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, SpawnEnv, 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
9
|
export { ErrorFact, ReplayRecordView, addUsage, aggregateUsage, appendErrorFact, createReplayRecord, emptyTurn, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent } from './journal-replay.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as E
|
|
|
3
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
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
|
-
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV,
|
|
6
|
+
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, SpawnEnv, 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
9
|
export { ErrorFact, ReplayRecordView, addUsage, aggregateUsage, appendErrorFact, createReplayRecord, emptyTurn, eventsToSessionView, sessionIdFromHandle, toReplayedTurn, updateFromEvent } from './journal-replay.js';
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
ENGINE_ENV_PREFIXES,
|
|
42
42
|
buildEngineChildEnv,
|
|
43
43
|
buildOutboundChildEnv
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-2JLFRKHK.js";
|
|
45
45
|
import {
|
|
46
46
|
DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS,
|
|
47
47
|
ENGINE_ABORT_KILL_GRACE_MS,
|
|
@@ -108,10 +108,8 @@ import {
|
|
|
108
108
|
import {
|
|
109
109
|
ExecutionNestingContext,
|
|
110
110
|
NESTED_SPAWN_ENV,
|
|
111
|
-
NestedSpawnRejectedError,
|
|
112
|
-
assertNotNestedSpawn,
|
|
113
111
|
buildNestedSpawnEnv
|
|
114
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-CIEZKW5F.js";
|
|
115
113
|
import {
|
|
116
114
|
DEFAULT_KILL_GRACE_MS,
|
|
117
115
|
DEFAULT_NATIVE_INTERRUPT_GRACE_MS,
|
|
@@ -244,7 +242,6 @@ export {
|
|
|
244
242
|
HANDSHAKE_TIMEOUT_MS,
|
|
245
243
|
HOST_TIMEOUT_ABORT_REASON,
|
|
246
244
|
NESTED_SPAWN_ENV,
|
|
247
|
-
NestedSpawnRejectedError,
|
|
248
245
|
PI_SUBAGENT_TASK_MAX_CHARS,
|
|
249
246
|
PROTOCOL_METHODS,
|
|
250
247
|
REVERSE_CHANNELS,
|
|
@@ -274,7 +271,6 @@ export {
|
|
|
274
271
|
appendErrorFact,
|
|
275
272
|
armEngineSelfDestruct,
|
|
276
273
|
assertChatConversationSupported,
|
|
277
|
-
assertNotNestedSpawn,
|
|
278
274
|
bestEffort,
|
|
279
275
|
buildEngineChildEnv,
|
|
280
276
|
buildNestedSpawnEnv,
|
package/dist/nesting-guard.cjs
CHANGED
|
@@ -22,8 +22,6 @@ var nesting_guard_exports = {};
|
|
|
22
22
|
__export(nesting_guard_exports, {
|
|
23
23
|
ExecutionNestingContext: () => ExecutionNestingContext,
|
|
24
24
|
NESTED_SPAWN_ENV: () => NESTED_SPAWN_ENV,
|
|
25
|
-
NestedSpawnRejectedError: () => NestedSpawnRejectedError,
|
|
26
|
-
assertNotNestedSpawn: () => assertNotNestedSpawn,
|
|
27
25
|
buildNestedSpawnEnv: () => buildNestedSpawnEnv
|
|
28
26
|
});
|
|
29
27
|
module.exports = __toCommonJS(nesting_guard_exports);
|
|
@@ -31,18 +29,6 @@ var import_node_async_hooks = require("async_hooks");
|
|
|
31
29
|
var NESTED_SPAWN_ENV = "TAIJI_AGENT_SUBAGENT";
|
|
32
30
|
var NATIVE_NESTED_KEYS = ["CLAUDECODE", "ZSW_NESTED"];
|
|
33
31
|
var NATIVE_NESTED_PREFIXES = ["PI_SUBAGENT_"];
|
|
34
|
-
var NestedSpawnRejectedError = class extends Error {
|
|
35
|
-
code = "nested_spawn_rejected";
|
|
36
|
-
/** 恢复指引:指向具体下一步,非安慰性文案。 */
|
|
37
|
-
recovery;
|
|
38
|
-
constructor() {
|
|
39
|
-
super(
|
|
40
|
-
"nested_spawn_rejected: this process is already a subagent (TAIJI_AGENT_SUBAGENT=1)"
|
|
41
|
-
);
|
|
42
|
-
this.name = "NestedSpawnRejectedError";
|
|
43
|
-
this.recovery = "Subagents must not spawn further subagents (unbounded recursion guard). Do the work directly inside the current task instead of delegating.";
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
32
|
function buildNestedSpawnEnv(baseEnv) {
|
|
47
33
|
const env = {};
|
|
48
34
|
for (const [key, value] of Object.entries(baseEnv)) {
|
|
@@ -53,11 +39,6 @@ function buildNestedSpawnEnv(baseEnv) {
|
|
|
53
39
|
env[NESTED_SPAWN_ENV] = "1";
|
|
54
40
|
return env;
|
|
55
41
|
}
|
|
56
|
-
function assertNotNestedSpawn(env) {
|
|
57
|
-
if (env[NESTED_SPAWN_ENV] === "1") {
|
|
58
|
-
throw new NestedSpawnRejectedError();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
42
|
var ExecutionNestingContext = class {
|
|
62
43
|
als = new import_node_async_hooks.AsyncLocalStorage();
|
|
63
44
|
baselineState = null;
|
|
@@ -89,7 +70,5 @@ var ExecutionNestingContext = class {
|
|
|
89
70
|
0 && (module.exports = {
|
|
90
71
|
ExecutionNestingContext,
|
|
91
72
|
NESTED_SPAWN_ENV,
|
|
92
|
-
NestedSpawnRejectedError,
|
|
93
|
-
assertNotNestedSpawn,
|
|
94
73
|
buildNestedSpawnEnv
|
|
95
74
|
});
|
package/dist/nesting-guard.d.cts
CHANGED
|
@@ -2,28 +2,12 @@
|
|
|
2
2
|
declare const NESTED_SPAWN_ENV = "TAIJI_AGENT_SUBAGENT";
|
|
3
3
|
/** env 对象形状(NodeJS.ProcessEnv 的结构子集,测试可传普通对象)。 */
|
|
4
4
|
type SpawnEnv = Record<string, string | undefined>;
|
|
5
|
-
/**
|
|
6
|
-
* nested_spawn_rejected 的结构化错误(自 core errors.ts 内联;code/recovery 与 core
|
|
7
|
-
* 词表逐字一致,EngineError 类形态对齐 SDK protocol/error-codes.ts 的 EngineSdkError)。
|
|
8
|
-
*/
|
|
9
|
-
declare class NestedSpawnRejectedError extends Error {
|
|
10
|
-
readonly code = "nested_spawn_rejected";
|
|
11
|
-
/** 恢复指引:指向具体下一步,非安慰性文案。 */
|
|
12
|
-
readonly recovery: string;
|
|
13
|
-
constructor();
|
|
14
|
-
}
|
|
15
5
|
/**
|
|
16
6
|
* 构造子代理 spawn env:注入 TAIJI_AGENT_SUBAGENT=1 + 剥离引擎原生嵌套标记。
|
|
17
7
|
* 返回新对象,不改入参(spawn env 组装链中的多层 spread 安全)。
|
|
18
8
|
*/
|
|
19
9
|
declare function buildNestedSpawnEnv(baseEnv: SpawnEnv): SpawnEnv;
|
|
20
|
-
/**
|
|
21
|
-
* 嵌套 spawn 防护断言:检测到统一标记(本进程已是 subagent)抛
|
|
22
|
-
* nested_spawn_rejected——文案说明防护规则、指向 task 内自行完成。
|
|
23
|
-
* 调用点:subagent 工具入口(进程创建前拒绝,D11 处置三级)。
|
|
24
|
-
*/
|
|
25
|
-
declare function assertNotNestedSpawn(env: SpawnEnv): void;
|
|
26
|
-
/** 执行嵌套状态:当前正在跑的 record 身份 + 递归深度(D-033 通用嵌套深度护栏的计数载体)。 */
|
|
10
|
+
/** 执行嵌套状态:当前正在跑的 record 身份 + 递归深度(身份归属域的计数载体)。 */
|
|
27
11
|
interface ExecutionNestingState {
|
|
28
12
|
recordId: string | undefined;
|
|
29
13
|
depth: number;
|
|
@@ -62,4 +46,4 @@ declare class ExecutionNestingContext {
|
|
|
62
46
|
enterWith(state: ExecutionNestingState): void;
|
|
63
47
|
}
|
|
64
48
|
|
|
65
|
-
export { ExecutionNestingContext, type ExecutionNestingState, NESTED_SPAWN_ENV,
|
|
49
|
+
export { ExecutionNestingContext, type ExecutionNestingState, NESTED_SPAWN_ENV, type SpawnEnv, buildNestedSpawnEnv };
|
package/dist/nesting-guard.d.ts
CHANGED
|
@@ -2,28 +2,12 @@
|
|
|
2
2
|
declare const NESTED_SPAWN_ENV = "TAIJI_AGENT_SUBAGENT";
|
|
3
3
|
/** env 对象形状(NodeJS.ProcessEnv 的结构子集,测试可传普通对象)。 */
|
|
4
4
|
type SpawnEnv = Record<string, string | undefined>;
|
|
5
|
-
/**
|
|
6
|
-
* nested_spawn_rejected 的结构化错误(自 core errors.ts 内联;code/recovery 与 core
|
|
7
|
-
* 词表逐字一致,EngineError 类形态对齐 SDK protocol/error-codes.ts 的 EngineSdkError)。
|
|
8
|
-
*/
|
|
9
|
-
declare class NestedSpawnRejectedError extends Error {
|
|
10
|
-
readonly code = "nested_spawn_rejected";
|
|
11
|
-
/** 恢复指引:指向具体下一步,非安慰性文案。 */
|
|
12
|
-
readonly recovery: string;
|
|
13
|
-
constructor();
|
|
14
|
-
}
|
|
15
5
|
/**
|
|
16
6
|
* 构造子代理 spawn env:注入 TAIJI_AGENT_SUBAGENT=1 + 剥离引擎原生嵌套标记。
|
|
17
7
|
* 返回新对象,不改入参(spawn env 组装链中的多层 spread 安全)。
|
|
18
8
|
*/
|
|
19
9
|
declare function buildNestedSpawnEnv(baseEnv: SpawnEnv): SpawnEnv;
|
|
20
|
-
/**
|
|
21
|
-
* 嵌套 spawn 防护断言:检测到统一标记(本进程已是 subagent)抛
|
|
22
|
-
* nested_spawn_rejected——文案说明防护规则、指向 task 内自行完成。
|
|
23
|
-
* 调用点:subagent 工具入口(进程创建前拒绝,D11 处置三级)。
|
|
24
|
-
*/
|
|
25
|
-
declare function assertNotNestedSpawn(env: SpawnEnv): void;
|
|
26
|
-
/** 执行嵌套状态:当前正在跑的 record 身份 + 递归深度(D-033 通用嵌套深度护栏的计数载体)。 */
|
|
10
|
+
/** 执行嵌套状态:当前正在跑的 record 身份 + 递归深度(身份归属域的计数载体)。 */
|
|
27
11
|
interface ExecutionNestingState {
|
|
28
12
|
recordId: string | undefined;
|
|
29
13
|
depth: number;
|
|
@@ -62,4 +46,4 @@ declare class ExecutionNestingContext {
|
|
|
62
46
|
enterWith(state: ExecutionNestingState): void;
|
|
63
47
|
}
|
|
64
48
|
|
|
65
|
-
export { ExecutionNestingContext, type ExecutionNestingState, NESTED_SPAWN_ENV,
|
|
49
|
+
export { ExecutionNestingContext, type ExecutionNestingState, NESTED_SPAWN_ENV, type SpawnEnv, buildNestedSpawnEnv };
|
package/dist/nesting-guard.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ExecutionNestingContext,
|
|
3
3
|
NESTED_SPAWN_ENV,
|
|
4
|
-
NestedSpawnRejectedError,
|
|
5
|
-
assertNotNestedSpawn,
|
|
6
4
|
buildNestedSpawnEnv
|
|
7
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CIEZKW5F.js";
|
|
8
6
|
import "./chunk-JSBRDJBE.js";
|
|
9
7
|
export {
|
|
10
8
|
ExecutionNestingContext,
|
|
11
9
|
NESTED_SPAWN_ENV,
|
|
12
|
-
NestedSpawnRejectedError,
|
|
13
|
-
assertNotNestedSpawn,
|
|
14
10
|
buildNestedSpawnEnv
|
|
15
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/subagent-engine-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Engine-side SDK for the subagent engine protocol: NDJSON stdio contract types, engine primitives (schema emulation, nesting guard, kill chain, journal replay projection, data-dir/paths resolution) — the shared contract root between subagent-core and engine CLI packages (engines import SDK only, never core)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsup",
|
|
75
|
-
"test": "vitest run",
|
|
75
|
+
"test": "vitest run --pool=threads",
|
|
76
76
|
"typecheck": "tsc --noEmit"
|
|
77
77
|
}
|
|
78
78
|
}
|