@openclaw/codex 2026.10.2 → 2026.10.5-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/.setup/{account-usage-runtime-DPXsyONK.mjs → account-usage-runtime-B6S1BQU7.mjs} +8 -7
  2. package/dist/.setup/{app-server-policy-Bg4FZw1f.mjs → app-server-policy-D_zv8J7V.mjs} +3 -4
  3. package/dist/.setup/{apply-CQ3brq3z.mjs → apply-Cc1DfWPz.mjs} +40 -51
  4. package/dist/.setup/{attempt-client-cleanup-DPUGAWP2.mjs → attempt-client-cleanup-CxX4cTSi.mjs} +6 -6
  5. package/dist/.setup/attempt-terminal-jO5IMj9K.mjs +2 -0
  6. package/dist/.setup/{attempt-workspace-context-GllQy8mw.mjs → attempt-workspace-context-CcwP3DA3.mjs} +21 -18
  7. package/dist/.setup/{auth-binding-BoMwpuPN.mjs → auth-binding-BaxlhaNx.mjs} +2 -2
  8. package/dist/.setup/{auth-cache-key-BE1HXsNo.mjs → auth-cache-key-tENCQOub.mjs} +30 -41
  9. package/dist/.setup/{binding-connection-C-08ez1w.mjs → binding-connection-B7HAAZSI.mjs} +2 -2
  10. package/dist/.setup/{binding-connection.runtime-Dn2p-fdy.mjs → binding-connection.runtime-DAXn7iFl.mjs} +6 -5
  11. package/dist/.setup/{bounded-turn-9YflG60n.mjs → bounded-turn-DxtRqV8t.mjs} +21 -17
  12. package/dist/.setup/{bounded-turn-isolation-DklXNk3k.mjs → bounded-turn-isolation-BfDAo-qZ.mjs} +4 -4
  13. package/dist/.setup/{build-state-LS-A65iX.mjs → build-state-CMYRQ_We.mjs} +1 -1
  14. package/dist/.setup/{capabilities-kQntafj_.mjs → capabilities-DbOzOglY.mjs} +1 -1
  15. package/dist/.setup/{client-catalog-response-BprQziLV.mjs → client-catalog-response-B7oqHQGO.mjs} +25 -32
  16. package/dist/.setup/{client-ChJtGEdJ.mjs → client-zrCKOu_E.mjs} +198 -247
  17. package/dist/.setup/{command-dispatch-BoC9hvFs.mjs → command-dispatch-ImiHvcyW.mjs} +3 -4
  18. package/dist/.setup/{command-formatters-DV3DHhdr.mjs → command-formatters-xW9KpoSZ.mjs} +16 -26
  19. package/dist/.setup/{command-handlers-BVX2quUD.mjs → command-handlers-B8CT4ngS.mjs} +270 -360
  20. package/dist/.setup/{command-rpc-M4gYsRiV.mjs → command-rpc-HtQjCQBg.mjs} +19 -18
  21. package/dist/.setup/{compact-D3JNLG_b.mjs → compact-Do9HPeDr.mjs} +41 -61
  22. package/dist/.setup/{computer-use-CF0jsDi1.mjs → computer-use-CeF5GuCX.mjs} +109 -147
  23. package/dist/.setup/{config-0Gxk3_eq.mjs → config-C1YVVLEA.mjs} +32 -59
  24. package/dist/.setup/config-contracts.shared-D85SGEuq.mjs +4 -0
  25. package/dist/.setup/{config-options-HG_Rr3W_.mjs → config-options-DDzeNQ8m.mjs} +52 -90
  26. package/dist/.setup/{config-parsing-BQq-CHTF.mjs → config-parsing-DsWSCPHO.mjs} +19 -55
  27. package/dist/.setup/{config-runtime-cUYrqu_a.mjs → config-runtime-DWzK-k0n.mjs} +2 -2
  28. package/dist/.setup/{config-security-KAPScztc.mjs → config-security-clxAZYWX.mjs} +35 -39
  29. package/dist/.setup/config-utils-DN_YT7dE.mjs +47 -0
  30. package/dist/.setup/{context-engine-projection-CsgYSQhW.mjs → context-engine-projection-ps-yn_ci.mjs} +10 -22
  31. package/dist/.setup/{conversation-binding-7kceEUf0.mjs → conversation-binding-D78aEdkE.mjs} +85 -119
  32. package/dist/.setup/{conversation-binding-data-DJ4ix-W5.mjs → conversation-binding-data-UgLuTSQT.mjs} +9 -8
  33. package/dist/.setup/{conversation-control-BpJpPo0t.mjs → conversation-control-GXM3unE4.mjs} +7 -10
  34. package/dist/.setup/{cyber-failover-Bb1J6hS1.mjs → cyber-failover-D4dgNfFf.mjs} +2 -5
  35. package/dist/.setup/{cyber-failover-notice-XR03ef31.mjs → cyber-failover-notice-ljgGGL0s.mjs} +1 -1
  36. package/dist/.setup/{doctor-start-options-DPW9JxIE.mjs → doctor-start-options-JjTAl-q_.mjs} +5 -5
  37. package/dist/.setup/{dynamic-tool-build-BCi00feJ.mjs → dynamic-tool-build-BMiiFROa.mjs} +57 -69
  38. package/dist/.setup/{dynamic-tools-DUv6Sr6h.mjs → dynamic-tools-DPPHrGKB.mjs} +680 -709
  39. package/dist/.setup/{effective-mcp-catalog-CIdbHp1t.mjs → effective-mcp-catalog-x3JVEcJp.mjs} +11 -20
  40. package/dist/.setup/{elicitation-input-r9axtppm.mjs → elicitation-input-DXG_qaXr.mjs} +14 -20
  41. package/dist/.setup/{ephemeral-turn-U4th15a6.mjs → ephemeral-turn-Dk0wWoqi.mjs} +3 -3
  42. package/dist/.setup/{event-projector-assistant-message-BwG5TUYW.mjs → event-projector-assistant-message-CLMKN4x-.mjs} +2 -2
  43. package/dist/.setup/{event-projector-usage-03R0I2dM.mjs → event-projector-usage-BpKfdoTm.mjs} +20 -33
  44. package/dist/.setup/{event-projector-values-DTqZHizf.mjs → event-projector-values-CLvG1Hil.mjs} +4 -5
  45. package/dist/.setup/history-rejection-B4nOXNXF.mjs +13 -0
  46. package/dist/.setup/{inference-context-D-9gWlTR.mjs → inference-context-DNlGwzwy.mjs} +10 -11
  47. package/dist/.setup/{inference-dispatch-B5UKEUyC.mjs → inference-dispatch-CO6tTs4q.mjs} +5 -4
  48. package/dist/.setup/{inference-metadata-CgIf7sOx.mjs → inference-metadata-DCvcG_N_.mjs} +36 -41
  49. package/dist/.setup/{inference-proxy-DUO5E2QQ.mjs → inference-proxy-BDWV0djM.mjs} +10 -14
  50. package/dist/.setup/{isolated-completion-C6QKyyDS.mjs → isolated-completion-z0ii1a_V.mjs} +8 -8
  51. package/dist/.setup/local-runtime-attribution-CZz2DJ4q.mjs +15 -0
  52. package/dist/.setup/{managed-binary-C1VFoVPf.mjs → managed-binary-BtIjV7yN.mjs} +16 -36
  53. package/dist/.setup/{mcp-app-session-preparation-JFCtSkRp.mjs → mcp-app-session-preparation-GTx-bRGN.mjs} +24 -25
  54. package/dist/.setup/{mcp-tool-metadata-j10HhfTC.mjs → mcp-tool-metadata-DW41snf3.mjs} +1 -1
  55. package/dist/.setup/{model-catalog-DD-evckc.mjs → model-catalog-VUdFUqnH.mjs} +8 -8
  56. package/dist/.setup/{models-DaW-7tld.mjs → models-Dph0RqpR.mjs} +6 -10
  57. package/dist/.setup/{native-auth-Cjb9y7IZ.mjs → native-auth-esN5MdIv.mjs} +5 -5
  58. package/dist/.setup/{native-execution-policy-ClzpdG3D.mjs → native-execution-policy-MXEe7PB3.mjs} +11 -28
  59. package/dist/.setup/native-hook-relay-CSZpcjwq.mjs +561 -0
  60. package/dist/.setup/{native-mcp-app-ChpyWmL-.mjs → native-mcp-app-CDrrBaTE.mjs} +6 -6
  61. package/dist/.setup/native-skill-isolation-BAatEJZb.mjs +391 -0
  62. package/dist/.setup/{native-subagent-monitor-wh_-K3Vo.mjs → native-subagent-monitor-D5O_o07p.mjs} +505 -639
  63. package/dist/.setup/{native-subagent-pending-assignments-BDqhOdJp.mjs → native-subagent-pending-assignments-DmVhedNs.mjs} +11 -23
  64. package/dist/.setup/{native-task-assignments-C6KVqiN1.mjs → native-task-assignments-DimsQ9Qa.mjs} +73 -27
  65. package/dist/.setup/{node-cli-sessions-B5oNDkUS.mjs → node-cli-sessions-CzKg2nGq.mjs} +18 -26
  66. package/dist/.setup/{node-exec-server.runtime-0xSEjKYt.mjs → node-exec-server.runtime-BWkULhBM.mjs} +5 -8
  67. package/dist/.setup/{plan-CUHSuL6_.mjs → plan-QNW5zpFp.mjs} +40 -50
  68. package/dist/.setup/{plugin-activation-BcyBv8PG.mjs → plugin-activation-D7WkJMvU.mjs} +4 -5
  69. package/dist/.setup/{plugin-app-cache-key-BW8rd98k.mjs → plugin-app-cache-key-Bg9DbDI6.mjs} +18 -23
  70. package/dist/.setup/{plugin-approval-roundtrip-bPQbG8BI.mjs → plugin-approval-roundtrip-DOQ3Tibe.mjs} +4 -6
  71. package/dist/.setup/{plugin-inventory-Bf0_piTw.mjs → plugin-inventory-CYgdo14P.mjs} +28 -43
  72. package/dist/.setup/{plugin-marketplace-discovery-SQPhSuic.mjs → plugin-marketplace-discovery-BblHM3DU.mjs} +7 -10
  73. package/dist/.setup/{plugin-metadata-cache-DWnB7VMj.mjs → plugin-metadata-cache-Bi8TAPwX.mjs} +5 -10
  74. package/dist/.setup/project-doc-thread-config-BVcvnps8.mjs +490 -0
  75. package/dist/.setup/{provider-Ct6-1lsF.mjs → provider-BG5nXBnY.mjs} +4 -4
  76. package/dist/.setup/{provider-capabilities-DhkeeHJd.mjs → provider-capabilities-DtJKxDf6.mjs} +1 -1
  77. package/dist/.setup/{rate-limits-CMPy24F5.mjs → rate-limits-CI8pTPqL.mjs} +15 -32
  78. package/dist/.setup/reasoning-effort-CS9kKWB9.mjs +37 -0
  79. package/dist/.setup/{request-CZkKkN6c.mjs → request-6piO0U_P.mjs} +28 -48
  80. package/dist/.setup/{rpc-error-hmWM21RB.mjs → rpc-error-C98SHchT.mjs} +3 -6
  81. package/dist/.setup/{run-attempt-C6-678kR.mjs → run-attempt-DejV9vDW.mjs} +927 -860
  82. package/dist/.setup/{run-attempt-lifecycle-BuZgVbDA.mjs → run-attempt-lifecycle-KN4oh-7O.mjs} +13 -4
  83. package/dist/.setup/{runtime-artifact-CUTOOnKw.mjs → runtime-artifact-C13pR7tD.mjs} +18 -22
  84. package/dist/.setup/{runtime-artifact-connection-CADz3_BY.mjs → runtime-artifact-connection-jS5DeCok.mjs} +3 -3
  85. package/dist/.setup/{sandbox-guard-WqE8yPge.mjs → sandbox-guard-DIImwCy1.mjs} +4 -6
  86. package/dist/.setup/service-tier-normalization-BPgw2Wdt.mjs +9 -0
  87. package/dist/.setup/{session-binding-Ce7BqiPN.mjs → session-binding-JEHNMPsr.mjs} +13 -40
  88. package/dist/.setup/{session-binding-record-BZB8RgcF.mjs → session-binding-record-DU_0biMD.mjs} +4 -4
  89. package/dist/.setup/{session-binding-record-codec-z4ZpDn6E.mjs → session-binding-record-codec-BpH8u_G9.mjs} +16 -39
  90. package/dist/.setup/{session-binding-sidecars-BrdV95Fg.mjs → session-binding-sidecars-DD-enC8w.mjs} +49 -54
  91. package/dist/.setup/{session-catalog-adoption-CPIP4S_y.mjs → session-catalog-adoption-Ca3OYGYM.mjs} +23 -27
  92. package/dist/.setup/{session-catalog-archive-DcgwvSbF.mjs → session-catalog-archive-Bv6gV7x9.mjs} +6 -6
  93. package/dist/.setup/{session-catalog-events-Cj-b2FpC.mjs → session-catalog-events-BziNSfLx.mjs} +6 -5
  94. package/dist/.setup/{session-catalog-index-BnvC43eZ.mjs → session-catalog-index-BmaZFGEH.mjs} +111 -105
  95. package/dist/.setup/{session-catalog-index-order-nhyO0wdW.mjs → session-catalog-index-order-CTfoefow.mjs} +28 -5
  96. package/dist/.setup/{session-catalog-limits-DEU36Qlo.mjs → session-catalog-limits-BynIoOYm.mjs} +1 -1
  97. package/dist/.setup/{session-catalog-list-request-tXephOB4.mjs → session-catalog-list-request-D4MYNgDB.mjs} +11 -8
  98. package/dist/.setup/{session-catalog-native-projection-DCtsWKSF.mjs → session-catalog-native-projection-4CsufcT8.mjs} +5 -61
  99. package/dist/.setup/{session-catalog-node-adoption-7-WEQTB1.mjs → session-catalog-node-adoption-BdP9Zjqo.mjs} +2 -2
  100. package/dist/.setup/{session-catalog-node-continue-DLWBwAAO.mjs → session-catalog-node-continue-CNJibO4_.mjs} +27 -49
  101. package/dist/.setup/{session-catalog-node-lookup-Uufckwcm.mjs → session-catalog-node-lookup-BH_DBGa9.mjs} +3 -3
  102. package/dist/.setup/{session-catalog-parsing-B-qWJh2x.mjs → session-catalog-parsing-DkeoVn60.mjs} +9 -19
  103. package/dist/.setup/{session-catalog-projection-Cn0bLb-d.mjs → session-catalog-projection-CcIdJdsd.mjs} +8 -22
  104. package/dist/.setup/session-catalog-source-CdPqS9sa.mjs +58 -0
  105. package/dist/.setup/{session-cli-kH4vuGod.mjs → session-cli-GwU0izn-.mjs} +20 -41
  106. package/dist/.setup/{session-history-BogBHKLk.mjs → session-history-BO6i_pfk.mjs} +1 -1
  107. package/dist/.setup/{session-history-import-NWKPa4ZO.mjs → session-history-import-CaO8s6ta.mjs} +4 -4
  108. package/dist/.setup/{session-history-read-CNN8zwbD.mjs → session-history-read-BI_2jRED.mjs} +4 -15
  109. package/dist/.setup/{session-history.worker-Cq_4DYgN.mjs → session-history.worker-DJQfek5p.mjs} +147 -159
  110. package/dist/.setup/{session-initialization-D6dtFQkE.mjs → session-initialization-Bi_2DKhc.mjs} +3 -5
  111. package/dist/.setup/{session-permission-policy-BxIUJ0Zd.mjs → session-permission-policy-CD2MAWU8.mjs} +12 -20
  112. package/dist/.setup/{session-retirement-Bo81t4Fb.mjs → session-retirement-CcWVhLVr.mjs} +7 -7
  113. package/dist/.setup/{settled-turn-context-BZsMjkIO.mjs → settled-turn-context-BPL6D3RO.mjs} +1 -1
  114. package/dist/.setup/{settled-turn-finalizer-CFARFqNd.mjs → settled-turn-finalizer-BezKSo-Y.mjs} +12 -11
  115. package/dist/.setup/{shared-client-5NUq43f3.mjs → shared-client-BjiqpbC5.mjs} +164 -227
  116. package/dist/.setup/{side-question-oTlegAz3.mjs → side-question-YQ5FObkD.mjs} +116 -137
  117. package/dist/.setup/{source-1cabQi3x.mjs → source-Ce3XIIsU.mjs} +37 -56
  118. package/dist/.setup/thread-archive-guard-LKdwQKyr.mjs +56 -0
  119. package/dist/.setup/{thread-lifecycle--EPPTNTe.mjs → thread-lifecycle-run-BWy0LDLB.mjs} +338 -478
  120. package/dist/.setup/thread-model-selection-DcVebr8N.mjs +61 -0
  121. package/dist/.setup/{thread-ownership-T7T_iffm.mjs → thread-ownership-5X4197vk.mjs} +5 -5
  122. package/dist/.setup/{thread-ownership-queue-Dp24d7-F.mjs → thread-ownership-queue-CeyYScUC.mjs} +5 -6
  123. package/dist/.setup/{thread-policy-VtqLex1l.mjs → thread-policy-BEecBTJM.mjs} +4 -4
  124. package/dist/.setup/thread-requests-BgzJwJtS.mjs +745 -0
  125. package/dist/.setup/{thread-resume-buZujRcC.mjs → thread-resume-BXY_6o6Z.mjs} +5 -5
  126. package/dist/.setup/{timeout-CXOfNoaX.mjs → timeout-D0mEWSGG.mjs} +6 -12
  127. package/dist/.setup/{transcript-history-projection-B9a7HwUV.mjs → transcript-history-projection-DfKcoZCB.mjs} +3 -4
  128. package/dist/.setup/{transcript-mirror-BfLRARNL.mjs → transcript-mirror-Bee2o6jj.mjs} +68 -68
  129. package/dist/.setup/{transcript-mirror-attestation-YSegaktH.mjs → transcript-mirror-attestation-BzUXnrvv.mjs} +5 -2
  130. package/dist/.setup/{transport-stdio-a0HDa2Mj.mjs → transport-stdio-CRWTkKOn.mjs} +67 -77
  131. package/dist/.setup/{transport-websocket-zqJ0Cmtn.mjs → transport-websocket-DIyPfkHo.mjs} +8 -16
  132. package/dist/.setup/{turn-router-BOKSJmfw.mjs → turn-router-D8DLkZgH.mjs} +30 -31
  133. package/dist/.setup/upstream-prompt-provenance-Ccd9MFRJ.mjs +44 -0
  134. package/dist/.setup/{upstream-session-fork-C4sbIoZb.mjs → upstream-session-fork-DQZbaYMK.mjs} +50 -43
  135. package/dist/.setup/{usage-Cq21xTMZ.mjs → usage-DVR5mNJK.mjs} +4 -4
  136. package/dist/.setup/{usage-limit-error-CGJUoQu8.mjs → usage-limit-error-BEONfgt-.mjs} +12 -21
  137. package/dist/.setup/web-search-item-CvokaZOo.mjs +20 -0
  138. package/dist/.setup/{web-search-provider.runtime-DrVE7-Br.mjs → web-search-provider.runtime-CffHOpYY.mjs} +3 -3
  139. package/dist/.setup/{workspace-write-sandbox-probe-DmUHLrrl.mjs → workspace-write-sandbox-probe-BDWO2Qkh.mjs} +4 -4
  140. package/dist/api.js +15 -15
  141. package/dist/catalog-page.worker.js +1 -1
  142. package/dist/cli-metadata.js +1 -1
  143. package/dist/doctor-contract-api.js +5 -6
  144. package/dist/harness.js +32 -61
  145. package/dist/index.js +302 -416
  146. package/dist/media-understanding-provider.js +32 -43
  147. package/dist/migration-provider-api.js +1 -1
  148. package/dist/native-session-binding-api.js +1 -1
  149. package/dist/native-tool-policy.js +23 -1
  150. package/dist/provider-discovery.js +1 -1
  151. package/dist/session-history-worker-runtime.js +52 -31
  152. package/dist/session-history.worker.js +1 -1
  153. package/openclaw.plugin.json +20 -3
  154. package/package.json +7 -7
  155. package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +0 -5
  156. package/dist/.setup/plugin-thread-config-deadline-C5i1S6RN.mjs +0 -124
  157. package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +0 -15
  158. package/dist/.setup/shell-dynamic-tools-Bmedt1QE.mjs +0 -85
  159. package/dist/.setup/thread-archive-guard-C9frICzX.mjs +0 -60
  160. package/dist/.setup/thread-requests-Bj_Lixmv.mjs +0 -2111
  161. package/dist/.setup/upstream-prompt-provenance-fXkKbPVC.mjs +0 -37
