@openclaw/codex 2026.6.2-beta.1 → 2026.6.5-beta.2

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 (28) hide show
  1. package/dist/{client-factory-BS9nYX8K.js → client-factory-Bt49r45B.js} +2 -1
  2. package/dist/{client-BFxKzFnH.js → client-kMCtlApt.js} +42 -0
  3. package/dist/{command-handlers-BaBMyAFy.js → command-handlers-DMn2M7W7.js} +9 -9
  4. package/dist/{compact-CVPc2Rag.js → compact-CwnPeYnM.js} +11 -4
  5. package/dist/{computer-use-Dhz6SrFx.js → computer-use-ClweWaMz.js} +11 -1
  6. package/dist/{conversation-binding-CMaXGYAc.js → conversation-binding-CzpvaBs1.js} +7 -7
  7. package/dist/doctor-contract-api.js +5 -0
  8. package/dist/harness.js +9 -5
  9. package/dist/index.js +8 -6
  10. package/dist/media-understanding-provider.js +13 -5
  11. package/dist/{models-D8i1zWEu.js → models-DXorTaja.js} +9 -2
  12. package/dist/{native-hook-relay-CBp3nIGk.js → native-hook-relay-DZ3Oon0b.js} +61 -3
  13. package/dist/{notification-correlation-Bg-AlEEy.js → notification-correlation-o8quHmTK.js} +30 -1
  14. package/dist/prompt-overlay.js +7 -0
  15. package/dist/{protocol-validators-DIt7cXIp.js → protocol-validators-CIpP8IJ2.js} +13 -0
  16. package/dist/provider-catalog.js +8 -0
  17. package/dist/provider-discovery.js +1 -0
  18. package/dist/provider.js +16 -1
  19. package/dist/{rate-limit-cache-N66I-Rd7.js → rate-limit-cache-C7qmZ0Jh.js} +2 -0
  20. package/dist/{request-nYrsFNU2.js → request-D64BfplD.js} +16 -4
  21. package/dist/{run-attempt-Wo9uasL_.js → run-attempt-CWfXFq9Q.js} +383 -27
  22. package/dist/{sandbox-guard-DMCJlzmz.js → sandbox-guard-C-Yv9uwY.js} +5 -0
  23. package/dist/{session-binding-D8DxeEbf.js → session-binding-BgTv_YGm.js} +11 -0
  24. package/dist/{shared-client-B31-oqN-.js → shared-client-xytpSKD0.js} +31 -2
  25. package/dist/{side-question-DbYSPUnj.js → side-question-BEpALo9c.js} +9 -9
  26. package/dist/{thread-lifecycle-BOYYMjx6.js → thread-lifecycle-BJsazZ8j.js} +50 -6
  27. package/npm-shrinkwrap.json +2 -2
  28. package/package.json +4 -4
@@ -6,6 +6,7 @@ const VALID_AGENT_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,63}$/i;
6
6
  const INVALID_AGENT_ID_CHARS_PATTERN = /[^a-z0-9_-]+/g;
7
7
  const LEADING_DASH_PATTERN = /^-+/;
8
8
  const TRAILING_DASH_PATTERN = /-+$/;
9
+ /** Resolves node/gateway/sandbox execution ownership from overrides, session, agent, and config. */
9
10
  function resolveCodexNativeExecutionPolicy(params) {
10
11
  const config = params.config ?? {};
11
12
  const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim() || void 0;
@@ -43,6 +44,7 @@ function resolveCodexNativeExecutionPolicy(params) {
43
44
  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."
44
45
  };
45
46
  }
