@openclaw/codex 2026.9.3 → 2026.9.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.
Files changed (97) hide show
  1. package/dist/api.js +26 -18
  2. package/dist/{apply-B6el6hdO.js → apply-CvT8tW5i.js} +11 -12
  3. package/dist/{attempt-client-cleanup-D6cR54TV.js → attempt-client-cleanup-DKHzbwt5.js} +8 -204
  4. package/dist/{attempt-context-AO4DSjE0.js → attempt-context-D44yeDII.js} +3 -3
  5. package/dist/{attempt-notifications--H8zXR5-.js → attempt-notifications-C9XufG6l.js} +1 -1
  6. package/dist/{auth-binding-Co2Vfcf_.js → auth-binding-CWlKVccJ.js} +1 -1
  7. package/dist/{auth-cache-key-Kq6oerr6.js → auth-cache-key-7orQae_j.js} +2 -2
  8. package/dist/{binding-connection-QqgcPCgk.js → binding-connection-D3udKbIE.js} +3 -3
  9. package/dist/{bounded-turn-lRpmZHFv.js → bounded-turn-C_Hneydj.js} +12 -12
  10. package/dist/{build-state-6RL6qohz.js → build-state-BCmg9-5p.js} +1 -1
  11. package/dist/{capabilities-BeqLPbtM.js → capabilities-8vx68WLH.js} +1 -1
  12. package/dist/cli-metadata.js +1 -1
  13. package/dist/{client-BEKu4yDx.js → client-B57KWPQx.js} +27 -5
  14. package/dist/{command-dispatch-CisT9Jqq.js → command-dispatch-BpduNGVf.js} +3 -3
  15. package/dist/{command-formatters-DeTfrapr.js → command-formatters-lxlkNZgU.js} +4 -3
  16. package/dist/{command-handlers-BfIsJEuA.js → command-handlers-tiL9iWj7.js} +783 -140
  17. package/dist/{command-rpc-BMqRQOFX.js → command-rpc-CR5EOEZX.js} +26 -19
  18. package/dist/{compact-CGJZ2rlb.js → compact-B_H3AOd7.js} +14 -14
  19. package/dist/{config-JDfTI4VI.js → config-oIORaQ5T.js} +4 -4
  20. package/dist/{config-options-jnIFvwxD.js → config-options-CXMq1T-C.js} +5 -5
  21. package/dist/{config-runtime-BWf6JLWG.js → config-runtime-D0zGNIHu.js} +1 -1
  22. package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
  23. package/dist/{conversation-binding-CxOlHiix.js → conversation-binding-DsB4-O7U.js} +53 -42
  24. package/dist/{conversation-control-CUCrSIQI.js → conversation-control-CtUu1b3m.js} +8 -8
  25. package/dist/doctor-contract-api.js +1 -1
  26. package/dist/{dynamic-tools-D-JBoaLt.js → dynamic-tools-CmN5RAip.js} +76 -15
  27. package/dist/{effective-mcp-catalog-J_5Ep5Um.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
  28. package/dist/{ephemeral-turn-DSwzP8YY.js → ephemeral-turn-D78_VmzO.js} +5 -5
  29. package/dist/event-projector-items-5VhsECCO.js +200 -0
  30. package/dist/{event-projector-usage-CIyrYYid.js → event-projector-usage-BfXmpOec.js} +1 -1
  31. package/dist/{harness-FR6eQgyO.js → harness-C7rRa7bm.js} +33 -16
  32. package/dist/harness.js +1 -1
  33. package/dist/index.js +39 -84
  34. package/dist/inference-context-Dr_mzvk4.js +94 -0
  35. package/dist/inference-proxy-HGXKUIre.js +311 -0
  36. package/dist/{isolated-completion-DHBefrzg.js → isolated-completion-DWVb5U2J.js} +6 -6
  37. package/dist/{managed-binary-DrjjRRUD.js → managed-binary-D22rNEcR.js} +10 -1
  38. package/dist/media-understanding-provider.js +2 -2
  39. package/dist/migration-provider-api.js +2 -0
  40. package/dist/{model-catalog-B_6M04Wo.js → model-catalog-Dq2n8f_p.js} +6 -6
  41. package/dist/{models-P9k2qAof.js → models-PCKOim-h.js} +3 -3
  42. package/dist/native-subagent-history-DjtPloaU.js +140 -0
  43. package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
  44. package/dist/{native-subagent-monitor-BbCUKRwC.js → native-subagent-monitor-fQ7eIXEf.js} +52 -424
  45. package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
  46. package/dist/{node-cli-sessions-rj0ysJwM.js → node-cli-sessions-DKaOmVUh.js} +1 -1
  47. package/dist/{node-exec-server.runtime-BY_ctYnT.js → node-exec-server.runtime-Cl2vapEi.js} +3 -3
  48. package/dist/{plan-BMJdMOEF.js → plan-7uG-Fp36.js} +288 -52
  49. package/dist/{plugin-activation-BQK-f5sV.js → plugin-activation-BYQculil.js} +24 -19
  50. package/dist/{plugin-app-cache-key-CdSQzWyX.js → plugin-app-cache-key-d0eKxy7b.js} +1 -1
  51. package/dist/{plugin-approval-roundtrip-DeW95wB5.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
  52. package/dist/{plugin-inventory-CoRCzWW4.js → plugin-inventory-oL4Na1ZG.js} +7 -4
  53. package/dist/{plugin-marketplace-discovery-3akBizzF.js → plugin-marketplace-discovery-P-Vndfqq.js} +18 -15
  54. package/dist/{plugin-metadata-cache-DgNfRAGA.js → plugin-metadata-cache-ClPJpRio.js} +13 -9
  55. package/dist/{protocol-CAAcVIKF.js → protocol-5bh1G-H7.js} +1 -1
  56. package/dist/provider-MQ8PVkuE.js +50 -0
  57. package/dist/{provider-capabilities-W4tfK5Y5.js → provider-capabilities-BvCUL69A.js} +2 -2
  58. package/dist/{rate-limits-Bqnx1N4z.js → rate-limits-CBMmWBr9.js} +1 -1
  59. package/dist/{request-CGvGOpeR.js → request-B7hEkBGq.js} +72 -58
  60. package/dist/rpc-error-ttN_QjEm.js +30 -0
  61. package/dist/{run-attempt-DwKds3DN.js → run-attempt-CvsAAGa0.js} +108 -37
  62. package/dist/{runtime-artifact-T-NwqeSH.js → runtime-artifact-BJ0rXBZ_.js} +1 -1
  63. package/dist/{sandbox-guard-BcT66fWy.js → sandbox-guard-BxgyoM8M.js} +2 -1
  64. package/dist/{session-binding-CKSepwIC.js → session-binding-CI8UuilT.js} +3 -3
  65. package/dist/{session-binding-record-CaZjYwNS.js → session-binding-record-Bcvslnhf.js} +1 -1
  66. package/dist/{session-catalog-adoption-BKLtSrwi.js → session-catalog-adoption-tcZi1IfX.js} +5 -5
  67. package/dist/{session-catalog-archive-D0i2pGj2.js → session-catalog-archive-CwKg8Xz2.js} +6 -6
  68. package/dist/{session-catalog-HaDcp7Sv.js → session-catalog-ct-AH01I.js} +31 -87
  69. package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
  70. package/dist/{session-catalog-node-adoption-BUuDYY8R.js → session-catalog-node-adoption-B1tgDW-m.js} +2 -2
  71. package/dist/{session-catalog-node-continue-CBtc4wkI.js → session-catalog-node-continue-Ci-DXyJP.js} +4 -4
  72. package/dist/{session-catalog-provenance-DkJHo735.js → session-catalog-provenance-D-dIfRAH.js} +2 -30
  73. package/dist/{session-cli-CbgaHh0f.js → session-cli-DNN_jhGc.js} +2 -2
  74. package/dist/{session-history-import-DFN7sWRU.js → session-history-import-DwyijFI6.js} +4 -4
  75. package/dist/session-history-worker-runtime.js +1 -1
  76. package/dist/{session-history.worker-CNEvGaU5.js → session-history.worker-BeK1YOyT.js} +187 -83
  77. package/dist/session-history.worker.js +1 -1
  78. package/dist/{session-initialization-Jo86C60I.js → session-initialization-Ct0_Hzmg.js} +2 -2
  79. package/dist/{session-permission-policy-B22InTp_.js → session-permission-policy-BBmXA8Eg.js} +2 -2
  80. package/dist/{session-retirement-BSNG_mhf.js → session-retirement-B2YfbAAT.js} +5 -5
  81. package/dist/{settled-turn-finalizer-BuLUrZl2.js → settled-turn-finalizer-Dn91stmc.js} +5 -5
  82. package/dist/{shared-client-CVhez2Uo.js → shared-client-CscigXXL.js} +228 -30
  83. package/dist/{side-question-DLbr2vUU.js → side-question-BGMJQf4U.js} +18 -18
  84. package/dist/{source-Da-h6f7e.js → source-CElXU0Oy.js} +12 -12
  85. package/dist/{thread-archive-guard-D1bP04Tf.js → thread-archive-guard-DfpBr-Sz.js} +1 -1
  86. package/dist/{session-catalog-parsing-CdD3JhdM.js → thread-history-page-D0JIp48V.js} +83 -2
  87. package/dist/{thread-lifecycle-D1pzRwHB.js → thread-lifecycle-DXl1-I6b.js} +96 -44
  88. package/dist/{thread-ownership-D6oASVRu.js → thread-ownership-BsDRTsyp.js} +2 -2
  89. package/dist/{thread-policy-D8kI7yAO.js → thread-policy-BuEQfE0g.js} +3 -3
  90. package/dist/{thread-resume-T5cveyxA.js → thread-resume-DsDOZpFg.js} +5 -5
  91. package/dist/{session-catalog-home-id-D7-aLiNt.js → transcript-history-projection-v17wXgdK.js} +66 -18
  92. package/dist/{transcript-mirror-t5TOccct.js → transcript-mirror-C5CKgNy6.js} +1 -1
  93. package/dist/{upstream-session-fork-De-sLJ2r.js → upstream-session-fork-BZerMte_.js} +20 -20
  94. package/dist/{usage-CPPTmBvZ.js → usage-tCk-mg_x.js} +4 -4
  95. package/dist/{web-search-provider.runtime-CSVgQL0w.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
  96. package/openclaw.plugin.json +1 -0
  97. package/package.json +4 -4
@@ -1,16 +1,16 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { t as codexBuildSymbol } from "./build-state-6RL6qohz.js";
2
+ import { n as defineCodexBuildState, t as codexBuildSymbol } from "./build-state-BCmg9-5p.js";
3
3
  import { t as CODEX_APP_SERVER_AUTH_PROVIDER } from "./auth-profile-selection-DFu9e167.js";
4
- import { a as resolveCodexAppServerStartOptionsForAgent, o as resolveCodexComputerUseConfig, t as codexAppServerStartOptionsKey } from "./config-options-jnIFvwxD.js";
5
- import { c as resolveCodexAppServerLocalHomeDir, l as resolveCodexAppServerUserHomeDir, o as isJsonObject, s as resolveCodexAppServerHomeDir, u as withEphemeralCodexAuthStore } from "./protocol-CAAcVIKF.js";
4
+ import { a as resolveCodexAppServerStartOptionsForAgent, g as readCodexEffectiveConfig, h as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES, o as resolveCodexComputerUseConfig, t as codexAppServerStartOptionsKey } from "./config-options-CXMq1T-C.js";
5
+ import { c as resolveCodexAppServerLocalHomeDir, l as resolveCodexAppServerUserHomeDir, o as isJsonObject, s as resolveCodexAppServerHomeDir, u as withEphemeralCodexAuthStore } from "./protocol-5bh1G-H7.js";
6
6
  import { t as isCodexAppServerProxyLaunch } from "./launch-args-RXQwn8zV.js";
7
- import { f as isUnsupportedCodexAppServerVersionError, t as CodexAppServerClient } from "./client-BEKu4yDx.js";
8
- import { c as resolveMacOSDesktopCodexBundledMarketplaceCandidates, l as resolveMacOSDesktopCodexComputerUseServiceAppCandidates, n as resolveManagedCodexAppServerStartOptions, o as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, r as resolveManagedCodexNativeCommand, s as resolveMacOSDesktopCodexAppPathCandidates, t as isManagedCodexDesktopCommand } from "./managed-binary-DrjjRRUD.js";
9
- import { _ as isCodexDesktopGenerationCurrent, a as readCodexCliAuthFileApiKey, c as resolveCodexAppServerPreparedApiKeyCacheKey, d as createCodexAppServerStartupLifetime, f as getCurrentSharedClientEntry, i as fingerprintTokenAuthProfileCacheKey, l as closeRetiredSharedClientEntry, m as retireSharedCodexAppServerClientIfCurrent, n as CODEX_AUTH_JSON_FILENAME, o as readFirstNonEmptyEnv, p as getSharedCodexAppServerClientState, r as fingerprintApiKeyAuthProfileCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey, t as CODEX_APP_SERVER_API_KEY_ENV_VARS, u as closeRetiredSharedClientEntryIfIdle, v as waitForCodexDesktopGeneration } from "./auth-cache-key-Kq6oerr6.js";
7
+ import { f as isUnsupportedCodexAppServerVersionError, t as CodexAppServerClient } from "./client-B57KWPQx.js";
8
+ import { c as resolveMacOSDesktopCodexAppPathCandidates, i as resolveManagedCodexNativeCommand, l as resolveMacOSDesktopCodexBundledMarketplaceCandidates, r as resolveManagedCodexAppServerStartOptions, s as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, t as isManagedCodexDesktopCommand, u as resolveMacOSDesktopCodexComputerUseServiceAppCandidates } from "./managed-binary-D22rNEcR.js";
9
+ import { _ as isCodexDesktopGenerationCurrent, a as readCodexCliAuthFileApiKey, c as resolveCodexAppServerPreparedApiKeyCacheKey, d as createCodexAppServerStartupLifetime, f as getCurrentSharedClientEntry, i as fingerprintTokenAuthProfileCacheKey, l as closeRetiredSharedClientEntry, m as retireSharedCodexAppServerClientIfCurrent, n as CODEX_AUTH_JSON_FILENAME, o as readFirstNonEmptyEnv, p as getSharedCodexAppServerClientState, r as fingerprintApiKeyAuthProfileCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey, t as CODEX_APP_SERVER_API_KEY_ENV_VARS, u as closeRetiredSharedClientEntryIfIdle, v as waitForCodexDesktopGeneration } from "./auth-cache-key-7orQae_j.js";
10
10
  import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-BGjHoYLr.js";
11
- import { n as readCodexSessionMeta } from "./session-catalog-provenance-DkJHo735.js";
12
11
  import { n as withTimeout } from "./timeout-BVw8aaM1.js";
13
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BWf6JLWG.js";
12
+ import { n as readCodexSessionMeta } from "./session-catalog-provenance-D-dIfRAH.js";
13
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-D0zGNIHu.js";
14
14
  import { a as resolveCodexAppServerAuthProfileStore, i as resolveCodexAppServerAuthProfileIdForAgent, r as resolveCodexAppServerAuthProfileId, t as isCodexAppServerNativeAuthProfile } from "./auth-profile-CwzO4_RG.js";
15
15
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
16
16
  import { createHash } from "node:crypto";
@@ -22,10 +22,9 @@ import path from "node:path";
22
22
  import fs$1 from "node:fs/promises";
23
23
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
24
24
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
25
- import { isDeepStrictEqual } from "node:util";
26
- import { ensureAuthProfileStore, findPersistedAuthProfileCredential, loadAuthProfileStoreForSecretsRuntime, refreshOAuthCredentialForRuntime, resolveApiKeyForProfile, resolvePersistedAuthProfileOwnerAgentDir } from "openclaw/plugin-sdk/agent-runtime";
25
+ import { ensureAuthProfileStore, findPersistedAuthProfileCredential, refreshOAuthCredentialForRuntime, resolveApiKeyForProfile, resolvePersistedAuthProfileOwnerAgentDir } from "openclaw/plugin-sdk/agent-runtime";
27
26
  import { AgentHarnessPreflightError as AgentHarnessPreflightError$1, embeddedAgentLog as embeddedAgentLog$1, formatErrorMessage } from "openclaw/plugin-sdk/agent-harness-runtime";
28
- import { resolveProviderIdForAuth } from "openclaw/plugin-sdk/provider-auth-aliases";
27
+ import { isDeepStrictEqual } from "node:util";
29
28
  import { assertNoSymlinkParents } from "openclaw/plugin-sdk/security-runtime";
30
29
  import { hasUsableOAuthCredential, resolveOpenAICodexAuthIdentity } from "openclaw/plugin-sdk/provider-auth";
31
30
  //#region extensions/codex/src/app-server/computer-use-service-path.ts
@@ -1131,7 +1130,16 @@ async function applyCodexAppServerAuthProfile(params) {
1131
1130
  assertCurrent: params.assertCurrent
1132
1131
  });
1133
1132
  }
1134
- if (loginParams) await params.client.request("account/login/start", loginParams, { assertCurrent: params.assertCurrent });
1133
+ if (loginParams) {
1134
+ await params.client.request("account/login/start", loginParams, { assertCurrent: params.assertCurrent });
1135
+ if (loginParams.type === "chatgptAuthTokens") {
1136
+ params.assertCurrent?.();
1137
+ return {
1138
+ accessFingerprint: fingerprintTokenAuthProfileCacheKey(loginParams.accessToken),
1139
+ chatgptAccountId: loginParams.chatgptAccountId
1140
+ };
1141
+ }
1142
+ }
1135
1143
  }
