@openclaw/codex 2026.9.5 → 2026.9.7

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 (174) hide show
  1. package/README.md +2 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
  4. package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
  5. package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
  6. package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
  7. package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
  8. package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
  9. package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
  10. package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
  11. package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
  12. package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
  13. package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
  14. package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
  15. package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
  16. package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
  17. package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
  18. package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
  19. package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
  20. package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
  21. package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
  22. package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
  23. package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
  24. package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
  25. package/dist/.setup/compact-C2WamavS.mjs +776 -0
  26. package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
  27. package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
  28. package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
  29. package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
  30. package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
  31. package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
  32. package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
  33. package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
  34. package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
  35. package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
  36. package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
  37. package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
  38. package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
  39. package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
  40. package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
  41. package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
  42. package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
  43. package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
  44. package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
  45. package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
  46. package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
  47. package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
  48. package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
  49. package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
  50. package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
  51. package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
  52. package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
  53. package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
  54. package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
  55. package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
  56. package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
  57. package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
  58. package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
  59. package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
  60. package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
  61. package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
  62. package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
  63. package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
  64. package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
  65. package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
  66. package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
  67. package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
  68. package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
  69. package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
  70. package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
  71. package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
  72. package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
  73. package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
  74. package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
  75. package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
  76. package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
  77. package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
  78. package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
  79. package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
  80. package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
  81. package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
  82. package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
  83. package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
  84. package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
  85. package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
  86. package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
  87. package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
  88. package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
  89. package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
  90. package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
  91. package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
  92. package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
  93. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
  94. package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
  95. package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
  96. package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
  97. package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
  98. package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
  99. package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
  100. package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
  101. package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
  102. package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
  103. package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
  104. package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
  105. package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
  106. package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
  107. package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
  108. package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
  109. package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
  110. package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
  111. package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
  112. package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
  113. package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
  114. package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
  115. package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
  116. package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
  117. package/dist/.setup/thread-lifecycle-DPflntEJ.mjs +2362 -0
  118. package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
  119. package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
  120. package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
  121. package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
  122. package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
  123. package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
  124. package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
  125. package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
  126. package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
  127. package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
  128. package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
  129. package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
  130. package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
  131. package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
  132. package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
  133. package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
  134. package/dist/api.js +25 -16
  135. package/dist/catalog-page-worker-entrypoint.js +12 -0
  136. package/dist/catalog-page.worker.js +9 -0
  137. package/dist/cli-metadata.js +1 -1
  138. package/dist/doctor-contract-api.js +50 -8
  139. package/dist/harness.js +344 -1
  140. package/dist/index.js +345 -346
  141. package/dist/media-understanding-provider.js +9 -22
  142. package/dist/migration-provider-api.js +1 -1
  143. package/dist/provider-discovery.js +1 -1
  144. package/dist/session-history-worker-runtime.js +16 -33
  145. package/dist/session-history.worker.js +1 -1
  146. package/openclaw.plugin.json +14 -2
  147. package/package.json +11 -7
  148. package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
  149. package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
  150. package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
  151. package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
  152. package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
  153. package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
  154. package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
  155. package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
  156. package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
  157. package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
  158. package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
  159. package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
  160. package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
  161. package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
  162. package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
  163. package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
  164. package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
  165. package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
  166. package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
  167. package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
  168. package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
  169. package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
  170. package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
  171. package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
  172. package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
  173. package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
  174. package/dist/.setup/version-CoqzXPgK.mjs +0 -12
package/README.md CHANGED
@@ -34,6 +34,8 @@ For a supervised branch, Codex App Server selects the snapshot fork's model and
34
34
 
35
35
  The visible-history mirror keeps at most 200 user or assistant messages, 512 KiB total, and 64 KiB per message. Image inputs become `[Image attachment]`; image data and local paths are not copied.
36
36
 
37
+ Settled-turn finalization uses the same configured Codex App Server transport as the supervised conversation. Remote websocket App Server configurations stay on their configured transport. Managed user-home stdio launches running inside an Agent home, and not through the proxy launcher, use a private stdio side turn for native-tool isolation. The bounded finalizer preserves the selected model, provider, and native authorization returned by Codex, and rejects native tool evidence outside the finalization contract. It may mirror a final answer after completed tool work; it does not diagnose why a model omitted a visible final message.
38
+
37
39
  When settled-turn recovery rejects history, the `codex settled-turn finalization context capture failed` warning includes a stable `reason`, such as `item_limit`, `byte_limit`, `field_limit`, `unsupported_user_image`, or `snapshot_invalidated`. Unknown failures use `history_read_failed`. The warning excludes transcript content and exception text. Rejected history remains unavailable for finalization, and completed actions are never replayed.
38
40
 
