@openclaw/codex 2026.8.2 → 2026.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/api.js +3 -3
  2. package/dist/{attempt-client-cleanup-CpVfwctT.js → attempt-client-cleanup-DYHcRQAa.js} +6 -43
  3. package/dist/attempt-context-DmQUNWwT.js +634 -0
  4. package/dist/{binding-connection-CF7BmrDk.js → binding-connection-E6uDsPlx.js} +2 -2
  5. package/dist/{bounded-turn-DRC3hcjm.js → bounded-turn-wzJrwKKe.js} +8 -9
  6. package/dist/{capabilities-D6m_TdVy.js → capabilities-dIjNVCYH.js} +1 -1
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters--UToCokS.js → command-formatters-CLHhEB1Q.js} +3 -3
  9. package/dist/{command-handlers-CLFx2Ypa.js → command-handlers-CTGb2csu.js} +54 -55
  10. package/dist/{compact-5xqW1oCh.js → compact-_t0HQrUS.js} +33 -25
  11. package/dist/{config-CcYL77O6.js → config-BhmfC1s6.js} +12 -8
  12. package/dist/{context-compaction-activity-BOeJf7yo.js → context-compaction-activity-CMla5FPJ.js} +4 -1
  13. package/dist/doctor-contract-api.js +31 -4
  14. package/dist/{dynamic-tools-BmeXjwNZ.js → dynamic-tools-BU9tmlYm.js} +448 -457
  15. package/dist/{effective-mcp-catalog-XXQKgK1U.js → effective-mcp-catalog-DzYBW4h1.js} +2 -2
  16. package/dist/{event-projector-assistant-message-C5-Ds8mA.js → event-projector-assistant-message-DHRFXKbS.js} +4 -4
  17. package/dist/{event-projector-usage-B2r5vhWH.js → event-projector-usage-C5mcrGjp.js} +9 -137
  18. package/dist/{harness-BgeB7LnD.js → harness-DXVZ5II5.js} +13 -13
  19. package/dist/harness.js +1 -1
  20. package/dist/index.js +323 -313
  21. package/dist/{isolated-completion-CxTus3vZ.js → isolated-completion-kg9kv4iH.js} +4 -4
  22. package/dist/{launch-args-sXOAg0SX.js → launch-args-RXQwn8zV.js} +7 -1
  23. package/dist/{managed-binary-ZkGodW19.js → managed-binary-4-Vjz5GH.js} +14 -9
  24. package/dist/media-understanding-provider.js +1 -1
  25. package/dist/{model-catalog-DULBcniB.js → model-catalog-CUM68Hkl.js} +11 -11
  26. package/dist/{models-DaWfETQk.js → models-sYnEc0gd.js} +3 -3
  27. package/dist/{native-subagent-monitor-vXYUZH37.js → native-subagent-monitor-CnH147jH.js} +3 -3
  28. package/dist/{node-exec-server.runtime-DirKVZ5h.js → node-exec-server.runtime-CstNHCmC.js} +2 -2
  29. package/dist/{plugin-approval-roundtrip-CCWQGlAI.js → plugin-approval-roundtrip-CNe-Xrjx.js} +29 -3
  30. package/dist/{plugin-marketplace-discovery-BXjIFEiw.js → plugin-marketplace-discovery-CfFlKqDl.js} +6 -6
  31. package/dist/{plugin-metadata-cache-DQQm4gWT.js → plugin-metadata-cache-BFrPhb2c.js} +5 -5
  32. package/dist/provider-capabilities-DW5p4k9w.js +101 -0
  33. package/dist/{rate-limits-BqHEHXQJ.js → rate-limits-CawQJfUS.js} +1 -1
  34. package/dist/{request-BWxweEdK.js → request-DYAI5FQE.js} +18 -6
  35. package/dist/{run-attempt-BVLE4Gbi.js → run-attempt-D1hJO4fX.js} +483 -1865
  36. package/dist/{runtime-artifact-D9pYp4zL.js → runtime-artifact-C3jVimFn.js} +19 -12
  37. package/dist/{session-binding-D0zinCP1.js → session-binding-BHuTCRZQ.js} +8 -10
  38. package/dist/{session-catalog-eMhVm0Ql.js → session-catalog-yyvTWFOw.js} +138 -116
  39. package/dist/{session-cli-B2lyjJA0.js → session-cli-CmFEXMAM.js} +1 -1
  40. package/dist/session-initialization-BeWzjGiR.js +74 -0
  41. package/dist/{session-permission-policy-ScnAyG90.js → session-permission-policy-DeWVTCMj.js} +2 -2
  42. package/dist/{session-retirement-CtUtUTr9.js → session-retirement-BujDjXVF.js} +16 -9
  43. package/dist/{session-upstream-marker-gqrYIRHk.js → session-upstream-marker-C351-5Qw.js} +18 -2
  44. package/dist/{settled-turn-context-Bk3IUwod.js → settled-turn-context-D3SNWtUn.js} +6 -28
  45. package/dist/{settled-turn-finalizer-BXLN9PfJ.js → settled-turn-finalizer-BVJx4yoc.js} +5 -5
  46. package/dist/{shared-client-B1tT5U6r.js → shared-client-DxcfF9KX.js} +2748 -101
  47. package/dist/{side-question-CZ-mCw-t.js → side-question-BTZAII4l.js} +97 -63
  48. package/dist/{thread-lifecycle-CGGKP720.js → thread-lifecycle-DAcEJ_Om.js} +2039 -1487
  49. package/dist/{thread-ownership-RkaoZCmQ.js → thread-ownership-zGokd8i1.js} +10 -9
  50. package/dist/thread-policy-g4KbJPzp.js +54 -0
  51. package/dist/{thread-resume-BFt1-ZDa.js → thread-resume-C7pyVKeW.js} +15 -7
  52. package/dist/{transcript-mirror-1ep4XjzF.js → transcript-mirror-DTUxFWa_.js} +47 -10
  53. package/dist/{transport-stdio-NT_Dpd9V.js → transport-stdio-CyPldczm.js} +3 -1
  54. package/dist/upstream-session-fork-CYlBIGVt.js +966 -0
  55. package/dist/{usage-DUhd58gI.js → usage-Bj-rrzkR.js} +3 -3
  56. package/dist/{web-search-provider.runtime-BEmlE7ov.js → web-search-provider.runtime-D2FWSK4w.js} +3 -3
  57. package/openclaw.plugin.json +0 -30
  58. package/package.json +5 -5
  59. package/dist/protocol-validators-Bg5rpNxk.js +0 -2542
  60. package/dist/session-catalog-home-id-Dt2GiG5o.js +0 -112
  61. package/dist/upstream-session-fork-Dc8BFExw.js +0 -312