1136
1144
  /**
1137
1145
  * Native-home connections are verified, never logged into. Both directions of the
@@ -1178,6 +1186,8 @@ async function resolveCodexAppServerAuthProfileLoginParams(params) {
1178
1186
  }
1179
1187
  async function refreshCodexAppServerAuthTokens(params) {
1180
1188
  const previousAccountId = params.previousAccountId?.trim();
1189
+ const handoffAccountId = params.authHandoff?.chatgptAccountId.trim();
1190
+ if (previousAccountId && handoffAccountId && previousAccountId !== handoffAccountId) throw new Error("ChatGPT workspace changed before Codex token refresh. Retry to start a client for the selected workspace.");
1181
1191
  if (previousAccountId) {
1182
1192
  const store = resolveCodexAppServerAuthProfileStore(params);
1183
1193
  const profileId = resolveCodexAppServerAuthProfileId({
@@ -1195,6 +1205,7 @@ async function refreshCodexAppServerAuthTokens(params) {
1195
1205
  });
1196
1206
  if (!loginParams || loginParams.type !== "chatgptAuthTokens") throw new Error("Codex app-server ChatGPT token refresh requires an OAuth auth profile. Sign in with `openclaw models auth login --provider openai`, select that profile, then retry.");
1197
1207
  if (previousAccountId && loginParams.chatgptAccountId !== previousAccountId) throw new Error("ChatGPT workspace changed during Codex token refresh. Retry to start a client for the selected workspace.");
1208
+ if (params.authHandoff && loginParams.chatgptAccountId !== params.authHandoff.chatgptAccountId) throw new Error("ChatGPT workspace changed during Codex token refresh. Retry to start a client for the selected workspace.");
1198
1209
  return {
1199
1210
  accessToken: loginParams.accessToken,
1200
1211
  chatgptAccountId: loginParams.chatgptAccountId,
@@ -1222,6 +1233,8 @@ async function resolveCodexAppServerAuthProfileLoginParamsInternal(params) {
1222
1233
  store,
1223
1234
  preferStoreCredential: Boolean(params.authProfileStore?.profiles[profileId]),
1224
1235
  forceOAuthRefresh: params.forceOAuthRefresh === true,
1236
+ authHandoff: params.authHandoff,
1237
+ previousAccountId: params.previousAccountId,
1225
1238
  config: params.config
1226
1239
  });
1227
1240
  if (!loginParams) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" does not contain usable credentials. Repair or replace the selected OpenAI credential, then retry.`);
@@ -1268,6 +1281,8 @@ async function resolveLoginParamsForCredential(profileId, credential, params) {
1268
1281
  store: params.store,
1269
1282
  preferStoreCredential: params.preferStoreCredential,
1270
1283
  forceRefresh: params.forceOAuthRefresh,
1284
+ authHandoff: params.authHandoff,
1285
+ previousAccountId: params.previousAccountId,
1271
1286
  config: params.config
1272
1287
  });
1273
1288
  const accessToken = resolvedCredential.access?.trim();
@@ -1286,9 +1301,9 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1286
1301
  store: params.store,
1287
1302
  profileId,
1288
1303
  persistedCredential,
1289
- suppliedCredential: credential,
1290
- config: params.config
1304
+ suppliedCredential: credential
1291
1305
  });
1306
+ if (params.preferStoreCredential && params.store.runtimePersistedProfileIds?.includes(profileId) && (persistedCredential?.type !== "oauth" || !isCodexAppServerAuthProvider(persistedCredential.provider))) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" is no longer available. Sign in again with OpenClaw, then retry.`);
1292
1307
  const store = useScopedCredential ? params.store : resolveCodexAppServerAuthProfileStore({
1293
1308
  agentDir: ownerAgentDir,
1294
1309
  authProfileId: profileId,
@@ -1297,15 +1312,28 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1297
1312
  const persistedOAuthCredential = !useScopedCredential && persistedCredential?.type === "oauth" && isCodexAppServerAuthProvider(persistedCredential.provider) ? persistedCredential : void 0;
1298
1313
  const ownerCredential = store.profiles[profileId];
1299
1314
  const overlaidOAuthCredential = ownerCredential?.type === "oauth" && isCodexAppServerAuthProvider(ownerCredential.provider) ? ownerCredential : void 0;
1315
+ const currentCredential = useScopedCredential || !persistedOAuthCredential ? overlaidOAuthCredential : persistedOAuthCredential;
1316
+ const reuseCompletedRotation = params.forceRefresh && (Boolean(persistedOAuthCredential) || params.preferStoreCredential) && shouldReuseCompletedCodexOAuthRotation({
1317
+ credential: currentCredential,
1318
+ authHandoff: params.authHandoff,
1319
+ previousAccountId: params.previousAccountId
1320
+ });
1321
+ const selectedAccountId = currentCredential ? resolveOpenAICodexAuthIdentity(currentCredential).accountId?.trim() : void 0;
1322
+ const callbackAccountId = params.authHandoff?.chatgptAccountId.trim() ?? params.previousAccountId?.trim() ?? void 0;
1323
+ if (callbackAccountId && selectedAccountId && callbackAccountId !== selectedAccountId) throw new Error("ChatGPT workspace changed before Codex token refresh. Retry to start a client for the selected workspace.");
1324
+ const expectedAccountId = callbackAccountId ?? selectedAccountId;
1300
1325
  if (useScopedCredential && overlaidOAuthCredential) return await resolveScopedOAuthCredential({
1301
1326
  store,
1302
1327
  profileId,
1303
1328
  credential: overlaidOAuthCredential,
1304
- forceRefresh: params.forceRefresh
1329
+ forceRefresh: params.forceRefresh && !reuseCompletedRotation,
1330
+ expectedAccountId
1305
1331
  });
1306
1332
  if (params.forceRefresh && !persistedOAuthCredential && overlaidOAuthCredential) {
1333
+ if (reuseCompletedRotation) return overlaidOAuthCredential;
1307
1334
  const refreshedRuntimeCredential = await refreshOAuthCredentialForRuntime({ credential: overlaidOAuthCredential });
1308
1335
  if (!refreshedRuntimeCredential?.access?.trim()) throw new Error(`Codex app-server auth profile "${profileId}" could not refresh. Sign in again with OpenClaw, then retry.`);
1336
+ assertCodexOAuthRefreshWorkspace(profileId, refreshedRuntimeCredential, expectedAccountId);
1309
1337
  store.profiles[profileId] = refreshedRuntimeCredential;
1310
1338
  return refreshedRuntimeCredential;
1311
1339
  }
@@ -1313,23 +1341,30 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1313
1341
  store,
1314
1342
  profileId,
1315
1343
  agentDir: ownerAgentDir,
1316
- forceRefresh: params.forceRefresh && Boolean(persistedOAuthCredential)
1344
+ forceRefresh: params.forceRefresh && Boolean(persistedOAuthCredential) && !reuseCompletedRotation,
1345
+ allowProfileFallback: false,
1346
+ ...expectedAccountId ? { validateOAuthCredential: (candidate) => assertCodexOAuthRefreshWorkspace(profileId, candidate, expectedAccountId) } : {}
1317
1347
  });
1318
- const refreshed = useScopedCredential ? void 0 : loadAuthProfileStoreForSecretsRuntime(ownerAgentDir, { profileId }).profiles[profileId];
1319
- const refreshedOAuthCredential = refreshed?.type === "oauth" && isCodexAppServerAuthProvider(refreshed.provider) ? refreshed : void 0;
1320
- if (refreshedOAuthCredential && isDeepStrictEqual(params.store.profiles[profileId], credential)) params.store.profiles[profileId] = refreshedOAuthCredential;
1321
- const storedCredential = store.profiles[profileId];
1322
- const candidate = refreshedOAuthCredential ? refreshedOAuthCredential : storedCredential?.type === "oauth" && isCodexAppServerAuthProvider(storedCredential.provider) ? storedCredential : credential;
1323
- return resolved?.apiKey ? {
1324
- ...candidate,
1348
+ if (!resolved || resolved.credential?.type !== "oauth" || !isCodexAppServerAuthProvider(resolved.credential.provider) || !resolved.apiKey.trim()) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" is no longer available. Sign in again with OpenClaw, then retry.`);
1349
+ const candidate = {
1350
+ ...resolved.credential,
1325
1351
  access: resolved.apiKey
1326
- } : candidate;
1352
+ };
1353
+ if (isDeepStrictEqual(params.store.profiles[profileId], credential)) params.store.profiles[profileId] = candidate;
1354
+ return candidate;
1355
+ }
1356
+ function shouldReuseCompletedCodexOAuthRotation(params) {
1357
+ const handoff = params.authHandoff;
1358
+ const credential = params.credential;
1359
+ if (!handoff || !credential || !hasUsableOAuthCredential(credential) || fingerprintTokenAuthProfileCacheKey(credential.access.trim()) === handoff.accessFingerprint) return false;
1360
+ const accountId = resolveOpenAICodexAuthIdentity(credential).accountId?.trim();
1361
+ const previousAccountId = params.previousAccountId?.trim();
1362
+ return accountId === handoff.chatgptAccountId && (!previousAccountId || previousAccountId === handoff.chatgptAccountId);
1327
1363
  }
1328
1364
  function shouldUseScopedOAuthCredential(params) {
1329
1365
  if (!params.store.runtimePersistedProfileIds?.includes(params.profileId)) return true;
1330
1366
  const persisted = params.persistedCredential;
1331
- if (persisted?.type !== "oauth") return true;
1332
- if (resolveProviderIdForAuth(persisted.provider, { config: params.config }) !== resolveProviderIdForAuth(params.suppliedCredential.provider, { config: params.config })) return true;
1367
+ if (persisted?.type !== "oauth" || !isCodexAppServerAuthProvider(persisted.provider)) return false;
1333
1368
  return !isDeepStrictEqual(persisted, params.suppliedCredential) && !hasMatchingOAuthIdentity(persisted, params.suppliedCredential);
1334
1369
  }
1335
1370
  function hasMatchingOAuthIdentity(persisted, supplied) {
@@ -1342,7 +1377,11 @@ function hasMatchingOAuthIdentity(persisted, supplied) {
1342
1377
  }
1343
1378
  async function resolveScopedOAuthCredential(params) {
1344
1379
  const existingRefresh = scopedOAuthRefreshQueues.get(params.store)?.get(params.profileId);
1345
- if (existingRefresh) return await existingRefresh;
1380
+ if (existingRefresh) {
1381
+ const refreshed = await existingRefresh;
1382
+ assertCodexOAuthRefreshWorkspace(params.profileId, refreshed, params.expectedAccountId);
1383
+ return refreshed;
1384
+ }
1346
1385
  if (!params.forceRefresh && hasUsableOAuthCredential(params.credential)) return params.credential;
1347
1386
  const storeRefreshes = scopedOAuthRefreshQueues.get(params.store) ?? /* @__PURE__ */ new Map();
