@zhushanwen/subagent-engine-sdk 0.7.0 → 0.8.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.
Files changed (50) hide show
  1. package/dist/best-effort.cjs +9 -1
  2. package/dist/best-effort.js +2 -2
  3. package/dist/{chunk-X24IVQKJ.js → chunk-3FVBDH3X.js} +3 -2
  4. package/dist/{chunk-YL5W5EMV.js → chunk-AF2ETADP.js} +1 -1
  5. package/dist/chunk-D36ZIQQK.js +28 -0
  6. package/dist/{chunk-W23PAAGX.js → chunk-DIIYVO4O.js} +1 -27
  7. package/dist/{chunk-RCT7L777.js → chunk-F7VDVSBZ.js} +1 -1
  8. package/dist/{chunk-HERD6RIR.js → chunk-MQPASWMA.js} +2 -2
  9. package/dist/{chunk-75QEMUGV.js → chunk-NXNNXGTY.js} +10 -1
  10. package/dist/{chunk-EJMF63R5.js → chunk-QMEHSKNR.js} +1 -1
  11. package/dist/{chunk-J4G2MXDS.js → chunk-VE3NVT7K.js} +1 -1
  12. package/dist/cli-entry.cjs +9 -1
  13. package/dist/cli-entry.js +2 -2
  14. package/dist/{contract-types-DiWyGRXr.d.cts → contract-types-DqOD58r-.d.cts} +7 -12
  15. package/dist/{contract-types-DiWyGRXr.d.ts → contract-types-DqOD58r-.d.ts} +7 -12
  16. package/dist/data-dir.cjs +10 -2
  17. package/dist/data-dir.js +2 -2
  18. package/dist/env.cjs +9 -1
  19. package/dist/env.d.cts +6 -6
  20. package/dist/env.d.ts +6 -6
  21. package/dist/env.js +2 -2
  22. package/dist/error-codes-C3oVToMr.d.cts +311 -0
  23. package/dist/error-codes-CiDwaODz.d.ts +311 -0
  24. package/dist/index.cjs +41 -3
  25. package/dist/index.d.cts +31 -3
  26. package/dist/index.d.ts +31 -3
  27. package/dist/index.js +62 -31
  28. package/dist/journal-io.d.cts +1 -1
  29. package/dist/journal-io.d.ts +1 -1
  30. package/dist/journal-replay.d.cts +1 -1
  31. package/dist/journal-replay.d.ts +1 -1
  32. package/dist/kill-chain.cjs +9 -1
  33. package/dist/kill-chain.d.cts +1 -1
  34. package/dist/kill-chain.d.ts +1 -1
  35. package/dist/kill-chain.js +2 -2
  36. package/dist/logger.cjs +11 -1
  37. package/dist/logger.js +1 -1
  38. package/dist/port-contract.d.cts +12 -6
  39. package/dist/port-contract.d.ts +12 -6
  40. package/dist/protocol/index.cjs +1 -1
  41. package/dist/protocol/index.d.cts +4 -296
  42. package/dist/protocol/index.d.ts +4 -296
  43. package/dist/protocol/index.js +7 -5
  44. package/dist/server/index.cjs +217 -0
  45. package/dist/server/index.d.cts +146 -0
  46. package/dist/server/index.d.ts +146 -0
  47. package/dist/server/index.js +143 -0
  48. package/dist/spawn.cjs +9 -1
  49. package/dist/spawn.js +3 -3
  50. package/package.json +12 -1
package/dist/index.cjs CHANGED
@@ -6617,6 +6617,7 @@ __export(src_exports, {
6617
6617
  SHARED_POOL_KEY: () => SHARED_POOL_KEY,
6618
6618
  STDERR_TAIL_CHARS: () => STDERR_TAIL_CHARS,
6619
6619
  STDOUT_TAIL_ECHO_CHARS: () => STDOUT_TAIL_ECHO_CHARS,
6620
+ SUBAGENT_IDENTITY_ENV: () => SUBAGENT_IDENTITY_ENV,
6620
6621
  SUPPORTED_PROTOCOL_RANGE: () => SUPPORTED_PROTOCOL_RANGE,
6621
6622
  TAIJI_DATA_DIR_ENV: () => TAIJI_DATA_DIR_ENV,
6622
6623
  ZCODE_HOST_DB_SUFFIX: () => ZCODE_HOST_DB_SUFFIX,
@@ -6988,7 +6989,7 @@ var runSessionParamsSchema = {
6988
6989
  properties: {
6989
6990
  // ResumeAnchor.sessionRef = Record<string, string>(引擎定位键值对)
6990
6991
  sessionRef: { type: "object", additionalProperties: { type: "string" } },
6991
- journalPath: { type: "string" }
6992
+ eventsPath: { type: "string" }
6992
6993
  }
6993
6994
  }
6994
6995
  }
@@ -7151,8 +7152,16 @@ var ExecutionNestingContext = class {
7151
7152
  }
7152
7153
  };
7153
7154
 
7155
+ // src/global-slots.ts
7156
+ var ENGINE_SDK_SLOT_KEYS = {
7157
+ /** dataDir 缺省告警一次性标记(data-dir.ts)。 */
7158
+ dataDirWarned: "@zhushanwen/subagent-engine-sdk.data-dir-warned",
7159
+ /** logger sink 进程级单例(logger.ts)。 */
7160
+ loggerSink: "@zhushanwen/subagent-engine-sdk.logger-sink"
7161
+ };
7162
+
7154
7163
  // src/logger.ts
