@openclaw/codex 2026.5.31-beta.4 → 2026.6.1-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.
@@ -1,7 +1,7 @@
1
1
  //#region extensions/codex/src/app-server/client-factory.ts
2
2
  let sharedClientModulePromise = null;
3
3
  const loadSharedClientModule = async () => {
4
- sharedClientModulePromise ??= import("./shared-client-ByKKWtYX.js").then((n) => n.s);
4
+ sharedClientModulePromise ??= import("./shared-client-DUWLidr5.js").then((n) => n.s);
5
5
  return await sharedClientModulePromise;
6
6
  };
7
7
  const defaultCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => loadSharedClientModule().then(({ getSharedCodexAppServerClient }) => getSharedCodexAppServerClient({
@@ -1,12 +1,12 @@
1
1
  import { d as resolveCodexAppServerRuntimeOptions, o as isCodexFastServiceTier } from "./config-AlzuNKCY.js";
2
- import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-DEgJXKQy.js";
2
+ import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-DAJvlyJu.js";
3
3
  import { l as isJsonObject } from "./client-BnOmn0y-.js";
4
- import { a as readCodexAppServerBinding, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-BXJAV_xy.js";
5
- import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-DYdA1i4c.js";
4
+ import { a as readCodexAppServerBinding, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DWiEGATW.js";
5
+ import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-CPtFWp-f.js";
6
6
  import { a as buildHelp, c as formatCodexStatus, d as formatModels, f as formatSkills, l as formatComputerUseStatus, m as readString$1, o as formatAccount, p as formatThreads, s as formatCodexDisplayText, u as formatList, v as summarizeCodexAccountUsage } from "./notification-correlation-BykOI_jh.js";
7
7
  import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-DMCJlzmz.js";
8
- import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, m as setCodexConversationFastMode, o as formatCodexCliSessions, p as readCodexConversationActiveTurn, r as startCodexConversationThread, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./conversation-binding-ffCScZef.js";
9
- import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-BbqwzKz3.js";
8
+ import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, m as setCodexConversationFastMode, o as formatCodexCliSessions, p as readCodexConversationActiveTurn, r as startCodexConversationThread, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./conversation-binding-CqVPKJPp.js";
9
+ import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-DYLSxIfq.js";
10
10
  import { n as rememberCodexRateLimits } from "./rate-limit-cache-N66I-Rd7.js";
11
11
  import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
12
12
  import crypto from "node:crypto";
@@ -1,7 +1,7 @@
1
1
  import { d as resolveCodexAppServerRuntimeOptions } from "./config-AlzuNKCY.js";
2
- import { a as readCodexAppServerBinding } from "./session-binding-BXJAV_xy.js";
2
+ import { a as readCodexAppServerBinding } from "./session-binding-DWiEGATW.js";
3
3
  import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DMCJlzmz.js";
4
- import { t as defaultCodexAppServerClientFactory } from "./client-factory-DBgo1xC5.js";
4
+ import { t as defaultCodexAppServerClientFactory } from "./client-factory-3ykiiX2z.js";
5
5
  import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
6
6
  //#region extensions/codex/src/app-server/compact.ts
7
7
  const warnedIgnoredCompactionOverrides = /* @__PURE__ */ new Set();
@@ -1,5 +1,5 @@
1
1
  import { d as resolveCodexAppServerRuntimeOptions, f as resolveCodexComputerUseConfig } from "./config-AlzuNKCY.js";
2
- import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-DYdA1i4c.js";
2
+ import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-CPtFWp-f.js";
3
3
  import { existsSync } from "node:fs";
4
4
  //#region extensions/codex/src/app-server/computer-use.ts
5
5
  var CodexComputerUseSetupError = class extends Error {
@@ -1,10 +1,10 @@
1
1
  import { d as resolveCodexAppServerRuntimeOptions, i as codexSandboxPolicyForTurn, m as resolveOpenClawExecPolicyForCodexAppServer, o as isCodexFastServiceTier } from "./config-AlzuNKCY.js";
2
2
  import { l as isJsonObject } from "./client-BnOmn0y-.js";
3
- import { t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-Bnlv_Q8u.js";
4
- import { a as readCodexAppServerBinding, i as normalizeCodexAppServerBindingModelProvider, r as isCodexAppServerNativeAuthProfile, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-BXJAV_xy.js";
5
- import { r as CODEX_CONTROL_METHODS } from "./request-DYdA1i4c.js";
3
+ import { t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-6nrEQZMV.js";
4
+ import { a as readCodexAppServerBinding, i as normalizeCodexAppServerBindingModelProvider, r as isCodexAppServerNativeAuthProfile, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DWiEGATW.js";
5
+ import { r as CODEX_CONTROL_METHODS } from "./request-CPtFWp-f.js";
6
6
  import { i as readCodexNotificationTurnId, r as readCodexNotificationThreadId, s as formatCodexDisplayText } from "./notification-correlation-BykOI_jh.js";
7
- import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient } from "./shared-client-ByKKWtYX.js";
7
+ import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient } from "./shared-client-DUWLidr5.js";
8
8
  import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-DMCJlzmz.js";
9
9
  import { resolveTimerTimeoutMs, timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
10
10
  import os from "node:os";
package/dist/harness.js CHANGED
@@ -28,31 +28,31 @@ function createCodexAppServerAgentHarness(options) {
28
28
  };
29
29
  },
30
30
  runAttempt: async (params) => {
31
- const { runCodexAppServerAttempt } = await import("./run-attempt-BHkuGybn.js");
31
+ const { runCodexAppServerAttempt } = await import("./run-attempt-DM53zFlW.js");
32
32
  return runCodexAppServerAttempt(params, {
33
33
  pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
34
34
  nativeHookRelay: { enabled: true }
35
35
  });
36
36
  },
37
37
  runSideQuestion: async (params) => {
38
- const { runCodexAppServerSideQuestion } = await import("./side-question-6HqYQ06R.js");
38
+ const { runCodexAppServerSideQuestion } = await import("./side-question-dIZf9RBV.js");
39
39
  return runCodexAppServerSideQuestion(params, {
40
40
  pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
41
41
  nativeHookRelay: { enabled: true }
42
42
  });
43
43
  },
44
44
  compact: async (params) => {
45
- const { maybeCompactCodexAppServerSession } = await import("./compact-Dgz_jIBU.js");
45
+ const { maybeCompactCodexAppServerSession } = await import("./compact-D1dSrNrT.js");
46
46
  return maybeCompactCodexAppServerSession(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
47
47
  },
48
48
  reset: async (params) => {
49
49
  if (params.sessionFile) {
50
- const { clearCodexAppServerBinding } = await import("./session-binding-BXJAV_xy.js").then((n) => n.o);
50
+ const { clearCodexAppServerBinding } = await import("./session-binding-DWiEGATW.js").then((n) => n.o);
51
51
  await clearCodexAppServerBinding(params.sessionFile);
52
52
  }
53
53
  },
54
54
  dispose: async () => {
55
- const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-ByKKWtYX.js").then((n) => n.s);
55
+ const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-DUWLidr5.js").then((n) => n.s);
56
56
  await clearSharedCodexAppServerClientAndWait();
57
57
  }
58
58
  };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { createCodexAppServerAgentHarness } from "./harness.js";
2
2
  import { d as resolveCodexAppServerRuntimeOptions, s as isCodexPluginsMarketplaceName, t as CODEX_PLUGINS_MARKETPLACE_NAME, u as readCodexPluginConfig } from "./config-AlzuNKCY.js";
3
3
  import { buildCodexProvider } from "./provider.js";
4
- import { v as ensureCodexPluginActivation, x as defaultCodexAppInventoryCache, y as pluginReadParams } from "./thread-lifecycle-Bnlv_Q8u.js";
4
+ import { v as ensureCodexPluginActivation, x as defaultCodexAppInventoryCache, y as pluginReadParams } from "./thread-lifecycle-6nrEQZMV.js";
5
5
  import { buildCodexMediaUnderstandingProvider } from "./media-understanding-provider.js";
6
- import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-DYdA1i4c.js";
6
+ import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-CPtFWp-f.js";
7
7
  import { s as formatCodexDisplayText } from "./notification-correlation-BykOI_jh.js";
8
- import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient, n as clearSharedCodexAppServerClientIfCurrentAndWait, p as resolveCodexAppServerFallbackApiKeyCacheKey, u as resolveCodexAppServerAuthAccountCacheKey } from "./shared-client-ByKKWtYX.js";
9
- import { a as createCodexCliSessionNodeInvokePolicies, c as resolveCodexCliSessionForBindingOnNode, i as createCodexCliSessionNodeHostCommands, l as resumeCodexCliSessionOnNode, n as handleCodexConversationInboundClaim, s as listCodexCliSessionsOnNode, t as handleCodexConversationBindingResolved } from "./conversation-binding-ffCScZef.js";
8
+ import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient, n as clearSharedCodexAppServerClientIfCurrentAndWait, p as resolveCodexAppServerFallbackApiKeyCacheKey, u as resolveCodexAppServerAuthAccountCacheKey } from "./shared-client-DUWLidr5.js";
9
+ import { a as createCodexCliSessionNodeInvokePolicies, c as resolveCodexCliSessionForBindingOnNode, i as createCodexCliSessionNodeHostCommands, l as resumeCodexCliSessionOnNode, n as handleCodexConversationInboundClaim, s as listCodexCliSessionsOnNode, t as handleCodexConversationBindingResolved } from "./conversation-binding-CqVPKJPp.js";
10
10
  import { mutateConfigFile } from "openclaw/plugin-sdk/config-mutation";
11
11
  import { resolveLivePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
12
12
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
@@ -48,7 +48,7 @@ async function handleCodexCommand(ctx, options = {}) {
48
48
  }
49
49
  }
50
50
  async function loadDefaultCodexSubcommandHandler() {
51
- const { handleCodexSubcommand } = await import("./command-handlers-82GqsKYq.js");
51
+ const { handleCodexSubcommand } = await import("./command-handlers-VhJdcXcI.js");
52
52
  return handleCodexSubcommand;
53
53
  }
54
54
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS } from "./provider-catalog.js";
2
2
  import { d as resolveCodexAppServerRuntimeOptions } from "./config-AlzuNKCY.js";
3
3
  import { i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, o as readCodexErrorNotification, r as assertCodexThreadStartResponse } from "./protocol-validators-DIt7cXIp.js";
4
- import { i as readModelListResult } from "./models-DEgJXKQy.js";
4
+ import { i as readModelListResult } from "./models-DAJvlyJu.js";
5
5
  import { l as isJsonObject } from "./client-BnOmn0y-.js";
6
- import { r as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-Bnlv_Q8u.js";
6
+ import { r as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-6nrEQZMV.js";
7
7
  import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
8
8
  import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
9
9
  //#region extensions/codex/media-understanding-provider.ts
@@ -64,7 +64,7 @@ async function runBoundedCodexVisionTurn(params) {
64
64
  const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.options.pluginConfig });
65
65
  const timeoutMs = resolveTimerTimeoutMs(params.timeoutMs, 100, 100);
66
66
  const ownsClient = !params.options.clientFactory;
67
- const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-ByKKWtYX.js").then((n) => n.s).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
67
+ const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-DUWLidr5.js").then((n) => n.s).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
68
68
  startOptions: appServer.start,
69
69
  timeoutMs,
70
70
  authProfileId: params.profile
@@ -40,7 +40,7 @@ async function listAllCodexAppServerModels(options = {}) {
40
40
  async function withCodexAppServerModelClient(options, run) {
41
41
  const timeoutMs = options.timeoutMs ?? 2500;
42
42
  const useSharedClient = options.sharedClient !== false;
43
- const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-ByKKWtYX.js").then((n) => n.s);
43
+ const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-DUWLidr5.js").then((n) => n.s);
44
44
  const client = useSharedClient ? await getLeasedSharedCodexAppServerClient({
45
45
  startOptions: options.startOptions,
46
46
  timeoutMs,
@@ -1,5 +1,5 @@
1
1
  import { l as isJsonObject } from "./client-BnOmn0y-.js";
2
- import { S as invalidInlineImageText, w as sanitizeInlineImageDataUrl } from "./thread-lifecycle-Bnlv_Q8u.js";
2
+ import { S as invalidInlineImageText, w as sanitizeInlineImageDataUrl } from "./thread-lifecycle-6nrEQZMV.js";
3
3
  import { s as formatCodexDisplayText } from "./notification-correlation-BykOI_jh.js";
4
4
  import { addTimerTimeoutGraceMs, finiteSecondsToTimerSafeMilliseconds, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
5
5
  import { createHash } from "node:crypto";
@@ -880,44 +880,6 @@ function formatErrorMessage$1(error) {
880
880
  return error instanceof Error ? error.message : String(error);
881
881
  }
882
882
  //#endregion
883
- //#region extensions/codex/src/app-server/dynamic-tool-profile.ts
884
- const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
885
- "read",
886
- "write",
887
- "edit",
888
- "apply_patch",
889
- "exec",
890
- "process",
891
- "update_plan",
892
- "tool_call",
893
- "tool_describe",
894
- "tool_search",
895
- "tool_search_code"
896
- ];
897
- const DYNAMIC_TOOL_NAME_ALIASES = {
898
- bash: "exec",
899
- "apply-patch": "apply_patch"
900
- };
901
- function normalizeCodexDynamicToolName(name) {
902
- const normalized = name.trim().toLowerCase();
903
- return DYNAMIC_TOOL_NAME_ALIASES[normalized] ?? normalized;
904
- }
905
- function isForcedPrivateQaCodexRuntime(env = process.env) {
906
- return env.OPENCLAW_BUILD_PRIVATE_QA === "1" && env.OPENCLAW_QA_FORCE_RUNTIME?.trim().toLowerCase() === "codex";
907
- }
908
- function resolveCodexDynamicToolsLoading(config, env = process.env) {
909
- return isForcedPrivateQaCodexRuntime(env) ? "direct" : config.codexDynamicToolsLoading ?? "searchable";
910
- }
911
- function filterCodexDynamicTools(tools, config, env = process.env) {
912
- const excludes = /* @__PURE__ */ new Set();
913
- if (!isForcedPrivateQaCodexRuntime(env)) for (const name of CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES) excludes.add(name);
914
- for (const name of config.codexDynamicToolsExclude ?? []) {
915
- const trimmed = normalizeCodexDynamicToolName(name);
916
- if (trimmed) excludes.add(trimmed);
917
- }
918
- return excludes.size === 0 ? tools : tools.filter((tool) => !excludes.has(normalizeCodexDynamicToolName(tool.name)));
919
- }
920
- //#endregion
921
883
  //#region extensions/codex/src/app-server/vision-tools.ts
922
884
  function filterToolsForVisionInputs(tools, params) {
923
885
  if (!params.modelHasVision || !params.hasInboundImages) return tools;
@@ -2167,4 +2129,4 @@ function sortJsonValue(value) {
2167
2129
  return sorted;
2168
2130
  }
2169
2131
  //#endregion
2170
- export { resolveCodexTurnAssistantCompletionIdleTimeoutMs as C, withCodexStartupTimeout as E, resolveCodexStartupTimeoutMs as S, resolveCodexTurnTerminalIdleTimeoutMs as T, normalizeCodexDynamicToolName as _, createCodexNativeHookRelay as a, CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS as b, scheduleCodexNativeHookRelayUnregister as c, emitDynamicToolErrorDiagnostic as d, emitDynamicToolStartedDiagnostic as f, isForcedPrivateQaCodexRuntime as g, filterCodexDynamicTools as h, buildCodexNativeHookRelayDisabledConfig as i, handleCodexAppServerElicitationRequest as l, filterToolsForVisionInputs as m, CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS as n, resolveCodexNativeHookRelayEvents as o, emitDynamicToolTerminalDiagnostic as p, buildCodexNativeHookRelayConfig as r, resolveCodexNativeHookRelayTtlMs as s, CODEX_NATIVE_HOOK_RELAY_EVENTS as t, createCodexDynamicToolBridge as u, resolveCodexDynamicToolsLoading as v, resolveCodexTurnCompletionIdleTimeoutMs as w, resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs as x, handleCodexAppServerApprovalRequest as y };
2132
+ export { withCodexStartupTimeout as S, resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs as _, createCodexNativeHookRelay as a, resolveCodexTurnCompletionIdleTimeoutMs as b, scheduleCodexNativeHookRelayUnregister as c, emitDynamicToolErrorDiagnostic as d, emitDynamicToolStartedDiagnostic as f, CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS as g, handleCodexAppServerApprovalRequest as h, buildCodexNativeHookRelayDisabledConfig as i, handleCodexAppServerElicitationRequest as l, filterToolsForVisionInputs as m, CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS as n, resolveCodexNativeHookRelayEvents as o, emitDynamicToolTerminalDiagnostic as p, buildCodexNativeHookRelayConfig as r, resolveCodexNativeHookRelayTtlMs as s, CODEX_NATIVE_HOOK_RELAY_EVENTS as t, createCodexDynamicToolBridge as u, resolveCodexStartupTimeoutMs as v, resolveCodexTurnTerminalIdleTimeoutMs as x, resolveCodexTurnAssistantCompletionIdleTimeoutMs as y };
package/dist/provider.js CHANGED
@@ -123,7 +123,7 @@ async function listModelsBestEffort(params) {
123
123
  }
124
124
  }
125
125
  async function listCodexAppServerModelsLazy(options) {
126
- const { listCodexAppServerModels } = await import("./models-DEgJXKQy.js").then((n) => n.r);
126
+ const { listCodexAppServerModels } = await import("./models-DAJvlyJu.js").then((n) => n.r);
127
127
  return listCodexAppServerModels(options);
128
128
  }
129
129
  function normalizeTimeoutMs(value) {
@@ -1,6 +1,6 @@
1
1
  import { n as CodexAppServerRpcError } from "./client-BnOmn0y-.js";
2
- import { b as buildCodexAppInventoryCacheKey } from "./thread-lifecycle-Bnlv_Q8u.js";
3
- import { a as releaseLeasedSharedCodexAppServerClient, c as withTimeout, i as getLeasedSharedCodexAppServerClient, m as resolveCodexAppServerHomeDir, r as createIsolatedCodexAppServerClient } from "./shared-client-ByKKWtYX.js";
2
+ import { b as buildCodexAppInventoryCacheKey } from "./thread-lifecycle-6nrEQZMV.js";
3
+ import { a as releaseLeasedSharedCodexAppServerClient, c as withTimeout, i as getLeasedSharedCodexAppServerClient, m as resolveCodexAppServerHomeDir, r as createIsolatedCodexAppServerClient } from "./shared-client-DUWLidr5.js";
4
4
  import { t as resolveCodexAppServerDirectSandboxBypassBlock } from "./sandbox-guard-DMCJlzmz.js";
5
5
  import { createHash } from "node:crypto";
6
6
  //#region extensions/codex/src/app-server/capabilities.ts
@@ -1,15 +1,15 @@
1
1
  import { a as isCodexAppServerApprovalPolicyAllowedByRequirements, c as isCodexSandboxExecServerEnabled, d as resolveCodexAppServerRuntimeOptions, f as resolveCodexComputerUseConfig, g as withMcpElicitationsApprovalPolicy, h as shouldAutoApproveCodexAppServerApprovals, m as resolveOpenClawExecPolicyForCodexAppServer, p as resolveCodexPluginsPolicy, u as readCodexPluginConfig } from "./config-AlzuNKCY.js";
2
2
  import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse } from "./protocol-validators-DIt7cXIp.js";
3
3
  import { a as isCodexAppServerConnectionClosedError, i as isCodexAppServerApprovalRequest, l as isJsonObject, r as compareCodexAppServerVersions, s as MIN_CODEX_SANDBOX_EXEC_SERVER_APP_SERVER_VERSION } from "./client-BnOmn0y-.js";
4
- import { C as sanitizeCodexHistoryImagePayloads, D as resolveCodexContextEngineProjectionReserveTokens, E as resolveCodexContextEngineProjectionMaxChars, T as projectContextEngineAssemblyForCodex, _ as shouldBuildCodexPluginThreadConfig, a as buildDeveloperInstructions, c as codexDynamicToolsFingerprint, f as startOrResumeThread, g as mergeCodexThreadConfigs, h as buildCodexPluginThreadConfigInputFingerprint, i as buildContextEngineBinding, l as isContextEngineBindingCompatible, m as buildCodexPluginThreadConfig, n as areCodexDynamicToolFingerprintsCompatible, o as buildTurnCollaborationMode, p as isCodexAppServerProfilerEnabled, s as buildTurnStartParams, x as defaultCodexAppInventoryCache } from "./thread-lifecycle-Bnlv_Q8u.js";
5
- import { a as readCodexAppServerBinding, n as clearCodexAppServerBindingForThread, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-BXJAV_xy.js";
6
- import { n as buildCodexPluginAppCacheKey, r as CODEX_CONTROL_METHODS } from "./request-DYdA1i4c.js";
4
+ import { A as projectContextEngineAssemblyForCodex, C as sanitizeCodexHistoryImagePayloads, D as normalizeCodexDynamicToolName$1, E as isForcedPrivateQaCodexRuntime, M as resolveCodexContextEngineProjectionReserveTokens, T as filterCodexDynamicTools, _ as shouldBuildCodexPluginThreadConfig, a as buildDeveloperInstructions, c as codexDynamicToolsFingerprint, f as startOrResumeThread, g as mergeCodexThreadConfigs, h as buildCodexPluginThreadConfigInputFingerprint, i as buildContextEngineBinding, j as resolveCodexContextEngineProjectionMaxChars, k as resolveCodexDynamicToolsLoadingForModel, l as isContextEngineBindingCompatible, m as buildCodexPluginThreadConfig, n as areCodexDynamicToolFingerprintsCompatible, o as buildTurnCollaborationMode, p as isCodexAppServerProfilerEnabled, s as buildTurnStartParams, x as defaultCodexAppInventoryCache } from "./thread-lifecycle-6nrEQZMV.js";
5
+ import { a as readCodexAppServerBinding, n as clearCodexAppServerBindingForThread, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DWiEGATW.js";
6
+ import { n as buildCodexPluginAppCacheKey, r as CODEX_CONTROL_METHODS } from "./request-CPtFWp-f.js";
7
7
  import { _ as shouldRefreshCodexRateLimitsForUsageLimitMessage, g as resolveCodexUsageLimitResetAtMs, h as formatCodexUsageLimitErrorMessage, i as readCodexNotificationTurnId, n as isCodexNotificationForTurn, r as readCodexNotificationThreadId, s as formatCodexDisplayText, t as describeCodexNotificationCorrelation } from "./notification-correlation-BykOI_jh.js";
8
- import { a as releaseLeasedSharedCodexAppServerClient, d as resolveCodexAppServerAuthProfileId, f as resolveCodexAppServerAuthProfileIdForAgent, l as refreshCodexAppServerAuthTokens, m as resolveCodexAppServerHomeDir, o as retireSharedCodexAppServerClientIfCurrent, p as resolveCodexAppServerFallbackApiKeyCacheKey, t as clearSharedCodexAppServerClientIfCurrent, u as resolveCodexAppServerAuthAccountCacheKey } from "./shared-client-ByKKWtYX.js";
8
+ import { a as releaseLeasedSharedCodexAppServerClient, d as resolveCodexAppServerAuthProfileId, f as resolveCodexAppServerAuthProfileIdForAgent, l as refreshCodexAppServerAuthTokens, m as resolveCodexAppServerHomeDir, o as retireSharedCodexAppServerClientIfCurrent, p as resolveCodexAppServerFallbackApiKeyCacheKey, t as clearSharedCodexAppServerClientIfCurrent, u as resolveCodexAppServerAuthAccountCacheKey } from "./shared-client-DUWLidr5.js";
9
9
  import { i as resolveCodexNativeExecutionPolicy } from "./sandbox-guard-DMCJlzmz.js";
10
- import { n as defaultLeasedCodexAppServerClientFactory } from "./client-factory-DBgo1xC5.js";
11
- import { C as resolveCodexTurnAssistantCompletionIdleTimeoutMs, E as withCodexStartupTimeout, S as resolveCodexStartupTimeoutMs, T as resolveCodexTurnTerminalIdleTimeoutMs, _ as normalizeCodexDynamicToolName$1, a as createCodexNativeHookRelay, b as CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS, c as scheduleCodexNativeHookRelayUnregister, d as emitDynamicToolErrorDiagnostic, f as emitDynamicToolStartedDiagnostic, g as isForcedPrivateQaCodexRuntime, h as filterCodexDynamicTools, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerElicitationRequest, m as filterToolsForVisionInputs, n as CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS, o as resolveCodexNativeHookRelayEvents, p as emitDynamicToolTerminalDiagnostic, r as buildCodexNativeHookRelayConfig, s as resolveCodexNativeHookRelayTtlMs, u as createCodexDynamicToolBridge, v as resolveCodexDynamicToolsLoading, w as resolveCodexTurnCompletionIdleTimeoutMs, x as resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs, y as handleCodexAppServerApprovalRequest } from "./native-hook-relay-D_LPgQFs.js";
12
- import { t as ensureCodexComputerUse } from "./computer-use-BbqwzKz3.js";
10
+ import { n as defaultLeasedCodexAppServerClientFactory } from "./client-factory-3ykiiX2z.js";
11
+ import { S as withCodexStartupTimeout, _ as resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs, a as createCodexNativeHookRelay, b as resolveCodexTurnCompletionIdleTimeoutMs, c as scheduleCodexNativeHookRelayUnregister, d as emitDynamicToolErrorDiagnostic, f as emitDynamicToolStartedDiagnostic, g as CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS, h as handleCodexAppServerApprovalRequest, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerElicitationRequest, m as filterToolsForVisionInputs, n as CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS, o as resolveCodexNativeHookRelayEvents, p as emitDynamicToolTerminalDiagnostic, r as buildCodexNativeHookRelayConfig, s as resolveCodexNativeHookRelayTtlMs, u as createCodexDynamicToolBridge, v as resolveCodexStartupTimeoutMs, x as resolveCodexTurnTerminalIdleTimeoutMs, y as resolveCodexTurnAssistantCompletionIdleTimeoutMs } from "./native-hook-relay-CIJt8cLN.js";
12
+ import { t as ensureCodexComputerUse } from "./computer-use-DYLSxIfq.js";
13
13
  import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-N66I-Rd7.js";
14
14
  import { asDateTimestampMs, parseStrictNonNegativeInteger, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
15
15
  import { createHash, randomUUID } from "node:crypto";
@@ -1535,7 +1535,7 @@ function sendResult(socket, id, result) {
1535
1535
  socket.send(JSON.stringify({
1536
1536
  jsonrpc: "2.0",
1537
1537
  id,
1538
- result: result ?? {}
1538
+ result: result === void 0 ? {} : result
1539
1539
  }));
1540
1540
  }
1541
1541
  function sendError(socket, id, code, message) {
@@ -2782,6 +2782,7 @@ async function startCodexAttemptThread(params) {
2782
2782
  mcpServersFingerprintEvaluated: params.bundleMcpThreadConfig.evaluated,
2783
2783
  environmentSelection: startupEnvironmentSelection,
2784
2784
  contextEngineProjection: params.contextEngineProjection,
2785
+ signal: params.signal,
2785
2786
  pluginThreadConfig: pluginThreadConfigRequired ? {
2786
2787
  enabled: true,
2787
2788
  inputFingerprint: pluginThreadConfigInputFingerprint,
@@ -2929,6 +2930,10 @@ function createCodexSteeringQueue(params) {
2929
2930
  });
2930
2931
  clearBatchTimer();
2931
2932
  const debounceMs = normalizeCodexSteerDebounceMs(options?.debounceMs);
2933
+ if (debounceMs === 0) {
2934
+ flushBatch().catch(() => void 0);
2935
+ return;
2936
+ }
2932
2937
  batchTimer = setTimeout(() => {
2933
2938
  batchTimer = void 0;
2934
2939
  flushBatch().catch(() => void 0);
@@ -3051,6 +3056,12 @@ function createCodexAttemptTurnWatchController(params) {
3051
3056
  scheduleCompletionIdleWatch();
3052
3057
  scheduleTerminalIdleWatch();
3053
3058
  }
3059
+ function isCompletionIdleTimeoutDueBeforeAttempt(timeoutMs) {
3060
+ if (params.isCompleted() || params.isTerminalTurnNotificationQueued() || params.signal.aborted || !completionIdleWatchArmed || params.getActiveAppServerTurnRequests() > 0) return false;
3061
+ const completionTimeoutMs = completionIdleTimeoutOverrideMs ?? turnCompletionIdleTimeoutMs;
3062
+ if (completionTimeoutMs > timeoutMs) return false;
3063
+ return Math.max(0, Date.now() - completionLastActivityAt) >= completionTimeoutMs;
3064
+ }
3054
3065
  function recordAttemptProgress(reason, options) {
3055
3066
  attemptIdleTimeoutOverrideMs = options?.attemptTimeoutMs !== void 0 ? resolveWatchTimeoutMs(options.attemptTimeoutMs) : void 0;
3056
3067
  attemptLastProgressAt = completionLastActivityAt;
@@ -3104,6 +3115,10 @@ function createCodexAttemptTurnWatchController(params) {
3104
3115
  scheduleAttemptIdleWatch();
3105
3116
  return;
3106
3117
  }
3118
+ if (isCompletionIdleTimeoutDueBeforeAttempt(timeoutMs)) {
3119
+ fireCompletionIdleTimeout();
3120
+ return;
3121
+ }
3107
3122
  const timeout = {
3108
3123
  kind: "progress",
3109
3124
  idleMs,
@@ -3806,6 +3821,7 @@ const CODEX_PROMPT_TOTAL_INPUT_KEYS = [
3806
3821
  ];
3807
3822
  const MAX_TOOL_OUTPUT_DELTA_MESSAGES_PER_ITEM = 20;
3808
3823
  const TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS = 12e3;
3824
+ const MISSING_TOOL_RESULT_ERROR = "OpenClaw recorded a native Codex tool.call without a matching tool.result before the turn completed.";
3809
3825
  const GENERATED_IMAGE_MEDIA_SUBDIR = "tool-image-generation";
3810
3826
  const BYTES_PER_MB = 1024 * 1024;
3811
3827
  const DEFAULT_GENERATED_IMAGE_MAX_BYTES = 6 * BYTES_PER_MB;
@@ -3852,6 +3868,10 @@ var CodexAppServerEventProjector = class {
3852
3868
  this.toolTranscriptMessages = [];
3853
3869
  this.toolTranscriptCallIds = /* @__PURE__ */ new Set();
3854
3870
  this.toolTranscriptResultIds = /* @__PURE__ */ new Set();
3871
+ this.toolTranscriptNamesById = /* @__PURE__ */ new Map();
3872
+ this.toolTrajectoryCallIds = /* @__PURE__ */ new Set();
3873
+ this.toolTrajectoryResultIds = /* @__PURE__ */ new Set();
3874
+ this.toolTrajectoryNamesById = /* @__PURE__ */ new Map();
3855
3875
  this.transcriptToolProgressCallIds = /* @__PURE__ */ new Set();
3856
3876
  this.nativeGeneratedMediaUrls = /* @__PURE__ */ new Set();
3857
3877
  this.nativeGeneratedMediaItemIds = /* @__PURE__ */ new Set();
@@ -3862,6 +3882,7 @@ var CodexAppServerEventProjector = class {
3862
3882
  this.reasoningStarted = false;
3863
3883
  this.reasoningEnded = false;
3864
3884
  this.promptErrorSource = null;
3885
+ this.synthesizedMissingToolResultError = null;
3865
3886
  this.aborted = false;
3866
3887
  this.guardianReviewCount = 0;
3867
3888
  this.completedCompactionCount = 0;
@@ -3935,6 +3956,7 @@ var CodexAppServerEventProjector = class {
3935
3956
  const assistantTexts = this.collectAssistantTexts();
3936
3957
  const reasoningText = collectReasoningTextValues(this.reasoningTextByGroup, this.reasoningItemOrder).join("\n\n");
3937
3958
  const planText = collectTextValues(this.planTextByItem).join("\n\n");
3959
+ this.synthesizeMissingToolResults({ failClosed: !this.completedTurn || this.completedTurn.status !== "completed" || assistantTexts.length > 0 });
3938
3960
  const lastAssistant = assistantTexts.length > 0 ? this.createAssistantMessage(assistantTexts.join("\n\n")) : void 0;
3939
3961
  const turnId = this.turnId;
3940
3962
  const messagesSnapshot = this.params.suppressNextUserMessagePersistence ? [] : [attachCodexMirrorIdentity(buildCodexUserPromptMessage(this.params), `${turnId}:prompt`)];
@@ -3943,7 +3965,7 @@ var CodexAppServerEventProjector = class {
3943
3965
  messagesSnapshot.push(...this.toolTranscriptMessages);
3944
3966
  if (lastAssistant) messagesSnapshot.push(attachCodexMirrorIdentity(lastAssistant, `${turnId}:assistant`));
3945
3967
  const turnFailed = this.completedTurn?.status === "failed";
3946
- const promptError = this.promptError ?? (turnFailed ? this.completedTurn?.error?.message ?? "codex app-server turn failed" : null);
3968
+ const promptError = this.promptError ?? this.synthesizedMissingToolResultError ?? (turnFailed ? this.completedTurn?.error?.message ?? "codex app-server turn failed" : null);
3947
3969
  const agentHarnessResultClassification = classifyAgentHarnessTerminalOutcome({
3948
3970
  assistantTexts,
3949
3971
  reasoningText,
@@ -4594,6 +4616,8 @@ var CodexAppServerEventProjector = class {
4594
4616
  }
4595
4617
  recordToolTrajectoryEvent(params) {
4596
4618
  if (params.phase === "start") {
4619
+ this.toolTrajectoryCallIds.add(params.item.id);
4620
+ this.toolTrajectoryNamesById.set(params.item.id, params.name);
4597
4621
  this.options.trajectoryRecorder?.recordEvent("tool.call", {
4598
4622
  threadId: this.threadId,
4599
4623
  turnId: this.turnId,
@@ -4604,6 +4628,7 @@ var CodexAppServerEventProjector = class {
4604
4628
  });
4605
4629
  return;
4606
4630
  }
4631
+ this.toolTrajectoryResultIds.add(params.item.id);
4607
4632
  const toolResult = itemToolResult(params.item).result;
4608
4633
  const output = itemOutputText(params.item, this.toolResultOutputTextByItem);
4609
4634
  this.options.trajectoryRecorder?.recordEvent("tool.result", {
@@ -4774,6 +4799,7 @@ var CodexAppServerEventProjector = class {
4774
4799
  recordToolTranscriptCall(params) {
4775
4800
  if (!params.id || !params.name || this.toolTranscriptCallIds.has(params.id)) return;
4776
4801
  this.toolTranscriptCallIds.add(params.id);
4802
+ this.toolTranscriptNamesById.set(params.id, params.name);
4777
4803
  this.toolTranscriptArgumentsById.set(params.id, params.arguments);
4778
4804
  if (!shouldEmitTranscriptToolProgress(params.name, params.arguments)) this.transcriptToolProgressSuppressedIds.add(params.id);
4779
4805
  else this.transcriptToolProgressSuppressedIds.delete(params.id);
@@ -4786,6 +4812,51 @@ var CodexAppServerEventProjector = class {
4786
4812
  this.emitTranscriptToolResultProgress(params);
4787
4813
  this.toolTranscriptMessages.push(attachCodexMirrorIdentity(this.createToolResultMessage(params), `${this.turnId}:tool:${params.id}:result`));
4788
4814
  }
4815
+ synthesizeMissingToolResults(params) {
4816
+ if (!params.failClosed) return;
4817
+ const missingTranscriptIds = [...this.toolTranscriptCallIds].filter((id) => !this.toolTranscriptResultIds.has(id));
4818
+ const missingTrajectoryIds = [...this.toolTrajectoryCallIds].filter((id) => !this.toolTrajectoryResultIds.has(id));
4819
+ if (missingTranscriptIds.length === 0 && missingTrajectoryIds.length === 0) return;
4820
+ for (const id of missingTranscriptIds) {
4821
+ const name = this.toolTranscriptNamesById.get(id) ?? this.toolTrajectoryNamesById.get(id);
4822
+ if (!name) continue;
4823
+ this.recordToolTranscriptResult({
4824
+ id,
4825
+ name,
4826
+ text: formatMissingToolResultError({
4827
+ id,
4828
+ name
4829
+ }),
4830
+ isError: true
4831
+ });
4832
+ }
4833
+ for (const id of missingTrajectoryIds) {
4834
+ const name = this.toolTrajectoryNamesById.get(id) ?? this.toolTranscriptNamesById.get(id);
4835
+ if (!name) continue;
4836
+ this.toolTrajectoryResultIds.add(id);
4837
+ const text = formatMissingToolResultError({
4838
+ id,
4839
+ name
4840
+ });
4841
+ this.options.trajectoryRecorder?.recordEvent("tool.result", {
4842
+ threadId: this.threadId,
4843
+ turnId: this.turnId,
4844
+ itemId: id,
4845
+ toolCallId: id,
4846
+ name,
4847
+ status: "failed",
4848
+ isError: true,
4849
+ result: {
4850
+ status: "failed",
4851
+ reason: "missing_tool_result"
4852
+ },
4853
+ output: text
4854
+ });
4855
+ }
4856
+ const missingCount = new Set([...missingTranscriptIds, ...missingTrajectoryIds]).size;
4857
+ this.synthesizedMissingToolResultError = missingCount === 1 ? MISSING_TOOL_RESULT_ERROR : `${MISSING_TOOL_RESULT_ERROR} missingToolResultCount=${missingCount}`;
4858
+ this.promptErrorSource = this.promptErrorSource ?? "prompt";
4859
+ }
4789
4860
  emitTranscriptToolCallProgress(params) {
4790
4861
  if (!shouldEmitTranscriptToolProgress(params.name, params.arguments)) return;
4791
4862
  this.transcriptToolProgressCallIds.add(params.id);
@@ -5152,6 +5223,9 @@ function itemStatus(item) {
5152
5223
  if (status === "inProgress" || status === "running") return "running";
5153
5224
  return "completed";
5154
5225
  }
5226
+ function formatMissingToolResultError(params) {
5227
+ return `${MISSING_TOOL_RESULT_ERROR} toolCallId=${params.id}; toolName=${params.name}`;
5228
+ }
5155
5229
  function isNonSuccessItemStatus(status) {
5156
5230
  return status === "failed" || status === "blocked";
5157
5231
  }
@@ -7457,7 +7531,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
7457
7531
  onCodexAppServerEvent: (event) => emitCodexAppServerEvent(params, event)
7458
7532
  }),
7459
7533
  signal: runAbortController.signal,
7460
- loading: resolveCodexDynamicToolsLoading(pluginConfig),
7534
+ loading: resolveCodexDynamicToolsLoadingForModel(pluginConfig, params.modelId),
7461
7535
  directToolNames: shouldForceMessageTool(params) ? ["message"] : [],
7462
7536
  hookContext: {
7463
7537
  agentId: sessionAgentId,
@@ -8414,6 +8488,14 @@ async function runCodexAppServerAttempt(params, options = {}) {
8414
8488
  }
8415
8489
  });
8416
8490
  let turn;
8491
+ const throwIfTurnStartAcceptedAfterAbort = () => {
8492
+ if (!runAbortController.signal.aborted) return;
8493
+ const reason = runAbortController.signal.reason;
8494
+ if (reason instanceof Error) throw reason;
8495
+ const error = new Error(typeof reason === "string" && reason.length > 0 ? reason : "codex app-server turn start aborted before acceptance");
8496
+ error.name = "AbortError";
8497
+ throw error;
8498
+ };
8417
8499
  const startCodexTurn = async () => {
8418
8500
  const turnStartParams = buildTurnStartParams(params, {
8419
8501
  threadId: thread.threadId,
@@ -8428,10 +8510,12 @@ async function runCodexAppServerAttempt(params, options = {}) {
8428
8510
  heartbeatCollaborationInstructions: workspaceBootstrapContext.heartbeatCollaborationInstructions
8429
8511
  });
8430
8512
  codexModelCallDiagnostics.setRequestPayloadBytes(utf8JsonByteLength(turnStartParams));
8431
- return assertCodexTurnStartResponse(await client.request("turn/start", turnStartParams, {
8513
+ const startedTurn = assertCodexTurnStartResponse(await client.request("turn/start", turnStartParams, {
8432
8514
  timeoutMs: params.timeoutMs,
8433
8515
  signal: runAbortController.signal
8434
8516
  }));
8517
+ throwIfTurnStartAcceptedAfterAbort();
8518
+ return startedTurn;
8435
8519
  };
8436
8520
  try {
8437
8521
  codexModelCallDiagnostics.emitStarted();
@@ -8469,6 +8553,23 @@ async function runCodexAppServerAttempt(params, options = {}) {
8469
8553
  });
8470
8554
  else {
8471
8555
  thread = await restartContextEngineCodexThread();
8556
+ {
8557
+ const retryBinding = await readCodexAppServerBinding(activeSessionFile);
8558
+ if (retryBinding && retryBinding.threadId === thread.threadId && retryBinding.contextEngine?.projection) {
8559
+ const { schemaVersion: _schemaVersion, sessionFile: _boundSessionFile, updatedAt: _updatedAt, ...bindingForWrite } = retryBinding;
8560
+ await writeCodexAppServerBinding(activeSessionFile, {
8561
+ ...bindingForWrite,
8562
+ contextEngine: bindingForWrite.contextEngine ? {
8563
+ ...bindingForWrite.contextEngine,
8564
+ projection: void 0
8565
+ } : void 0
8566
+ });
8567
+ embeddedAgentLog.info("codex app-server cleared stale context-engine projection after overflow retry", {
8568
+ threadId: thread.threadId,
8569
+ previousEpoch: retryBinding.contextEngine.projection.epoch
8570
+ });
8571
+ }
8572
+ }
8472
8573
  emitCodexAppServerEvent(params, {
8473
8574
  stream: "codex_app_server.lifecycle",
8474
8575
  data: {
@@ -8656,7 +8757,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8656
8757
  const handle = {
8657
8758
  kind: "embedded",
8658
8759
  queueMessage: async (text, optionsLocal) => activeSteeringQueue.queue(text, optionsLocal),
8659
- isStreaming: () => !completed,
8760
+ isStreaming: () => !completed && !runAbortController.signal.aborted,
8660
8761
  isCompacting: () => projectorRef.current?.isCompacting() ?? false,
8661
8762
  sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
8662
8763
  cancel: () => runAbortController.abort("cancelled"),
@@ -51,6 +51,7 @@ async function readCodexAppServerBinding(sessionFile, lookup = {}) {
51
51
  sandbox: readSandboxMode(parsed.sandbox),
52
52
  serviceTier: readServiceTier(parsed.serviceTier),
53
53
  dynamicToolsFingerprint: typeof parsed.dynamicToolsFingerprint === "string" ? parsed.dynamicToolsFingerprint : void 0,
54
+ dynamicToolsContainDeferred: typeof parsed.dynamicToolsContainDeferred === "boolean" ? parsed.dynamicToolsContainDeferred : void 0,
54
55
  userMcpServersFingerprint: typeof parsed.userMcpServersFingerprint === "string" ? parsed.userMcpServersFingerprint : void 0,
55
56
  mcpServersFingerprint: typeof parsed.mcpServersFingerprint === "string" ? parsed.mcpServersFingerprint : void 0,
56
57
  nativeHookRelayGeneration: typeof parsed.nativeHookRelayGeneration === "string" && parsed.nativeHookRelayGeneration.trim() ? parsed.nativeHookRelayGeneration : void 0,
@@ -88,6 +89,7 @@ async function writeCodexAppServerBinding(sessionFile, binding, lookup = {}) {
88
89
  sandbox: binding.sandbox,
89
90
  serviceTier: binding.serviceTier,
90
91
  dynamicToolsFingerprint: binding.dynamicToolsFingerprint,
92
+ dynamicToolsContainDeferred: binding.dynamicToolsContainDeferred,
91
93
  userMcpServersFingerprint: binding.userMcpServersFingerprint,
92
94
  mcpServersFingerprint: binding.mcpServersFingerprint,
93
95
  nativeHookRelayGeneration: binding.nativeHookRelayGeneration,
@@ -713,7 +713,11 @@ async function createIsolatedCodexAppServerClient(options) {
713
713
  }
714
714
  }
715
715
  function resetSharedCodexAppServerClientForTests() {
716
- getSharedCodexAppServerClientState().clients.clear();
716
+ const state = getSharedCodexAppServerClientState();
717
+ const clients = collectSharedClients(state);
718
+ state.clients.clear();
719
+ state.leasedReleases = /* @__PURE__ */ new WeakMap();
720
+ for (const client of clients) client.close();
717
721
  }
718
722
  function clearSharedCodexAppServerClient() {
719
723
  const state = getSharedCodexAppServerClientState();
@@ -1,12 +1,12 @@
1
1
  import { d as resolveCodexAppServerRuntimeOptions, h as shouldAutoApproveCodexAppServerApprovals, u as readCodexPluginConfig } from "./config-AlzuNKCY.js";
2
2
  import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-DIt7cXIp.js";
3
3
  import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./client-BnOmn0y-.js";
4
- import { d as resolveReasoningEffort, g as mergeCodexThreadConfigs, r as buildCodexRuntimeThreadConfig, t as CODEX_NATIVE_PERSONALITY_NONE, u as resolveCodexAppServerModelProvider } from "./thread-lifecycle-Bnlv_Q8u.js";
5
- import { a as readCodexAppServerBinding } from "./session-binding-BXJAV_xy.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-6nrEQZMV.js";
5
+ import { a as readCodexAppServerBinding } from "./session-binding-DWiEGATW.js";
6
6
  import { h as formatCodexUsageLimitErrorMessage, i as readCodexNotificationTurnId, r as readCodexNotificationThreadId } from "./notification-correlation-BykOI_jh.js";
7
- import { a as releaseLeasedSharedCodexAppServerClient, i as getLeasedSharedCodexAppServerClient, l as refreshCodexAppServerAuthTokens } from "./shared-client-ByKKWtYX.js";
7
+ import { a as releaseLeasedSharedCodexAppServerClient, i as getLeasedSharedCodexAppServerClient, l as refreshCodexAppServerAuthTokens } from "./shared-client-DUWLidr5.js";
8
8
  import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DMCJlzmz.js";
9
- import { d as emitDynamicToolErrorDiagnostic, f as emitDynamicToolStartedDiagnostic, h as filterCodexDynamicTools, 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, v as resolveCodexDynamicToolsLoading, y as handleCodexAppServerApprovalRequest } from "./native-hook-relay-D_LPgQFs.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-CIJt8cLN.js";
10
10
  import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-N66I-Rd7.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
@@ -3,7 +3,7 @@ import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartRespon
3
3
  import { a as isCodexAppServerConnectionClosedError, l as isJsonObject, n as CodexAppServerRpcError } from "./client-BnOmn0y-.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-BXJAV_xy.js";
6
+ import { a as readCodexAppServerBinding, r as isCodexAppServerNativeAuthProfile, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-DWiEGATW.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";
@@ -227,6 +227,59 @@ function truncateOlderContext(text, maxChars) {
227
227
  return `${marker}${text.slice(text.length - tailChars).trimStart()}`;
228
228
  }
229
229
  //#endregion
230
+ //#region extensions/codex/src/app-server/dynamic-tool-profile.ts
231
+ const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
232
+ "read",
233
+ "write",
234
+ "edit",
235
+ "apply_patch",
236
+ "exec",
237
+ "process",
238
+ "update_plan",
239
+ "tool_call",
240
+ "tool_describe",
241
+ "tool_search",
242
+ "tool_search_code"
243
+ ];
244
+ const DYNAMIC_TOOL_NAME_ALIASES = {
245
+ bash: "exec",
246
+ "apply-patch": "apply_patch"
247
+ };
248
+ function normalizeCodexDynamicToolName(name) {
249
+ const normalized = name.trim().toLowerCase();
250
+ return DYNAMIC_TOOL_NAME_ALIASES[normalized] ?? normalized;
251
+ }
252
+ function isForcedPrivateQaCodexRuntime(env = process.env) {
253
+ return env.OPENCLAW_BUILD_PRIVATE_QA === "1" && env.OPENCLAW_QA_FORCE_RUNTIME?.trim().toLowerCase() === "codex";
254
+ }
255
+ function resolveCodexDynamicToolsLoading(config, env = process.env) {
256
+ return isForcedPrivateQaCodexRuntime(env) ? "direct" : config.codexDynamicToolsLoading ?? "searchable";
257
+ }
258
+ function normalizeCodexModelId(modelId) {
259
+ const normalized = modelId?.trim().toLowerCase();
260
+ if (!normalized) return "";
261
+ return normalized.includes("/") ? normalized.split("/").at(-1) : normalized;
262
+ }
263
+ function shouldUseDirectCodexDynamicToolsForModel(modelId) {
264
+ return shouldDisableCodexToolSearchForModel(modelId);
265
+ }
266
+ function shouldDisableCodexToolSearchForModel(modelId) {
267
+ return normalizeCodexModelId(modelId) === "gpt-5.4-nano";
268
+ }
269
+ function resolveCodexDynamicToolsLoadingForModel(config, modelId, env = process.env) {
270
+ const loading = resolveCodexDynamicToolsLoading(config, env);
271
+ return loading === "searchable" && shouldUseDirectCodexDynamicToolsForModel(modelId) ? "direct" : loading;
272
+ }
273
+ function filterCodexDynamicTools(tools, config, env = process.env) {
274
+ const excludes = /* @__PURE__ */ new Set();
275
+ if (!isForcedPrivateQaCodexRuntime(env)) for (const name of CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES) excludes.add(name);
276
+ for (const name of config.codexDynamicToolsExclude ?? []) {
277
+ const trimmed = normalizeCodexDynamicToolName(name);
278
+ if (trimmed) excludes.add(trimmed);
279
+ }
280
+ return excludes.size === 0 ? tools : tools.filter((tool) => !excludes.has(normalizeCodexDynamicToolName(tool.name)));
281
+ }
282
+ //#endregion
230
283
  //#region extensions/codex/src/app-server/image-payload-sanitizer.ts
231
284
  const IMAGE_OMITTED_TEXT = "omitted image payload: invalid inline image data";
232
285
  function sanitizeInlineImageDataUrl$1(imageUrl) {
@@ -1037,38 +1090,50 @@ const CODEX_CODE_MODE_DISABLED_THREAD_CONFIG = {
1037
1090
  "features.code_mode_only": false
1038
1091
  };
1039
1092
  const CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG = { project_doc_max_bytes: 0 };
1093
+ const CODEX_TOOL_SEARCH_UNSUPPORTED_THREAD_CONFIG = { "features.multi_agent": false };
1040
1094
  const CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS = 1e3;
1041
1095
  const CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS = 500;
1096
+ function shouldWarnCodexThreadLifecycleTimingSummary(summary, options = {}) {
1097
+ const totalThresholdMs = options.totalThresholdMs ?? CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS;
1098
+ const stageThresholdMs = options.stageThresholdMs ?? CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS;
1099
+ return summary.totalMs >= totalThresholdMs || summary.spans.some((span) => span.durationMs >= stageThresholdMs);
1100
+ }
1101
+ function formatCodexThreadLifecycleTimingSummary(params) {
1102
+ const spans = params.summary.spans.length > 0 ? params.summary.spans.map((span) => `${span.name}:${span.durationMs}ms@${span.elapsedMs}ms`).join(",") : "none";
1103
+ return `[trace:codex-app-server] thread lifecycle: runId=${params.runId} sessionId=${params.sessionId} sessionKey=${params.sessionKey ?? "unknown"} action=${params.action} totalMs=${params.summary.totalMs} stages=${spans}`;
1104
+ }
1042
1105
  function createCodexThreadLifecycleTimingTracker(options = {}) {
1043
- if (!options.enabled) return {
1106
+ const log = options.log ?? embeddedAgentLog;
1107
+ if (!options.enabled && log.isEnabled?.("trace") !== true) return {
1044
1108
  async measure(_name, run) {
1045
1109
  return await run();
1046
1110
  },
1047
1111
  measureSync(_name, run) {
1048
1112
  return run();
1049
1113
  },
1050
- logIfSlow() {}
1114
+ mark() {},
1115
+ logSummary() {}
1051
1116
  };
1052
- const startedAt = Date.now();
1117
+ const now = options.now ?? Date.now;
1118
+ const startedAt = now();
1053
1119
  let didLog = false;
1054
1120
  const spans = [];
1055
1121
  const toMs = (value) => Math.max(0, Math.round(value));
1056
1122
  const record = (name, spanStartedAt) => {
1123
+ const currentAt = now();
1057
1124
  spans.push({
1058
1125
  name,
1059
- durationMs: toMs(Date.now() - spanStartedAt),
1060
- elapsedMs: toMs(Date.now() - startedAt)
1126
+ durationMs: toMs(currentAt - spanStartedAt),
1127
+ elapsedMs: toMs(currentAt - startedAt)
1061
1128
  });
1062
1129
  };
1063
1130
  const snapshot = () => ({
1064
- totalMs: toMs(Date.now() - startedAt),
1131
+ totalMs: toMs(now() - startedAt),
1065
1132
  spans: spans.slice()
1066
1133
  });
1067
- const shouldLog = (summary) => summary.totalMs >= CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS || summary.spans.some((span) => span.durationMs >= CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS);
1068
- const formatSpans = (summary) => summary.spans.length > 0 ? summary.spans.map((span) => `${span.name}:${span.durationMs}ms@${span.elapsedMs}ms`).join(",") : "none";
1069
1134
  return {
1070
1135
  async measure(name, run) {
1071
- const spanStartedAt = Date.now();
1136
+ const spanStartedAt = now();
1072
1137
  try {
1073
1138
  return await run();
1074
1139
  } finally {
@@ -1076,19 +1141,30 @@ function createCodexThreadLifecycleTimingTracker(options = {}) {
1076
1141
  }
1077
1142
  },
1078
1143
  measureSync(name, run) {
1079
- const spanStartedAt = Date.now();
1144
+ const spanStartedAt = now();
1080
1145
  try {
1081
1146
  return run();
1082
1147
  } finally {
1083
1148
  record(name, spanStartedAt);
1084
1149
  }
1085
1150
  },
1086
- logIfSlow(params) {
1151
+ mark(name) {
1152
+ record(name, now());
1153
+ },
1154
+ logSummary(params) {
1087
1155
  if (didLog) return;
1088
1156
  const summary = snapshot();
1089
- if (!shouldLog(summary)) return;
1157
+ const shouldWarn = shouldWarnCodexThreadLifecycleTimingSummary(summary, options);
1158
+ if (!shouldWarn && !log.isEnabled?.("trace")) return;
1090
1159
  didLog = true;
1091
- embeddedAgentLog.warn(`codex app-server thread lifecycle timings runId=${params.runId} sessionId=${params.sessionId} sessionKey=${params.sessionKey ?? "unknown"} action=${params.action} totalMs=${summary.totalMs} stages=${formatSpans(summary)}`, {
1160
+ const message = formatCodexThreadLifecycleTimingSummary({
1161
+ runId: params.runId,
1162
+ sessionId: params.sessionId,
1163
+ sessionKey: params.sessionKey,
1164
+ action: params.action,
1165
+ summary
1166
+ });
1167
+ const meta = {
1092
1168
  runId: params.runId,
1093
1169
  sessionId: params.sessionId,
1094
1170
  sessionKey: params.sessionKey,
@@ -1096,18 +1172,24 @@ function createCodexThreadLifecycleTimingTracker(options = {}) {
1096
1172
  threadId: params.threadId,
1097
1173
  totalMs: summary.totalMs,
1098
1174
  spans: summary.spans
1099
- });
1175
+ };
1176
+ if (shouldWarn) log.warn(message, meta);
1177
+ else log.trace(message, meta);
1100
1178
  }
1101
1179
  };
1102
1180
  }
1103
1181
  async function startOrResumeThread(params) {
1104
- const lifecycleTiming = createCodexThreadLifecycleTimingTracker({ enabled: isCodexAppServerProfilerEnabled(params.params.config) });
1105
- const dynamicToolsFingerprint = lifecycleTiming.measureSync("fingerprint_dynamic_tools", () => fingerprintDynamicTools(params.dynamicTools));
1106
- const contextEngineBinding = lifecycleTiming.measureSync("context_engine_binding", () => buildContextEngineBinding(params.params, params.contextEngineProjection));
1182
+ const lifecycleTiming = createCodexThreadLifecycleTimingTracker({
1183
+ ...params.timing,
1184
+ enabled: params.timing?.enabled ?? isCodexAppServerProfilerEnabled(params.params.config)
1185
+ });
1186
+ const dynamicToolsFingerprint = lifecycleTiming.measureSync("dynamic-tools-fingerprint", () => fingerprintDynamicTools(params.dynamicTools));
1187
+ const dynamicToolsContainDeferred = params.dynamicTools.some((tool) => tool.deferLoading === true);
1188
+ const contextEngineBinding = lifecycleTiming.measureSync("context-engine-binding", () => buildContextEngineBinding(params.params, params.contextEngineProjection));
1107
1189
  const userMcpServersConfigPatch = params.userMcpServersEnabled === false ? void 0 : buildCodexUserMcpServersThreadConfigPatch(params.params.config, { agentId: params.agentId ?? params.params.agentId });
1108
1190
  const userMcpServersFingerprint = fingerprintUserMcpServersConfigPatch(userMcpServersConfigPatch);
1109
1191
  const environmentSelectionFingerprint = fingerprintEnvironmentSelection(params.environmentSelection);
1110
- let binding = await lifecycleTiming.measure("read_binding", () => readCodexAppServerBinding(params.params.sessionFile, {
1192
+ let binding = await lifecycleTiming.measure("read-binding", () => readCodexAppServerBinding(params.params.sessionFile, {
1111
1193
  authProfileStore: params.params.authProfileStore,
1112
1194
  agentDir: params.params.agentDir,
1113
1195
  config: params.params.config
@@ -1115,6 +1197,14 @@ async function startOrResumeThread(params) {
1115
1197
  let preserveExistingBinding = false;
1116
1198
  let rotatedContextEngineBinding = false;
1117
1199
  let prebuiltPluginThreadConfig;
1200
+ const throwIfAborted = () => {
1201
+ if (!params.signal?.aborted) return;
1202
+ const reason = params.signal.reason;
1203
+ if (reason instanceof Error) throw reason;
1204
+ const error = new Error(typeof reason === "string" && reason.length > 0 ? reason : "codex app-server thread lifecycle aborted");
1205
+ error.name = "AbortError";
1206
+ throw error;
1207
+ };
1118
1208
  if (binding?.threadId && params.nativeCodeModeEnabled === false) {
1119
1209
  embeddedAgentLog.debug("codex app-server native tool surface disabled for turn; starting transient thread", { threadId: binding.threadId });
1120
1210
  preserveExistingBinding = true;
@@ -1165,7 +1255,7 @@ async function startOrResumeThread(params) {
1165
1255
  binding,
1166
1256
  pluginThreadConfig: params.pluginThreadConfig
1167
1257
  })) try {
1168
- prebuiltPluginThreadConfig = await lifecycleTiming.measure("plugin_config_recovery", () => params.pluginThreadConfig?.build());
1258
+ prebuiltPluginThreadConfig = await lifecycleTiming.measure("plugin-config-recovery", () => params.pluginThreadConfig?.build());
1169
1259
  pluginBindingStale = prebuiltPluginThreadConfig?.fingerprint !== binding.pluginAppsFingerprint;
1170
1260
  } catch (error) {
1171
1261
  embeddedAgentLog.warn("codex app-server plugin app config recovery check failed", {
@@ -1184,6 +1274,13 @@ async function startOrResumeThread(params) {
1184
1274
  await clearCodexAppServerBinding(params.params.sessionFile);
1185
1275
  binding = void 0;
1186
1276
  }
1277
+ if (binding?.threadId) {
1278
+ if (binding.dynamicToolsFingerprint && params.dynamicTools.length > 0 && binding.dynamicToolsContainDeferred !== dynamicToolsContainDeferred && (binding.dynamicToolsContainDeferred !== void 0 || !dynamicToolsContainDeferred)) {
1279
+ embeddedAgentLog.debug("codex app-server dynamic tool loading changed; starting a new thread", { threadId: binding.threadId });
1280
+ await clearCodexAppServerBinding(params.params.sessionFile);
1281
+ binding = void 0;
1282
+ }
1283
+ }
1187
1284
  if (binding?.threadId) if (binding.dynamicToolsFingerprint && !areDynamicToolFingerprintsCompatible(binding.dynamicToolsFingerprint, dynamicToolsFingerprint)) {
1188
1285
  preserveExistingBinding = shouldStartTransientNoToolThread({
1189
1286
  previous: binding.dynamicToolsFingerprint,
@@ -1204,7 +1301,7 @@ async function startOrResumeThread(params) {
1204
1301
  nativeHookRelayGeneration: params.nativeHookRelayGeneration
1205
1302
  };
1206
1303
  const resumeConfig = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, finalConfigPatch.configPatch);
1207
- const resumeParams = lifecycleTiming.measureSync("thread_resume_params", () => buildThreadResumeParams(params.params, {
1304
+ const resumeParams = lifecycleTiming.measureSync("thread-resume-params", () => buildThreadResumeParams(params.params, {
1208
1305
  threadId: binding.threadId,
1209
1306
  authProfileId,
1210
1307
  appServer: params.appServer,
@@ -1214,7 +1311,8 @@ async function startOrResumeThread(params) {
1214
1311
  nativeCodeModeEnabled: params.nativeCodeModeEnabled,
1215
1312
  nativeCodeModeOnlyEnabled: params.nativeCodeModeOnlyEnabled
1216
1313
  }));
1217
- const response = assertCodexThreadResumeResponse(await lifecycleTiming.measure("thread_resume_request", () => params.client.request("thread/resume", resumeParams)));
1314
+ const response = assertCodexThreadResumeResponse(await lifecycleTiming.measure("thread-resume-request", () => params.client.request("thread/resume", resumeParams, { signal: params.signal })));
1315
+ throwIfAborted();
1218
1316
  const boundAuthProfileId = authProfileId;
1219
1317
  const fallbackModelProvider = resolveCodexAppServerModelProvider({
1220
1318
  provider: params.params.provider,
@@ -1224,13 +1322,14 @@ async function startOrResumeThread(params) {
1224
1322
  config: params.params.config
1225
1323
  });
1226
1324
  const nextMcpServersFingerprint = params.mcpServersFingerprintEvaluated === true ? params.mcpServersFingerprint : binding.mcpServersFingerprint;
1227
- await lifecycleTiming.measure("thread_resume_write_binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
1325
+ await lifecycleTiming.measure("thread-resume-write-binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
1228
1326
  threadId: response.thread.id,
1229
1327
  cwd: params.cwd,
1230
1328
  authProfileId: boundAuthProfileId,
1231
1329
  model: params.params.modelId,
1232
1330
  modelProvider: response.modelProvider ?? fallbackModelProvider,
1233
1331
  dynamicToolsFingerprint,
1332
+ dynamicToolsContainDeferred,
1234
1333
  userMcpServersFingerprint,
1235
1334
  mcpServersFingerprint: nextMcpServersFingerprint,
1236
1335
  nativeHookRelayGeneration: finalConfigPatch.nativeHookRelayGeneration ?? binding.nativeHookRelayGeneration,
@@ -1254,7 +1353,8 @@ async function startOrResumeThread(params) {
1254
1353
  fingerprint: contextEngineBinding.projection?.fingerprint,
1255
1354
  action: "resumed"
1256
1355
  });
1257
- lifecycleTiming.logIfSlow({
1356
+ lifecycleTiming.mark("thread-ready");
1357
+ lifecycleTiming.logSummary({
1258
1358
  runId: params.params.runId,
1259
1359
  sessionId: params.params.sessionId,
1260
1360
  sessionKey: params.params.sessionKey,
@@ -1269,6 +1369,7 @@ async function startOrResumeThread(params) {
1269
1369
  model: params.params.modelId,
1270
1370
  modelProvider: response.modelProvider ?? fallbackModelProvider,
1271
1371
  dynamicToolsFingerprint,
1372
+ dynamicToolsContainDeferred,
1272
1373
  userMcpServersFingerprint,
1273
1374
  mcpServersFingerprint: nextMcpServersFingerprint,
1274
1375
  nativeHookRelayGeneration: finalConfigPatch.nativeHookRelayGeneration ?? binding.nativeHookRelayGeneration,
@@ -1284,13 +1385,13 @@ async function startOrResumeThread(params) {
1284
1385
  embeddedAgentLog.warn("codex app-server thread resume failed; starting a new thread", { error });
1285
1386
  await clearCodexAppServerBinding(params.params.sessionFile);
1286
1387
  }
1287
- const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await lifecycleTiming.measure("plugin_config_build", () => params.pluginThreadConfig?.build()) : void 0;
1388
+ const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await lifecycleTiming.measure("plugin-config-build", () => params.pluginThreadConfig?.build()) : void 0;
1288
1389
  const finalConfigPatch = params.buildFinalConfigPatch?.({ action: "start" }) ?? {
1289
1390
  configPatch: params.finalConfigPatch,
1290
1391
  nativeHookRelayGeneration: params.nativeHookRelayGeneration
1291
1392
  };
1292
- const config = lifecycleTiming.measureSync("merge_thread_config", () => mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch));
1293
- const startParams = lifecycleTiming.measureSync("thread_start_params", () => buildThreadStartParams(params.params, {
1393
+ const config = lifecycleTiming.measureSync("merge-thread-config", () => mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch));
1394
+ const startParams = lifecycleTiming.measureSync("thread-start-params", () => buildThreadStartParams(params.params, {
1294
1395
  cwd: params.cwd,
1295
1396
  dynamicTools: params.dynamicTools,
1296
1397
  appServer: params.appServer,
@@ -1300,14 +1401,15 @@ async function startOrResumeThread(params) {
1300
1401
  nativeCodeModeOnlyEnabled: params.nativeCodeModeOnlyEnabled,
1301
1402
  environmentSelection: params.environmentSelection
1302
1403
  }));
1303
- const response = assertCodexThreadStartResponse(await lifecycleTiming.measure("thread_start_request", async () => {
1404
+ const response = assertCodexThreadStartResponse(await lifecycleTiming.measure("thread-start-request", async () => {
1304
1405
  try {
1305
- return await params.client.request("thread/start", startParams);
1406
+ return await params.client.request("thread/start", startParams, { signal: params.signal });
1306
1407
  } catch (error) {
1307
1408
  if (error instanceof CodexAppServerRpcError) throw new CodexThreadStartRequestError(error);
1308
1409
  throw error;
1309
1410
  }
1310
1411
  }));
1412
+ throwIfAborted();
1311
1413
  const modelProvider = resolveCodexAppServerModelProvider({
1312
1414
  provider: params.params.provider,
1313
1415
  authProfileId: params.params.authProfileId,
@@ -1318,13 +1420,14 @@ async function startOrResumeThread(params) {
1318
1420
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
1319
1421
  const nextMcpServersFingerprint = params.mcpServersFingerprintEvaluated === true ? params.mcpServersFingerprint : void 0;
1320
1422
  if (!preserveExistingBinding) {
1321
- await lifecycleTiming.measure("thread_start_write_binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
1423
+ await lifecycleTiming.measure("thread-start-write-binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
1322
1424
  threadId: response.thread.id,
1323
1425
  cwd: params.cwd,
1324
1426
  authProfileId: params.params.authProfileId,
1325
1427
  model: response.model ?? params.params.modelId,
1326
1428
  modelProvider: response.modelProvider ?? modelProvider,
1327
1429
  dynamicToolsFingerprint,
1430
+ dynamicToolsContainDeferred,
1328
1431
  userMcpServersFingerprint,
1329
1432
  mcpServersFingerprint: nextMcpServersFingerprint,
1330
1433
  nativeHookRelayGeneration: finalConfigPatch.nativeHookRelayGeneration,
@@ -1349,7 +1452,8 @@ async function startOrResumeThread(params) {
1349
1452
  action: rotatedContextEngineBinding ? "rotated" : "started"
1350
1453
  });
1351
1454
  }
1352
- lifecycleTiming.logIfSlow({
1455
+ lifecycleTiming.mark("thread-ready");
1456
+ lifecycleTiming.logSummary({
1353
1457
  runId: params.params.runId,
1354
1458
  sessionId: params.params.sessionId,
1355
1459
  sessionKey: params.params.sessionKey,
@@ -1365,6 +1469,7 @@ async function startOrResumeThread(params) {
1365
1469
  model: response.model ?? params.params.modelId,
1366
1470
  modelProvider: response.modelProvider ?? modelProvider,
1367
1471
  dynamicToolsFingerprint,
1472
+ dynamicToolsContainDeferred,
1368
1473
  userMcpServersFingerprint,
1369
1474
  mcpServersFingerprint: nextMcpServersFingerprint,
1370
1475
  nativeHookRelayGeneration: finalConfigPatch.nativeHookRelayGeneration,
@@ -1512,7 +1617,8 @@ function buildCodexRuntimeThreadConfig(config, options = {}) {
1512
1617
  return mergeCodexThreadConfigs(codeModeConfig, config) ?? { ...codeModeConfig };
1513
1618
  }
1514
1619
  function buildCodexRuntimeThreadConfigForRun(params, config, options = {}) {
1515
- const runtimeConfig = buildCodexRuntimeThreadConfig(config, options);
1620
+ const baseConfig = buildCodexRuntimeThreadConfig(config, options);
1621
+ const runtimeConfig = mergeCodexThreadConfigs(baseConfig, shouldDisableCodexToolSearchForModel(params.modelId) ? CODEX_TOOL_SEARCH_UNSUPPORTED_THREAD_CONFIG : void 0) ?? baseConfig;
1516
1622
  if (params.bootstrapContextMode !== "lightweight") return runtimeConfig;
1517
1623
  return mergeCodexThreadConfigs(runtimeConfig, CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG) ?? {
1518
1624
  ...runtimeConfig,
@@ -1614,7 +1720,7 @@ function fingerprintDynamicToolSpec(tool) {
1614
1720
  if (!isJsonObject(tool)) return stabilizeJsonValue(tool);
1615
1721
  const stable = {};
1616
1722
  for (const [key, child] of Object.entries(tool).toSorted(([left], [right]) => left.localeCompare(right))) {
1617
- if (key === "description" || key === "deferLoading" || key === "namespace") continue;
1723
+ if (key === "description") continue;
1618
1724
  stable[key] = stabilizeJsonValue(child);
1619
1725
  }
1620
1726
  return stable;
@@ -1697,4 +1803,4 @@ function resolveReasoningEffort(thinkLevel, modelId) {
1697
1803
  return null;
1698
1804
  }
1699
1805
  //#endregion
1700
- export { sanitizeCodexHistoryImagePayloads as C, resolveCodexContextEngineProjectionReserveTokens as D, resolveCodexContextEngineProjectionMaxChars as E, invalidInlineImageText as S, projectContextEngineAssemblyForCodex as T, shouldBuildCodexPluginThreadConfig as _, buildDeveloperInstructions as a, buildCodexAppInventoryCacheKey as b, codexDynamicToolsFingerprint as c, resolveReasoningEffort as d, startOrResumeThread as f, mergeCodexThreadConfigs as g, buildCodexPluginThreadConfigInputFingerprint as h, buildContextEngineBinding as i, isContextEngineBindingCompatible as l, buildCodexPluginThreadConfig as m, areCodexDynamicToolFingerprintsCompatible as n, buildTurnCollaborationMode as o, isCodexAppServerProfilerEnabled as p, buildCodexRuntimeThreadConfig as r, buildTurnStartParams as s, CODEX_NATIVE_PERSONALITY_NONE as t, resolveCodexAppServerModelProvider as u, ensureCodexPluginActivation as v, sanitizeInlineImageDataUrl$1 as w, defaultCodexAppInventoryCache as x, pluginReadParams as y };
1806
+ export { projectContextEngineAssemblyForCodex as A, sanitizeCodexHistoryImagePayloads as C, normalizeCodexDynamicToolName as D, isForcedPrivateQaCodexRuntime as E, resolveCodexContextEngineProjectionReserveTokens as M, resolveCodexDynamicToolsLoading as O, invalidInlineImageText as S, filterCodexDynamicTools as T, shouldBuildCodexPluginThreadConfig as _, buildDeveloperInstructions as a, buildCodexAppInventoryCacheKey as b, codexDynamicToolsFingerprint as c, resolveReasoningEffort as d, startOrResumeThread as f, mergeCodexThreadConfigs as g, buildCodexPluginThreadConfigInputFingerprint as h, buildContextEngineBinding as i, resolveCodexContextEngineProjectionMaxChars as j, resolveCodexDynamicToolsLoadingForModel as k, isContextEngineBindingCompatible as l, buildCodexPluginThreadConfig as m, areCodexDynamicToolFingerprintsCompatible as n, buildTurnCollaborationMode as o, isCodexAppServerProfilerEnabled as p, buildCodexRuntimeThreadConfig as r, buildTurnStartParams as s, CODEX_NATIVE_PERSONALITY_NONE as t, resolveCodexAppServerModelProvider as u, ensureCodexPluginActivation as v, sanitizeInlineImageDataUrl$1 as w, defaultCodexAppInventoryCache as x, pluginReadParams as y };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.5.31-beta.4",
3
+ "version": "2026.6.1-beta.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/codex",
9
- "version": "2026.5.31-beta.4",
9
+ "version": "2026.6.1-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.5.31-beta.4",
3
+ "version": "2026.6.1-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.5.31-beta.4"
29
+ "pluginApi": ">=2026.6.1-beta.2"
30
30
  },
31
31
  "build": {
32
- "openclawVersion": "2026.5.31-beta.4"
32
+ "openclawVersion": "2026.6.1-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.5.31-beta.4"
50
+ "openclaw": ">=2026.6.1-beta.2"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "openclaw": {