@openclaw/codex 2026.5.16-beta.2 → 2026.5.16-beta.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.
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
- import { o as normalizeCodexServiceTier } from "./config-3ATInASk.js";
2
+ import { o as normalizeCodexServiceTier } from "./config-B5pq6hEz.js";
3
3
  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";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
- import { c as resolveCodexAppServerRuntimeOptions, n as codexAppServerStartOptionsKey } from "./config-3ATInASk.js";
3
- import { a as MANAGED_CODEX_APP_SERVER_PACKAGE, o as resolveCodexAppServerSpawnEnv, t as CodexAppServerClient } from "./client-CA7amCZ8.js";
2
+ import { c as resolveCodexAppServerRuntimeOptions, n as codexAppServerStartOptionsKey } from "./config-B5pq6hEz.js";
3
+ import { a as MANAGED_CODEX_APP_SERVER_PACKAGE, o as resolveCodexAppServerSpawnEnv, t as CodexAppServerClient } from "./client-6FkrXfaz.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { createHash } from "node:crypto";
6
6
  import { constants, readFileSync } from "node:fs";
@@ -467,20 +467,39 @@ async function withTimeout$1(promise, timeoutMs, timeoutMessage) {
467
467
  //#endregion
468
468
  //#region extensions/codex/src/app-server/shared-client.ts
469
469
  var shared_client_exports = /* @__PURE__ */ __exportAll({
470
- clearSharedCodexAppServerClient: () => clearSharedCodexAppServerClient,
471
470
  clearSharedCodexAppServerClientAndWait: () => clearSharedCodexAppServerClientAndWait,
472
471
  clearSharedCodexAppServerClientIfCurrent: () => clearSharedCodexAppServerClientIfCurrent,
472
+ clearSharedCodexAppServerClientIfCurrentAndWait: () => clearSharedCodexAppServerClientIfCurrentAndWait,
473
473
  createIsolatedCodexAppServerClient: () => createIsolatedCodexAppServerClient,
474
474
  getSharedCodexAppServerClient: () => getSharedCodexAppServerClient
475
475
  });
476
476
  const SHARED_CODEX_APP_SERVER_CLIENT_STATE = Symbol.for("openclaw.codexAppServerClientState");
477
477
  function getSharedCodexAppServerClientState() {
478
478
  const globalState = globalThis;
479
- globalState[SHARED_CODEX_APP_SERVER_CLIENT_STATE] ??= {};
480
- return globalState[SHARED_CODEX_APP_SERVER_CLIENT_STATE];
479
+ const state = globalState[SHARED_CODEX_APP_SERVER_CLIENT_STATE];
480
+ if (isSharedCodexAppServerClientState(state)) return state;
481
+ const legacyState = readLegacySharedCodexAppServerClientState(state);
482
+ const clients = /* @__PURE__ */ new Map();
483
+ if (legacyState?.key && (legacyState.client || legacyState.promise)) {
484
+ const legacyKey = legacyState.key;
485
+ clients.set(legacyKey, {
486
+ client: legacyState.client,
487
+ promise: legacyState.promise
488
+ });
489
+ legacyState.client?.addCloseHandler((closedClient) => clearSharedClientEntryIfCurrent(legacyKey, closedClient));
490
+ }
491
+ const nextState = { clients };
492
+ globalState[SHARED_CODEX_APP_SERVER_CLIENT_STATE] = nextState;
493
+ return nextState;
494
+ }
495
+ function isSharedCodexAppServerClientState(value) {
496
+ return value !== null && typeof value === "object" && value.clients instanceof Map;
497
+ }
498
+ function readLegacySharedCodexAppServerClientState(value) {
499
+ if (value === null || typeof value !== "object") return;
500
+ return value;
481
501
  }
482
502
  async function getSharedCodexAppServerClient(options) {
483
- const state = getSharedCodexAppServerClientState();
484
503
  const agentDir = options?.agentDir ?? resolveDefaultAgentDir(options?.config ?? {});
485
504
  const usesNativeAuth = options?.authProfileId === null;
486
505
  const requestedAuthProfileId = options?.authProfileId === null ? void 0 : options?.authProfileId;
@@ -499,12 +518,12 @@ async function getSharedCodexAppServerClient(options) {
499
518
  authProfileId,
500
519
  agentDir: usesNativeAuth ? void 0 : agentDir
501
520
  });
502
- if (state.key && state.key !== key) clearSharedCodexAppServerClient();
503
- state.key = key;
504
- const sharedPromise = state.promise ?? (state.promise = (async () => {
521
+ const state = getSharedCodexAppServerClientState();
522
+ const entry = getOrCreateSharedClientEntry(state, key);
523
+ const sharedPromise = entry.promise ?? (entry.promise = (async () => {
505
524
  const client = CodexAppServerClient.start(startOptions);
506
- state.client = client;
507
- client.addCloseHandler(clearSharedClientIfCurrent);
525
+ entry.client = client;
526
+ client.addCloseHandler((closedClient) => clearSharedClientEntryIfCurrent(key, closedClient));
508
527
  try {
509
528
  await client.initialize();
510
529
  await applyCodexAppServerAuthProfile({
@@ -523,7 +542,8 @@ async function getSharedCodexAppServerClient(options) {
523
542
  try {
524
543
  return await withTimeout$1(sharedPromise, options?.timeoutMs ?? 0, "codex app-server initialize timed out");
525
544
  } catch (error) {
526
- if (state.promise === sharedPromise && state.key === key) clearSharedCodexAppServerClient();
545
+ const currentEntry = state.clients.get(key);
546
+ if (currentEntry?.promise === sharedPromise) clearSharedClientEntry(key, currentEntry);
527
547
  throw error;
528
548
  }
529
549
  }
@@ -560,38 +580,52 @@ async function createIsolatedCodexAppServerClient(options) {
560
580
  throw error;
561
581
  }
562
582
  }
563
- function clearSharedCodexAppServerClient() {
583
+ function clearSharedCodexAppServerClientIfCurrent(client) {
584
+ if (!client) return false;
564
585
  const state = getSharedCodexAppServerClientState();
565
- const client = state.client;
566
- state.client = void 0;
567
- state.promise = void 0;
568
- state.key = void 0;
569
- client?.close();
586
+ for (const [key, entry] of state.clients) if (entry.client === client) {
587
+ state.clients.delete(key);
588
+ client.close();
589
+ return true;
590
+ }
591
+ return false;
570
592
  }
571
- function clearSharedCodexAppServerClientIfCurrent(client) {
593
+ async function clearSharedCodexAppServerClientIfCurrentAndWait(client, options) {
572
594
  if (!client) return false;
573
595
  const state = getSharedCodexAppServerClientState();
574
- if (state.client !== client) return false;
575
- state.client = void 0;
576
- state.promise = void 0;
577
- state.key = void 0;
578
- client.close();
579
- return true;
596
+ for (const [key, entry] of state.clients) if (entry.client === client) {
597
+ state.clients.delete(key);
598
+ await client.closeAndWait(options);
599
+ return true;
600
+ }
601
+ return false;
580
602
  }
581
603
  async function clearSharedCodexAppServerClientAndWait(options) {
582
604
  const state = getSharedCodexAppServerClientState();
583
- const client = state.client;
584
- state.client = void 0;
585
- state.promise = void 0;
586
- state.key = void 0;
587
- await client?.closeAndWait(options);
605
+ const clients = collectSharedClients(state);
606
+ state.clients.clear();
607
+ await Promise.all(clients.map((client) => client.closeAndWait(options)));
608
+ }
609
+ function getOrCreateSharedClientEntry(state, key) {
610
+ let entry = state.clients.get(key);
611
+ if (!entry) {
612
+ entry = {};
613
+ state.clients.set(key, entry);
614
+ }
615
+ return entry;
616
+ }
617
+ function clearSharedClientEntry(key, entry) {
618
+ const state = getSharedCodexAppServerClientState();
619
+ if (state.clients.get(key) !== entry) return;
620
+ state.clients.delete(key);
621
+ entry.client?.close();
588
622
  }
589
- function clearSharedClientIfCurrent(client) {
623
+ function clearSharedClientEntryIfCurrent(key, client) {
590
624
  const state = getSharedCodexAppServerClientState();
591
- if (state.client !== client) return;
592
- state.client = void 0;
593
- state.promise = void 0;
594
- state.key = void 0;
625
+ if (state.clients.get(key)?.client === client) state.clients.delete(key);
626
+ }
627
+ function collectSharedClients(state) {
628
+ return [...new Set([...state.clients.values()].map((entry) => entry.client).filter((client) => Boolean(client)))];
595
629
  }
596
630
  //#endregion
597
- export { shared_client_exports as a, resolveCodexAppServerAuthAccountCacheKey as c, resolveCodexAppServerEnvApiKeyCacheKey as d, resolveCodexAppServerHomeDir as f, getSharedCodexAppServerClient as i, resolveCodexAppServerAuthProfileId as l, clearSharedCodexAppServerClientIfCurrent as n, withTimeout$1 as o, createIsolatedCodexAppServerClient as r, refreshCodexAppServerAuthTokens as s, clearSharedCodexAppServerClientAndWait as t, resolveCodexAppServerAuthProfileIdForAgent as u };
631
+ export { shared_client_exports as a, resolveCodexAppServerAuthAccountCacheKey as c, resolveCodexAppServerEnvApiKeyCacheKey as d, resolveCodexAppServerHomeDir as f, getSharedCodexAppServerClient as i, resolveCodexAppServerAuthProfileId as l, clearSharedCodexAppServerClientIfCurrentAndWait as n, withTimeout$1 as o, createIsolatedCodexAppServerClient as r, refreshCodexAppServerAuthTokens as s, clearSharedCodexAppServerClientIfCurrent as t, resolveCodexAppServerAuthProfileIdForAgent as u };
@@ -1,11 +1,11 @@
1
- import { c as resolveCodexAppServerRuntimeOptions, s as readCodexPluginConfig } from "./config-3ATInASk.js";
2
- import { a as readCodexDynamicToolCallParams, i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, t as assertCodexThreadForkResponse } from "./protocol-validators-CSY0BFBo.js";
1
+ import { c as resolveCodexAppServerRuntimeOptions, s as readCodexPluginConfig } from "./config-B5pq6hEz.js";
2
+ import { a as readCodexDynamicToolCallParams, i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, t as assertCodexThreadForkResponse } from "./protocol-validators-BGBspNmF.js";
3
3
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
4
- import { r as isCodexAppServerApprovalRequest } from "./client-CA7amCZ8.js";
4
+ import { r as isCodexAppServerApprovalRequest } from "./client-6FkrXfaz.js";
5
5
  import { u as formatCodexUsageLimitErrorMessage } from "./command-formatters-BRW7_Nu7.js";
6
- import { i as getSharedCodexAppServerClient, s as refreshCodexAppServerAuthTokens } from "./shared-client-CnbrvEfV.js";
7
- import { i as readCodexAppServerBinding } from "./session-binding-DbdVqMzW.js";
8
- import { b as createCodexDynamicToolBridge, d as resolveReasoningEffort, n as buildCodexRuntimeThreadConfig, u as resolveCodexAppServerModelProvider, x as filterCodexDynamicTools } from "./thread-lifecycle-BMK4m_PL.js";
6
+ import { i as getSharedCodexAppServerClient, s as refreshCodexAppServerAuthTokens } from "./shared-client-DlvmoLBJ.js";
7
+ import { i as readCodexAppServerBinding } from "./session-binding-DqApZIgD.js";
8
+ import { b as createCodexDynamicToolBridge, d as resolveReasoningEffort, n as buildCodexRuntimeThreadConfig, u as resolveCodexAppServerModelProvider, x as filterCodexDynamicTools } from "./thread-lifecycle-wcyYqwrl.js";
9
9
  import { n as handleCodexAppServerElicitationRequest, r as handleCodexAppServerApprovalRequest, t as filterToolsForVisionInputs } from "./vision-tools-Cm_YicZb.js";
10
10
  import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-dvhq-4pi.js";
11
11
  import { embeddedAgentLog, formatErrorMessage, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
package/dist/test-api.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as resolveCodexAppServerRuntimeOptions } from "./config-3ATInASk.js";
2
- import { a as buildThreadResumeParams, b as createCodexDynamicToolBridge, i as buildDeveloperInstructions, o as buildThreadStartParams, s as buildTurnStartParams, x as filterCodexDynamicTools } from "./thread-lifecycle-BMK4m_PL.js";
1
+ import { c as resolveCodexAppServerRuntimeOptions } from "./config-B5pq6hEz.js";
2
+ import { a as buildThreadResumeParams, b as createCodexDynamicToolBridge, i as buildDeveloperInstructions, o as buildThreadStartParams, s as buildTurnStartParams, x as filterCodexDynamicTools } from "./thread-lifecycle-wcyYqwrl.js";
3
3
  //#region extensions/codex/test-api.ts
4
4
  function resolveCodexPromptSnapshotAppServerOptions(pluginConfig) {
5
5
  return resolveCodexAppServerRuntimeOptions({
@@ -1,11 +1,11 @@
1
- import { r as codexSandboxPolicyForTurn, u as resolveCodexPluginsPolicy } from "./config-3ATInASk.js";
2
- import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-CSY0BFBo.js";
1
+ import { r as codexSandboxPolicyForTurn, u as resolveCodexPluginsPolicy } from "./config-B5pq6hEz.js";
2
+ import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-BGBspNmF.js";
3
3
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
4
4
  import { CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY, renderCodexPromptOverlay } from "./prompt-overlay.js";
5
5
  import { isModernCodexModel } from "./provider.js";
6
- import { i as isCodexAppServerConnectionClosedError } from "./client-CA7amCZ8.js";
7
- import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DbdVqMzW.js";
8
- import { a as defaultCodexAppInventoryCache, r as readCodexPluginInventory, t as ensureCodexPluginActivation } from "./plugin-activation-BDU4e-NA.js";
6
+ import { i as isCodexAppServerConnectionClosedError } from "./client-6FkrXfaz.js";
7
+ import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DqApZIgD.js";
8
+ import { a as defaultCodexAppInventoryCache, r as readCodexPluginInventory, t as ensureCodexPluginActivation } from "./plugin-activation-B49xb7pI.js";
9
9
  import crypto from "node:crypto";
10
10
  import { HEARTBEAT_RESPONSE_TOOL_NAME, createAgentToolResultMiddlewareRunner, createCodexAppServerToolResultExtensionRunner, embeddedAgentLog, extractToolResultMediaArtifact, filterToolResultMediaUrls, isActiveHarnessContextEngine, isMessagingTool, isMessagingToolSendAction, isToolWrappedWithBeforeToolCallHook, normalizeHeartbeatToolResponse, runAgentHarnessAfterToolCallHook, wrapToolWithBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
11
11
  import { buildCodexUserMcpServersThreadConfigPatch } from "openclaw/plugin-sdk/codex-mcp-projection";
@@ -19,10 +19,10 @@ const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
19
19
  "exec",
20
20
  "process",
21
21
  "update_plan",
22
- "tool_search_code",
23
- "tool_search",
22
+ "tool_call",
24
23
  "tool_describe",
25
- "tool_call"
24
+ "tool_search",
25
+ "tool_search_code"
26
26
  ];
27
27
  const DYNAMIC_TOOL_NAME_ALIASES = {
28
28
  bash: "exec",
@@ -872,7 +872,7 @@ async function startOrResumeThread(params) {
872
872
  }
873
873
  } else try {
874
874
  const authProfileId = params.params.authProfileId ?? binding.authProfileId;
875
- const resumeConfig = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch);
875
+ const resumeConfig = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, params.finalConfigPatch);
876
876
  const response = assertCodexThreadResumeResponse(await params.client.request("thread/resume", buildThreadResumeParams(params.params, {
877
877
  threadId: binding.threadId,
878
878
  authProfileId,
@@ -939,7 +939,7 @@ async function startOrResumeThread(params) {
939
939
  await clearCodexAppServerBinding(params.params.sessionFile);
940
940
  }
941
941
  const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await params.pluginThreadConfig.build() : void 0;
942
- const config = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch);
942
+ const config = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, params.finalConfigPatch);
943
943
  const response = assertCodexThreadStartResponse(await params.client.request("thread/start", buildThreadStartParams(params.params, {
944
944
  cwd: params.cwd,
945
945
  dynamicTools: params.dynamicTools,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.5.16-beta.2",
3
+ "version": "2026.5.16-beta.4",
4
4
  "description": "OpenClaw Codex harness and model provider plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,10 +27,10 @@
27
27
  "minHostVersion": ">=2026.5.1-beta.1"
28
28
  },
29
29
  "compat": {
30
- "pluginApi": ">=2026.5.16-beta.2"
30
+ "pluginApi": ">=2026.5.16-beta.4"
31
31
  },
32
32
  "build": {
33
- "openclawVersion": "2026.5.16-beta.2"
33
+ "openclawVersion": "2026.5.16-beta.4"
34
34
  },
35
35
  "release": {
36
36
  "publishToClawHub": true,
@@ -45,7 +45,7 @@
45
45
  "openclaw.plugin.json"
46
46
  ],
47
47
  "peerDependencies": {
48
- "openclaw": ">=2026.5.16-beta.2"
48
+ "openclaw": ">=2026.5.16-beta.4"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "openclaw": {