47
+ /** Formats the user-facing explanation shown when native tools are blocked by exec host=node. */
46
48
  function formatCodexNativeNodeExecBlock(params) {
47
49
  return [
48
50
  `Codex-native ${params.surface} is unavailable because OpenClaw exec host=node is active for this session.`,
@@ -155,6 +157,7 @@ const BLOCKED_DIRECT_METHOD_PREFIXES = [
155
157
  "windowsSandbox/"
156
158
  ];
157
159
  const NODE_EXEC_BLOCKED_CONTROL_PLANE_METHODS = new Set(["config/mcpServer/reload"]);
160
+ /** Returns a block message when a direct app-server method would bypass OpenClaw execution policy. */
158
161
  function resolveCodexAppServerDirectSandboxBypassBlock(params) {
159
162
  const policy = resolveDirectMethodPolicy(params.method);
160
163
  if (NODE_EXEC_BLOCKED_CONTROL_PLANE_METHODS.has(params.method)) {
@@ -185,9 +188,11 @@ function resolveCodexAppServerDirectSandboxBypassBlock(params) {
185
188
  if (policy === "requires-openclaw-environment" && hasOpenClawSandboxEnvironmentSelection(params.requestParams)) return;
186
189
  return sandboxBlock;
187
190
  }
191
+ /** Resolves the generic native-execution block for sandboxed or node-hosted sessions. */
188
192
  function resolveCodexNativeExecutionBlock(params) {
189
193
  return resolveCodexNativeSandboxBlock(params) ?? resolveCodexNativeNodeExecBlock(params);
190
194
  }
195
+ /** Returns a block message when native Codex execution cannot honor active sandboxing. */
191
196
  function resolveCodexNativeSandboxBlock(params) {
192
197
  const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim();
193
198
  if (!sessionKey) return;
@@ -4,6 +4,10 @@ import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
4
4
  import fs from "node:fs/promises";
5
5
  import { ensureAuthProfileStore, resolveDefaultAgentDir, resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
6
6
  //#region extensions/codex/src/app-server/session-binding.ts
7
+ /**
8
+ * Persists and normalizes the Codex app-server thread binding associated with
9
+ * an OpenClaw session file.
10
+ */
7
11
  var session_binding_exports = /* @__PURE__ */ __exportAll({
8
12
  clearCodexAppServerBinding: () => clearCodexAppServerBinding,
9
13
  clearCodexAppServerBindingForThread: () => clearCodexAppServerBindingForThread,
@@ -15,9 +19,11 @@ var session_binding_exports = /* @__PURE__ */ __exportAll({
15
19
  });
16
20
  const CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER = "openai";
17
21
  const PUBLIC_OPENAI_MODEL_PROVIDER = "openai";
22
+ /** Returns the JSON sidecar path for the Codex app-server binding beside a session file. */
18
23
  function resolveCodexAppServerBindingPath(sessionFile) {
19
24
  return `${sessionFile}.codex-app-server.json`;
20
25
  }
26
+ /** Reads and normalizes a Codex app-server binding sidecar, returning undefined on stale data. */
21
27
  async function readCodexAppServerBinding(sessionFile, lookup = {}) {
22
28
  const path = resolveCodexAppServerBindingPath(sessionFile);
23
29
  let raw;
@@ -71,6 +77,7 @@ async function readCodexAppServerBinding(sessionFile, lookup = {}) {
71
77
  return;
72
78
  }
73
79
  }
80
+ /** Writes the Codex app-server binding sidecar with normalized provider/auth metadata. */
74
81
  async function writeCodexAppServerBinding(sessionFile, binding, lookup = {}) {
75
82
  const now = (/* @__PURE__ */ new Date()).toISOString();
76
83
  const payload = {
@@ -157,6 +164,7 @@ function readPluginAppPolicyContext(value) {
157
164
  pluginAppIds: parsedPluginAppIds
158
165
  };
159
166
  }
167
+ /** Removes the Codex app-server binding sidecar if present. */
160
168
  async function clearCodexAppServerBinding(sessionFile, _lookup = {}) {
161
169
  try {
162
170
  await fs.unlink(resolveCodexAppServerBindingPath(sessionFile));
@@ -167,6 +175,7 @@ async function clearCodexAppServerBinding(sessionFile, _lookup = {}) {
167
175
  });
168
176
  }
169
177
  }
178
+ /** Clears a binding only when it still points at the expected Codex thread id. */
170
179
  async function clearCodexAppServerBindingForThread(sessionFile, threadId, lookup = {}) {
171
180
  const binding = await readCodexAppServerBinding(sessionFile, lookup);
172
181
  if (!binding) return false;
@@ -184,6 +193,7 @@ async function clearCodexAppServerBindingForThread(sessionFile, threadId, lookup
184
193
  function isNotFound(error) {
185
194
  return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
186
195
  }
196
+ /** Returns true when an auth profile uses native Codex/OpenAI app-server auth. */
187
197
  function isCodexAppServerNativeAuthProfile(lookup) {
188
198
  const authProfileId = lookup.authProfileId?.trim();
189
199
  if (!authProfileId) return false;
@@ -205,6 +215,7 @@ function isCodexAppServerNativeAuthProfile(lookup) {
205
215
  return false;
206
216
  }
207
217
  }
218
+ /** Hides redundant OpenAI provider attribution for native Codex auth bindings. */
208
219
  function normalizeCodexAppServerBindingModelProvider(params) {
209
220
  const modelProvider = params.modelProvider?.trim();
210
221
  if (!modelProvider) return;
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
2
  import { l as resolveCodexAppServerRuntimeOptions, n as codexAppServerStartOptionsKey } from "./config-BT6SLiE6.js";
3
- import { c as resolveCodexAppServerSpawnEnv, o as MANAGED_CODEX_APP_SERVER_PACKAGE, t as CodexAppServerClient } from "./client-BFxKzFnH.js";
3
+ import { c as resolveCodexAppServerSpawnEnv, o as MANAGED_CODEX_APP_SERVER_PACKAGE, t as CodexAppServerClient } from "./client-kMCtlApt.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { createHash } from "node:crypto";
6
6
  import fsSync, { constants, readFileSync } from "node:fs";
@@ -12,6 +12,7 @@ import { fileURLToPath } from "node:url";
12
12
  import { withTimeout } from "openclaw/plugin-sdk/security-runtime";
13
13
  //#region extensions/codex/src/app-server/auth-bridge.ts
14
14
  const CODEX_APP_SERVER_AUTH_PROVIDER = "openai";
15
+ const OPENAI_CODEX_APP_SERVER_AUTH_PROVIDER = "openai-codex";
15
16
  const LEGACY_CODEX_APP_SERVER_AUTH_PROVIDER = "codex-cli";
16
17
  const CODEX_APP_SERVER_EXTERNAL_CLI_PROVIDER_IDS = [CODEX_APP_SERVER_AUTH_PROVIDER, LEGACY_CODEX_APP_SERVER_AUTH_PROVIDER];
17
18
  const OPENAI_PROVIDER = "openai";
@@ -368,7 +369,7 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
368
369
  }
369
370
  function isCodexAppServerAuthProvider(provider, config) {
370
371
  const resolvedProvider = resolveProviderIdForAuth(provider, { config });
371
- return resolvedProvider === CODEX_APP_SERVER_AUTH_PROVIDER || resolvedProvider === LEGACY_CODEX_APP_SERVER_AUTH_PROVIDER;
372
+ return resolvedProvider === CODEX_APP_SERVER_AUTH_PROVIDER || resolvedProvider === OPENAI_CODEX_APP_SERVER_AUTH_PROVIDER || resolvedProvider === LEGACY_CODEX_APP_SERVER_AUTH_PROVIDER;
372
373
  }
373
374
  function isOpenAIApiKeyBackupCredential(credential, config) {
374
375
  return credential.type === "api_key" && resolveProviderIdForAuth(credential.provider, { config }) === OPENAI_PROVIDER;
@@ -427,7 +428,12 @@ function resolveChatgptAccountId(profileId, credential) {
427
428
  }
428
429
  //#endregion
429
430
  //#region extensions/codex/src/app-server/managed-binary.ts
431
+ /**
432
+ * Resolves the managed Codex app-server binary shipped with or installed beside
433
+ * the Codex plugin before stdio startup.
434
+ */
430
435
  const CODEX_PLUGIN_ROOT = resolveDefaultCodexPluginRoot(path.dirname(fileURLToPath(import.meta.url)));
436
+ /** Rewrites managed stdio start options to point at an executable Codex binary path. */
431
437
  async function resolveManagedCodexAppServerStartOptions(startOptions, options = {}) {
432
438
  if (startOptions.transport !== "stdio" || startOptions.commandSource !== "managed") return startOptions;
433
439
  const platform = options.platform ?? process.platform;
@@ -447,6 +453,7 @@ async function resolveManagedCodexAppServerStartOptions(startOptions, options =
447
453
  commandSource: "resolved-managed"
448
454
  };
449
455
  }
456
+ /** Returns the preferred and fallback managed Codex binary paths for a plugin root. */
450
457
  function resolveManagedCodexAppServerPaths(params) {
451
458
  const platform = params.platform ?? process.platform;
452
459
  const candidateCommandPaths = resolveManagedCodexAppServerCommandCandidates(params.pluginRoot ?? CODEX_PLUGIN_ROOT, platform);
@@ -543,11 +550,20 @@ async function commandPathExists(filePath, platform) {
543
550
  }
544
551
  //#endregion
545
552
  //#region extensions/codex/src/app-server/timeout.ts
553
+ /**
554
+ * Thin Codex app-server timeout adapter around OpenClaw's shared security
555
+ * runtime timeout helper.
556
+ */
557
+ /** Awaits a promise with a Codex-specific timeout error message. */
546
558
  async function withTimeout$1(promise, timeoutMs, timeoutMessage) {
547
559
  return await withTimeout(promise, timeoutMs, { message: timeoutMessage });
548
560
  }
549
561
  //#endregion
550
562
  //#region extensions/codex/src/app-server/shared-client.ts
563
+ /**
564
+ * Owns shared and isolated Codex app-server client startup, auth application,
565
+ * lease tracking, and teardown.
566
+ */
551
567
  var shared_client_exports = /* @__PURE__ */ __exportAll({
552
568
  clearSharedCodexAppServerClient: () => clearSharedCodexAppServerClient,
553
569
  clearSharedCodexAppServerClientAndWait: () => clearSharedCodexAppServerClientAndWait,
@@ -630,9 +646,11 @@ async function resolveCodexAppServerClientStartContext(options) {
630
646
  })
631
647
  };
632
648
  }
649
+ /** Gets or starts a shared Codex app-server client without retaining a lease. */
633
650
  async function getSharedCodexAppServerClient(options) {
634
651
  return (await acquireSharedCodexAppServerClient(options)).client;
635
652
  }
653
+ /** Gets or starts a shared Codex app-server client and records a release lease. */
636
654
  async function getLeasedSharedCodexAppServerClient(options) {
637
655
  const acquired = await acquireSharedCodexAppServerClient(options, { leased: true });
638
656
  const state = getSharedCodexAppServerClientState();
@@ -641,6 +659,7 @@ async function getLeasedSharedCodexAppServerClient(options) {
641
659
  state.leasedReleases.set(acquired.client, releases);
642
660
  return acquired.client;
643
661
  }
662
+ /** Releases one outstanding lease for a shared Codex app-server client. */
644
663
  function releaseLeasedSharedCodexAppServerClient(client) {
645
664
  const state = getSharedCodexAppServerClientState();
646
665
  const releases = state.leasedReleases.get(client);
@@ -710,6 +729,7 @@ async function acquireSharedCodexAppServerClient(options, leaseOptions) {
710
729
  releasePendingAcquire();
711
730
  }
712
731
  }
732
+ /** Starts a non-shared Codex app-server client owned entirely by the caller. */
713
733
  async function createIsolatedCodexAppServerClient(options) {
714
734
  const { agentDir, usesNativeAuth, authProfileId, startOptions } = await resolveCodexAppServerClientStartContext(options);
715
735
  const client = CodexAppServerClient.start(startOptions);
@@ -730,6 +750,7 @@ async function createIsolatedCodexAppServerClient(options) {
730
750
  throw error;
731
751
  }
732
752
  }
753
+ /** Clears and closes all shared clients for deterministic tests. */
733
754
  function resetSharedCodexAppServerClientForTests() {
734
755
  const state = getSharedCodexAppServerClientState();
735
756
  const clients = collectSharedClients(state);
@@ -737,12 +758,14 @@ function resetSharedCodexAppServerClientForTests() {
737
758
  state.leasedReleases = /* @__PURE__ */ new WeakMap();
738
759
  for (const client of clients) client.close();
739
760
  }
761
+ /** Clears and closes all shared clients. */
740
762
  function clearSharedCodexAppServerClient() {
741
763
  const state = getSharedCodexAppServerClientState();
742
764
  const clients = collectSharedClients(state);
743
765
  state.clients.clear();
744
766
  for (const client of clients) client.close();
745
767
  }
768
+ /** Clears and closes the shared entry only if it still owns the supplied client. */
746
769
  function clearSharedCodexAppServerClientIfCurrent(client) {
747
770
  if (!client) return false;
748
771
  const state = getSharedCodexAppServerClientState();
@@ -753,6 +776,7 @@ function clearSharedCodexAppServerClientIfCurrent(client) {
753
776
  }
754
777
  return false;
755
778
  }
779
+ /** Detaches the shared entry without closing the client when it still matches. */
756
780
  function detachSharedCodexAppServerClientIfCurrent(client) {
757
781
  if (!client) return false;
758
782
  const state = getSharedCodexAppServerClientState();
@@ -762,11 +786,13 @@ function detachSharedCodexAppServerClientIfCurrent(client) {
762
786
  }
763
787
  return false;
764
788
  }
789
+ /** Retains the matching shared client and returns a release callback. */
765
790
  function retainSharedCodexAppServerClientIfCurrent(client) {
766
791
  if (!client) return;
767
792
  const state = getSharedCodexAppServerClientState();
768
793
  for (const entry of state.clients.values()) if (entry.client === client) return retainSharedClientEntry(entry);
769
794
  }
795
+ /** Marks a matching shared client to close after active leases/acquires drain. */
770
796
  function retireSharedCodexAppServerClientIfCurrent(client) {
771
797
  if (!client) return;
772
798
  const state = getSharedCodexAppServerClientState();
@@ -785,6 +811,7 @@ function retireSharedCodexAppServerClientIfCurrent(client) {
785
811
  closed: false
786
812
  };
787
813
  }
814
+ /** Clears a matching shared client and waits for its process to exit. */
788
815
  async function clearSharedCodexAppServerClientIfCurrentAndWait(client, options) {
789
816
  if (!client) return false;
790
817
  const state = getSharedCodexAppServerClientState();
@@ -795,6 +822,7 @@ async function clearSharedCodexAppServerClientIfCurrentAndWait(client, options)
795
822
  }
796
823
  return false;
797
824
  }
825
+ /** Clears all shared clients and waits for their processes to exit. */
798
826
  async function clearSharedCodexAppServerClientAndWait(options) {
799
827
  const state = getSharedCodexAppServerClientState();
800
828
  const clients = collectSharedClients(state);
@@ -823,6 +851,7 @@ function clearSharedClientEntryIfCurrent(key, client) {
823
851
  const state = getSharedCodexAppServerClientState();
824
852
  if (state.clients.get(key)?.client === client) state.clients.delete(key);
825
853
  }
854
+ /** Clears a matching shared client only when no lease or acquire currently claims it. */
826
855
  function clearSharedCodexAppServerClientIfCurrentAndUnclaimed(client) {
827
856
  if (!client) return {
828
857
  found: false,
@@ -1,13 +1,13 @@
1
1
  import { c as readCodexPluginConfig, l as resolveCodexAppServerRuntimeOptions, p as shouldAutoApproveCodexAppServerApprovals } from "./config-BT6SLiE6.js";
2
- import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-DIt7cXIp.js";
3
- import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./client-BFxKzFnH.js";
4
- import { O as resolveCodexDynamicToolsLoading, T as filterCodexDynamicTools, d as resolveReasoningEffort, g as mergeCodexThreadConfigs, r as buildCodexRuntimeThreadConfig, t as CODEX_NATIVE_PERSONALITY_NONE, u as resolveCodexAppServerModelProvider } from "./thread-lifecycle-BOYYMjx6.js";
5
- import { a as readCodexAppServerBinding } from "./session-binding-D8DxeEbf.js";
6
- import { h as formatCodexUsageLimitErrorMessage, i as readCodexNotificationTurnId, r as readCodexNotificationThreadId } from "./notification-correlation-Bg-AlEEy.js";
7
- import { a as getLeasedSharedCodexAppServerClient, o as releaseLeasedSharedCodexAppServerClient, u as refreshCodexAppServerAuthTokens } from "./shared-client-B31-oqN-.js";
8
- import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DMCJlzmz.js";
9
- import { d as emitDynamicToolErrorDiagnostic, f as emitDynamicToolStartedDiagnostic, h as handleCodexAppServerApprovalRequest, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerElicitationRequest, m as filterToolsForVisionInputs, p as emitDynamicToolTerminalDiagnostic, r as buildCodexNativeHookRelayConfig, t as CODEX_NATIVE_HOOK_RELAY_EVENTS, u as createCodexDynamicToolBridge } from "./native-hook-relay-CBp3nIGk.js";
10
- import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-N66I-Rd7.js";
2
+ import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-CIpP8IJ2.js";
3
+ import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./client-kMCtlApt.js";
4
+ import { O as resolveCodexDynamicToolsLoading, T as filterCodexDynamicTools, d as resolveReasoningEffort, g as mergeCodexThreadConfigs, r as buildCodexRuntimeThreadConfig, t as CODEX_NATIVE_PERSONALITY_NONE, u as resolveCodexAppServerModelProvider } from "./thread-lifecycle-BJsazZ8j.js";
5
+ import { a as readCodexAppServerBinding } from "./session-binding-BgTv_YGm.js";
6
+ import { h as formatCodexUsageLimitErrorMessage, i as readCodexNotificationTurnId, r as readCodexNotificationThreadId } from "./notification-correlation-o8quHmTK.js";
7
+ import { a as getLeasedSharedCodexAppServerClient, o as releaseLeasedSharedCodexAppServerClient, u as refreshCodexAppServerAuthTokens } from "./shared-client-xytpSKD0.js";
8
+ import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-C-Yv9uwY.js";
9
+ import { d as emitDynamicToolErrorDiagnostic, f as emitDynamicToolStartedDiagnostic, h as handleCodexAppServerApprovalRequest, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerElicitationRequest, m as filterToolsForVisionInputs, p as emitDynamicToolTerminalDiagnostic, r as buildCodexNativeHookRelayConfig, t as CODEX_NATIVE_HOOK_RELAY_EVENTS, u as createCodexDynamicToolBridge } from "./native-hook-relay-DZ3Oon0b.js";
10
+ import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-C7qmZ0Jh.js";
11
11
  import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
12
12
  //#region extensions/codex/src/app-server/side-question.ts
13
13
  const CODEX_SIDE_DYNAMIC_TOOL_TIMEOUT_MS = 9e4;
@@ -1,9 +1,9 @@
1
1
  import { d as resolveCodexPluginsPolicy, r as codexSandboxPolicyForTurn, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-BT6SLiE6.js";
2
- import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-DIt7cXIp.js";
3
- import { a as isCodexAppServerConnectionClosedError, l as isJsonObject, n as CodexAppServerRpcError } from "./client-BFxKzFnH.js";
2
+ import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-CIpP8IJ2.js";
3
+ import { a as isCodexAppServerConnectionClosedError, l as isJsonObject, n as CodexAppServerRpcError } from "./client-kMCtlApt.js";
4
4
  import { CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY } from "./prompt-overlay.js";
5
5
  import { isModernCodexModel } from "./provider.js";
6
- import { a as readCodexAppServerBinding, r as isCodexAppServerNativeAuthProfile, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-D8DxeEbf.js";
6
+ import { a as readCodexAppServerBinding, r as isCodexAppServerNativeAuthProfile, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-BgTv_YGm.js";
7
7
  import { isFutureDateTimestampMs, resolveDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
8
8
  import crypto from "node:crypto";
9
9
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -26,12 +26,11 @@ const MAX_RENDERED_CONTEXT_CHARS = 1e6;
26
26
  const DEFAULT_TEXT_PART_CHARS = 6e3;
27
27
  const MAX_TEXT_PART_CHARS = 128e3;
28
28
  const APPROX_RENDERED_CHARS_PER_TOKEN = 4;
29
+ /** Default token reserve kept out of rendered context-engine prompt text. */
29
30
  const DEFAULT_CODEX_PROJECTION_RESERVE_TOKENS = 2e4;
30
31
  const MIN_PROMPT_BUDGET_RATIO = .5;
31
32
  const MIN_PROMPT_BUDGET_TOKENS = 8e3;
32
- /**
33
- * Project assembled OpenClaw context-engine messages into Codex prompt inputs.
34
- */
33
+ /** Projects assembled OpenClaw context-engine messages into Codex prompt inputs. */
35
34
  function projectContextEngineAssemblyForCodex(params) {
36
35
  const prompt = params.prompt.trim();
37
36
  const contextMessages = dropDuplicateTrailingPrompt(params.assembledMessages, prompt);
@@ -58,6 +57,7 @@ function projectContextEngineAssemblyForCodex(params) {
58
57
  prePromptMessageCount: params.originalHistoryMessages.length
59
58
  };
60
59
  }
60
+ /** Resolves rendered context size from a token budget and reserve. */
61
61
  function resolveCodexContextEngineProjectionMaxChars(params) {
62
62
  const contextTokenBudget = typeof params.contextTokenBudget === "number" && Number.isFinite(params.contextTokenBudget) ? Math.floor(params.contextTokenBudget) : void 0;
63
63
  if (!contextTokenBudget || contextTokenBudget <= 0) return DEFAULT_RENDERED_CONTEXT_CHARS;
@@ -66,6 +66,7 @@ function resolveCodexContextEngineProjectionMaxChars(params) {
66
66
  reserveTokens: params.reserveTokens
67
67
  }) * APPROX_RENDERED_CHARS_PER_TOKEN);
68
68
  }
69
+ /** Reads Codex projection reserve tokens from compaction config. */
69
70
  function resolveCodexContextEngineProjectionReserveTokens(params) {
70
71
  const compaction = asRecord(asRecord(asRecord(params.config)?.agents)?.defaults)?.compaction;
71
72
  const configuredReserveTokens = toNonNegativeInt(asRecord(compaction)?.reserveTokens);
@@ -228,6 +229,7 @@ function truncateOlderContext(text, maxChars) {
228
229
  }
229
230
  //#endregion
230
231
  //#region extensions/codex/src/app-server/dynamic-tool-profile.ts
232
+ /** Tool names owned by Codex app-server and normally excluded from OpenClaw dynamic tools. */
231
233
  const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
232
234
  "read",
233
235
  "write",
@@ -245,13 +247,16 @@ const DYNAMIC_TOOL_NAME_ALIASES = {
245
247
  bash: "exec",
246
248
  "apply-patch": "apply_patch"
247
249
  };
250
+ /** Normalizes OpenClaw/Codex tool names before filtering and allowlist checks. */
248
251
  function normalizeCodexDynamicToolName(name) {
249
252
  const normalized = name.trim().toLowerCase();
250
253
  return DYNAMIC_TOOL_NAME_ALIASES[normalized] ?? normalized;
251
254
  }
255
+ /** Returns true for private QA runs that force the Codex runtime profile. */
252
256
  function isForcedPrivateQaCodexRuntime(env = process.env) {
253
257
  return env.OPENCLAW_BUILD_PRIVATE_QA === "1" && env.OPENCLAW_QA_FORCE_RUNTIME?.trim().toLowerCase() === "codex";
254
258
  }
259
+ /** Resolves whether dynamic tools load directly or through Codex tool search. */
255
260
  function resolveCodexDynamicToolsLoading(config, env = process.env) {
256
261
  return isForcedPrivateQaCodexRuntime(env) ? "direct" : config.codexDynamicToolsLoading ?? "searchable";
257
262
  }
@@ -260,16 +265,20 @@ function normalizeCodexModelId(modelId) {
260
265
  if (!normalized) return "";
261
266
  return normalized.includes("/") ? normalized.split("/").at(-1) : normalized;
262
267
  }
268
+ /** Returns true when model behavior requires direct dynamic-tool registration. */
263
269
  function shouldUseDirectCodexDynamicToolsForModel(modelId) {
264
270
  return shouldDisableCodexToolSearchForModel(modelId);
265
271
  }
272
+ /** Returns true for models whose tool-search path is unsupported or inefficient. */
266
273
  function shouldDisableCodexToolSearchForModel(modelId) {
267
274
  return normalizeCodexModelId(modelId) === "gpt-5.4-nano";
268
275
  }
276
+ /** Resolves dynamic-tool loading after applying model-specific restrictions. */
269
277
  function resolveCodexDynamicToolsLoadingForModel(config, modelId, env = process.env) {
270
278
  const loading = resolveCodexDynamicToolsLoading(config, env);
271
279
  return loading === "searchable" && shouldUseDirectCodexDynamicToolsForModel(modelId) ? "direct" : loading;
272
280
  }
281
+ /** Filters OpenClaw tools that Codex owns natively or config explicitly excludes. */
273
282
  function filterCodexDynamicTools(tools, config, env = process.env) {
274
283
  const excludes = /* @__PURE__ */ new Set();
275
284
  if (!isForcedPrivateQaCodexRuntime(env)) for (const name of CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES) excludes.add(name);
@@ -281,10 +290,16 @@ function filterCodexDynamicTools(tools, config, env = process.env) {
281
290
  }
282
291
  //#endregion
283
292
  //#region extensions/codex/src/app-server/image-payload-sanitizer.ts
293
+ /**
294
+ * Sanitizes inline image payloads mirrored through Codex history so invalid
295
+ * base64 data becomes readable text instead of poisoning replayed transcripts.
296
+ */
284
297
  const IMAGE_OMITTED_TEXT = "omitted image payload: invalid inline image data";
298
+ /** Validates and normalizes an inline image data URL for Codex history payloads. */
285
299
  function sanitizeInlineImageDataUrl$1(imageUrl) {
286
300
  return sanitizeInlineImageDataUrl(imageUrl);
287
301
  }
302
+ /** Builds the replacement text inserted when an inline image payload is invalid. */
288
303
  function invalidInlineImageText(label) {
289
304
  return `[${label}] ${IMAGE_OMITTED_TEXT}`;
290
305
  }
@@ -325,6 +340,7 @@ function sanitizeImageContentRecord(record, label) {
325
340
  };
326
341
  }
327
342
  }
343
+ /** Recursively sanitizes all Codex history image shapes while preserving unknown structure. */
328
344
  function sanitizeCodexHistoryImagePayloads(value, label) {
329
345
  if (Array.isArray(value)) return value.map((entry) => sanitizeCodexHistoryImagePayloads(entry, label));
330
346
  if (!isRecord(value)) return value;
@@ -335,6 +351,7 @@ function sanitizeCodexHistoryImagePayloads(value, label) {
335
351
  return next;
336
352
  }
337
353
  const MAX_SERIALIZED_ERROR_MESSAGE_LENGTH = 500;
354
+ /** In-memory app inventory cache with coalesced refreshes per key. */
338
355
  var CodexAppInventoryCache = class {
339
356
  constructor(options = {}) {
340
357
  this.entries = /* @__PURE__ */ new Map();
@@ -344,6 +361,7 @@ var CodexAppInventoryCache = class {
344
361
  this.revision = 0;
345
362
  this.ttlMs = options.ttlMs ?? 36e5;
346
363
  }
364
+ /** Reads a snapshot and schedules refresh when missing, stale, or forced. */
347
365
  read(params) {
348
366
  const nowMs = resolveDateTimestampMs(params.nowMs);
349
367
  const entry = this.entries.get(params.key);
@@ -368,9 +386,11 @@ var CodexAppInventoryCache = class {
368
386
  ...entry.lastError ? { diagnostic: entry.lastError } : {}
369
387
  };
370
388
  }
389
+ /** Forces or joins an immediate refresh for a cache key. */
371
390
  refreshNow(params) {
372
391
  return this.refresh(params);
373
392
  }
393
+ /** Marks a key stale and records the reason as a diagnostic. */
374
394
  invalidate(key, reason, nowMs = Date.now()) {
375
395
  this.revision += 1;
376
396
  const diagnostic = {
@@ -385,6 +405,7 @@ var CodexAppInventoryCache = class {
385
405
  } else this.diagnostics.set(key, diagnostic);
386
406
  return this.revision;
387
407
  }
408
+ /** Clears all cached snapshots, diagnostics, in-flight requests, and revision state. */
388
409
  clear() {
389
410
  this.entries.clear();
390
411
  this.inFlight.clear();
@@ -392,6 +413,7 @@ var CodexAppInventoryCache = class {
392
413
  this.diagnostics.clear();
393
414
  this.revision = 0;
394
415
  }
416
+ /** Returns the monotonically increasing cache revision. */
395
417
  getRevision() {
396
418
  return this.revision;
397
419
  }
@@ -453,6 +475,7 @@ var CodexAppInventoryCache = class {
453
475
  }
454
476
  }
455
477
  };
478
+ /** Serializes a refresh failure without leaking large or sensitive error data. */
456
479
  function serializeCodexAppInventoryError(error) {
457
480
  const record = isRecord(error) ? error : void 0;
458
481
  const data = record && "data" in record ? redactErrorData(record.data) : void 0;
@@ -463,7 +486,9 @@ function serializeCodexAppInventoryError(error) {
463
486
  ...data !== void 0 ? { data } : {}
464
487
  };
465
488
  }
489
+ /** Shared app inventory cache used by Codex app-server runtime paths. */
466
490
  const defaultCodexAppInventoryCache = new CodexAppInventoryCache();
491
+ /** Builds a stable cache key from runtime identity fields. */
467
492
  function buildCodexAppInventoryCacheKey(input) {
468
493
  return JSON.stringify({
469
494
  codexHome: input.codexHome ?? null,
@@ -524,6 +549,11 @@ function isSensitiveErrorDataKey(key) {
524
549
  }
525
550
  //#endregion
526
551
  //#region extensions/codex/src/app-server/plugin-inventory.ts
552
+ /**
553
+ * Reads Codex plugin marketplace state and app inventory to decide which
554
+ * plugin-owned apps can be exposed to a native Codex thread.
555
+ */
556
+ /** Reads configured Codex plugin state and maps owned apps to readiness diagnostics. */
527
557
  async function readCodexPluginInventory(params) {
528
558
  const policy = params.policy ?? resolveCodexPluginsPolicy(params.pluginConfig);
529
559
  if (!policy.enabled) return {
@@ -609,6 +639,7 @@ async function readCodexPluginInventory(params) {
609
639
  ...appInventory ? { appInventory } : {}
610
640
  };
611
641
  }
642
+ /** Finds one plugin summary in the OpenAI curated marketplace response. */
612
643
  function findOpenAiCuratedPluginSummary(listed, pluginName) {
613
644
  const marketplaceEntry = listed.marketplaces.find((marketplace) => marketplace.name === CODEX_PLUGINS_MARKETPLACE_NAME);
614
645
  if (!marketplaceEntry) return;
@@ -618,6 +649,7 @@ function findOpenAiCuratedPluginSummary(listed, pluginName) {
618
649
  summary
619
650
  } : void 0;
620
651
  }
652
+ /** Builds plugin/read or plugin/install params from a marketplace reference. */
621
653
  function pluginReadParams(marketplace, pluginName) {
622
654
  return {
623
655
  ...marketplace.path ? { marketplacePath: marketplace.path } : {},
@@ -700,6 +732,7 @@ function marketplaceRef(marketplace) {
700
732
  }
701
733
  //#endregion
702
734
  //#region extensions/codex/src/app-server/plugin-activation.ts
735
+ /** Installs/enables a configured Codex plugin and refreshes plugin/app state. */
703
736
  async function ensureCodexPluginActivation(params) {
704
737
  if (params.identity.marketplaceName !== "openai-curated") return activationFailure(params.identity, "marketplace_missing", { message: "Only openai-curated plugins can be activated." });
705
738
  const listed = await params.request("plugin/list", { cwds: [] });
@@ -741,6 +774,7 @@ async function ensureCodexPluginActivation(params) {
741
774
  diagnostics: [...refreshDiagnostics, ...installResponse.appsNeedingAuth.map((app) => ({ message: `${app.name} requires app authentication before plugin tools are exposed.` }))]
742
775
  };
743
776
  }
777
+ /** Forces Codex plugin, skill, hook, MCP, and app inventory refreshes after activation. */
744
778
  async function refreshCodexPluginRuntimeState(params) {
745
779
  const diagnostics = [];
746
780
  await params.request("plugin/list", { cwds: [] });
@@ -780,11 +814,17 @@ function activationFailure(identity, reason, diagnostic) {
780
814
  }
781
815
  //#endregion
782
816
  //#region extensions/codex/src/app-server/plugin-thread-config.ts
817
+ /**
818
+ * Builds Codex thread config patches that expose only policy-approved
819
+ * plugin-owned apps for native Codex turns.
820
+ */
783
821
  const CODEX_PLUGIN_THREAD_CONFIG_INPUT_FINGERPRINT_VERSION = 1;
784
822
  const CODEX_PLUGIN_THREAD_CONFIG_FINGERPRINT_VERSION = 1;
823
+ /** Returns true when plugin config exists and thread config may need app patches. */
785
824
  function shouldBuildCodexPluginThreadConfig(pluginConfig) {
786
825
  return resolveCodexPluginsPolicy(pluginConfig).configured;
787
826
  }
827
+ /** Fingerprints policy and app-cache identity before runtime inventory is read. */
788
828
  function buildCodexPluginThreadConfigInputFingerprint(params) {
789
829
  return fingerprintJson({
790
830
  version: CODEX_PLUGIN_THREAD_CONFIG_INPUT_FINGERPRINT_VERSION,
@@ -792,6 +832,7 @@ function buildCodexPluginThreadConfigInputFingerprint(params) {
792
832
  appCacheKey: params.appCacheKey ?? null
793
833
  });
794
834
  }
835
+ /** Builds the Codex apps config patch and policy context for a native thread. */
795
836
  async function buildCodexPluginThreadConfig(params) {
796
837
  const appCache = params.appCache ?? defaultCodexAppInventoryCache;
797
838
  let inputFingerprint = buildCodexPluginThreadConfigInputFingerprint({
@@ -943,6 +984,7 @@ async function buildCodexPluginThreadConfig(params) {
943
984
  diagnostics
944
985
  };
945
986
  }
987
+ /** Deep-merges optional Codex thread config patches, returning undefined when empty. */
946
988
  function mergeCodexThreadConfigs(...configs) {
947
989
  let merged;
948
990
  for (const config of configs) {
@@ -951,6 +993,7 @@ function mergeCodexThreadConfigs(...configs) {
951
993
  }
952
994
  return merged && Object.keys(merged).length > 0 ? merged : void 0;
953
995
  }
996
+ /** Detects when a stored thread binding no longer matches current plugin policy inputs. */
954
997
  function isCodexPluginThreadBindingStale(params) {
955
998
  if (!params.codexPluginsEnabled) return Boolean(params.bindingFingerprint || params.bindingInputFingerprint || params.hasBindingPolicyContext);
956
999
  if (!params.bindingFingerprint || !params.bindingInputFingerprint || !params.hasBindingPolicyContext) return true;
@@ -1057,6 +1100,7 @@ function stableStringify(value) {
1057
1100
  //#endregion
1058
1101
  //#region extensions/codex/src/app-server/profiler-flag.ts
1059
1102
  const PROFILER_FLAGS = ["profiler", "codex.profiler"];
1103
+ /** Checks the generic and Codex-specific profiler diagnostic flags. */
1060
1104
  function isCodexAppServerProfilerEnabled(config, env = process.env) {
1061
1105
  return PROFILER_FLAGS.some((flag) => isDiagnosticFlagEnabled(flag, config, env));
1062
1106
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.6.2-beta.1",
3
+ "version": "2026.6.5-beta.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/codex",
9
- "version": "2026.6.2-beta.1",
9
+ "version": "2026.6.5-beta.2",
10
10
  "dependencies": {
11
11
  "@openai/codex": "0.135.0",
12
12
  "typebox": "1.1.39",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.6.2-beta.1",
3
+ "version": "2026.6.5-beta.2",
4
4
  "description": "OpenClaw Codex app-server harness and model provider plugin with a Codex-managed GPT catalog.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "minHostVersion": ">=2026.5.1-beta.1"
27
27
  },
28
28
  "compat": {
29
- "pluginApi": ">=2026.6.2-beta.1"
29
+ "pluginApi": ">=2026.6.5-beta.2"
30
30
  },
31
31
  "build": {
32
- "openclawVersion": "2026.6.2-beta.1"
32
+ "openclawVersion": "2026.6.5-beta.2"
33
33
  },
34
34
  "release": {
35
35
  "publishToClawHub": true,
@@ -47,7 +47,7 @@
47
47
  "README.md"
48
48
  ],
49
49
  "peerDependencies": {
50
- "openclaw": ">=2026.6.2-beta.1"
50
+ "openclaw": ">=2026.6.5-beta.2"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "openclaw": {