1348
1387
  scopedOAuthRefreshQueues.set(params.store, storeRefreshes);
@@ -1352,6 +1391,7 @@ async function resolveScopedOAuthCredential(params) {
1352
1391
  if (!params.forceRefresh && hasUsableOAuthCredential(credential)) return credential;
1353
1392
  const refreshed = await refreshOAuthCredentialForRuntime({ credential });
1354
1393
  if (!refreshed?.access?.trim()) throw new Error(`Codex app-server auth profile "${params.profileId}" could not refresh. Sign in again with OpenClaw, then retry.`);
1394
+ assertCodexOAuthRefreshWorkspace(params.profileId, refreshed, params.expectedAccountId);
1355
1395
  if (!isDeepStrictEqual(params.store.profiles[params.profileId], credential)) throw new Error(`Codex app-server auth profile "${params.profileId}" changed while refreshing. Retry with the newly selected OpenAI profile.`);
1356
1396
  params.store.profiles[params.profileId] = refreshed;
1357
1397
  return refreshed;
@@ -1363,6 +1403,11 @@ async function resolveScopedOAuthCredential(params) {
1363
1403
  if (storeRefreshes.get(params.profileId) === refresh) storeRefreshes.delete(params.profileId);
1364
1404
  }
1365
1405
  }
