@openclaw/codex 2026.10.5-beta.4 → 2026.10.10-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 (156) hide show
  1. package/README.md +10 -3
  2. package/dist/.setup/{account-usage-runtime-CoVpNIlD.mjs → account-usage-runtime-BVO-lpvn.mjs} +15 -9
  3. package/dist/.setup/{app-server-policy-D_zv8J7V.mjs → app-server-policy-Cog6mm2i.mjs} +1 -1
  4. package/dist/.setup/{apply-BXDMd05l.mjs → apply-tJl5mopa.mjs} +11 -11
  5. package/dist/.setup/{attempt-client-cleanup-zNuNTKVr.mjs → attempt-client-cleanup-DMJWXGxM.mjs} +14 -8
  6. package/dist/.setup/attempt-terminal-sZutF0WY.mjs +1 -0
  7. package/dist/.setup/{attempt-workspace-context-CcwP3DA3.mjs → attempt-workspace-context-GYPLawX6.mjs} +2 -2
  8. package/dist/.setup/{auth-binding-BaxlhaNx.mjs → auth-binding-830RLAJW.mjs} +2 -2
  9. package/dist/.setup/{auth-cache-key-f8ODJ_OX.mjs → auth-cache-key-BW1YeaIk.mjs} +92 -80
  10. package/dist/.setup/{auth-profile-CgHQ8Vot.mjs → auth-profile-auwzSwwy.mjs} +14 -8
  11. package/dist/.setup/{auth-profile-health-oHizqgye.mjs → auth-profile-health-BVPZU9I8.mjs} +15 -8
  12. package/dist/.setup/{auth-profile-selection-hr8ocLtz.mjs → auth-profile-selection-Bp5PDk3W.mjs} +24 -7
  13. package/dist/.setup/{binding-connection-B7HAAZSI.mjs → binding-connection-GTgUj9pi.mjs} +2 -2
  14. package/dist/.setup/{binding-connection.runtime-DAXn7iFl.mjs → binding-connection.runtime-RcWR3vQu.mjs} +4 -3
  15. package/dist/.setup/{bounded-turn-DfIJtRlv.mjs → bounded-turn-BQkmyyjB.mjs} +18 -22
  16. package/dist/.setup/{bounded-turn-isolation-BfDAo-qZ.mjs → bounded-turn-isolation-D8CDrAVX.mjs} +3 -3
  17. package/dist/.setup/{build-state-Ds14X10-.mjs → build-state-CjLCC0wm.mjs} +1 -1
  18. package/dist/.setup/{capabilities-DbOzOglY.mjs → capabilities-DAS-JX1z.mjs} +1 -1
  19. package/dist/.setup/{client-D93nbdB8.mjs → client--P8jwXvA.mjs} +47 -317
  20. package/dist/.setup/{client-catalog-response-CuVLp4I0.mjs → client-catalog-response-CsDxVVOZ.mjs} +2 -2
  21. package/dist/.setup/client-initialize-CjgZcX61.mjs +165 -0
  22. package/dist/.setup/{command-dispatch-DxdH5a9-.mjs → command-dispatch-DqaVBeR3.mjs} +3 -3
  23. package/dist/.setup/{command-formatters-xW9KpoSZ.mjs → command-formatters-B_7-QZ1c.mjs} +2 -2
  24. package/dist/.setup/{command-handlers-fiYvYYq0.mjs → command-handlers-i6mEjvfo.mjs} +539 -406
  25. package/dist/.setup/command-rpc-B65jEc0r.mjs +296 -0
  26. package/dist/.setup/compact-AO2H4RJe.mjs +823 -0
  27. package/dist/.setup/{computer-use-DL2v3Kxq.mjs → computer-use-YUnu0JVx.mjs} +21 -68
  28. package/dist/.setup/{config-C1YVVLEA.mjs → config-BfrAlTMT.mjs} +3 -3
  29. package/dist/.setup/{config-options-DDzeNQ8m.mjs → config-options-DMFZkd3X.mjs} +1 -1
  30. package/dist/.setup/{config-runtime-DWzK-k0n.mjs → config-runtime-BZRizyuG.mjs} +2 -2
  31. package/dist/.setup/{context-engine-projection-ps-yn_ci.mjs → context-engine-projection-PIeLSnR-.mjs} +16 -30
  32. package/dist/.setup/{conversation-binding-BieJZRRV.mjs → conversation-binding-CfnUR-IM.mjs} +228 -116
  33. package/dist/.setup/{conversation-binding-data-UgLuTSQT.mjs → conversation-binding-data-khgW0n-o.mjs} +4 -2
  34. package/dist/.setup/{conversation-control-GXM3unE4.mjs → conversation-control-B2EpVZEb.mjs} +53 -23
  35. package/dist/.setup/{cyber-failover-D4dgNfFf.mjs → cyber-failover-CqEZoQsj.mjs} +1 -1
  36. package/dist/.setup/{cyber-failover-notice-ljgGGL0s.mjs → cyber-failover-notice-poL3Advd.mjs} +1 -1
  37. package/dist/.setup/{doctor-start-options-JjTAl-q_.mjs → doctor-start-options-8uIBXIzR.mjs} +8 -5
  38. package/dist/.setup/{dynamic-tool-build-DcaPmBlE.mjs → dynamic-tool-build-DOub3CB5.mjs} +208 -218
  39. package/dist/.setup/{dynamic-tools-CnQFnNKH.mjs → dynamic-tools-Us5mvq_N.mjs} +344 -118
  40. package/dist/.setup/{effective-mcp-catalog-B5HKFZNK.mjs → effective-mcp-catalog-DfUUoeeM.mjs} +11 -9
  41. package/dist/.setup/{ephemeral-turn-De3qb8EQ.mjs → ephemeral-turn-B2z0RIeF.mjs} +5 -4
  42. package/dist/.setup/{event-projector-assistant-message-CLMKN4x-.mjs → event-projector-assistant-message-ChOAY7rW.mjs} +16 -11
  43. package/dist/.setup/{event-projector-usage-BpKfdoTm.mjs → event-projector-usage-CBY0Hkga.mjs} +2 -2
  44. package/dist/.setup/{event-projector-values-CLvG1Hil.mjs → event-projector-values-yf4us9Pf.mjs} +1 -1
  45. package/dist/.setup/experimental-features-uGnVDtp-.mjs +19 -0
  46. package/dist/.setup/inference-context-HRw3PDwn.mjs +209 -0
  47. package/dist/.setup/{inference-dispatch-CO6tTs4q.mjs → inference-dispatch-C2zVSnrr.mjs} +2 -2
  48. package/dist/.setup/{inference-metadata-DCvcG_N_.mjs → inference-metadata-CYFWLHVk.mjs} +3 -1
  49. package/dist/.setup/{inference-proxy-BDWV0djM.mjs → inference-proxy-CiLbHMLf.mjs} +8 -8
  50. package/dist/.setup/installed-probe-lVC1X5ve.mjs +185 -0
  51. package/dist/.setup/{isolated-completion-BPJdvk5F.mjs → isolated-completion-CybgD6uU.mjs} +7 -7
  52. package/dist/.setup/managed-binary-DbKvGXKl.mjs +395 -0
  53. package/dist/.setup/{mcp-app-session-preparation-Dz2GOwyE.mjs → mcp-app-session-preparation-zUgpDLWR.mjs} +18 -14
  54. package/dist/.setup/{model-catalog-ZNwltCKl.mjs → model-catalog-CWY3wo0B.mjs} +28 -17
  55. package/dist/.setup/{models-BHpbAuz8.mjs → models-CmOBxsKF.mjs} +3 -3
  56. package/dist/.setup/{native-auth-esN5MdIv.mjs → native-auth-DpZIaY8N.mjs} +7 -4
  57. package/dist/.setup/native-execution-policy-D09tLP-u.mjs +152 -0
  58. package/dist/.setup/{native-hook-relay-wq7jrNLk.mjs → native-hook-relay-CocOW9YS.mjs} +45 -10
  59. package/dist/.setup/{native-mcp-app-DX3nyTtc.mjs → native-mcp-app-DrQeLxXj.mjs} +5 -5
  60. package/dist/.setup/{native-skill-isolation-DSBeF-Yy.mjs → native-skill-isolation-DL4-PQa4.mjs} +7 -7
  61. package/dist/.setup/{native-subagent-monitor-DOLEIf9r.mjs → native-subagent-monitor-C3CIIaZG.mjs} +485 -239
  62. package/dist/.setup/{native-subagent-pending-assignments-DmVhedNs.mjs → native-subagent-pending-assignments-CTinVtjo.mjs} +1 -1
  63. package/dist/.setup/{native-task-assignments-DimsQ9Qa.mjs → native-task-assignments-YJopbaVO.mjs} +9 -5
  64. package/dist/.setup/{node-cli-sessions-CzKg2nGq.mjs → node-cli-sessions-BuJnBnEq.mjs} +7 -4
  65. package/dist/.setup/{node-exec-server.runtime-BWkULhBM.mjs → node-exec-server.runtime-CP7RC1Nd.mjs} +3 -3
  66. package/dist/.setup/{plan-41-YOBMq.mjs → plan-Bqj6VQvQ.mjs} +7 -20
  67. package/dist/.setup/{plugin-activation-D7WkJMvU.mjs → plugin-activation-CXPWe-hl.mjs} +4 -4
  68. package/dist/.setup/{plugin-app-cache-key-Bg9DbDI6.mjs → plugin-app-cache-key-DRb-niJc.mjs} +17 -55
  69. package/dist/.setup/{plugin-approval-roundtrip-CD88q3yx.mjs → plugin-approval-roundtrip-CGEiG7hG.mjs} +1 -1
  70. package/dist/.setup/{plugin-inventory-CYgdo14P.mjs → plugin-inventory-DE9wcaeH.mjs} +2 -2
  71. package/dist/.setup/{plugin-metadata-cache-Bi8TAPwX.mjs → plugin-metadata-cache-BqC-a6Fb.mjs} +2 -15
  72. package/dist/.setup/{project-doc-thread-config-BVcvnps8.mjs → project-doc-thread-config-B0UI3f1D.mjs} +6 -6
  73. package/dist/.setup/protocol-CaPAVwe9.mjs +12 -0
  74. package/dist/.setup/{provider-LWKll6dV.mjs → provider-C_1fMsyD.mjs} +4 -4
  75. package/dist/.setup/{provider-capabilities-Dn2WwH4P.mjs → provider-capabilities-C7pYYpvh.mjs} +1 -1
  76. package/dist/.setup/{rate-limits-CI8pTPqL.mjs → rate-limits-BpfURnuy.mjs} +1 -1
  77. package/dist/.setup/{request-Bo0kKABI.mjs → request-C6U8q2uz.mjs} +132 -136
  78. package/dist/.setup/{responses-oauth-twnuTaAa.mjs → responses-oauth-CCV7aVYF.mjs} +6 -6
  79. package/dist/.setup/{rpc-error-C98SHchT.mjs → rpc-error-DemqqaxE.mjs} +7 -3
  80. package/dist/.setup/{run-attempt-ClU8MxhZ.mjs → run-attempt-BhuXanLv.mjs} +595 -426
  81. package/dist/.setup/{run-attempt-lifecycle-KN4oh-7O.mjs → run-attempt-lifecycle-DN-ATDp9.mjs} +1 -1
  82. package/dist/.setup/{runtime-artifact-C13pR7tD.mjs → runtime-artifact-CmLWeyJB.mjs} +3 -3
  83. package/dist/.setup/{runtime-artifact-connection-jS5DeCok.mjs → runtime-artifact-connection-DpWlZ02e.mjs} +3 -3
  84. package/dist/.setup/{sandbox-guard-DIImwCy1.mjs → sandbox-guard-DneAfNye.mjs} +70 -30
  85. package/dist/.setup/{session-binding-JEHNMPsr.mjs → session-binding-BgsWcbdY.mjs} +25 -23
  86. package/dist/.setup/{session-binding-record-DU_0biMD.mjs → session-binding-record-C_THntMe.mjs} +27 -12
  87. package/dist/.setup/{session-binding-record-codec-BpH8u_G9.mjs → session-binding-record-codec-DvmOI7g_.mjs} +1 -0
  88. package/dist/.setup/{session-binding-sidecars-DD-enC8w.mjs → session-binding-sidecars-BNSS6WL4.mjs} +55 -63
  89. package/dist/.setup/session-cancellation-DCN1FcBZ.mjs +43 -0
  90. package/dist/.setup/{session-catalog-adoption-Ca3OYGYM.mjs → session-catalog-adoption-ppsLlVLB.mjs} +24 -38
  91. package/dist/.setup/{session-catalog-archive-Bv6gV7x9.mjs → session-catalog-archive-CqLRHJ6z.mjs} +11 -13
  92. package/dist/.setup/{session-catalog-events-kR2Ot6nX.mjs → session-catalog-events-CEi6SuLQ.mjs} +5 -5
  93. package/dist/.setup/{session-catalog-index-order-CTfoefow.mjs → session-catalog-index-order-0Zqng2u8.mjs} +1 -1
  94. package/dist/.setup/{session-catalog-index-CrnfVEnT.mjs → session-catalog-index-qt4UWBua.mjs} +96 -271
  95. package/dist/.setup/{session-catalog-limits-BynIoOYm.mjs → session-catalog-limits-Dc6E0BZz.mjs} +1 -1
  96. package/dist/.setup/{session-catalog-list-request-D4MYNgDB.mjs → session-catalog-list-request-CAjoWjaH.mjs} +3 -4
  97. package/dist/.setup/{session-catalog-native-projection-CWqCU1I_.mjs → session-catalog-native-projection-BqBYi6kV.mjs} +5 -5
  98. package/dist/.setup/{session-catalog-node-adoption-BdP9Zjqo.mjs → session-catalog-node-adoption-e9v8mGgx.mjs} +5 -5
  99. package/dist/.setup/{session-catalog-node-continue-CNJibO4_.mjs → session-catalog-node-continue-H7nrzcUD.mjs} +5 -5
  100. package/dist/.setup/{session-catalog-node-lookup-BH_DBGa9.mjs → session-catalog-node-lookup-BrZfDkA8.mjs} +2 -2
  101. package/dist/.setup/{session-catalog-parsing-DkeoVn60.mjs → session-catalog-parsing-V6jyFg9g.mjs} +2 -2
  102. package/dist/.setup/{session-catalog-projection-BzHiV818.mjs → session-catalog-projection-CNyhjZze.mjs} +8 -7
  103. package/dist/.setup/{session-catalog-provenance-CmsOE5mh.mjs → session-catalog-provenance-Dg9s12z-.mjs} +50 -30
  104. package/dist/.setup/{session-catalog-source-DGuRdGvM.mjs → session-catalog-source-z_mNyQdX.mjs} +2 -6
  105. package/dist/.setup/{session-cli-GwU0izn-.mjs → session-cli-CBGKiqdv.mjs} +1 -1
  106. package/dist/.setup/{session-history-BO6i_pfk.mjs → session-history-7W0cgTXF.mjs} +11 -9
  107. package/dist/.setup/{session-history-import-CaO8s6ta.mjs → session-history-import-BwPKwcNi.mjs} +4 -4
  108. package/dist/.setup/{session-initialization-Bi_2DKhc.mjs → session-initialization-Dn3vveGv.mjs} +2 -2
  109. package/dist/.setup/{session-retirement-B3U5hpGJ.mjs → session-retirement-RZStisKb.mjs} +8 -8
  110. package/dist/.setup/{session-history.worker-DJQfek5p.mjs → settled-turn-evidence--tRW6fSm.mjs} +2 -18
  111. package/dist/.setup/{settled-turn-finalizer-CYCVpTv2.mjs → settled-turn-finalizer-gioXygEX.mjs} +8 -8
  112. package/dist/.setup/{shared-client-BCx1wbyA.mjs → shared-client-CkyTrNB8.mjs} +380 -557
  113. package/dist/.setup/side-question-DHPWKgO3.mjs +998 -0
  114. package/dist/.setup/{source-DipMO9hL.mjs → source-63MLSmLJ.mjs} +5 -5
  115. package/dist/.setup/{thread-archive-guard-LKdwQKyr.mjs → thread-archive-guard-BWjSsA92.mjs} +1 -1
  116. package/dist/.setup/{thread-lifecycle-run-C_aYiYqk.mjs → thread-lifecycle-run-zCXYFW8W.mjs} +172 -75
  117. package/dist/.setup/{thread-model-selection-DcVebr8N.mjs → thread-model-selection-DxposL4X.mjs} +9 -9
  118. package/dist/.setup/{thread-ownership-BoUd0i6L.mjs → thread-ownership-Bmk5a2Gu.mjs} +7 -7
  119. package/dist/.setup/{thread-policy-B3wBRNph.mjs → thread-policy-DYtvZ5Ay.mjs} +6 -6
  120. package/dist/.setup/{thread-requests-BgzJwJtS.mjs → thread-requests-BjawdIVV.mjs} +14 -14
  121. package/dist/.setup/{thread-resume-D-3bsr1j.mjs → thread-resume-vBShG3-o.mjs} +6 -6
  122. package/dist/.setup/{transcript-history-projection-DfKcoZCB.mjs → transcript-history-projection-i-FVpyha.mjs} +1 -1
  123. package/dist/.setup/{transcript-mirror-Bee2o6jj.mjs → transcript-mirror-CEQJZlF3.mjs} +6 -9
  124. package/dist/.setup/{transport-stdio-CRWTkKOn.mjs → transport-stdio-Bq160Dhv.mjs} +63 -64
  125. package/dist/.setup/{transport-websocket-DIyPfkHo.mjs → transport-websocket-0YqiI_MH.mjs} +1 -1
  126. package/dist/.setup/{turn-router-DBVMToGo.mjs → turn-router-BGj67FMK.mjs} +2 -2
  127. package/dist/.setup/{upstream-session-fork-p5fwKi7w.mjs → upstream-session-fork-CWKjpdtW.mjs} +46 -219
  128. package/dist/.setup/{usage-C2Kq7oej.mjs → usage-AhrLFxZP.mjs} +4 -4
  129. package/dist/.setup/{usage-limit-error-BQX8RHAd.mjs → usage-limit-error-BdNbGJC3.mjs} +4 -4
  130. package/dist/.setup/{web-search-item-CvokaZOo.mjs → web-search-item-DHVuNSqk.mjs} +1 -1
  131. package/dist/.setup/{web-search-provider.runtime-D89djc7e.mjs → web-search-provider.runtime-Yk6lnJBG.mjs} +3 -3
  132. package/dist/.setup/{workspace-write-sandbox-probe-BDWO2Qkh.mjs → workspace-write-sandbox-probe-DJxOXcF3.mjs} +2 -2
  133. package/dist/api.js +7 -28
  134. package/dist/catalog-page.worker.js +1 -1
  135. package/dist/cli-metadata.js +1 -1
  136. package/dist/client-version-api.js +25 -0
  137. package/dist/doctor-contract-api.js +5 -5
  138. package/dist/harness.js +59 -36
  139. package/dist/index.js +259 -295
  140. package/dist/media-understanding-provider.js +2 -2
  141. package/dist/migration-provider-api.js +1 -2
  142. package/dist/native-session-binding-api.js +1 -2
  143. package/dist/provider-discovery.js +1 -1
  144. package/dist/session-history-worker-entrypoint.js +12 -0
  145. package/dist/session-history-worker-runtime.js +7 -18
  146. package/dist/session-history.worker.js +18 -2
  147. package/openclaw.plugin.json +1 -1
  148. package/package.json +6 -6
  149. package/dist/.setup/attempt-terminal-jO5IMj9K.mjs +0 -2
  150. package/dist/.setup/command-rpc-HIvsy3wS.mjs +0 -247
  151. package/dist/.setup/compact-ClZ7Ar7L.mjs +0 -808
  152. package/dist/.setup/inference-context-DNlGwzwy.mjs +0 -91
  153. package/dist/.setup/managed-binary-BtIjV7yN.mjs +0 -175
  154. package/dist/.setup/native-execution-policy-MXEe7PB3.mjs +0 -75
  155. package/dist/.setup/protocol-CANUwXJ3.mjs +0 -17
  156. package/dist/.setup/side-question-Bz2UQW0l.mjs +0 -826