@@ -1,4 +1,4 @@
1
- import { $ as CodexAppServerRpcError } from "./shared-client-B1tT5U6r.js";
1
+ import { q as CodexAppServerRpcError } from "./shared-client-DxcfF9KX.js";
2
2
  //#region extensions/codex/src/app-server/capabilities.ts
3
3
  /**
4
4
  * Capability helpers for optional Codex app-server control-plane methods.
@@ -2,7 +2,7 @@ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
2
2
  //#region extensions/codex/cli-metadata.ts
3
3
  function registerCodexCliMetadata(api) {
4
4
  api.registerCli(async ({ program }) => {
5
- const { registerCodexSessionCli } = await import("./session-cli-B2lyjJA0.js");
5
+ const { registerCodexSessionCli } = await import("./session-cli-CmFEXMAM.js");
6
6
  registerCodexSessionCli(program);
7
7
  }, { descriptors: [{
8
8
  name: "codex",
@@ -1,5 +1,5 @@
1
- import { Ht as isJsonObject } from "./shared-client-B1tT5U6r.js";
2
- import { c as summarizeCodexRateLimits, o as summarizeCodexAccountRateLimits, r as hasCodexRateLimitSnapshots } from "./rate-limits-BqHEHXQJ.js";
1
+ import { $t as isJsonObject } from "./shared-client-DxcfF9KX.js";
2
+ import { c as summarizeCodexRateLimits, o as summarizeCodexAccountRateLimits, r as hasCodexRateLimitSnapshots } from "./rate-limits-CawQJfUS.js";
3
3
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  //#region extensions/codex/src/command-formatters.ts
5
5
  /**
@@ -279,4 +279,4 @@ function extractArray(value) {
279
279
  return [];
280
280
  }
281
281
  //#endregion
282
- export { formatComputerUseStatus as a, formatSkills as c, formatCodexStatus as i, formatThreads as l, formatAccount as n, formatList as o, formatCodexDisplayText as r, formatModels as s, buildHelp as t };
282
+ export { formatCodexDisplayText as a, formatComputerUseStatus as c, formatSkills as d, formatThreads as f, formatAccount as i, formatList as l, buildHelp as n, formatCodexStatus as o, escapeCodexChatText as r, formatCodexTextForDisplay as s, CODEX_RESUME_SAFE_THREAD_ID_PATTERN as t, formatModels as u };
@@ -1,25 +1,27 @@
1
- import { i as resolveCodexAppServerRuntimeOptions, j as CODEX_PLUGINS_MARKETPLACE_NAME, k as isCodexFastServiceTier } from "./config-CcYL77O6.js";
2
- import { Ft as resolveCodexAppServerFallbackApiKeyCacheKey, Ht as isJsonObject, Nt as resolveCodexAppServerAuthProfileIdForAgent, c as getLeasedSharedCodexAppServerClient, gt as consumeCodexAppServerLiveThread, h as releaseLeasedSharedCodexAppServerClient, jt as resolveCodexAppServerAuthAccountCacheKey, vt as hasCodexAppServerLiveThread } from "./shared-client-B1tT5U6r.js";
3
- import { c as reclaimCurrentCodexSessionGeneration, d as sessionBindingIdentity, i as createCodexSessionGenerationSupersededError, n as assertCodexBindingMayBeReplaced, r as bindingStoreKey, s as normalizeCodexAppServerBindingModelProvider } from "./session-binding-D0zinCP1.js";
4
- import { o as assertCodexThreadResumeResponse, r as assertCodexThreadAcceptsDirectInput } from "./protocol-validators-Bg5rpNxk.js";
5
- import { a as closeCodexStartupClientBestEffort } from "./attempt-client-cleanup-CpVfwctT.js";
6
- import { t as listAllCodexAppServerModels } from "./models-DaWfETQk.js";
7
- import { i as buildCodexPluginAppCacheKey, s as defaultCodexAppInventoryCache } from "./thread-resume-BFt1-ZDa.js";
8
- import { dt as isOpenAiCuratedMarketplaceName, lt as refreshCodexPluginRuntimeState } from "./thread-lifecycle-CGGKP720.js";
9
- import { a as rollbackCodexAppServerBindingSubscription, c as withExclusiveCodexAppServerThread, i as retireCodexConversationThreadBinding, l as isIncognitoSessionKey, n as releaseCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, s as withCodexConversationThreadActivity, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-RkaoZCmQ.js";
10
- import { c as resolveCodexNativeSandboxBlock, s as resolveCodexNativeExecutionBlock } from "./request-BWxweEdK.js";
11
- import { t as CODEX_CONTROL_METHODS } from "./capabilities-D6m_TdVy.js";
12
- import { s as summarizeCodexAccountUsage } from "./rate-limits-BqHEHXQJ.js";
13
- import { a as formatComputerUseStatus, c as formatSkills, i as formatCodexStatus, l as formatThreads, n as formatAccount, o as formatList, r as formatCodexDisplayText, s as formatModels, t as buildHelp } from "./command-formatters--UToCokS.js";
14
- import { _ as hasCodexAdminScope, a as parseCodexPermissionsModeArg, c as setCodexConversationModel, d as stopCodexConversationTurn, g as canMutateCodexHost, h as CODEX_NATIVE_EXECUTION_AUTH_ERROR, i as parseCodexFastModeArg, l as setCodexConversationPermissions, m as CODEX_HOST_INSPECTION_AUTH_ERROR, n as parseCodexPluginMarketplaceId, o as readCodexConversationActiveTurn, p as CODEX_FULL_PERMISSIONS_AUTH_ERROR, r as formatPermissionsMode, s as setCodexConversationFastMode, t as discoverCodexMarketplacePlugins, u as steerCodexConversationTurn } from "./plugin-marketplace-discovery-BXjIFEiw.js";
1
+ import { $ as assertCodexThreadResumeResponse, $t as isJsonObject, Bt as resolveCodexAppServerAuthProfileIdForAgent, Ht as resolveCodexAppServerFallbackApiKeyCacheKey, Rt as resolveCodexAppServerAuthAccountCacheKey, St as consumeCodexAppServerLiveThread, X as assertCodexThreadAcceptsDirectInput, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, wt as hasCodexAppServerLiveThread } from "./shared-client-DxcfF9KX.js";
2
+ import { A as isCodexFastServiceTier, M as CODEX_PLUGINS_MARKETPLACE_NAME, i as resolveCodexAppServerRuntimeOptions } from "./config-BhmfC1s6.js";
3
+ import { c as reclaimCurrentCodexSessionGeneration, d as sessionBindingIdentity, i as createCodexSessionGenerationSupersededError, n as assertCodexBindingMayBeReplaced, r as bindingStoreKey, s as normalizeCodexAppServerBindingModelProvider } from "./session-binding-BHuTCRZQ.js";
4
+ import { a as closeCodexStartupClientBestEffort } from "./attempt-client-cleanup-DYHcRQAa.js";
5
+ import { t as listAllCodexAppServerModels } from "./models-sYnEc0gd.js";
6
+ import { i as buildCodexPluginAppCacheKey, s as defaultCodexAppInventoryCache } from "./thread-resume-C7pyVKeW.js";
7
+ import { At as refreshCodexPluginRuntimeState, Mt as isOpenAiCuratedMarketplaceName } from "./thread-lifecycle-DAcEJ_Om.js";
8
+ import { a as rollbackCodexAppServerBindingSubscription, c as withExclusiveCodexAppServerThread, i as retireCodexConversationThreadBinding, l as isIncognitoSessionKey, n as releaseCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, s as withCodexConversationThreadActivity, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-zGokd8i1.js";
9
+ import { c as resolveCodexNativeSandboxBlock, s as resolveCodexNativeExecutionBlock } from "./request-DYAI5FQE.js";
10
+ import { r as assertCodexSupervisionThreadLineage } from "./thread-policy-g4KbJPzp.js";
11
+ import { t as CODEX_CONTROL_METHODS } from "./capabilities-dIjNVCYH.js";
12
+ import { s as summarizeCodexAccountUsage } from "./rate-limits-CawQJfUS.js";
13
+ import { a as formatCodexDisplayText, c as formatComputerUseStatus, d as formatSkills, f as formatThreads, i as formatAccount, l as formatList, n as buildHelp, o as formatCodexStatus, r as escapeCodexChatText, s as formatCodexTextForDisplay, t as CODEX_RESUME_SAFE_THREAD_ID_PATTERN, u as formatModels } from "./command-formatters-CLHhEB1Q.js";
14
+ import { _ as hasCodexAdminScope, a as parseCodexPermissionsModeArg, c as setCodexConversationModel, d as stopCodexConversationTurn, g as canMutateCodexHost, h as CODEX_NATIVE_EXECUTION_AUTH_ERROR, i as parseCodexFastModeArg, l as setCodexConversationPermissions, m as CODEX_HOST_INSPECTION_AUTH_ERROR, n as parseCodexPluginMarketplaceId, o as readCodexConversationActiveTurn, p as CODEX_FULL_PERMISSIONS_AUTH_ERROR, r as formatPermissionsMode, s as setCodexConversationFastMode, t as discoverCodexMarketplacePlugins, u as steerCodexConversationTurn } from "./plugin-marketplace-discovery-CfFlKqDl.js";
15
15
  import { i as readCodexConversationBindingData, n as createCodexCliNodeConversationBindingData, o as resolveCodexDefaultWorkspaceDir, r as createCodexConversationBindingData } from "./conversation-binding-data-BiodpIzq.js";
16
- import { n as resolveCodexBindingAppServerConnection } from "./binding-connection-CF7BmrDk.js";
17
- import { c as readCodexStatusProbes, l as requestOptions, p as formatCodexCliSessions, s as codexControlRequest, u as safeCodexControlRequest } from "./session-catalog-eMhVm0Ql.js";
18
- import { i as readCodexComputerUseStatus, r as installCodexComputerUse, t as defaultCodexPluginMetadataCache } from "./plugin-metadata-cache-DQQm4gWT.js";
16
+ import { n as resolveCodexBindingAppServerConnection } from "./binding-connection-E6uDsPlx.js";
17
+ import { c as readCodexStatusProbes, l as requestOptions, p as formatCodexCliSessions, s as codexControlRequest, u as safeCodexControlRequest } from "./session-catalog-yyvTWFOw.js";
18
+ import { i as readCodexComputerUseStatus, r as installCodexComputerUse, t as defaultCodexPluginMetadataCache } from "./plugin-metadata-cache-BFrPhb2c.js";
19
19
  import { normalizeOptionalString, normalizeUniqueStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
20
20
  import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
21
21
  import crypto from "node:crypto";
22
- import { ensureAuthProfileStore, findNormalizedProviderValue, resolveAgentDir, resolveAuthProfileEligibility, resolveAuthProfileOrder, resolveProfileUnusableUntilForDisplay } from "openclaw/plugin-sdk/agent-runtime";
22
+ import { isDeepStrictEqual } from "node:util";
23
+ import { ensureAuthProfileStore, resolveAgentDir, resolveAuthProfileEligibility, resolveProfileUnusableUntilForDisplay } from "openclaw/plugin-sdk/agent-runtime";
24
+ import { findNormalizedProviderValue, resolveAuthProfileOrder } from "openclaw/plugin-sdk/provider-auth";
23
25
  import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
24
26
  import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
25
27
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
@@ -757,7 +759,6 @@ const CODEX_DIAGNOSTICS_CONFIRMATION_TTL_MS = 3e5;
757
759
  const CODEX_DIAGNOSTICS_CONFIRMATION_MAX_REQUESTS_PER_SCOPE = 100;
758
760
  const CODEX_DIAGNOSTICS_CONFIRMATION_MAX_SCOPES = 100;
759
761
  const CODEX_DIAGNOSTICS_SCOPE_FIELD_MAX_CHARS = 128;
760
- const CODEX_RESUME_SAFE_THREAD_ID_PATTERN = /^[A-Za-z0-9._:-]+$/;
761
762
  const { lastUploadByThread: lastCodexDiagnosticsUploadByThread, lastUploadByScope: lastCodexDiagnosticsUploadByScope, pendingConfirmations: pendingCodexDiagnosticsConfirmations, pendingTokensByScope: pendingCodexDiagnosticsConfirmationTokensByScope } = codexDiagnosticsFeedbackState;
762
763
  function normalizeDiagnosticsReason(note) {
763
764
  const normalized = normalizeOptionalString(note);
@@ -910,7 +911,7 @@ function formatCodexDiagnosticsTargetLines(targets) {
910
911
  }
911
912
  function formatCodexDiagnosticsTargetBlock(target, index) {
912
913
  const lines = [`Session ${index + 1}`];
913
- if (target.channel) lines.push(`Channel: ${formatCodexValueForDisplay(target.channel)}`);
914
+ if (target.channel) lines.push(`Channel: ${formatCodexDisplayText(target.channel)}`);
914
915
  if (target.sessionKey) lines.push(`OpenClaw session key: ${formatCodexCopyableValueForDisplay(target.sessionKey)}`);
915
916
  if (target.sessionId) lines.push(`OpenClaw session id: ${formatCodexCopyableValueForDisplay(target.sessionId)}`);
916
917
  lines.push(`Codex thread id: ${formatCodexCopyableValueForDisplay(target.threadId)}`);
@@ -919,30 +920,18 @@ function formatCodexDiagnosticsTargetBlock(target, index) {
919
920
  }
920
921
  function formatCodexDiagnosticsTargetLine(target) {
921
922
  const parts = [];
922
- if (target.channel) parts.push(`channel ${formatCodexValueForDisplay(target.channel)}`);
923
+ if (target.channel) parts.push(`channel ${formatCodexDisplayText(target.channel)}`);
923
924
  const sessionLabel = target.sessionId || target.sessionKey;
924
- if (sessionLabel) parts.push(`OpenClaw session ${formatCodexValueForDisplay(sessionLabel)}`);
925
- parts.push(`Codex thread ${formatCodexThreadIdForDisplay(target.threadId)}`);
925
+ if (sessionLabel) parts.push(`OpenClaw session ${formatCodexDisplayText(sessionLabel)}`);
926
+ parts.push(`Codex thread ${formatCodexDisplayText(target.threadId)}`);
926
927
  return `- ${parts.join(", ")}`;
927
928
  }
928
- function escapeCodexChatText(value) {
929
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("@", "@").replaceAll("`", "`").replaceAll("[", "[").replaceAll("]", "]").replaceAll("(", "(").replaceAll(")", ")").replaceAll("*", "∗").replaceAll("_", "_").replaceAll("~", "~").replaceAll("|", "|");
930
- }
931
- function formatCodexTextForDisplay(value) {
932
- let safe = "";
933
- for (const character of value) {
934
- const codePoint = character.codePointAt(0);
935
- safe += codePoint != null && isUnsafeDisplayCodePoint(codePoint) ? "?" : character;
936
- }
937
- safe = safe.trim();
938
- return safe || "<unknown>";
939
- }
940
929
  function readCodexDiagnosticsTargetsCooldownMessage(targets, ctx, now, options = {}) {
941
930
  for (const target of targets) {
942
931
  const cooldownMs = readCodexDiagnosticsCooldownMs(target.threadId, now);
943
932
  if (cooldownMs > 0) {
944
933
  if (options.includeThreadId === false) return `Codex diagnostics were already sent for one of these Codex threads recently. Try again in ${Math.ceil(cooldownMs / 1e3)}s.`;
945
- return `Codex diagnostics were already sent for thread ${formatCodexThreadIdForDisplay(target.threadId)} recently. Try again in ${Math.ceil(cooldownMs / 1e3)}s.`;
934
+ return `Codex diagnostics were already sent for thread ${formatCodexDisplayText(target.threadId)} recently. Try again in ${Math.ceil(cooldownMs / 1e3)}s.`;
946
935
  }
947
936
  }
948
937
  const scopeCooldownMs = readCodexDiagnosticsScopeCooldownMs(options.cooldownScope ?? readCodexDiagnosticsCooldownScope(ctx), now);
@@ -974,12 +963,6 @@ function buildDiagnosticsTags(ctx) {
974
963
  function addTag(tags, key, value) {
975
964
  if (typeof value === "string" && value.trim()) tags[key] = value.trim();
976
965
  }
977
- function formatCodexThreadIdForDisplay(threadId) {
978
- return escapeCodexChatText(formatCodexTextForDisplay(threadId));
979
- }
980
- function formatCodexValueForDisplay(value) {
981
- return escapeCodexChatText(formatCodexTextForDisplay(value));
982
- }
983
966
  function formatCodexCopyableValueForDisplay(value) {
984
967
  const safe = formatCodexTextForDisplay(value);
985
968
  if (CODEX_RESUME_SAFE_THREAD_ID_PATTERN.test(safe)) return `\`${safe}\``;
@@ -1015,16 +998,14 @@ function pruneCodexDiagnosticsCooldownMap(map, now) {
1015
998
  for (const [key, lastSentAt] of map) if (now - lastSentAt >= CODEX_DIAGNOSTICS_COOLDOWN_MS) map.delete(key);
1016
999
  }
1017
1000
  function formatCodexErrorForDisplay(error) {
1018
- return escapeCodexChatText(truncateUtf16Safe(formatCodexTextForDisplay(error), CODEX_DIAGNOSTICS_ERROR_MAX_CHARS)) || "unknown error";
1001
+ const safe = truncateUtf16Safe(formatCodexTextForDisplay(error), CODEX_DIAGNOSTICS_ERROR_MAX_CHARS);
1002
+ return escapeCodexChatText(safe) || "unknown error";
1019
1003
  }
1020
1004
  function formatCodexResumeCommandForDisplay(threadId) {
1021
1005
  const safeThreadId = formatCodexTextForDisplay(threadId);
1022
1006
  if (!CODEX_RESUME_SAFE_THREAD_ID_PATTERN.test(safeThreadId)) return "run codex resume and paste the thread id shown above";
1023
1007
  return `\`codex resume ${safeThreadId}\``;
1024
1008
  }
1025
- function isUnsafeDisplayCodePoint(codePoint) {
1026
- return codePoint <= 31 || codePoint >= 127 && codePoint <= 159 || codePoint === 173 || codePoint === 1564 || codePoint === 6158 || codePoint >= 8203 && codePoint <= 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8288 && codePoint <= 8303 || codePoint === 65279 || codePoint >= 65529 && codePoint <= 65531 || codePoint >= 917504 && codePoint <= 917631;
1027
- }
1028
1009
  function normalizeCodexDiagnosticsScopeField(value) {
1029
1010
  const normalized = normalizeOptionalString(value);
1030
1011
  if (!normalized) return;
@@ -1158,7 +1139,7 @@ async function requestCodexDiagnosticsFeedbackApproval(deps, ctx, note, commandP
1158
1139
  });
1159
1140
  const confirmCommand = `${commandPrefix} confirm ${token}`;
1160
1141
  const cancelCommand = `${commandPrefix} cancel ${token}`;
1161
- const displayReason = reason ? escapeCodexChatText(formatCodexTextForDisplay(reason)) : void 0;
1142
+ const displayReason = reason ? formatCodexDisplayText(reason) : void 0;
1162
1143
  return {
1163
1144
  text: [
1164
1145
  targets.length === 1 ? "Codex runtime thread detected." : "Codex runtime threads detected.",
@@ -1200,7 +1181,7 @@ async function previewCodexDiagnosticsFeedbackApproval(deps, ctx, note) {
1200
1181
  const cooldownMessage = readCodexDiagnosticsTargetsCooldownMessage(targets, ctx, Date.now(), { includeThreadId: false });
1201
1182
  if (cooldownMessage) return cooldownMessage;
1202
1183
  const reason = normalizeDiagnosticsReason(note);
1203
- const displayReason = reason ? escapeCodexChatText(formatCodexTextForDisplay(reason)) : void 0;
1184
+ const displayReason = reason ? formatCodexDisplayText(reason) : void 0;
1204
1185
  return [
1205
1186
  targets.length === 1 ? "Codex runtime thread detected." : "Codex runtime threads detected.",
1206
1187
  `Approving diagnostics will also send ${targets.length === 1 ? "this thread's feedback bundle" : "these threads' feedback bundles"} to OpenAI servers.`,
@@ -1806,11 +1787,14 @@ async function handleNativeGoal(deps, ctx, pluginConfig, args) {
1806
1787
  const isObjectiveUpdate = action === "set";
1807
1788
  if (!requestedStatus && !isObjectiveUpdate || isObjectiveUpdate && !objective) return "Usage: /codex goal [status|set <objective>|pause|resume|block|complete|clear]";
1808
1789
  if (requestedStatus && args.length > 1) return `Usage: /codex goal ${action}`;
1809
- return formatNativeGoal(await deps.codexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.setThreadGoal, {
1790
+ return formatNativeGoal(await deps.bindingStore.withLease(target.identity, () => deps.codexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.setThreadGoal, {
1810
1791
  threadId: binding.threadId,
1811
1792
  ...objective ? { objective } : {},
1812
1793
  ...requestedStatus ? { status: requestedStatus } : {}
1813
- }, goalRequestOptions));
1794
+ }, {
1795
+ ...goalRequestOptions,
1796
+ ...(isObjectiveUpdate || requestedStatus === "active") && connection.usesSupervisionConnection ? { beforeRequest: supervisedCommandGuard(deps, target.identity, binding) } : {}
1797
+ })));
1814
1798
  }
1815
1799
  function formatNativeGoal(response) {
1816
1800
  const goal = isJsonObject(response) && isJsonObject(response.goal) ? response.goal : void 0;
@@ -1942,20 +1926,35 @@ async function startThreadAction(deps, ctx, pluginConfig, kind, args) {
1942
1926
  authProfileId: binding.authProfileId,
1943
1927
  pluginConfig
1944
1928
  });
1945
- await deps.codexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.review, {
1929
+ await deps.bindingStore.withLease(target.identity, () => deps.codexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.review, {
1946
1930
  threadId: binding.threadId,
1947
1931
  target: { type: "uncommittedChanges" }
1948
1932
  }, {
1949
1933
  agentDir: target.agentDir,
1950
1934
  authProfileId: connection.clientAuthProfileId,
1951
1935
  config: ctx.config,
1952
- ...connection.usesSupervisionConnection ? { startOptions: connection.appServer.start } : {}
1953
- });
1936
+ ...connection.usesSupervisionConnection ? {
1937
+ startOptions: connection.appServer.start,
1938
+ beforeRequest: supervisedCommandGuard(deps, target.identity, binding)
1939
+ } : {}
1940
+ }));
1954
1941
  return `Started Codex review for thread ${formatCodexDisplayText(binding.threadId)}.`;
1955
1942
  }
1943
+ function supervisedCommandGuard(deps, identity, binding) {
1944
+ return async (_request, client, scope) => {
1945
+ const { thread } = await client.request("thread/read", {
1946
+ threadId: binding.threadId,
1947
+ includeTurns: false
1948
+ });
1949
+ scope.assertCurrent();
1950
+ if (!isDeepStrictEqual(await deps.bindingStore.read(identity), binding)) throw new Error("Codex command binding changed before model execution");
1951
+ scope.assertCurrent();
1952
+ assertCodexSupervisionThreadLineage(binding, thread);
1953
+ };
1954
+ }
1956
1955
  //#endregion
1957
1956
  //#region extensions/codex/src/command-plugins-management.ts
1958
- const POLICY_REFRESH_HINT = "New Codex conversations pick this up automatically. Use /new or /reset to refresh the current one.";
1957
+ const POLICY_REFRESH_HINT = "Takes effect on your next message.";
1959
1958
  async function handleCodexPluginsSubcommand(ctx, rest, io, runtime) {
1960
1959
  const [verb = "list", ...args] = rest;
1961
1960
  const normalized = verb.toLowerCase();
@@ -2314,7 +2313,7 @@ function formatPluginList(plugins, options = {}) {
2314
2313
  ...rows.map((r) => ` ${r.state} ${r.displayKey.padEnd(keyW)} ${r.pluginName.padEnd(pluginW)} [${r.marketplace}]`),
2315
2314
  "",
2316
2315
  ...globalEnabled ? [] : ["Global codexPlugins.enabled is off; configured sub-plugins are inactive.", ""],
2317
- "New Codex conversations pick up policy changes automatically; /new or /reset to refresh the current one."
2316
+ POLICY_REFRESH_HINT
2318
2317
  ].join("\n");
2319
2318
  }
2320
2319
  //#endregion
@@ -1,12 +1,13 @@
1
- import { $ as CodexAppServerRpcError, Ct as retainCodexAppServerLiveThread, Ht as isJsonObject, c as getLeasedSharedCodexAppServerClient, gt as consumeCodexAppServerLiveThread, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-B1tT5U6r.js";
2
- import { d as sessionBindingIdentity, t as CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS } from "./session-binding-D0zinCP1.js";
3
- import { _ as readCodexNotificationThreadId, a as closeCodexStartupClientBestEffort, f as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError, s as isCodexAlreadyTerminalInterruptError, v as readCodexNotificationTurnId } from "./attempt-client-cleanup-CpVfwctT.js";
4
- import { i as readCodexThreadContextSnapshot, x as readCodexNotificationItem } from "./event-projector-usage-B2r5vhWH.js";
5
- import { t as resumeCodexAppServerThread } from "./thread-resume-BFt1-ZDa.js";
6
- import { l as isIncognitoSessionKey, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-RkaoZCmQ.js";
7
- import { s as resolveCodexNativeExecutionBlock } from "./request-BWxweEdK.js";
8
- import { n as resolveCodexBindingAppServerConnection } from "./binding-connection-CF7BmrDk.js";
9
- import { t as persistCodexContextCompactionActivity } from "./context-compaction-activity-BOeJf7yo.js";
1
+ import { $t as isJsonObject, At as retainCodexAppServerLiveThread, St as consumeCodexAppServerLiveThread, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, q as CodexAppServerRpcError } from "./shared-client-DxcfF9KX.js";
2
+ import { d as sessionBindingIdentity, t as CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS } from "./session-binding-BHuTCRZQ.js";
3
+ import { _ as readCodexNotificationTurnId, a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, g as readCodexNotificationThreadId, r as CodexAppServerUnsafeSubscriptionError, s as isCodexAlreadyTerminalInterruptError } from "./attempt-client-cleanup-DYHcRQAa.js";
4
+ import { f as readCodexNotificationItem, i as readCodexThreadContextSnapshot } from "./event-projector-usage-C5mcrGjp.js";
5
+ import { t as resumeCodexAppServerThread } from "./thread-resume-C7pyVKeW.js";
6
+ import { l as isIncognitoSessionKey, o as withCodexAppServerThreadMutation, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-zGokd8i1.js";
7
+ import { s as resolveCodexNativeExecutionBlock } from "./request-DYAI5FQE.js";
8
+ import { r as assertCodexSupervisionThreadLineage } from "./thread-policy-g4KbJPzp.js";
9
+ import { n as resolveCodexBindingAppServerConnection } from "./binding-connection-E6uDsPlx.js";
10
+ import { t as persistCodexContextCompactionActivity } from "./context-compaction-activity-CMla5FPJ.js";
10
11
  import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
11
12
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
12
13
  import { embeddedAgentLog, resolveCompactionTimeoutMs } from "openclaw/plugin-sdk/agent-harness-runtime";
@@ -14,17 +15,12 @@ import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-
14
15
  import { resolveDefaultAgentId as resolveDefaultAgentId$1 } from "openclaw/plugin-sdk/agent-scope-runtime";
15
16
  import { AsyncLocalStorage } from "node:async_hooks";
16
17
  import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
17
- import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
18
18
  import { createDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
19
19
  //#region extensions/codex/src/app-server/compact.ts
20
- /**
21
- * Native Codex app-server compaction bridge for bound OpenClaw sessions.
22
- */
23
20
  const warnedIgnoredCompactionOverrides = createDedupeCache({
24
21
  ttlMs: 0,
25
22
  maxSize: 4096
26
23
  });
