@zhushanwen/subagent-engine-sdk 0.10.1 → 0.11.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-AF2ETADP.js → chunk-2L3I2TWJ.js} +5 -10
- package/dist/{chunk-HSNDUHFH.js → chunk-3MCOZY3Z.js} +32 -4
- package/dist/{chunk-JZN76I3S.js → chunk-NVF3PADP.js} +29 -1
- package/dist/{chunk-LM7P7OTA.js → chunk-QBXDEF4N.js} +35 -3
- package/dist/{chunk-NTOLHLCL.js → chunk-QGXILDWB.js} +1 -1
- package/dist/{chunk-CNCFMPEH.js → chunk-TJMS3YOR.js} +1 -1
- package/dist/{chunk-SGAIDL63.js → chunk-YFSNX3N3.js} +2 -2
- package/dist/cli-entry.d.cts +1 -1
- package/dist/cli-entry.d.ts +1 -1
- package/dist/{contract-types-jSa1g28F.d.cts → contract-types-BUHUMF9R.d.cts} +17 -17
- package/dist/{contract-types-jSa1g28F.d.ts → contract-types-BUHUMF9R.d.ts} +17 -17
- package/dist/env.cjs +5 -10
- package/dist/env.d.cts +6 -17
- package/dist/env.d.ts +6 -17
- package/dist/env.js +1 -1
- package/dist/{error-codes-f-UO4a8D.d.cts → error-codes-D_aPibUt.d.cts} +42 -6
- package/dist/{error-codes-DnFru4L4.d.ts → error-codes-DrNf0gwT.d.ts} +42 -6
- package/dist/index.cjs +126 -97
- package/dist/index.d.cts +28 -40
- package/dist/index.d.ts +28 -40
- package/dist/index.js +38 -57
- package/dist/journal-io.d.cts +1 -1
- package/dist/journal-io.d.ts +1 -1
- package/dist/journal-replay.cjs +2 -2
- package/dist/journal-replay.d.cts +4 -4
- package/dist/journal-replay.d.ts +4 -4
- package/dist/journal-replay.js +1 -1
- package/dist/kill-chain.d.cts +5 -5
- package/dist/kill-chain.d.ts +5 -5
- package/dist/kill-chain.js +2 -2
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logs/stderr-rotation.d.cts +4 -4
- package/dist/logs/stderr-rotation.d.ts +4 -4
- package/dist/{methods-C2zvZqhP.d.ts → methods-BdIH3FwS.d.ts} +5 -5
- package/dist/{methods-BLxg4ZFr.d.cts → methods-CHiDwvRK.d.cts} +5 -5
- package/dist/node-executor.cjs +1 -1
- package/dist/node-executor.d.cts +4 -4
- package/dist/node-executor.d.ts +4 -4
- package/dist/node-executor.js +2 -2
- package/dist/port-contract.d.cts +9 -9
- package/dist/port-contract.d.ts +9 -9
- package/dist/protocol/index.cjs +73 -4
- package/dist/protocol/index.d.cts +57 -14
- package/dist/protocol/index.d.ts +57 -14
- package/dist/protocol/index.js +20 -2
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +10 -10
- package/dist/server/index.d.ts +10 -10
- package/dist/server/index.js +1 -1
- package/dist/spawn.cjs +32 -3
- package/dist/spawn.d.cts +34 -8
- package/dist/spawn.d.ts +34 -8
- package/dist/spawn.js +5 -3
- package/dist/ui-types.d.cts +2 -2
- package/dist/ui-types.d.ts +2 -2
- package/package.json +2 -2
- package/dist/chunk-GSW3DMN6.js +0 -39
- package/dist/relay-env.cjs +0 -71
- package/dist/relay-env.d.cts +0 -37
- package/dist/relay-env.d.ts +0 -37
- package/dist/relay-env.js +0 -23
package/dist/index.cjs
CHANGED
|
@@ -6574,6 +6574,8 @@ var src_exports = {};
|
|
|
6574
6574
|
__export(src_exports, {
|
|
6575
6575
|
AGENT_EVENT_TYPE_NAMES: () => AGENT_EVENT_TYPE_NAMES,
|
|
6576
6576
|
CANCEL_SETTLE_GRACE_MS: () => CANCEL_SETTLE_GRACE_MS,
|
|
6577
|
+
CONTROL_ENV_ROOT_SESSION_ID: () => CONTROL_ENV_ROOT_SESSION_ID,
|
|
6578
|
+
CONTROL_ENV_SOCKET: () => CONTROL_ENV_SOCKET,
|
|
6577
6579
|
DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS: () => DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS,
|
|
6578
6580
|
DEFAULT_KILL_GRACE_MS: () => DEFAULT_KILL_GRACE_MS,
|
|
6579
6581
|
DEFAULT_NATIVE_INTERRUPT_GRACE_MS: () => DEFAULT_NATIVE_INTERRUPT_GRACE_MS,
|
|
@@ -6589,7 +6591,11 @@ __export(src_exports, {
|
|
|
6589
6591
|
ENGINE_PROTOCOL_ERROR_CODES: () => ENGINE_PROTOCOL_ERROR_CODES,
|
|
6590
6592
|
ENGINE_PROTOCOL_SCHEMAS: () => ENGINE_PROTOCOL_SCHEMAS,
|
|
6591
6593
|
ENGINE_PROTOCOL_VERSION: () => ENGINE_PROTOCOL_VERSION,
|
|
6594
|
+
ENGINE_SPAWN_DELIVERY_ERROR_CODES: () => ENGINE_SPAWN_DELIVERY_ERROR_CODES,
|
|
6595
|
+
ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY: () => ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
|
|
6592
6596
|
ENGINE_TIMEOUT_RECOVERY: () => ENGINE_TIMEOUT_RECOVERY,
|
|
6597
|
+
ENGINE_TRANSPORT_ERROR_CODES: () => ENGINE_TRANSPORT_ERROR_CODES,
|
|
6598
|
+
ENGINE_TRANSPORT_ERROR_RECOVERY: () => ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
6593
6599
|
EngineSdkError: () => EngineSdkError,
|
|
6594
6600
|
ExecutionNestingContext: () => ExecutionNestingContext,
|
|
6595
6601
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS: () => FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
@@ -6597,17 +6603,8 @@ __export(src_exports, {
|
|
|
6597
6603
|
HOST_TIMEOUT_ABORT_REASON: () => HOST_TIMEOUT_ABORT_REASON,
|
|
6598
6604
|
NESTED_SPAWN_ENV: () => NESTED_SPAWN_ENV,
|
|
6599
6605
|
NestedSpawnRejectedError: () => NestedSpawnRejectedError,
|
|
6606
|
+
PI_SUBAGENT_TASK_MAX_CHARS: () => PI_SUBAGENT_TASK_MAX_CHARS,
|
|
6600
6607
|
PROTOCOL_METHODS: () => PROTOCOL_METHODS,
|
|
6601
|
-
RELAY_ENV_NODE: () => RELAY_ENV_NODE,
|
|
6602
|
-
RELAY_ENV_RECORD_ID: () => RELAY_ENV_RECORD_ID,
|
|
6603
|
-
RELAY_ENV_SCRIPT: () => RELAY_ENV_SCRIPT,
|
|
6604
|
-
RELAY_ENV_SESSION_ID: () => RELAY_ENV_SESSION_ID,
|
|
6605
|
-
RELAY_ENV_SOCKET: () => RELAY_ENV_SOCKET,
|
|
6606
|
-
RELAY_EXIT_CODES: () => RELAY_EXIT_CODES,
|
|
6607
|
-
RELAY_FRAME_DIRS: () => RELAY_FRAME_DIRS,
|
|
6608
|
-
RELAY_FRAME_KINDS: () => RELAY_FRAME_KINDS,
|
|
6609
|
-
RELAY_PROTOCOL_VERSION: () => RELAY_PROTOCOL_VERSION,
|
|
6610
|
-
RELAY_REJECT_REASONS: () => RELAY_REJECT_REASONS,
|
|
6611
6608
|
REVERSE_CHANNELS: () => REVERSE_CHANNELS,
|
|
6612
6609
|
REVERSE_CHANNEL_TIMEOUT_CLASS: () => REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
6613
6610
|
REVERSE_REQUEST_TIMEOUT_MS: () => REVERSE_REQUEST_TIMEOUT_MS,
|
|
@@ -6619,6 +6616,9 @@ __export(src_exports, {
|
|
|
6619
6616
|
SHARED_POOL_KEY: () => SHARED_POOL_KEY,
|
|
6620
6617
|
STDERR_TAIL_CHARS: () => STDERR_TAIL_CHARS,
|
|
6621
6618
|
STDOUT_TAIL_ECHO_CHARS: () => STDOUT_TAIL_ECHO_CHARS,
|
|
6619
|
+
SUBAGENT_CONTROL_CLOSED_REASONS: () => SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
6620
|
+
SUBAGENT_CONTROL_FRAME_KINDS: () => SUBAGENT_CONTROL_FRAME_KINDS,
|
|
6621
|
+
SUBAGENT_CONTROL_PROTOCOL_VERSION: () => SUBAGENT_CONTROL_PROTOCOL_VERSION,
|
|
6622
6622
|
SUBAGENT_IDENTITY_ENV: () => SUBAGENT_IDENTITY_ENV,
|
|
6623
6623
|
SUPPORTED_PROTOCOL_RANGE: () => SUPPORTED_PROTOCOL_RANGE,
|
|
6624
6624
|
TAIJI_DATA_DIR_ENV: () => TAIJI_DATA_DIR_ENV,
|
|
@@ -6649,17 +6649,20 @@ __export(src_exports, {
|
|
|
6649
6649
|
extractAndValidateStructuredOutput: () => extractAndValidateStructuredOutput,
|
|
6650
6650
|
getLogger: () => getLogger,
|
|
6651
6651
|
hostKindOf: () => hostKindOf,
|
|
6652
|
+
isControlEnvActive: () => isControlEnvActive,
|
|
6652
6653
|
isEngineErrorPassthroughCode: () => isEngineErrorPassthroughCode,
|
|
6653
6654
|
isEngineProtocolErrorCode: () => isEngineProtocolErrorCode,
|
|
6654
6655
|
isNotificationFrame: () => isNotificationFrame,
|
|
6655
6656
|
isPidAlive: () => isPidAlive,
|
|
6656
6657
|
isProtocolVersionCompatible: () => isProtocolVersionCompatible,
|
|
6657
|
-
isRelayActive: () => isRelayActive,
|
|
6658
6658
|
isRequestFrame: () => isRequestFrame,
|
|
6659
6659
|
isResponseFrame: () => isResponseFrame,
|
|
6660
6660
|
isReverseRequestFrame: () => isReverseRequestFrame,
|
|
6661
|
+
isSubagentControlClosedReason: () => isSubagentControlClosedReason,
|
|
6662
|
+
isSubagentControlFrameKind: () => isSubagentControlFrameKind,
|
|
6661
6663
|
isUiResponse: () => isUiResponse,
|
|
6662
6664
|
killChain: () => killChain,
|
|
6665
|
+
killOwnProcessGroup: () => killOwnProcessGroup,
|
|
6663
6666
|
killPidChain: () => killPidChain,
|
|
6664
6667
|
notificationFrameSchema: () => notificationFrameSchema,
|
|
6665
6668
|
parseChannel: () => parseChannel,
|
|
@@ -6668,7 +6671,6 @@ __export(src_exports, {
|
|
|
6668
6671
|
probePidAlive: () => probePidAlive,
|
|
6669
6672
|
protocolErrorSchema: () => protocolErrorSchema,
|
|
6670
6673
|
pumpNdjsonLines: () => pumpNdjsonLines,
|
|
6671
|
-
readRelayForwardEnv: () => readRelayForwardEnv,
|
|
6672
6674
|
replayJournal: () => replayJournal,
|
|
6673
6675
|
requestFrameSchema: () => requestFrameSchema,
|
|
6674
6676
|
resetDataDirWarnForTests: () => resetDataDirWarnForTests,
|
|
@@ -6768,6 +6770,30 @@ var REVERSE_CHANNEL_TIMEOUT_CLASS = {
|
|
|
6768
6770
|
};
|
|
6769
6771
|
|
|
6770
6772
|
// src/protocol/error-codes.ts
|
|
6773
|
+
var ENGINE_SPAWN_DELIVERY_ERROR_CODES = [
|
|
6774
|
+
"engine_prompt_not_delivered",
|
|
6775
|
+
"engine_prompt_rejected",
|
|
6776
|
+
"engine_spawn_handshake_timeout"
|
|
6777
|
+
];
|
|
6778
|
+
var ENGINE_TRANSPORT_ERROR_CODES = [
|
|
6779
|
+
"engine_transport_unavailable",
|
|
6780
|
+
"engine_transport_lost",
|
|
6781
|
+
"engine_open_timeout",
|
|
6782
|
+
"engine_frame_too_large",
|
|
6783
|
+
"engine_backpressure_overflow"
|
|
6784
|
+
];
|
|
6785
|
+
var ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY = {
|
|
6786
|
+
engine_prompt_not_delivered: "The task never reached the child pi (zero stdout after the prompt write, or the engine stdin was unavailable). Re-run the task; if it recurs, inspect the engine/pi logs (the failure carries the delivery diagnostics) and the runtime log.",
|
|
6787
|
+
engine_prompt_rejected: "The child pi explicitly rejected the prompt command (success:false). Check the pi-side reason carried in the error detail (busy/queue/extension takeover states are reported by pi itself), then re-run.",
|
|
6788
|
+
engine_spawn_handshake_timeout: "The engine spawn handshake did not complete in time. Check the runtime log for a spawn/handshake stall, then restart taiji and re-run the task."
|
|
6789
|
+
};
|
|
6790
|
+
var ENGINE_TRANSPORT_ERROR_RECOVERY = {
|
|
6791
|
+
engine_transport_unavailable: "The runtime control socket is unreachable (connect or hello failed). The runtime side is failing explicitly instead of silently falling back to local spawn \u2014 restart taiji and re-run the task.",
|
|
6792
|
+
engine_transport_lost: "The control connection to the runtime was lost mid-flight (runtime restart or crash). In-flight requests were rejected; restart taiji (or wait for the runtime to come back) and re-run the task \u2014 the connection is not retried in place.",
|
|
6793
|
+
engine_open_timeout: "The runtime did not finish opening the engine channel in time (spawn/attribution stalled). Check the runtime log (engine opened / kill decision lines), then re-run the task.",
|
|
6794
|
+
engine_frame_too_large: "A single frame exceeded the control-plane size limit and the channel was closed without truncation. Shrink the task/result payload (e.g. point the agent at files instead of inlining them) and re-run.",
|
|
6795
|
+
engine_backpressure_overflow: "The control-plane write queue overflowed (engine consumed frames too slowly) and the overflowed scope was torn down without dropping frames silently. Re-run the task; if it recurs, reduce concurrent subagent fan-out."
|
|
6796
|
+
};
|
|
6771
6797
|
var SET_MODEL_ERROR_CODES = [
|
|
6772
6798
|
/** 目标模型不在当前进程快照(子进程模型快照冻结于 spawn 时刻——模型本身有效,
|
|
6773
6799
|
* 下一轮 spawn 现取目录即可用;宿主按「写覆盖意图」处置,设计 §7.2 快照型失败行)。 */
|
|
@@ -6812,7 +6838,7 @@ var EngineSdkError = class extends Error {
|
|
|
6812
6838
|
this.recovery = recovery;
|
|
6813
6839
|
this.data = data;
|
|
6814
6840
|
}
|
|
6815
|
-
/** 协议 error
|
|
6841
|
+
/** 协议 error 帧载荷派生视图。 */
|
|
6816
6842
|
toStructured() {
|
|
6817
6843
|
return { code: this.code, message: this.message, recovery: this.recovery, data: this.data };
|
|
6818
6844
|
}
|
|
@@ -6863,12 +6889,39 @@ function schemaEmulationFailedDetail(error, tail) {
|
|
|
6863
6889
|
return `structured output emulation failed after tolerant extraction and one host-side retry: ${error}. Raw output tail: ${truncate(tail, DETAIL_ECHO_MAX_CHARS)}. Recovery: retry with a strengthened prompt or relax the schema; if it still fails switch to a schema-native engine (engine: pi).`;
|
|
6864
6890
|
}
|
|
6865
6891
|
|
|
6892
|
+
// src/protocol/control-protocol.ts
|
|
6893
|
+
var SUBAGENT_CONTROL_PROTOCOL_VERSION = 1;
|
|
6894
|
+
var SUBAGENT_CONTROL_FRAME_KINDS = {
|
|
6895
|
+
hello: "hello",
|
|
6896
|
+
helloOk: "hello_ok",
|
|
6897
|
+
helloReject: "hello_reject",
|
|
6898
|
+
engineOpen: "engine_open",
|
|
6899
|
+
engineOpened: "engine_opened",
|
|
6900
|
+
engineOpenFailed: "engine_open_failed",
|
|
6901
|
+
engineFrame: "engine_frame",
|
|
6902
|
+
engineClose: "engine_close",
|
|
6903
|
+
engineClosed: "engine_closed",
|
|
6904
|
+
error: "error"
|
|
6905
|
+
};
|
|
6906
|
+
function isSubagentControlFrameKind(value) {
|
|
6907
|
+
return typeof value === "string" && Object.values(SUBAGENT_CONTROL_FRAME_KINDS).includes(value);
|
|
6908
|
+
}
|
|
6909
|
+
var SUBAGENT_CONTROL_CLOSED_REASONS = {
|
|
6910
|
+
engineExit: "engine_exit",
|
|
6911
|
+
engineSignal: "engine_signal",
|
|
6912
|
+
killedByControl: "killed_by_control",
|
|
6913
|
+
openTimeout: "open_timeout"
|
|
6914
|
+
};
|
|
6915
|
+
function isSubagentControlClosedReason(value) {
|
|
6916
|
+
return typeof value === "string" && Object.values(SUBAGENT_CONTROL_CLOSED_REASONS).includes(value);
|
|
6917
|
+
}
|
|
6918
|
+
|
|
6866
6919
|
// src/protocol/contract-types.ts
|
|
6867
6920
|
var AGENT_EVENT_TYPE_NAMES = [
|
|
6868
6921
|
"tool_start",
|
|
6869
6922
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 tool 起始占位(显示降级),turn 结构不受损
|
|
6870
6923
|
"tool_end",
|
|
6871
|
-
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn
|
|
6924
|
+
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 result,turn 收尾由 turn_end/message_end 承担
|
|
6872
6925
|
"text_delta",
|
|
6873
6926
|
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺正文增量,不产生半解析状态
|
|
6874
6927
|
"thinking_delta",
|
|
@@ -6876,7 +6929,7 @@ var AGENT_EVENT_TYPE_NAMES = [
|
|
|
6876
6929
|
"turn_end",
|
|
6877
6930
|
// noop-safe: 旧宿主 default 分支零写入——丢弃则该 turn 滞留进行态,journal 重放仍按序重建
|
|
6878
6931
|
"message_end",
|
|
6879
|
-
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage
|
|
6932
|
+
// noop-safe: 旧宿主 default 分支零写入——丢弃仅缺 usage 聚合与结束计量,已累积内容不回滚
|
|
6880
6933
|
"compaction",
|
|
6881
6934
|
// noop-safe: 事件无载荷且现行 reducer 即直接 return——丢弃与处理零差异
|
|
6882
6935
|
"activity",
|
|
@@ -6958,7 +7011,7 @@ var notificationFrameSchema = {
|
|
|
6958
7011
|
type: {
|
|
6959
7012
|
type: "string",
|
|
6960
7013
|
// 事件 enum 从词表 SSOT 派生(U2 词表锁:union⟷词表互证后,此处不再
|
|
6961
|
-
//
|
|
7014
|
+
// 手写字面量集合——手写即漂移点,问题点 1 的第三处同步点)
|
|
6962
7015
|
enum: [...AGENT_EVENT_TYPE_NAMES]
|
|
6963
7016
|
}
|
|
6964
7017
|
}
|
|
@@ -7543,7 +7596,7 @@ function updateFromEvent(record, event) {
|
|
|
7543
7596
|
return applyToolStart(record, event);
|
|
7544
7597
|
case "tool_end":
|
|
7545
7598
|
return applyToolEnd(record, event);
|
|
7546
|
-
// ── turn_end
|
|
7599
|
+
// ── turn_end:结束当前 turn ──
|
|
7547
7600
|
case "turn_end":
|
|
7548
7601
|
return applyTurnEnd(record);
|
|
7549
7602
|
// ── message_end:usage 增量累加 + totalTokens 累加 ──
|
|
@@ -7559,7 +7612,7 @@ function updateFromEvent(record, event) {
|
|
|
7559
7612
|
case "activity":
|
|
7560
7613
|
return;
|
|
7561
7614
|
// ── armed:武装确认回执([D3 协议版 P6],协议语义见 contract-types)——监控
|
|
7562
|
-
// 信号不进 record
|
|
7615
|
+
// 信号不进 record 派生视图,消费方 = 宿主等待门 + run 事件 journal(C3 第④步
|
|
7563
7616
|
// 双侧 reducer no-op 义务的 SDK 侧)
|
|
7564
7617
|
case "armed":
|
|
7565
7618
|
return;
|
|
@@ -7782,8 +7835,6 @@ var ENGINE_ENV_DENY_LIST = [
|
|
|
7782
7835
|
"TAIJI_AGENT_PACKAGED",
|
|
7783
7836
|
"TAIJI_RUNTIME_TOKEN",
|
|
7784
7837
|
"TAIJI_AGENT_API_KEY",
|
|
7785
|
-
"TAIJI_SUBAGENT_RELAY_SESSION_ID",
|
|
7786
|
-
"TAIJI_SUBAGENT_RELAY_RECORD_ID",
|
|
7787
7838
|
// 预设回落事实(env 名 SSOT = shared PRESET_FALLBACK_ENV_KEYS):「本进程本次运行」
|
|
7788
7839
|
// 事实只对 runtime 直接 spawn 的 pi 成立,引擎一跳继承会造成子 agent pi 假披露
|
|
7789
7840
|
"TAIJI_PRESET_FALLBACK_FROM",
|
|
@@ -7794,9 +7845,11 @@ var ENGINE_ENV_L0_INFRA_KEYS = [
|
|
|
7794
7845
|
"TAIJI_AGENT_ENGINE_NODE",
|
|
7795
7846
|
"ELECTRON_RUN_AS_NODE",
|
|
7796
7847
|
"TAIJI_AGENT_SUBAGENT",
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7848
|
+
// [M3] control 两键(键名 SSOT = src/control-env.ts):runtime 注入主 pi 与引擎的
|
|
7849
|
+
// L0 基础设施键,嵌套 task pi 经引擎出站 env 继承同值。刻意不进 ENGINE_ENV_DENY_LIST:
|
|
7850
|
+
// 引擎/嵌套 extension 是合法读者(transport 选择谓词 + engine_open 归属键)。
|
|
7851
|
+
"TAIJI_SUBAGENT_CONTROL_SOCKET",
|
|
7852
|
+
"TAIJI_SUBAGENT_CONTROL_ROOT_SESSION_ID"
|
|
7800
7853
|
];
|
|
7801
7854
|
var ENV_PREFIX_SHAPE_RE = /^[A-Za-z0-9_]+$/;
|
|
7802
7855
|
function deleteEnvKeysCaseInsensitive(env, names) {
|
|
@@ -7850,11 +7903,6 @@ function injectL0InfraKeys(env, opts) {
|
|
|
7850
7903
|
if (opts.engineNode !== void 0) env.TAIJI_AGENT_ENGINE_NODE = opts.engineNode;
|
|
7851
7904
|
if (opts.electronRunAsNode === true) env.ELECTRON_RUN_AS_NODE = "1";
|
|
7852
7905
|
env.TAIJI_AGENT_SUBAGENT = "1";
|
|
7853
|
-
if (opts.relay !== void 0) {
|
|
7854
|
-
env.TAIJI_SUBAGENT_RELAY_SOCKET = opts.relay.socket;
|
|
7855
|
-
env.TAIJI_SUBAGENT_RELAY_NODE = opts.relay.node;
|
|
7856
|
-
env.TAIJI_SUBAGENT_RELAY_SCRIPT = opts.relay.script;
|
|
7857
|
-
}
|
|
7858
7906
|
if (opts.identityEnv !== void 0) {
|
|
7859
7907
|
for (const [key, value] of Object.entries(opts.identityEnv)) {
|
|
7860
7908
|
if (value !== void 0) env[key] = value;
|
|
@@ -7920,6 +7968,7 @@ var SUBAGENT_IDENTITY_ENV = {
|
|
|
7920
7968
|
/** worktree 隔离标志("true" = 是)。 */
|
|
7921
7969
|
worktree: "PI_SUBAGENT_WORKTREE"
|
|
7922
7970
|
};
|
|
7971
|
+
var PI_SUBAGENT_TASK_MAX_CHARS = 2e3;
|
|
7923
7972
|
|
|
7924
7973
|
// src/spawn.ts
|
|
7925
7974
|
var import_node_child_process = require("child_process");
|
|
@@ -7973,13 +8022,40 @@ function resolveHostRequestTimeoutMs(opts) {
|
|
|
7973
8022
|
}
|
|
7974
8023
|
return parsed;
|
|
7975
8024
|
}
|
|
7976
|
-
function killOwnProcessGroup() {
|
|
8025
|
+
function killOwnProcessGroup(deps = {}) {
|
|
7977
8026
|
const pid = process.pid;
|
|
8027
|
+
const kill = deps.killFn ?? ((targetPid, signal) => process.kill(targetPid, signal));
|
|
8028
|
+
if ((deps.platform ?? process.platform) === "win32") {
|
|
8029
|
+
const fallbackSelfKill = (reason) => {
|
|
8030
|
+
logger4.warn(`taskkill self-tree failed (${reason}); falling back to self SIGKILL`);
|
|
8031
|
+
try {
|
|
8032
|
+
kill(pid, "SIGKILL");
|
|
8033
|
+
} catch (err) {
|
|
8034
|
+
logger4.warn(
|
|
8035
|
+
`self SIGKILL fallback failed (${String(err)}); descendant pi may linger until runtime sweep`
|
|
8036
|
+
);
|
|
8037
|
+
}
|
|
8038
|
+
};
|
|
8039
|
+
const spawnFn = deps.spawnFn ?? ((command, args, options) => (0, import_node_child_process.spawn)(command, [...args], options));
|
|
8040
|
+
try {
|
|
8041
|
+
const child = spawnFn("taskkill", ["/PID", String(pid), "/T", "/F"], {
|
|
8042
|
+
stdio: "ignore",
|
|
8043
|
+
windowsHide: true
|
|
8044
|
+
});
|
|
8045
|
+
child.on("error", (err) => {
|
|
8046
|
+
fallbackSelfKill(String(err));
|
|
8047
|
+
});
|
|
8048
|
+
child.unref?.();
|
|
8049
|
+
} catch (err) {
|
|
8050
|
+
fallbackSelfKill(`spawn threw: ${String(err)}`);
|
|
8051
|
+
}
|
|
8052
|
+
return;
|
|
8053
|
+
}
|
|
7978
8054
|
try {
|
|
7979
|
-
|
|
8055
|
+
kill(-pid, "SIGKILL");
|
|
7980
8056
|
} catch (err) {
|
|
7981
8057
|
logger4.warn(`process-group kill failed (${String(err)}), falling back to self kill`);
|
|
7982
|
-
|
|
8058
|
+
kill(pid, "SIGKILL");
|
|
7983
8059
|
}
|
|
7984
8060
|
}
|
|
7985
8061
|
function armEngineSelfDestruct(opts) {
|
|
@@ -8275,61 +8351,12 @@ var ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS = [
|
|
|
8275
8351
|
"pi-synced-provider-config.json"
|
|
8276
8352
|
];
|
|
8277
8353
|
|
|
8278
|
-
// src/
|
|
8279
|
-
var
|
|
8280
|
-
var
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
var RELAY_ENV_RECORD_ID = "TAIJI_SUBAGENT_RELAY_RECORD_ID";
|
|
8284
|
-
var RELAY_PROTOCOL_VERSION = 1;
|
|
8285
|
-
var RELAY_EXIT_CODES = {
|
|
8286
|
-
/** 握手被拒:协议版本不匹配(安装损坏,重装应用)。 */
|
|
8287
|
-
VERSION_MISMATCH: 10,
|
|
8288
|
-
/** relay socket 不可达(runtime 未运行或已重启)。 */
|
|
8289
|
-
SOCKET_UNREACHABLE: 11,
|
|
8290
|
-
/** socket 中途断开(runtime 崩溃等)——代理生命线断即退。 */
|
|
8291
|
-
SOCKET_CLOSED: 12,
|
|
8292
|
-
/** 归属 env(SESSION_ID/RECORD_ID)缺失——防无归属帧污染广播。 */
|
|
8293
|
-
MISSING_IDENTITY: 13
|
|
8294
|
-
};
|
|
8295
|
-
function isRelayActive(env) {
|
|
8296
|
-
return Boolean(env[RELAY_ENV_SOCKET] && env[RELAY_ENV_NODE] && env[RELAY_ENV_SCRIPT]);
|
|
8354
|
+
// src/control-env.ts
|
|
8355
|
+
var CONTROL_ENV_SOCKET = "TAIJI_SUBAGENT_CONTROL_SOCKET";
|
|
8356
|
+
var CONTROL_ENV_ROOT_SESSION_ID = "TAIJI_SUBAGENT_CONTROL_ROOT_SESSION_ID";
|
|
8357
|
+
function isControlEnvActive(env) {
|
|
8358
|
+
return Boolean(env[CONTROL_ENV_SOCKET]);
|
|
8297
8359
|
}
|
|
8298
|
-
function readRelayForwardEnv(env) {
|
|
8299
|
-
const socket = env[RELAY_ENV_SOCKET];
|
|
8300
|
-
const node = env[RELAY_ENV_NODE];
|
|
8301
|
-
const script = env[RELAY_ENV_SCRIPT];
|
|
8302
|
-
if (!isRelayActive(env)) return void 0;
|
|
8303
|
-
return { socket, node, script };
|
|
8304
|
-
}
|
|
8305
|
-
|
|
8306
|
-
// src/relay-frames.ts
|
|
8307
|
-
var RELAY_FRAME_KINDS = {
|
|
8308
|
-
handshake: "handshake",
|
|
8309
|
-
accept: "accept",
|
|
8310
|
-
reject: "reject",
|
|
8311
|
-
data: "data",
|
|
8312
|
-
exit: "exit",
|
|
8313
|
-
/**
|
|
8314
|
-
* goodbye(代理 → runtime,v1):代理被宿主终止(SIGTERM/SIGINT)前的预告帧——
|
|
8315
|
-
* 宿主侧的正常收割(agent_settled 后杀代理)与异常断连(宿主崩溃/主 pi 死)在
|
|
8316
|
-
* runtime 侧都表现为 socket close,无法区分;goodbye 让正常收割显式自报,runtime
|
|
8317
|
-
* 据此把后续 close 的日志从 warn(kill-on-disconnect)降级为 info(reaped,正常
|
|
8318
|
-
* teardown)。kill 行为本身不变(预告后 child 仍由 runtime 收割)。
|
|
8319
|
-
*/
|
|
8320
|
-
goodbye: "goodbye"
|
|
8321
|
-
};
|
|
8322
|
-
var RELAY_FRAME_DIRS = {
|
|
8323
|
-
down: "down",
|
|
8324
|
-
up: "up",
|
|
8325
|
-
upStderr: "up-stderr"
|
|
8326
|
-
};
|
|
8327
|
-
var RELAY_REJECT_REASONS = {
|
|
8328
|
-
version: "version",
|
|
8329
|
-
identity: "identity",
|
|
8330
|
-
duplicate: "duplicate",
|
|
8331
|
-
malformed: "malformed"
|
|
8332
|
-
};
|
|
8333
8360
|
|
|
8334
8361
|
// src/best-effort.ts
|
|
8335
8362
|
var logger5 = getLogger("subagents");
|
|
@@ -8430,6 +8457,8 @@ function runEngineCliEntry(opts) {
|
|
|
8430
8457
|
0 && (module.exports = {
|
|
8431
8458
|
AGENT_EVENT_TYPE_NAMES,
|
|
8432
8459
|
CANCEL_SETTLE_GRACE_MS,
|
|
8460
|
+
CONTROL_ENV_ROOT_SESSION_ID,
|
|
8461
|
+
CONTROL_ENV_SOCKET,
|
|
8433
8462
|
DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS,
|
|
8434
8463
|
DEFAULT_KILL_GRACE_MS,
|
|
8435
8464
|
DEFAULT_NATIVE_INTERRUPT_GRACE_MS,
|
|
@@ -8445,7 +8474,11 @@ function runEngineCliEntry(opts) {
|
|
|
8445
8474
|
ENGINE_PROTOCOL_ERROR_CODES,
|
|
8446
8475
|
ENGINE_PROTOCOL_SCHEMAS,
|
|
8447
8476
|
ENGINE_PROTOCOL_VERSION,
|
|
8477
|
+
ENGINE_SPAWN_DELIVERY_ERROR_CODES,
|
|
8478
|
+
ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY,
|
|
8448
8479
|
ENGINE_TIMEOUT_RECOVERY,
|
|
8480
|
+
ENGINE_TRANSPORT_ERROR_CODES,
|
|
8481
|
+
ENGINE_TRANSPORT_ERROR_RECOVERY,
|
|
8449
8482
|
EngineSdkError,
|
|
8450
8483
|
ExecutionNestingContext,
|
|
8451
8484
|
FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS,
|
|
@@ -8453,17 +8486,8 @@ function runEngineCliEntry(opts) {
|
|
|
8453
8486
|
HOST_TIMEOUT_ABORT_REASON,
|
|
8454
8487
|
NESTED_SPAWN_ENV,
|
|
8455
8488
|
NestedSpawnRejectedError,
|
|
8489
|
+
PI_SUBAGENT_TASK_MAX_CHARS,
|
|
8456
8490
|
PROTOCOL_METHODS,
|
|
8457
|
-
RELAY_ENV_NODE,
|
|
8458
|
-
RELAY_ENV_RECORD_ID,
|
|
8459
|
-
RELAY_ENV_SCRIPT,
|
|
8460
|
-
RELAY_ENV_SESSION_ID,
|
|
8461
|
-
RELAY_ENV_SOCKET,
|
|
8462
|
-
RELAY_EXIT_CODES,
|
|
8463
|
-
RELAY_FRAME_DIRS,
|
|
8464
|
-
RELAY_FRAME_KINDS,
|
|
8465
|
-
RELAY_PROTOCOL_VERSION,
|
|
8466
|
-
RELAY_REJECT_REASONS,
|
|
8467
8491
|
REVERSE_CHANNELS,
|
|
8468
8492
|
REVERSE_CHANNEL_TIMEOUT_CLASS,
|
|
8469
8493
|
REVERSE_REQUEST_TIMEOUT_MS,
|
|
@@ -8475,6 +8499,9 @@ function runEngineCliEntry(opts) {
|
|
|
8475
8499
|
SHARED_POOL_KEY,
|
|
8476
8500
|
STDERR_TAIL_CHARS,
|
|
8477
8501
|
STDOUT_TAIL_ECHO_CHARS,
|
|
8502
|
+
SUBAGENT_CONTROL_CLOSED_REASONS,
|
|
8503
|
+
SUBAGENT_CONTROL_FRAME_KINDS,
|
|
8504
|
+
SUBAGENT_CONTROL_PROTOCOL_VERSION,
|
|
8478
8505
|
SUBAGENT_IDENTITY_ENV,
|
|
8479
8506
|
SUPPORTED_PROTOCOL_RANGE,
|
|
8480
8507
|
TAIJI_DATA_DIR_ENV,
|
|
@@ -8505,17 +8532,20 @@ function runEngineCliEntry(opts) {
|
|
|
8505
8532
|
extractAndValidateStructuredOutput,
|
|
8506
8533
|
getLogger,
|
|
8507
8534
|
hostKindOf,
|
|
8535
|
+
isControlEnvActive,
|
|
8508
8536
|
isEngineErrorPassthroughCode,
|
|
8509
8537
|
isEngineProtocolErrorCode,
|
|
8510
8538
|
isNotificationFrame,
|
|
8511
8539
|
isPidAlive,
|
|
8512
8540
|
isProtocolVersionCompatible,
|
|
8513
|
-
isRelayActive,
|
|
8514
8541
|
isRequestFrame,
|
|
8515
8542
|
isResponseFrame,
|
|
8516
8543
|
isReverseRequestFrame,
|
|
8544
|
+
isSubagentControlClosedReason,
|
|
8545
|
+
isSubagentControlFrameKind,
|
|
8517
8546
|
isUiResponse,
|
|
8518
8547
|
killChain,
|
|
8548
|
+
killOwnProcessGroup,
|
|
8519
8549
|
killPidChain,
|
|
8520
8550
|
notificationFrameSchema,
|
|
8521
8551
|
parseChannel,
|
|
@@ -8524,7 +8554,6 @@ function runEngineCliEntry(opts) {
|
|
|
8524
8554
|
probePidAlive,
|
|
8525
8555
|
protocolErrorSchema,
|
|
8526
8556
|
pumpNdjsonLines,
|
|
8527
|
-
readRelayForwardEnv,
|
|
8528
8557
|
replayJournal,
|
|
8529
8558
|
requestFrameSchema,
|
|
8530
8559
|
resetDataDirWarnForTests,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReverseChannel, ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.cjs';
|
|
2
|
-
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as
|
|
3
|
-
export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from './methods-
|
|
4
|
-
export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from './contract-types-
|
|
1
|
+
export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReverseChannel, ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUBAGENT_CONTROL_CLOSED_REASONS, SUBAGENT_CONTROL_FRAME_KINDS, SUBAGENT_CONTROL_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_RANGE, SubagentControlClosedReason, SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.cjs';
|
|
2
|
+
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_SPAWN_DELIVERY_ERROR_CODES, d as ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY, e as ENGINE_TIMEOUT_RECOVERY, f as ENGINE_TRANSPORT_ERROR_CODES, g as ENGINE_TRANSPORT_ERROR_RECOVERY, h as EngineProtocolErrorCode, E as EngineSdkError, i as EngineSpawnDeliveryErrorCode, j as EngineTransportErrorCode, k as ErrorResponseFrame, l as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, m as ResponseFrame, n as ReverseRequestFrame, o as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, p as SET_MODEL_NOT_ACTIVE_CODE, q as STDOUT_TAIL_ECHO_CHARS, r as SetModelErrorCode, s as SuccessResponseFrame, t as assertChatConversationSupported, u as engineConversationUnsupportedError, v as engineProtocolMismatchError, w as engineSetModelUnsupportedError, x as engineTimeoutDetail, y as isEngineErrorPassthroughCode, z as isEngineProtocolErrorCode, A as isNotificationFrame, B as isRequestFrame, C as isResponseFrame, D as isReverseRequestFrame, F as schemaEmulationFailedDetail } from './error-codes-D_aPibUt.cjs';
|
|
3
|
+
export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from './methods-CHiDwvRK.cjs';
|
|
4
|
+
export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from './contract-types-BUHUMF9R.cjs';
|
|
5
5
|
export { SCHEMA_EMULATION_TAIL_CHARS, StructuredOutputResult, buildSchemaEmulationSegment, extractAndValidateStructuredOutput } from './schema-emulation.cjs';
|
|
6
6
|
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, NestedSpawnRejectedError, SpawnEnv, assertNotNestedSpawn, buildNestedSpawnEnv } from './nesting-guard.cjs';
|
|
7
7
|
export { CoreLogger, LogLevel, LoggerSink, configureLoggerSink, getLogger, resetLoggerSinkForTests } from './logger.cjs';
|
|
@@ -11,12 +11,11 @@ export { TAIJI_DATA_DIR_ENV, resetDataDirWarnForTests, resolveEngineDataDir } fr
|
|
|
11
11
|
export { resolveEngineDir, resolveEnginesRoot, resolveJournalPath, resolvePoolDir, sanitizeSeg } from './paths.cjs';
|
|
12
12
|
export { UiMethod, UiRequest, UiRequestHandler, UiResponse, isUiResponse } from './ui-types.cjs';
|
|
13
13
|
export { ChannelHandler, ExtensionUiRequestLike, ParsedChannel, UiChannelRegistry, createUiChannelRegistry, parseChannel } from './ui-channels.cjs';
|
|
14
|
-
export { BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, EngineChildEnvOptions,
|
|
15
|
-
export { DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS, ENGINE_ABORT_KILL_GRACE_MS, ENGINE_HOST_REQUEST_TIMEOUT_ENV, EngineChildEnv, EngineSelfDestructOptions, ReverseRequestClock, SpawnEngineChildOptions, armEngineSelfDestruct, pumpNdjsonLines, spawnEngineChild } from './spawn.cjs';
|
|
14
|
+
export { BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, EngineChildEnvOptions, buildEngineChildEnv, buildOutboundChildEnv } from './env.cjs';
|
|
15
|
+
export { DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS, ENGINE_ABORT_KILL_GRACE_MS, ENGINE_HOST_REQUEST_TIMEOUT_ENV, EngineChildEnv, EngineSelfDestructOptions, KillOwnProcessGroupDeps, KillOwnProcessGroupSpawnResult, ReverseRequestClock, SpawnEngineChildOptions, armEngineSelfDestruct, killOwnProcessGroup, pumpNdjsonLines, spawnEngineChild } from './spawn.cjs';
|
|
16
16
|
export { ENGINE_NODE_ENV, EngineNodeHostKind, EngineNodeLaunch, EngineNodeLaunchOptions, hostKindOf, probeNodeExecutor, resetEngineNodeProbeCache, resolveEngineNodeLaunch } from './node-executor.cjs';
|
|
17
17
|
export { CleanupResult, DEFAULT_STDERR_KEEP_DAYS, DEFAULT_STDERR_MAX_BYTES, StderrRotationParams, cleanupSiblingStderrLogs, cleanupStaleStderrLogs, isPidAlive, rotateStderrLogIfNeeded, stderrLogPathFor, stderrLogPidOf, stderrRotationParams } from './logs/stderr-rotation.cjs';
|
|
18
18
|
export { ZCODE_HOST_DB_SUFFIX, ZCODE_ISOLATED_DB_SEGMENTS, ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS } from './zcode-db-paths.cjs';
|
|
19
|
-
export { RELAY_ENV_NODE, RELAY_ENV_RECORD_ID, RELAY_ENV_SCRIPT, RELAY_ENV_SESSION_ID, RELAY_ENV_SOCKET, RELAY_EXIT_CODES, RELAY_PROTOCOL_VERSION, isRelayActive, readRelayForwardEnv } from './relay-env.cjs';
|
|
20
19
|
export { toErrorMessage } from './error-message.cjs';
|
|
21
20
|
export { BestEffortLevel, bestEffort } from './best-effort.cjs';
|
|
22
21
|
export { replayJournal } from './journal-io.cjs';
|
|
@@ -50,38 +49,27 @@ declare const SUBAGENT_IDENTITY_ENV: {
|
|
|
50
49
|
/** worktree 隔离标志("true" = 是)。 */
|
|
51
50
|
readonly worktree: "PI_SUBAGENT_WORKTREE";
|
|
52
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* [M1 D2] 任务文本进 env 的截断上限(字符数):写入点 = pi 引擎 spawn-runner 的
|
|
54
|
+
* applyContentIdentityKeys——写 `params.task` 前 2000 字符 + 截断标记
|
|
55
|
+
* `…[truncated N chars]`;env 读取点(appendSubagentIdentityEntry)零改动(读 env 值
|
|
56
|
+
* 即用)。全文以 pi session 文件首条 user 消息与父侧 manifest 为准(manifest 主路径
|
|
57
|
+
* 保留全文;截断只影响 manifest 缺席时的重建链/P-fallback 投影,降级面逐层判定登记
|
|
58
|
+
* 见设计 D2 消费方矩阵与 §3.7)。目的:控制面(握手帧)与 execve env 不再随任务正文
|
|
59
|
+
* 线性膨胀(ARG_MAX/E2BIG 族无界暴露的写入点根因修复)。
|
|
60
|
+
*/
|
|
61
|
+
declare const PI_SUBAGENT_TASK_MAX_CHARS = 2000;
|
|
53
62
|
|
|
54
|
-
/**
|
|
55
|
-
declare const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* 据此把后续 close 的日志从 warn(kill-on-disconnect)降级为 info(reaped,正常
|
|
66
|
-
* teardown)。kill 行为本身不变(预告后 child 仍由 runtime 收割)。
|
|
67
|
-
*/
|
|
68
|
-
readonly goodbye: "goodbye";
|
|
69
|
-
};
|
|
70
|
-
/** 数据泵方向(data 帧 dir 字段词表)。 */
|
|
71
|
-
declare const RELAY_FRAME_DIRS: {
|
|
72
|
-
readonly down: "down";
|
|
73
|
-
readonly up: "up";
|
|
74
|
-
readonly upStderr: "up-stderr";
|
|
75
|
-
};
|
|
76
|
-
/** reject 帧 reason 词表(runtime→代理的拒绝理由;代理对 version 以退出码 10 应答)。 */
|
|
77
|
-
declare const RELAY_REJECT_REASONS: {
|
|
78
|
-
readonly version: "version";
|
|
79
|
-
readonly identity: "identity";
|
|
80
|
-
readonly duplicate: "duplicate";
|
|
81
|
-
readonly malformed: "malformed";
|
|
82
|
-
};
|
|
83
|
-
type RelayFrameKind = (typeof RELAY_FRAME_KINDS)[keyof typeof RELAY_FRAME_KINDS];
|
|
84
|
-
type RelayFrameDir = (typeof RELAY_FRAME_DIRS)[keyof typeof RELAY_FRAME_DIRS];
|
|
85
|
-
type RelayRejectReason = (typeof RELAY_REJECT_REASONS)[keyof typeof RELAY_REJECT_REASONS];
|
|
63
|
+
/** control socket 路径(runtime 监听 `<dataDir>/run/subagent-<pid>.sock`;Windows 为 named pipe)。 */
|
|
64
|
+
declare const CONTROL_ENV_SOCKET = "TAIJI_SUBAGENT_CONTROL_SOCKET";
|
|
65
|
+
/** 主会话根 id(runtime 注入;嵌套链所有层同值——连接归属与 channel 树的归属键)。 */
|
|
66
|
+
declare const CONTROL_ENV_ROOT_SESSION_ID = "TAIJI_SUBAGENT_CONTROL_ROOT_SESSION_ID";
|
|
67
|
+
/**
|
|
68
|
+
* transport 选择谓词(D5 选择逻辑的单一实现):SOCKET 非空 = 托管态 → runtime
|
|
69
|
+
* transport;空串/缺失 = standalone → local transport(调用方 warn)。消费方 =
|
|
70
|
+
* EngineClient transport 选择(u-m3-rt-transport);缺失即 local,不存在
|
|
71
|
+
* 「注入了一半」的中间态。
|
|
72
|
+
*/
|
|
73
|
+
declare function isControlEnvActive(env: NodeJS.ProcessEnv | Record<string, string | undefined>): boolean;
|
|
86
74
|
|
|
87
|
-
export {
|
|
75
|
+
export { CONTROL_ENV_ROOT_SESSION_ID, CONTROL_ENV_SOCKET, PI_SUBAGENT_TASK_MAX_CHARS, SUBAGENT_IDENTITY_ENV, isControlEnvActive };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReverseChannel, ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.js';
|
|
2
|
-
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as
|
|
3
|
-
export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from './methods-
|
|
4
|
-
export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from './contract-types-
|
|
1
|
+
export { CANCEL_SETTLE_GRACE_MS, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReverseChannel, ReverseRequestTimeoutClass, SET_MODEL_REQUEST_TIMEOUT_MS, SET_MODEL_STAGE_TIMEOUT_MS, STDERR_TAIL_CHARS, SUBAGENT_CONTROL_CLOSED_REASONS, SUBAGENT_CONTROL_FRAME_KINDS, SUBAGENT_CONTROL_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_RANGE, SubagentControlClosedReason, SubagentControlFrameKind, errorResponseFrameSchema, isProtocolVersionCompatible, isSubagentControlClosedReason, isSubagentControlFrameKind, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.js';
|
|
2
|
+
export { a as ENGINE_ERROR_CODE_PREFIX, b as ENGINE_PROTOCOL_ERROR_CODES, c as ENGINE_SPAWN_DELIVERY_ERROR_CODES, d as ENGINE_SPAWN_DELIVERY_ERROR_RECOVERY, e as ENGINE_TIMEOUT_RECOVERY, f as ENGINE_TRANSPORT_ERROR_CODES, g as ENGINE_TRANSPORT_ERROR_RECOVERY, h as EngineProtocolErrorCode, E as EngineSdkError, i as EngineSpawnDeliveryErrorCode, j as EngineTransportErrorCode, k as ErrorResponseFrame, l as EventNotificationParams, N as NotificationFrame, P as ProtocolError, R as RequestFrame, m as ResponseFrame, n as ReverseRequestFrame, o as ReverseResponseResult, S as SET_MODEL_ERROR_CODES, p as SET_MODEL_NOT_ACTIVE_CODE, q as STDOUT_TAIL_ECHO_CHARS, r as SetModelErrorCode, s as SuccessResponseFrame, t as assertChatConversationSupported, u as engineConversationUnsupportedError, v as engineProtocolMismatchError, w as engineSetModelUnsupportedError, x as engineTimeoutDetail, y as isEngineErrorPassthroughCode, z as isEngineProtocolErrorCode, A as isNotificationFrame, B as isRequestFrame, C as isResponseFrame, D as isReverseRequestFrame, F as schemaEmulationFailedDetail } from './error-codes-DrNf0gwT.js';
|
|
3
|
+
export { C as CancelParams, c as CancelResult, D as DisposeParams, d as DisposeResult, b as InitializeParams, I as InitializeResult, L as ListModelsParams, e as ListModelsResult, P as PROTOCOL_METHODS, f as PingParams, g as PingResult, h as ProbeParams, i as ProtocolMethod, j as ProtocolParamsMap, k as ProtocolResultMap, l as ReadParams, R as RunContextParams, m as RunParams, n as RunResult, o as RunResumeParams, S as SetModelParams, a as SetModelResult, V as ValidateModelParams, p as ValidateModelResult } from './methods-BdIH3FwS.js';
|
|
4
|
+
export { g as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, h as AgentEventTypeName, i as AgentFailureKind, c as AgentOutcome, j as AgentOutcomeUsage, k as AgentUsage, a as AgentUsageTotal, l as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, m as EngineProcessModel, I as InternalToolCall, f as ModelCatalogEntry, M as ModelRef, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, n as ToolCall, o as ToolCallEntry, p as ToolCallResult, T as Turn, W as WorktreeHandle } from './contract-types-BUHUMF9R.js';
|
|
5
5
|
export { SCHEMA_EMULATION_TAIL_CHARS, StructuredOutputResult, buildSchemaEmulationSegment, extractAndValidateStructuredOutput } from './schema-emulation.js';
|
|
6
6
|
export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, NestedSpawnRejectedError, SpawnEnv, assertNotNestedSpawn, buildNestedSpawnEnv } from './nesting-guard.js';
|
|
7
7
|
export { CoreLogger, LogLevel, LoggerSink, configureLoggerSink, getLogger, resetLoggerSinkForTests } from './logger.js';
|
|
@@ -11,12 +11,11 @@ export { TAIJI_DATA_DIR_ENV, resetDataDirWarnForTests, resolveEngineDataDir } fr
|
|
|
11
11
|
export { resolveEngineDir, resolveEnginesRoot, resolveJournalPath, resolvePoolDir, sanitizeSeg } from './paths.js';
|
|
12
12
|
export { UiMethod, UiRequest, UiRequestHandler, UiResponse, isUiResponse } from './ui-types.js';
|
|
13
13
|
export { ChannelHandler, ExtensionUiRequestLike, ParsedChannel, UiChannelRegistry, createUiChannelRegistry, parseChannel } from './ui-channels.js';
|
|
14
|
-
export { BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, EngineChildEnvOptions,
|
|
15
|
-
export { DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS, ENGINE_ABORT_KILL_GRACE_MS, ENGINE_HOST_REQUEST_TIMEOUT_ENV, EngineChildEnv, EngineSelfDestructOptions, ReverseRequestClock, SpawnEngineChildOptions, armEngineSelfDestruct, pumpNdjsonLines, spawnEngineChild } from './spawn.js';
|
|
14
|
+
export { BuildOutboundChildEnvOptions, ENGINE_ENV_DENY_LIST, ENGINE_ENV_L0_INFRA_KEYS, ENGINE_ENV_PREFIXES, EngineChildEnvOptions, buildEngineChildEnv, buildOutboundChildEnv } from './env.js';
|
|
15
|
+
export { DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS, ENGINE_ABORT_KILL_GRACE_MS, ENGINE_HOST_REQUEST_TIMEOUT_ENV, EngineChildEnv, EngineSelfDestructOptions, KillOwnProcessGroupDeps, KillOwnProcessGroupSpawnResult, ReverseRequestClock, SpawnEngineChildOptions, armEngineSelfDestruct, killOwnProcessGroup, pumpNdjsonLines, spawnEngineChild } from './spawn.js';
|
|
16
16
|
export { ENGINE_NODE_ENV, EngineNodeHostKind, EngineNodeLaunch, EngineNodeLaunchOptions, hostKindOf, probeNodeExecutor, resetEngineNodeProbeCache, resolveEngineNodeLaunch } from './node-executor.js';
|
|
17
17
|
export { CleanupResult, DEFAULT_STDERR_KEEP_DAYS, DEFAULT_STDERR_MAX_BYTES, StderrRotationParams, cleanupSiblingStderrLogs, cleanupStaleStderrLogs, isPidAlive, rotateStderrLogIfNeeded, stderrLogPathFor, stderrLogPidOf, stderrRotationParams } from './logs/stderr-rotation.js';
|
|
18
18
|
export { ZCODE_HOST_DB_SUFFIX, ZCODE_ISOLATED_DB_SEGMENTS, ZCODE_PI_SYNCED_PROVIDER_CONFIG_SEGMENTS } from './zcode-db-paths.js';
|
|
19
|
-
export { RELAY_ENV_NODE, RELAY_ENV_RECORD_ID, RELAY_ENV_SCRIPT, RELAY_ENV_SESSION_ID, RELAY_ENV_SOCKET, RELAY_EXIT_CODES, RELAY_PROTOCOL_VERSION, isRelayActive, readRelayForwardEnv } from './relay-env.js';
|
|
20
19
|
export { toErrorMessage } from './error-message.js';
|
|
21
20
|
export { BestEffortLevel, bestEffort } from './best-effort.js';
|
|
22
21
|
export { replayJournal } from './journal-io.js';
|
|
@@ -50,38 +49,27 @@ declare const SUBAGENT_IDENTITY_ENV: {
|
|
|
50
49
|
/** worktree 隔离标志("true" = 是)。 */
|
|
51
50
|
readonly worktree: "PI_SUBAGENT_WORKTREE";
|
|
52
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* [M1 D2] 任务文本进 env 的截断上限(字符数):写入点 = pi 引擎 spawn-runner 的
|
|
54
|
+
* applyContentIdentityKeys——写 `params.task` 前 2000 字符 + 截断标记
|
|
55
|
+
* `…[truncated N chars]`;env 读取点(appendSubagentIdentityEntry)零改动(读 env 值
|
|
56
|
+
* 即用)。全文以 pi session 文件首条 user 消息与父侧 manifest 为准(manifest 主路径
|
|
57
|
+
* 保留全文;截断只影响 manifest 缺席时的重建链/P-fallback 投影,降级面逐层判定登记
|
|
58
|
+
* 见设计 D2 消费方矩阵与 §3.7)。目的:控制面(握手帧)与 execve env 不再随任务正文
|
|
59
|
+
* 线性膨胀(ARG_MAX/E2BIG 族无界暴露的写入点根因修复)。
|
|
60
|
+
*/
|
|
61
|
+
declare const PI_SUBAGENT_TASK_MAX_CHARS = 2000;
|
|
53
62
|
|
|
54
|
-
/**
|
|
55
|
-
declare const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* 据此把后续 close 的日志从 warn(kill-on-disconnect)降级为 info(reaped,正常
|
|
66
|
-
* teardown)。kill 行为本身不变(预告后 child 仍由 runtime 收割)。
|
|
67
|
-
*/
|
|
68
|
-
readonly goodbye: "goodbye";
|
|
69
|
-
};
|
|
70
|
-
/** 数据泵方向(data 帧 dir 字段词表)。 */
|
|
71
|
-
declare const RELAY_FRAME_DIRS: {
|
|
72
|
-
readonly down: "down";
|
|
73
|
-
readonly up: "up";
|
|
74
|
-
readonly upStderr: "up-stderr";
|
|
75
|
-
};
|
|
76
|
-
/** reject 帧 reason 词表(runtime→代理的拒绝理由;代理对 version 以退出码 10 应答)。 */
|
|
77
|
-
declare const RELAY_REJECT_REASONS: {
|
|
78
|
-
readonly version: "version";
|
|
79
|
-
readonly identity: "identity";
|
|
80
|
-
readonly duplicate: "duplicate";
|
|
81
|
-
readonly malformed: "malformed";
|
|
82
|
-
};
|
|
83
|
-
type RelayFrameKind = (typeof RELAY_FRAME_KINDS)[keyof typeof RELAY_FRAME_KINDS];
|
|
84
|
-
type RelayFrameDir = (typeof RELAY_FRAME_DIRS)[keyof typeof RELAY_FRAME_DIRS];
|
|
85
|
-
type RelayRejectReason = (typeof RELAY_REJECT_REASONS)[keyof typeof RELAY_REJECT_REASONS];
|
|
63
|
+
/** control socket 路径(runtime 监听 `<dataDir>/run/subagent-<pid>.sock`;Windows 为 named pipe)。 */
|
|
64
|
+
declare const CONTROL_ENV_SOCKET = "TAIJI_SUBAGENT_CONTROL_SOCKET";
|
|
65
|
+
/** 主会话根 id(runtime 注入;嵌套链所有层同值——连接归属与 channel 树的归属键)。 */
|
|
66
|
+
declare const CONTROL_ENV_ROOT_SESSION_ID = "TAIJI_SUBAGENT_CONTROL_ROOT_SESSION_ID";
|
|
67
|
+
/**
|
|
68
|
+
* transport 选择谓词(D5 选择逻辑的单一实现):SOCKET 非空 = 托管态 → runtime
|
|
69
|
+
* transport;空串/缺失 = standalone → local transport(调用方 warn)。消费方 =
|
|
70
|
+
* EngineClient transport 选择(u-m3-rt-transport);缺失即 local,不存在
|
|
71
|
+
* 「注入了一半」的中间态。
|
|
72
|
+
*/
|
|
73
|
+
declare function isControlEnvActive(env: NodeJS.ProcessEnv | Record<string, string | undefined>): boolean;
|
|
86
74
|
|
|
87
|
-
export {
|
|
75
|
+
export { CONTROL_ENV_ROOT_SESSION_ID, CONTROL_ENV_SOCKET, PI_SUBAGENT_TASK_MAX_CHARS, SUBAGENT_IDENTITY_ENV, isControlEnvActive };
|