@@ -0,0 +1,395 @@
1
+ import { t as __exportAll } from "./session-binding-sidecars-BNSS6WL4.mjs";
2
+ import { createRequire } from "node:module";
3
+ import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-registration";
4
+ import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
5
+ import { runUtf8CommandWithTimeout } from "openclaw/plugin-sdk/process-runtime";
6
+ import { constants, existsSync, realpathSync } from "node:fs";
7
+ import path from "node:path";
8
+ import { access, open, realpath } from "node:fs/promises";
9
+ import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
10
+ import { resolveNodeHostExecutable } from "openclaw/plugin-sdk/node-host";
11
+ import { parse } from "semver";
12
+ //#region extensions/codex/src/app-server/desktop-app-paths.ts
13
+ /** Shared path candidates for Codex's macOS desktop app bundle. */
14
+ const MACOS_DESKTOP_CODEX_APP_PATH_CANDIDATES = ["ChatGPT.app", "Codex.app"].flatMap((appName) => {
15
+ const appBundlePath = `/Applications/${appName}`;
16
+ const resources = `${appBundlePath}/Contents/Resources`;
17
+ const computerUseServiceAppPaths = [`${resources}/cua_node/lib/node_modules/@oai/sky/Codex Computer Use.app`, `${resources}/plugins/openai-bundled/plugins/computer-use/Codex Computer Use.app`];
18
+ if (appName === "Codex.app") computerUseServiceAppPaths.reverse();
19
+ const candidate = {
20
+ appName,
21
+ appBundlePath,
22
+ appServerCommandPath: `${resources}/codex`,
23
+ bundledMarketplacePath: `${resources}/plugins/openai-bundled`,
24
+ computerUseServiceAppPaths
25
+ };
26
+ return [{
27
+ ...candidate,
28
+ appServerCommandPath: path.join(resources, "codex-cli", "CodexCLI.app", "Contents", "MacOS", "codex")
29
+ }, candidate];
30
+ });
31
+ function resolveMacOSDesktopCodexAppPathCandidates(platform = process.platform) {
32
+ return platform === "darwin" ? MACOS_DESKTOP_CODEX_APP_PATH_CANDIDATES : [];
33
+ }
34
+ function resolveMacOSDesktopCodexAppServerCommandCandidates(platform = process.platform) {
35
+ return resolveMacOSDesktopCodexAppPathCandidates(platform).map((candidate) => candidate.appServerCommandPath);
36
+ }
37
+ function resolveMacOSDesktopCodexBundledMarketplaceCandidates(platform = process.platform) {
38
+ return [...new Set(resolveMacOSDesktopCodexAppPathCandidates(platform).map((candidate) => candidate.bundledMarketplacePath))];
39
+ }
40
+ function resolveMacOSDesktopCodexComputerUseServiceAppCandidates(platform = process.platform, appServerCommand) {
41
+ if (platform !== "darwin") return [];
42
+ const candidates = resolveMacOSDesktopCodexAppPathCandidates(platform);
43
+ const matchingCandidate = appServerCommand ? candidates.find((candidate) => path.resolve(candidate.appServerCommandPath) === path.resolve(appServerCommand)) : void 0;
44
+ return [.../* @__PURE__ */ new Set([...matchingCandidate?.computerUseServiceAppPaths ?? [], ...candidates.flatMap((candidate) => candidate.computerUseServiceAppPaths)])];
45
+ }
46
+ function resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath(params = {}) {
47
+ const candidates = params.candidates ?? resolveMacOSDesktopCodexBundledMarketplaceCandidates(params.platform);
48
+ const pathExists = params.pathExists ?? existsSync;
49
+ return candidates.find((candidate) => pathExists(candidate));
50
+ }
51
+ //#endregion
52
+ //#region extensions/codex/src/app-server/version.ts
53
+ /** Exact Codex app-server version shipped by the OpenClaw Codex bridge. */
54
+ const CODEX_APP_SERVER_VERSION = "0.160.0";
55
+ /** Inclusive runtime compatibility floor for external app-server binaries. */
56
+ const MIN_SUPPORTED_CODEX_APP_SERVER_VERSION = "0.149.0";
57
+ const MANAGED_CODEX_APP_SERVER_PACKAGE = "@openai/codex";
58
+ //#endregion
59
+ //#region extensions/codex/src/app-server/managed-binary.ts
60
+ /**
61
+ * Resolves the managed Codex app-server binary before stdio startup: a newer
62
+ * user-installed Codex from PATH when it passes the version policy and an
63
+ * app-server handshake, otherwise the package shipped beside the Codex plugin.
64
+ */
65
+ var managed_binary_exports = /* @__PURE__ */ __exportAll({
66
+ CODEX_VERSION_TIMEOUT_MS: () => CODEX_VERSION_TIMEOUT_MS,
67
+ INSTALLED_CODEX_PROBE_TIMEOUT_MS: () => INSTALLED_CODEX_PROBE_TIMEOUT_MS,
68
+ INSTALLED_CODEX_START_TIMEOUT_MS: () => INSTALLED_CODEX_START_TIMEOUT_MS,
69
+ assertInstalledCodexAppServerVersion: () => assertInstalledCodexAppServerVersion,
70
+ isManagedCodexDesktopCommand: () => isManagedCodexDesktopCommand,
71
+ parseCodexVersion: () => parseCodexVersion,
72
+ readInstalledCodexAppServerStatus: () => readInstalledCodexAppServerStatus,
73
+ rejectInstalledCodexAppServer: () => rejectInstalledCodexAppServer,
74
+ resolveManagedCodexAppServerStartOptions: () => resolveManagedCodexAppServerStartOptions,
75
+ resolveManagedCodexClientVersion: () => resolveManagedCodexClientVersion,
76
+ resolveManagedCodexNativeCommand: () => resolveManagedCodexNativeCommand,
77
+ resolveManagedCodexPackageEntrypoint: () => resolveManagedCodexPackageEntrypoint,
78
+ resolvePackagedCodexNativeCommand: () => resolvePackagedCodexNativeCommand,
79
+ runCodexVersionCommand: () => runCodexVersionCommand,
80
+ setManagedCodexPluginRoot: () => setManagedCodexPluginRoot
81
+ });
82
+ const CODEX_VERSION_TIMEOUT_MS = 5e3;
83
+ const CODEX_VERSION_MAX_OUTPUT_BYTES = 65536;
84
+ const INSTALLED_CODEX_PROBE_TIMEOUT_MS = 4e3;
85
+ /**
86
+ * Initialize allowance for a managed start of the already-probed installed
87
+ * Codex while the bundled fallback remains; short enough that the fallback
88
+ * fits the 10 second model-catalog deadline.
89
+ */
90
+ const INSTALLED_CODEX_START_TIMEOUT_MS = 4e3;
91
+ const NATIVE_TARGET_TRIPLES = /* @__PURE__ */ new Map([
92
+ ["linux-x64", "x86_64-unknown-linux-musl"],
93
+ ["linux-arm64", "aarch64-unknown-linux-musl"],
94
+ ["darwin-x64", "x86_64-apple-darwin"],
95
+ ["darwin-arm64", "aarch64-apple-darwin"],
96
+ ["win32-x64", "x86_64-pc-windows-msvc"],
97
+ ["win32-arm64", "aarch64-pc-windows-msvc"]
98
+ ]);
99
+ const registeredCodexPlugin = resolveGlobalSingleton(Symbol.for("openclaw.codexManagedPluginRoot"), () => ({}));
100
+ const installedCodex = resolveGlobalSingleton(Symbol.for("openclaw.codexInstalledAppServer"), () => ({}), (state) => {
101
+ delete state.selection;
102
+ delete state.selected;
103
+ delete state.pending;
104
+ delete state.rejected;
105
+ });
106
+ /** Records the process-stable plugin root prepared by OpenClaw's plugin loader. */
107
+ function setManagedCodexPluginRoot(pluginRoot) {
108
+ registeredCodexPlugin.root = pluginRoot;
109
+ }
110
+ /**
111
+ * Version that managed starts with this command order report to ChatGPT model
112
+ * discovery: the selected installed Codex, otherwise the bundled pin.
113
+ */
114
+ async function resolveManagedCodexClientVersion(order, options = {}) {
115
+ return (await resolveInstalledCodexForOrder(order, options))?.version ?? "0.160.0";
116
+ }
117
+ /**
118
+ * Desktop-first starts that find a macOS desktop app run it with the bundled
119
+ * package as fallback; they never wait on, start, or report a PATH Codex.
120
+ */
121
+ async function resolveInstalledCodexForOrder(order, options) {
122
+ const platform = options.platform ?? process.platform;
123
+ const pathExists = options.pathExists ?? commandPathExists;
124
+ if (order === "desktop-first") {
125
+ for (const command of resolveMacOSDesktopCodexAppServerCommandCandidates(platform)) if (await pathExists(command, platform)) return;
126
+ }
127
+ return resolveInstalledCodexAppServer(options.probes, options.selectionTimeoutMs);
128
+ }
129
+ /**
130
+ * Selects the installed Codex once per process; later callers reuse the
131
+ * decision, so probes only apply to the call that makes it.
132
+ */
133
+ async function resolveInstalledCodexAppServer(probes = {}, timeoutMs = INSTALLED_CODEX_PROBE_TIMEOUT_MS) {
134
+ if (!installedCodex.selection) {
135
+ installedCodex.pending = true;
136
+ const selection = decideInstalledCodexAppServer(probes).then((decision) => {
137
+ if (installedCodex.selection !== selection) return;
138
+ delete installedCodex.pending;
139
+ embeddedAgentLog.info("selected" in decision ? `Codex app-server: using installed ${decision.found} ${decision.selected.version} (newer than bundled ${CODEX_APP_SERVER_VERSION})` : `Codex app-server: using bundled ${CODEX_APP_SERVER_VERSION} (${decision.reason})`);
140
+ if ("selected" in decision) {
141
+ installedCodex.selected = decision.selected;
142
+ return decision.selected;
143
+ }
144
+ });
145
+ installedCodex.selection = selection;
146
+ }
147
+ const selection = installedCodex.selection;
148
+ if (!installedCodex.pending) return selection;
149
+ let timer;
150
+ const expired = new Promise((resolve) => {
151
+ timer = setTimeout(() => {
152
+ if (installedCodex.selection === selection) {
153
+ installedCodex.selection = Promise.resolve(void 0);
154
+ delete installedCodex.pending;
155
+ embeddedAgentLog.info(`Codex app-server: using bundled ${CODEX_APP_SERVER_VERSION} (installed Codex selection exceeded its startup budget)`);
156
+ }
157
+ resolve(void 0);
158
+ }, Math.min(timeoutMs, INSTALLED_CODEX_PROBE_TIMEOUT_MS));
159
+ });
160
+ try {
161
+ return await Promise.race([selection, expired]);
162
+ } finally {
163
+ clearTimeout(timer);
164
+ }
165
+ }
166
+ /**
167
+ * Drops the selected installed Codex after it failed to start, so this process
168
+ * uses the bundled package until the Gateway restarts. Returns true for that
169
+ * launcher, including starts that captured it before another start dropped it,
170
+ * and false for any other command. Only the first failure is logged.
171
+ */
172
+ function rejectInstalledCodexAppServer(command, error) {
173
+ const selected = installedCodex.selected;
174
+ if (selected?.command !== command) return installedCodex.rejected === command;
175
+ installedCodex.rejected = command;
176
+ installedCodex.selection = Promise.resolve(void 0);
177
+ delete installedCodex.selected;
178
+ embeddedAgentLog.warn(`Codex app-server: installed ${command} ${selected.version} failed to start (${coerceErrorMessage(error)}); using bundled ${CODEX_APP_SERVER_VERSION} until the Gateway restarts`);
179
+ return true;
180
+ }
181
+ /**
182
+ * Rejects an initialize answer from the selected installed Codex that names
183
+ * another version, and any start of a launcher another start already rejected.
184
+ */
185
+ function assertInstalledCodexAppServerVersion(command, serverVersion) {
186
+ const selected = installedCodex.selected;
187
+ if (selected?.command === command && serverVersion !== selected.version) throw new Error(`app-server reported ${serverVersion ?? "no version"}`);
188
+ if (selected?.command !== command && installedCodex.rejected === command) throw new Error("another start already rejected this installed Codex");
189
+ }
190
+ /** Whether `command` is this process's selected installed Codex, or was until it failed. */
191
+ function readInstalledCodexAppServerStatus(command) {
192
+ if (installedCodex.selected?.command === command) return "selected";
193
+ return installedCodex.rejected === command ? "rejected" : void 0;
194
+ }
195
+ async function decideInstalledCodexAppServer(probes) {
196
+ const env = probes.env ?? process.env;
197
+ const platform = probes.platform ?? process.platform;
198
+ const selectionDeadline = performance.now() + INSTALLED_CODEX_PROBE_TIMEOUT_MS;
199
+ const found = resolveNodeHostExecutable("codex", {
200
+ env,
201
+ strategy: "direct"
202
+ })?.executable;
203
+ if (!found) return { reason: "no codex on PATH" };
204
+ const launcher = await resolveInstalledCodexLauncher(found, platform);
205
+ if (!launcher) return { reason: `installed ${found} is not a native Codex executable or the official ${MANAGED_CODEX_APP_SERVER_PACKAGE} launcher` };
206
+ if (isManagedCodexDesktopCommand(launcher.command, platform)) return { reason: `installed ${found} belongs to a macOS desktop app` };
207
+ let output;
208
+ const versionTimeoutMs = Math.max(0, selectionDeadline - performance.now());
209
+ if (versionTimeoutMs <= 0) return { reason: `installed ${found} selection timed out before the version check` };
210
+ try {
211
+ output = probes.runVersion ? await probes.runVersion(launcher.nativeCommand) : await runCodexVersionCommand(launcher.nativeCommand, process.env, versionTimeoutMs);
212
+ } catch (error) {
213
+ return { reason: `installed ${found} --version failed: ${coerceErrorMessage(error)}` };
214
+ }
215
+ const version = parseCodexVersion(output);
216
+ const parsed = version ? parse(version) : null;
217
+ if (!version || !parsed) return { reason: `installed ${found} did not report a parseable version` };
218
+ const bundled = parse(CODEX_APP_SERVER_VERSION);
219
+ if (parsed.compare(bundled) <= 0) return { reason: `installed ${found} ${version} is not newer` };
220
+ if (parsed.prerelease.length > 0) return { reason: `installed ${found} ${version} is a prerelease` };
221
+ if (parsed.major !== bundled.major) return { reason: `installed ${found} ${version} is a different major version` };
222
+ const handshakeTimeoutMs = Math.max(0, selectionDeadline - performance.now());
223
+ if (handshakeTimeoutMs <= 0) return { reason: `installed ${found} selection timed out before the app-server handshake` };
224
+ let handshakeVersion;
225
+ try {
226
+ handshakeVersion = await (probes.probeHandshake ?? (async (command) => (await import("./installed-probe-lVC1X5ve.mjs")).probeCodexAppServerHandshake(command, handshakeTimeoutMs)))(launcher.command);
227
+ } catch (error) {
228
+ return { reason: `installed ${found} ${version} failed the app-server handshake: ${coerceErrorMessage(error)}` };
229
+ }
230
+ if (handshakeVersion !== version) return { reason: `installed ${found} ${version} reported ${handshakeVersion ?? "no version"} from app-server` };
231
+ return {
232
+ found,
233
+ selected: {
234
+ ...launcher,
235
+ version
236
+ }
237
+ };
238
+ }
239
+ /** Accepts native executables and the official npm launcher, never other script wrappers. */
240
+ async function resolveInstalledCodexLauncher(found, platform) {
241
+ let command;
242
+ try {
243
+ command = await realpath(found);
244
+ if (platform === "win32" && /\.(?:cmd|bat|ps1)$/iu.test(command)) command = await realpath(path.join(path.dirname(command), "node_modules", "@openai", "codex", "bin", "codex.js"));
245
+ } catch {
246
+ return;
247
+ }
248
+ const packagedNative = resolvePackagedCodexNativeCommand(command);
249
+ if (packagedNative) return {
250
+ command,
251
+ nativeCommand: packagedNative
252
+ };
253
+ if (/\.(?:[cm]?js|cmd|bat|ps1)$/iu.test(command) || await startsWithShebang(command)) return;
254
+ return {
255
+ command,
256
+ nativeCommand: command
257
+ };
258
+ }
259
+ async function startsWithShebang(filePath) {
260
+ const handle = await open(filePath, "r").catch(() => void 0);
261
+ if (!handle) return true;
262
+ try {
263
+ const buffer = Buffer.alloc(2);
264
+ const { bytesRead } = await handle.read(buffer, 0, 2, 0);
265
+ return bytesRead === 2 && buffer.toString("latin1") === "#!";
266
+ } finally {
267
+ await handle.close();
268
+ }
269
+ }
270
+ /** Extracts the semver from `codex --version` output such as `codex-cli 0.160.0`. */
271
+ function parseCodexVersion(output) {
272
+ return /(?:^|\s)(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)(?:\s|$)/u.exec(output)?.[1];
273
+ }
274
+ /** Runs `<native> --version` with bounded time and output; returns stdout and stderr. */
275
+ async function runCodexVersionCommand(nativeCommand, env = process.env, timeoutMs = CODEX_VERSION_TIMEOUT_MS) {
276
+ const result = await runUtf8CommandWithTimeout([nativeCommand, "--version"], {
277
+ baseEnv: env,
278
+ timeoutMs,
279
+ maxOutputBytes: CODEX_VERSION_MAX_OUTPUT_BYTES,
280
+ outputCapture: "head",
281
+ terminateOnOutputLimit: true,
282
+ killProcessTree: true,
283
+ killSignal: "SIGKILL",
284
+ killGraceMs: 0
285
+ });
286
+ if (result.termination !== "exit" || result.code !== 0 || result.outputLimitExceeded) throw new Error(result.outputLimitExceeded ? "Version output exceeded its capture limit" : result.termination === "timeout" ? `Version check timed out after ${timeoutMs} ms` : `Version check failed (${result.signal ?? result.code ?? result.termination})`);
287
+ return `${result.stdout}\n${result.stderr}`;
288
+ }
289
+ async function resolveManagedCodexAppServerStartOptions(startOptions, options = {}) {
290
+ if (startOptions.transport !== "stdio" || startOptions.commandSource !== "managed") return startOptions;
291
+ const pluginRoot = options.pluginRoot ?? registeredCodexPlugin.root;
292
+ if (!pluginRoot) throw new Error("Codex plugin root is unavailable. Load the Codex plugin before starting its managed app-server.");
293
+ const platform = options.platform ?? process.platform;
294
+ const pathExists = options.pathExists ?? commandPathExists;
295
+ const managedCommandOrder = startOptions.managedCommandOrder ?? "package-first";
296
+ const installed = options.preferInstalled === false ? void 0 : await resolveInstalledCodexForOrder(managedCommandOrder, {
297
+ platform,
298
+ pathExists,
299
+ selectionTimeoutMs: options.selectionTimeoutMs
300
+ });
301
+ const candidateCommandPaths = resolveManagedCodexAppServerCommandCandidates(pluginRoot, platform, managedCommandOrder, installed?.command);
302
+ const commandPaths = [];
303
+ for (const commandPath of candidateCommandPaths) {
304
+ const isInstalled = commandPath === installed?.command;
305
+ if (await pathExists(commandPath, platform) && (!isInstalled || await pathExists(installed.nativeCommand, platform))) commandPaths.push(commandPath);
306
+ else if (isInstalled) rejectInstalledCodexAppServer(commandPath, /* @__PURE__ */ new Error("executable is no longer available"));
307
+ }
308
+ const [commandPath, ...managedFallbackCommandPaths] = commandPaths;
309
+ if (commandPath === void 0) throw new Error([
310
+ `Managed Codex app-server binary was not found for ${MANAGED_CODEX_APP_SERVER_PACKAGE}.`,
311
+ "Reinstall or update OpenClaw, or run pnpm install in a source checkout.",
312
+ "Set plugins.entries.codex.config.appServer.command or OPENCLAW_CODEX_APP_SERVER_BIN to use a custom Codex binary."
313
+ ].join(" "));
314
+ return {
315
+ ...startOptions,
316
+ command: commandPath,
317
+ commandSource: "resolved-managed",
318
+ ...managedFallbackCommandPaths.length > 0 ? { managedFallbackCommandPaths } : {}
319
+ };
320
+ }
321
+ /** Resolves the native artifact behind a successful managed launcher selection. */
322
+ function resolveManagedCodexNativeCommand(command, options = {}) {
323
+ const platform = options.platform ?? process.platform;
324
+ const installedNative = installedCodex.selected;
325
+ if (installedNative?.command === command) return installedNative.nativeCommand;
326
+ if (isManagedCodexDesktopCommand(command, platform)) return command;
327
+ const target = `${platform === "android" ? "linux" : platform}-${options.arch ?? process.arch}`;
328
+ const triple = NATIVE_TARGET_TRIPLES.get(target);
329
+ if (!triple) return;
330
+ const packageRoot = resolveManagedCodexPackageRootForCommand(command, platform);
331
+ if (!packageRoot) return;
332
+ const resolvePackageJson = options.resolvePackageJson ?? resolvePackageJsonFromRoot;
333
+ const pathExists = options.pathExists ?? existsSync;
334
+ const packageJsonPath = resolvePackageJson(`@openai/codex-${target}`, packageRoot) ?? resolvePackageJson("@openai/codex", packageRoot);
335
+ if (!packageJsonPath) return;
336
+ const candidate = path.join(path.dirname(packageJsonPath), "vendor", triple, "bin", platform === "win32" ? "codex.exe" : "codex");
337
+ return pathExists(candidate) ? candidate : void 0;
338
+ }
339
+ /** Recognizes only the official npm entrypoint, not arbitrary configured wrappers. */
340
+ function resolvePackagedCodexNativeCommand(entrypoint) {
341
+ const packageRoot = path.dirname(path.dirname(entrypoint));
342
+ if (path.basename(packageRoot) !== "codex" || path.basename(path.dirname(packageRoot)) !== "@openai" || path.relative(packageRoot, entrypoint) !== path.join("bin", "codex.js")) return;
343
+ return resolveManagedCodexNativeCommand(entrypoint);
344
+ }
345
+ function isManagedCodexDesktopCommand(command, platform = process.platform) {
346
+ return platform === "darwin" && resolveMacOSDesktopCodexAppServerCommandCandidates(platform).includes(command);
347
+ }
348
+ function resolveManagedCodexPackageRootForCommand(command, platform) {
349
+ const pathApi = platform === "win32" ? path.win32 : path.posix;
350
+ const commandPaths = [command];
351
+ try {
352
+ commandPaths.unshift(realpathSync(command));
353
+ } catch {}
354
+ for (const commandPath of commandPaths) {
355
+ let current = pathApi.dirname(commandPath);
356
+ while (true) {
357
+ if (pathApi.basename(current) === "codex" && pathApi.basename(pathApi.dirname(current)) === "@openai") return current;
358
+ if (pathApi.basename(current) === ".bin") return pathApi.join(pathApi.dirname(current), "@openai", "codex");
359
+ const parent = pathApi.dirname(current);
360
+ if (parent === current) break;
361
+ current = parent;
362
+ }
363
+ }
364
+ }
365
+ function resolvePackageJsonFromRoot(packageName, root) {
366
+ try {
367
+ const manifestPath = realpathSync(path.join(root, "package.json"));
368
+ return createRequire(manifestPath).resolve(`${packageName}/package.json`);
369
+ } catch {
370
+ return;
371
+ }
372
+ }
373
+ function resolveManagedCodexAppServerCommandCandidates(pluginRoot, platform, managedCommandOrder, installedCommand) {
374
+ const packageCommandPaths = [installedCommand, resolveManagedCodexPackageEntrypoint(pluginRoot)].filter((command) => command !== void 0);
375
+ if (managedCommandOrder === "package-only") return packageCommandPaths;
376
+ const desktopCommandPaths = resolveMacOSDesktopCodexAppServerCommandCandidates(platform);
377
+ return managedCommandOrder === "desktop-first" ? [...desktopCommandPaths, ...packageCommandPaths] : [...packageCommandPaths, ...desktopCommandPaths];
378
+ }
379
+ function resolveManagedCodexPackageEntrypoint(pluginRoot) {
380
+ try {
381
+ return createRequire(path.join(pluginRoot, "package.json")).resolve(`${MANAGED_CODEX_APP_SERVER_PACKAGE}/bin/codex.js`);
382
+ } catch {
383
+ return;
384
+ }
385
+ }
386
+ async function commandPathExists(filePath, platform) {
387
+ try {
388
+ await access(filePath, platform === "win32" ? constants.F_OK : constants.X_OK);
389
+ return true;
390
+ } catch {
391
+ return false;
392
+ }
393
+ }
394
+ //#endregion
395
+ export { MIN_SUPPORTED_CODEX_APP_SERVER_VERSION as _, isManagedCodexDesktopCommand as a, resolveMacOSDesktopCodexBundledMarketplaceCandidates as b, readInstalledCodexAppServerStatus as c, resolveManagedCodexClientVersion as d, resolveManagedCodexNativeCommand as f, CODEX_APP_SERVER_VERSION as g, setManagedCodexPluginRoot as h, assertInstalledCodexAppServerVersion as i, rejectInstalledCodexAppServer as l, runCodexVersionCommand as m, INSTALLED_CODEX_PROBE_TIMEOUT_MS as n, managed_binary_exports as o, resolvePackagedCodexNativeCommand as p, INSTALLED_CODEX_START_TIMEOUT_MS as r, parseCodexVersion as s, CODEX_VERSION_TIMEOUT_MS as t, resolveManagedCodexAppServerStartOptions as u, resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath as v, resolveMacOSDesktopCodexComputerUseServiceAppCandidates as x, resolveMacOSDesktopCodexAppPathCandidates as y };
@@ -1,21 +1,21 @@
1
- import { m as sessionBindingIdentity } from "./session-binding-record-DU_0biMD.mjs";
1
+ import { g as sessionBindingIdentity } from "./session-binding-record-C_THntMe.mjs";
2
2
  import { d as readCodexRequirementsToml } from "./config-security-clxAZYWX.mjs";