7155
- var SINK_SLOT_KEY = /* @__PURE__ */ Symbol.for("@zhushanwen/subagent-engine-sdk.logger-sink");
7164
+ var SINK_SLOT_KEY = Symbol.for(ENGINE_SDK_SLOT_KEYS.loggerSink);
7156
7165
  function getSinkSlot() {
7157
7166
  let slot = Reflect.get(globalThis, SINK_SLOT_KEY);
7158
7167
  if (!slot) {
@@ -7589,7 +7598,7 @@ function sessionIdFromHandle(handle) {
7589
7598
  // src/data-dir.ts
7590
7599
  var logger2 = getLogger("subagents");
7591
7600
  var TAIJI_DATA_DIR_ENV = "TAIJI_AGENT_DATA_DIR";
7592
- var WARNED_SLOT_KEY = /* @__PURE__ */ Symbol.for("@zhushanwen/subagent-engine-sdk.data-dir-warned");
7601
+ var WARNED_SLOT_KEY = Symbol.for(ENGINE_SDK_SLOT_KEYS.dataDirWarned);
7593
7602
  function getWarnedSlot() {
7594
7603
  let slot = Reflect.get(globalThis, WARNED_SLOT_KEY);
7595
7604
  if (!slot) {
@@ -7863,6 +7872,34 @@ function buildOutboundChildEnv(opts) {
7863
7872
  return out;
7864
7873
  }
7865
7874
 
7875
+ // src/identity-env.ts
7876
+ var SUBAGENT_IDENTITY_ENV = {
7877
+ /** 本次 run 的 record id(子进程自身身份;主/子进程判定的唯一标记)。 */
7878
+ selfRecordId: "PI_SUBAGENT_SELF_RECORD_ID",
7879
+ /** 真 ROOT 的 pi session id。 */
7880
+ rootSessionId: "PI_SUBAGENT_ROOT_SESSION_ID",
7881
+ /** 真 ROOT 的工作目录(worktree 场景下≠子进程 cwd)。 */
7882
+ rootCwd: "PI_SUBAGENT_ROOT_CWD",
7883
+ /** 执行嵌套深度(子进程 = 父进程 + 1)。 */
7884
+ depth: "PI_SUBAGENT_DEPTH",
7885
+ /** fork 链深度。 */
7886
+ forkDepth: "PI_SUBAGENT_FORK_DEPTH",
7887
+ /** 父 record id(嵌套时 = 父进程 selfRecordId)。 */
7888
+ parentRecordId: "PI_SUBAGENT_PARENT_RECORD_ID",
7889
+ /** agent 名。 */
7890
+ agent: "PI_SUBAGENT_AGENT",
7891
+ /** 任务文本。 */
7892
+ task: "PI_SUBAGENT_TASK",
7893
+ /** 执行形态(background / chat;壳读者非法值兜底 background)。 */
7894
+ mode: "PI_SUBAGENT_MODE",
7895
+ /** 短标签(可选)。 */
7896
+ slug: "PI_SUBAGENT_SLUG",
7897
+ /** 起始时刻(epoch ms;缺席回落 Date.now())。 */
7898
+ startedAt: "PI_SUBAGENT_STARTED_AT",
7899
+ /** worktree 隔离标志("true" = 是)。 */
7900
+ worktree: "PI_SUBAGENT_WORKTREE"
7901
+ };
7902
+
7866
7903
  // src/spawn.ts
7867
7904
  var import_node_child_process = require("child_process");
7868
7905
  var logger4 = getLogger("engine-sdk/spawn");
@@ -8410,6 +8447,7 @@ function runEngineCliEntry(opts) {
8410
8447
  SHARED_POOL_KEY,
8411
8448
  STDERR_TAIL_CHARS,
8412
8449
  STDOUT_TAIL_ECHO_CHARS,
8450
+ SUBAGENT_IDENTITY_ENV,
8413
8451
  SUPPORTED_PROTOCOL_RANGE,
8414
8452
  TAIJI_DATA_DIR_ENV,
8415
8453
  ZCODE_HOST_DB_SUFFIX,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- export { CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, CancelParams, CancelResult, DisposeParams, DisposeResult, ENGINE_ERROR_CODE_PREFIX, ENGINE_PROTOCOL_ERROR_CODES, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, ENGINE_TIMEOUT_RECOVERY, EngineProtocolErrorCode, EngineSdkError, ErrorResponseFrame, EventNotificationParams, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, InitializeParams, InitializeResult, ListModelsParams, ListModelsResult, NotificationFrame, PROTOCOL_METHODS, PingParams, PingResult, ProbeParams, ProtocolError, ProtocolMethod, ProtocolParamsMap, ProtocolResultMap, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReadParams, RequestFrame, ResponseFrame, ReverseChannel, ReverseRequestFrame, ReverseRequestTimeoutClass, ReverseResponseResult, RunContextParams, RunParams, RunResult, RunResumeParams, STDERR_TAIL_CHARS, STDOUT_TAIL_ECHO_CHARS, SUPPORTED_PROTOCOL_RANGE, SuccessResponseFrame, ValidateModelParams, ValidateModelResult, assertChatConversationSupported, engineConversationUnsupportedError, engineProtocolMismatchError, engineTimeoutDetail, errorResponseFrameSchema, isEngineErrorPassthroughCode, isEngineProtocolErrorCode, isNotificationFrame, isProtocolVersionCompatible, isRequestFrame, isResponseFrame, isReverseRequestFrame, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, schemaEmulationFailedDetail, successResponseFrameSchema } from './protocol/index.cjs';
2
- export { A as AGENT_EVENT_TYPE_NAMES, a as AgentCallOpts, b as AgentEvent, c as AgentEventTypeName, d as AgentFailureKind, e as AgentOutcome, f as AgentOutcomeUsage, g as AgentUsage, h as AgentUsageTotal, i as AssertMutuallyAssignable, E as EngineCapabilities, j as EngineHandleData, k as EngineProcessModel, I as InternalToolCall, M as ModelCatalogEntry, P as ProbeReport, R as ReplayedTurn, l as ResumeAnchor, S as SessionView, T as ToolCall, m as ToolCallEntry, n as ToolCallResult, o as Turn, W as WorktreeHandle } from './contract-types-DiWyGRXr.cjs';
1
+ export { CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, 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, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.cjs';
2
+ export { C as CancelParams, b as CancelResult, D as DisposeParams, c as DisposeResult, d as ENGINE_ERROR_CODE_PREFIX, e as ENGINE_PROTOCOL_ERROR_CODES, f as ENGINE_TIMEOUT_RECOVERY, g as EngineProtocolErrorCode, E as EngineSdkError, h as ErrorResponseFrame, i as EventNotificationParams, a as InitializeParams, I as InitializeResult, L as ListModelsParams, j as ListModelsResult, N as NotificationFrame, P as PROTOCOL_METHODS, k as PingParams, l as PingResult, m as ProbeParams, n as ProtocolError, o as ProtocolMethod, p as ProtocolParamsMap, q as ProtocolResultMap, r as ReadParams, s as RequestFrame, t as ResponseFrame, u as ReverseRequestFrame, v as ReverseResponseResult, R as RunContextParams, w as RunParams, x as RunResult, y as RunResumeParams, S as STDOUT_TAIL_ECHO_CHARS, z as SuccessResponseFrame, V as ValidateModelParams, A as ValidateModelResult, B as assertChatConversationSupported, F as engineConversationUnsupportedError, G as engineProtocolMismatchError, H as engineTimeoutDetail, J as isEngineErrorPassthroughCode, K as isEngineProtocolErrorCode, M as isNotificationFrame, O as isRequestFrame, Q as isResponseFrame, T as isReverseRequestFrame, U as schemaEmulationFailedDetail } from './error-codes-C3oVToMr.cjs';
3
+ export { f as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, g as AgentEventTypeName, h as AgentFailureKind, c as AgentOutcome, i as AgentOutcomeUsage, j as AgentUsage, a as AgentUsageTotal, k as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, l as EngineProcessModel, I as InternalToolCall, M as ModelCatalogEntry, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, m as ToolCall, n as ToolCallEntry, o as ToolCallResult, T as Turn, W as WorktreeHandle } from './contract-types-DqOD58r-.cjs';
3
4
  export { SCHEMA_EMULATION_TAIL_CHARS, StructuredOutputResult, buildSchemaEmulationSegment, extractAndValidateStructuredOutput } from './schema-emulation.cjs';
4
5
  export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, NestedSpawnRejectedError, SpawnEnv, assertNotNestedSpawn, buildNestedSpawnEnv } from './nesting-guard.cjs';
5
6
  export { CoreLogger, LogLevel, LoggerSink, configureLoggerSink, getLogger, resetLoggerSinkForTests } from './logger.cjs';
@@ -22,6 +23,33 @@ export { EngineAgentCallOpts, EngineCtxModel, EngineHandle, EnginePort, EngineRu
22
23
  export { CliProtocolServerSink, RunEngineCliEntryOptions, runEngineCliEntry } from './cli-entry.cjs';
23
24
  import 'node:child_process';
24
25
 
26
+ declare const SUBAGENT_IDENTITY_ENV: {
27
+ /** 本次 run 的 record id(子进程自身身份;主/子进程判定的唯一标记)。 */
28
+ readonly selfRecordId: "PI_SUBAGENT_SELF_RECORD_ID";
29
+ /** 真 ROOT 的 pi session id。 */
30
+ readonly rootSessionId: "PI_SUBAGENT_ROOT_SESSION_ID";
31
+ /** 真 ROOT 的工作目录(worktree 场景下≠子进程 cwd)。 */
32
+ readonly rootCwd: "PI_SUBAGENT_ROOT_CWD";
33
+ /** 执行嵌套深度(子进程 = 父进程 + 1)。 */
34
+ readonly depth: "PI_SUBAGENT_DEPTH";
35
+ /** fork 链深度。 */
36
+ readonly forkDepth: "PI_SUBAGENT_FORK_DEPTH";
37
+ /** 父 record id(嵌套时 = 父进程 selfRecordId)。 */
38
+ readonly parentRecordId: "PI_SUBAGENT_PARENT_RECORD_ID";
39
+ /** agent 名。 */
40
+ readonly agent: "PI_SUBAGENT_AGENT";
41
+ /** 任务文本。 */
42
+ readonly task: "PI_SUBAGENT_TASK";
43
+ /** 执行形态(background / chat;壳读者非法值兜底 background)。 */
44
+ readonly mode: "PI_SUBAGENT_MODE";
45
+ /** 短标签(可选)。 */
46
+ readonly slug: "PI_SUBAGENT_SLUG";
47
+ /** 起始时刻(epoch ms;缺席回落 Date.now())。 */
48
+ readonly startedAt: "PI_SUBAGENT_STARTED_AT";
49
+ /** worktree 隔离标志("true" = 是)。 */
50
+ readonly worktree: "PI_SUBAGENT_WORKTREE";
51
+ };
52
+
25
53
  /** 帧类型判别值(kind 字段词表)。as const 值即字面量类型——类型位置同样可用。 */
26
54
  declare const RELAY_FRAME_KINDS: {
27
55
  readonly handshake: "handshake";
@@ -55,4 +83,4 @@ type RelayFrameKind = (typeof RELAY_FRAME_KINDS)[keyof typeof RELAY_FRAME_KINDS]
55
83
  type RelayFrameDir = (typeof RELAY_FRAME_DIRS)[keyof typeof RELAY_FRAME_DIRS];
56
84
  type RelayRejectReason = (typeof RELAY_REJECT_REASONS)[keyof typeof RELAY_REJECT_REASONS];
57
85
 
58
- export { RELAY_FRAME_DIRS, RELAY_FRAME_KINDS, RELAY_REJECT_REASONS, type RelayFrameDir, type RelayFrameKind, type RelayRejectReason };
86
+ export { RELAY_FRAME_DIRS, RELAY_FRAME_KINDS, RELAY_REJECT_REASONS, type RelayFrameDir, type RelayFrameKind, type RelayRejectReason, SUBAGENT_IDENTITY_ENV };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export { CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, CancelParams, CancelResult, DisposeParams, DisposeResult, ENGINE_ERROR_CODE_PREFIX, ENGINE_PROTOCOL_ERROR_CODES, ENGINE_PROTOCOL_SCHEMAS, ENGINE_PROTOCOL_VERSION, ENGINE_TIMEOUT_RECOVERY, EngineProtocolErrorCode, EngineSdkError, ErrorResponseFrame, EventNotificationParams, FORBIDDEN_CREDENTIAL_KEY_FRAGMENTS, HANDSHAKE_TIMEOUT_MS, HostAskUserParams, HostAskUserResult, HostChildSpawnedParams, HostChildStateChangedParams, HostHandleReadyParams, HostLogParams, HostStreamDeltaParams, InitializeParams, InitializeResult, ListModelsParams, ListModelsResult, NotificationFrame, PROTOCOL_METHODS, PingParams, PingResult, ProbeParams, ProtocolError, ProtocolMethod, ProtocolParamsMap, ProtocolResultMap, REVERSE_CHANNELS, REVERSE_CHANNEL_TIMEOUT_CLASS, REVERSE_REQUEST_TIMEOUT_MS, ReadParams, RequestFrame, ResponseFrame, ReverseChannel, ReverseRequestFrame, ReverseRequestTimeoutClass, ReverseResponseResult, RunContextParams, RunParams, RunResult, RunResumeParams, STDERR_TAIL_CHARS, STDOUT_TAIL_ECHO_CHARS, SUPPORTED_PROTOCOL_RANGE, SuccessResponseFrame, ValidateModelParams, ValidateModelResult, assertChatConversationSupported, engineConversationUnsupportedError, engineProtocolMismatchError, engineTimeoutDetail, errorResponseFrameSchema, isEngineErrorPassthroughCode, isEngineProtocolErrorCode, isNotificationFrame, isProtocolVersionCompatible, isRequestFrame, isResponseFrame, isReverseRequestFrame, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, schemaEmulationFailedDetail, successResponseFrameSchema } from './protocol/index.js';
2
- export { A as AGENT_EVENT_TYPE_NAMES, a as AgentCallOpts, b as AgentEvent, c as AgentEventTypeName, d as AgentFailureKind, e as AgentOutcome, f as AgentOutcomeUsage, g as AgentUsage, h as AgentUsageTotal, i as AssertMutuallyAssignable, E as EngineCapabilities, j as EngineHandleData, k as EngineProcessModel, I as InternalToolCall, M as ModelCatalogEntry, P as ProbeReport, R as ReplayedTurn, l as ResumeAnchor, S as SessionView, T as ToolCall, m as ToolCallEntry, n as ToolCallResult, o as Turn, W as WorktreeHandle } from './contract-types-DiWyGRXr.js';
1
+ export { CANCEL_SETTLE_GRACE_MS, CRASH_REBUILD_BACKOFF_MS, CRASH_REBUILD_MAX_ATTEMPTS, 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, STDERR_TAIL_CHARS, SUPPORTED_PROTOCOL_RANGE, errorResponseFrameSchema, isProtocolVersionCompatible, notificationFrameSchema, protocolErrorSchema, requestFrameSchema, reverseRequestFrameSchema, runSessionParamsSchema, successResponseFrameSchema } from './protocol/index.js';
2
+ export { C as CancelParams, b as CancelResult, D as DisposeParams, c as DisposeResult, d as ENGINE_ERROR_CODE_PREFIX, e as ENGINE_PROTOCOL_ERROR_CODES, f as ENGINE_TIMEOUT_RECOVERY, g as EngineProtocolErrorCode, E as EngineSdkError, h as ErrorResponseFrame, i as EventNotificationParams, a as InitializeParams, I as InitializeResult, L as ListModelsParams, j as ListModelsResult, N as NotificationFrame, P as PROTOCOL_METHODS, k as PingParams, l as PingResult, m as ProbeParams, n as ProtocolError, o as ProtocolMethod, p as ProtocolParamsMap, q as ProtocolResultMap, r as ReadParams, s as RequestFrame, t as ResponseFrame, u as ReverseRequestFrame, v as ReverseResponseResult, R as RunContextParams, w as RunParams, x as RunResult, y as RunResumeParams, S as STDOUT_TAIL_ECHO_CHARS, z as SuccessResponseFrame, V as ValidateModelParams, A as ValidateModelResult, B as assertChatConversationSupported, F as engineConversationUnsupportedError, G as engineProtocolMismatchError, H as engineTimeoutDetail, J as isEngineErrorPassthroughCode, K as isEngineProtocolErrorCode, M as isNotificationFrame, O as isRequestFrame, Q as isResponseFrame, T as isReverseRequestFrame, U as schemaEmulationFailedDetail } from './error-codes-CiDwaODz.js';
3
+ export { f as AGENT_EVENT_TYPE_NAMES, b as AgentCallOpts, A as AgentEvent, g as AgentEventTypeName, h as AgentFailureKind, c as AgentOutcome, i as AgentOutcomeUsage, j as AgentUsage, a as AgentUsageTotal, k as AssertMutuallyAssignable, d as EngineCapabilities, E as EngineHandleData, l as EngineProcessModel, I as InternalToolCall, M as ModelCatalogEntry, P as ProbeReport, R as ReplayedTurn, e as ResumeAnchor, S as SessionView, m as ToolCall, n as ToolCallEntry, o as ToolCallResult, T as Turn, W as WorktreeHandle } from './contract-types-DqOD58r-.js';
3
4
  export { SCHEMA_EMULATION_TAIL_CHARS, StructuredOutputResult, buildSchemaEmulationSegment, extractAndValidateStructuredOutput } from './schema-emulation.js';
4
5
  export { ExecutionNestingContext, ExecutionNestingState, NESTED_SPAWN_ENV, NestedSpawnRejectedError, SpawnEnv, assertNotNestedSpawn, buildNestedSpawnEnv } from './nesting-guard.js';
5
6
  export { CoreLogger, LogLevel, LoggerSink, configureLoggerSink, getLogger, resetLoggerSinkForTests } from './logger.js';
@@ -22,6 +23,33 @@ export { EngineAgentCallOpts, EngineCtxModel, EngineHandle, EnginePort, EngineRu
22
23
  export { CliProtocolServerSink, RunEngineCliEntryOptions, runEngineCliEntry } from './cli-entry.js';
23
24
  import 'node:child_process';
24
25
 
26
+ declare const SUBAGENT_IDENTITY_ENV: {
27
+ /** 本次 run 的 record id(子进程自身身份;主/子进程判定的唯一标记)。 */
28
+ readonly selfRecordId: "PI_SUBAGENT_SELF_RECORD_ID";
29
+ /** 真 ROOT 的 pi session id。 */
30
+ readonly rootSessionId: "PI_SUBAGENT_ROOT_SESSION_ID";
31
+ /** 真 ROOT 的工作目录(worktree 场景下≠子进程 cwd)。 */
32
+ readonly rootCwd: "PI_SUBAGENT_ROOT_CWD";
33
+ /** 执行嵌套深度(子进程 = 父进程 + 1)。 */
34
+ readonly depth: "PI_SUBAGENT_DEPTH";
35
+ /** fork 链深度。 */
36
+ readonly forkDepth: "PI_SUBAGENT_FORK_DEPTH";
37
+ /** 父 record id(嵌套时 = 父进程 selfRecordId)。 */
38
+ readonly parentRecordId: "PI_SUBAGENT_PARENT_RECORD_ID";
39
+ /** agent 名。 */
40
+ readonly agent: "PI_SUBAGENT_AGENT";
41
+ /** 任务文本。 */
42
+ readonly task: "PI_SUBAGENT_TASK";
43
+ /** 执行形态(background / chat;壳读者非法值兜底 background)。 */
44
+ readonly mode: "PI_SUBAGENT_MODE";
45
+ /** 短标签(可选)。 */
46
+ readonly slug: "PI_SUBAGENT_SLUG";
47
+ /** 起始时刻(epoch ms;缺席回落 Date.now())。 */
48
+ readonly startedAt: "PI_SUBAGENT_STARTED_AT";
49
+ /** worktree 隔离标志("true" = 是)。 */
50
+ readonly worktree: "PI_SUBAGENT_WORKTREE";
51
+ };
52
+
25
53
  /** 帧类型判别值(kind 字段词表)。as const 值即字面量类型——类型位置同样可用。 */
26
54
  declare const RELAY_FRAME_KINDS: {
27
55
  readonly handshake: "handshake";
@@ -55,4 +83,4 @@ type RelayFrameKind = (typeof RELAY_FRAME_KINDS)[keyof typeof RELAY_FRAME_KINDS]
55
83
  type RelayFrameDir = (typeof RELAY_FRAME_DIRS)[keyof typeof RELAY_FRAME_DIRS];
56
84
  type RelayRejectReason = (typeof RELAY_REJECT_REASONS)[keyof typeof RELAY_REJECT_REASONS];
57
85
 
58
- export { RELAY_FRAME_DIRS, RELAY_FRAME_KINDS, RELAY_REJECT_REASONS, type RelayFrameDir, type RelayFrameKind, type RelayRejectReason };
86
+ export { RELAY_FRAME_DIRS, RELAY_FRAME_KINDS, RELAY_REJECT_REASONS, type RelayFrameDir, type RelayFrameKind, type RelayRejectReason, SUBAGENT_IDENTITY_ENV };
package/dist/index.js CHANGED
@@ -1,6 +1,17 @@
1
+ import {
2
+ RELAY_ENV_NODE,
3
+ RELAY_ENV_RECORD_ID,
4
+ RELAY_ENV_SCRIPT,
5
+ RELAY_ENV_SESSION_ID,
6
+ RELAY_ENV_SOCKET,
7
+ RELAY_EXIT_CODES,
8
+ RELAY_PROTOCOL_VERSION,
9
+ isRelayActive,
10
+ readRelayForwardEnv
11
+ } from "./chunk-GSW3DMN6.js";
1
12
  import {
2
13
  bestEffort
3
- } from "./chunk-EJMF63R5.js";
14
+ } from "./chunk-QMEHSKNR.js";
4
15
  import {
5
16
  replayJournal
6
17
  } from "./chunk-RDH3ZOV6.js";
@@ -10,11 +21,16 @@ import {
10
21
  } from "./chunk-LQR73V67.js";
11
22
  import {
12
23
  runEngineCliEntry
13
- } from "./chunk-J4G2MXDS.js";
24
+ } from "./chunk-VE3NVT7K.js";
14
25
  import {
15
26
  ZCODE_HOST_DB_SUFFIX,
16
27
  ZCODE_ISOLATED_DB_SEGMENTS
17
28
  } from "./chunk-CT3FEBDO.js";
29
+ import {
30
+ TAIJI_DATA_DIR_ENV,
31
+ resetDataDirWarnForTests,
32
+ resolveEngineDataDir
33
+ } from "./chunk-3FVBDH3X.js";
18
34
  import {
19
35
  resolveEngineDir,
20
36
  resolveEnginesRoot,
@@ -35,7 +51,7 @@ import {
35
51
  ENGINE_ENV_PREFIXES,
36
52
  buildEngineChildEnv,
37
53
  buildOutboundChildEnv
38
- } from "./chunk-YL5W5EMV.js";
54
+ } from "./chunk-AF2ETADP.js";
39
55
  import {
40
56
  DEFAULT_ENGINE_HOST_REQUEST_TIMEOUT_MS,
41
57
  ENGINE_ABORT_KILL_GRACE_MS,
@@ -43,7 +59,7 @@ import {
43
59
  armEngineSelfDestruct,
44
60
  pumpNdjsonLines,
45
61
  spawnEngineChild
46
- } from "./chunk-HERD6RIR.js";
62
+ } from "./chunk-MQPASWMA.js";
47
63
  import {
48
64
  ENGINE_NODE_ENV,
49
65
  hostKindOf,
@@ -62,17 +78,6 @@ import {
62
78
  stderrLogPidOf,
63
79
  stderrRotationParams
64
80
  } from "./chunk-MSAJXIP4.js";
65
- import {
66
- RELAY_ENV_NODE,
67
- RELAY_ENV_RECORD_ID,
68
- RELAY_ENV_SCRIPT,
69
- RELAY_ENV_SESSION_ID,
70
- RELAY_ENV_SOCKET,
71
- RELAY_EXIT_CODES,
72
- RELAY_PROTOCOL_VERSION,
73
- isRelayActive,
74
- readRelayForwardEnv
75
- } from "./chunk-GSW3DMN6.js";
76
81
  import {
77
82
  AGENT_EVENT_TYPE_NAMES,
78
83
  ENGINE_PROTOCOL_SCHEMAS,
@@ -81,17 +86,19 @@ import {
81
86
  REVERSE_CHANNELS,
82
87
  REVERSE_CHANNEL_TIMEOUT_CLASS,
83
88
  errorResponseFrameSchema,
84
- isNotificationFrame,
85
- isRequestFrame,
86
- isResponseFrame,
87
- isReverseRequestFrame,
88
89
  notificationFrameSchema,
89
90
  protocolErrorSchema,
90
91
  requestFrameSchema,
91
92
  reverseRequestFrameSchema,
92
93
  runSessionParamsSchema,
93
94
  successResponseFrameSchema
94
- } from "./chunk-W23PAAGX.js";
95
+ } from "./chunk-DIIYVO4O.js";
96
+ import {
97
+ isNotificationFrame,
98
+ isRequestFrame,
99
+ isResponseFrame,
100
+ isReverseRequestFrame
101
+ } from "./chunk-D36ZIQQK.js";
95
102
  import {
96
103
  SCHEMA_EMULATION_TAIL_CHARS,
97
104
  buildSchemaEmulationSegment,
@@ -114,7 +121,7 @@ import {
114
121
  probePidAlive,
115
122
  safeKill,
116
123
  synthesizeTimeoutOutcome
117
- } from "./chunk-RCT7L777.js";
124
+ } from "./chunk-F7VDVSBZ.js";
118
125
  import {
119
126
  toErrorMessage
120
127
  } from "./chunk-PYO3YR7W.js";
@@ -141,6 +148,11 @@ import {
141
148
  isProtocolVersionCompatible,
142
149
  schemaEmulationFailedDetail
143
150
  } from "./chunk-SFNTX7Q3.js";
151
+ import {
152
+ configureLoggerSink,
153
+ getLogger,
154
+ resetLoggerSinkForTests
155
+ } from "./chunk-NXNNXGTY.js";
144
156
  import {
145
157
  aggregateUsage,
146
158
  createReplayRecord,
@@ -149,18 +161,36 @@ import {
149
161
  toReplayedTurn,
150
162
  updateFromEvent
151
163
  } from "./chunk-SGAIDL63.js";
152
- import {
153
- TAIJI_DATA_DIR_ENV,
154
- resetDataDirWarnForTests,
155
- resolveEngineDataDir
156
- } from "./chunk-X24IVQKJ.js";
157
- import {
158
- configureLoggerSink,
159
- getLogger,
160
- resetLoggerSinkForTests
161
- } from "./chunk-75QEMUGV.js";
162
164
  import "./chunk-JSBRDJBE.js";
163
165
 
166
+ // src/identity-env.ts
167
+ var SUBAGENT_IDENTITY_ENV = {
168
+ /** 本次 run 的 record id(子进程自身身份;主/子进程判定的唯一标记)。 */
169
+ selfRecordId: "PI_SUBAGENT_SELF_RECORD_ID",
170
+ /** 真 ROOT 的 pi session id。 */
171
+ rootSessionId: "PI_SUBAGENT_ROOT_SESSION_ID",
172
+ /** 真 ROOT 的工作目录(worktree 场景下≠子进程 cwd)。 */
173
+ rootCwd: "PI_SUBAGENT_ROOT_CWD",
174
+ /** 执行嵌套深度(子进程 = 父进程 + 1)。 */
175
+ depth: "PI_SUBAGENT_DEPTH",
176
+ /** fork 链深度。 */
177
+ forkDepth: "PI_SUBAGENT_FORK_DEPTH",
178
+ /** 父 record id(嵌套时 = 父进程 selfRecordId)。 */
179
+ parentRecordId: "PI_SUBAGENT_PARENT_RECORD_ID",
180
+ /** agent 名。 */
181
+ agent: "PI_SUBAGENT_AGENT",
182
+ /** 任务文本。 */
183
+ task: "PI_SUBAGENT_TASK",
184
+ /** 执行形态(background / chat;壳读者非法值兜底 background)。 */
185
+ mode: "PI_SUBAGENT_MODE",
186
+ /** 短标签(可选)。 */
187
+ slug: "PI_SUBAGENT_SLUG",
188
+ /** 起始时刻(epoch ms;缺席回落 Date.now())。 */
189
+ startedAt: "PI_SUBAGENT_STARTED_AT",
190
+ /** worktree 隔离标志("true" = 是)。 */
191
+ worktree: "PI_SUBAGENT_WORKTREE"
192
+ };
193
+
164
194
  // src/relay-frames.ts
165
195
  var RELAY_FRAME_KINDS = {
166
196
  handshake: "handshake",
@@ -234,6 +264,7 @@ export {
234
264
  SHARED_POOL_KEY,
235
265
  STDERR_TAIL_CHARS,
236
266
  STDOUT_TAIL_ECHO_CHARS,
267
+ SUBAGENT_IDENTITY_ENV,
237
268
  SUPPORTED_PROTOCOL_RANGE,
238
269
  TAIJI_DATA_DIR_ENV,
239
270
  ZCODE_HOST_DB_SUFFIX,
@@ -1,4 +1,4 @@
1
- import { b as AgentEvent } from './contract-types-DiWyGRXr.cjs';
1
+ import { A as AgentEvent } from './contract-types-DqOD58r-.cjs';
2
2
 
3
3
  /**
4
4
  * 重放 journal:读取路径下全部事件,重放即得 AgentEvent 流(read 第②级)。
@@ -1,4 +1,4 @@
1
- import { b as AgentEvent } from './contract-types-DiWyGRXr.js';
1
+ import { A as AgentEvent } from './contract-types-DqOD58r-.js';
2
2
 
3
3
  /**
4
4
  * 重放 journal:读取路径下全部事件,重放即得 AgentEvent 流(read 第②级)。
@@ -1,4 +1,4 @@
1
- import { o as Turn, h as AgentUsageTotal, b as AgentEvent, S as SessionView, j as EngineHandleData, R as ReplayedTurn } from './contract-types-DiWyGRXr.cjs';
1
+ import { T as Turn, a as AgentUsageTotal, A as AgentEvent, S as SessionView, E as EngineHandleData, R as ReplayedTurn } from './contract-types-DqOD58r-.cjs';
2
2
 
3
3
  /**
4
4
  * reducer 的 record 视图(core ExecutionRecord 的结构子集:reducer 只触碰这四个字段)。
@@ -1,4 +1,4 @@
1
- import { o as Turn, h as AgentUsageTotal, b as AgentEvent, S as SessionView, j as EngineHandleData, R as ReplayedTurn } from './contract-types-DiWyGRXr.js';
1
+ import { T as Turn, a as AgentUsageTotal, A as AgentEvent, S as SessionView, E as EngineHandleData, R as ReplayedTurn } from './contract-types-DqOD58r-.js';
2
2
 
3
3
  /**
4
4
  * reducer 的 record 视图(core ExecutionRecord 的结构子集:reducer 只触碰这四个字段)。
@@ -32,8 +32,16 @@ __export(kill_chain_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(kill_chain_exports);
34
34
 
35
+ // src/global-slots.ts
36
+ var ENGINE_SDK_SLOT_KEYS = {
37
+ /** dataDir 缺省告警一次性标记(data-dir.ts)。 */
38
+ dataDirWarned: "@zhushanwen/subagent-engine-sdk.data-dir-warned",
39
+ /** logger sink 进程级单例(logger.ts)。 */
40
+ loggerSink: "@zhushanwen/subagent-engine-sdk.logger-sink"
41
+ };
42
+
35
43
  // src/logger.ts
36
- var SINK_SLOT_KEY = /* @__PURE__ */ Symbol.for("@zhushanwen/subagent-engine-sdk.logger-sink");
44
+ var SINK_SLOT_KEY = Symbol.for(ENGINE_SDK_SLOT_KEYS.loggerSink);
37
45
  function getSinkSlot() {
38
46
  let slot = Reflect.get(globalThis, SINK_SLOT_KEY);
39
47
  if (!slot) {
@@ -1,4 +1,4 @@
1
- import { a as AgentCallOpts, e as AgentOutcome } from './contract-types-DiWyGRXr.cjs';
1
+ import { b as AgentCallOpts, c as AgentOutcome } from './contract-types-DqOD58r-.cjs';
2
2
 
3
3
  /**
4
4
  * 可杀子进程的结构形状(Node ChildProcess 的结构子集)。
@@ -1,4 +1,4 @@
1
- import { a as AgentCallOpts, e as AgentOutcome } from './contract-types-DiWyGRXr.js';
1
+ import { b as AgentCallOpts, c as AgentOutcome } from './contract-types-DqOD58r-.js';
2
2
 
3
3
  /**
4
4
  * 可杀子进程的结构形状(Node ChildProcess 的结构子集)。
@@ -8,10 +8,10 @@ import {
8
8
  probePidAlive,
9
9
  safeKill,
10
10
  synthesizeTimeoutOutcome
11
- } from "./chunk-RCT7L777.js";
11
+ } from "./chunk-F7VDVSBZ.js";
12
12
  import "./chunk-PYO3YR7W.js";
13
13
  import "./chunk-SFNTX7Q3.js";
14
- import "./chunk-75QEMUGV.js";
14
+ import "./chunk-NXNNXGTY.js";
15
15
  import "./chunk-JSBRDJBE.js";
16
16
  export {
17
17
  DEFAULT_KILL_GRACE_MS,
package/dist/logger.cjs CHANGED
@@ -25,7 +25,17 @@ __export(logger_exports, {
25
25
  resetLoggerSinkForTests: () => resetLoggerSinkForTests
26
26
  });
27
27
  module.exports = __toCommonJS(logger_exports);
28
- var SINK_SLOT_KEY = /* @__PURE__ */ Symbol.for("@zhushanwen/subagent-engine-sdk.logger-sink");
28
+
29
+ // src/global-slots.ts
30
+ var ENGINE_SDK_SLOT_KEYS = {
31
+ /** dataDir 缺省告警一次性标记(data-dir.ts)。 */
32
+ dataDirWarned: "@zhushanwen/subagent-engine-sdk.data-dir-warned",
33
+ /** logger sink 进程级单例(logger.ts)。 */
34
+ loggerSink: "@zhushanwen/subagent-engine-sdk.logger-sink"
35
+ };
36
+
37
+ // src/logger.ts
38
+ var SINK_SLOT_KEY = Symbol.for(ENGINE_SDK_SLOT_KEYS.loggerSink);
29
39
  function getSinkSlot() {
30
40
  let slot = Reflect.get(globalThis, SINK_SLOT_KEY);
31
41
  if (!slot) {
package/dist/logger.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  configureLoggerSink,
3
3
  getLogger,
4
4
  resetLoggerSinkForTests
5
- } from "./chunk-75QEMUGV.js";
5
+ } from "./chunk-NXNNXGTY.js";
6
6
  import "./chunk-JSBRDJBE.js";
7
7
  export {
8
8
  configureLoggerSink,
@@ -1,4 +1,4 @@
1
- import { a as AgentCallOpts, j as EngineHandleData, E as EngineCapabilities, P as ProbeReport, b as AgentEvent, l as ResumeAnchor, e as AgentOutcome, S as SessionView } from './contract-types-DiWyGRXr.cjs';
1
+ import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-DqOD58r-.cjs';
2
2
 
3
3
  /**
4
4
  * 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
@@ -31,7 +31,7 @@ interface EngineStream {
31
31
  * 本值(pi / zcode 均无池化实现——pi = PI_CODING_AGENT_DIR 全局一份,zcode = 共享
32
32
  * 宿主 HOME)。[池抽象降级 2026-09-13] poolKey 协议面(RunContext/run.params.ctx/
33
33
  * host/poolResolved 通道/EngineHandleData)已整体退役,本常量不再跨进程透传,仅
34
- * 三类消费:① journal 落盘路径构造(core journal-wiring);② 存量 record 兼容
34
+ * 三类消费:① journal 落盘路径构造(core event-journal-wiring);② 存量 record 兼容
35
35
  * (zcode read 旧相对 dbPath 的锚定分支 + 持久化 engineHandle.poolKey 字段——
36
36
  * record-store 读侧守卫要求非空,值恒本常量);③ 引擎数据目录布局 SSOT paths.ts
37
37
  * 的签名参数。**值逐字不变**(存量 journal 落盘路径与记录含该值分段,改名不改值)。
@@ -44,10 +44,6 @@ interface RunContext {
44
44
  onEvent?: (event: AgentEvent) => void;
45
45
  ctxModel?: EngineCtxModel;
46
46
  stream?: EngineStream;
47
- engineFallback?: {
48
- from: string;
49
- reason: string;
50
- };
51
47
  /**
52
48
  * [F6] 根 session id(协议 run.params.ctx.sessionRootId 的进程内还原)——pi 引擎
53
49
  * relay 归属键 SESSION_ID 的权威来源。additive 可选:宿主缺省不传。
@@ -67,6 +63,16 @@ interface RunContext {
67
63
  * 恒无扩展 flag)。additive 可选:宿主缺省不传。
68
64
  */
69
65
  extensionPaths?: string[];
66
+ /**
67
+ * [D4 record 身份信封] 协议 `run.params.ctx.identity` 的进程内还原——引擎把它整封
68
+ * 写进任务子进程的身份 env(`SUBAGENT_IDENTITY_ENV` 的 slug / startedAt / mode)。
69
+ * additive 可选:宿主缺省不传时引擎不写这三个键,读者按回落语义工作。
70
+ */
71
+ identity?: {
72
+ slug?: string;
73
+ startedAt?: number;
74
+ mode?: string;
75
+ };
70
76
  onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef">) => void;
71
77
  /** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
72
78
  onChildSpawned?: (child: {
@@ -1,4 +1,4 @@
1
- import { a as AgentCallOpts, j as EngineHandleData, E as EngineCapabilities, P as ProbeReport, b as AgentEvent, l as ResumeAnchor, e as AgentOutcome, S as SessionView } from './contract-types-DiWyGRXr.js';
1
+ import { b as AgentCallOpts, E as EngineHandleData, d as EngineCapabilities, P as ProbeReport, A as AgentEvent, e as ResumeAnchor, c as AgentOutcome, S as SessionView } from './contract-types-DqOD58r-.js';
2
2
 
3
3
  /**
4
4
  * 引擎进程内全量任务声明 = SDK AgentCallOpts 引擎面子集 + 协议 ctx 还原字段(model/
@@ -31,7 +31,7 @@ interface EngineStream {
31
31
  * 本值(pi / zcode 均无池化实现——pi = PI_CODING_AGENT_DIR 全局一份,zcode = 共享
32
32
  * 宿主 HOME)。[池抽象降级 2026-09-13] poolKey 协议面(RunContext/run.params.ctx/
33
33
  * host/poolResolved 通道/EngineHandleData)已整体退役,本常量不再跨进程透传,仅
34
- * 三类消费:① journal 落盘路径构造(core journal-wiring);② 存量 record 兼容
34
+ * 三类消费:① journal 落盘路径构造(core event-journal-wiring);② 存量 record 兼容
35
35
  * (zcode read 旧相对 dbPath 的锚定分支 + 持久化 engineHandle.poolKey 字段——
36
36
  * record-store 读侧守卫要求非空,值恒本常量);③ 引擎数据目录布局 SSOT paths.ts
37
37
  * 的签名参数。**值逐字不变**(存量 journal 落盘路径与记录含该值分段,改名不改值)。
@@ -44,10 +44,6 @@ interface RunContext {
44
44
  onEvent?: (event: AgentEvent) => void;
45
45
  ctxModel?: EngineCtxModel;
46
46
  stream?: EngineStream;
47
- engineFallback?: {
48
- from: string;
49
- reason: string;
50
- };
51
47
  /**
52
48
  * [F6] 根 session id(协议 run.params.ctx.sessionRootId 的进程内还原)——pi 引擎
53
49
  * relay 归属键 SESSION_ID 的权威来源。additive 可选:宿主缺省不传。
@@ -67,6 +63,16 @@ interface RunContext {
67
63
  * 恒无扩展 flag)。additive 可选:宿主缺省不传。
68
64
  */
69
65
  extensionPaths?: string[];
66
+ /**
67
+ * [D4 record 身份信封] 协议 `run.params.ctx.identity` 的进程内还原——引擎把它整封
68
+ * 写进任务子进程的身份 env(`SUBAGENT_IDENTITY_ENV` 的 slug / startedAt / mode)。
69
+ * additive 可选:宿主缺省不传时引擎不写这三个键,读者按回落语义工作。
70
+ */
71
+ identity?: {
72
+ slug?: string;
73
+ startedAt?: number;
74
+ mode?: string;
75
+ };
70
76
  onHandleReady?: (partial: Pick<EngineHandleData, "sessionRef">) => void;
71
77
  /** 一次性子进程 pid 上报(host/childSpawned 载荷形态;ChildProcess 句柄不跨协议面)。 */
72
78
  onChildSpawned?: (child: {
@@ -354,7 +354,7 @@ var runSessionParamsSchema = {
354
354
  properties: {
355
355
  // ResumeAnchor.sessionRef = Record<string, string>(引擎定位键值对)
356
356
  sessionRef: { type: "object", additionalProperties: { type: "string" } },
357
- journalPath: { type: "string" }
357
+ eventsPath: { type: "string" }
358
358
  }
359
359
  }
360
360
  }