@openclaw/codex 2026.10.1-beta.2 → 2026.10.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/.setup/{account-usage-runtime-DGqFpAud.mjs → account-usage-runtime-QBZsvZS8.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-CXTudl9p.mjs → apply-CBMV8LN0.mjs} +40 -51
  4. package/dist/.setup/{attempt-client-cleanup-BH0hW2xU.mjs → attempt-client-cleanup-t-kd_1ys.mjs} +6 -6
  5. package/dist/.setup/attempt-terminal-jO5IMj9K.mjs +2 -0
  6. package/dist/.setup/{attempt-workspace-context-BY0jprWJ.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-CGm0UJOr.mjs → auth-cache-key-DyfUvsSa.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-pGsfXcmH.mjs → bounded-turn-CyQVQwGe.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-CqQnsg7T.mjs → build-state-CzLMy1S9.mjs} +1 -1
  14. package/dist/.setup/{capabilities-kQntafj_.mjs → capabilities-DbOzOglY.mjs} +1 -1
  15. package/dist/.setup/{client-catalog-response-Bqp7WG51.mjs → client-catalog-response-DsbEAtpd.mjs} +25 -32
  16. package/dist/.setup/{client-C8lgBOoO.mjs → client-y7nO6X9c.mjs} +198 -247
  17. package/dist/.setup/{command-dispatch-DhBbFIQ5.mjs → command-dispatch-uA9lz2Kf.mjs} +3 -4
  18. package/dist/.setup/{command-formatters-DV3DHhdr.mjs → command-formatters-xW9KpoSZ.mjs} +16 -26
  19. package/dist/.setup/{command-handlers-ztOOzm6O.mjs → command-handlers-VBaJnpZo.mjs} +270 -360
  20. package/dist/.setup/{command-rpc-CuC5fPom.mjs → command-rpc-C9VxOLuG.mjs} +19 -18
  21. package/dist/.setup/{compact-tUb9AYfH.mjs → compact-CD8xJxXS.mjs} +41 -61
  22. package/dist/.setup/{computer-use-BBN9y326.mjs → computer-use-CiToXF5C.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-B3MNMVzb.mjs → conversation-binding-CTSLDM9S.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-CYsMlCuE.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-C8xGEXmR.mjs → dynamic-tool-build-D731PCdv.mjs} +57 -69
  38. package/dist/.setup/{dynamic-tools-DyERJnR6.mjs → dynamic-tools-D0pYbxHH.mjs} +689 -710
  39. package/dist/.setup/{effective-mcp-catalog-C26Mio5l.mjs → effective-mcp-catalog-1hWFKghy.mjs} +11 -20
  40. package/dist/.setup/{elicitation-input-r9axtppm.mjs → elicitation-input-DXG_qaXr.mjs} +14 -20
  41. package/dist/.setup/{ephemeral-turn-D8VcDTNo.mjs → ephemeral-turn-Cphy5Qr_.mjs} +3 -3
  42. package/dist/.setup/{event-projector-assistant-message-BN7CNUB5.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-C0jrcplS.mjs → isolated-completion-Bhqd2yBq.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-BxN0_CYe.mjs → mcp-app-session-preparation-DqSvxFqc.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-DZyNeDKG.mjs → model-catalog-B227ST3D.mjs} +6 -6
  56. package/dist/.setup/{models-DSseKSMg.mjs → models-DdRyi93L.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-BUWIOrSr.mjs +561 -0
  60. package/dist/.setup/{native-mcp-app-CqcPVmhH.mjs → native-mcp-app-CjxJQ4F7.mjs} +6 -6
  61. package/dist/.setup/native-skill-isolation-UMVoNjZz.mjs +391 -0
  62. package/dist/.setup/{native-subagent-monitor-BUYOUp9X.mjs → native-subagent-monitor-iHc8oLg5.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-BJ37d2Og.mjs → plan-C_F3aio0.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-CuahdPLC.mjs → plugin-approval-roundtrip-BSV-51ig.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-BnwHVD_z.mjs → provider-BJ4xhaGX.mjs} +4 -4
  76. package/dist/.setup/{provider-capabilities-D68Whix6.mjs → provider-capabilities-CjRaV3bx.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-jSbhc1sg.mjs → request-Y8dmbqZ3.mjs} +28 -48
  80. package/dist/.setup/{rpc-error-hmWM21RB.mjs → rpc-error-C98SHchT.mjs} +3 -6
  81. package/dist/.setup/{run-attempt-BLDZeYLD.mjs → run-attempt-Dx7a4Mfm.mjs} +927 -849
  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-Bdjw9HEn.mjs → session-catalog-events-DzFlXNUe.mjs} +6 -5
  94. package/dist/.setup/{session-catalog-index-DufISKJ6.mjs → session-catalog-index-DozvkUPd.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-D6IiLtMb.mjs → session-catalog-native-projection-rCKnZud1.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-8aHNwzWD.mjs → session-catalog-projection-DDVmALHj.mjs} +8 -22
  104. package/dist/.setup/session-catalog-source-CygTGmrb.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-Czbchv_O.mjs → session-retirement-IoS3zr17.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-DjZsIwbZ.mjs → settled-turn-finalizer-X-Fylp-u.mjs} +12 -11
  115. package/dist/.setup/{shared-client-qhyYWbew.mjs → shared-client-ByIwuAC-.mjs} +172 -229
  116. package/dist/.setup/{side-question-D3NJlgbl.mjs → side-question-BDUdozFy.mjs} +116 -137
  117. package/dist/.setup/{source-BYu0T780.mjs → source-Bxbqf3S1.mjs} +37 -56
  118. package/dist/.setup/thread-archive-guard-LKdwQKyr.mjs +56 -0
  119. package/dist/.setup/{thread-lifecycle-Cbz_7ySv.mjs → thread-lifecycle-run-CfP4PnEf.mjs} +348 -484
  120. package/dist/.setup/thread-model-selection-DcVebr8N.mjs +61 -0
  121. package/dist/.setup/{thread-ownership-DwuSrt3s.mjs → thread-ownership-Be53aiaG.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-DoNxbhqt.mjs → thread-policy-CHgY-KNl.mjs} +4 -4
  124. package/dist/.setup/thread-requests-BgzJwJtS.mjs +745 -0
  125. package/dist/.setup/{thread-resume-BT6NHMkM.mjs → thread-resume-B2EmMcgE.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-sS69wYnI.mjs → turn-router-DKDAziUW.mjs} +30 -31
  133. package/dist/.setup/upstream-prompt-provenance-Ccd9MFRJ.mjs +44 -0
  134. package/dist/.setup/{upstream-session-fork-ChSld66u.mjs → upstream-session-fork-Djp_yssT.mjs} +50 -43
  135. package/dist/.setup/{usage-D8e8Xiqf.mjs → usage-DQA-peQC.mjs} +4 -4
  136. package/dist/.setup/{usage-limit-error-GbT-5NcW.mjs → usage-limit-error-2t3KBqiX.mjs} +12 -21
  137. package/dist/.setup/web-search-item-CvokaZOo.mjs +20 -0
  138. package/dist/.setup/{web-search-provider.runtime-dL2GD1Kl.mjs → web-search-provider.runtime-BsuCMNix.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-B8LGaZNW.mjs +0 -124
  157. package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +0 -15
  158. package/dist/.setup/shell-dynamic-tools-D3Brj3g9.mjs +0 -85
  159. package/dist/.setup/thread-archive-guard-C9frICzX.mjs +0 -60
  160. package/dist/.setup/thread-requests-CL1e8Wmx.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-CqQnsg7T.mjs";
2
+ import { n as defineCodexBuildState, t as codexBuildSymbol } from "./build-state-CzLMy1S9.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-CGm0UJOr.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-DyfUvsSa.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-Bdjw9HEn.mjs";
15
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-cUYrqu_a.mjs";
14
+ import { n as observeCodexCatalogClient } from "./session-catalog-events-DzFlXNUe.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-C8lgBOoO.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-y7nO6X9c.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";
@@ -39,6 +39,7 @@ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
39
39
  import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
40
40
  //#region extensions/codex/src/app-server/attempt-timeouts.ts
41
41
  const CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS = 100;
42
+ const CODEX_APP_SERVER_STARTUP_REQUEST_TIMEOUT_MULTIPLE = 10;
42
43
  const TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS = 12e4;
43
44
  const TURN_FINALIZE_DRAIN_ABORT_GRACE_MS = 5e3;
44
45
  var CodexAppServerStartupError = class extends Error {
@@ -62,10 +63,8 @@ async function withCodexStartupTimeout(params) {
62
63
  try {
63
64
  return await Promise.race([params.operation(), new Promise((_, reject) => {
64
65
  const rejectOnce = (error) => {
65
- if (timeout) {
66
- clearTimeout(timeout);
67
- timeout = void 0;
68
- }
66
+ clearTimeout(timeout);
67
+ timeout = void 0;
69
68
  reject(error);
70
69
  };
71
70
  timeout = setTimeout(() => {
@@ -86,14 +85,19 @@ async function withCodexStartupTimeout(params) {
86
85
  }
87
86
  throw error;
88
87
  } finally {
89
- if (timeout) clearTimeout(timeout);
88
+ clearTimeout(timeout);
90
89
  abortCleanup?.();
91
90
  }
92
91
  }
92
+ /**
93
+ * Bounds app-server startup by the turn budget and, when known, by a multiple of
94
+ * the per-request timeout, so a turn with a long budget cannot hang silently in startup.
95
+ */
93
96
  function resolveCodexStartupTimeoutMs(params) {
94
97
  const timeoutFloorMs = resolveTimerTimeoutMs(params.timeoutFloorMs, CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS);
95
- const timeoutMs = resolveTimerTimeoutMs(params.timeoutMs, timeoutFloorMs);
96
- return Math.max(timeoutFloorMs, timeoutMs);
98
+ const turnTimeoutMs = resolveTimerTimeoutMs(params.timeoutMs, timeoutFloorMs);
99
+ const requestBudgetMs = params.requestTimeoutMs === void 0 ? turnTimeoutMs : resolveTimerTimeoutMs(params.requestTimeoutMs * CODEX_APP_SERVER_STARTUP_REQUEST_TIMEOUT_MULTIPLE, turnTimeoutMs);
100
+ return Math.max(timeoutFloorMs, Math.min(turnTimeoutMs, requestBudgetMs));
97
101
  }
98
102
  function resolveCodexGatewayTimeoutWithGraceMs(timeoutMs, graceMs = 1e4) {
99
103
  const timeout = resolveTimerTimeoutMs(timeoutMs, 1);
@@ -110,13 +114,7 @@ async function assertOwnedServicePath(params) {
110
114
  allowMissing: true
111
115
  });
112
116
  assertPathAtOrInside(params.ownershipRoot, params.targetParent, "Computer Use service parent");
113
- await assertNoSymlinkParents({
114
- rootDir: params.ownershipRoot,
115
- targetPath: params.targetParent,
116
- allowMissing: true,
117
- requireDirectories: true,
118
- messagePrefix: "Computer Use service path"
119
- });
117
+ await assertServicePathParents(params.ownershipRoot, params.targetParent, true);
120
118
  await assertNotSymlink(params.targetPath, "Computer Use service target");
121
119
  }
122
120
  async function ensureOwnedCodexHome(codexHomeInput, ownershipRootInput = path.dirname(path.resolve(codexHomeInput))) {
@@ -141,13 +139,7 @@ async function ensureOwnedCodexHome(codexHomeInput, ownershipRootInput = path.di
141
139
  async function prepareOwnedServiceParent(params) {
142
140
  await ensureOwnedCodexHome(params.codexHome, params.ownershipRoot);
143
141
  await ensureRealDirectoryTree(params.ownershipRoot, params.targetParent, "Computer Use service parent");
144
- await assertNoSymlinkParents({
145
- rootDir: params.ownershipRoot,
146
- targetPath: params.targetParent,
147
- allowMissing: false,
148
- requireDirectories: true,
149
- messagePrefix: "Computer Use service path"
150
- });
142
+ await assertServicePathParents(params.ownershipRoot, params.targetParent, false);
151
143
  const [rootIdentity, parentIdentity] = await Promise.all([readRealDirectoryIdentity(params.ownershipRoot, "Computer Use ownership root"), readRealDirectoryIdentity(params.targetParent, "Computer Use service parent")]);
152
144
  assertPathAtOrInside(rootIdentity.realPath, parentIdentity.realPath, "canonical Computer Use service parent");
153
145
  return parentIdentity;
@@ -155,10 +147,13 @@ async function prepareOwnedServiceParent(params) {
155
147
  async function assertOwnedCodexHomePath(params) {
156
148
  await readRealDirectoryIdentity(params.ownershipRoot, "Computer Use ownership root");
157
149
  assertPathAtOrInside(params.ownershipRoot, params.codexHome, "isolated Codex home");
158
- await assertNoSymlinkParents({
159
- rootDir: params.ownershipRoot,
160
- targetPath: params.codexHome,
161
- 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,
162
157
  requireDirectories: true,
163
158
  messagePrefix: "Computer Use service path"
164
159
  });
@@ -176,9 +171,6 @@ async function readRealDirectoryIdentity(directoryPath, label) {
176
171
  throw new Error(`${label} must remain a real directory: ${logicalPath}`, { cause });
177
172
  }
178
173
  }
179
- async function assertOwnedServiceParentStable(parent) {
180
- await assertDirectoryIdentityStable(parent, "Computer Use service parent");
181
- }
182
174
  async function assertDirectoryIdentityStable(expected, label) {
183
175
  if (!await directoryIdentityIsStable(expected)) throw new Error(`${label} changed during refresh; refusing to mutate the replacement path.`);
184
176
  }
@@ -395,15 +387,18 @@ async function resolveManagedCodexComputerUseConfig(config, marketplacePath) {
395
387
  }
396
388
  /** A native plugin disable veto must survive an automatic identity replacement. */
397
389
  function isLegacyCodexComputerUsePluginDisabled(config) {
398
- const plugin = isRecord(config) && isRecord(config.plugins) ? config.plugins["computer-use@openai-bundled"] : void 0;
399
- return isRecord(plugin) && plugin.enabled === false;
390
+ return readLegacyComputerUsePlugin(config)?.enabled === false;
400
391
  }
401
392
  /** Renaming a server must not discard an operator's legacy server or tool restrictions. */
402
393
  function hasLegacyCodexComputerUseMcpPolicy(config) {
403
394
  if (!isRecord(config)) return false;
404
395
  if (isRecord(config.mcp_servers) && Object.hasOwn(config.mcp_servers, "computer-use")) return true;
405
- const plugin = isRecord(config.plugins) ? config.plugins["computer-use@openai-bundled"] : void 0;
406
- 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"]);
407
402
  }
408
403
  async function readObject(file) {
409
404
  try {
@@ -622,6 +617,7 @@ const CLIENT_BUNDLE_ID = "com.openai.sky.CUAService.cli";
622
617
  const OPENAI_TEAM_ID = "2DC432GLL2";
623
618
  const CLIENT_APP_RELATIVE_PATH = path.join("Contents", "SharedSupport", "SkyComputerUseClient.app");
624
619
  const CLIENT_RELATIVE_PATH = path.join(CLIENT_APP_RELATIVE_PATH, "Contents", "MacOS", "SkyComputerUseClient");
620
+ const SERVICE_PARENT_LABEL = "Computer Use service parent";
625
621
  const COPY_TIMEOUT_MS = 12e4;
626
622
  const INSPECT_TIMEOUT_MS = 3e4;
627
623
  const activeInstalls = /* @__PURE__ */ new Map();
@@ -701,31 +697,31 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
701
697
  await assertNotSymlink(operationTargetPath, "Computer Use service target");
702
698
  const initialTarget = await readServiceAppSnapshot(operationTargetPath, inspectServiceApp);
703
699
  if (initialTarget.identity && identitiesMatch(initialTarget.identity, sourceIdentity)) return alreadyCurrent;
704
- await assertOwnedServiceParentStable(ownedParent);
700
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
705
701
  const stagingRoot = await fs$1.mkdtemp(path.join(ownedParent.realPath, ".service-app.staging-"));
706
702
  const stagingRootIdentity = await readRealDirectoryIdentity(stagingRoot, "Computer Use service staging directory");
707
703
  const stagedPath = path.join(stagingRoot, SERVICE_APP_NAME);
708
704
  const backupPath = path.join(ownedParent.realPath, `.service-app.backup-${process.pid}-${Date.now()}`);
709
705
  let backupCreated = false;
710
706
  const restoreBackup = async () => {
711
- await assertOwnedServiceParentStable(ownedParent);
707
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
712
708
  await fs$1.rename(backupPath, operationTargetPath);
713
- await assertOwnedServiceParentStable(ownedParent);
709
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
714
710
  backupCreated = false;
715
711
  };
716
712
  const removeBackup = async () => {
717
- await assertOwnedServiceParentStable(ownedParent);
713
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
718
714
  await assertNotSymlink(backupPath, "Computer Use service backup");
719
715
  await fs$1.rm(backupPath, {
720
716
  recursive: true,
721
717
  force: true
722
718
  });
723
- await assertOwnedServiceParentStable(ownedParent);
719
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
724
720
  backupCreated = false;
725
721
  };
726
722
  try {
727
723
  await (params.copyServiceApp ?? copyServiceAppWithDitto)(sourcePath, stagedPath);
728
- await assertOwnedServiceParentStable(ownedParent);
724
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
729
725
  await assertDirectoryIdentityStable(stagingRootIdentity, "Computer Use service staging directory");
730
726
  await assertNotSymlink(stagedPath, "Copied Computer Use service app");
731
727
  const stagedIdentity = await inspectServiceApp(stagedPath);
@@ -733,15 +729,15 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
733
729
  const stagedSnapshot = await readServiceAppSnapshot(stagedPath, inspectServiceApp);
734
730
  const currentSourceIdentity = await inspectServiceApp(sourcePath);
735
731
  await waitForCodexDesktopGeneration();
736
- await assertOwnedServiceParentStable(ownedParent);
732
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
737
733
  await assertDirectoryIdentityStable(stagingRootIdentity, "Computer Use service staging directory");
738
734
  if (!currentSourceIdentity || !identitiesMatch(currentSourceIdentity, sourceIdentity)) throw new Error("Selected Computer Use service source changed during refresh.");
739
735
  await assertNotSymlink(operationTargetPath, "Computer Use service target");
740
736
  if (await pathExists$1(operationTargetPath)) {
741
- await assertOwnedServiceParentStable(ownedParent);
737
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
742
738
  params.assertCurrent?.();
743
739
  await fs$1.rename(operationTargetPath, backupPath);
744
- await assertOwnedServiceParentStable(ownedParent);
740
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
745
741
  backupCreated = true;
746
742
  const movedTarget = await readServiceAppSnapshot(backupPath, inspectServiceApp);
747
743
  if (movedTarget.identity && identitiesMatch(movedTarget.identity, sourceIdentity)) {
@@ -754,12 +750,12 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
754
750
  }
755
751
  }
756
752
  try {
757
- await assertOwnedServiceParentStable(ownedParent);
753
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
758
754
  params.assertCurrent?.();
759
755
  await fs$1.rename(stagedPath, operationTargetPath);
760
- await assertOwnedServiceParentStable(ownedParent);
756
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
761
757
  } catch (error) {
762
- await assertOwnedServiceParentStable(ownedParent);
758
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
763
759
  await assertNotSymlink(operationTargetPath, "Computer Use service target");
764
760
  const winnerIdentity = await inspectServiceApp(operationTargetPath);
765
761
  if (!winnerIdentity || !identitiesMatch(winnerIdentity, sourceIdentity)) {
@@ -773,15 +769,15 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
773
769
  const installedSnapshot = await readServiceAppSnapshot(operationTargetPath, inspectServiceApp);
774
770
  if (!installedSnapshot.identity || !identitiesMatch(installedSnapshot.identity, sourceIdentity)) {
775
771
  if (filesystemSnapshotsMatch(installedSnapshot, stagedSnapshot)) {
776
- await assertOwnedServiceParentStable(ownedParent);
772
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
777
773
  await fs$1.rm(operationTargetPath, {
778
774
  recursive: true,
779
775
  force: true
780
776
  });
781
- await assertOwnedServiceParentStable(ownedParent);
777
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
782
778
  if (backupCreated) {
783
779
  await fs$1.rename(backupPath, operationTargetPath);
784
- await assertOwnedServiceParentStable(ownedParent);
780
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
785
781
  backupCreated = false;
786
782
  }
787
783
  }
@@ -789,16 +785,14 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
789
785
  }
790
786
  if (backupCreated) await removeBackup();
791
787
  return {
788
+ ...alreadyCurrent,
792
789
  status: initialTarget.exists ? "refreshed" : "installed",
793
790
  changed: true,
794
- targetPath: params.targetPath,
795
- sourcePath,
796
- sourceBuild: sourceIdentity.build,
797
791
  ...initialTarget.identity ? { previousBuild: initialTarget.identity.build } : {}
798
792
  };
799
793
  } catch (error) {
800
794
  if (backupCreated && await directoryIdentityIsStable(ownedParent) && !await pathExists$1(operationTargetPath)) {
801
- await assertOwnedServiceParentStable(ownedParent);
795
+ await assertDirectoryIdentityStable(ownedParent, SERVICE_PARENT_LABEL);
802
796
  await fs$1.rename(backupPath, operationTargetPath);
803
797
  backupCreated = false;
804
798
  }
@@ -836,7 +830,7 @@ async function readServiceAppFilesystemKey(appPath) {
836
830
  path.join(appPath, "Contents", "Info.plist"),
837
831
  path.join(appPath, CLIENT_RELATIVE_PATH)
838
832
  ];
839
- 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("|");
840
834
  }
841
835
  function snapshotsMatch(left, right) {
842
836
  if (left.exists !== right.exists) return false;
@@ -846,7 +840,7 @@ function snapshotsMatch(left, right) {
846
840
  return left.filesystemKey !== void 0 && left.filesystemKey === right.filesystemKey;
847
841
  }
848
842
  function filesystemSnapshotsMatch(left, right) {
849
- 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);
850
844
  }
851
845
  function identitiesMatch(left, right) {
852
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;
@@ -950,12 +944,8 @@ async function copyServiceAppWithDitto(sourcePath, targetPath) {
950
944
  const OPENAI_CODEX_DEFAULT_PROFILE_ID = "openai:default";
951
945
  const CODEX_HOME_ENV_VAR = "CODEX_HOME";
952
946
  const HOME_ENV_VAR = "HOME";
953
- const CODEX_APP_SERVER_PREPARED_AUTH_ENV_VARS = [
954
- "CODEX_API_KEY",
955
- "OPENAI_API_KEY",
956
- "CODEX_ACCESS_TOKEN"
957
- ];
958
- 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]);
959
949
  const MAX_COMPUTER_USE_ARTIFACT_OWNERS = 128;
960
950
  const activeComputerUseArtifactReconciliations = /* @__PURE__ */ new Map();
961
951
  const scopedOAuthRefreshQueues = /* @__PURE__ */ new WeakMap();
@@ -1139,9 +1129,10 @@ async function withCodexHomeEnvironment(startOptions, agentDir) {
1139
1129
  ...nativeHome ? { [HOME_ENV_VAR]: nativeHome } : {}
1140
1130
  }
1141
1131
  };
1142
- const clearEnv = withoutClearedCodexHomeEnv(startOptions.clearEnv);
1143
- if (clearEnv) nextStartOptions.clearEnv = clearEnv;
1144
- 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;
1145
1136
  return nextStartOptions;
1146
1137
  }
1147
1138
  /** Reconciles Computer Use artifacts for the exact managed command about to start. */
@@ -1150,16 +1141,12 @@ async function reconcileCodexComputerUseStartArtifacts(params) {
1150
1141
  const codexHome = resolveCodexAppServerLocalHomeDir(params.startOptions, params.agentDir);
1151
1142
  const key = path.resolve(codexHome);
1152
1143
  let owner = activeComputerUseArtifactReconciliations.get(key);
1153
- if (!owner) {
1154
- owner = {
1155
- active: 0,
1156
- tail: Promise.resolve()
1157
- };
1158
- activeComputerUseArtifactReconciliations.set(key, owner);
1159
- } else {
1160
- activeComputerUseArtifactReconciliations.delete(key);
1161
- activeComputerUseArtifactReconciliations.set(key, owner);
1162
- }
1144
+ if (!owner) owner = {
1145
+ active: 0,
1146
+ tail: Promise.resolve()
1147
+ };
1148
+ else activeComputerUseArtifactReconciliations.delete(key);
1149
+ activeComputerUseArtifactReconciliations.set(key, owner);
1163
1150
  owner.active += 1;
1164
1151
  const epoch = params.desktopGeneration?.epoch;
1165
1152
  if (epoch !== void 0 && (owner.latestEpoch === void 0 || epoch > owner.latestEpoch)) owner.latestEpoch = epoch;
@@ -1167,7 +1154,7 @@ async function reconcileCodexComputerUseStartArtifacts(params) {
1167
1154
  params.assertCurrent?.();
1168
1155
  if (epoch !== void 0 && owner.latestEpoch !== epoch) throw new Error("Codex Computer Use artifact reconciliation was superseded.");
1169
1156
  };
1170
- const operation = owner.tail.catch(() => void 0).then(async () => {
1157
+ const operation = owner.tail.then(async () => {
1171
1158
  assertCurrent();
1172
1159
  const appliedCacheBinding = await reconcileCodexComputerUseStartArtifactsOnce({
1173
1160
  ...params,
@@ -1178,7 +1165,7 @@ async function reconcileCodexComputerUseStartArtifacts(params) {
1178
1165
  assertCurrent();
1179
1166
  owner.appliedCacheBinding = appliedCacheBinding;
1180
1167
  });
1181
- const settled = operation.then(() => void 0, () => void 0);
1168
+ const settled = operation.catch(() => void 0);
1182
1169
  owner.tail = settled;
1183
1170
  try {
1184
1171
  await operation;
@@ -1277,12 +1264,6 @@ var CodexComputerUseCandidateArtifactsUnavailableError = class extends Error {
1277
1264
  this.name = "CodexComputerUseCandidateArtifactsUnavailableError";
1278
1265
  }
1279
1266
  };
1280
- function withoutClearedCodexHomeEnv(clearEnv) {
1281
- if (!clearEnv) return;
1282
- const reserved = new Set(CODEX_APP_SERVER_HOME_ENV_VARS);
1283
- const filtered = clearEnv.filter((envVar) => !reserved.has(envVar.trim().toUpperCase()));
1284
- return filtered.length === clearEnv.length ? clearEnv : filtered;
1285
- }
1286
1267
  async function applyCodexAppServerAuthProfile(params) {
1287
1268
  params.assertCurrent?.();
1288
1269
  if (!params.preparedAuth && params.authProfileId === null) {
@@ -1350,7 +1331,7 @@ function createCodexAppServerAuthError(message) {
1350
1331
  async function refreshCodexAppServerAuthTokens(params) {
1351
1332
  const previousAccountId = params.previousAccountId?.trim();
1352
1333
  const handoffAccountId = params.authHandoff?.chatgptAccountId.trim();
1353
- 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");
1354
1335
  if (previousAccountId) {
1355
1336
  const store = resolveCodexAppServerAuthProfileStore(params);
1356
1337
  const profileId = resolveCodexAppServerAuthProfileId({
@@ -1359,14 +1340,14 @@ async function refreshCodexAppServerAuthTokens(params) {
1359
1340
  });
1360
1341
  const credential = profileId ? store.profiles[profileId] : void 0;
1361
1342
  const selectedAccountId = credential ? resolveExplicitChatgptAccountId(credential) ?? (credential.type === "oauth" ? resolveOpenAICodexAuthIdentity({ access: credential.access }).accountId : void 0) : void 0;
1362
- 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");
1363
1344
  }
1364
1345
  const loginParams = await resolveCodexAppServerAuthProfileLoginParamsInternal({
1365
1346
  ...params,
1366
1347
  forceOAuthRefresh: true
1367
1348
  });
1368
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.");
1369
- 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");
1370
1351
  return {
1371
1352
  accessToken: loginParams.accessToken,
1372
1353
  chatgptAccountId: loginParams.chatgptAccountId,
@@ -1383,32 +1364,14 @@ async function resolveCodexAppServerAuthProfileLoginParamsInternal(params) {
1383
1364
  const credential = store.profiles[profileId];
1384
1365
  if (!credential) throw new CodexAppServerAuthProfileUnavailableError(formatCodexAuthProfileUnavailableMessage(profileId));
1385
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.`);
1386
- const loginParams = await resolveLoginParamsForCredential(profileId, credential, {
1387
- agentDir: params.agentDir,
1388
- store,
1389
- preferStoreCredential: Boolean(params.authProfileStore?.profiles[profileId]),
1390
- forceOAuthRefresh: params.forceOAuthRefresh === true,
1391
- authHandoff: params.authHandoff,
1392
- previousAccountId: params.previousAccountId,
1393
- config: params.config
1394
- });
1395
- 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.`);
1396
- return loginParams;
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
- };
1406
- }
1407
- 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;
1408
1371
  if (credential.type === "api_key" || credential.type === "token") {
1409
- const value = (await resolveApiKeyForProfile({
1372
+ value = (await resolveApiKeyForProfile({
1410
1373
  cfg: params.config,
1411
- store: params.preferStoreCredential ? params.store : ensureAuthProfileStore(params.agentDir, {
1374
+ store: preferStoreCredential ? store : ensureAuthProfileStore(params.agentDir, {
1412
1375
  allowKeychainPrompt: false,
1413
1376
  profileId,
1414
1377
  config: params.config
@@ -1416,23 +1379,30 @@ async function resolveLoginParamsForCredential(profileId, credential, params) {
1416
1379
  profileId,
1417
1380
  agentDir: params.agentDir
1418
1381
  }))?.apiKey?.trim();
1419
- if (!value) return;
1420
- return credential.type === "api_key" ? {
1421
- type: "apiKey",
1422
- apiKey: value
1423
- } : 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();
1424
1391
  }
1425
- const resolvedCredential = await resolveOAuthCredentialForCodexAppServer(profileId, credential, {
1426
- agentDir: params.agentDir,
1427
- store: params.store,
1428
- preferStoreCredential: params.preferStoreCredential,
1429
- forceRefresh: params.forceOAuthRefresh,
1430
- authHandoff: params.authHandoff,
1431
- previousAccountId: params.previousAccountId,
1432
- config: params.config
1433
- });
1434
- const accessToken = resolvedCredential.access?.trim();
1435
- 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
+ };
1436
1406
  }
1437
1407
  async function resolveOAuthCredentialForCodexAppServer(profileId, credential, params) {
1438
1408
  const ownerAgentDir = resolvePersistedAuthProfileOwnerAgentDir({
@@ -1443,13 +1413,9 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1443
1413
  agentDir: ownerAgentDir,
1444
1414
  profileId
1445
1415
  });
1446
- const useScopedCredential = params.preferStoreCredential && shouldUseScopedOAuthCredential({
1447
- store: params.store,
1448
- profileId,
1449
- persistedCredential,
1450
- suppliedCredential: credential
1451
- });
1452
- 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.`);
1453
1419
  const store = useScopedCredential ? params.store : resolveCodexAppServerAuthProfileStore({
1454
1420
  agentDir: ownerAgentDir,
1455
1421
  authProfileId: profileId,
@@ -1466,7 +1432,7 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1466
1432
  });
1467
1433
  const selectedAccountId = currentCredential ? resolveOpenAICodexAuthIdentity(currentCredential).accountId?.trim() : void 0;
1468
1434
  const callbackAccountId = params.authHandoff?.chatgptAccountId.trim() ?? params.previousAccountId?.trim() ?? void 0;
1469
- 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");
1470
1436
  const expectedAccountId = callbackAccountId ?? selectedAccountId;
1471
1437
  if (useScopedCredential && overlaidOAuthCredential) return await resolveScopedOAuthCredential({
1472
1438
  store,
@@ -1477,7 +1443,6 @@ async function resolveOAuthCredentialForCodexAppServer(profileId, credential, pa
1477
1443
  config: params.config
1478
1444
  });
1479
1445
  if (params.forceRefresh && !persistedOAuthCredential && overlaidOAuthCredential) {
1480
- if (reuseCompletedRotation) return overlaidOAuthCredential;
1481
1446
  const refreshedRuntimeCredential = await refreshOAuthCredentialForRuntime({
1482
1447
  credential: overlaidOAuthCredential,
1483
1448
  cfg: params.config
@@ -1512,12 +1477,6 @@ function shouldReuseCompletedCodexOAuthRotation(params) {
1512
1477
  const previousAccountId = params.previousAccountId?.trim();
1513
1478
  return accountId === handoff.chatgptAccountId && (!previousAccountId || previousAccountId === handoff.chatgptAccountId);
1514
1479
  }
1515
- function shouldUseScopedOAuthCredential(params) {
1516
- if (!params.store.runtimePersistedProfileIds?.includes(params.profileId)) return true;
1517
- const persisted = params.persistedCredential;
1518
- if (persisted?.type !== "oauth" || !isCodexAppServerAuthProvider(persisted.provider)) return false;
1519
- return !isDeepStrictEqual(persisted, params.suppliedCredential) && !hasMatchingOAuthIdentity(persisted, params.suppliedCredential);
1520
- }
1521
1480
  function hasMatchingOAuthIdentity(persisted, supplied) {
1522
1481
  const persistedAccountId = resolveOpenAICodexAuthIdentity(persisted).accountId?.trim();
1523
1482
  const suppliedAccountId = resolveOpenAICodexAuthIdentity(supplied).accountId?.trim();
@@ -1557,9 +1516,12 @@ async function resolveScopedOAuthCredential(params) {
1557
1516
  if (storeRefreshes.get(params.profileId) === refresh) storeRefreshes.delete(params.profileId);
1558
1517
  }
1559
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
+ }
1560
1522
  function assertCodexOAuthRefreshWorkspace(profileId, credential, expectedAccountId) {
1561
1523
  if (!expectedAccountId) return;
1562
- 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");
1563
1525
  }
1564
1526
  function isCodexAppServerAuthProvider(provider) {
1565
1527
  return provider.trim().toLowerCase() === CODEX_APP_SERVER_AUTH_PROVIDER;
@@ -1595,10 +1557,7 @@ function resolveStableChatgptAccountId(credential) {
1595
1557
  return resolveExplicitChatgptAccountId(credential) ?? (credential.email?.trim() || void 0);
1596
1558
  }
1597
1559
  function resolveExplicitChatgptAccountId(credential) {
1598
- if ("accountId" in credential && typeof credential.accountId === "string") {
1599
- const accountId = credential.accountId.trim();
1600
- if (accountId) return accountId;
1601
- }
1560
+ return "accountId" in credential && typeof credential.accountId === "string" ? credential.accountId.trim() || void 0 : void 0;
1602
1561
  }
1603
1562
  //#endregion
1604
1563
  //#region extensions/codex/src/app-server/client-thread-owner.ts
@@ -1787,12 +1746,19 @@ function readRecentCodexRateLimits(client, options) {
1787
1746
  }
1788
1747
  function mergeRateLimitUpdate(current, update) {
1789
1748
  const currentEnvelope = isJsonObject(current) ? current : void 0;
1790
- const currentPrimary = currentEnvelope && isJsonObject(currentEnvelope.rateLimits) ? currentEnvelope.rateLimits : void 0;
1791
- const currentByLimitId = currentEnvelope && isJsonObject(currentEnvelope.rateLimitsByLimitId) ? currentEnvelope.rateLimitsByLimitId : void 0;
1749
+ const currentPrimary = readObjectField(currentEnvelope, "rateLimits");
1750
+ const currentByLimitId = readObjectField(currentEnvelope, "rateLimitsByLimitId");
1792
1751
  const limitId = readLimitId(update);
1793
1752
  const currentPrimaryLimitId = currentPrimary ? readLimitId(currentPrimary) : void 0;
1794
- const currentForLimit = (currentByLimitId && isJsonObject(currentByLimitId[limitId]) ? currentByLimitId[limitId] : void 0) ?? (currentPrimaryLimitId === limitId ? currentPrimary : void 0);
1795
- 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
+ }
1796
1762
  const nextPrimary = !currentPrimary || currentPrimaryLimitId === limitId ? merged : currentPrimary;
1797
1763
  let nextByLimitId;
1798
1764
  if (currentByLimitId) nextByLimitId = {
@@ -1819,24 +1785,20 @@ function readRateLimitIds(value) {
1819
1785
  }
1820
1786
  return [...ids];
1821
1787
  }
1822
- function mergeSparseSnapshot(current, accountFallback, update, limitId) {
1823
- const merged = {
1824
- ...update,
1825
- limitId
1826
- };
1827
- for (const key of SPARSE_ACCOUNT_METADATA_KEYS) {
1828
- const previous = current?.[key] ?? accountFallback?.[key];
1829
- if (merged[key] == null && previous != null) merged[key] = previous;
1830
- }
1831
- return merged;
1832
- }
1833
1788
  function readLimitId(snapshot) {
1834
1789
  const value = snapshot.limitId;
1835
1790
  return typeof value === "string" && value.trim() ? value.trim() : "codex";
1836
1791
  }
1792
+ function readObjectField(value, key) {
1793
+ return value && isJsonObject(value[key]) ? value[key] : void 0;
1794
+ }
1837
1795
  //#endregion
1838
1796
  //#region extensions/codex/src/app-server/client-runtime.ts
1839
- /** 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
+ }
1840
1802
  /** Match Codex's native grace window without retaining inactive conversations indefinitely. */
1841
1803
  const CODEX_APP_SERVER_LIVE_THREAD_IDLE_TIMEOUT_MS = 18e5;
1842
1804
  /** Native-child parents are active ownership, so only otherwise-idle threads count against this cap. */
@@ -1893,10 +1855,8 @@ function ensureCodexAppServerClientRuntime(client, context) {
1893
1855
  configuredClients.set(client, runtime);
1894
1856
  client.addCloseHandler(() => {
1895
1857
  runtime.closed = true;
1896
- if (runtime.evictionTimer) {
1897
- clearTimeout(runtime.evictionTimer);
1898
- runtime.evictionTimer = void 0;
1899
- }
1858
+ clearTimeout(runtime.evictionTimer);
1859
+ runtime.evictionTimer = void 0;
1900
1860
  for (const threadId of /* @__PURE__ */ new Set([
1901
1861
  ...runtime.retainedThreads.keys(),
1902
1862
  ...runtime.claimedThreads.keys(),
@@ -1957,10 +1917,8 @@ function ensureCodexAppServerClientRuntime(client, context) {
1957
1917
  });
1958
1918
  }
1959
1919
  function scheduleRetainedThreadEviction(client, runtime) {
1960
- if (runtime.evictionTimer) {
1961
- clearTimeout(runtime.evictionTimer);
1962
- runtime.evictionTimer = void 0;
1963
- }
1920
+ clearTimeout(runtime.evictionTimer);
1921
+ runtime.evictionTimer = void 0;
1964
1922
  if (runtime.closed) return;
1965
1923
  let expiresAt = Number.POSITIVE_INFINITY;
1966
1924
  for (const [threadId, thread] of runtime.retainedThreads) if (!runtime.protectedThreads.has(threadId)) expiresAt = Math.min(expiresAt, thread.expiresAt);
@@ -2049,9 +2007,7 @@ async function retainCodexAppServerLiveThread(client, threadId, releaseThread, c
2049
2007
  ephemeralPolicy,
2050
2008
  serviceTier,
2051
2009
  expiresAt: ephemeralPolicy === void 0 ? Date.now() + CODEX_APP_SERVER_LIVE_THREAD_IDLE_TIMEOUT_MS : Number.POSITIVE_INFINITY,
2052
- release: (releaseThread ? physicalThreadReleases.get(releaseThread) ?? releaseThread : void 0) ?? (async (releasedThreadId, assertCurrent, withCurrent) => {
2053
- await unsubscribeCodexAppServerLiveThread(client, releasedThreadId, 5e3, assertCurrent, withCurrent);
2054
- })
2010
+ release: (releaseThread ? physicalThreadReleases.get(releaseThread) ?? releaseThread : void 0) ?? defaultThreadRelease(client)
2055
2011
  };
2056
2012
  runtime.retainedThreads.set(threadId, retained);
2057
2013
  if (previousOwner !== ownerToken) previousOwner?.invalidate();
@@ -2095,9 +2051,7 @@ async function claimCodexAppServerLiveThread(client, threadId, onInvalidated) {
2095
2051
  }
2096
2052
  return claimCodexAppServerThreadOwnership(client, runtime, threadId, runtime.retainedThreads.get(threadId) ?? {
2097
2053
  expiresAt: Date.now() + CODEX_APP_SERVER_LIVE_THREAD_IDLE_TIMEOUT_MS,
2098
- release: async (releasedThreadId, assertCurrent, withCurrent) => {
2099
- await unsubscribeCodexAppServerLiveThread(client, releasedThreadId, 5e3, assertCurrent, withCurrent);
2100
- }
2054
+ release: defaultThreadRelease(client)
2101
2055
  }, onInvalidated);
2102
2056
  }
2103
2057
  function claimCodexAppServerThreadOwnership(client, runtime, threadId, retained, onInvalidated) {
@@ -2312,15 +2266,13 @@ function supportsInferenceEnvironment(native) {
2312
2266
  const lower = upper.toLowerCase();
2313
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;
2314
2268
  }
2315
- const value = (name) => (native[name] ?? native[name.toLowerCase()])?.trim() || void 0;
2316
- const http = value("HTTP_PROXY");
2317
- const https = value("HTTPS_PROXY");
2318
- 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);
2319
2271
  if (!http && !https && !all) return true;
2320
2272
  const noProxy = native.NO_PROXY ?? native.no_proxy ?? "";
2321
2273
  if (noProxy === "*") return true;
2322
2274
  if (native.REQUEST_METHOD !== void 0 || names.slice(0, 3).some((name) => {
2323
- const raw = native[name] ?? native[name.toLowerCase()];
2275
+ const raw = value(name);
2324
2276
  return raw !== void 0 && raw !== raw.trim();
2325
2277
  })) return false;
2326
2278
  if ((https ?? all) !== (https ?? http ?? all)) return false;
@@ -2360,8 +2312,7 @@ function projectProviderRoutes(config, providers) {
2360
2312
  return projected;
2361
2313
  }
2362
2314
  function readProviderBaseUrl(config, provider) {
2363
- if (provider === "openai") return config?.openai_base_url;
2364
- return readProviderField(config, provider, "base_url");
2315
+ return provider === "openai" ? config?.openai_base_url : readProviderField(config, provider, "base_url");
2365
2316
  }
2366
2317
  function readProviderField(config, provider, field) {
2367
2318
  const selected = (isJsonObject(config?.model_providers) ? config.model_providers : void 0)?.[provider];
@@ -2449,6 +2400,7 @@ async function prepareCodexInferenceRoute(params) {
2449
2400
  ...params.authority ? { withCurrent: params.authority.withCurrent } : {}
2450
2401
  });
2451
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);
2452
2404
  const unsupported = () => {
2453
2405
  if (owner.oauth) throw new Error("ChatGPT subscription sharing requires the managed public Responses inference route.");
2454
2406
  };
@@ -2467,7 +2419,7 @@ async function prepareCodexInferenceRoute(params) {
2467
2419
  "ollama",
2468
2420
  "lmstudio"
2469
2421
  ].includes(provider) || hasProviderAws(params.config, provider) || hasProviderAws(snapshot.config, provider) || wireApi != null && wireApi !== "responses")) return unsupported();
2470
- 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();
2471
2423
  const configured = customProvider ? providerField("base_url") : params.config?.openai_base_url ?? snapshot.config.openai_base_url;
2472
2424
  if (configured != null && typeof configured !== "string") throw new Error("Codex inference upstream configuration is invalid");
2473
2425
  if (typeof configured === "string" && (!configured.trim() || configured.includes("?") || configured.includes("#"))) return unsupported();
@@ -2506,7 +2458,7 @@ async function prepareCodexInferenceRoute(params) {
2506
2458
  "windows.net/openai"
2507
2459
  ].some((marker) => nativeBaseUrl.includes(marker));
2508
2460
  const preserveCodexBackendRoutes = nativeProviderName === "OpenAI" && (configured == null || configured.replace(/\/+$/, "").endsWith("/backend-api/codex"));
2509
- 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");
2510
2462
  const modelPolicyEnforced = params.modelPolicyEnforced !== false;
2511
2463
  const key = JSON.stringify([
2512
2464
  provider,
@@ -2528,9 +2480,9 @@ async function prepareCodexInferenceRoute(params) {
2528
2480
  throw new Error("Codex inference route limit reached; start a fresh managed native connection before retrying.");
2529
2481
  }
2530
2482
  pending = Promise.all([
2531
- import("./inference-proxy-DUO5E2QQ.mjs"),
2532
- import("./native-subagent-monitor-BUYOUp9X.mjs").then((n) => n.n),
2533
- import("./inference-dispatch-B5UKEUyC.mjs")
2483
+ import("./inference-proxy-BDWV0djM.mjs"),
2484
+ import("./native-subagent-monitor-iHc8oLg5.mjs").then((n) => n.n),
2485
+ import("./inference-dispatch-CO6tTs4q.mjs")
2534
2486
  ]).then(([{ createCodexInferenceProxy }, native, { createCodexInferenceModelBinding }]) => {
2535
2487
  assertClient();
2536
2488
  return createCodexInferenceProxy({
@@ -2754,22 +2706,17 @@ async function waitForPreviousFence(previous, options) {
2754
2706
  }
2755
2707
  await new Promise((resolve, reject) => {
2756
2708
  let timeout;
2757
- const cleanup = () => {
2758
- if (timeout) {
2759
- clearTimeout(timeout);
2760
- timeout = void 0;
2761
- }
2709
+ const settle = (error) => {
2710
+ clearTimeout(timeout);
2711
+ timeout = void 0;
2762
2712
  options.signal?.removeEventListener("abort", onAbort);
2713
+ return error ? reject(error) : resolve();
2763
2714
  };
2764
- const settle = (run) => {
2765
- cleanup();
2766
- run();
2767
- };
2768
- const onAbort = () => settle(() => reject(new Error(options.abortMessage ?? "Codex native config fence aborted")));
2769
- previous.then(() => settle(resolve));
2770
- 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 });
2771
2718
  if (options.timeoutMs !== void 0) {
2772
- 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));
2773
2720
  timeout.unref?.();
2774
2721
  }
2775
2722
  });
@@ -2802,7 +2749,7 @@ const nativeHookRelayUnregisterQueue = {
2802
2749
  clearTimeout(entry.timeout);
2803
2750
  entry.unregister();
2804
2751
  }
2805
- while (closing.size > 0) await Promise.allSettled(closing);
2752
+ await nativeHookRelayUnregisterQueue.clear();
2806
2753
  },
2807
2754
  async clear() {
2808
2755
  for (const entry of pending) clearTimeout(entry.timeout);
@@ -3179,7 +3126,7 @@ async function acquireSharedCodexAppServerClient(options, leased = false) {
3179
3126
  entry,
3180
3127
  authProfileId: usesNativeAuth || preparedAuth?.kind === "api-key" ? null : authProfileId,
3181
3128
  runtimeArtifactMode,
3182
- ...options?.expectedRuntimeArtifact ? { expectedRuntimeArtifact: options.expectedRuntimeArtifact } : {},
3129
+ expectedRuntimeArtifact: options?.expectedRuntimeArtifact,
3183
3130
  abandonSignal: entry.startupAbort.signal,
3184
3131
  config: options?.config
3185
3132
  }));
@@ -3274,7 +3221,7 @@ async function createIsolatedCodexAppServerClient(options) {
3274
3221
  lifetime,
3275
3222
  authProfileId: usesNativeAuth || context.preparedAuth?.kind === "api-key" ? null : context.authProfileId,
3276
3223
  runtimeArtifactMode: options?.runtimeArtifactMode ?? (options?.expectedRuntimeArtifact ? "capture" : void 0),
3277
- ...options?.expectedRuntimeArtifact ? { expectedRuntimeArtifact: options.expectedRuntimeArtifact } : {},
3224
+ expectedRuntimeArtifact: options?.expectedRuntimeArtifact,
3278
3225
  config: options?.config,
3279
3226
  timeoutMs: resolveRemainingAcquireTimeout(timeoutMs, startedAt),
3280
3227
  abandonSignal,
@@ -3305,9 +3252,9 @@ async function startInitializedCodexAppServerClientOnce(params) {
3305
3252
  const acquireStartedAt = performance.now();
3306
3253
  const timeoutMs = params.timeoutMs ?? 0;
3307
3254
  const abandonSignal = params.abandonSignal ? AbortSignal.any([params.lifetime.controller.signal, params.abandonSignal]) : params.lifetime.controller.signal;
3308
- const waitForStartup = (operation, timeoutMessage = CODEX_APP_SERVER_INITIALIZE_TIMEOUT_MESSAGE, timeoutErrorFactory) => {
3255
+ const waitForStartup = (operation, timeoutErrorFactory) => {
3309
3256
  if (abandonSignal.aborted) throw new CodexAppServerStartupError("aborted", "codex app-server initialize aborted");
3310
- 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);
3311
3258
  };
3312
3259
  const startOptionsCandidates = resolveManagedFallbackStartOptions(params.startOptions);
3313
3260
  for (const [index, startOptions] of startOptionsCandidates.entries()) {
@@ -3349,7 +3296,7 @@ async function startInitializedCodexAppServerClientOnce(params) {
3349
3296
  } finally {
3350
3297
  artifactDrain?.cancel();
3351
3298
  }
3352
- 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;
3353
3300
  const runtimeArtifactBeforeStart = runtimeArtifactModule ? await runtimeArtifactModule.captureCodexAppServerRuntimeArtifactBeforeStart({
3354
3301
  startOptions,
3355
3302
  spawnIdentity: resolveCodexAppServerSpawnIdentity(startOptions),
@@ -3396,7 +3343,7 @@ async function startInitializedCodexAppServerClientOnce(params) {
3396
3343
  params.onStartedClient?.(client);
3397
3344
  observeAcquire(params, { boundary: "initialize" });
3398
3345
  try {
3399
- await waitForStartup(() => client.initialize(), CODEX_APP_SERVER_INITIALIZE_TIMEOUT_MESSAGE, () => buildCodexAppServerInitializeTimeoutError(client));
3346
+ await waitForStartup(() => client.initialize(), () => buildCodexAppServerInitializeTimeoutError(client));
3400
3347
  } catch (error) {
3401
3348
  if (startOptions.commandSource === "resolved-managed" && index < startOptionsCandidates.length - 1 && isUnsupportedCodexAppServerVersionError(error)) continue;
3402
3349
  throw error;
@@ -3497,12 +3444,12 @@ function resolveManagedFallbackStartOptions(startOptions) {
3497
3444
  }
3498
3445
  return candidates;
3499
3446
  }
3447
+ function detachCurrentSharedClient(client) {
3448
+ const entry = client && getCurrentSharedClientEntry(client);
3449
+ return Boolean(entry && getSharedCodexAppServerClientState().clients.delete(entry.key));
3450
+ }
3500
3451
  function clearSharedCodexAppServerClientIfCurrent(client) {
3501
- if (!client) return false;
3502
- const state = getSharedCodexAppServerClientState();
3503
- const entry = getCurrentSharedClientEntry(client);
3504
- if (!entry) return false;
3505
- state.clients.delete(entry.key);
3452
+ if (!detachCurrentSharedClient(client)) return false;
3506
3453
  client.close();
3507
3454
  return true;
3508
3455
  }
@@ -3573,11 +3520,7 @@ function hasLiveOlderDesktopGenerationClient(params) {
3573
3520
  return false;
3574
3521
  }
3575
3522
  async function clearSharedCodexAppServerClientIfCurrentAndWait(client, options) {
3576
- if (!client) return false;
3577
- const state = getSharedCodexAppServerClientState();
3578
- const entry = getCurrentSharedClientEntry(client);
3579
- if (!entry) return false;
3580
- state.clients.delete(entry.key);
3523
+ if (!detachCurrentSharedClient(client)) return false;
3581
3524
  await client.closeAndWait(options);
3582
3525
  return true;
3583
3526
  }