@openclaw/codex 2026.5.31-beta.2 → 2026.5.31-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,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-DBlR-rV2.js").then((n) => n.s);
4
+ sharedClientModulePromise ??= import("./shared-client-ByKKWtYX.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-mbjSisZL.js";
2
+ import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-DEgJXKQy.js";
3
3
  import { l as isJsonObject } from "./client-BnOmn0y-.js";
4
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-DuFgTwRU.js";
5
+ import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-DYdA1i4c.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-KUDxop-C.js";
9
- import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-D-0EFJBJ.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";
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";
@@ -305,9 +305,8 @@ function formatRelativeReset(untilMs, nowMs) {
305
305
  return `in ${days} ${days === 1 ? "day" : "days"}`;
306
306
  }
307
307
  //#endregion
308
- //#region extensions/codex/src/command-plugins-management.ts
309
- const POLICY_REFRESH_HINT = "New Codex conversations pick this up automatically. Use /new or /reset to refresh the current one.";
310
- function buildPickerPresentation$1(title, prompt, buttons) {
308
+ //#region extensions/codex/src/command-presentation.ts
309
+ function buildCodexCommandPickerPresentation(title, prompt, buttons) {
311
310
  return {
312
311
  title,
313
312
  blocks: [{
@@ -317,11 +316,17 @@ function buildPickerPresentation$1(title, prompt, buttons) {
317
316
  type: "buttons",
318
317
  buttons: buttons.map((button) => ({
319
318
  label: button.label,
320
- value: button.command
319
+ action: {
320
+ type: "command",
321
+ command: button.command
322
+ }
321
323
  }))
322
324
  }]
323
325
  };
324
326
  }
327
+ //#endregion
328
+ //#region extensions/codex/src/command-plugins-management.ts
329
+ const POLICY_REFRESH_HINT = "New Codex conversations pick this up automatically. Use /new or /reset to refresh the current one.";
325
330
  async function handleCodexPluginsSubcommand(ctx, rest, io) {
326
331
  const [verb = "list", ...args] = rest;
327
332
  const normalized = verb.toLowerCase();
@@ -369,7 +374,7 @@ function buildPluginsMenuReply() {
369
374
  "",
370
375
  "Type '/codex' to go back to the main menu."
371
376
  ].join("\n"),
372
- presentation: buildPickerPresentation$1("Codex sub-plugins", "Pick a Codex sub-plugin action:", [
377
+ presentation: buildCodexCommandPickerPresentation("Codex sub-plugins", "Pick a Codex sub-plugin action:", [
373
378
  {
374
379
  label: "list",
375
380
  command: "/codex plugins list"
@@ -406,7 +411,7 @@ function buildPluginNamePickerReply(verb, current) {
406
411
  "Type '/codex plugins list' to inspect configured sub-plugins.",
407
412
  "Type '/codex plugins menu' to go back to the plugins menu."
408
413
  ].join("\n"),
409
- presentation: buildPickerPresentation$1("Codex sub-plugins", "Pick another Codex sub-plugin action:", [{
414
+ presentation: buildCodexCommandPickerPresentation("Codex sub-plugins", "Pick another Codex sub-plugin action:", [{
410
415
  label: "list",
411
416
  command: "/codex plugins list"
412
417
  }, {
@@ -430,7 +435,7 @@ function buildPluginNamePickerReply(verb, current) {
430
435
  ...verb === "enable" && !globalEnabled ? ["Global codexPlugins.enabled is off; enabling one configured sub-plugin turns it on.", ""] : [],
431
436
  "Type '/codex plugins menu' to go back to the plugins menu."
432
437
  ].join("\n"),
433
- presentation: buildPickerPresentation$1("Codex sub-plugins", `Pick a Codex sub-plugin to ${verb}:`, buttons)
438
+ presentation: buildCodexCommandPickerPresentation("Codex sub-plugins", `Pick a Codex sub-plugin to ${verb}:`, buttons)
434
439
  };
435
440
  }
436
441
  function canMutateCodexPlugins(ctx) {
@@ -585,24 +590,9 @@ const lastCodexDiagnosticsUploadByThread = /* @__PURE__ */ new Map();
585
590
  const lastCodexDiagnosticsUploadByScope = /* @__PURE__ */ new Map();
586
591
  const pendingCodexDiagnosticsConfirmations = /* @__PURE__ */ new Map();
587
592
  const pendingCodexDiagnosticsConfirmationTokensByScope = /* @__PURE__ */ new Map();
588
- function buildPickerPresentation(title, prompt, buttons) {
589
- return {
590
- title,
591
- blocks: [{
592
- type: "text",
593
- text: prompt
594
- }, {
595
- type: "buttons",
596
- buttons: buttons.map((button) => ({
597
- label: button.label,
598
- value: button.command
599
- }))
600
- }]
601
- };
602
- }
603
593
  /**
604
- * No-arg `/codex` picker. Core owns the native command tree; channels render
605
- * the portable buttons as inline controls when their transport can.
594
+ * No-arg `/codex` picker. Codex owns the command tree; channels render the
595
+ * portable command actions as inline controls when their transport can.
606
596
  */
607
597
  function buildCodexSubcommandPickerReply() {
608
598
  const verbs = [
@@ -643,7 +633,7 @@ function buildCodexSubcommandPickerReply() {
643
633
  "",
644
634
  "Top-level shortcuts cover everyday operations: /status, /fast, /help, /stop, /models."
645
635
  ].join("\n"),
646
- presentation: buildPickerPresentation("Codex commands", "Pick a Codex subcommand:", verbs)
636
+ presentation: buildCodexCommandPickerPresentation("Codex commands", "Pick a Codex subcommand:", verbs)
647
637
  };
648
638
  }
649
639
  /** Sub-picker for `/codex fast menu` (on / off / status). */
@@ -668,7 +658,7 @@ function buildCodexFastMenuReply() {
668
658
  "",
669
659
  "Type '/codex' to go back to the main menu."
670
660
  ].join("\n"),
671
- presentation: buildPickerPresentation("Codex fast mode", "Pick a Codex fast mode:", buttons)
661
+ presentation: buildCodexCommandPickerPresentation("Codex fast mode", "Pick a Codex fast mode:", buttons)
672
662
  };
673
663
  }
674
664
  /** Sub-picker for `/codex permissions menu` (default / yolo / status). */
@@ -693,7 +683,7 @@ function buildCodexPermissionsMenuReply() {
693
683
  "",
694
684
  "Type '/codex' to go back to the main menu."
695
685
  ].join("\n"),
696
- presentation: buildPickerPresentation("Codex permissions", "Pick a Codex permissions mode:", buttons)
686
+ presentation: buildCodexCommandPickerPresentation("Codex permissions", "Pick a Codex permissions mode:", buttons)
697
687
  };
698
688
  }
699
689
  /** Sub-picker for `/codex computer-use menu` (status / install). */
@@ -716,7 +706,7 @@ function buildCodexComputerUseMenuReply() {
716
706
  "",
717
707
  "Type '/codex' to go back to the main menu."
718
708
  ].join("\n"),
719
- presentation: buildPickerPresentation("Codex computer-use", "Pick a Codex computer-use action:", buttons)
709
+ presentation: buildCodexCommandPickerPresentation("Codex computer-use", "Pick a Codex computer-use action:", buttons)
720
710
  };
721
711
  }
722
712
  /** Returns true when the rest-args are exactly `["menu"]` (case-insensitive). */
@@ -1136,10 +1126,18 @@ async function requestCodexDiagnosticsFeedbackApproval(deps, ctx, note, commandP
1136
1126
  type: "buttons",
1137
1127
  buttons: [{
1138
1128
  label: "Send diagnostics",
1129
+ action: {
1130
+ type: "command",
1131
+ command: confirmCommand
1132
+ },
1139
1133
  value: confirmCommand,
1140
1134
  style: "danger"
1141
1135
  }, {
1142
1136
  label: "Cancel",
1137
+ action: {
1138
+ type: "command",
1139
+ command: cancelCommand
1140
+ },
1143
1141
  value: cancelCommand,
1144
1142
  style: "secondary"
1145
1143
  }]
@@ -1,7 +1,7 @@
1
1
  import { d as resolveCodexAppServerRuntimeOptions } from "./config-AlzuNKCY.js";
2
2
  import { a as readCodexAppServerBinding } from "./session-binding-BXJAV_xy.js";
3
3
  import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DMCJlzmz.js";
4
- import { t as defaultCodexAppServerClientFactory } from "./client-factory-B8dh39UW.js";
4
+ import { t as defaultCodexAppServerClientFactory } from "./client-factory-DBgo1xC5.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-DuFgTwRU.js";
2
+ import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-DYdA1i4c.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 {
@@ -2,9 +2,9 @@ import { d as resolveCodexAppServerRuntimeOptions, i as codexSandboxPolicyForTur
2
2
  import { l as isJsonObject } from "./client-BnOmn0y-.js";
3
3
  import { t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-Bnlv_Q8u.js";
4
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-DuFgTwRU.js";
5
+ import { r as CODEX_CONTROL_METHODS } from "./request-DYdA1i4c.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-DBlR-rV2.js";
7
+ import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient } from "./shared-client-ByKKWtYX.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,21 +28,21 @@ function createCodexAppServerAgentHarness(options) {
28
28
  };
29
29
  },
30
30
  runAttempt: async (params) => {
31
- const { runCodexAppServerAttempt } = await import("./run-attempt-CgaY9r5u.js");
31
+ const { runCodexAppServerAttempt } = await import("./run-attempt-BHkuGybn.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-SjBLGANT.js");
38
+ const { runCodexAppServerSideQuestion } = await import("./side-question-6HqYQ06R.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-BXLjhUHX.js");
45
+ const { maybeCompactCodexAppServerSession } = await import("./compact-Dgz_jIBU.js");
46
46
  return maybeCompactCodexAppServerSession(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
47
47
  },
48
48
  reset: async (params) => {
@@ -52,7 +52,7 @@ function createCodexAppServerAgentHarness(options) {
52
52
  }
53
53
  },
54
54
  dispose: async () => {
55
- const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-DBlR-rV2.js").then((n) => n.s);
55
+ const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-ByKKWtYX.js").then((n) => n.s);
56
56
  await clearSharedCodexAppServerClientAndWait();
57
57
  }
58
58
  };
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ import { d as resolveCodexAppServerRuntimeOptions, s as isCodexPluginsMarketplac
3
3
  import { buildCodexProvider } from "./provider.js";
4
4
  import { v as ensureCodexPluginActivation, x as defaultCodexAppInventoryCache, y as pluginReadParams } from "./thread-lifecycle-Bnlv_Q8u.js";
5
5
  import { buildCodexMediaUnderstandingProvider } from "./media-understanding-provider.js";
6
- import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-DuFgTwRU.js";
6
+ import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-DYdA1i4c.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-DBlR-rV2.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-KUDxop-C.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";
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-BsK6kZJi.js");
51
+ const { handleCodexSubcommand } = await import("./command-handlers-82GqsKYq.js");
52
52
  return handleCodexSubcommand;
53
53
  }
54
54
  //#endregion
@@ -1355,7 +1355,9 @@ function isCodexPluginLoadWarningItem(item) {
1355
1355
  return item.kind === "plugin" && item.action === "install" && item.status === "warning" && item.details?.warningReason === CODEX_PLUGIN_LOAD_WARNING;
1356
1356
  }
1357
1357
  async function sleep(ms) {
1358
- await new Promise((resolve) => setTimeout(resolve, ms));
1358
+ await new Promise((resolve) => {
1359
+ setTimeout(resolve, ms);
1360
+ });
1359
1361
  }
1360
1362
  async function buildTargetCodexPluginAppCacheKey(ctx) {
1361
1363
  const targets = resolveCodexMigrationTargets(ctx);
@@ -1,7 +1,7 @@
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-mbjSisZL.js";
4
+ import { i as readModelListResult } from "./models-DEgJXKQy.js";
5
5
  import { l as isJsonObject } from "./client-BnOmn0y-.js";
6
6
  import { r as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-Bnlv_Q8u.js";
7
7
  import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
@@ -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-DBlR-rV2.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-ByKKWtYX.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-DBlR-rV2.js").then((n) => n.s);
43
+ const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-ByKKWtYX.js").then((n) => n.s);
44
44
  const client = useSharedClient ? await getLeasedSharedCodexAppServerClient({
45
45
  startOptions: options.startOptions,
46
46
  timeoutMs,
@@ -113,10 +113,10 @@ async function waitForPluginApprovalDecision(params) {
113
113
  let onAbort;
114
114
  const abortPromise = new Promise((_, reject) => {
115
115
  if (params.signal.aborted) {
116
- reject(params.signal.reason);
116
+ reject(toLintErrorObject(params.signal.reason, "Non-Error rejection"));
117
117
  return;
118
118
  }
119
- onAbort = () => reject(params.signal.reason);
119
+ onAbort = () => reject(toLintErrorObject(params.signal.reason, "Non-Error rejection"));
120
120
  params.signal.addEventListener("abort", onAbort, { once: true });
121
121
  });
122
122
  try {
@@ -134,6 +134,13 @@ function mapExecDecisionToOutcome(decision) {
134
134
  function truncateForGateway(value, maxLength) {
135
135
  return value.length <= maxLength ? value : `${value.slice(0, Math.max(0, maxLength - 3))}...`;
136
136
  }
137
+ function toLintErrorObject(value, fallbackMessage) {
138
+ if (value instanceof Error) return value;
139
+ if (typeof value === "string") return new Error(value);
140
+ const error = new Error(fallbackMessage, { cause: value });
141
+ if (typeof value === "object" && value !== null || typeof value === "function") Object.assign(error, value);
142
+ return error;
143
+ }
137
144
  //#endregion
138
145
  //#region extensions/codex/src/app-server/approval-bridge.ts
139
146
  const PERMISSION_DESCRIPTION_MAX_LENGTH = 700;
@@ -2098,7 +2105,8 @@ function buildCodexNativeHookRelayConfig(params) {
2098
2105
  for (const event of CODEX_NATIVE_HOOK_RELAY_EVENTS) {
2099
2106
  const codexEvent = CODEX_HOOK_EVENT_BY_NATIVE_EVENT[event];
2100
2107
  const selected = selectedEvents.has(event);
2101
- if (!selected || !params.relay.shouldRelayEvent(event)) {
2108
+ const shouldRelay = params.relay.shouldRelayEvent(event);
2109
+ if (!selected || !shouldRelay && !(selected && event === "pre_tool_use" && !shouldRelay)) {
2102
2110
  if (selected || params.clearOmittedEvents) config[`hooks.${codexEvent}`] = [];
2103
2111
  if (params.clearOmittedEvents) for (const sourcePath of CODEX_SESSION_FLAGS_HOOK_SOURCE_PATHS) hookState[`${sourcePath}:${CODEX_HOOK_KEY_LABEL_BY_NATIVE_EVENT[event]}:0:0`] = { enabled: false };
2104
2112
  continue;
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-mbjSisZL.js").then((n) => n.r);
126
+ const { listCodexAppServerModels } = await import("./models-DEgJXKQy.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
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-DBlR-rV2.js";
3
+ import { a as releaseLeasedSharedCodexAppServerClient, c as withTimeout, i as getLeasedSharedCodexAppServerClient, m as resolveCodexAppServerHomeDir, r as createIsolatedCodexAppServerClient } from "./shared-client-ByKKWtYX.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
@@ -3,20 +3,20 @@ import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCod
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
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
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-DuFgTwRU.js";
6
+ import { n as buildCodexPluginAppCacheKey, r as CODEX_CONTROL_METHODS } from "./request-DYdA1i4c.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-DBlR-rV2.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";
9
9
  import { i as resolveCodexNativeExecutionPolicy } from "./sandbox-guard-DMCJlzmz.js";
10
- import { n as defaultLeasedCodexAppServerClientFactory } from "./client-factory-B8dh39UW.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-DCxPRaBN.js";
12
- import { t as ensureCodexComputerUse } from "./computer-use-D-0EFJBJ.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";
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";
16
16
  import fsSync from "node:fs";
17
17
  import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
18
18
  import { asBoolean, asFiniteNumber, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
19
- import { CODEX_APP_SERVER_CONTEXT_ENGINE_HOST, TOOL_PROGRESS_OUTPUT_MAX_CHARS, acquireSessionWriteLock, appendSessionTranscriptMessage, assembleHarnessContextEngine, assertContextEngineHostSupport, awaitAgentHarnessAgentEndHook, bootstrapHarnessContextEngine, buildAgentHookContextChannelFields, buildBootstrapContextForFiles, buildEmbeddedAttemptToolRunContext, buildHarnessContextEngineRuntimeContext, buildHarnessContextEngineRuntimeContextFromUsage, classifyAgentHarnessTerminalOutcome, clearActiveEmbeddedRun, embeddedAgentLog, emitAgentEvent, emitSessionTranscriptUpdate, finalizeHarnessContextEngineTurn, formatErrorMessage, formatToolAggregate, formatToolProgressOutput, getAgentHarnessHookRunner, getBeforeToolCallPolicyDiagnosticState, inferToolMetaFromArgs, isActiveHarnessContextEngine, isSubagentSessionKey, loadCodexBundleMcpThreadConfig, normalizeAgentRuntimeTools, normalizeUsage, resolveAgentHarnessBeforePromptBuildResult, resolveAttemptSpawnWorkspaceDir, resolveBootstrapFilesForRun, resolveContextEngineOwnerPluginId, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, resolveSessionWriteLockOptions, resolveUserPath, runAgentCleanupStep, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessAgentEndHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessBeforeMessageWriteHook, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
19
+ import { CODEX_APP_SERVER_CONTEXT_ENGINE_HOST, TOOL_PROGRESS_OUTPUT_MAX_CHARS, acquireSessionWriteLock, appendSessionTranscriptMessage, assembleHarnessContextEngine, assertContextEngineHostSupport, awaitAgentHarnessAgentEndHook, bootstrapHarnessContextEngine, buildAgentHookContextChannelFields, buildBootstrapContextForFiles, buildEmbeddedAttemptToolRunContext, buildHarnessContextEngineRuntimeContext, buildHarnessContextEngineRuntimeContextFromUsage, classifyAgentHarnessTerminalOutcome, clearActiveEmbeddedRun, embeddedAgentLog, emitAgentEvent, emitSessionTranscriptUpdate, filterProviderNormalizableTools, finalizeHarnessContextEngineTurn, formatErrorMessage, formatToolAggregate, formatToolProgressOutput, getAgentHarnessHookRunner, getBeforeToolCallPolicyDiagnosticState, inferToolMetaFromArgs, isActiveHarnessContextEngine, isSubagentSessionKey, loadCodexBundleMcpThreadConfig, normalizeAgentRuntimeTools, normalizeUsage, resolveAgentHarnessBeforePromptBuildResult, resolveAttemptSpawnWorkspaceDir, resolveBootstrapFilesForRun, resolveContextEngineOwnerPluginId, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, resolveSessionWriteLockOptions, resolveUserPath, runAgentCleanupStep, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessAgentEndHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessBeforeMessageWriteHook, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
20
20
  import { spawn } from "node:child_process";
21
21
  import { once } from "node:events";
22
22
  import { WebSocketServer } from "ws";
@@ -1266,7 +1266,11 @@ async function buildDynamicTools(input) {
1266
1266
  }
1267
1267
  });
1268
1268
  toolBuildStages.mark("create-openclaw-coding-tools");
1269
- const codexFilteredTools = addNodeShellDynamicToolsIfNeeded(addSandboxShellDynamicToolsIfAvailable(isCodexMemoryFlushRun(params) ? filterCodexMemoryFlushDynamicTools(allTools) : filterCodexDynamicTools(allTools, input.pluginConfig), allTools, input), allTools, input);
1269
+ const preNormalizationDiagnostics = [];
1270
+ const readableAllToolProjection = filterProviderNormalizableTools(allTools);
1271
+ preNormalizationDiagnostics.push(...readableAllToolProjection.diagnostics);
1272
+ const readableAllTools = [...readableAllToolProjection.tools];
1273
+ const codexFilteredTools = addNodeShellDynamicToolsIfNeeded(addSandboxShellDynamicToolsIfAvailable(isCodexMemoryFlushRun(params) ? filterCodexMemoryFlushDynamicTools(readableAllTools) : filterCodexDynamicTools(readableAllTools, input.pluginConfig), readableAllTools, input), readableAllTools, input);
1270
1274
  toolBuildStages.mark("codex-filtering");
1271
1275
  const visionFilteredTools = filterToolsForVisionInputs(codexFilteredTools, {
1272
1276
  modelHasVision,
@@ -1284,9 +1288,20 @@ async function buildDynamicTools(input) {
1284
1288
  env: process.env,
1285
1289
  modelId: params.modelId,
1286
1290
  modelApi: params.model.api,
1287
- model: params.model
1291
+ model: params.model,
1292
+ onPreNormalizationSchemaDiagnostics: (diagnostics) => preNormalizationDiagnostics.push(...diagnostics)
1288
1293
  });
1289
1294
  toolBuildStages.mark("runtime-normalization");
1295
+ if (preNormalizationDiagnostics.length > 0) embeddedAgentLog.warn(`codex app-server quarantined ${preNormalizationDiagnostics.length} unsupported runtime tool schema${preNormalizationDiagnostics.length === 1 ? "" : "s"} before dynamic tool registration`, {
1296
+ runId: params.runId,
1297
+ sessionId: params.sessionId,
1298
+ diagnostics: preNormalizationDiagnostics.map((diagnostic) => ({
1299
+ index: diagnostic.toolIndex,
1300
+ tool: diagnostic.toolName,
1301
+ violations: diagnostic.violations.slice(0, 12),
1302
+ violationCount: diagnostic.violations.length
1303
+ }))
1304
+ });
1290
1305
  const summary = toolBuildStages.snapshot();
1291
1306
  if (shouldWarnCodexDynamicToolBuildStageSummary(summary)) {
1292
1307
  const phase = input.forceHeartbeatTool ? "registered-tools" : "runtime-tools";
@@ -1296,7 +1311,7 @@ async function buildDynamicTools(input) {
1296
1311
  phase,
1297
1312
  totalMs: summary.totalMs,
1298
1313
  stages: summary.stages,
1299
- allToolCount: allTools.length,
1314
+ allToolCount: readableAllTools.length,
1300
1315
  codexFilteredToolCount: codexFilteredTools.length,
1301
1316
  visionFilteredToolCount: visionFilteredTools.length,
1302
1317
  filteredToolCount: filteredTools.length,
@@ -2819,7 +2834,6 @@ async function startCodexAttemptThread(params) {
2819
2834
  const failedClient = attemptedClient;
2820
2835
  const clearedSharedClient = clearSharedCodexAppServerClientIfCurrent(failedClient);
2821
2836
  if (startupClientForAbandonedRequestCleanup === failedClient) startupClientForAbandonedRequestCleanup = void 0;
2822
- attemptedClient = void 0;
2823
2837
  if (attempt >= CODEX_APP_SERVER_STARTUP_CONNECTION_CLOSE_MAX_ATTEMPTS) {
2824
2838
  embeddedAgentLog.warn("codex app-server connection closed during startup; retries exhausted", {
2825
2839
  attempt,
@@ -4022,6 +4036,9 @@ var CodexAppServerEventProjector = class {
4022
4036
  const itemId = readString$5(params, "itemId") ?? readString$5(params, "id") ?? "assistant";
4023
4037
  const delta = readString$5(params, "delta") ?? "";
4024
4038
  if (!delta) return;
4039
+ this.rememberAssistantPhase(readItem(params.item));
4040
+ const phase = readString$5(params, "phase");
4041
+ if (phase) this.assistantPhaseByItem.set(itemId, phase);
4025
4042
  if (!this.assistantStarted) {
4026
4043
  this.assistantStarted = true;
4027
4044
  await this.params.onAssistantMessageStart?.();
@@ -4033,6 +4050,10 @@ var CodexAppServerEventProjector = class {
4033
4050
  itemId,
4034
4051
  text
4035
4052
  });
4053
+ else if (this.shouldStreamAssistantPartial(itemId)) await this.params.onPartialReply?.({
4054
+ text,
4055
+ delta
4056
+ });
4036
4057
  }
4037
4058
  async handleReasoningDelta(method, params) {
4038
4059
  const itemId = readString$5(params, "itemId") ?? readString$5(params, "id") ?? "reasoning";
@@ -4461,6 +4482,9 @@ var CodexAppServerEventProjector = class {
4461
4482
  isCommentaryAssistantItem(itemId) {
4462
4483
  return this.assistantPhaseByItem.get(itemId) === "commentary";
4463
4484
  }
4485
+ shouldStreamAssistantPartial(itemId) {
4486
+ return this.assistantPhaseByItem.get(itemId) === "final_answer";
4487
+ }
4464
4488
  emitCommentaryProgress(params) {
4465
4489
  const progressText = params.text.replace(/\s+/g, " ").trim();
4466
4490
  if (!progressText || this.lastCommentaryProgressTextByItem.get(params.itemId) === progressText) return;
@@ -5464,6 +5488,7 @@ var CodexNativeSubagentTaskMirror = class {
5464
5488
  this.params = params;
5465
5489
  this.runtime = runtime;
5466
5490
  this.mirroredThreadIds = /* @__PURE__ */ new Set();
5491
+ this.failedMirrorThreadIds = /* @__PURE__ */ new Set();
5467
5492
  this.terminalRunIds = /* @__PURE__ */ new Set();
5468
5493
  this.now = params.now ?? Date.now;
5469
5494
  }
@@ -5493,7 +5518,7 @@ var CodexNativeSubagentTaskMirror = class {
5493
5518
  const label = trimOptional(spawn.agent_nickname) ?? trimOptional(thread.agentNickname) ?? trimOptional(spawn.agent_role) ?? trimOptional(thread.agentRole) ?? "Codex subagent";
5494
5519
  const task = trimOptional(thread.preview) ?? `Codex native subagent${label === "Codex subagent" ? "" : ` ${label}`}`;
5495
5520
  const createdAt = secondsToMillis$1(thread.createdAt) ?? this.now();
5496
- this.runtime.createRunningTaskRun({
5521
+ if (!this.runtime.tryCreateRunningTaskRun({
5497
5522
  sourceId: runId,
5498
5523
  agentId: this.params.agentId,
5499
5524
  runId,
@@ -5505,7 +5530,13 @@ var CodexNativeSubagentTaskMirror = class {
5505
5530
  startedAt: createdAt,
5506
5531
  lastEventAt: this.now(),
5507
5532
  progressSummary: "Codex native subagent started."
5508
- });
5533
+ })) {
5534
+ this.mirroredThreadIds.delete(threadId);
5535
+ this.failedMirrorThreadIds.add(threadId);
5536
+ return;
5537
+ }
5538
+ this.failedMirrorThreadIds.delete(threadId);
5539
+ this.terminalRunIds.delete(runId);
5509
5540
  this.applyStatus(threadId, thread.status);
5510
5541
  }
5511
5542
  handleThreadStatusChanged(params) {
@@ -5514,6 +5545,7 @@ var CodexNativeSubagentTaskMirror = class {
5514
5545
  this.applyStatus(notification.threadId, notification.status);
5515
5546
  }
5516
5547
  applyStatus(threadId, status) {
5548
+ if (!this.mirroredThreadIds.has(threadId) && this.failedMirrorThreadIds.has(threadId)) return;
5517
5549
  const statusType = status?.type;
5518
5550
  if (!statusType) return;
5519
5551
  const runId = codexNativeSubagentRunId(threadId);
@@ -5593,7 +5625,7 @@ var CodexNativeSubagentTaskMirror = class {
5593
5625
  const prompt = trimOptional(readString$3(item, "prompt"));
5594
5626
  const runId = codexNativeSubagentRunId(normalizedThreadId);
5595
5627
  const createdAt = this.now();
5596
- this.runtime.createRunningTaskRun({
5628
+ if (!this.runtime.tryCreateRunningTaskRun({
5597
5629
  sourceId: runId,
5598
5630
  agentId: this.params.agentId,
5599
5631
  runId,
@@ -5605,9 +5637,16 @@ var CodexNativeSubagentTaskMirror = class {
5605
5637
  startedAt: createdAt,
5606
5638
  lastEventAt: createdAt,
5607
5639
  progressSummary: "Codex native subagent spawned."
5608
- });
5640
+ })) {
5641
+ this.mirroredThreadIds.delete(normalizedThreadId);
5642
+ this.failedMirrorThreadIds.add(normalizedThreadId);
5643
+ return;
5644
+ }
5645
+ this.failedMirrorThreadIds.delete(normalizedThreadId);
5646
+ this.terminalRunIds.delete(runId);
5609
5647
  }
5610
5648
  applyCollabAgentStatus(threadId, status, message) {
5649
+ if (!this.mirroredThreadIds.has(threadId) && this.failedMirrorThreadIds.has(threadId)) return;
5611
5650
  const normalizedStatus = normalizeAgentStateStatus(status);
5612
5651
  if (!normalizedStatus) return;
5613
5652
  const runId = codexNativeSubagentRunId(threadId);
@@ -6834,7 +6873,7 @@ function sanitizeValue(value, depth = 0, key = "") {
6834
6873
  if (Array.isArray(value)) return value.slice(0, 100).map((entry) => sanitizeValue(entry, depth + 1, key));
6835
6874
  if (typeof value === "object") {
6836
6875
  const next = {};
6837
- for (const [key, child] of Object.entries(value).slice(0, 100)) next[key] = sanitizeValue(child, depth + 1, key);
6876
+ for (const [keyLocal, child] of Object.entries(value).slice(0, 100)) next[keyLocal] = sanitizeValue(child, depth + 1, keyLocal);
6838
6877
  return next;
6839
6878
  }
6840
6879
  return JSON.stringify(value);
@@ -7291,17 +7330,21 @@ async function runCodexAppServerAttempt(params, options = {}) {
7291
7330
  else params.abortSignal?.addEventListener("abort", abortFromUpstream, { once: true });
7292
7331
  const agentDir = params.agentDir ?? resolveAgentDir$1(params.config ?? {}, sessionAgentId);
7293
7332
  preDynamicStartupStages.mark("session-agent");
7333
+ const activeContextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
7334
+ const isInactiveThreadBootstrapBinding = (binding) => !activeContextEngine && binding?.contextEngine?.projection?.mode === "thread_bootstrap";
7294
7335
  let startupBinding = await readCodexAppServerBinding(params.sessionFile);
7295
7336
  preDynamicStartupStages.mark("read-binding");
7296
7337
  const startupBindingAuthProfileId = startupBinding?.authProfileId;
7338
+ const initialStartupBindingHadInactiveThreadBootstrap = isInactiveThreadBootstrapBinding(startupBinding);
7297
7339
  startupBinding = await rotateOversizedCodexAppServerStartupBinding({
7298
7340
  binding: startupBinding,
7299
7341
  sessionFile: params.sessionFile,
7300
7342
  agentDir,
7301
7343
  codexHome: appServer.start.env?.CODEX_HOME,
7302
7344
  config: params.config,
7303
- contextEngineActive: isActiveHarnessContextEngine(params.contextEngine)
7345
+ contextEngineActive: Boolean(activeContextEngine)
7304
7346
  });
7347
+ const initialInactiveThreadBootstrapBindingForcedFreshStart = initialStartupBindingHadInactiveThreadBootstrap && !startupBinding?.threadId;
7305
7348
  preDynamicStartupStages.mark("rotate-binding");
7306
7349
  const startupAuthProfileCandidate = params.runtimePlan?.auth.forwardedAuthProfileId ?? params.authProfileId ?? startupBinding?.authProfileId ?? startupBindingAuthProfileId;
7307
7350
  const startupAuthProfileId = params.authProfileStore ? resolveCodexAppServerAuthProfileId({
@@ -7356,7 +7399,6 @@ async function runCodexAppServerAttempt(params, options = {}) {
7356
7399
  });
7357
7400
  preDynamicStartupStages.mark("native-tool-surface");
7358
7401
  for (const diagnostic of bundleMcpThreadConfig.diagnostics) embeddedAgentLog.warn(`bundle-mcp: ${diagnostic.pluginId}: ${diagnostic.message}`);
7359
- const activeContextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
7360
7402
  if (activeContextEngine) assertContextEngineHostSupport({
7361
7403
  contextEngine: activeContextEngine,
7362
7404
  operation: "agent-run",
@@ -7492,6 +7534,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
7492
7534
  let contextEngineProjection;
7493
7535
  let precomputedStaleBindingContinuityProjectionApplied = false;
7494
7536
  let staleBindingContinuityForcedFreshStart = false;
7537
+ let inactiveThreadBootstrapBindingForcedFreshStart = initialInactiveThreadBootstrapBindingForcedFreshStart;
7495
7538
  const applyFreshThreadContinuityProjection = () => {
7496
7539
  const projection = projectContextEngineAssemblyForCodex({
7497
7540
  assembledMessages: historyMessages,
@@ -7622,6 +7665,10 @@ async function runCodexAppServerAttempt(params, options = {}) {
7622
7665
  precomputedStaleBindingContinuityProjectionApplied = false;
7623
7666
  staleBindingContinuityForcedFreshStart = false;
7624
7667
  if (activeContextEngine || !binding?.threadId) return false;
7668
+ if (isInactiveThreadBootstrapBinding(binding)) {
7669
+ inactiveThreadBootstrapBindingForcedFreshStart = true;
7670
+ return false;
7671
+ }
7625
7672
  const projected = applyResumeStaleBindingContinuityProjection(binding);
7626
7673
  precomputedStaleBindingContinuityProjectionApplied = projected;
7627
7674
  return projected;
@@ -7630,6 +7677,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
7630
7677
  if (activeContextEngine || !historyMessages.some((message) => message.role === "user")) return false;
7631
7678
  if (action === "resumed" && precomputedStaleBindingContinuityProjectionApplied) return true;
7632
7679
  if (action === "started" && staleBindingContinuityForcedFreshStart) return true;
7680
+ if (action === "started" && inactiveThreadBootstrapBindingForcedFreshStart) return false;
7633
7681
  if (action === "resumed" && binding) return applyResumeStaleBindingContinuityProjection(binding);
7634
7682
  if (action === "started") {
7635
7683
  applyFreshThreadContinuityProjection();
@@ -7641,6 +7689,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
7641
7689
  const rotateStartupBindingForProjectedTurn = async () => {
7642
7690
  if (!startupBinding?.threadId) return;
7643
7691
  const previousThreadId = startupBinding.threadId;
7692
+ const hadInactiveThreadBootstrapBinding = isInactiveThreadBootstrapBinding(startupBinding);
7644
7693
  const projectedTurnTokens = estimateCodexAppServerProjectedTurnTokens({
7645
7694
  prompt: codexTurnPromptText,
7646
7695
  developerInstructions: buildRenderedCodexDeveloperInstructions()
@@ -7655,7 +7704,8 @@ async function runCodexAppServerAttempt(params, options = {}) {
7655
7704
  projectedTurnTokens
7656
7705
  });
7657
7706
  if (startupBinding?.threadId) return;
7658
- staleBindingContinuityForcedFreshStart = precomputedStaleBindingContinuityProjectionApplied;
7707
+ inactiveThreadBootstrapBindingForcedFreshStart = hadInactiveThreadBootstrapBinding;
7708
+ staleBindingContinuityForcedFreshStart = precomputedStaleBindingContinuityProjectionApplied && !inactiveThreadBootstrapBindingForcedFreshStart;
7659
7709
  if (activeContextEngine) {
7660
7710
  contextEngineProjection = void 0;
7661
7711
  try {
@@ -7693,8 +7743,17 @@ async function runCodexAppServerAttempt(params, options = {}) {
7693
7743
  let client;
7694
7744
  let thread;
7695
7745
  let trajectoryEndRecorded = false;
7746
+ const markTrajectoryEndRecorded = () => {
7747
+ trajectoryEndRecorded = true;
7748
+ };
7696
7749
  let nativeHookRelay;
7697
7750
  let releaseSharedClientLease;
7751
+ const releaseSharedClientLeaseOnce = () => {
7752
+ const release = releaseSharedClientLease;
7753
+ if (!release) return;
7754
+ releaseSharedClientLease = void 0;
7755
+ release();
7756
+ };
7698
7757
  let sandboxExecEnvironmentAcquired = false;
7699
7758
  const releaseSandboxExecEnvironment = async () => {
7700
7759
  if (sandboxExecEnvironmentAcquired) {
@@ -7902,11 +7961,11 @@ async function runCodexAppServerAttempt(params, options = {}) {
7902
7961
  });
7903
7962
  }
7904
7963
  });
7905
- const releaseTurnAfterTerminalDynamicTool = (params) => {
7964
+ const releaseTurnAfterTerminalDynamicTool = (paramsValue) => {
7906
7965
  if (!shouldReleaseTurnAfterTerminalDynamicTool({
7907
7966
  completed,
7908
7967
  aborted: runAbortController.signal.aborted,
7909
- responseSuccess: params.response.success,
7968
+ responseSuccess: paramsValue.response.success,
7910
7969
  currentTurnHadNonTerminalDynamicToolResult,
7911
7970
  activeAppServerTurnRequests,
7912
7971
  activeTurnItemIdsCount: activeTurnItemIds.size,
@@ -7914,22 +7973,22 @@ async function runCodexAppServerAttempt(params, options = {}) {
7914
7973
  })) return;
7915
7974
  pendingTerminalDynamicToolRelease = void 0;
7916
7975
  trajectoryRecorder?.recordEvent("turn.dynamic_tool_terminal_release", {
7917
- threadId: params.call.threadId,
7918
- turnId: params.call.turnId,
7919
- toolCallId: params.call.callId,
7920
- name: params.call.tool,
7921
- durationMs: params.durationMs
7976
+ threadId: paramsValue.call.threadId,
7977
+ turnId: paramsValue.call.turnId,
7978
+ toolCallId: paramsValue.call.callId,
7979
+ name: paramsValue.call.tool,
7980
+ durationMs: paramsValue.durationMs
7922
7981
  });
7923
7982
  embeddedAgentLog.info("codex app-server turn released after terminal dynamic tool result", {
7924
- threadId: params.call.threadId,
7925
- turnId: params.call.turnId,
7926
- toolCallId: params.call.callId,
7927
- tool: params.call.tool,
7928
- durationMs: params.durationMs
7983
+ threadId: paramsValue.call.threadId,
7984
+ turnId: paramsValue.call.turnId,
7985
+ toolCallId: paramsValue.call.callId,
7986
+ tool: paramsValue.call.tool,
7987
+ durationMs: paramsValue.durationMs
7929
7988
  });
7930
7989
  interruptCodexTurnBestEffort(client, {
7931
- threadId: params.call.threadId,
7932
- turnId: params.call.turnId,
7990
+ threadId: paramsValue.call.threadId,
7991
+ turnId: paramsValue.call.turnId,
7933
7992
  timeoutMs: CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS
7934
7993
  });
7935
7994
  completed = true;
@@ -7957,8 +8016,8 @@ async function runCodexAppServerAttempt(params, options = {}) {
7957
8016
  }
7958
8017
  }).unref?.();
7959
8018
  };
7960
- const scheduleTurnReleaseAfterTerminalDynamicTool = (params) => {
7961
- pendingTerminalDynamicToolRelease = params;
8019
+ const scheduleTurnReleaseAfterTerminalDynamicTool = (paramsLocal) => {
8020
+ pendingTerminalDynamicToolRelease = paramsLocal;
7962
8021
  scheduleTerminalDynamicToolReleaseCheck();
7963
8022
  };
7964
8023
  const emitLifecycleStart = () => {
@@ -8455,7 +8514,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8455
8514
  aborted: runAbortController.signal.aborted,
8456
8515
  promptError: turnStartErrorMessage
8457
8516
  });
8458
- trajectoryEndRecorded = true;
8517
+ markTrajectoryEndRecorded();
8459
8518
  runAgentHarnessLlmOutputHook({
8460
8519
  event: {
8461
8520
  runId: params.runId,
@@ -8512,8 +8571,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8512
8571
  }
8513
8572
  });
8514
8573
  params.abortSignal?.removeEventListener("abort", abortFromUpstream);
8515
- releaseSharedClientLease?.();
8516
- releaseSharedClientLease = void 0;
8574
+ releaseSharedClientLeaseOnce();
8517
8575
  if (usageLimitError) {
8518
8576
  await markCodexAuthProfileBlockedFromRateLimits({
8519
8577
  params,
@@ -8531,8 +8589,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8531
8589
  }
8532
8590
  }
8533
8591
  if (!turn) {
8534
- releaseSharedClientLease?.();
8535
- releaseSharedClientLease = void 0;
8592
+ releaseSharedClientLeaseOnce();
8536
8593
  throw new Error("codex app-server turn/start failed without an error");
8537
8594
  }
8538
8595
  turnIdRef.current = turn.turn.id;
@@ -8598,7 +8655,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8598
8655
  steeringQueueRef.current = activeSteeringQueue;
8599
8656
  const handle = {
8600
8657
  kind: "embedded",
8601
- queueMessage: async (text, options) => activeSteeringQueue.queue(text, options),
8658
+ queueMessage: async (text, optionsLocal) => activeSteeringQueue.queue(text, optionsLocal),
8602
8659
  isStreaming: () => !completed,
8603
8660
  isCompacting: () => projectorRef.current?.isCompacting() ?? false,
8604
8661
  sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
@@ -8707,7 +8764,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8707
8764
  yieldDetected,
8708
8765
  promptError: normalizeCodexTrajectoryError(finalPromptError)
8709
8766
  });
8710
- trajectoryEndRecorded = true;
8767
+ markTrajectoryEndRecorded();
8711
8768
  await mirrorTranscriptBestEffort({
8712
8769
  params,
8713
8770
  agentId: sessionAgentId,
@@ -8732,7 +8789,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8732
8789
  ...finalAborted ? { aborted: true } : {}
8733
8790
  });
8734
8791
  if (activeContextEngine) {
8735
- const activeContextEnginePluginId = resolveContextEngineOwnerPluginId(activeContextEngine);
8792
+ const activeContextEnginePluginIdLocal = resolveContextEngineOwnerPluginId(activeContextEngine);
8736
8793
  const finalMessages = await readMirroredSessionHistoryMessages(activeSessionFile) ?? historyMessages.concat(result.messagesSnapshot);
8737
8794
  await finalizeHarnessContextEngineTurn({
8738
8795
  contextEngine: activeContextEngine,
@@ -8751,7 +8808,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8751
8808
  cwd: effectiveCwd,
8752
8809
  agentDir,
8753
8810
  activeAgentId: sessionAgentId,
8754
- contextEnginePluginId: activeContextEnginePluginId,
8811
+ contextEnginePluginId: activeContextEnginePluginIdLocal,
8755
8812
  tokenBudget: params.contextTokenBudget,
8756
8813
  lastCallUsage: result.attemptUsage,
8757
8814
  promptCache: result.promptCache
@@ -8845,7 +8902,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
8845
8902
  notificationCleanup();
8846
8903
  requestCleanup();
8847
8904
  closeCleanup?.();
8848
- releaseSharedClientLease?.();
8905
+ releaseSharedClientLeaseOnce();
8849
8906
  if (nativeHookRelay) if (shouldDelayNativeHookRelayUnregister) scheduleCodexNativeHookRelayUnregister({
8850
8907
  relay: nativeHookRelay,
8851
8908
  hookTimeoutSec: options.nativeHookRelay?.hookTimeoutSec
@@ -12,6 +12,8 @@ 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 LEGACY_CODEX_APP_SERVER_AUTH_PROVIDER = "codex-cli";
16
+ const CODEX_APP_SERVER_EXTERNAL_CLI_PROVIDER_IDS = [CODEX_APP_SERVER_AUTH_PROVIDER, LEGACY_CODEX_APP_SERVER_AUTH_PROVIDER];
15
17
  const OPENAI_PROVIDER = "openai";
16
18
  const OPENAI_CODEX_DEFAULT_PROFILE_ID = "openai:default";
17
19
  const CODEX_HOME_ENV_VAR = "CODEX_HOME";
@@ -65,7 +67,7 @@ function ensureCodexAppServerAuthProfileStore(params) {
65
67
  return ensureAuthProfileStore(params.agentDir, {
66
68
  allowKeychainPrompt: false,
67
69
  config: params.config,
68
- externalCliProviderIds: [CODEX_APP_SERVER_AUTH_PROVIDER],
70
+ externalCliProviderIds: CODEX_APP_SERVER_EXTERNAL_CLI_PROVIDER_IDS,
69
71
  ...params.authProfileId ? { externalCliProfileIds: [params.authProfileId] } : {}
70
72
  });
71
73
  }
@@ -365,7 +367,8 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
365
367
  } : candidate;
366
368
  }
367
369
  function isCodexAppServerAuthProvider(provider, config) {
368
- return resolveProviderIdForAuth(provider, { config }) === CODEX_APP_SERVER_AUTH_PROVIDER;
370
+ const resolvedProvider = resolveProviderIdForAuth(provider, { config });
371
+ return resolvedProvider === CODEX_APP_SERVER_AUTH_PROVIDER || resolvedProvider === LEGACY_CODEX_APP_SERVER_AUTH_PROVIDER;
369
372
  }
370
373
  function isOpenAIApiKeyBackupCredential(credential, config) {
371
374
  return credential.type === "api_key" && resolveProviderIdForAuth(credential.provider, { config }) === OPENAI_PROVIDER;
@@ -4,9 +4,9 @@ import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./clien
4
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
5
  import { a as readCodexAppServerBinding } from "./session-binding-BXJAV_xy.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-DBlR-rV2.js";
7
+ import { a as releaseLeasedSharedCodexAppServerClient, i as getLeasedSharedCodexAppServerClient, l as refreshCodexAppServerAuthTokens } from "./shared-client-ByKKWtYX.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-DCxPRaBN.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";
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
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.5.31-beta.2",
3
+ "version": "2026.5.31-beta.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/codex",
9
- "version": "2026.5.31-beta.2",
9
+ "version": "2026.5.31-beta.4",
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.2",
3
+ "version": "2026.5.31-beta.4",
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.2"
29
+ "pluginApi": ">=2026.5.31-beta.4"
30
30
  },
31
31
  "build": {
32
- "openclawVersion": "2026.5.31-beta.2"
32
+ "openclawVersion": "2026.5.31-beta.4"
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.2"
50
+ "openclaw": ">=2026.5.31-beta.4"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "openclaw": {