3
3
  import { d as readCodexPluginConfig } from "./config-parsing-DsWSCPHO.mjs";
4
4
  import { n as isCodexAppServerProxyLaunch } from "./launch-args-DbFCehO7.mjs";
5
- import { i as withCodexAppServerGitConfig } from "./transport-stdio-CRWTkKOn.mjs";
6
- import { n as buildCodexAppServerRuntimeFingerprint, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-Bg9DbDI6.mjs";
7
- import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-B7HAAZSI.mjs";
8
- import { r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-C1YVVLEA.mjs";
9
- import { r as resolveCodexAppServerAuthProfileId } from "./auth-profile-CgHQ8Vot.mjs";
10
- import { I as ensureCodexAppServerClientRuntime, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-BCx1wbyA.mjs";
11
- import { d as mergeCodexThreadConfigs } from "./project-doc-thread-config-BVcvnps8.mjs";
12
- import { i as resolveCodexSessionBinding } from "./session-binding-JEHNMPsr.mjs";
13
- import { a as rollbackCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-BoUd0i6L.mjs";
14
- import { a as prepareCodexPluginThreadConfigStartupProvider, o as resolveCodexPluginThreadConfigStartupPolicy, t as startOrResumeThread } from "./thread-lifecycle-run-C_aYiYqk.mjs";
5
+ import { i as withCodexAppServerGitConfig } from "./transport-stdio-Bq160Dhv.mjs";
6
+ import { n as buildCodexAppServerRuntimeFingerprint, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-DRb-niJc.mjs";
7
+ import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-GTgUj9pi.mjs";
8
+ import { r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-BfrAlTMT.mjs";
9
+ import { r as resolveCodexAppServerAuthProfileId } from "./auth-profile-auwzSwwy.mjs";
10
+ import { O as ensureCodexAppServerClientRuntime, f as releaseLeasedSharedCodexAppServerClient, o as getLeasedSharedCodexAppServerClient } from "./shared-client-CkyTrNB8.mjs";
11
+ import { d as mergeCodexThreadConfigs } from "./project-doc-thread-config-B0UI3f1D.mjs";
12
+ import { i as resolveCodexSessionBinding } from "./session-binding-BgsWcbdY.mjs";
13
+ import { a as rollbackCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-Bmk5a2Gu.mjs";
14
+ import { a as prepareCodexPluginThreadConfigStartupProvider, o as resolveCodexPluginThreadConfigStartupPolicy, t as startOrResumeThread } from "./thread-lifecycle-run-zCXYFW8W.mjs";
15
15
  import { n as applyCodexSessionPermissionPolicy } from "./session-permission-policy-CD2MAWU8.mjs";
16
16
  import { z } from "zod";
17
17
  import { loadCodexBundleMcpThreadConfig } from "openclaw/plugin-sdk/agent-harness-runtime";
18
- import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
18
+ import { loadExecApprovalsReadOnlyAsync } from "openclaw/plugin-sdk/exec-approvals-runtime";
19
19
  import { buildCodexUserMcpServersThreadConfigPatchForRuntime } from "openclaw/plugin-sdk/codex-mcp-projection";
20
20
  //#region extensions/codex/src/app-server/mcp-app-session-preparation.ts
21
21
  /** Runs the existing thread lifecycle only. This path has no prompt or turn submission. */
@@ -40,6 +40,7 @@ async function prepareCodexMcpAppSession(params) {
40
40
  signal: input.abortSignal,
41
41
  assertCurrent: assertSourceCurrent
42
42
  });
43
+ using _ = { [Symbol.dispose]: admitted.release };
43
44
  const assertCurrent = () => {
44
45
  assertSourceCurrent();
45
46
  admitted.authority.assertLegacyCurrent();
@@ -49,7 +50,7 @@ async function prepareCodexMcpAppSession(params) {
49
50
  const execPolicy = resolveOpenClawExecPolicyForCodexAppServer({
50
51
  permissionMode: input.permissionMode,
51
52
  execOverrides: input.execOverrides,
52
- approvals: input.permissionMode === "full" ? void 0 : loadExecApprovals(),
53
+ approvals: input.permissionMode === "full" ? void 0 : await loadExecApprovalsReadOnlyAsync(),
53
54
  config: input.config,
54
55
  agentId: input.agentId
55
56
  });
@@ -164,6 +165,7 @@ async function prepareCodexMcpAppSession(params) {
164
165
  authProfileId
165
166
  },
166
167
  assertCurrent,
168
+ authority: admitted.authority,
167
169
  agentId: input.agentId,
168
170
  agentDir: input.agentDir,
169
171
  cwd: input.workspaceDir,
@@ -212,7 +214,9 @@ async function prepareCodexMcpAppSession(params) {
212
214
  if (admitted.binding) return await prepareThread();
213
215
  const thread = await params.bindingStore.withLease(sessionBindingIdentity(input), async () => {
214
216
  assertCurrent();
215
- return params.bindingStore.read(sessionBindingIdentity(input)) ?? await prepareThread();
217
+ const current = await params.bindingStore.readAsync(sessionBindingIdentity(input));
218
+ assertCurrent();
219
+ return current ?? await prepareThread();
216
220
  });
217
221
  assertCurrent();
218
222
  return thread;
@@ -1,15 +1,15 @@
1
1
  import { t as buildCodexRuntimeModelParams } from "./model-runtime-BdqzOMkU.mjs";
2
2
  import { d as readCodexPluginConfig } from "./config-parsing-DsWSCPHO.mjs";
3
3
  import { n as isCodexAppServerProxyLaunch } from "./launch-args-DbFCehO7.mjs";
4
- import { w as retireSharedCodexAppServerClientIfCurrent } from "./auth-cache-key-f8ODJ_OX.mjs";
5
- import { a as withCodexAppServerJsonClient } from "./request-Bo0kKABI.mjs";
6
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-DWzK-k0n.mjs";
7
- import { a as resolveCodexAppServerAuthProfileStore, r as resolveCodexAppServerAuthProfileId } from "./auth-profile-CgHQ8Vot.mjs";
8
- import { r as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-BCx1wbyA.mjs";
9
- import { i as isCodexResponsesOAuthCredential } from "./responses-oauth-twnuTaAa.mjs";
10
- import { a as isCodexAppServerIndeterminateRequestCancellationError } from "./client-D93nbdB8.mjs";
11
- import { n as listAllCodexAppServerModels } from "./models-BHpbAuz8.mjs";
12
- import { probeCodexNativeAuth } from "./native-auth-esN5MdIv.mjs";
4
+ import { D as retireSharedCodexAppServerClientIfCurrent } from "./auth-cache-key-BW1YeaIk.mjs";
5
+ import { a as withCodexAppServerJsonClient } from "./request-C6U8q2uz.mjs";
6
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BZRizyuG.mjs";
7
+ import { a as resolveCodexAppServerAuthProfileStore, r as resolveCodexAppServerAuthProfileId } from "./auth-profile-auwzSwwy.mjs";
8
+ import { n as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-CkyTrNB8.mjs";
9
+ import { i as isCodexResponsesOAuthCredential } from "./responses-oauth-CCV7aVYF.mjs";
10
+ import { i as isCodexAppServerIndeterminateRequestCancellationError } from "./client--P8jwXvA.mjs";
11
+ import { n as listAllCodexAppServerModels } from "./models-CmOBxsKF.mjs";
12
+ import { probeCodexNativeAuth } from "./native-auth-DpZIaY8N.mjs";
13
13
  //#region extensions/codex/src/app-server/model-catalog.ts
14
14
  const INPUT_TYPES = /* @__PURE__ */ new Set([
15
15
  "text",
@@ -62,7 +62,7 @@ function createCodexAppServerModelCatalog(runtime) {
62
62
  } : void 0;
63
63
  },
64
64
  async load(params, pluginConfig) {
65
- if (disposed) return [];
65
+ if (disposed) return { entries: [] };
66
66
  let observations = scopes.get(params.config);
67
67
  if (!observations) {
68
68
  observations = /* @__PURE__ */ new Map();
@@ -72,10 +72,10 @@ function createCodexAppServerModelCatalog(runtime) {
72
72
  const observation = { pluginConfig };
73
73
  observations.set(key, observation);
74
74
  const discovery = readCodexPluginConfig(pluginConfig).discovery;
75
- if (discovery?.enabled === false) return [];
75
+ if (discovery?.enabled === false) return { entries: [] };
76
76
  const options = resolveCodexAppServerRuntimeOptions({ pluginConfig });
77
77
  const ownsLocalProcess = options.start.transport === "stdio" && !isCodexAppServerProxyLaunch(options.start.args);
78
- const authProfileStore = ownsLocalProcess && options.start.homeScope === "agent" ? resolveCodexAppServerAuthProfileStore({
78
+ const authProfileStore = ownsLocalProcess && options.start.homeScope === "agent" ? await resolveCodexAppServerAuthProfileStore({
79
79
  agentDir: params.agentDir,
80
80
  config: params.config
81
81
  }) : void 0;
@@ -83,10 +83,10 @@ function createCodexAppServerModelCatalog(runtime) {
83
83
  store: authProfileStore,
84
84
  config: params.config
85
85
  }) : void 0;
86
- if (isCodexResponsesOAuthCredential(authProfileStore?.profiles[authProfileId ?? ""])) return [];
86
+ if (isCodexResponsesOAuthCredential(authProfileStore?.profiles[authProfileId ?? ""])) return { entries: [] };
87
87
  const usesNativeHome = ownsLocalProcess && options.start.homeScope === "user";
88
88
  const native = usesNativeHome ? await probeCodexNativeAuth({ pluginConfig }) : void 0;
89
- if (usesNativeHome && !native || disposed || observations.get(key) !== observation) return [];
89
+ if (usesNativeHome && !native || disposed || observations.get(key) !== observation) return { entries: [] };
90
90
  const { start } = options;
91
91
  const timeoutMs = discovery?.timeoutMs ?? 1e4;
92
92
  const result = await withCodexAppServerJsonClient({
@@ -97,9 +97,14 @@ function createCodexAppServerModelCatalog(runtime) {
97
97
  ...authProfileStore ? {
98
98
  authProfileStore,
99
99
  authProfileId
100
- } : {}
100
+ } : {},
101
+ ...ownsLocalProcess && start.homeScope === "agent" && !authProfileId ? { authRequirement: "environment-api-key" } : {}
101
102
  }, async (request, client) => {
102
103
  try {
104
+ await request({
105
+ method: "account/read",
106
+ requestParams: { refreshToken: false }
107
+ });
103
108
  const isCurrent = captureSharedCodexAppServerCatalogLifetime(client);
104
109
  const models = (await listAllCodexAppServerModels({
105
110
  request,
@@ -121,12 +126,18 @@ function createCodexAppServerModelCatalog(runtime) {
121
126
  throw error;
122
127
  }
123
128
  });
124
- if (disposed || observations.get(key) !== observation || !result.isCurrent()) return [];
129
+ if (disposed || observations.get(key) !== observation || !result.isCurrent()) return { entries: [] };
125
130
  observation.models = new Set(result.models.map((model) => model.id));
126
131
  observation.accountType = !usesNativeHome || native?.mode === "api-key" && result.accountType === "apiKey" || (native?.mode === "oauth" || native?.mode === "token") && result.accountType === "chatgpt" ? result.accountType : void 0;
127
132
  observation.isCurrent = result.isCurrent;
128
133
  observation.authMode = observation.accountType === "apiKey" ? "api_key" : observation.accountType === "chatgpt" && (native?.mode === "oauth" || native?.mode === "token") ? native.mode : void 0;
129
- return codexAppServerModelsToCatalogEntries(result.models, runtime);
134
+ return {
135
+ entries: codexAppServerModelsToCatalogEntries(result.models, runtime),
136
+ outcomes: [{
137
+ provider: "openai",
138
+ status: observation.accountType ? "ready" : "unavailable"
139
+ }]
140
+ };
130
141
  }
131
142
  };
132
143
  }
@@ -1,4 +1,4 @@
1
- import { d as assertCodexModelListResponse } from "./client-D93nbdB8.mjs";
1
+ import { u as assertCodexModelListResponse } from "./client--P8jwXvA.mjs";
2
2
  import { normalizeOptionalString, normalizeUniqueTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  //#region extensions/codex/src/app-server/models.ts
4
4
  const DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS = 1e4;
@@ -29,8 +29,8 @@ async function listAllCodexAppServerModels(options = {}) {
29
29
  async function withCodexAppServerModelRequest(options, run) {
30
30
  if (options.request) return await run(options.request);
31
31
  const timeoutMs = options.timeoutMs ?? 1e4;
32
- const { getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-BCx1wbyA.mjs").then((n) => n.v);
33
- const { requestCodexAppServerClientJson } = await import("./request-Bo0kKABI.mjs").then((n) => n.i);
32
+ const { getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-CkyTrNB8.mjs").then((n) => n.m);
33
+ const { requestCodexAppServerClientJson } = await import("./request-C6U8q2uz.mjs").then((n) => n.i);
34
34
  const client = await getLeasedSharedCodexAppServerClient({
35
35
  startOptions: options.startOptions,
36
36
  timeoutMs,
@@ -1,8 +1,8 @@
1
1
  import { d as readCodexPluginConfig } from "./config-parsing-DsWSCPHO.mjs";
2
2
  import { n as isCodexAppServerProxyLaunch, t as buildCodexLoginStatusArgs } from "./launch-args-DbFCehO7.mjs";
3
- import { r as resolveManagedCodexAppServerStartOptions } from "./managed-binary-BtIjV7yN.mjs";
4
- import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-CRWTkKOn.mjs";
5
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-DWzK-k0n.mjs";
3
+ import { u as resolveManagedCodexAppServerStartOptions } from "./managed-binary-DbKvGXKl.mjs";
4
+ import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-Bq160Dhv.mjs";
5
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BZRizyuG.mjs";
6
6
  import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
7
7
  import { runUtf8CommandWithTimeout } from "openclaw/plugin-sdk/process-runtime";
8
8
  //#region extensions/codex/src/app-server/native-auth.ts
@@ -21,7 +21,10 @@ async function probeCodexNativeAuth(params) {
21
21
  env: params.env
22
22
  });
23
23
  if (options.start.transport !== "stdio" || options.start.homeScope !== "user" || isCodexAppServerProxyLaunch(options.start.args)) return;
24
- const start = await resolveManagedCodexAppServerStartOptions(options.start, { pluginRoot: params.pluginRoot });
24
+ const start = await resolveManagedCodexAppServerStartOptions(options.start, {
25
+ pluginRoot: params.pluginRoot,
26
+ preferInstalled: false
27
+ });
25
28
  const env = resolveCodexAppServerSpawnEnv(start, params.env ?? process.env);
26
29
  const invocation = materializeWindowsSpawnProgram(resolveWindowsSpawnProgram({
27
30
  command: start.command,