39
41
  See the [Codex harness](https://docs.openclaw.ai/plugins/codex-harness) and [Codex supervision](https://docs.openclaw.ai/plugins/codex-supervision) guides.
package/assets/icon.png CHANGED
Binary file
@@ -1,9 +1,9 @@
1
- import { n as isCodexAppServerProxyLaunch } from "./launch-args-DnMak49W.mjs";
2
- import { t as buildCodexAppServerUsageSnapshot } from "./rate-limits-DOEGYRNs.mjs";
3
- import { n as readCodexAppServerUsage } from "./request-BioXJLYa.mjs";
4
- import "./config-CedDWjM-.mjs";
5
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-CeAhl_h4.mjs";
6
- import { a as resolveCodexAppServerAuthProfileStore } from "./auth-profile-WqZtZfXN.mjs";
1
+ import { n as isCodexAppServerProxyLaunch } from "./launch-args-DbFCehO7.mjs";
2
+ import { t as buildCodexAppServerUsageSnapshot } from "./rate-limits-B7-X2TgG.mjs";
3
+ import { n as readCodexAppServerUsage } from "./request-BHZ1nz8d.mjs";
4
+ import "./config-DKhXquav.mjs";
5
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
6
+ import { a as resolveCodexAppServerAuthProfileStore } from "./auth-profile-B0okYl2D.mjs";
7
7
  import { isDeepStrictEqual } from "node:util";
8
8
  import { listAgentIds, resolveAgentDir } from "openclaw/plugin-sdk/agent-scope-runtime";
9
9
  import { z } from "zod";
@@ -1,21 +1,21 @@
1
- import { c as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-DUle8DLz.mjs";
2
- import { d as readCodexPluginConfig } from "./config-parsing-CcB9iPoq.mjs";
3
- import { s as resolveCodexAppServerFallbackApiKeyCacheKey } from "./auth-cache-key-QirmgiCo.mjs";
4
- import { a as defaultCodexAppInventoryCache, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BOxKP7db.mjs";
5
- import { i as requestCodexAppServerJson } from "./request-BioXJLYa.mjs";
6
- import "./config-CedDWjM-.mjs";
7
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-CeAhl_h4.mjs";
8
- import { i as resolveCodexAppServerAuthProfileIdForAgent } from "./auth-profile-WqZtZfXN.mjs";
9
- import { X as resolveCodexAppServerAuthAccountCacheKey, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, o as clearSharedCodexAppServerClientIfCurrentAndWait } from "./shared-client-BpTtuLQ5.mjs";
10
- import { t as ensureCodexPluginActivation } from "./plugin-activation-r8nq5Jzp.mjs";
11
- import { CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict, n as applyCodexAuthItems, r as resolveCodexConfigPatchMode, readCodexPluginMigrationConfigEntry, t as resolveCodexMigrationTargets } from "./plan-xD7WKYTM.mjs";
1
+ import { n as isOpenAiCuratedMarketplace, u as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-Cky2XJUw.mjs";
2
+ import { d as readCodexPluginConfig } from "./config-parsing-b088LyhT.mjs";
3
+ import { s as resolveCodexAppServerFallbackApiKeyCacheKey } from "./auth-cache-key-Dbvq-QgB.mjs";
4
+ import { a as defaultCodexAppInventoryCache, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BL9B5H0L.mjs";
5
+ import { i as requestCodexAppServerJson } from "./request-BHZ1nz8d.mjs";
6
+ import "./config-DKhXquav.mjs";
7
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
8
+ import { i as resolveCodexAppServerAuthProfileIdForAgent } from "./auth-profile-B0okYl2D.mjs";
9
+ import { c as getLeasedSharedCodexAppServerClient, et as resolveCodexAppServerAuthAccountCacheKey, h as releaseLeasedSharedCodexAppServerClient, o as clearSharedCodexAppServerClientIfCurrentAndWait } from "./shared-client-DqyTMYug.mjs";
10
+ import { t as ensureCodexPluginActivation } from "./plugin-activation-cNHRfaxU.mjs";
11
+ import { CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict, n as resolveCodexConfigPatchMode, readCodexPluginMigrationConfigEntry, t as createCodexAuthItemApplier } from "./plan-Y-QIvrKB.mjs";
12
12
  import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
13
13
  import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
14
14
  import path from "node:path";
15
15
  import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
16
16
  import { sleep } from "openclaw/plugin-sdk/runtime-env";
17
17
  import { MIGRATION_REASON_TARGET_EXISTS, applyMigrationManualItem, markMigrationItemConflict, markMigrationItemError, markMigrationItemSkipped, resolveMigrationConfigRuntime, summarizeMigrationItems, writeMigrationConfigPath } from "openclaw/plugin-sdk/migration";
18
- import { archiveMigrationItem, copyMemoryMigrationFileItem, copyMigrationFileItem, withCachedMigrationConfigRuntime, writeMigrationReport } from "openclaw/plugin-sdk/migration-runtime";
18
+ import { archiveMigrationItem, copyMemoryMigrationFileItem, copyMigrationFileItem, resolvePlannedMigrationTargets, withCachedMigrationConfigRuntime, writeMigrationReport } from "openclaw/plugin-sdk/migration-runtime";
19
19
  //#region extensions/codex/src/migration/apply-report.ts
20
20
  function codexPluginActivationReportState(result) {
21
21
  switch (result.reason) {
@@ -24,7 +24,8 @@ function codexPluginActivationReportState(result) {
24
24
  installed: true,
25
25
  enabled: true
26
26
  };
27
- case "auth_required": return {
27
+ case "auth_required":
28
+ case "refresh_failed": return {
28
29
  installed: true,
29
30
  enabled: false
30
31
  };
@@ -35,20 +36,9 @@ function codexPluginActivationReportState(result) {
35
36
  installed: false,
36
37
  enabled: false
37
38
  };
38
- case "refresh_failed": return {
39
- installed: true,
40
- enabled: false
41
- };
42
39
  }
43
40
  return result.reason;
44
41
  }
45
- function sanitizeAppsNeedingAuth(apps) {
46
- return apps.map((app) => ({
47
- id: app.id,
48
- name: app.name,
49
- needsAuth: true
50
- }));
51
- }
52
42
  //#endregion
53
43
  //#region extensions/codex/src/migration/apply.ts
54
44
  const CODEX_PLUGIN_AUTH_REQUIRED_REASON = "auth_required";
@@ -64,12 +54,9 @@ var CodexPluginConfigConflictError = class extends Error {
64
54
  this.name = "CodexPluginConfigConflictError";
65
55
  }
66
56
  };
67
- function shouldReturnCodexPluginConfigPatch(ctx) {
68
- return resolveCodexConfigPatchMode(ctx) === "return";
69
- }
70
57
  function prepareTargetCodexAppServer(ctx) {
71
58
  const appServer = resolveTargetCodexAppServer(ctx);
72
- const targets = resolveCodexMigrationTargets(ctx);
59
+ const targets = resolvePlannedMigrationTargets(ctx);
73
60
  let warmedClient;
74
61
  const ready = getLeasedSharedCodexAppServerClient({
75
62
  startOptions: appServer.start,
@@ -92,7 +79,7 @@ async function applyCodexMigrationPlan(params) {
92
79
  const plan = params.plan ?? await buildCodexMigrationPlan(params.ctx);
93
80
  const reportDir = params.ctx.reportDir ?? path.join(params.ctx.stateDir, "migration", "codex");
94
81
  const items = [];
95
- const targets = resolveCodexMigrationTargets(params.ctx);
82
+ const targets = resolvePlannedMigrationTargets(params.ctx);
96
83
  const codexHome = typeof plan.metadata?.codexHome === "string" && plan.metadata.codexHome.trim() ? plan.metadata.codexHome : plan.source;
97
84
  const authSource = {
98
85
  codexHome,
@@ -104,18 +91,19 @@ async function applyCodexMigrationPlan(params) {
104
91
  ...params.ctx,
105
92
  runtime
106
93
  };
94
+ const applyAuthItem = createCodexAuthItemApplier({
95
+ ctx: applyCtx,
96
+ source: authSource,
97
+ targets,
98
+ items: plan.items
99
+ });
107
100
  for (const item of plan.items) {
108
101
  if (item.status !== "planned") {
109
102
  items.push(item);
110
103
  continue;
111
104
  }
112
105
  if (item.id === "config:codex-plugins") items.push(await applyCodexPluginConfigItem(applyCtx, item, items));
113
- else if (item.kind === "auth") items.push(...await applyCodexAuthItems({
114
- ctx: applyCtx,
115
- item,
116
- source: authSource,
117
- targets
118
- }));
106
+ else if (item.kind === "auth") items.push(...await applyAuthItem(item));
119
107
  else if (item.kind === "plugin" && item.action === "install") items.push(await applyCodexPluginInstallItem(applyCtx, item));
120
108
  else if (item.kind === "manual") items.push(applyMigrationManualItem(item));
121
109
  else if (item.action === "archive") items.push(await archiveMigrationItem(item, reportDir));
@@ -159,7 +147,7 @@ async function applyCodexPluginInstallItem(ctx, item) {
159
147
  requestParams,
160
148
  timeoutMs: 6e4,
161
149
  startOptions: appServer.start,
162
- agentDir: resolveCodexMigrationTargets(ctx).agentDir,
150
+ agentDir: resolvePlannedMigrationTargets(ctx).agentDir,
163
151
  config: ctx.config,
164
152
  isolated: false
165
153
  }),
@@ -186,7 +174,11 @@ async function applyCodexPluginInstallItem(ctx, item) {
186
174
  reason: CODEX_PLUGIN_AUTH_REQUIRED_REASON,
187
175
  details: {
188
176
  ...baseDetails,
189
- appsNeedingAuth: sanitizeAppsNeedingAuth(result.installResponse?.appsNeedingAuth ?? [])
177
+ appsNeedingAuth: (result.installResponse?.appsNeedingAuth ?? []).map(({ id, name }) => ({
178
+ id,
179
+ name,
180
+ needsAuth: true
181
+ }))
190
182
  }
191
183
  };
192
184
  if (result.reason === "plugin_missing" || result.reason === "marketplace_missing") return {
@@ -206,7 +198,7 @@ async function applyCodexPluginInstallItem(ctx, item) {
206
198
  details: baseDetails
207
199
  };
208
200
  } catch (error) {
209
- if (isCodexPluginInventoryLoadError(error)) return {
201
+ if (coerceErrorMessage(error).includes("codex app-server plugin/list timed out")) return {
210
202
  ...item,
211
203
  status: "warning",
212
204
  reason: "plugin_inventory_unavailable",
@@ -229,9 +221,6 @@ async function applyCodexPluginInstallItem(ctx, item) {
229
221
  };
230
222
  }
231
223
  }
232
- function isCodexPluginInventoryLoadError(error) {
233
- return coerceErrorMessage(error).includes("codex app-server plugin/list timed out");
234
- }
235
224
  function resolveTargetCodexAppServer(ctx) {
236
225
  return resolveCodexAppServerRuntimeOptions({ pluginConfig: readCodexPluginConfig(ctx.config) });
237
226
  }
@@ -241,36 +230,27 @@ async function requestTargetCodexAppServerJson(params) {
241
230
  const discoveryTimeoutMs = targetCodexMarketplaceDiscoveryTimeoutMs();
242
231
  const discoveryDeadline = Math.min(deadline, Date.now() + discoveryTimeoutMs);
243
232
  let lastResponse;
244
- let attempt = 0;
245
233
  do {
246
- attempt += 1;
247
234
  const remainingMs = Math.max(1, discoveryDeadline - Date.now());
248
235
  lastResponse = await requestCodexAppServerJson({
249
236
  ...params,
250
237
  timeoutMs: remainingMs
251
238
  });
252
- if (hasOpenAiCuratedMarketplace(lastResponse)) return lastResponse;
239
+ if (lastResponse.marketplaces.some(isOpenAiCuratedMarketplace)) return lastResponse;
253
240
  if (Date.now() >= discoveryDeadline) return lastResponse;
254
241
  const waitMs = Math.min(TARGET_CODEX_MARKETPLACE_DISCOVERY_POLL_MS, discoveryDeadline - Date.now());
255
242
  await sleep(waitMs);
256
243
  } while (Date.now() < discoveryDeadline);
257
244
  return lastResponse;
258
245
  }
259
- function hasOpenAiCuratedMarketplace(response) {
260
- if (!response || typeof response !== "object" || !("marketplaces" in response)) return false;
261
- const marketplaces = response.marketplaces;
262
- return Array.isArray(marketplaces) && marketplaces.some((marketplace) => marketplace && typeof marketplace === "object" && marketplace.name === "openai-curated");
263
- }
264
246
  function targetCodexMarketplaceDiscoveryTimeoutMs(env = process.env) {
265
- const configured = parseStrictNonNegativeInteger(env[TARGET_CODEX_MARKETPLACE_DISCOVERY_TIMEOUT_ENV]);
266
- if (configured !== void 0) return configured;
267
- return TARGET_CODEX_MARKETPLACE_DISCOVERY_TIMEOUT_MS;
247
+ return parseStrictNonNegativeInteger(env[TARGET_CODEX_MARKETPLACE_DISCOVERY_TIMEOUT_ENV]) ?? TARGET_CODEX_MARKETPLACE_DISCOVERY_TIMEOUT_MS;
268
248
  }
269
249
  function isCodexPluginLoadWarningItem(item) {
270
250
  return item.kind === "plugin" && item.action === "install" && item.status === "warning" && item.details?.warningReason === CODEX_PLUGIN_LOAD_WARNING;
271
251
  }
272
252
  async function buildTargetCodexPluginAppCacheKey(ctx) {
273
- const targets = resolveCodexMigrationTargets(ctx);
253
+ const targets = resolvePlannedMigrationTargets(ctx);
274
254
  const appServer = resolveTargetCodexAppServer(ctx);
275
255
  const authProfileId = resolveCodexAppServerAuthProfileIdForAgent({
276
256
  agentDir: targets.agentDir,
@@ -291,7 +271,7 @@ async function buildTargetCodexPluginAppCacheKey(ctx) {
291
271
  });
292
272
  }
293
273
  async function applyCodexPluginConfigItem(ctx, item, appliedItems) {
294
- if (appliedItems.filter((candidate) => candidate.kind === "plugin" && candidate.action === "install" && readCodexPluginPolicy(candidate) !== void 0 && !isCodexPluginConfigTerminal(candidate)).length > 0) return {
274
+ if (appliedItems.some((candidate) => candidate.kind === "plugin" && candidate.action === "install" && readCodexPluginPolicy(candidate) !== void 0 && !isCodexPluginConfigTerminal(candidate))) return {
295
275
  ...item,
296
276
  status: "warning",
297
277
  reason: "selected Codex plugin activation is incomplete"
@@ -301,7 +281,7 @@ async function applyCodexPluginConfigItem(ctx, item, appliedItems) {
301
281
  ...markMigrationItemSkipped(item, "no selected Codex plugins"),
302
282
  deferredCompletion: true
303
283
  };
304
- const returnPatch = shouldReturnCodexPluginConfigPatch(ctx);
284
+ const returnPatch = resolveCodexConfigPatchMode(ctx) === "return";
305
285
  const configApi = resolveMigrationConfigRuntime(ctx);
306
286
  const currentConfig = returnPatch ? ctx.config : configApi?.current?.();
307
287
  if (!currentConfig) return markMigrationItemError(item, "config runtime unavailable");
@@ -1,21 +1,132 @@
1
- import { m as isJsonObject } from "./config-security-BRQ2mgW9.mjs";
2
- import { a as isCodexAppServerBrokenPipeError, d as isCodexAppServerRequestTimeoutError, l as isCodexAppServerOverloadError } from "./client-vXs2929Q.mjs";
3
- import { m as retireSharedCodexAppServerClientIfCurrent } from "./auth-cache-key-QirmgiCo.mjs";
4
- import { i as CodexAppServerRpcError } from "./timeout-DZF05XrR.mjs";
5
- import { h as unknownItemStatus } from "./event-projector-items-DyTQ_XqL.mjs";
6
- import { G as unsubscribeCodexAppServerLiveThread, rt as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-BpTtuLQ5.mjs";
7
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
+ import { d as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-lifecycle-DJIgqgMw.mjs";
3
+ import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
4
+ import { n as waitForPromiseOrAbort, t as abortReason } from "./timeout-CXOfNoaX.mjs";
5
+ import { J as unsubscribeCodexAppServerLiveThread, ft as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-DqyTMYug.mjs";
6
+ import { E as readCodexTurnCompletedNotification, a as isCodexAppServerBrokenPipeError, d as isCodexAppServerRequestTimeoutError, l as isCodexAppServerOverloadError } from "./client-N0JpgSzF.mjs";
7
+ import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
8
+ import { normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
8
9
  import { AsyncResource } from "node:async_hooks";
9
10
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
10
- import { AgentHarnessPreflightError, embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
11
11
  import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
12
+ import { AgentHarnessPreflightError, embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
12
13
  import { redactSensitiveText } from "openclaw/plugin-sdk/logging-core";
14
+ //#region extensions/codex/src/app-server/event-projector-items.ts
15
+ const itemStatuses = /* @__PURE__ */ new Map([
16
+ ["completed", "completed"],
17
+ ["failed", "failed"],
18
+ ["error", "failed"],
19
+ ["declined", "blocked"],
20
+ ["inProgress", "running"],
21
+ ["in_progress", "running"],
22
+ ["running", "running"]
23
+ ]);
24
+ const itemPresentations = /* @__PURE__ */ new Map([
25
+ ["dynamicToolCall", {
26
+ kind: "tool",
27
+ title: "Tool"
28
+ }],
29
+ ["mcpToolCall", {
30
+ kind: "tool",
31
+ title: "MCP tool",
32
+ projectedTool: true
33
+ }],
34
+ ["commandExecution", {
35
+ kind: "command",
36
+ title: "Command",
37
+ toolName: "bash",
38
+ projectedTool: true
39
+ }],
40
+ ["fileChange", {
41
+ kind: "patch",
42
+ title: "File change",
43
+ toolName: "apply_patch",
44
+ projectedTool: true
45
+ }],
46
+ ["webSearch", {
47
+ kind: "search",
48
+ title: "Web search",
49
+ toolName: "web_search",
50
+ projectedTool: true
51
+ }],
52
+ ["contextCompaction", {
53
+ kind: "analysis",
54
+ title: "Context compaction"
55
+ }],
56
+ ["reasoning", {
57
+ kind: "analysis",
58
+ title: "Reasoning"
59
+ }]
60
+ ]);
61
+ function matchesCodexSnapshotTurn(item, turnId) {
62
+ const itemTurnId = readStringField(item, "turnId");
63
+ return itemTurnId === void 0 || itemTurnId === turnId;
64
+ }
65
+ function itemKind(item) {
66
+ return itemPresentations.get(item.type)?.kind;
67
+ }
68
+ function itemTitle(item) {
69
+ return itemPresentations.get(item.type)?.title ?? item.type;
70
+ }
71
+ function itemStatus(item) {
72
+ return itemStatuses.get(readStringField(item, "status") ?? "") ?? "completed";
73
+ }
74
+ function unknownItemStatus(item) {
75
+ const status = readStringField(item, "status");
76
+ return status === void 0 || itemStatuses.has(status) ? void 0 : status;
77
+ }
78
+ function auditNativeToolTerminalStatus(item) {
79
+ if (item.type === "imageView" || item.type === "sleep") return "completed";
80
+ const status = itemStatuses.get(readStringField(item, "status") ?? "");
81
+ return status === void 0 || status === "running" ? "unknown" : status;
82
+ }
83
+ function auditNativeToolUnfinishedStatus(item) {
84
+ return item.type === "webSearch" || item.type === "imageGeneration" ? "unknown" : "failed";
85
+ }
86
+ function isNonSuccessItemStatus(status) {
87
+ return status === "failed" || status === "blocked";
88
+ }
89
+ function itemName(item) {
90
+ if (item.type === "dynamicToolCall" && typeof item.tool === "string") return item.tool;
91
+ if (item.type === "mcpToolCall" && typeof item.tool === "string") {
92
+ const server = typeof item.server === "string" ? item.server : void 0;
93
+ return server ? `${server}.${item.tool}` : item.tool;
94
+ }
95
+ return itemPresentations.get(item.type)?.toolName;
96
+ }
97
+ function auditNativeToolName(item) {
98
+ if (item.type === "dynamicToolCall") return;
99
+ const progressName = itemName(item);
100
+ if (progressName) return progressName;
101
+ if (item.type === "collabAgentToolCall") return typeof item.tool === "string" && item.tool.trim() ? `collab.${item.tool.trim()}` : "collab_agent";
102
+ if (item.type === "imageGeneration") return "image_generation";
103
+ if (item.type === "imageView") return "image_view";
104
+ if (item.type === "sleep") return "sleep";
105
+ }
106
+ function isSideEffectingNativeToolItem(item) {
107
+ return itemStatus(item) !== "blocked" && (isMutatingNativeToolItem(item) || item.type === "mcpToolCall");
108
+ }
109
+ function isProjectedNativeToolItem(item) {
110
+ return itemPresentations.get(item.type)?.projectedTool === true;
111
+ }
112
+ function isMutatingNativeToolItem(item) {
113
+ if (item.type === "commandExecution") return true;
114
+ return item.type === "fileChange" || item.type === "collabAgentToolCall" || item.type === "imageGeneration";
115
+ }
116
+ function shouldClearTerminalPresentationForNativeItem(item) {
117
+ switch (item.type) {
118
+ case "collabAgentToolCall":
119
+ case "commandExecution":
120
+ case "fileChange":
121
+ case "imageGeneration":
122
+ case "imageView":
123
+ case "mcpToolCall":
124
+ case "webSearch": return true;
125
+ default: return false;
126
+ }
127
+ }
128
+ //#endregion
13
129
  //#region extensions/codex/src/app-server/notification-correlation.ts
14
- /**
15
- * Correlates Codex app-server notifications with the active thread/turn so
16
- * projectors can ignore global or stale events without losing diagnostics.
17
- */
18
- /** Returns true when a notification payload belongs to the exact active thread and turn. */
19
130
  function isCodexNotificationForTurn(value, threadId, turnId) {
20
131
  if (!isJsonObject(value)) return false;
21
132
  return readCodexNotificationThreadId(value) === threadId && readCodexNotificationTurnId(value) === turnId;
@@ -30,13 +141,8 @@ function readCodexNotificationThreadId(record) {
30
141
  const thread = isJsonObject(record.thread) ? record.thread : void 0;
31
142
  return normalizeOptionalString(record.threadId) ?? (thread ? normalizeOptionalString(thread.id) : void 0);
32
143
  }
33
- /** Reads a turn id from either top-level notification params or nested turn payloads. */
34
144
  function readCodexNotificationTurnId(record) {
35
- return readNestedTurnId(record) ?? normalizeOptionalString(record.turnId);
36
- }
37
- function readNestedTurnId(record) {
38
- const turn = record.turn;
39
- return isJsonObject(turn) ? normalizeOptionalString(turn.id) : void 0;
145
+ return (isJsonObject(record.turn) ? normalizeOptionalString(record.turn.id) : void 0) ?? normalizeOptionalString(record.turnId);
40
146
  }
41
147
  //#endregion
42
148
  //#region extensions/codex/src/app-server/event-projector-diagnostics.ts
@@ -87,7 +193,6 @@ var CodexProjectionDiagnostics = class {
87
193
  };
88
194
  //#endregion
89
195
  //#region extensions/codex/src/app-server/turn-router.ts
90
- /** Keyed routing for all turn traffic on one shared Codex app-server client. */
91
196
  const DEFAULT_PREBIND_NOTIFICATION_LIMIT = 256;
92
197
  const DEFAULT_GLOBAL_WARNING_LIMIT = 32;
93
198
  const CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS = 3e4;
@@ -95,7 +200,6 @@ const routers = /* @__PURE__ */ new WeakMap();
95
200
  function hasCodexAppServerSiblingRouteWork(client, threadId) {
96
201
  return routers.get(client)?.hasSiblingWork(threadId) ?? false;
97
202
  }
98
- /** Returns the sole router installed on a physical app-server client. */
99
203
  function getCodexAppServerTurnRouter(client) {
100
204
  const existing = routers.get(client);
101
205
  if (existing) return existing;
@@ -115,9 +219,7 @@ var ClientTurnRouter = class {
115
219
  this.nativeTurnCompletionWatchers = /* @__PURE__ */ new Map();
116
220
  client.addNotificationHandler((notification) => this.routeNotification(notification));
117
221
  client.addRequestHandler((request, signal, setExecutionTimeoutMs) => this.routeRequest(request, signal, setExecutionTimeoutMs));
118
- client.addCloseHandler((closedClient) => {
119
- this.dispose(closedClient.getCloseError());
120
- });
222
+ client.addCloseHandler((closedClient) => this.dispose(closedClient.getCloseError()));
121
223
  }
122
224
  reserveThread(options) {
123
225
  this.assertActive();
@@ -160,7 +262,7 @@ var ClientTurnRouter = class {
160
262
  armTurn: () => this.armTurn(route),
161
263
  bindTurn: (turnId, bindingOptions) => this.bindTurn(route, turnId, bindingOptions),
162
264
  cancelTurn: () => this.cancelTurn(route),
163
- drain: () => this.drainNotifications(route),
265
+ drain: () => this.waitForNotifications(route),
164
266
  release: () => this.release(route)
165
267
  };
166
268
  }
@@ -168,15 +270,10 @@ var ClientTurnRouter = class {
168
270
  this.assertActive();
169
271
  const threadId = requireId(options.threadId, "thread id");
170
272
  const turnId = requireId(options.turnId, "turn id");
171
- if (options.signal?.aborted) return {
172
- completion: Promise.resolve(false),
173
- state: "unconfirmed",
174
- settledSignal: AbortSignal.abort(),
175
- cancel: () => {}
176
- };
177
- if (this.routes.get(threadId)?.completedNativeTurnIds.has(turnId)) return {
178
- completion: Promise.resolve(true),
179
- state: "confirmed",
273
+ const confirmed = !options.signal?.aborted && this.routes.get(threadId)?.completedNativeTurnIds.has(turnId) === true;
274
+ if (options.signal?.aborted || confirmed) return {
275
+ completion: Promise.resolve(confirmed),
276
+ state: confirmed ? "confirmed" : "unconfirmed",
180
277
  settledSignal: AbortSignal.abort(),
181
278
  cancel: () => {}
182
279
  };
@@ -266,10 +363,22 @@ var ClientTurnRouter = class {
266
363
  if (route.gate !== "armed") throw new Error(`codex app-server thread route cannot bind from ${route.gate}`);
267
364
  route.gate = "bound";
268
365
  route.turnId = turnId;
366
+ if (options?.beforeNotifications) {
367
+ route.notificationPause = options.beforeNotifications.then(() => {
368
+ route.notificationPause = void 0;
369
+ this.flushNotifications(route);
370
+ }, (cause) => {
371
+ const error = new Error("codex app-server notification barrier failed", { cause });
372
+ this.release(route, error);
373
+ throw error;
374
+ });
375
+ route.notificationPause.catch(() => {});
376
+ }
269
377
  this.flushNotifications(route);
270
378
  route.binding?.resolve();
271
379
  await this.waitForNotifications(route);
272
380
  this.assertRoute(route, turnId);
381
+ await route.notificationPause;
273
382
  await route.notificationTail;
274
383
  }
275
384
  routeNotification(notification) {
@@ -282,13 +391,14 @@ var ClientTurnRouter = class {
282
391
  this.bufferNotification(route, notification, { threadId: route.threadId }, Date.now());
283
392
  if (route.gate === "bound") this.flushNotifications(route);
284
393
  }
285
- return Promise.all([...this.routes.values()].map((route) => route.notificationTail)).then(() => void 0);
394
+ return Promise.all([...this.routes.values()].map((route) => this.waitForNotifications(route))).then(() => void 0);
286
395
  }
287
396
  const watchers = scope.threadId ? this.nativeTurnCompletionWatchers.get(scope.threadId) : void 0;
288
397
  const route = scope.threadId ? this.routes.get(scope.threadId) : void 0;
289
398
  if (!watchers && !route) return;
399
+ const completedTurn = notification.method === "turn/completed" && readCodexTurnCompletedNotification(notification.params) !== void 0;
290
400
  if (scope.turnId && watchers) {
291
- for (const watcher of watchers) if (watcher.turnId === scope.turnId && notification.method === "turn/completed") watcher.finish(true);
401
+ for (const watcher of watchers) if (watcher.turnId === scope.turnId && completedTurn) watcher.finish(true);
292
402
  else if (watcher.turnId === scope.turnId && notification.method === "turn/started") watcher.onStarted?.();
293
403
  }
294
404
  if (!route) return;
@@ -304,7 +414,7 @@ var ClientTurnRouter = class {
304
414
  id: scope.turnId,
305
415
  completed: false
306
416
  };
307
- } else if (notification.method === "turn/completed") {
417
+ } else if (completedTurn) {
308
418
  if (route.gate === "bound") route.completedNativeTurnIds.clear();
309
419
  route.completedNativeTurnIds.add(scope.turnId);
310
420
  if (!route.observedNativeTurn || route.observedNativeTurn.completed || route.observedNativeTurn.id === scope.turnId) route.observedNativeTurn = {
@@ -323,7 +433,7 @@ var ClientTurnRouter = class {
323
433
  this.warnDroppedStaleTurnNotification(route, notification, routeScope);
324
434
  return;
325
435
  }
326
- if (route.gate === "armed") {
436
+ if (route.gate === "armed" || route.notificationPause) {
327
437
  this.bufferNotification(route, notification, routeScope, receivedAtMs);
328
438
  return;
329
439
  }
@@ -375,10 +485,16 @@ var ClientTurnRouter = class {
375
485
  this.warnDroppedStaleTurnNotification(route, pending.notification, pending.scope);
376
486
  continue;
377
487
  }
378
- route.handlers?.onNotificationReceived?.(pending.notification, pending.scope, pending.receivedAtMs);
379
- this.enqueueNotification(route, handler, pending.notification, pending.scope);
488
+ this.observeNotificationReceipt(route, pending);
489
+ if (route.notificationPause) route.pending.push(pending);
490
+ else this.enqueueNotification(route, handler, pending.notification, pending.scope);
380
491
  }
381
492
  }
493
+ observeNotificationReceipt(route, pending) {
494
+ if (pending.receiptObserved) return;
495
+ pending.receiptObserved = true;
496
+ route.handlers?.onNotificationReceived?.(pending.notification, pending.scope, pending.receivedAtMs);
497
+ }
382
498
  warnDroppedStaleTurnNotification(route, notification, scope) {
383
499
  if (notification.method === "turn/completed" || !scope.turnId || !route.turnId) return;
384
500
  const eventKind = redactCodexEventKind(notification.method);
@@ -396,12 +512,14 @@ var ClientTurnRouter = class {
396
512
  });
397
513
  }
398
514
  bufferNotification(route, notification, scope, receivedAtMs) {
515
+ const pending = {
516
+ notification,
517
+ receivedAtMs,
518
+ scope
519
+ };
520
+ if (route.gate === "bound") this.observeNotificationReceipt(route, pending);
399
521
  if (route.pending.length < DEFAULT_PREBIND_NOTIFICATION_LIMIT) {
400
- route.pending.push({
401
- notification,
402
- receivedAtMs,
403
- scope
404
- });
522
+ route.pending.push(pending);
405
523
  return;
406
524
  }
407
525
  const error = /* @__PURE__ */ new Error(`codex app-server pre-bind notification buffer exceeded ${DEFAULT_PREBIND_NOTIFICATION_LIMIT} entries for thread ${route.threadId}`);
@@ -420,9 +538,7 @@ var ClientTurnRouter = class {
420
538
  });
421
539
  }
422
540
  async waitForNotifications(route) {
423
- await Promise.race([route.notificationTail, route.ended.promise]);
424
- }
425
- async drainNotifications(route) {
541
+ if (route.notificationPause) await Promise.race([route.notificationPause, route.ended.promise]);
426
542
  await Promise.race([route.notificationTail, route.ended.promise]);
427
543
  }
428
544
  release(route, error = /* @__PURE__ */ new Error("codex app-server thread route is released")) {
@@ -446,23 +562,6 @@ var ClientTurnRouter = class {
446
562
  if (route.released && !this.canDrainClosedTurn(route, completedTurnId)) throw route.released;
447
563
  }
448
564
  };
449
- async function waitForPromiseOrAbort(promise, signal) {
450
- if (signal.aborted) return false;
451
- let removeAbort;
452
- try {
453
- return await Promise.race([promise.then(() => true), new Promise((resolve) => {
454
- const onAbort = () => resolve(false);
455
- signal.addEventListener("abort", onAbort, { once: true });
456
- removeAbort = () => signal.removeEventListener("abort", onAbort);
457
- if (signal.aborted) onAbort();
458
- })]);
459
- } finally {
460
- removeAbort?.();
461
- }
462
- }
463
- function abortReason(signal) {
464
- return signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "codex app-server thread route aborted"));
465
- }
466
565
  function readScope(value) {
467
566
  if (!isJsonObject(value)) return {};
468
567
  const threadId = readCodexNotificationThreadId(value);
@@ -479,12 +578,21 @@ function requireId(value, label) {
479
578
  }
480
579
  //#endregion
481
580
  //#region extensions/codex/src/app-server/attempt-client-cleanup.ts
482
- /**
483
- * Best-effort cleanup helpers for Codex app-server startup attempts and turns.
484
- */
485
- /** Timeout for best-effort app-server turn interruption during cleanup. */
581
+ var attempt_client_cleanup_exports = /* @__PURE__ */ __exportAll({
582
+ CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS: () => CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS,
583
+ CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS: () => CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS,
584
+ CodexAppServerUnsafeSubscriptionError: () => CodexAppServerUnsafeSubscriptionError,
585
+ assertCodexThreadResumeSubscription: () => assertCodexThreadResumeSubscription,
586
+ closeCodexStartupClientBestEffort: () => closeCodexStartupClientBestEffort,
587
+ interruptCodexTurnAndWaitBestEffort: () => interruptCodexTurnAndWaitBestEffort,
588
+ isCodexAppServerUnsafeSubscriptionError: () => isCodexAppServerUnsafeSubscriptionError,
589
+ isCodexNoActiveTurnInterruptError: () => isCodexNoActiveTurnInterruptError,
590
+ retireUnsafeCodexTurnClientBestEffort: () => retireUnsafeCodexTurnClientBestEffort,
591
+ shouldRetireCodexStartupClient: () => shouldRetireCodexStartupClient,
592
+ terminateCodexBackgroundTerminals: () => terminateCodexBackgroundTerminals,
593
+ unsubscribeCodexThreadBestEffort: () => unsubscribeCodexThreadBestEffort
594
+ });
486
595
  const CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS = 5e3;
487
- /** Timeout for best-effort thread unsubscribe during cleanup. */
488
596
  const CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS = 5e3;
489
597
  const CODEX_NO_ACTIVE_TURN_ERROR_CODE = -32600;
490
598
  const CODEX_NO_ACTIVE_TURN_ERROR_MESSAGE = "no active turn to interrupt";
@@ -502,7 +610,6 @@ var CodexAppServerUnsafeSubscriptionError = class extends Error {
502
610
  function isCodexAppServerUnsafeSubscriptionError(error) {
503
611
  return error instanceof CodexAppServerUnsafeSubscriptionError;
504
612
  }
505
- /** Asserts Codex resumed the exact thread this attempt subscribed to. */
506
613
  function assertCodexThreadResumeSubscription(requestedThreadId, returnedThreadId) {
507
614
  if (returnedThreadId !== requestedThreadId) throw new CodexAppServerUnsafeSubscriptionError(`Codex thread/resume returned ${returnedThreadId} for ${requestedThreadId}`);
508
615
  }
@@ -601,7 +708,6 @@ async function terminateCodexBackgroundTerminals(client, threadId, oneShotCliRun
601
708
  throw new Error("Codex background-terminal cleanup failed; inspect the thread's running terminals before starting more work.", { cause });
602
709
  }
603
710
  }
604
- /** Unsubscribes from a thread while swallowing cleanup-only failures. */
605
711
  async function unsubscribeCodexThreadBestEffort(client, params) {
606
712
  try {
607
713
  await unsubscribeCodexAppServerLiveThread(client, params.threadId, params.timeoutMs, params.assertCurrent);
@@ -620,4 +726,4 @@ function shouldRetireCodexStartupClient(error, spawnedBy, signal) {
620
726
  return !isCodexAppServerStartSelectionChangedError(error) && !isCodexAppServerOverloadError(error) && !(error instanceof AgentHarnessPreflightError && error.scope === void 0) && (isCodexAppServerBrokenPipeError(error) || !spawnedBy);
621
727
  }
622
728
  //#endregion
623
- export { CodexProjectionDiagnostics as _, closeCodexStartupClientBestEffort as a, readCodexNotificationTurnId as b, isCodexNoActiveTurnInterruptError as c, terminateCodexBackgroundTerminals as d, unsubscribeCodexThreadBestEffort as f, waitForPromiseOrAbort as g, hasCodexAppServerSiblingRouteWork as h, assertCodexThreadResumeSubscription as i, retireUnsafeCodexTurnClientBestEffort as l, getCodexAppServerTurnRouter as m, CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS as n, interruptCodexTurnAndWaitBestEffort as o, CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS as p, CodexAppServerUnsafeSubscriptionError as r, isCodexAppServerUnsafeSubscriptionError as s, CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS as t, shouldRetireCodexStartupClient as u, isCodexNotificationForTurn as v, readCodexNotificationThreadId as y };
729
+ export { itemStatus as A, auditNativeToolUnfinishedStatus as C, isSideEffectingNativeToolItem as D, isProjectedNativeToolItem as E, matchesCodexSnapshotTurn as M, shouldClearTerminalPresentationForNativeItem as N, itemKind as O, unknownItemStatus as P, auditNativeToolTerminalStatus as S, isNonSuccessItemStatus as T, CodexProjectionDiagnostics as _, attempt_client_cleanup_exports as a, readCodexNotificationTurnId as b, isCodexAppServerUnsafeSubscriptionError as c, shouldRetireCodexStartupClient as d, terminateCodexBackgroundTerminals as f, hasCodexAppServerSiblingRouteWork as g, getCodexAppServerTurnRouter as h, assertCodexThreadResumeSubscription as i, itemTitle as j, itemName as k, isCodexNoActiveTurnInterruptError as l, CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS as m, CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS as n, closeCodexStartupClientBestEffort as o, unsubscribeCodexThreadBestEffort as p, CodexAppServerUnsafeSubscriptionError as r, interruptCodexTurnAndWaitBestEffort as s, CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS as t, retireUnsafeCodexTurnClientBestEffort as u, isCodexNotificationForTurn as v, isMutatingNativeToolItem as w, auditNativeToolName as x, readCodexNotificationThreadId as y };