1406
+ function assertCodexOAuthRefreshWorkspace(profileId, credential, expectedAccountId) {
1407
+ if (!expectedAccountId) return;
1408
+ const loginParams = buildChatgptAuthTokensParams(profileId, credential, credential.access.trim());
1409
+ if (loginParams.type !== "chatgptAuthTokens" || loginParams.chatgptAccountId !== expectedAccountId) throw new Error("ChatGPT workspace changed during Codex token refresh. Retry to start a client for the selected workspace.");
1410
+ }
1366
1411
  function isCodexAppServerAuthProvider(provider) {
1367
1412
  return provider.trim().toLowerCase() === CODEX_APP_SERVER_AUTH_PROVIDER;
1368
1413
  }
@@ -1531,6 +1576,10 @@ function isCodexAppServerClientRuntimeLive(client) {
1531
1576
  const runtime = configuredClients.get(client);
1532
1577
  return runtime !== void 0 && !runtime.closed;
1533
1578
  }
1579
+ function recordCodexAppServerAuthHandoff(client, handoff) {
1580
+ const runtime = configuredClients.get(client);
1581
+ if (runtime && !runtime.closed && handoff) runtime.authHandoff = handoff;
1582
+ }
1534
1583
  /** Reference history is only trusted while this native subscription stays warm. */
