@openclaw/codex 2026.9.2 → 2026.9.4

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 (120) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +29 -26
  3. package/dist/apply-CvT8tW5i.js +356 -0
  4. package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-DKHzbwt5.js} +38 -214
  5. package/dist/{attempt-context-CSazkWns.js → attempt-context-D44yeDII.js} +9 -7
  6. package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications-C9XufG6l.js} +3 -106
  7. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-CWlKVccJ.js} +2 -2
  8. package/dist/auth-cache-key-7orQae_j.js +498 -0
  9. package/dist/auth-profile-CwzO4_RG.js +43 -0
  10. package/dist/auth-profile-selection-DFu9e167.js +45 -0
  11. package/dist/binding-connection-D3udKbIE.js +60 -0
  12. package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-C_Hneydj.js} +28 -125
  13. package/dist/build-state-BCmg9-5p.js +19 -0
  14. package/dist/{capabilities-B1mgvpP8.js → capabilities-8vx68WLH.js} +1 -1
  15. package/dist/cli-metadata.js +1 -1
  16. package/dist/client-B57KWPQx.js +4005 -0
  17. package/dist/command-dispatch-BpduNGVf.js +21 -0
  18. package/dist/{command-formatters-DSbGMXA0.js → command-formatters-lxlkNZgU.js} +4 -3
  19. package/dist/{command-handlers-DOJvGv6-.js → command-handlers-tiL9iWj7.js} +788 -135
  20. package/dist/command-rpc-CR5EOEZX.js +233 -0
  21. package/dist/{compact-Y_xBqrHN.js → compact-B_H3AOd7.js} +19 -14
  22. package/dist/config-oIORaQ5T.js +106 -0
  23. package/dist/{config-CyapYSji.js → config-options-CXMq1T-C.js} +205 -593
  24. package/dist/config-runtime-D0zGNIHu.js +11 -0
  25. package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
  26. package/dist/conversation-binding-DsB4-O7U.js +900 -0
  27. package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CtUu1b3m.js} +11 -143
  28. package/dist/doctor-contract-api.js +5 -5
  29. package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-CmN5RAip.js} +133 -76
  30. package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
  31. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  32. package/dist/ephemeral-turn-D78_VmzO.js +101 -0
  33. package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
  34. package/dist/event-projector-items-5VhsECCO.js +200 -0
  35. package/dist/event-projector-usage-BfXmpOec.js +102 -0
  36. package/dist/{harness-Czh2Sdoc.js → harness-C7rRa7bm.js} +48 -24
  37. package/dist/harness.js +1 -1
  38. package/dist/history-rejection-B4nOXNXF.js +13 -0
  39. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  40. package/dist/index.js +406 -2915
  41. package/dist/inference-context-Dr_mzvk4.js +94 -0
  42. package/dist/inference-proxy-HGXKUIre.js +311 -0
  43. package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DWVb5U2J.js} +7 -4
  44. package/dist/launch-args-RXQwn8zV.js +90 -0
  45. package/dist/{managed-binary-DcpnJF9x.js → managed-binary-D22rNEcR.js} +13 -103
  46. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  47. package/dist/media-understanding-provider.js +4 -1
  48. package/dist/migration-provider-api.js +2 -0
  49. package/dist/{model-catalog-DT5vo6qo.js → model-catalog-Dq2n8f_p.js} +6 -5
  50. package/dist/{models-CcrgSMQR.js → models-PCKOim-h.js} +3 -3
  51. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  52. package/dist/native-subagent-history-DjtPloaU.js +140 -0
  53. package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
  54. package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-fQ7eIXEf.js} +115 -460
  55. package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
  56. package/dist/node-cli-sessions-DKaOmVUh.js +527 -0
  57. package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-Cl2vapEi.js} +55 -24
  58. package/dist/plan-7uG-Fp36.js +947 -0
  59. package/dist/plugin-activation-BYQculil.js +138 -0
  60. package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-d0eKxy7b.js} +4 -52
  61. package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
  62. package/dist/plugin-inventory-oL4Na1ZG.js +328 -0
  63. package/dist/plugin-marketplace-discovery-P-Vndfqq.js +137 -0
  64. package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-ClPJpRio.js} +17 -9
  65. package/dist/protocol-5bh1G-H7.js +275 -0
  66. package/dist/provider-MQ8PVkuE.js +50 -0
  67. package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-BvCUL69A.js} +2 -2
  68. package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-CBMmWBr9.js} +1 -1
  69. package/dist/request-B7hEkBGq.js +212 -0
  70. package/dist/rpc-error-ttN_QjEm.js +30 -0
  71. package/dist/{run-attempt-BzthFQSM.js → run-attempt-CvsAAGa0.js} +664 -377
  72. package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-BJ0rXBZ_.js} +27 -27
  73. package/dist/sandbox-guard-BxgyoM8M.js +166 -0
  74. package/dist/{session-binding-4Ki04sW-.js → session-binding-CI8UuilT.js} +30 -48
  75. package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-Bcvslnhf.js} +12 -26
  76. package/dist/session-catalog-adoption-tcZi1IfX.js +251 -0
  77. package/dist/session-catalog-archive-CwKg8Xz2.js +56 -0
  78. package/dist/session-catalog-ct-AH01I.js +1477 -0
  79. package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
  80. package/dist/session-catalog-node-adoption-B1tgDW-m.js +182 -0
  81. package/dist/session-catalog-node-continue-Ci-DXyJP.js +238 -0
  82. package/dist/session-catalog-provenance-D-dIfRAH.js +96 -0
  83. package/dist/{session-cli-BjLhpmS1.js → session-cli-DNN_jhGc.js} +3 -2
  84. package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
  85. package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DwyijFI6.js} +5 -50
  86. package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
  87. package/dist/session-history-worker-runtime.js +18 -6
  88. package/dist/session-history.worker-BeK1YOyT.js +378 -0
  89. package/dist/session-history.worker.js +1 -1
  90. package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Ct0_Hzmg.js} +2 -2
  91. package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-BBmXA8Eg.js} +4 -7
  92. package/dist/{session-retirement-DNdmYdFc.js → session-retirement-B2YfbAAT.js} +6 -5
  93. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  94. package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
  95. package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-Dn91stmc.js} +8 -7
  96. package/dist/shared-client-CscigXXL.js +3109 -0
  97. package/dist/{side-question-B6DWAw1A.js → side-question-BGMJQf4U.js} +65 -170
  98. package/dist/source-CElXU0Oy.js +518 -0
  99. package/dist/thread-archive-guard-DfpBr-Sz.js +53 -0
  100. package/dist/thread-history-page-D0JIp48V.js +361 -0
  101. package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-DXl1-I6b.js} +187 -639
  102. package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-BsDRTsyp.js} +13 -15
  103. package/dist/thread-policy-BuEQfE0g.js +54 -0
  104. package/dist/thread-resume-DsDOZpFg.js +52 -0
  105. package/dist/timeout-BVw8aaM1.js +33 -0
  106. package/dist/transcript-history-projection-v17wXgdK.js +238 -0
  107. package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-C5CKgNy6.js} +50 -260
  108. package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
  109. package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
  110. package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-BZerMte_.js} +27 -19
  111. package/dist/{usage-i9fv5-4m.js → usage-tCk-mg_x.js} +4 -3
  112. package/dist/version-omm6IPI3.js +12 -0
  113. package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
  114. package/openclaw.plugin.json +23 -1
  115. package/package.json +4 -4
  116. package/dist/request-C8H22rPi.js +0 -475
  117. package/dist/session-catalog-B47uwekb.js +0 -3272
  118. package/dist/session-history.worker-zZVcx0ME.js +0 -267
  119. package/dist/shared-client-CKhX2kFt.js +0 -7505
  120. package/dist/thread-policy-CTalhWFy.js +0 -105