27
- const codexNativeCompactionQueue = new KeyedAsyncQueue();
28
24
  const CODEX_NATIVE_COMPACTION_INTERRUPT_GRACE_MS = 3e4;
29
25
  function watchCodexNativeCompactionCompletion(params) {
30
26
  const runOutsideBindingLease = AsyncLocalStorage.snapshot();
@@ -195,7 +191,7 @@ function watchCodexNativeCompactionCompletion(params) {
195
191
  async function runExclusiveCodexNativeCompaction(threadId, signal, run) {
196
192
  signal?.throwIfAborted();
197
193
  let started = false;
198
- const queued = codexNativeCompactionQueue.enqueue(threadId, async () => {
194
+ const queued = withCodexAppServerThreadMutation(threadId, async () => {
199
195
  started = true;
200
196
  signal?.throwIfAborted();
201
197
  return run();
@@ -399,17 +395,29 @@ async function compactCodexNativeThread(params, options) {
399
395
  const acquireThreadSubscription = async (timeoutMs) => {
400
396
  if (!isIncognitoSessionKey(params.sessionKey)) {
401
397
  retainedThreadOwnership = await consumeCodexAppServerLiveThread(client, binding.threadId);
402
- if (!retainedThreadOwnership) await resumeCodexAppServerThread({
403
- client,
404
- abandonClient: async () => closeCodexStartupClientBestEffort(client),
405
- request: {
398
+ if (!retainedThreadOwnership) {
399
+ const resumed = await resumeCodexAppServerThread({
400
+ client,
401
+ abandonClient: async () => closeCodexStartupClientBestEffort(client),
402
+ request: {
403
+ threadId: binding.threadId,
404
+ excludeTurns: true
405
+ },
406
+ timeoutMs: timeoutMs ?? appServer.requestTimeoutMs,
407
+ ...params.abortSignal ? { signal: params.abortSignal } : {}
408
+ });
409
+ releaseThreadSubscription = async () => releaseCompactionThread(binding.threadId);
410
+ assertCodexSupervisionThreadLineage(binding, resumed.thread);
411
+ } else if (binding.connectionScope === "supervision") {
412
+ releaseThreadSubscription = async () => retainedThreadOwnership?.release(binding.threadId);
413
+ const { thread } = await client.request("thread/read", {
406
414
  threadId: binding.threadId,
407
- excludeTurns: true
408
- },
409
- timeoutMs: timeoutMs ?? appServer.requestTimeoutMs,
410
- ...params.abortSignal ? { signal: params.abortSignal } : {}
411
- });
412
- releaseThreadSubscription = async () => releaseCompactionThread(binding.threadId);
415
+ includeTurns: false
416
+ });
417
+ retainedThreadOwnership.assertCurrent();
418
+ assertCodexSupervisionThreadLineage(binding, thread);
419
+ }
420
+ releaseThreadSubscription ??= async () => releaseCompactionThread(binding.threadId);
413
421
  }
414
422
  };
415
423
  try {
@@ -1,4 +1,4 @@
1
- import { n as readCodexAppServerConfigOptions, t as normalizeCodexAppServerArgs } from "./launch-args-sXOAg0SX.js";
1
+ import { n as normalizeCodexAppServerArgs, r as readCodexAppServerConfigOptions } from "./launch-args-RXQwn8zV.js";
2
2
  import { asNullableRecord, asOptionalRecord as readRecord, normalizeOptionalString, normalizeOptionalString as readNonEmptyString, normalizeTrimmedStringList, parseBooleanValue } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import path from "node:path";
4
4
  import { resolvePositiveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
@@ -443,9 +443,6 @@ const codexPluginConfigSchema = z.object({
443
443
  codeModeOnly: z.boolean().optional(),
444
444
  loopDetectionPreToolUseRelay: z.boolean().optional(),
445
445
  requestTimeoutMs: z.number().positive().optional(),
446
- turnCompletionIdleTimeoutMs: z.number().positive().optional(),
447
- turnAssistantCompletionIdleTimeoutMs: z.number().positive().optional(),
448
- postToolRawAssistantCompletionIdleTimeoutMs: z.number().positive().optional(),
449
446
  approvalPolicy: codexAppServerApprovalPolicySchema.optional(),
450
447
  sandbox: codexAppServerSandboxSchema.optional(),
451
448
  approvalsReviewer: codexAppServerApprovalsReviewerSchema.optional(),
@@ -997,6 +994,16 @@ function stableStringifyJson(value) {
997
994
  if (value && typeof value === "object") return `{${Object.entries(value).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stableStringifyJson(item)}`).join(",")}}`;
998
995
  return JSON.stringify(value);
999
996
  }
997
+ /** Explicit MCP prompting must bypass Codex's unconditional Never-policy approval. */
998
+ function hasCodexMcpToolApprovalOverrides(servers, serverNames, projectedMcpServers) {
999
+ const modes = new Map(Object.entries(projectedMcpServers ?? {}).map(([name, server]) => [name, server.default_tools_approval_mode]));
1000
+ for (const name of serverNames ?? Object.keys(servers ?? {})) {
1001
+ const server = servers?.[name];
1002
+ const mode = server?.codex?.defaultToolsApprovalMode;
1003
+ if (mode !== void 0 && (serverNames !== void 0 || server?.enabled !== false)) modes.set(name, mode);
1004
+ }
1005
+ return [...modes.values()].some((mode) => mode === "auto" || mode === "prompt");
1006
+ }
1000
1007
  function withMcpElicitationsApprovalPolicy(policy) {
1001
1008
  if (policy === "untrusted") return policy;
1002
1009
  if (typeof policy !== "string") return { granular: {
@@ -1246,9 +1253,6 @@ function resolveCodexAppServerRuntimeOptions(params = {}) {
1246
1253
  codeModeOnly: config.codeModeOnly === true,
1247
1254
  loopDetectionPreToolUseRelay: config.loopDetectionPreToolUseRelay !== false,
1248
1255
  requestTimeoutMs: normalizePositiveNumber(config.requestTimeoutMs, 6e4),
1249
- turnCompletionIdleTimeoutMs: normalizePositiveNumber(config.turnCompletionIdleTimeoutMs, 6e4),
1250
- turnAssistantCompletionIdleTimeoutMs: normalizePositiveNumber(config.turnAssistantCompletionIdleTimeoutMs, 1e4),
1251
- ...config.postToolRawAssistantCompletionIdleTimeoutMs !== void 0 ? { postToolRawAssistantCompletionIdleTimeoutMs: normalizePositiveNumber(config.postToolRawAssistantCompletionIdleTimeoutMs, 6e4) } : {},
1252
1256
  approvalPolicy: forcedPolicy?.approvalPolicy ?? approvalPolicy,
1253
1257
  approvalPolicySource,
1254
1258
  sandbox: resolvedSandbox,
@@ -1394,4 +1398,4 @@ function resolveCodexSupervisionAppServerRuntimeOptions(params = {}) {
1394
1398
  });
1395
1399
  }
1396
1400
  //#endregion
1397
- export { normalizeCodexServiceTier as A, isCodexRemoteExecPlacementSandbox as C, resolveOpenClawExecPolicyForCodexAppServer as D, resolveCodexPluginsPolicy as E, resolveCodexAppServerLocalHomeDir as F, resolveCodexAppServerUserHomeDir as I, withEphemeralCodexAuthStore as L, CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME as M, CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN as N, selectGuardianSandbox as O, resolveCodexAppServerHomeDir as P, isCodexPairedNodeRemoteExecPlacementSandbox as S, readCodexPluginConfig as T, parseAllowedSandboxModesFromCodexRequirements as _, resolveCodexAppServerStartOptionsForAgent as a, selectGuardianApprovalsReviewer as b, assertCodexAppServerConnectionSecurity as c, withMcpElicitationsApprovalPolicy as d, assertCodexModelBackedReviewerEffectiveConfig as f, parseAllowedApprovalsReviewersFromCodexRequirements as g, parseAllowedApprovalPoliciesFromCodexRequirements as h, resolveCodexAppServerRuntimeOptions as i, CODEX_PLUGINS_MARKETPLACE_NAME as j, isCodexFastServiceTier as k, resolveCodexAppServerNetworkProxy as l, resolveCodexModelBackedReviewerPolicyContext as m, codexSandboxPolicyForTurn as n, resolveCodexComputerUseConfig as o, canUseCodexModelBackedApprovalsReviewerForModel as p, resolveCodexAppServerHomeScope as r, resolveCodexSupervisionAppServerRuntimeOptions as s, codexAppServerStartOptionsKey as t, shouldAutoApproveCodexAppServerApprovals as u, readCodexRequirementsToml as v, isCodexSandboxExecServerEnabled as w, selectUserApprovalsReviewer as x, selectGuardianApprovalPolicy as y };
1401
+ export { isCodexFastServiceTier as A, isCodexPairedNodeRemoteExecPlacementSandbox as C, resolveCodexPluginsPolicy as D, readCodexPluginConfig as E, resolveCodexAppServerHomeDir as F, resolveCodexAppServerLocalHomeDir as I, resolveCodexAppServerUserHomeDir as L, CODEX_PLUGINS_MARKETPLACE_NAME as M, CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME as N, resolveOpenClawExecPolicyForCodexAppServer as O, CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN as P, withEphemeralCodexAuthStore as R, selectUserApprovalsReviewer as S, isCodexSandboxExecServerEnabled as T, parseAllowedApprovalsReviewersFromCodexRequirements as _, resolveCodexAppServerStartOptionsForAgent as a, selectGuardianApprovalPolicy as b, assertCodexAppServerConnectionSecurity as c, shouldAutoApproveCodexAppServerApprovals as d, withMcpElicitationsApprovalPolicy as f, parseAllowedApprovalPoliciesFromCodexRequirements as g, resolveCodexModelBackedReviewerPolicyContext as h, resolveCodexAppServerRuntimeOptions as i, normalizeCodexServiceTier as j, selectGuardianSandbox as k, hasCodexMcpToolApprovalOverrides as l, canUseCodexModelBackedApprovalsReviewerForModel as m, codexSandboxPolicyForTurn as n, resolveCodexComputerUseConfig as o, assertCodexModelBackedReviewerEffectiveConfig as p, resolveCodexAppServerHomeScope as r, resolveCodexSupervisionAppServerRuntimeOptions as s, codexAppServerStartOptionsKey as t, resolveCodexAppServerNetworkProxy as u, parseAllowedSandboxModesFromCodexRequirements as v, isCodexRemoteExecPlacementSandbox as w, selectGuardianApprovalsReviewer as x, readCodexRequirementsToml as y };
@@ -20,7 +20,10 @@ async function persistCodexContextCompactionActivity(params) {
20
20
  itemId: params.itemId,
21
21
  ...params.runId ? { runId: params.runId } : {}
22
22
  },
23
- ...params.runId ? { __openclaw: { runId: params.runId } } : {},
23
+ __openclaw: {
24
+ itemId: params.itemId,
25
+ ...params.runId ? { runId: params.runId } : {}
26
+ },
24
27
  timestamp: params.timestamp,
25
28
  idempotencyKey: activityId
26
29
  };
@@ -2,13 +2,13 @@ import { n as CODEX_APP_SERVER_BINDING_NAMESPACE, t as CODEX_APP_SERVER_BINDING_
2
2
  import { asNullableRecord, asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
+ import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
5
6
  import { createHash } from "node:crypto";
6
7
  import { isDeepStrictEqual } from "node:util";
7
8
  import { pathExists } from "openclaw/plugin-sdk/security-runtime";
8
9
  import { listAgentIds, resolveAgentDir, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
9
10
  import { setImmediate } from "node:timers/promises";
10
11
  import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
11
- import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
12
12
  import { withFileLock } from "openclaw/plugin-sdk/file-lock";
13
13
  import { archiveLegacyStateSource, legacyStateFileExists } from "openclaw/plugin-sdk/runtime-doctor-migrations";
14
14
  //#region extensions/codex/src/migration/session-binding-orphans.ts
@@ -392,7 +392,7 @@ async function migrateSource(source, candidates, params, store) {
392
392
  return await withFileLock(source.sidecarPath, LEGACY_BINDING_LOCK_OPTIONS, async () => {
393
393
  const [contents, stat] = await Promise.all([fs.readFile(source.sidecarPath, "utf8"), fs.stat(source.sidecarPath)]);
394
394
  const raw = JSON.parse(contents);
395
- const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-D0zinCP1.js").then((n) => n.f), import("./conversation-binding-data-BiodpIzq.js").then((n) => n.t)]);
395
+ const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-BHuTCRZQ.js").then((n) => n.f), import("./conversation-binding-data-BiodpIzq.js").then((n) => n.t)]);
396
396
  const agentId = owner?.agentId ?? (source.agentIds.size === 1 ? [...source.agentIds][0] : void 0);
397
397
  const baseStored = createStoredCodexAppServerBinding(raw, {
398
398
  now: stat.mtime.toISOString(),
@@ -640,6 +640,15 @@ function hasRetiredApprovalPolicy(value) {
640
640
  const approvalPolicy = asNullableRecord(value)?.approvalPolicy;
641
641
  return approvalPolicy === "on-failure" || approvalPolicy === "untrusted";
642
642
  }
643
+ const RETIRED_TURN_IDLE_TIMEOUT_KEYS = [
644
+ "turnCompletionIdleTimeoutMs",
645
+ "turnAssistantCompletionIdleTimeoutMs",
646
+ "postToolRawAssistantCompletionIdleTimeoutMs"
647
+ ];
648
+ function hasRetiredTurnIdleTimeout(value) {
649
+ const appServer = asNullableRecord(value);
650
+ return appServer !== null && RETIRED_TURN_IDLE_TIMEOUT_KEYS.some((key) => Object.hasOwn(appServer, key));
651
+ }
643
652
  /** Legacy Codex config keys that doctor should report or repair. */
644
653
  const legacyConfigRules = [
645
654
  {
@@ -673,6 +682,17 @@ const legacyConfigRules = [
673
682
  ],
674
683
  message: "plugins.entries.codex.config.appServer.approvalPolicy values \"on-failure\" and \"untrusted\" are retired; use \"on-request\". Run \"openclaw doctor --fix\".",
675
684
  match: hasRetiredApprovalPolicy
685
+ },
686
+ {
687
+ path: [
688
+ "plugins",
689
+ "entries",
690
+ "codex",
691
+ "config",
692
+ "appServer"
693
+ ],
694
+ message: "Codex app-server turn idle timeouts are retired; native Codex owns provider liveness and turn completion. The existing agents.defaults.timeoutSeconds run limit remains unchanged. Run \"openclaw doctor --fix\" to remove the old settings.",
695
+ match: hasRetiredTurnIdleTimeout
676
696
  }
677
697
  ];
678
698
  /**
@@ -686,7 +706,8 @@ function normalizeCompatibilityConfig({ cfg }) {
686
706
  const shouldRemoveDynamicToolsProfile = rawPluginConfig !== null && hasRetiredDynamicToolsProfile(rawPluginConfig);
687
707
  const shouldRewriteDestructivePolicy = hasLegacyPluginDestructivePolicy(rawCodexPlugins);
688
708
  const shouldRewriteApprovalPolicy = hasRetiredApprovalPolicy(rawAppServer);
689
- if (!rawPluginConfig || !shouldRemoveDynamicToolsProfile && !shouldRewriteDestructivePolicy && !shouldRewriteApprovalPolicy) return {
709
+ const shouldRemoveTurnIdleTimeouts = hasRetiredTurnIdleTimeout(rawAppServer);
710
+ if (!rawPluginConfig || !shouldRemoveDynamicToolsProfile && !shouldRewriteDestructivePolicy && !shouldRewriteApprovalPolicy && !shouldRemoveTurnIdleTimeouts) return {
690
711
  config: cfg,
691
712
  changes: []
692
713
  };
@@ -714,8 +735,14 @@ function normalizeCompatibilityConfig({ cfg }) {
714
735
  }
715
736
  changes.push("Renamed plugins.entries.codex.config.codexPlugins allow_destructive_actions=\"on-request\" values to \"auto\".");
716
737
  }
738
+ const nextAppServer = asNullableRecord(nextPluginConfig.appServer);
739
+ if (nextAppServer && shouldRemoveTurnIdleTimeouts) {
740
+ for (const key of RETIRED_TURN_IDLE_TIMEOUT_KEYS) if (Object.hasOwn(nextAppServer, key)) {
741
+ delete nextAppServer[key];
742
+ changes.push(`Removed retired plugins.entries.codex.config.appServer.${key}; native Codex owns provider liveness and turn completion. agents.defaults.timeoutSeconds was not changed.`);
743
+ }
744
+ }
717
745
  if (shouldRewriteApprovalPolicy) {
718
- const nextAppServer = asNullableRecord(nextPluginConfig.appServer);
719
746
  if (nextAppServer?.approvalPolicy === "on-failure" || nextAppServer?.approvalPolicy === "untrusted") nextAppServer.approvalPolicy = "on-request";
720
747
  changes.push("Renamed retired plugins.entries.codex.config.appServer.approvalPolicy to \"on-request\".");
721
748
  }