1535
1584
  function forgetCodexWorkspaceReferences(client, threadId) {
1536
1585
  configuredClients.get(client)?.workspaceReferences.delete(threadId);
@@ -1616,15 +1665,22 @@ function ensureCodexAppServerClientRuntime(client, context) {
1616
1665
  if (request.method !== "account/chatgptAuthTokens/refresh") return;
1617
1666
  if (runtime.context.authMode === "prepared-api-key") throw new Error("ChatGPT token refresh is unavailable for prepared Codex API-key auth.");
1618
1667
  const previousAccountId = isJsonObject(request.params) && typeof request.params.previousAccountId === "string" ? request.params.previousAccountId.trim() || void 0 : void 0;
1668
+ const authHandoff = runtime.authHandoff;
1619
1669
  try {
1620
1670
  const tokens = await withTimeout(refreshCodexAppServerAuthTokens({
1621
1671
  agentDir: runtime.context.agentDir,
1622
1672
  authProfileId: runtime.context.authProfileId,
1673
+ ...authHandoff ? { authHandoff } : {},
1623
1674
  ...previousAccountId ? { previousAccountId } : {},
1624
1675
  ...runtime.context.authProfileStore ? { authProfileStore: runtime.context.authProfileStore } : {},
1625
1676
  config: runtime.context.config
1626
1677
  }), CODEX_EXTERNAL_AUTH_REFRESH_TIMEOUT_MS, "Codex app-server ChatGPT token refresh timed out before its external-auth deadline. Retry the request; if it persists, sign in again with OpenClaw.");
1627
1678
  if (previousAccountId && tokens.chatgptAccountId !== previousAccountId) throw new Error("ChatGPT workspace changed during Codex token refresh. Retry to start a client for the selected workspace.");
1679
+ if (runtime.closed) throw new Error("Codex app-server client closed during ChatGPT token refresh.");
1680
+ runtime.authHandoff = {
1681
+ accessFingerprint: fingerprintTokenAuthProfileCacheKey(tokens.accessToken),
1682
+ chatgptAccountId: tokens.chatgptAccountId
1683
+ };
1628
1684
  return { ...tokens };
1629
1685
  } catch (error) {
1630
1686
  runtime.context.onAuthRefreshFailure?.();
@@ -2005,6 +2061,146 @@ function resolveCodexGatewayTimeoutWithGraceMs(timeoutMs, graceMs = 1e4) {
2005
2061
  return addTimerTimeoutGraceMs(timeout, grace) ?? timeout;
2006
2062
  }
2007
2063
  //#endregion
2064
+ //#region extensions/codex/src/app-server/inference-routing.ts
2065
+ const owners = defineCodexBuildState("openclaw.codexAppServerInferenceOwners", () => /* @__PURE__ */ new WeakMap())();
2066
+ const MAX_ROUTES = 8;
2067
+ const MAX_THREADS = 256;
2068
+ const NATIVE_OPENAI_UPSTREAMS = /* @__PURE__ */ new Set(["https://api.openai.com/v1", "https://chatgpt.com/backend-api/codex"]);
2069
+ /** Only managed native stdio startup calls this; locality or metadata cannot opt a client in. */
2070
+ function ownCodexInferenceClient(client) {
2071
+ if (owners.has(client)) return;
2072
+ const owner = {
2073
+ closed: false,
2074
+ routes: /* @__PURE__ */ new Map(),
2075
+ threads: /* @__PURE__ */ new Map(),
2076
+ handles: /* @__PURE__ */ new Set()
2077
+ };
2078
+ owners.set(client, owner);
2079
+ const close = () => {
2080
+ owner.closed = true;
2081
+ owner.threads.clear();
2082
+ owner.handles.clear();
2083
+ for (const pending of owner.routes.values()) pending.then((route) => route.close(), () => {});
2084
+ owner.routes.clear();
2085
+ };
2086
+ client.addCloseHandler(close);
2087
+ client.addNotificationHandler((notification) => {
2088
+ if (notification.method === "thread/closed" && isJsonObject(notification.params) && typeof notification.params.threadId === "string") owner.threads.delete(notification.params.threadId);
2089
+ if (notification.method !== "account/updated" || !owner.authRoute) return;
2090
+ const mode = isJsonObject(notification.params) ? notification.params.authMode : void 0;
2091
+ if ((mode === "apiKey" ? "apiKey" : mode === "chatgpt" || mode === "chatgptAuthTokens" ? "chatgpt" : void 0) !== owner.authRoute) close();
2092
+ });
2093
+ }
2094
+ async function prepareCodexInferenceRoute(params) {
2095
+ const owner = owners.get(params.client);
2096
+ if (!owner) return;
2097
+ const assertClient = () => {
2098
+ if (owner.closed || owners.get(params.client) !== owner) throw new Error("Codex inference route ownership changed; reconnect before retrying");
2099
+ };
2100
+ const assertCurrent = () => {
2101
+ assertClient();
2102
+ params.signal?.throwIfAborted();
2103
+ params.assertCurrent();
2104
+ };
2105
+ assertCurrent();
2106
+ const snapshot = params.effectiveConfig ?? await readCodexEffectiveConfig(params.client, params.cwd, { signal: params.signal });
2107
+ assertCurrent();
2108
+ if (snapshot.config.model_provider != null && snapshot.config.model_provider !== "openai") return;
2109
+ if (isJsonObject(snapshot.config.features) && snapshot.config.features.respect_system_proxy === true) return;
2110
+ const configured = snapshot.config.openai_base_url;
2111
+ if (configured != null && typeof configured !== "string") throw new Error("Codex inference upstream configuration is invalid");
2112
+ if (configured) {
2113
+ let target;
2114
+ try {
2115
+ target = new URL(configured);
2116
+ } catch {
2117
+ return;
2118
+ }
2119
+ if (!NATIVE_OPENAI_UPSTREAMS.has(target.href.replace(/\/$/, ""))) return;
2120
+ }
2121
+ const origin = snapshot.origins?.openai_base_url;
2122
+ if (origin && !CODEX_SESSION_OVERRIDABLE_LAYER_TYPES.has(origin.name.type)) return;
2123
+ const account = await params.client.request("account/read", { refreshToken: false }, {
2124
+ signal: params.signal,
2125
+ assertCurrent
2126
+ });
2127
+ assertCurrent();
2128
+ const type = isJsonObject(account.account) ? account.account.type : void 0;
2129
+ if (type !== "apiKey" && type !== "chatgpt") return;
2130
+ if (owner.authRoute && owner.authRoute !== type) throw new Error("Codex native account route changed; reconnect before retrying");
2131
+ owner.authRoute = type;
2132
+ const target = new URL(configured || (type === "apiKey" ? "https://api.openai.com/v1" : "https://chatgpt.com/backend-api/codex"));
2133
+ const key = target.toString();
2134
+ let pending = owner.routes.get(key);
2135
+ if (!pending) {
2136
+ if (owner.routes.size >= MAX_ROUTES) throw new Error("Codex inference route limit reached");
2137
+ pending = import("./inference-proxy-HGXKUIre.js").then(({ createCodexInferenceProxy }) => {
2138
+ assertClient();
2139
+ return createCodexInferenceProxy({
2140
+ upstream: target,
2141
+ assertCurrent: assertClient
2142
+ });
2143
+ });
2144
+ owner.routes.set(key, pending);
2145
+ }
2146
+ const route = await pending;
2147
+ assertCurrent();
2148
+ route.assertCurrent();
2149
+ params.client.protectPrivateTransportSecret(new URL(route.baseUrl).pathname.split("/")[1] ?? "");
2150
+ owner.handles.add(route);
2151
+ return route;
2152
+ }
2153
+ /** Prepare a managed thread without changing an attached or unsupported native profile. */
2154
+ async function prepareCodexInferenceThreadConfig(params) {
2155
+ const { binding } = params;
2156
+ if (binding?.connectionScope === "supervision" || binding?.preserveNativeModel === true) return;
2157
+ const route = await prepareCodexInferenceRoute(params);
2158
+ if (!route) return;
2159
+ if (binding?.clientId === params.clientId && !getCodexInferenceThread(params.client, binding.threadId)) {
2160
+ const { thread } = await params.client.request("thread/read", {
2161
+ threadId: binding.threadId,
2162
+ includeTurns: false
2163
+ }, {
2164
+ signal: params.signal,
2165
+ assertCurrent: params.assertCurrent
2166
+ });
2167
+ params.assertCurrent();
2168
+ if (thread.id !== binding.threadId || thread.status?.type !== "notLoaded") throw new Error("Codex loaded thread has no owned inference route; reconnect before retrying");
2169
+ }
2170
+ if (params.config?.openai_base_url !== void 0 && params.config.openai_base_url !== route.upstream) throw new Error("Codex thread configuration conflicts with its trusted inference upstream");
2171
+ return {
2172
+ route,
2173
+ config: {
2174
+ ...params.config,
2175
+ openai_base_url: route.baseUrl
2176
+ }
2177
+ };
2178
+ }
2179
+ /** Validate the exact private handle and unchanged upstream, not a localhost string exception. */
2180
+ function assertCodexInferenceRouteConfig(client, route, config) {
2181
+ if (!route) return;
2182
+ const owner = owners.get(client);
2183
+ if (!owner || owner.closed || !owner.handles.has(route) || config?.openai_base_url !== route.baseUrl) throw new Error("Codex parent-local inference route was overridden; no turn was sent");
2184
+ route.assertCurrent();
2185
+ }
2186
+ function bindCodexInferenceThread(client, threadId, route) {
2187
+ const owner = owners.get(client);
2188
+ if (!owner && !route) return;
2189
+ if (!owner || owner.closed) throw new Error("Codex inference client is closed");
2190
+ if (!route) {
2191
+ owner.threads.delete(threadId);
2192
+ return;
2193
+ }
2194
+ route.assertCurrent();
2195
+ if (!owner.threads.has(threadId) && owner.threads.size >= MAX_THREADS) throw new Error("Codex inference thread limit reached; reconnect before retrying");
2196
+ owner.threads.set(threadId, route);
2197
+ }
2198
+ function getCodexInferenceThread(client, threadId) {
2199
+ const owner = owners.get(client);
2200
+ if (owner?.closed) throw new Error("Codex inference client is closed");
2201
+ return owner?.threads.get(threadId);
2202
+ }
2203
+ //#endregion
2008
2204
  //#region extensions/codex/src/app-server/native-config-fence.ts
2009
2205
  const CODEX_NATIVE_CONFIG_FENCE_STATE = Symbol.for("openclaw.codexNativeConfigFenceState");
2010
2206
  function getFenceState() {
@@ -2609,7 +2805,7 @@ async function startInitializedCodexAppServerClient(params) {
2609
2805
  } finally {
2610
2806
  artifactDrain?.cancel();
2611
2807
  }
2612
- const runtimeArtifactModule = params.runtimeArtifactMode ? await import("./runtime-artifact-T-NwqeSH.js") : void 0;
2808
+ const runtimeArtifactModule = params.runtimeArtifactMode ? await import("./runtime-artifact-BJ0rXBZ_.js") : void 0;
2613
2809
  const runtimeArtifactBeforeStart = runtimeArtifactModule ? await runtimeArtifactModule.captureCodexAppServerRuntimeArtifactBeforeStart({
2614
2810
  startOptions,
2615
2811
  spawnIdentity: resolveCodexAppServerSpawnIdentity(startOptions),
@@ -2671,7 +2867,7 @@ async function startInitializedCodexAppServerClient(params) {
2671
2867
  onAuthRefreshFailure: () => retireSharedCodexAppServerClientIfCurrent(client)
2672
2868
  });
2673
2869
  assertStartupCurrent();
2674
- await waitForStartup(() => applyCodexAppServerAuthProfile({
2870
+ const authHandoff = await waitForStartup(() => applyCodexAppServerAuthProfile({
2675
2871
  client,
2676
2872
  agentDir: params.agentDir,
2677
2873
  authProfileId: params.authProfileId,
@@ -2682,6 +2878,8 @@ async function startInitializedCodexAppServerClient(params) {
2682
2878
  assertCurrent: assertStartupCurrent,
2683
2879
  ...params.authProfileStore ? { authProfileStore: params.authProfileStore } : {}
2684
2880
  }));
2881
+ if (startOptions.transport === "stdio" && nativeCommandAtStart && !desktopGeneration && !isManagedCodexDesktopCommand(startOptions.command) && !isCodexAppServerProxyLaunch(startOptions.args)) ownCodexInferenceClient(client);
2882
+ recordCodexAppServerAuthHandoff(client, authHandoff);
2685
2883
  if (runtimeArtifactModule && runtimeArtifact) runtimeArtifactModule.bindCodexAppServerRuntimeArtifact(client, runtimeArtifact);
2686
2884
  assertStartupCurrent();
2687
2885
  const fenceKey = resolveCodexNativeConfigFenceKey({ client });
@@ -2908,4 +3106,4 @@ function retirePendingSharedClientEntryIfUnclaimed(entry) {
2908
3106
  closeRetiredSharedClientEntry(entry);
2909
3107
  }
2910
3108
  //#endregion
2911
- export { assertNotSymlink as $, resolveCodexGatewayTimeoutWithGraceMs as A, prepareCodexWorkspaceReferences as B, CodexThreadBindingConflictError as C, TURN_FINALIZE_DRAIN_ABORT_GRACE_MS as D, CodexAppServerStartupError as E, ensureCodexAppServerClientRuntime as F, unsubscribeCodexAppServerLiveThread as G, readCodexClientSessionMeta as H, forgetCodexWorkspaceReferences as I, rememberCodexRateLimitsRead as J, readCodexRateLimitsRevision as K, hasCodexAppServerLiveThread as L, withCodexStartupTimeout as M, claimCodexAppServerLiveThread as N, TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS as O, consumeCodexAppServerLiveThread as P, resolveCodexManagedBundledMarketplacePath as Q, isCodexAppServerClientRuntimeLive as R, CodexAdoptedThreadActiveError as S, acquireCodexNativeConfigFence as T, releaseCodexAppServerLiveThread as U, protectCodexAppServerLiveThread as V, retainCodexAppServerLiveThread as W, resolveCodexAppServerAuthAccountCacheKey as X, reconcileCodexComputerUseStartArtifacts as Y, resolveCodexAppServerPreparedAuthHandoff as Z, retainSharedCodexAppServerClientByInstanceId as _, clearSharedCodexAppServerClientIfCurrentAndUnclaimed as a, waitForCodexAppServerClientDesktopGenerationDrain as b, getLeasedSharedCodexAppServerClient as c, readCodexAppServerClientDesktopGeneration as d, readCodexAppServerClientDesktopGenerationFingerprint as f, resolveCodexNativeConfigFenceKey as g, releaseLeasedSharedCodexAppServerClient as h, clearSharedCodexAppServerClientIfCurrent as i, resolveCodexStartupTimeoutMs as j, isCodexAppServerStartupError as k, getSharedCodexAppServerClient as l, releaseCodexAppServerClientLease as m, captureCodexAppServerClientLifetime as n, clearSharedCodexAppServerClientIfCurrentAndWait as o, readCodexAppServerClientProcessIdentity as p, readRecentCodexRateLimits as q, captureSharedCodexAppServerCatalogLifetime as r, createIsolatedCodexAppServerClient as s, assertCodexAppServerClientStartSelectionCurrent as t, isCodexAppServerStartSelectionChangedError as u, retainSharedCodexAppServerClientIfCurrent as v, CodexThreadStartRequestError as w, withLeasedCodexAppServerClientStartSelectionRetry as x, shared_client_exports as y, isCodexAppServerLiveThreadClaimed as z };
3109
+ export { reconcileCodexComputerUseStartArtifacts as $, CodexAppServerStartupError as A, forgetCodexWorkspaceReferences as B, CodexThreadBindingConflictError as C, bindCodexInferenceThread as D, assertCodexInferenceRouteConfig as E, resolveCodexStartupTimeoutMs as F, protectCodexAppServerLiveThread as G, isCodexAppServerClientRuntimeLive as H, withCodexStartupTimeout as I, retainCodexAppServerLiveThread as J, readCodexClientSessionMeta as K, claimCodexAppServerLiveThread as L, TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS as M, isCodexAppServerStartupError as N, getCodexInferenceThread as O, resolveCodexGatewayTimeoutWithGraceMs as P, rememberCodexRateLimitsRead as Q, consumeCodexAppServerLiveThread as R, CodexAdoptedThreadActiveError as S, acquireCodexNativeConfigFence as T, isCodexAppServerLiveThreadClaimed as U, hasCodexAppServerLiveThread as V, prepareCodexWorkspaceReferences as W, readCodexRateLimitsRevision as X, unsubscribeCodexAppServerLiveThread as Y, readRecentCodexRateLimits as Z, retainSharedCodexAppServerClientByInstanceId as _, clearSharedCodexAppServerClientIfCurrentAndUnclaimed as a, waitForCodexAppServerClientDesktopGenerationDrain as b, getLeasedSharedCodexAppServerClient as c, readCodexAppServerClientDesktopGeneration as d, resolveCodexAppServerAuthAccountCacheKey as et, readCodexAppServerClientDesktopGenerationFingerprint as f, resolveCodexNativeConfigFenceKey as g, releaseLeasedSharedCodexAppServerClient as h, clearSharedCodexAppServerClientIfCurrent as i, TURN_FINALIZE_DRAIN_ABORT_GRACE_MS as j, prepareCodexInferenceThreadConfig as k, getSharedCodexAppServerClient as l, releaseCodexAppServerClientLease as m, captureCodexAppServerClientLifetime as n, resolveCodexManagedBundledMarketplacePath as nt, clearSharedCodexAppServerClientIfCurrentAndWait as o, readCodexAppServerClientProcessIdentity as p, releaseCodexAppServerLiveThread as q, captureSharedCodexAppServerCatalogLifetime as r, assertNotSymlink as rt, createIsolatedCodexAppServerClient as s, assertCodexAppServerClientStartSelectionCurrent as t, resolveCodexAppServerPreparedAuthHandoff as tt, isCodexAppServerStartSelectionChangedError as u, retainSharedCodexAppServerClientIfCurrent as v, CodexThreadStartRequestError as w, withLeasedCodexAppServerClientStartSelectionRetry as x, shared_client_exports as y, ensureCodexAppServerClientRuntime as z };
@@ -1,27 +1,27 @@
1
- import { l as sessionBindingIdentity } from "./session-binding-record-CaZjYwNS.js";
2
- import { b as readCodexRequirementsToml, c as hasCodexMcpToolApprovalOverrides, d as withMcpElicitationsApprovalPolicy, i as resolveCodexAppServerHomeScope, m as resolveCodexModelBackedReviewerPolicyContext, u as shouldAutoApproveCodexAppServerApprovals } from "./config-options-jnIFvwxD.js";
3
- import { b as isCodexSandboxExecServerEnabled, o as isJsonObject, v as isCodexPairedNodeRemoteExecPlacementSandbox, x as readCodexPluginConfig, y as isCodexRemoteExecPlacementSandbox } from "./protocol-CAAcVIKF.js";
4
- import { D as handleDynamicToolCallWithTimeout, E as createCodexElicitationResponse, L as resolveCodexToolAbortTerminalReason, S as readCodexDynamicToolCallParams, i as isCodexAppServerApprovalRequest, j as resolveDynamicToolCallTimeoutMs, s as isCodexAppServerIndeterminateRequestCancellationError, v as assertCodexThreadForkResponse, x as assertCodexTurnStartResponse } from "./client-BEKu4yDx.js";
5
- import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-Bqnx1N4z.js";
6
- import { n as resolveOpenClawExecPolicyForCodexAppServer, t as canUseCodexModelBackedApprovalsReviewerForModel } from "./config-JDfTI4VI.js";
7
- import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection } from "./binding-connection-QqgcPCgk.js";
8
- import { F as ensureCodexAppServerClientRuntime, Z as resolveCodexAppServerPreparedAuthHandoff, c as getLeasedSharedCodexAppServerClient, m as releaseCodexAppServerClientLease, q as readRecentCodexRateLimits, x as withLeasedCodexAppServerClientStartSelectionRetry } from "./shared-client-CVhez2Uo.js";
9
- import { d as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, o as interruptCodexTurnAndWaitBestEffort } from "./attempt-client-cleanup-D6cR54TV.js";
10
- import { t as CodexEphemeralTurn } from "./ephemeral-turn-DSwzP8YY.js";
11
- import { B as emitCodexNativePreToolUseFailureDiagnostic, E as resolveCodexAppServerRequestModelSelection, Et as refreshCodexPluginAppApprovalPolicy, I as buildCodexNativeHookRelayConfig, L as buildCodexNativeHookRelayDisabledConfig, N as CODEX_NATIVE_HOOK_RELAY_EVENTS, O as resolveCodexBindingModelProviderFallback, S as resolveCodexWebSearchPlan, T as resolveCodexAppServerModelProvider, Tt as mergeCodexThreadConfigs, a as readCodexSupportedReasoningEfforts, ct as resolveCodexDynamicToolsLoading, nt as filterCodexDynamicTools, o as resolveCodexAppServerReasoningEffort, t as buildCodexTemporalAdditionalContext, v as buildCodexRuntimeThreadConfig, w as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-D1pzRwHB.js";
12
- import { o as resolveCodexSessionBinding } from "./session-binding-CKSepwIC.js";
13
- import { i as refreshCodexThreadPolicy, n as CodexThreadPolicyHandoffError, r as assertCodexSupervisionThreadLineage } from "./thread-policy-D8kI7yAO.js";
14
- import { t as resolveCodexNativeExecutionBlock } from "./sandbox-guard-BcT66fWy.js";
15
- import { C as shouldRequireCodexSandboxExecServerEnvironment, S as shouldEnableCodexAppServerNativeToolSurface, T as filterCodexVisionTools, a as emitDynamicToolStartedDiagnostic, b as resolveCodexNodePlacementToolConstructionPlan, c as ensureCodexSandboxExecServerEnvironment, d as CodexNativeToolLifecycleProjector, i as emitDynamicToolErrorDiagnostic, l as releaseCodexSandboxExecServerEnvironment, o as emitDynamicToolTerminalDiagnostic, r as routeCodexAppServerElicitationRequest, s as handleCodexAppServerApprovalRequest, t as createCodexDynamicToolBridge, v as resolveCodexExternalSandboxPolicyForOpenClawSandbox, x as resolveCodexSandboxEnvironmentSelection, y as resolveCodexMessageToolProvider } from "./dynamic-tools-D-JBoaLt.js";
16
- import { n as resolveCodexProviderWebSearchSupportForClient } from "./provider-capabilities-W4tfK5Y5.js";
17
- import { a as resolveCodexAppServerForModelProvider, i as resolveCodexSessionPermissionCwd, n as applyCodexSessionPermissionPolicy, r as resolveCodexEffectiveSessionPermissionPolicy, t as CODEX_SESSION_PERMISSION_EXEC_MODES } from "./session-permission-policy-B22InTp_.js";
1
+ import { l as sessionBindingIdentity } from "./session-binding-record-Bcvslnhf.js";
2
+ import { b as readCodexRequirementsToml, c as hasCodexMcpToolApprovalOverrides, d as withMcpElicitationsApprovalPolicy, i as resolveCodexAppServerHomeScope, m as resolveCodexModelBackedReviewerPolicyContext, u as shouldAutoApproveCodexAppServerApprovals } from "./config-options-CXMq1T-C.js";
3
+ import { b as isCodexSandboxExecServerEnabled, o as isJsonObject, v as isCodexPairedNodeRemoteExecPlacementSandbox, x as readCodexPluginConfig, y as isCodexRemoteExecPlacementSandbox } from "./protocol-5bh1G-H7.js";
4
+ import { D as handleDynamicToolCallWithTimeout, E as createCodexElicitationResponse, L as resolveCodexToolAbortTerminalReason, S as readCodexDynamicToolCallParams, i as isCodexAppServerApprovalRequest, j as resolveDynamicToolCallTimeoutMs, s as isCodexAppServerIndeterminateRequestCancellationError, v as assertCodexThreadForkResponse, x as assertCodexTurnStartResponse } from "./client-B57KWPQx.js";
5
+ import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-CBMmWBr9.js";
6
+ import { n as resolveOpenClawExecPolicyForCodexAppServer, t as canUseCodexModelBackedApprovalsReviewerForModel } from "./config-oIORaQ5T.js";
7
+ import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection } from "./binding-connection-D3udKbIE.js";
8
+ import { Z as readRecentCodexRateLimits, c as getLeasedSharedCodexAppServerClient, m as releaseCodexAppServerClientLease, tt as resolveCodexAppServerPreparedAuthHandoff, x as withLeasedCodexAppServerClientStartSelectionRetry, z as ensureCodexAppServerClientRuntime } from "./shared-client-CscigXXL.js";
9
+ import { d as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, o as interruptCodexTurnAndWaitBestEffort } from "./attempt-client-cleanup-DKHzbwt5.js";
10
+ import { t as CodexEphemeralTurn } from "./ephemeral-turn-D78_VmzO.js";
11
+ import { C as resolveCodexWebSearchPlan, D as resolveCodexAppServerRequestModelSelection, Dt as refreshCodexPluginAppApprovalPolicy, E as resolveCodexAppServerModelProvider, Et as mergeCodexThreadConfigs, L as buildCodexNativeHookRelayConfig, P as CODEX_NATIVE_HOOK_RELAY_EVENTS, R as buildCodexNativeHookRelayDisabledConfig, T as CODEX_NATIVE_PERSONALITY_NONE, V as emitCodexNativePreToolUseFailureDiagnostic, k as resolveCodexBindingModelProviderFallback, lt as resolveCodexDynamicToolsLoading, n as buildCodexTemporalAdditionalContext, o as readCodexSupportedReasoningEfforts, rt as filterCodexDynamicTools, s as resolveCodexAppServerReasoningEffort, y as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-DXl1-I6b.js";
12
+ import { o as resolveCodexSessionBinding } from "./session-binding-CI8UuilT.js";
13
+ import { i as refreshCodexThreadPolicy, n as CodexThreadPolicyHandoffError, r as assertCodexSupervisionThreadLineage } from "./thread-policy-BuEQfE0g.js";
14
+ import { t as resolveCodexNativeExecutionBlock } from "./sandbox-guard-BxgyoM8M.js";
15
+ import { C as shouldRequireCodexSandboxExecServerEnvironment, S as shouldEnableCodexAppServerNativeToolSurface, T as filterCodexVisionTools, a as emitDynamicToolStartedDiagnostic, b as resolveCodexNodePlacementToolConstructionPlan, c as ensureCodexSandboxExecServerEnvironment, d as CodexNativeToolLifecycleProjector, i as emitDynamicToolErrorDiagnostic, l as releaseCodexSandboxExecServerEnvironment, o as emitDynamicToolTerminalDiagnostic, r as routeCodexAppServerElicitationRequest, s as handleCodexAppServerApprovalRequest, t as createCodexDynamicToolBridge, v as resolveCodexExternalSandboxPolicyForOpenClawSandbox, x as resolveCodexSandboxEnvironmentSelection, y as resolveCodexMessageToolProvider } from "./dynamic-tools-CmN5RAip.js";
16
+ import { n as resolveCodexProviderWebSearchSupportForClient } from "./provider-capabilities-BvCUL69A.js";
17
+ import { a as resolveCodexAppServerForModelProvider, i as resolveCodexSessionPermissionCwd, n as applyCodexSessionPermissionPolicy, r as resolveCodexEffectiveSessionPermissionPolicy, t as CODEX_SESSION_PERMISSION_EXEC_MODES } from "./session-permission-policy-BBmXA8Eg.js";
18
18
  import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
19
19
  import { randomUUID } from "node:crypto";
20
20
  import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
21
- import { isDeepStrictEqual } from "node:util";
22
21
  import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
23
22
  import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir as resolveAgentDir$2, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
24
23
  import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
24
+ import { isDeepStrictEqual } from "node:util";
25
25
  import { loadCodexBundleMcpApprovalConfig, resolveCodexMcpToolOverridesForAgent } from "openclaw/plugin-sdk/codex-mcp-projection";
26
26
  //#region extensions/codex/src/app-server/side-question.ts
27
27
  const SIDE_QUESTION_COMPLETION_TIMEOUT_MS = 6e5;
@@ -1,9 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { m as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-utils-C57JiJrU.js";
3
- import { r as buildCodexPluginAppCacheKey, s as defaultCodexAppInventoryCache } from "./plugin-app-cache-key-CdSQzWyX.js";
4
- import { o as withCodexAppServerJsonClient } from "./request-CGvGOpeR.js";
5
- import "./config-JDfTI4VI.js";
6
- import { i as pluginReadParams, n as isOpenAiCuratedMarketplace } from "./plugin-inventory-CoRCzWW4.js";
2
+ import { c as CODEX_PLUGINS_MARKETPLACE_NAME, i as pluginReadParams, n as isOpenAiCuratedMarketplace } from "./plugin-inventory-oL4Na1ZG.js";
3
+ import { r as buildCodexPluginAppCacheKey, s as defaultCodexAppInventoryCache } from "./plugin-app-cache-key-d0eKxy7b.js";
4
+ import { o as withCodexAppServerJsonClient } from "./request-B7hEkBGq.js";
5
+ import "./config-oIORaQ5T.js";
7
6
  import path from "node:path";
8
7
  import os from "node:os";
9
8
  import fs from "node:fs/promises";
@@ -459,31 +458,32 @@ async function discoverCodexSource(options = {}) {
459
458
  const authPath = path.join(codexHome, "auth.json");
460
459
  const modelsCachePath = path.join(codexHome, "models_cache.json");
461
460
  const hooksPath = path.join(codexHome, "hooks", "hooks.json");
462
- const memoryFiles = await discoverCodexMemorySources(codexHome);
463
- const codexSkills = options.memoryOnly ? [] : await discoverSkillDirs({
461
+ const skipAssets = options.memoryOnly === true || options.authOnly === true;
462
+ const memoryFiles = options.authOnly ? [] : await discoverCodexMemorySources(codexHome);
463
+ const codexSkills = skipAssets ? [] : await discoverSkillDirs({
464
464
  root: codexSkillsDir,
465
465
  sourceLabel: "Codex skill",
466
466
  excludeSystem: true
467
467
  });
468
- const personalAgentSkills = options.memoryOnly ? [] : await discoverSkillDirs({
468
+ const personalAgentSkills = skipAssets ? [] : await discoverSkillDirs({
469
469
  root: agentsSkillsDir,
470
470
  sourceLabel: "personal AgentSkill"
471
471
  });
472
- const sourcePluginDiscovery = options.memoryOnly ? { plugins: [] } : await discoverInstalledCuratedPlugins(codexHome, options);
472
+ const sourcePluginDiscovery = skipAssets ? { plugins: [] } : await discoverInstalledCuratedPlugins(codexHome, options);
473
473
  const sourcePluginNames = new Set(sourcePluginDiscovery.plugins.flatMap((plugin) => plugin.pluginName ? [plugin.pluginName] : []));
474
- const cachedPlugins = (options.memoryOnly ? [] : await discoverPluginDirs(codexHome)).filter((plugin) => {
474
+ const cachedPlugins = (skipAssets ? [] : await discoverPluginDirs(codexHome)).filter((plugin) => {
475
475
  const normalizedName = sanitizePluginName(plugin.name);
476
476
  return !sourcePluginNames.has(normalizedName);
477
477
  });
478
478
  const plugins = [...sourcePluginDiscovery.plugins, ...cachedPlugins].toSorted((a, b) => a.source.localeCompare(b.source));
479
479
  const archivePaths = [];
480
- if (!options.memoryOnly && await exists(configPath)) archivePaths.push({
480
+ if (!skipAssets && await exists(configPath)) archivePaths.push({
481
481
  id: "archive:config.toml",
482
482
  path: configPath,
483
483
  relativePath: "config.toml",
484
484
  message: "Codex config is archived for manual review; it is not activated automatically"
485
485
  });
486
- if (!options.memoryOnly && await exists(hooksPath)) archivePaths.push({
486
+ if (!skipAssets && await exists(hooksPath)) archivePaths.push({
487
487
  id: "archive:hooks/hooks.json",
488
488
  path: hooksPath,
489
489
  relativePath: "hooks/hooks.json",
@@ -1,4 +1,4 @@
1
- import { o as isJsonObject } from "./protocol-CAAcVIKF.js";
1
+ import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
2
2
  import { normalizeBoundedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  //#region extensions/codex/src/app-server/thread-archive-guard.ts
4
4
  const DESCENDANT_PAGE_LIMIT = 100;