@@ -0,0 +1,66 @@
1
+ import { createHash } from "node:crypto";
2
+ import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-registration";
3
+ import { z } from "zod";
4
+ //#region extensions/codex/src/app-server/managed-thread-store.ts
5
+ const CODEX_MANAGED_THREAD_NAMESPACE = "app-server-managed-threads";
6
+ const CODEX_MANAGED_THREAD_MAX_ENTRIES = 2e4;
7
+ const managedThreadSchema = z.object({
8
+ version: z.literal(1),
9
+ kind: z.literal("managed-thread"),
10
+ sourceHomeId: z.string().min(1),
11
+ threadId: z.string().min(1),
12
+ rolloutPath: z.string().min(1).optional()
13
+ });
14
+ async function markStartedCodexManagedThread(store, params) {
15
+ if (!store) return;
16
+ try {
17
+ await store.mark({
18
+ sourceHomeId: params.sourceHomeId,
19
+ threadId: params.threadId,
20
+ ...params.rolloutPath ? { rolloutPath: params.rolloutPath } : {}
21
+ });
22
+ } catch (error) {
23
+ embeddedAgentLog.warn("failed to record Codex managed thread ownership", { error });
24
+ }
25
+ }
26
+ function managedThreadStoreKey(sourceHomeId, threadId) {
27
+ return `sha256:${createHash("sha256").update("openclaw:codex-managed-thread:v1\0").update(sourceHomeId).update("\0").update(threadId).digest("hex")}`;
28
+ }
29
+ /** Durable ownership index for Codex threads created by OpenClaw. */
30
+ function createCodexManagedThreadStore(state) {
31
+ return {
32
+ async has(sourceHomeId, threadId) {
33
+ const parsed = managedThreadSchema.safeParse(state.lookup(managedThreadStoreKey(sourceHomeId, threadId)));
34
+ return parsed.success && parsed.data.sourceHomeId === sourceHomeId && parsed.data.threadId === threadId;
35
+ },
36
+ async mark(params) {
37
+ try {
38
+ const value = managedThreadSchema.parse({
39
+ version: 1,
40
+ kind: "managed-thread",
41
+ sourceHomeId: params.sourceHomeId.trim(),
42
+ threadId: params.threadId.trim(),
43
+ ...params.rolloutPath?.trim() ? { rolloutPath: params.rolloutPath.trim() } : {}
44
+ });
45
+ state.registerIfAbsent(managedThreadStoreKey(value.sourceHomeId, value.threadId), value);
46
+ return true;
47
+ } catch (error) {
48
+ embeddedAgentLog.warn("failed to record Codex managed thread ownership", { error });
49
+ return false;
50
+ }
51
+ },
52
+ async snapshot() {
53
+ const byHome = /* @__PURE__ */ new Map();
54
+ for (const entry of state.entries()) {
55
+ const parsed = managedThreadSchema.safeParse(entry.value);
56
+ if (!parsed.success) continue;
57
+ const ids = byHome.get(parsed.data.sourceHomeId) ?? /* @__PURE__ */ new Set();
58
+ ids.add(parsed.data.threadId);
59
+ byHome.set(parsed.data.sourceHomeId, ids);
60
+ }
61
+ return byHome;
62
+ }
63
+ };
64
+ }
65
+ //#endregion
66
+ export { markStartedCodexManagedThread as i, CODEX_MANAGED_THREAD_NAMESPACE as n, createCodexManagedThreadStore as r, CODEX_MANAGED_THREAD_MAX_ENTRIES as t };
@@ -1,4 +1,3 @@
1
- import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-DxGJRYbY.js";
2
1
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
2
  import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