@@ -1,24 +1,24 @@
1
1
  import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
- import { n as defineCodexBuildState, t as codexBuildSymbol } from "./build-state-LS-A65iX.mjs";
2
+ import { n as defineCodexBuildState, t as codexBuildSymbol } from "./build-state-CMYRQ_We.mjs";
3
3
  import { t as CODEX_APP_SERVER_AUTH_PROVIDER } from "./auth-profile-selection-hr8ocLtz.mjs";
4
4
  import { n as isCodexAppServerProxyLaunch } from "./launch-args-DbFCehO7.mjs";
5
5
  import { a as withEphemeralCodexAuthStore, i as withClearedEnvironmentVariables, n as resolveCodexAppServerLocalHomeDir, r as resolveCodexAppServerUserHomeDir, t as resolveCodexAppServerHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
6
- import { a as resolveCodexAppServerStartOptionsForAgent, d as readCodexEffectiveConfig, o as resolveCodexComputerUseConfig, t as codexAppServerStartOptionsKey, u as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES } from "./config-options-HG_Rr3W_.mjs";
7
- import { d as resolveMacOSDesktopCodexBundledMarketplaceCandidates, f as resolveMacOSDesktopCodexComputerUseServiceAppCandidates, i as resolveManagedCodexNativeCommand, l as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, r as resolveManagedCodexAppServerStartOptions, t as isManagedCodexDesktopCommand, u as resolveMacOSDesktopCodexAppPathCandidates } from "./managed-binary-C1VFoVPf.mjs";
8
- import { A as waitForCodexDesktopGeneration, C as retirePendingSharedClientEntryIfUnclaimed, D as waitForUnclaimedSharedClientStartup, _ as observeSharedClientAcquire, a as readCodexCliAuthFileApiKey, b as releaseSharedClientEntry, c as resolveCodexAppServerPreparedApiKeyCacheKey, d as getCurrentSharedClientEntry, f as getOrCreateSharedClientEntry, g as observeAcquire, h as notifyDesktopGenerationDrainChecks, i as fingerprintTokenAuthProfileCacheKey, j as readCodexDesktopArtifactTreeFingerprint, k as isCodexDesktopGenerationCurrent, l as closeSharedClientEntryIfUnclaimed, 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 createCodexAppServerStartupLifetime, v as ownCodexStartup, w as retireSharedCodexAppServerClientIfCurrent, x as retainSharedClientEntry, y as recordSharedClientAcquireBoundary } from "./auth-cache-key-BE1HXsNo.mjs";
9
- import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-a0HDa2Mj.mjs";
6
+ import { a as resolveCodexAppServerStartOptionsForAgent, d as readCodexEffectiveConfig, o as resolveCodexComputerUseConfig, t as codexAppServerStartOptionsKey, u as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES } from "./config-options-DDzeNQ8m.mjs";
7
+ import { d as resolveMacOSDesktopCodexBundledMarketplaceCandidates, f as resolveMacOSDesktopCodexComputerUseServiceAppCandidates, i as resolveManagedCodexNativeCommand, l as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, r as resolveManagedCodexAppServerStartOptions, t as isManagedCodexDesktopCommand, u as resolveMacOSDesktopCodexAppPathCandidates } from "./managed-binary-BtIjV7yN.mjs";
8
+ import { A as waitForCodexDesktopGeneration, C as retirePendingSharedClientEntryIfUnclaimed, D as waitForUnclaimedSharedClientStartup, _ as observeSharedClientAcquire, a as readCodexCliAuthFileApiKey, b as releaseSharedClientEntry, c as resolveCodexAppServerPreparedApiKeyCacheKey, d as getCurrentSharedClientEntry, f as getOrCreateSharedClientEntry, g as observeAcquire, h as notifyDesktopGenerationDrainChecks, i as fingerprintTokenAuthProfileCacheKey, j as readCodexDesktopArtifactTreeFingerprint, k as isCodexDesktopGenerationCurrent, l as closeSharedClientEntryIfUnclaimed, 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 createCodexAppServerStartupLifetime, v as ownCodexStartup, w as retireSharedCodexAppServerClientIfCurrent, x as retainSharedClientEntry, y as recordSharedClientAcquireBoundary } from "./auth-cache-key-tENCQOub.mjs";
9
+ import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-CRWTkKOn.mjs";
10
10
  import { n as CodexAppServerAuthProfileUnavailableError, r as formatCodexAuthProfileUnavailableMessage } from "./auth-profile-recovery-BREezV0L.mjs";
11
- import { a as codexPrewriteRejectionCause } from "./rpc-error-hmWM21RB.mjs";
12
- import { i as withTimeout } from "./timeout-CXOfNoaX.mjs";
11
+ import { a as codexPrewriteRejectionCause } from "./rpc-error-C98SHchT.mjs";
12
+ import { i as withTimeout } from "./timeout-D0mEWSGG.mjs";
13
13
  import { n as readCodexSessionMeta } from "./session-catalog-provenance-CmsOE5mh.mjs";
14
- import { n as observeCodexCatalogClient } from "./session-catalog-events-Cj-b2FpC.mjs";
15
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-cUYrqu_a.mjs";
14
+ import { n as observeCodexCatalogClient } from "./session-catalog-events-BziNSfLx.mjs";
15
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-DWzK-k0n.mjs";
16
16
  import { a as resolveCodexAppServerAuthProfileStore, i as resolveCodexAppServerAuthProfileIdForAgent, r as resolveCodexAppServerAuthProfileId, t as isCodexAppServerNativeAuthProfile } from "./auth-profile-CgHQ8Vot.mjs";
17
17
  import { i as isCodexResponsesOAuthCredential, n as createCodexResponsesOAuth, o as resolveCodexResponsesOAuthProfileFingerprint, r as isCodexResponsesOAuth, t as CODEX_RESPONSES_OAUTH_PROVIDER } from "./responses-oauth-twnuTaAa.mjs";
18
- import { R as isUnsupportedCodexAppServerVersionError, t as CodexAppServerClient } from "./client-ChJtGEdJ.mjs";
19
- import { n as isCodexWebSocketOpenFailure } from "./transport-websocket-zqJ0Cmtn.mjs";
20
- import { t as __exportAll } from "./session-binding-sidecars-BrdV95Fg.mjs";
21
- import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
18
+ import { N as isUnsupportedCodexAppServerVersionError, t as CodexAppServerClient } from "./client-zrCKOu_E.mjs";
19
+ import { n as isCodexWebSocketOpenFailure } from "./transport-websocket-DIyPfkHo.mjs";
20
+ import { t as __exportAll } from "./session-binding-sidecars-DD-enC8w.mjs";
21
+ import { asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
22
22
  import { createHash, randomUUID } from "node:crypto";
23
23
  import { isDeepStrictEqual } from "node:util";
24
24
  import { AgentHarnessPreflightError, resolveDefaultAgentDir } from "openclaw/plugin-sdk/agent-harness-registration";
@@ -30,8 +30,8 @@ import path from "node:path";
30
30
  import fs$1 from "node:fs/promises";
31
31
  import { extractErrorCode } from "openclaw/plugin-sdk/error-runtime";
32
32
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
33
- import { AgentHarnessPreflightError as AgentHarnessPreflightError$1, embeddedAgentLog as embeddedAgentLog$1, formatErrorMessage as formatErrorMessage$1 } from "openclaw/plugin-sdk/agent-harness-runtime";
34
33
  import { ensureAuthProfileStore, findPersistedAuthProfileCredential, refreshOAuthCredentialForRuntime, resolveApiKeyForProfile, resolvePersistedAuthProfileOwnerAgentDir } from "openclaw/plugin-sdk/agent-runtime";
34
+ import { AgentHarnessPreflightError as AgentHarnessPreflightError$1, embeddedAgentLog as embeddedAgentLog$1, formatErrorMessage as formatErrorMessage$1 } from "openclaw/plugin-sdk/agent-harness-runtime";
35
35
  import { hasUsableOAuthCredential, resolveOpenAICodexAuthIdentity } from "openclaw/plugin-sdk/provider-auth";
36
36
  import { assertDirectoryIdentitySync, readDirectoryIdentity } from "@openclaw/fs-safe/advanced";
37
37
  import { assertNoSymlinkParents, pathScope } from "openclaw/plugin-sdk/security-runtime";
@@ -63,10 +63,8 @@ async function withCodexStartupTimeout(params) {
63
63
  try {
64
64
  return await Promise.race([params.operation(), new Promise((_, reject) => {
65
65
  const rejectOnce = (error) => {
66
- if (timeout) {
67
- clearTimeout(timeout);
68
- timeout = void 0;
69
- }
66
+ clearTimeout(timeout);
67
+ timeout = void 0;
70
68
  reject(error);
71
69
  };
72
70
  timeout = setTimeout(() => {
@@ -87,7 +85,7 @@ async function withCodexStartupTimeout(params) {
87
85
  }
88
86
  throw error;
89
87
  } finally {
90
- if (timeout) clearTimeout(timeout);
88
+ clearTimeout(timeout);
91
89
  abortCleanup?.();
92
90
  }
93
91
  }
@@ -116,13 +114,7 @@ async function assertOwnedServicePath(params) {
116
114
  allowMissing: true
117
115
  });
118
116
  assertPathAtOrInside(params.ownershipRoot, params.targetParent, "Computer Use service parent");
119
- await assertNoSymlinkParents({
120
- rootDir: params.ownershipRoot,
121
- targetPath: params.targetParent,
122
- allowMissing: true,
123
- requireDirectories: true,
124
- messagePrefix: "Computer Use service path"
125
- });
117
+ await assertServicePathParents(params.ownershipRoot, params.targetParent, true);
126
118
  await assertNotSymlink(params.targetPath, "Computer Use service target");
127
119
  }
128
120
  async function ensureOwnedCodexHome(codexHomeInput, ownershipRootInput = path.dirname(path.resolve(codexHomeInput))) {
@@ -147,13 +139,7 @@ async function ensureOwnedCodexHome(codexHomeInput, ownershipRootInput = path.di
147
139
  async function prepareOwnedServiceParent(params) {
148
140
  await ensureOwnedCodexHome(params.codexHome, params.ownershipRoot);
149
141
  await ensureRealDirectoryTree(params.ownershipRoot, params.targetParent, "Computer Use service parent");
150
- await assertNoSymlinkParents({
151
- rootDir: params.ownershipRoot,
152
- targetPath: params.targetParent,
153
- allowMissing: false,
154
- requireDirectories: true,
155
- messagePrefix: "Computer Use service path"
156
- });
142
+ await assertServicePathParents(params.ownershipRoot, params.targetParent, false);
157
143
  const [rootIdentity, parentIdentity] = await Promise.all([readRealDirectoryIdentity(params.ownershipRoot, "Computer Use ownership root"), readRealDirectoryIdentity(params.targetParent, "Computer Use service parent")]);
158
144
  assertPathAtOrInside(rootIdentity.realPath, parentIdentity.realPath, "canonical Computer Use service parent");
159
145
  return parentIdentity;
@@ -161,10 +147,13 @@ async function prepareOwnedServiceParent(params) {
161
147
  async function assertOwnedCodexHomePath(params) {
162
148
  await readRealDirectoryIdentity(params.ownershipRoot, "Computer Use ownership root");
163
149
  assertPathAtOrInside(params.ownershipRoot, params.codexHome, "isolated Codex home");
164
- await assertNoSymlinkParents({
165
- rootDir: params.ownershipRoot,
166
- targetPath: params.codexHome,
167
- allowMissing: params.allowMissing,
150
+ await assertServicePathParents(params.ownershipRoot, params.codexHome, params.allowMissing);
151
+ }
152
+ function assertServicePathParents(rootDir, targetPath, allowMissing) {
153
+ return assertNoSymlinkParents({
154
+ rootDir,
155
+ targetPath,
156
+ allowMissing,
168
157
  requireDirectories: true,
169
158
  messagePrefix: "Computer Use service path"
170
159
  });
@@ -182,9 +171,6 @@ async function readRealDirectoryIdentity(directoryPath, label) {
182
171
  throw new Error(`${label} must remain a real directory: ${logicalPath}`, { cause });
183
172
  }
184
173
  }
185
- async function assertOwnedServiceParentStable(parent) {
186
- await assertDirectoryIdentityStable(parent, "Computer Use service parent");
187
- }
188
174
  async function assertDirectoryIdentityStable(expected, label) {
189
175
  if (!await directoryIdentityIsStable(expected)) throw new Error(`${label} changed during refresh; refusing to mutate the replacement path.`);
190
176
  }
@@ -401,15 +387,18 @@ async function resolveManagedCodexComputerUseConfig(config, marketplacePath) {
401
387
  }
402
388
  /** A native plugin disable veto must survive an automatic identity replacement. */
403
389
  function isLegacyCodexComputerUsePluginDisabled(config) {
404
- const plugin = isRecord(config) && isRecord(config.plugins) ? config.plugins["computer-use@openai-bundled"] : void 0;
405
- return isRecord(plugin) && plugin.enabled === false;
390
+ return readLegacyComputerUsePlugin(config)?.enabled === false;
406
391
  }
407
392
  /** Renaming a server must not discard an operator's legacy server or tool restrictions. */
408
393
  function hasLegacyCodexComputerUseMcpPolicy(config) {
409
394
  if (!isRecord(config)) return false;
410
395
  if (isRecord(config.mcp_servers) && Object.hasOwn(config.mcp_servers, "computer-use")) return true;
411
- const plugin = isRecord(config.plugins) ? config.plugins["computer-use@openai-bundled"] : void 0;
412
- return isRecord(plugin) && isRecord(plugin.mcp_servers) && Object.keys(plugin.mcp_servers).length > 0;
396
+ const servers = readLegacyComputerUsePlugin(config)?.mcp_servers;
397
+ return isRecord(servers) && Object.keys(servers).length > 0;
398
+ }
399
+ function readLegacyComputerUsePlugin(config) {
400
+ const plugins = asOptionalRecord(asOptionalRecord(config)?.plugins);
401
+ return asOptionalRecord(plugins?.["computer-use@openai-bundled"]);
413
402
  }
414
403
  async function readObject(file) {
415
404
  try {
@@ -628,6 +617,7 @@ const CLIENT_BUNDLE_ID = "com.openai.sky.CUAService.cli";
628
617
  const OPENAI_TEAM_ID = "2DC432GLL2";
629
618
  const CLIENT_APP_RELATIVE_PATH = path.join("Contents", "SharedSupport", "SkyComputerUseClient.app");
630
619
  const CLIENT_RELATIVE_PATH = path.join(CLIENT_APP_RELATIVE_PATH, "Contents", "MacOS", "SkyComputerUseClient");
620
+ const SERVICE_PARENT_LABEL = "Computer Use service parent";
631
621
  const COPY_TIMEOUT_MS = 12e4;
632
622
  const INSPECT_TIMEOUT_MS = 3e4;
633
623
  const activeInstalls = /* @__PURE__ */ new Map();
@@ -707,31 +697,31 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
707
697
  await assertNotSymlink(operationTargetPath, "Computer Use service target");
708
698
  const initialTarget = await readServiceAppSnapshot(operationTargetPath, inspectServiceApp);
709
699
  if (initialTarget.identity && identitiesMatch(initialTarget.identity, sourceIdentity)) return alreadyCurrent;
710
- await assertOwnedServiceParentStable(ownedParent);
700
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
711
701
  const stagingRoot = await fs$1.mkdtemp(path.join(ownedParent.realPath, ".service-app.staging-"));
712
702
  const stagingRootIdentity = await readRealDirectoryIdentity(stagingRoot, "Computer Use service staging directory");
713
703
  const stagedPath = path.join(stagingRoot, SERVICE_APP_NAME);
714
704
  const backupPath = path.join(ownedParent.realPath, `.service-app.backup-${process.pid}-${Date.now()}`);
715
705
  let backupCreated = false;
716
706
  const restoreBackup = async () => {
717
- await assertOwnedServiceParentStable(ownedParent);
707
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
718
708
  await fs$1.rename(backupPath, operationTargetPath);
719
- await assertOwnedServiceParentStable(ownedParent);
709
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
720
710
  backupCreated = false;
721
711
  };
722
712
  const removeBackup = async () => {
723
- await assertOwnedServiceParentStable(ownedParent);
713
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
724
714
  await assertNotSymlink(backupPath, "Computer Use service backup");
725
715
  await fs$1.rm(backupPath, {
726
716
  recursive: true,
727
717
  force: true
728
718
  });
729
- await assertOwnedServiceParentStable(ownedParent);
719
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
730
720
  backupCreated = false;
731
721
  };
732
722
  try {
733
723
  await (params.copyServiceApp ?? copyServiceAppWithDitto)(sourcePath, stagedPath);
734
- await assertOwnedServiceParentStable(ownedParent);
724
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
735
725
  await assertDirectoryIdentityStable(stagingRootIdentity, "Computer Use service staging directory");
736
726
  await assertNotSymlink(stagedPath, "Copied Computer Use service app");
737
727
  const stagedIdentity = await inspectServiceApp(stagedPath);
@@ -739,15 +729,15 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
739
729
  const stagedSnapshot = await readServiceAppSnapshot(stagedPath, inspectServiceApp);
740
730
  const currentSourceIdentity = await inspectServiceApp(sourcePath);
741
731
  await waitForCodexDesktopGeneration();
742
- await assertOwnedServiceParentStable(ownedParent);
732
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
743
733
  await assertDirectoryIdentityStable(stagingRootIdentity, "Computer Use service staging directory");
744
734
  if (!currentSourceIdentity || !identitiesMatch(currentSourceIdentity, sourceIdentity)) throw new Error("Selected Computer Use service source changed during refresh.");
745
735
  await assertNotSymlink(operationTargetPath, "Computer Use service target");
746
736
  if (await pathExists$1(operationTargetPath)) {
747
- await assertOwnedServiceParentStable(ownedParent);
737
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
748
738
  params.assertCurrent?.();
749
739
  await fs$1.rename(operationTargetPath, backupPath);
750
- await assertOwnedServiceParentStable(ownedParent);
740
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
751
741
  backupCreated = true;
752
742
  const movedTarget = await readServiceAppSnapshot(backupPath, inspectServiceApp);
753
743
  if (movedTarget.identity && identitiesMatch(movedTarget.identity, sourceIdentity)) {
@@ -760,12 +750,12 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
760
750
  }
761
751
  }
762
752
  try {
763
- await assertOwnedServiceParentStable(ownedParent);
753
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
764
754
  params.assertCurrent?.();
765
755
  await fs$1.rename(stagedPath, operationTargetPath);
766
- await assertOwnedServiceParentStable(ownedParent);
756
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
767
757
  } catch (error) {
768
- await assertOwnedServiceParentStable(ownedParent);
758
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
769
759
  await assertNotSymlink(operationTargetPath, "Computer Use service target");
770
760
  const winnerIdentity = await inspectServiceApp(operationTargetPath);
771
761
  if (!winnerIdentity || !identitiesMatch(winnerIdentity, sourceIdentity)) {
@@ -779,15 +769,15 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
779
769
  const installedSnapshot = await readServiceAppSnapshot(operationTargetPath, inspectServiceApp);
780
770
  if (!installedSnapshot.identity || !identitiesMatch(installedSnapshot.identity, sourceIdentity)) {
781
771
  if (filesystemSnapshotsMatch(installedSnapshot, stagedSnapshot)) {
782
- await assertOwnedServiceParentStable(ownedParent);
772
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
783
773
  await fs$1.rm(operationTargetPath, {
784
774
  recursive: true,
785
775
  force: true
786
776
  });
787
- await assertOwnedServiceParentStable(ownedParent);
777
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
788
778
  if (backupCreated) {
789
779
  await fs$1.rename(backupPath, operationTargetPath);
790
- await assertOwnedServiceParentStable(ownedParent);
780
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
791
781
  backupCreated = false;
792
782
  }
793
783
  }
@@ -795,16 +785,14 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
795
785
  }
796
786
  if (backupCreated) await removeBackup();
797
787
  return {
788
+ ...alreadyCurrent,
798
789
  status: initialTarget.exists ? "refreshed" : "installed",
799
790
  changed: true,
800
- targetPath: params.targetPath,
801
- sourcePath,
802
- sourceBuild: sourceIdentity.build,
803
791
  ...initialTarget.identity ? { previousBuild: initialTarget.identity.build } : {}
804
792
  };
805
793
  } catch (error) {
806
794
  if (backupCreated && await directoryIdentityIsStable(ownedParent) && !await pathExists$1(operationTargetPath)) {
807
- await assertOwnedServiceParentStable(ownedParent);
795
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
808
796
  await fs$1.rename(backupPath, operationTargetPath);
809
797
  backupCreated = false;
810
798
  }
@@ -842,7 +830,7 @@ async function readServiceAppFilesystemKey(appPath) {
842
830
  path.join(appPath, "Contents", "Info.plist"),
843
831
  path.join(appPath, CLIENT_RELATIVE_PATH)
844
832
  ];
845
- return (await Promise.all(paths.map(async (entryPath) => await fs$1.stat(entryPath).then((stat) => `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeMs}`, () => "missing")))).join("|");
833
+ return (await Promise.all(paths.map((entryPath) => fs$1.stat(entryPath).then((stat) => `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeMs}`, () => "missing")))).join("|");
846
834
  }
847
835
  function snapshotsMatch(left, right) {
848
836
  if (left.exists !== right.exists) return false;
@@ -852,7 +840,7 @@ function snapshotsMatch(left, right) {
852
840
  return left.filesystemKey !== void 0 && left.filesystemKey === right.filesystemKey;
853
841
  }
854
842
  function filesystemSnapshotsMatch(left, right) {
855
- return Boolean(left.exists && right.exists && left.filesystemKey && right.filesystemKey && left.filesystemKey === right.filesystemKey);
843
+ return Boolean(left.exists && right.exists && left.filesystemKey && left.filesystemKey === right.filesystemKey);
856
844
  }
857
845
  function identitiesMatch(left, right) {
858
846
  return left.bundleId === right.bundleId && left.version === right.version && left.build === right.build && left.cdHash === right.cdHash && left.teamId === right.teamId && left.clientBundleId === right.clientBundleId && left.clientCdHash === right.clientCdHash && left.clientTeamId === right.clientTeamId;
@@ -956,12 +944,8 @@ async function copyServiceAppWithDitto(sourcePath, targetPath) {
956
944
  const OPENAI_CODEX_DEFAULT_PROFILE_ID = "openai:default";
957
945
  const CODEX_HOME_ENV_VAR = "CODEX_HOME";
958
946
  const HOME_ENV_VAR = "HOME";
959
- const CODEX_APP_SERVER_PREPARED_AUTH_ENV_VARS = [
960
- "CODEX_API_KEY",
961
- "OPENAI_API_KEY",
962
- "CODEX_ACCESS_TOKEN"
963
- ];
964
- const CODEX_APP_SERVER_HOME_ENV_VARS = [CODEX_HOME_ENV_VAR, HOME_ENV_VAR];
947
+ const CODEX_APP_SERVER_PREPARED_AUTH_ENV_VARS = [...CODEX_APP_SERVER_API_KEY_ENV_VARS, "CODEX_ACCESS_TOKEN"];
948
+ const CODEX_APP_SERVER_HOME_ENV_VARS = /* @__PURE__ */ new Set([CODEX_HOME_ENV_VAR, HOME_ENV_VAR]);
965
949
  const MAX_COMPUTER_USE_ARTIFACT_OWNERS = 128;
966
950
  const activeComputerUseArtifactReconciliations = /* @__PURE__ */ new Map();
967
951
  const scopedOAuthRefreshQueues = /* @__PURE__ */ new WeakMap();
@@ -1145,9 +1129,10 @@ async function withCodexHomeEnvironment(startOptions, agentDir) {
1145
1129
  ...nativeHome ? { [HOME_ENV_VAR]: nativeHome } : {}
1146
1130
  }
1147
1131
  };
1148
- const clearEnv = withoutClearedCodexHomeEnv(startOptions.clearEnv);
1149
- if (clearEnv) nextStartOptions.clearEnv = clearEnv;
1150
- else delete nextStartOptions.clearEnv;
1132
+ if (startOptions.clearEnv) {
1133
+ const filtered = startOptions.clearEnv.filter((envVar) => !CODEX_APP_SERVER_HOME_ENV_VARS.has(envVar.trim().toUpperCase()));
1134
+ nextStartOptions.clearEnv = filtered.length === startOptions.clearEnv.length ? startOptions.clearEnv : filtered;
1135
+ } else delete nextStartOptions.clearEnv;
1151
1136
  return nextStartOptions;
1152
1137
  }
1153
1138
  /** Reconciles Computer Use artifacts for the exact managed command about to start. */
@@ -1156,16 +1141,12 @@ async function reconcileCodexComputerUseStartArtifacts(params) {
1156
1141
  const codexHome = resolveCodexAppServerLocalHomeDir(params.startOptions, params.agentDir);
1157
1142
  const key = path.resolve(codexHome);
1158
1143
  let owner = activeComputerUseArtifactReconciliations.get(key);
1159
- if (!owner) {
1160
- owner = {
1161
- active: 0,
1162
- tail: Promise.resolve()
1163
- };
1164
- activeComputerUseArtifactReconciliations.set(key, owner);
1165
- } else {
1166
- activeComputerUseArtifactReconciliations.delete(key);
1167
- activeComputerUseArtifactReconciliations.set(key, owner);
1168
- }
1144
+ if (!owner) owner = {
1145
+ active: 0,
1146
+ tail: Promise.resolve()
1147
+ };
1148
+ else activeComputerUseArtifactReconciliations.delete(key);
1149
+ activeComputerUseArtifactReconciliations.set(key, owner);
1169
1150
  owner.active += 1;
1170
1151
  const epoch = params.desktopGeneration?.epoch;
1171
1152
  if (epoch !== void 0 && (owner.latestEpoch === void 0 || epoch > owner.latestEpoch)) owner.latestEpoch = epoch;
@@ -1173,7 +1154,7 @@ async function reconcileCodexComputerUseStartArtifacts(params) {
1173
1154
  params.assertCurrent?.();
1174
1155
  if (epoch !== void 0 && owner.latestEpoch !== epoch) throw new Error("Codex Computer Use artifact reconciliation was superseded.");
1175
1156
  };
1176
- const operation = owner.tail.catch(() => void 0).then(async () => {
1157
+ const operation = owner.tail.then(async () => {
1177
1158
  assertCurrent();
1178
1159
  const appliedCacheBinding = await reconcileCodexComputerUseStartArtifactsOnce({
1179
1160
  ...params,
@@ -1184,7 +1165,7 @@ async function reconcileCodexComputerUseStartArtifacts(params) {
1184
1165
  assertCurrent();
1185
1166
  owner.appliedCacheBinding = appliedCacheBinding;
1186
1167
  });
1187
- const settled = operation.then(() => void 0, () => void 0);
1168
+ const settled = operation.catch(() => void 0);
1188
1169
  owner.tail = settled;
1189
1170
  try {
1190
1171
  await operation;
@@ -1283,12 +1264,6 @@ var CodexComputerUseCandidateArtifactsUnavailableError = class extends Error {
1283
1264
  this.name = "CodexComputerUseCandidateArtifactsUnavailableError";
1284
1265
  }
1285
1266
  };
1286
- function withoutClearedCodexHomeEnv(clearEnv) {
1287
- if (!clearEnv) return;
1288
- const reserved = new Set(CODEX_APP_SERVER_HOME_ENV_VARS);
1289
- const filtered = clearEnv.filter((envVar) => !reserved.has(envVar.trim().toUpperCase()));
1290
- return filtered.length === clearEnv.length ? clearEnv : filtered;
1291
- }
1292
1267
  async function applyCodexAppServerAuthProfile(params) {
1293
1268
  params.assertCurrent?.();
1294
1269
  if (!params.preparedAuth && params.authProfileId === null) {
@@ -1356,7 +1331,7 @@ function createCodexAppServerAuthError(message) {
1356
1331
  async function refreshCodexAppServerAuthTokens(params) {
1357
1332
  const previousAccountId = params.previousAccountId?.trim();
1358
1333
  const handoffAccountId = params.authHandoff?.chatgptAccountId.trim();
1359
- if (previousAccountId && handoffAccountId && previousAccountId !== handoffAccountId) throw new Error("ChatGPT workspace changed before Codex token refresh. Retry to start a client for the selected workspace.");
1334
+ if (previousAccountId && handoffAccountId && previousAccountId !== handoffAccountId) throw codexWorkspaceChangedError("before");
1360
1335
  if (previousAccountId) {
1361
1336
  const store = resolveCodexAppServerAuthProfileStore(params);
1362
1337
  const profileId = resolveCodexAppServerAuthProfileId({
@@ -1365,14 +1340,14 @@ async function refreshCodexAppServerAuthTokens(params) {
1365
1340
  });
1366
1341
  const credential = profileId ? store.profiles[profileId] : void 0;
1367
1342
  const selectedAccountId = credential ? resolveExplicitChatgptAccountId(credential) ?? (credential.type === "oauth" ? resolveOpenAICodexAuthIdentity({ access: credential.access }).accountId : void 0) : void 0;
1368
- if (selectedAccountId && selectedAccountId !== previousAccountId) throw new Error("ChatGPT workspace changed before Codex token refresh. Retry to start a client for the selected workspace.");
1343
+ if (selectedAccountId && selectedAccountId !== previousAccountId) throw codexWorkspaceChangedError("before");
1369
1344
  }
1370
1345
  const loginParams = await resolveCodexAppServerAuthProfileLoginParamsInternal({
1371
1346
  ...params,
1372
1347
  forceOAuthRefresh: true
1373
1348
  });
1374
1349
  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.");
1375
- if (previousAccountId && loginParams.chatgptAccountId !== previousAccountId || 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.");
1350
+ if (previousAccountId && loginParams.chatgptAccountId !== previousAccountId || params.authHandoff && loginParams.chatgptAccountId !== params.authHandoff.chatgptAccountId) throw codexWorkspaceChangedError("during");
1376
1351
  return {
1377
1352
  accessToken: loginParams.accessToken,
1378
1353
  chatgptAccountId: loginParams.chatgptAccountId,
@@ -1389,32 +1364,14 @@ async function resolveCodexAppServerAuthProfileLoginParamsInternal(params) {
1389
1364
  const credential = store.profiles[profileId];
1390
1365
  if (!credential) throw new CodexAppServerAuthProfileUnavailableError(formatCodexAuthProfileUnavailableMessage(profileId));
1391
1366
  if (!isCodexAppServerAuthProvider(credential.provider)) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" must use the canonical OpenAI auth provider; run "openclaw doctor --fix" to migrate legacy provider IDs.`);
1392
- const loginParams = await resolveLoginParamsForCredential(profileId, credential, {
1393
- agentDir: params.agentDir,
1394
- store,
1395
- preferStoreCredential: Boolean(params.authProfileStore?.profiles[profileId]),
1396
- forceOAuthRefresh: params.forceOAuthRefresh === true,
1397
- authHandoff: params.authHandoff,
1398
- previousAccountId: params.previousAccountId,
1399
- config: params.config
1400
- });
1401
- 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.`);
1402
- return loginParams;
1403
- }
1404
- async function resolveCodexAppServerFallbackApiKeyLoginParams(params) {
1405
- const apiKey = readFirstNonEmptyEnv(params.env, CODEX_APP_SERVER_API_KEY_ENV_VARS) ?? await readCodexCliAuthFileApiKey(params.codexCliAuthEnv);
1406
- if (!apiKey) return;
1407
- if ((await params.client.request("account/read", { refreshToken: false }, { assertCurrent: params.assertCurrent })).account) return;
1408
- return {
1409
- type: "apiKey",
1410
- apiKey
1411
- };
1412
- }
1413
- async function resolveLoginParamsForCredential(profileId, credential, params) {
1367
+ const preferStoreCredential = Boolean(params.authProfileStore?.profiles[profileId]);
1368
+ let loginCredential = credential;
1369
+ let value;
1370
+ let useApiKey = false;
1414
1371
  if (credential.type === "api_key" || credential.type === "token") {
1415
- const value = (await resolveApiKeyForProfile({
1372
+ value = (await resolveApiKeyForProfile({
1416
1373
  cfg: params.config,
1417
- store: params.preferStoreCredential ? params.store : ensureAuthProfileStore(params.agentDir, {
1374
+ store: preferStoreCredential ? store : ensureAuthProfileStore(params.agentDir, {
1418
1375
  allowKeychainPrompt: false,
1419
1376
  profileId,
1420
1377
  config: params.config
@@ -1422,23 +1379,30 @@ async function resolveLoginParamsForCredential(profileId, credential, params) {
1422
1379
  profileId,
1423
1380
  agentDir: params.agentDir
1424
1381
  }))?.apiKey?.trim();
1425
- if (!value) return;
1426
- return credential.type === "api_key" ? {
1427
- type: "apiKey",
1428
- apiKey: value
1429
- } : buildChatgptAuthTokensParams(profileId, credential, value);
1382
+ useApiKey = credential.type === "api_key";
1383
+ } else {
1384
+ loginCredential = await resolveOAuthCredentialForCodexAppServer(profileId, credential, {
1385
+ ...params,
1386
+ store,
1387
+ preferStoreCredential,
1388
+ forceRefresh: params.forceOAuthRefresh === true
1389
+ });
1390
+ value = loginCredential.access?.trim();
1430
1391
  }
1431
- const resolvedCredential = await resolveOAuthCredentialForCodexAppServer(profileId, credential, {
1432
- agentDir: params.agentDir,
1433
- store: params.store,
1434
- preferStoreCredential: params.preferStoreCredential,
1435
- forceRefresh: params.forceOAuthRefresh,
1436
- authHandoff: params.authHandoff,
1437
- previousAccountId: params.previousAccountId,
1438
- config: params.config
1439
- });
1440
- const accessToken = resolvedCredential.access?.trim();
1441
- return accessToken ? buildChatgptAuthTokensParams(profileId, resolvedCredential, accessToken) : void 0;
1392
+ if (!value) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" does not contain usable credentials. Repair or replace the selected OpenAI credential, then retry.`);
1393
+ return useApiKey ? {
1394
+ type: "apiKey",
1395
+ apiKey: value
1396
+ } : buildChatgptAuthTokensParams(profileId, loginCredential, value);
1397
+ }
1398
+ async function resolveCodexAppServerFallbackApiKeyLoginParams(params) {
1399
+ const apiKey = readFirstNonEmptyEnv(params.env, CODEX_APP_SERVER_API_KEY_ENV_VARS) ?? await readCodexCliAuthFileApiKey(params.codexCliAuthEnv);
1400
+ if (!apiKey) return;
1401
+ if ((await params.client.request("account/read", { refreshToken: false }, { assertCurrent: params.assertCurrent })).account) return;
1402
+ return {
1403
+ type: "apiKey",
1404
+ apiKey
1405
+ };
1442
1406
  }
1443
1407
  async function resolveOAuthCredentialForCodexAppServer(profileId, credential, params) {
1444
1408
  const ownerAgentDir = resolvePersistedAuthProfileOwnerAgentDir({
@@ -1449,13 +1413,9 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1449
1413
  agentDir: ownerAgentDir,
1450
1414
  profileId
1451
1415
  });
1452
- const useScopedCredential = params.preferStoreCredential && shouldUseScopedOAuthCredential({
1453
- store: params.store,
1454
- profileId,
1455
- persistedCredential,
1456
- suppliedCredential: credential
1457
- });
1458
- 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 an OpenAI OAuth credential in its persisted OpenClaw store. Run "openclaw doctor" to inspect credential ownership, or select an existing OpenAI profile.`);
1416
+ const persistedProfile = params.store.runtimePersistedProfileIds?.includes(profileId);
1417
+ const useScopedCredential = params.preferStoreCredential && (!persistedProfile || persistedCredential?.type === "oauth" && isCodexAppServerAuthProvider(persistedCredential.provider) && !isDeepStrictEqual(persistedCredential, credential) && !hasMatchingOAuthIdentity(persistedCredential, credential));
1418
+ if (params.preferStoreCredential && persistedProfile && (persistedCredential?.type !== "oauth" || !isCodexAppServerAuthProvider(persistedCredential.provider))) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" is no longer an OpenAI OAuth credential in its persisted OpenClaw store. Run "openclaw doctor" to inspect credential ownership, or select an existing OpenAI profile.`);
1459
1419
  const store = useScopedCredential ? params.store : resolveCodexAppServerAuthProfileStore({
1460
1420
  agentDir: ownerAgentDir,
1461
1421
  authProfileId: profileId,
@@ -1472,7 +1432,7 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1472
1432
  });
1473
1433
  const selectedAccountId = currentCredential ? resolveOpenAICodexAuthIdentity(currentCredential).accountId?.trim() : void 0;
1474
1434
  const callbackAccountId = params.authHandoff?.chatgptAccountId.trim() ?? params.previousAccountId?.trim() ?? void 0;
1475
- if (callbackAccountId && selectedAccountId && callbackAccountId !== selectedAccountId) throw new Error("ChatGPT workspace changed before Codex token refresh. Retry to start a client for the selected workspace.");
1435
+ if (callbackAccountId && selectedAccountId && callbackAccountId !== selectedAccountId) throw codexWorkspaceChangedError("before");
1476
1436
  const expectedAccountId = callbackAccountId ?? selectedAccountId;
1477
1437
  if (useScopedCredential && overlaidOAuthCredential) return await resolveScopedOAuthCredential({
1478
1438
  store,
@@ -1483,7 +1443,6 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1483
1443
  config: params.config
1484
1444
  });
1485
1445
  if (params.forceRefresh && !persistedOAuthCredential && overlaidOAuthCredential) {
1486
- if (reuseCompletedRotation) return overlaidOAuthCredential;
1487
1446
  const refreshedRuntimeCredential = await refreshOAuthCredentialForRuntime({
1488
1447
  credential: overlaidOAuthCredential,
1489
1448
  cfg: params.config
@@ -1518,12 +1477,6 @@ function shouldReuseCompletedCodexOAuthRotation(params) {
1518
1477
  const previousAccountId = params.previousAccountId?.trim();
1519
1478
  return accountId === handoff.chatgptAccountId && (!previousAccountId || previousAccountId === handoff.chatgptAccountId);
1520
1479
  }
1521
- function shouldUseScopedOAuthCredential(params) {
1522
- if (!params.store.runtimePersistedProfileIds?.includes(params.profileId)) return true;
1523
- const persisted = params.persistedCredential;
1524
- if (persisted?.type !== "oauth" || !isCodexAppServerAuthProvider(persisted.provider)) return false;
1525
- return !isDeepStrictEqual(persisted, params.suppliedCredential) && !hasMatchingOAuthIdentity(persisted, params.suppliedCredential);
1526
- }
1527
1480
  function hasMatchingOAuthIdentity(persisted, supplied) {
1528
1481
  const persistedAccountId = resolveOpenAICodexAuthIdentity(persisted).accountId?.trim();
1529
1482
  const suppliedAccountId = resolveOpenAICodexAuthIdentity(supplied).accountId?.trim();
@@ -1563,9 +1516,12 @@ async function resolveScopedOAuthCredential(params) {
1563
1516
  if (storeRefreshes.get(params.profileId) === refresh) storeRefreshes.delete(params.profileId);
1564
1517
  }
1565
1518
  }
1519
+ function codexWorkspaceChangedError(phase) {
1520
+ return /* @__PURE__ */ new Error(`ChatGPT workspace changed ${phase} Codex token refresh. Retry to start a client for the selected workspace.`);
1521
+ }
1566
1522
  function assertCodexOAuthRefreshWorkspace(profileId, credential, expectedAccountId) {
1567
1523
  if (!expectedAccountId) return;
1568
- if (buildChatgptAuthTokensParams(profileId, credential, credential.access.trim()).chatgptAccountId !== expectedAccountId) throw new Error("ChatGPT workspace changed during Codex token refresh. Retry to start a client for the selected workspace.");
1524
+ if (buildChatgptAuthTokensParams(profileId, credential, credential.access.trim()).chatgptAccountId !== expectedAccountId) throw codexWorkspaceChangedError("during");
1569
1525
  }
1570
1526
  function isCodexAppServerAuthProvider(provider) {
1571
1527
  return provider.trim().toLowerCase() === CODEX_APP_SERVER_AUTH_PROVIDER;
@@ -1601,10 +1557,7 @@ function resolveStableChatgptAccountId(credential) {
1601
1557
  return resolveExplicitChatgptAccountId(credential) ?? (credential.email?.trim() || void 0);
1602
1558
  }
1603
1559
  function resolveExplicitChatgptAccountId(credential) {
1604
- if ("accountId" in credential && typeof credential.accountId === "string") {
1605
- const accountId = credential.accountId.trim();
1606
- if (accountId) return accountId;
1607
- }
1560
+ return "accountId" in credential && typeof credential.accountId === "string" ? credential.accountId.trim() || void 0 : void 0;
1608
1561
  }
1609
1562
  //#endregion
1610
1563
  //#region extensions/codex/src/app-server/client-thread-owner.ts
@@ -1793,12 +1746,19 @@ function readRecentCodexRateLimits(client, options) {
1793
1746
  }
1794
1747
  function mergeRateLimitUpdate(current, update) {
1795
1748
  const currentEnvelope = isJsonObject(current) ? current : void 0;
1796
- const currentPrimary = currentEnvelope && isJsonObject(currentEnvelope.rateLimits) ? currentEnvelope.rateLimits : void 0;
1797
- const currentByLimitId = currentEnvelope && isJsonObject(currentEnvelope.rateLimitsByLimitId) ? currentEnvelope.rateLimitsByLimitId : void 0;
1749
+ const currentPrimary = readObjectField(currentEnvelope, "rateLimits");
1750
+ const currentByLimitId = readObjectField(currentEnvelope, "rateLimitsByLimitId");
1798
1751
  const limitId = readLimitId(update);
1799
1752
  const currentPrimaryLimitId = currentPrimary ? readLimitId(currentPrimary) : void 0;
1800
- const currentForLimit = (currentByLimitId && isJsonObject(currentByLimitId[limitId]) ? currentByLimitId[limitId] : void 0) ?? (currentPrimaryLimitId === limitId ? currentPrimary : void 0);
1801
- const merged = mergeSparseSnapshot(isJsonObject(currentForLimit) ? currentForLimit : void 0, currentPrimary, update, limitId);
1753
+ const currentForLimit = readObjectField(currentByLimitId, limitId) ?? (currentPrimaryLimitId === limitId ? currentPrimary : void 0);
1754
+ const merged = {
1755
+ ...update,
1756
+ limitId
1757
+ };
1758
+ for (const key of SPARSE_ACCOUNT_METADATA_KEYS) {
1759
+ const previous = currentForLimit?.[key] ?? currentPrimary?.[key];
1760
+ if (merged[key] == null && previous != null) merged[key] = previous;
1761
+ }
1802
1762
  const nextPrimary = !currentPrimary || currentPrimaryLimitId === limitId ? merged : currentPrimary;
1803
1763
  let nextByLimitId;
1804
1764
  if (currentByLimitId) nextByLimitId = {
@@ -1825,24 +1785,20 @@ function readRateLimitIds(value) {
1825
1785
  }
1826
1786
  return [...ids];
1827
1787
  }
1828
- function mergeSparseSnapshot(current, accountFallback, update, limitId) {
1829
- const merged = {
1830
- ...update,
1831
- limitId
1832
- };
1833
- for (const key of SPARSE_ACCOUNT_METADATA_KEYS) {
1834
- const previous = current?.[key] ?? accountFallback?.[key];
1835
- if (merged[key] == null && previous != null) merged[key] = previous;
1836
- }
1837
- return merged;
1838
- }
1839
1788
  function readLimitId(snapshot) {
1840
1789
  const value = snapshot.limitId;
1841
1790
  return typeof value === "string" && value.trim() ? value.trim() : "codex";
1842
1791
  }
1792
+ function readObjectField(value, key) {
1793
+ return value && isJsonObject(value[key]) ? value[key] : void 0;
1794
+ }
1843
1795
  //#endregion
1844
1796
  //#region extensions/codex/src/app-server/client-runtime.ts
1845
- /** Client-scoped Codex auth and account observers. */
1797
+ function defaultThreadRelease(client) {
1798
+ return async (threadId, assertCurrent, withCurrent) => {
1799
+ await unsubscribeCodexAppServerLiveThread(client, threadId, 5e3, assertCurrent, withCurrent);
1800
+ };
1801
+ }
1846
1802
  /** Match Codex's native grace window without retaining inactive conversations indefinitely. */
1847
1803
  const CODEX_APP_SERVER_LIVE_THREAD_IDLE_TIMEOUT_MS = 18e5;
1848
1804
  /** Native-child parents are active ownership, so only otherwise-idle threads count against this cap. */
@@ -1899,10 +1855,8 @@ function ensureCodexAppServerClientRuntime(client, context) {
1899
1855
  configuredClients.set(client, runtime);
1900
1856
  client.addCloseHandler(() => {
1901
1857
  runtime.closed = true;
1902
- if (runtime.evictionTimer) {
1903
- clearTimeout(runtime.evictionTimer);
1904
- runtime.evictionTimer = void 0;
1905
- }
1858
+ clearTimeout(runtime.evictionTimer);
1859
+ runtime.evictionTimer = void 0;
1906
1860
  for (const threadId of /* @__PURE__ */ new Set([
1907
1861
  ...runtime.retainedThreads.keys(),
1908
1862
  ...runtime.claimedThreads.keys(),
@@ -1963,10 +1917,8 @@ function ensureCodexAppServerClientRuntime(client, context) {
1963
1917
  });
1964
1918
  }
1965
1919
  function scheduleRetainedThreadEviction(client, runtime) {
1966
- if (runtime.evictionTimer) {
1967
- clearTimeout(runtime.evictionTimer);
1968
- runtime.evictionTimer = void 0;
1969
- }
1920
+ clearTimeout(runtime.evictionTimer);
1921
+ runtime.evictionTimer = void 0;
1970
1922
  if (runtime.closed) return;
1971
1923
  let expiresAt = Number.POSITIVE_INFINITY;
1972
1924
  for (const [threadId, thread] of runtime.retainedThreads) if (!runtime.protectedThreads.has(threadId)) expiresAt = Math.min(expiresAt, thread.expiresAt);
@@ -2055,9 +2007,7 @@ async function retainCodexAppServerLiveThread(client, threadId, releaseThread, c
2055
2007
  ephemeralPolicy,
2056
2008
  serviceTier,
2057
2009
  expiresAt: ephemeralPolicy === void 0 ? Date.now() + CODEX_APP_SERVER_LIVE_THREAD_IDLE_TIMEOUT_MS : Number.POSITIVE_INFINITY,
2058
- release: (releaseThread ? physicalThreadReleases.get(releaseThread) ?? releaseThread : void 0) ?? (async (releasedThreadId, assertCurrent, withCurrent) => {
2059
- await unsubscribeCodexAppServerLiveThread(client, releasedThreadId, 5e3, assertCurrent, withCurrent);
2060
- })
2010
+ release: (releaseThread ? physicalThreadReleases.get(releaseThread) ?? releaseThread : void 0) ?? defaultThreadRelease(client)
2061
2011
  };
2062
2012
  runtime.retainedThreads.set(threadId, retained);
2063
2013
  if (previousOwner !== ownerToken) previousOwner?.invalidate();
@@ -2101,9 +2051,7 @@ async function claimCodexAppServerLiveThread(client, threadId, onInvalidated) {
2101
2051
  }
2102
2052
  return claimCodexAppServerThreadOwnership(client, runtime, threadId, runtime.retainedThreads.get(threadId) ?? {
2103
2053
  expiresAt: Date.now() + CODEX_APP_SERVER_LIVE_THREAD_IDLE_TIMEOUT_MS,
2104
- release: async (releasedThreadId, assertCurrent, withCurrent) => {
2105
- await unsubscribeCodexAppServerLiveThread(client, releasedThreadId, 5e3, assertCurrent, withCurrent);
2106
- }
2054
+ release: defaultThreadRelease(client)
2107
2055
  }, onInvalidated);
2108
2056
  }
2109
2057
  function claimCodexAppServerThreadOwnership(client, runtime, threadId, retained, onInvalidated) {
@@ -2318,15 +2266,13 @@ function supportsInferenceEnvironment(native) {
2318
2266
  const lower = upper.toLowerCase();
2319
2267
  if (native[upper] !== process.env[upper] || native[lower] !== process.env[lower] || native[upper] !== void 0 && native[lower] !== void 0 && native[upper] !== native[lower]) return false;
2320
2268
  }
2321
- const value = (name) => (native[name] ?? native[name.toLowerCase()])?.trim() || void 0;
2322
- const http = value("HTTP_PROXY");
2323
- const https = value("HTTPS_PROXY");
2324
- const all = value("ALL_PROXY");
2269
+ const value = (name) => native[name] ?? native[name.toLowerCase()];
2270
+ const [http, https, all] = names.slice(0, 3).map((name) => value(name)?.trim() || void 0);
2325
2271
  if (!http && !https && !all) return true;
2326
2272
  const noProxy = native.NO_PROXY ?? native.no_proxy ?? "";
2327
2273
  if (noProxy === "*") return true;
2328
2274
  if (native.REQUEST_METHOD !== void 0 || names.slice(0, 3).some((name) => {
2329
- const raw = native[name] ?? native[name.toLowerCase()];
2275
+ const raw = value(name);
2330
2276
  return raw !== void 0 && raw !== raw.trim();
2331
2277
  })) return false;
2332
2278
  if ((https ?? all) !== (https ?? http ?? all)) return false;
@@ -2366,8 +2312,7 @@ function projectProviderRoutes(config, providers) {
2366
2312
  return projected;
2367
2313
  }
2368
2314
  function readProviderBaseUrl(config, provider) {
2369
- if (provider === "openai") return config?.openai_base_url;
2370
- return readProviderField(config, provider, "base_url");
2315
+ return provider === "openai" ? config?.openai_base_url : readProviderField(config, provider, "base_url");
2371
2316
  }
2372
2317
  function readProviderField(config, provider, field) {
2373
2318
  const selected = (isJsonObject(config?.model_providers) ? config.model_providers : void 0)?.[provider];
@@ -2455,6 +2400,7 @@ async function prepareCodexInferenceRoute(params) {
2455
2400
  ...params.authority ? { withCurrent: params.authority.withCurrent } : {}
2456
2401
  });
2457
2402
  assertCurrent();
2403
+ const feature = (name) => params.config?.[`features.${name}`] ?? (isJsonObject(params.config?.features) ? params.config.features[name] : void 0) ?? (isJsonObject(snapshot.config.features) ? snapshot.config.features[name] : void 0);
2458
2404
  const unsupported = () => {
2459
2405
  if (owner.oauth) throw new Error("ChatGPT subscription sharing requires the managed public Responses inference route.");
2460
2406
  };
@@ -2473,7 +2419,7 @@ async function prepareCodexInferenceRoute(params) {
2473
2419
  "ollama",
2474
2420
  "lmstudio"
2475
2421
  ].includes(provider) || hasProviderAws(params.config, provider) || hasProviderAws(snapshot.config, provider) || wireApi != null && wireApi !== "responses")) return unsupported();
2476
- if ((params.config?.["features.respect_system_proxy"] ?? (isJsonObject(params.config?.features) ? params.config.features.respect_system_proxy : void 0) ?? (isJsonObject(snapshot.config.features) ? snapshot.config.features.respect_system_proxy : void 0)) === true) return unsupported();
2422
+ if (feature("respect_system_proxy") === true) return unsupported();
2477
2423
  const configured = customProvider ? providerField("base_url") : params.config?.openai_base_url ?? snapshot.config.openai_base_url;
2478
2424
  if (configured != null && typeof configured !== "string") throw new Error("Codex inference upstream configuration is invalid");
2479
2425
  if (typeof configured === "string" && (!configured.trim() || configured.includes("?") || configured.includes("#"))) return unsupported();
@@ -2512,7 +2458,7 @@ async function prepareCodexInferenceRoute(params) {
2512
2458
  "windows.net/openai"
2513
2459
  ].some((marker) => nativeBaseUrl.includes(marker));
2514
2460
  const preserveCodexBackendRoutes = nativeProviderName === "OpenAI" && (configured == null || configured.replace(/\/+$/, "").endsWith("/backend-api/codex"));
2515
- const memoryFeature = params.config?.["features.memories"] ?? (isJsonObject(params.config?.features) ? params.config.features.memories : void 0) ?? (isJsonObject(snapshot.config.features) ? snapshot.config.features.memories : void 0);
2461
+ const memoryFeature = feature("memories");
2516
2462
  const modelPolicyEnforced = params.modelPolicyEnforced !== false;
2517
2463
  const key = JSON.stringify([
2518
2464
  provider,
@@ -2534,9 +2480,9 @@ async function prepareCodexInferenceRoute(params) {
2534
2480
  throw new Error("Codex inference route limit reached; start a fresh managed native connection before retrying.");
2535
2481
  }
2536
2482
  pending = Promise.all([
2537
- import("./inference-proxy-DUO5E2QQ.mjs"),
2538
- import("./native-subagent-monitor-wh_-K3Vo.mjs").then((n) => n.n),
2539
- import("./inference-dispatch-B5UKEUyC.mjs")
2483
+ import("./inference-proxy-BDWV0djM.mjs"),
2484
+ import("./native-subagent-monitor-D5O_o07p.mjs").then((n) => n.n),
2485
+ import("./inference-dispatch-CO6tTs4q.mjs")
2540
2486
  ]).then(([{ createCodexInferenceProxy }, native, { createCodexInferenceModelBinding }]) => {
2541
2487
  assertClient();
2542
2488
  return createCodexInferenceProxy({
@@ -2760,22 +2706,17 @@ async function waitForPreviousFence(previous, options) {
2760
2706
  }
2761
2707
  await new Promise((resolve, reject) => {
2762
2708
  let timeout;
2763
- const cleanup = () => {
2764
- if (timeout) {
2765
- clearTimeout(timeout);
2766
- timeout = void 0;
2767
- }
2709
+ const settle = (error) => {
2710
+ clearTimeout(timeout);
2711
+ timeout = void 0;
2768
2712
  options.signal?.removeEventListener("abort", onAbort);
2713
+ return error ? reject(error) : resolve();
2769
2714
  };
2770
- const settle = (run) => {
2771
- cleanup();
2772
- run();
2773
- };
2774
- const onAbort = () => settle(() => reject(new Error(options.abortMessage ?? "Codex native config fence aborted")));
2775
- previous.then(() => settle(resolve));
2776
- if (options.signal) options.signal.addEventListener("abort", onAbort, { once: true });
2715
+ const onAbort = () => settle(new Error(options.abortMessage ?? "Codex native config fence aborted"));
2716
+ previous.then(() => settle());
2717
+ options.signal?.addEventListener("abort", onAbort, { once: true });
2777
2718
  if (options.timeoutMs !== void 0) {
2778
- timeout = setTimeout(() => settle(() => reject(new Error(options.timeoutMessage ?? "Codex native config fence timed out"))), Math.max(1, options.timeoutMs));
2719
+ timeout = setTimeout(() => settle(new Error(options.timeoutMessage ?? "Codex native config fence timed out")), Math.max(1, options.timeoutMs));
2779
2720
  timeout.unref?.();
2780
2721
  }
2781
2722
  });
@@ -2808,7 +2749,7 @@ const nativeHookRelayUnregisterQueue = {
2808
2749
  clearTimeout(entry.timeout);
2809
2750
  entry.unregister();
2810
2751
  }
2811
- while (closing.size > 0) await Promise.allSettled(closing);
2752
+ await nativeHookRelayUnregisterQueue.clear();
2812
2753
  },
2813
2754
  async clear() {
2814
2755
  for (const entry of pending) clearTimeout(entry.timeout);
@@ -3185,7 +3126,7 @@ async function acquireSharedCodexAppServerClient(options, leased = false) {
3185
3126
  entry,
3186
3127
  authProfileId: usesNativeAuth || preparedAuth?.kind === "api-key" ? null : authProfileId,
3187
3128
  runtimeArtifactMode,
3188
- ...options?.expectedRuntimeArtifact ? { expectedRuntimeArtifact: options.expectedRuntimeArtifact } : {},
3129
+ expectedRuntimeArtifact: options?.expectedRuntimeArtifact,
3189
3130
  abandonSignal: entry.startupAbort.signal,
3190
3131
  config: options?.config
3191
3132
  }));
@@ -3280,7 +3221,7 @@ async function createIsolatedCodexAppServerClient(options) {
3280
3221
  lifetime,
3281
3222
  authProfileId: usesNativeAuth || context.preparedAuth?.kind === "api-key" ? null : context.authProfileId,
3282
3223
  runtimeArtifactMode: options?.runtimeArtifactMode ?? (options?.expectedRuntimeArtifact ? "capture" : void 0),
3283
- ...options?.expectedRuntimeArtifact ? { expectedRuntimeArtifact: options.expectedRuntimeArtifact } : {},
3224
+ expectedRuntimeArtifact: options?.expectedRuntimeArtifact,
3284
3225
  config: options?.config,
3285
3226
  timeoutMs: resolveRemainingAcquireTimeout(timeoutMs, startedAt),
3286
3227
  abandonSignal,
@@ -3311,9 +3252,9 @@ async function startInitializedCodexAppServerClientOnce(params) {
3311
3252
  const acquireStartedAt = performance.now();
3312
3253
  const timeoutMs = params.timeoutMs ?? 0;
3313
3254
  const abandonSignal = params.abandonSignal ? AbortSignal.any([params.lifetime.controller.signal, params.abandonSignal]) : params.lifetime.controller.signal;
3314
- const waitForStartup = (operation, timeoutMessage = CODEX_APP_SERVER_INITIALIZE_TIMEOUT_MESSAGE, timeoutErrorFactory) => {
3255
+ const waitForStartup = (operation, timeoutErrorFactory) => {
3315
3256
  if (abandonSignal.aborted) throw new CodexAppServerStartupError("aborted", "codex app-server initialize aborted");
3316
- return withCodexAppServerAcquireDeadline(resolveRemainingAcquireTimeout(timeoutMs, acquireStartedAt), ownCodexStartup(params.lifetime, operation()), abandonSignal, timeoutMessage, timeoutErrorFactory);
3257
+ return withCodexAppServerAcquireDeadline(resolveRemainingAcquireTimeout(timeoutMs, acquireStartedAt), ownCodexStartup(params.lifetime, operation()), abandonSignal, CODEX_APP_SERVER_INITIALIZE_TIMEOUT_MESSAGE, timeoutErrorFactory);
3317
3258
  };
3318
3259
  const startOptionsCandidates = resolveManagedFallbackStartOptions(params.startOptions);
3319
3260
  for (const [index, startOptions] of startOptionsCandidates.entries()) {
@@ -3355,7 +3296,7 @@ async function startInitializedCodexAppServerClientOnce(params) {
3355
3296
  } finally {
3356
3297
  artifactDrain?.cancel();
3357
3298
  }
3358
- const runtimeArtifactModule = params.runtimeArtifactMode ? await import("./runtime-artifact-CUTOOnKw.mjs") : void 0;
3299
+ const runtimeArtifactModule = params.runtimeArtifactMode ? await import("./runtime-artifact-C13pR7tD.mjs") : void 0;
3359
3300
  const runtimeArtifactBeforeStart = runtimeArtifactModule ? await runtimeArtifactModule.captureCodexAppServerRuntimeArtifactBeforeStart({
3360
3301
  startOptions,
3361
3302
  spawnIdentity: resolveCodexAppServerSpawnIdentity(startOptions),
@@ -3402,7 +3343,7 @@ async function startInitializedCodexAppServerClientOnce(params) {
3402
3343
  params.onStartedClient?.(client);
3403
3344
  observeAcquire(params, { boundary: "initialize" });
3404
3345
  try {
3405
- await waitForStartup(() => client.initialize(), CODEX_APP_SERVER_INITIALIZE_TIMEOUT_MESSAGE, () => buildCodexAppServerInitializeTimeoutError(client));
3346
+ await waitForStartup(() => client.initialize(), () => buildCodexAppServerInitializeTimeoutError(client));
3406
3347
  } catch (error) {
3407
3348
  if (startOptions.commandSource === "resolved-managed" && index < startOptionsCandidates.length - 1 && isUnsupportedCodexAppServerVersionError(error)) continue;
3408
3349
  throw error;
@@ -3503,12 +3444,12 @@ function resolveManagedFallbackStartOptions(startOptions) {
3503
3444
  }
3504
3445
  return candidates;
3505
3446
  }
3447
+ function detachCurrentSharedClient(client) {
3448
+ const entry = client && getCurrentSharedClientEntry(client);
3449
+ return Boolean(entry && getSharedCodexAppServerClientState().clients.delete(entry.key));
3450
+ }
3506
3451
  function clearSharedCodexAppServerClientIfCurrent(client) {
3507
- if (!client) return false;
3508
- const state = getSharedCodexAppServerClientState();
3509
- const entry = getCurrentSharedClientEntry(client);
3510
- if (!entry) return false;
3511
- state.clients.delete(entry.key);
3452
+ if (!detachCurrentSharedClient(client)) return false;
3512
3453
  client.close();
3513
3454
  return true;
3514
3455
  }
@@ -3579,11 +3520,7 @@ function hasLiveOlderDesktopGenerationClient(params) {
3579
3520
  return false;
3580
3521
  }
3581
3522
  async function clearSharedCodexAppServerClientIfCurrentAndWait(client, options) {
3582
- if (!client) return false;
3583
- const state = getSharedCodexAppServerClientState();
3584
- const entry = getCurrentSharedClientEntry(client);
3585
- if (!entry) return false;
3586
- state.clients.delete(entry.key);
3523
+ if (!detachCurrentSharedClient(client)) return false;
3587
3524
  await client.closeAndWait(options);
3588
3525
  return true;
3589
3526
  }