4
3
  //#region extensions/codex/media-understanding-provider.ts
@@ -44,6 +43,8 @@ async function describeCodexImages(req, options) {
44
43
  const model = req.model.trim();
45
44
  if (!model) throw new Error("Codex image understanding requires model id.");
46
45
  req.signal?.throwIfAborted();
46
+ const { runBoundedCodexAppServerTurn } = await import("./bounded-turn-C_Hneydj.js");
47
+ req.signal?.throwIfAborted();
47
48
  const { text } = await runBoundedCodexAppServerTurn({
48
49
  config: req.cfg,
49
50
  model: {
@@ -82,6 +83,8 @@ async function extractCodexStructured(req, options) {
82
83
  if (req.input.length === 0) throw new Error("Codex structured extraction requires at least one input.");
83
84
  if (!req.input.some((entry) => entry.type === "image")) throw new Error("Codex structured extraction requires at least one image input.");
84
85
  req.signal?.throwIfAborted();
86
+ const { runBoundedCodexAppServerTurn } = await import("./bounded-turn-C_Hneydj.js");
87
+ req.signal?.throwIfAborted();
85
88
  const { text } = await runBoundedCodexAppServerTurn({
86
89
  config: req.cfg,
87
90
  model: {
@@ -0,0 +1,2 @@
1
+ import { t as buildCodexMigrationProvider } from "./provider-MQ8PVkuE.js";
2
+ export { buildCodexMigrationProvider as buildMigrationProvider };
@@ -1,8 +1,9 @@
1
- import { r as buildCodexRuntimeModelParams } from "./harness-Czh2Sdoc.js";
2
- import { B as isJsonObject, O as readCodexPluginConfig, i as resolveCodexAppServerRuntimeOptions } from "./config-CyapYSji.js";
3
- import { r as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-CKhX2kFt.js";
4
- import { t as listAllCodexAppServerModels } from "./models-CcrgSMQR.js";
5
- import { o as withCodexAppServerJsonClient } from "./request-C8H22rPi.js";
1
+ import { r as buildCodexRuntimeModelParams } from "./harness-C7rRa7bm.js";
2
+ import { o as isJsonObject, x as readCodexPluginConfig } from "./protocol-5bh1G-H7.js";
3
+ import { o as withCodexAppServerJsonClient } from "./request-B7hEkBGq.js";
4
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-D0zGNIHu.js";
5
+ import { r as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-CscigXXL.js";
6
+ import { t as listAllCodexAppServerModels } from "./models-PCKOim-h.js";
6
7
  //#region extensions/codex/src/app-server/model-catalog.ts
7
8
  const DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS = 2500;
8
9
  const INPUT_TYPES = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { X as assertCodexModelListResponse } from "./shared-client-CKhX2kFt.js";
1
+ import { h as assertCodexModelListResponse } from "./client-B57KWPQx.js";
2
2
  import { normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  //#region extensions/codex/src/app-server/models.ts
4
4
  /**
@@ -37,8 +37,8 @@ async function withCodexAppServerModelRequest(options, run) {
37
37
  if (options.request) return await run(options.request);
38
38
  const timeoutMs = options.timeoutMs ?? 2500;
39
39
  const useSharedClient = options.sharedClient !== false;
40
- const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-CKhX2kFt.js").then((n) => n.x);
41
- const { requestCodexAppServerClientJson } = await import("./request-C8H22rPi.js").then((n) => n.a);
40
+ const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-CscigXXL.js").then((n) => n.y);
41
+ const { requestCodexAppServerClientJson } = await import("./request-B7hEkBGq.js").then((n) => n.a);
42
42
  const client = await (useSharedClient ? getLeasedSharedCodexAppServerClient : createIsolatedCodexAppServerClient)({
43
43
  startOptions: options.startOptions,
44
44
  timeoutMs,
@@ -0,0 +1,128 @@
1
+ import { resolveAgentConfig, tryResolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
2
+ import { normalizeAgentId, parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
3
+ import { getSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
4
+ import { resolveSandboxRuntimeStatus } from "openclaw/plugin-sdk/sandbox";
5
+ //#region extensions/codex/src/app-server/native-execution-policy.ts
6
+ /** Projects node execution ownership into the runtime tool factory options. */
7
+ function resolveCodexNodeExecToolOverrides(policy) {
8
+ if (policy.effectiveExecHost !== "node") return;
9
+ const node = policy.node?.trim();
10
+ return {
11
+ host: "node",
12
+ ...node ? { node } : {}
13
+ };
14
+ }
15
+ /** Resolves node/gateway/sandbox execution ownership from overrides, session, agent, and config. */
16
+ function resolveCodexNativeExecutionPolicy(params) {
17
+ const config = params.config ?? {};
18
+ const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim() || void 0;
19
+ const agentId = resolvePolicyAgentId({
20
+ config,
21
+ sessionKey,
22
+ agentId: params.agentId
23
+ });
24
+ const canReadSessionEntry = Boolean(agentId) && params.readRuntimeSessionEntry && shouldReadRuntimeSessionEntry({
25
+ config,
26
+ sessionKey,
27
+ agentId
28
+ });
29
+ const sessionEntry = params.sessionEntry ?? (canReadSessionEntry && sessionKey && agentId ? readRuntimeSessionEntryBestEffort({
30
+ sessionKey,
31
+ agentId
32
+ }) : void 0);
33
+ const sandboxAgentId = parseAgentSessionKey(sessionKey)?.agentId ?? agentId;
34
+ const sandboxAvailable = params.sandboxAvailable ?? (sessionKey && sandboxAgentId ? resolveSandboxRuntimeStatus({
35
+ cfg: config,
36
+ sessionKey,
37
+ agentId: sandboxAgentId,
38
+ classificationAgentId: sandboxAgentId
39
+ }).sandboxed : false);
40
+ const agentExec = agentId ? resolvePolicyAgentExec({
41
+ config,
42
+ agentId
43
+ }) : void 0;
44
+ const globalExec = config.tools?.exec;
45
+ const requestedExecHost = normalizeExecTarget(params.execOverrides?.host) ?? normalizeExecTarget(sessionEntry?.execHost) ?? normalizeExecTarget(agentExec?.host) ?? normalizeExecTarget(globalExec?.host) ?? "auto";
46
+ const effectiveExecHost = resolveEffectiveExecHost({
47
+ requestedExecHost,
48
+ sandboxAvailable
49
+ });
50
+ const node = params.execOverrides?.node ?? sessionEntry?.execNode ?? agentExec?.node ?? globalExec?.node;
51
+ if (effectiveExecHost !== "node") return {
52
+ nativeToolSurfaceAllowed: true,
53
+ requestedExecHost,
54
+ effectiveExecHost,
55
+ node
56
+ };
57
+ return {
58
+ nativeToolSurfaceAllowed: false,
59
+ requestedExecHost,
60
+ effectiveExecHost,
61
+ node,
62
+ blockReason: "OpenClaw exec host=node is active for this session. Codex app-server native execution cannot route shell, filesystem, MCP, or app-backed work through the selected OpenClaw node."
63
+ };
64
+ }
65
+ /** Formats the user-facing explanation shown when native tools are blocked by exec host=node. */
66
+ function formatCodexNativeNodeExecBlock(params) {
67
+ return [
68
+ `Codex-native ${params.surface} is unavailable because OpenClaw exec host=node is active for this session.`,
69
+ params.reason ?? "Codex app-server native execution cannot route execution through the selected OpenClaw node.",
70
+ "Use a normal Codex harness turn so OpenClaw exec/process tools run on the node, or switch exec host to gateway for native Codex app-server execution."
71
+ ].join(" ");
72
+ }
73
+ function resolvePolicyAgentId(params) {
74
+ const explicitAgentId = normalizeAgentIdOrDefault(params.agentId);
75
+ if (explicitAgentId) return explicitAgentId;
76
+ const sessionAgentId = parseAgentIdFromSessionKey(params.sessionKey);
77
+ if (sessionAgentId) return sessionAgentId;
78
+ return tryResolveDefaultAgentId(params.config);
79
+ }
80
+ function resolvePolicyAgentExec(params) {
81
+ return resolveAgentConfig(params.config, params.agentId)?.tools?.exec;
82
+ }
83
+ function parseAgentIdFromSessionKey(sessionKey) {
84
+ const raw = sessionKey?.trim();
85
+ if (!raw) return;
86
+ const parts = raw.toLowerCase().split(":").filter(Boolean);
87
+ if (parts.length < 3 || parts[0] !== "agent" || !parts[2]) return;
88
+ return normalizeAgentIdOrDefault(parts[1]);
89
+ }
90
+ function shouldReadRuntimeSessionEntry(params) {
91
+ if (!params.sessionKey) return false;
92
+ const explicitAgentId = normalizeAgentIdOrDefault(params.agentId);
93
+ if (!explicitAgentId) return true;
94
+ const sessionAgentId = parseAgentIdFromSessionKey(params.sessionKey);
95
+ if (!sessionAgentId) return isDefaultAgentSessionKeyForAgent({
96
+ config: params.config,
97
+ agentId: explicitAgentId
98
+ });
99
+ return sessionAgentId === explicitAgentId;
100
+ }
101
+ function isDefaultAgentSessionKeyForAgent(params) {
102
+ return normalizeAgentId(params.agentId) === tryResolveDefaultAgentId(params.config);
103
+ }
104
+ function normalizeAgentIdOrDefault(value) {
105
+ const normalized = normalizeAgentId(value);
106
+ return normalized === "main" && !(value ?? "").trim() ? void 0 : normalized;
107
+ }
108
+ function normalizeExecTarget(value) {
109
+ const normalized = value?.trim().toLowerCase();
110
+ if (normalized === "auto" || normalized === "sandbox" || normalized === "gateway" || normalized === "node") return normalized;
111
+ }
112
+ function resolveEffectiveExecHost(params) {
113
+ if (params.requestedExecHost === "auto") return params.sandboxAvailable ? "sandbox" : "gateway";
114
+ return params.requestedExecHost;
115
+ }
116
+ function readRuntimeSessionEntryBestEffort(params) {
117
+ try {
118
+ return getSessionEntry({
119
+ sessionKey: params.sessionKey,
120
+ agentId: params.agentId,
121
+ hydrateSkillPromptRefs: false
122
+ });
123
+ } catch {
124
+ return;
125
+ }
126
+ }
127
+ //#endregion
128
+ export { resolveCodexNativeExecutionPolicy as n, resolveCodexNodeExecToolOverrides as r, formatCodexNativeNodeExecBlock as t };
@@ -0,0 +1,140 @@
1
+ import { l as sessionBindingIdentity } from "./session-binding-record-Bcvslnhf.js";
2
+ import { t as readCodexThreadHistoryPage } from "./thread-history-page-D0JIp48V.js";
3
+ import { r as readMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
4
+ import { r as projectCodexThreadHistoryItem } from "./transcript-history-projection-v17wXgdK.js";
5
+ import { n as buildCodexAppServerRuntimeFingerprint, t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-d0eKxy7b.js";
6
+ import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-D3udKbIE.js";
7
+ import { c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-CscigXXL.js";
8
+ import { c as itemToolArgs, d as itemTranscriptResultText, n as CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX } from "./native-subagent-task-ids-BzTdT0Uw.js";
9
+ import { r as readCodexNativeSubagentHistoryOwner, t as codexNativeSubagentHistoryConnectionFingerprint } from "./native-subagent-history-owner-Pcp7JuVF.js";
10
+ import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
11
+ import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
12
+ //#region extensions/codex/src/app-server/native-subagent-history.ts
13
+ const MAX_SUBAGENT_ANCESTRY_READS = 32;
14
+ const taskHistoryToolItems = {
15
+ itemToolArgs,
16
+ itemTranscriptResultText
17
+ };
18
+ function parentThreadId(thread) {
19
+ const source = thread.source;
20
+ const spawn = source && typeof source === "object" && "subAgent" in source && typeof source.subAgent === "object" && "thread_spawn" in source.subAgent ? source.subAgent.thread_spawn : void 0;
21
+ return thread.parentThreadId?.trim() ?? spawn?.parent_thread_id.trim();
22
+ }
23
+ /** Resolves history from the parent binding's native store without adopting the child. */
24
+ async function readCodexNativeSubagentHistory(params, options) {
25
+ params.assertCurrent();
26
+ const { task, cfg } = params;
27
+ const sessionKey = task.requesterSessionKey;
28
+ const agentId = task.agentId;
29
+ const threadId = task.runId?.startsWith("codex-thread:") ? task.runId.slice(CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX.length) : void 0;
30
+ if (task.taskKind !== "codex-native" || !sessionKey || !agentId || !threadId) throw new Error("Subagent transcript owner is unavailable.");
31
+ const storePath = resolveStorePath(cfg.session?.store, { agentId });
32
+ const readSession = () => getSessionEntry({
33
+ agentId,
34
+ sessionKey,
35
+ storePath,
36
+ hydrateSkillPromptRefs: false,
37
+ readConsistency: "latest"
38
+ });
39
+ const session = readSession();
40
+ if (!session?.sessionId) throw new Error("Subagent parent session is unavailable.");
41
+ const sessionId = session.sessionId;
42
+ const lifecycleRevision = session.lifecycleRevision;
43
+ const historyOwner = readCodexNativeSubagentHistoryOwner(task.detail);
44
+ if (historyOwner && (historyOwner.lifecycleRevision ? historyOwner.lifecycleRevision !== lifecycleRevision : historyOwner.sessionId !== sessionId)) throw new Error("Subagent history owner changed; reconnect its parent session.");
45
+ const identity = sessionBindingIdentity({
46
+ agentId,
47
+ sessionId,
48
+ sessionKey,
49
+ config: cfg
50
+ });
51
+ const binding = options.bindingStore.read(identity);
52
+ if (!binding || binding.pendingSupervisionBranch) throw new Error("Subagent parent thread is unavailable.");
53
+ if (historyOwner && historyOwner.connectionFingerprint !== codexNativeSubagentHistoryConnectionFingerprint(binding)) throw new Error("Subagent history owner changed; reconnect its parent session.");
54
+ const historyParentThreadId = historyOwner?.parentThreadId ?? binding.threadId;
55
+ const assertCurrent = () => {
56
+ params.assertCurrent();
57
+ const currentSession = readSession();
58
+ const current = options.bindingStore.read(identity);
59
+ if (currentSession?.sessionId !== sessionId || currentSession?.lifecycleRevision !== lifecycleRevision || current?.threadId !== binding.threadId || current?.appServerRuntimeFingerprint !== binding.appServerRuntimeFingerprint || current?.connectionScope !== binding.connectionScope || current?.authProfileId !== binding.authProfileId) throw new Error("Subagent parent changed; refresh its transcript.");
60
+ };
61
+ const agentDir = resolveAgentDir(cfg, agentId);
62
+ const connection = resolveCodexBindingAppServerConnection({
63
+ binding,
64
+ pluginConfig: options.pluginConfig,
65
+ agentDir,
66
+ authProfileId: binding.authProfileId
67
+ });
68
+ const client = await getLeasedSharedCodexAppServerClient({
69
+ startOptions: connection.appServer.start,
70
+ timeoutMs: connection.appServer.requestTimeoutMs,
71
+ authProfileId: connection.clientAuthProfileId,
72
+ agentDir,
73
+ config: cfg,
74
+ assertCurrent
75
+ });
76
+ try {
77
+ assertCurrent();
78
+ const fingerprint = binding.connectionScope === "supervision" ? buildCodexAppServerConnectionFingerprint(connection.appServer, agentDir) : buildCodexAppServerRuntimeFingerprint({
79
+ appServer: connection.appServer,
80
+ appServerVersion: client.getServerVersion(),
81
+ runtimeIdentity: client.getRuntimeIdentity()
82
+ });
83
+ if (!binding.appServerRuntimeFingerprint || fingerprint !== binding.appServerRuntimeFingerprint) throw new Error("Subagent connection changed; reconnect its parent session.");
84
+ const { thread } = await client.request("thread/read", {
85
+ threadId,
86
+ includeTurns: false
87
+ }, { assertCurrent });
88
+ assertCurrent();
89
+ if (thread.id !== threadId || threadId === historyParentThreadId) throw new Error("Subagent transcript does not belong to this parent session.");
90
+ const visited = /* @__PURE__ */ new Set([threadId]);
91
+ let ancestor = thread;
92
+ for (;;) {
93
+ const parentId = parentThreadId(ancestor);
94
+ if (parentId === historyParentThreadId) break;
95
+ if (!parentId || visited.has(parentId) || visited.size >= MAX_SUBAGENT_ANCESTRY_READS) throw new Error("Subagent transcript does not belong to this parent session.");
96
+ visited.add(parentId);
97
+ const response = await client.request("thread/read", {
98
+ threadId: parentId,
99
+ includeTurns: false
100
+ }, { assertCurrent });
101
+ assertCurrent();
102
+ if (response.thread.id !== parentId) throw new Error("Subagent transcript does not belong to this parent session.");
103
+ ancestor = response.thread;
104
+ }
105
+ const page = await readCodexThreadHistoryPage({
106
+ listItemPage: async (request) => {
107
+ assertCurrent();
108
+ const result = await client.request("thread/items/list", request, { assertCurrent });
109
+ assertCurrent();
110
+ return result;
111
+ },
112
+ listTurnPage: async (request) => {
113
+ assertCurrent();
114
+ const result = await client.request("thread/turns/list", request, { assertCurrent });
115
+ assertCurrent();
116
+ return result;
117
+ }
118
+ }, thread, {
119
+ threadId,
120
+ cursor: params.cursor,
121
+ limit: Math.max(1, Math.floor(Math.min(params.limit, 200) / 2))
122
+ }, {
123
+ project: (entries) => entries.map((entry) => projectCodexThreadHistoryItem(thread, entry, taskHistoryToolItems).map((message) => {
124
+ const messageIdentity = readMirrorIdentity(message);
125
+ if (!messageIdentity) throw new Error("Subagent history message is missing its native identity.");
126
+ return Object.assign(message, { messageId: JSON.stringify([threadId, messageIdentity]) });
127
+ })),
128
+ fits: (result) => Buffer.byteLength(JSON.stringify(result), "utf8") <= 524288
129
+ });
130
+ assertCurrent();
131
+ return {
132
+ messages: page.items.toReversed().flat(),
133
+ ...page.nextCursor ? { nextCursor: page.nextCursor } : {}
134
+ };
135
+ } finally {
136
+ releaseLeasedSharedCodexAppServerClient(client);
137
+ }
138
+ }
139
+ //#endregion
140
+ export { readCodexNativeSubagentHistory };
@@ -0,0 +1,34 @@
1
+ import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
2
+ import { createHash } from "node:crypto";
3
+ //#region extensions/codex/src/app-server/native-subagent-history-owner.ts
4
+ function codexNativeSubagentHistoryConnectionFingerprint(binding) {
5
+ if (!binding.appServerRuntimeFingerprint) return;
6
+ return createHash("sha256").update(JSON.stringify([
7
+ binding.appServerRuntimeFingerprint,
8
+ binding.connectionScope ?? null,
9
+ binding.authProfileId ?? null
10
+ ])).digest("hex");
11
+ }
12
+ function createCodexNativeSubagentHistoryOwner(params) {
13
+ const connectionFingerprint = codexNativeSubagentHistoryConnectionFingerprint(params.binding);
14
+ return connectionFingerprint ? {
15
+ parentThreadId: params.parentThreadId,
16
+ sessionId: params.sessionId,
17
+ ...params.lifecycleRevision ? { lifecycleRevision: params.lifecycleRevision } : {},
18
+ connectionFingerprint
19
+ } : void 0;
20
+ }
21
+ function readCodexNativeSubagentHistoryOwner(detail) {
22
+ const value = asOptionalRecord(detail)?.nativeHistory;
23
+ if (value === void 0) return;
24
+ const owner = asOptionalRecord(value);
25
+ if (typeof owner?.parentThreadId !== "string" || !owner.parentThreadId.trim() || typeof owner.sessionId !== "string" || !owner.sessionId.trim() || owner.lifecycleRevision !== void 0 && (typeof owner.lifecycleRevision !== "string" || !owner.lifecycleRevision.trim()) || typeof owner.connectionFingerprint !== "string" || !/^[a-f0-9]{64}$/u.test(owner.connectionFingerprint)) throw new Error("Subagent history owner is invalid.");
26
+ return {
27
+ parentThreadId: owner.parentThreadId,
28
+ sessionId: owner.sessionId,
29
+ ...typeof owner.lifecycleRevision === "string" ? { lifecycleRevision: owner.lifecycleRevision } : {},
30
+ connectionFingerprint: owner.connectionFingerprint
31
+ };
32
+ }
33
+ //#endregion
34
+ export { createCodexNativeSubagentHistoryOwner as n, readCodexNativeSubagentHistoryOwner as r, codexNativeSubagentHistoryConnectionFingerprint as t };