@openclaw/codex 2026.10.2 → 2026.10.5-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/.setup/{account-usage-runtime-DPXsyONK.mjs → account-usage-runtime-B6S1BQU7.mjs} +8 -7
  2. package/dist/.setup/{app-server-policy-Bg4FZw1f.mjs → app-server-policy-D_zv8J7V.mjs} +3 -4
  3. package/dist/.setup/{apply-CQ3brq3z.mjs → apply-Cc1DfWPz.mjs} +40 -51
  4. package/dist/.setup/{attempt-client-cleanup-DPUGAWP2.mjs → attempt-client-cleanup-CxX4cTSi.mjs} +6 -6
  5. package/dist/.setup/attempt-terminal-jO5IMj9K.mjs +2 -0
  6. package/dist/.setup/{attempt-workspace-context-GllQy8mw.mjs → attempt-workspace-context-CcwP3DA3.mjs} +21 -18
  7. package/dist/.setup/{auth-binding-BoMwpuPN.mjs → auth-binding-BaxlhaNx.mjs} +2 -2
  8. package/dist/.setup/{auth-cache-key-BE1HXsNo.mjs → auth-cache-key-tENCQOub.mjs} +30 -41
  9. package/dist/.setup/{binding-connection-C-08ez1w.mjs → binding-connection-B7HAAZSI.mjs} +2 -2
  10. package/dist/.setup/{binding-connection.runtime-Dn2p-fdy.mjs → binding-connection.runtime-DAXn7iFl.mjs} +6 -5
  11. package/dist/.setup/{bounded-turn-9YflG60n.mjs → bounded-turn-DxtRqV8t.mjs} +21 -17
  12. package/dist/.setup/{bounded-turn-isolation-DklXNk3k.mjs → bounded-turn-isolation-BfDAo-qZ.mjs} +4 -4
  13. package/dist/.setup/{build-state-LS-A65iX.mjs → build-state-CMYRQ_We.mjs} +1 -1
  14. package/dist/.setup/{capabilities-kQntafj_.mjs → capabilities-DbOzOglY.mjs} +1 -1
  15. package/dist/.setup/{client-catalog-response-BprQziLV.mjs → client-catalog-response-B7oqHQGO.mjs} +25 -32
  16. package/dist/.setup/{client-ChJtGEdJ.mjs → client-zrCKOu_E.mjs} +198 -247
  17. package/dist/.setup/{command-dispatch-BoC9hvFs.mjs → command-dispatch-ImiHvcyW.mjs} +3 -4
  18. package/dist/.setup/{command-formatters-DV3DHhdr.mjs → command-formatters-xW9KpoSZ.mjs} +16 -26
  19. package/dist/.setup/{command-handlers-BVX2quUD.mjs → command-handlers-B8CT4ngS.mjs} +270 -360
  20. package/dist/.setup/{command-rpc-M4gYsRiV.mjs → command-rpc-HtQjCQBg.mjs} +19 -18
  21. package/dist/.setup/{compact-D3JNLG_b.mjs → compact-Do9HPeDr.mjs} +41 -61
  22. package/dist/.setup/{computer-use-CF0jsDi1.mjs → computer-use-CeF5GuCX.mjs} +109 -147
  23. package/dist/.setup/{config-0Gxk3_eq.mjs → config-C1YVVLEA.mjs} +32 -59
  24. package/dist/.setup/config-contracts.shared-D85SGEuq.mjs +4 -0
  25. package/dist/.setup/{config-options-HG_Rr3W_.mjs → config-options-DDzeNQ8m.mjs} +52 -90
  26. package/dist/.setup/{config-parsing-BQq-CHTF.mjs → config-parsing-DsWSCPHO.mjs} +19 -55
  27. package/dist/.setup/{config-runtime-cUYrqu_a.mjs → config-runtime-DWzK-k0n.mjs} +2 -2
  28. package/dist/.setup/{config-security-KAPScztc.mjs → config-security-clxAZYWX.mjs} +35 -39
  29. package/dist/.setup/config-utils-DN_YT7dE.mjs +47 -0
  30. package/dist/.setup/{context-engine-projection-CsgYSQhW.mjs → context-engine-projection-ps-yn_ci.mjs} +10 -22
  31. package/dist/.setup/{conversation-binding-7kceEUf0.mjs → conversation-binding-D78aEdkE.mjs} +85 -119
  32. package/dist/.setup/{conversation-binding-data-DJ4ix-W5.mjs → conversation-binding-data-UgLuTSQT.mjs} +9 -8
  33. package/dist/.setup/{conversation-control-BpJpPo0t.mjs → conversation-control-GXM3unE4.mjs} +7 -10
  34. package/dist/.setup/{cyber-failover-Bb1J6hS1.mjs → cyber-failover-D4dgNfFf.mjs} +2 -5
  35. package/dist/.setup/{cyber-failover-notice-XR03ef31.mjs → cyber-failover-notice-ljgGGL0s.mjs} +1 -1
  36. package/dist/.setup/{doctor-start-options-DPW9JxIE.mjs → doctor-start-options-JjTAl-q_.mjs} +5 -5
  37. package/dist/.setup/{dynamic-tool-build-BCi00feJ.mjs → dynamic-tool-build-BMiiFROa.mjs} +57 -69
  38. package/dist/.setup/{dynamic-tools-DUv6Sr6h.mjs → dynamic-tools-DPPHrGKB.mjs} +680 -709
  39. package/dist/.setup/{effective-mcp-catalog-CIdbHp1t.mjs → effective-mcp-catalog-x3JVEcJp.mjs} +11 -20
  40. package/dist/.setup/{elicitation-input-r9axtppm.mjs → elicitation-input-DXG_qaXr.mjs} +14 -20
  41. package/dist/.setup/{ephemeral-turn-U4th15a6.mjs → ephemeral-turn-Dk0wWoqi.mjs} +3 -3
  42. package/dist/.setup/{event-projector-assistant-message-BwG5TUYW.mjs → event-projector-assistant-message-CLMKN4x-.mjs} +2 -2
  43. package/dist/.setup/{event-projector-usage-03R0I2dM.mjs → event-projector-usage-BpKfdoTm.mjs} +20 -33
  44. package/dist/.setup/{event-projector-values-DTqZHizf.mjs → event-projector-values-CLvG1Hil.mjs} +4 -5
  45. package/dist/.setup/history-rejection-B4nOXNXF.mjs +13 -0
  46. package/dist/.setup/{inference-context-D-9gWlTR.mjs → inference-context-DNlGwzwy.mjs} +10 -11
  47. package/dist/.setup/{inference-dispatch-B5UKEUyC.mjs → inference-dispatch-CO6tTs4q.mjs} +5 -4
  48. package/dist/.setup/{inference-metadata-CgIf7sOx.mjs → inference-metadata-DCvcG_N_.mjs} +36 -41
  49. package/dist/.setup/{inference-proxy-DUO5E2QQ.mjs → inference-proxy-BDWV0djM.mjs} +10 -14
  50. package/dist/.setup/{isolated-completion-C6QKyyDS.mjs → isolated-completion-z0ii1a_V.mjs} +8 -8
  51. package/dist/.setup/local-runtime-attribution-CZz2DJ4q.mjs +15 -0
  52. package/dist/.setup/{managed-binary-C1VFoVPf.mjs → managed-binary-BtIjV7yN.mjs} +16 -36
  53. package/dist/.setup/{mcp-app-session-preparation-JFCtSkRp.mjs → mcp-app-session-preparation-GTx-bRGN.mjs} +24 -25
  54. package/dist/.setup/{mcp-tool-metadata-j10HhfTC.mjs → mcp-tool-metadata-DW41snf3.mjs} +1 -1
  55. package/dist/.setup/{model-catalog-DD-evckc.mjs → model-catalog-VUdFUqnH.mjs} +8 -8
  56. package/dist/.setup/{models-DaW-7tld.mjs → models-Dph0RqpR.mjs} +6 -10
  57. package/dist/.setup/{native-auth-Cjb9y7IZ.mjs → native-auth-esN5MdIv.mjs} +5 -5
  58. package/dist/.setup/{native-execution-policy-ClzpdG3D.mjs → native-execution-policy-MXEe7PB3.mjs} +11 -28
  59. package/dist/.setup/native-hook-relay-CSZpcjwq.mjs +561 -0
  60. package/dist/.setup/{native-mcp-app-ChpyWmL-.mjs → native-mcp-app-CDrrBaTE.mjs} +6 -6
  61. package/dist/.setup/native-skill-isolation-BAatEJZb.mjs +391 -0
  62. package/dist/.setup/{native-subagent-monitor-wh_-K3Vo.mjs → native-subagent-monitor-D5O_o07p.mjs} +505 -639
  63. package/dist/.setup/{native-subagent-pending-assignments-BDqhOdJp.mjs → native-subagent-pending-assignments-DmVhedNs.mjs} +11 -23
  64. package/dist/.setup/{native-task-assignments-C6KVqiN1.mjs → native-task-assignments-DimsQ9Qa.mjs} +73 -27
  65. package/dist/.setup/{node-cli-sessions-B5oNDkUS.mjs → node-cli-sessions-CzKg2nGq.mjs} +18 -26
  66. package/dist/.setup/{node-exec-server.runtime-0xSEjKYt.mjs → node-exec-server.runtime-BWkULhBM.mjs} +5 -8
  67. package/dist/.setup/{plan-CUHSuL6_.mjs → plan-QNW5zpFp.mjs} +40 -50
  68. package/dist/.setup/{plugin-activation-BcyBv8PG.mjs → plugin-activation-D7WkJMvU.mjs} +4 -5
  69. package/dist/.setup/{plugin-app-cache-key-BW8rd98k.mjs → plugin-app-cache-key-Bg9DbDI6.mjs} +18 -23
  70. package/dist/.setup/{plugin-approval-roundtrip-bPQbG8BI.mjs → plugin-approval-roundtrip-DOQ3Tibe.mjs} +4 -6
  71. package/dist/.setup/{plugin-inventory-Bf0_piTw.mjs → plugin-inventory-CYgdo14P.mjs} +28 -43
  72. package/dist/.setup/{plugin-marketplace-discovery-SQPhSuic.mjs → plugin-marketplace-discovery-BblHM3DU.mjs} +7 -10
  73. package/dist/.setup/{plugin-metadata-cache-DWnB7VMj.mjs → plugin-metadata-cache-Bi8TAPwX.mjs} +5 -10
  74. package/dist/.setup/project-doc-thread-config-BVcvnps8.mjs +490 -0
  75. package/dist/.setup/{provider-Ct6-1lsF.mjs → provider-BG5nXBnY.mjs} +4 -4
  76. package/dist/.setup/{provider-capabilities-DhkeeHJd.mjs → provider-capabilities-DtJKxDf6.mjs} +1 -1
  77. package/dist/.setup/{rate-limits-CMPy24F5.mjs → rate-limits-CI8pTPqL.mjs} +15 -32
  78. package/dist/.setup/reasoning-effort-CS9kKWB9.mjs +37 -0
  79. package/dist/.setup/{request-CZkKkN6c.mjs → request-6piO0U_P.mjs} +28 -48
  80. package/dist/.setup/{rpc-error-hmWM21RB.mjs → rpc-error-C98SHchT.mjs} +3 -6
  81. package/dist/.setup/{run-attempt-C6-678kR.mjs → run-attempt-DejV9vDW.mjs} +927 -860
  82. package/dist/.setup/{run-attempt-lifecycle-BuZgVbDA.mjs → run-attempt-lifecycle-KN4oh-7O.mjs} +13 -4
  83. package/dist/.setup/{runtime-artifact-CUTOOnKw.mjs → runtime-artifact-C13pR7tD.mjs} +18 -22
  84. package/dist/.setup/{runtime-artifact-connection-CADz3_BY.mjs → runtime-artifact-connection-jS5DeCok.mjs} +3 -3
  85. package/dist/.setup/{sandbox-guard-WqE8yPge.mjs → sandbox-guard-DIImwCy1.mjs} +4 -6
  86. package/dist/.setup/service-tier-normalization-BPgw2Wdt.mjs +9 -0
  87. package/dist/.setup/{session-binding-Ce7BqiPN.mjs → session-binding-JEHNMPsr.mjs} +13 -40
  88. package/dist/.setup/{session-binding-record-BZB8RgcF.mjs → session-binding-record-DU_0biMD.mjs} +4 -4
  89. package/dist/.setup/{session-binding-record-codec-z4ZpDn6E.mjs → session-binding-record-codec-BpH8u_G9.mjs} +16 -39
  90. package/dist/.setup/{session-binding-sidecars-BrdV95Fg.mjs → session-binding-sidecars-DD-enC8w.mjs} +49 -54
  91. package/dist/.setup/{session-catalog-adoption-CPIP4S_y.mjs → session-catalog-adoption-Ca3OYGYM.mjs} +23 -27
  92. package/dist/.setup/{session-catalog-archive-DcgwvSbF.mjs → session-catalog-archive-Bv6gV7x9.mjs} +6 -6
  93. package/dist/.setup/{session-catalog-events-Cj-b2FpC.mjs → session-catalog-events-BziNSfLx.mjs} +6 -5
  94. package/dist/.setup/{session-catalog-index-BnvC43eZ.mjs → session-catalog-index-BmaZFGEH.mjs} +111 -105
  95. package/dist/.setup/{session-catalog-index-order-nhyO0wdW.mjs → session-catalog-index-order-CTfoefow.mjs} +28 -5
  96. package/dist/.setup/{session-catalog-limits-DEU36Qlo.mjs → session-catalog-limits-BynIoOYm.mjs} +1 -1
  97. package/dist/.setup/{session-catalog-list-request-tXephOB4.mjs → session-catalog-list-request-D4MYNgDB.mjs} +11 -8
  98. package/dist/.setup/{session-catalog-native-projection-DCtsWKSF.mjs → session-catalog-native-projection-4CsufcT8.mjs} +5 -61
  99. package/dist/.setup/{session-catalog-node-adoption-7-WEQTB1.mjs → session-catalog-node-adoption-BdP9Zjqo.mjs} +2 -2
  100. package/dist/.setup/{session-catalog-node-continue-DLWBwAAO.mjs → session-catalog-node-continue-CNJibO4_.mjs} +27 -49
  101. package/dist/.setup/{session-catalog-node-lookup-Uufckwcm.mjs → session-catalog-node-lookup-BH_DBGa9.mjs} +3 -3
  102. package/dist/.setup/{session-catalog-parsing-B-qWJh2x.mjs → session-catalog-parsing-DkeoVn60.mjs} +9 -19
  103. package/dist/.setup/{session-catalog-projection-Cn0bLb-d.mjs → session-catalog-projection-CcIdJdsd.mjs} +8 -22
  104. package/dist/.setup/session-catalog-source-CdPqS9sa.mjs +58 -0
  105. package/dist/.setup/{session-cli-kH4vuGod.mjs → session-cli-GwU0izn-.mjs} +20 -41
  106. package/dist/.setup/{session-history-BogBHKLk.mjs → session-history-BO6i_pfk.mjs} +1 -1
  107. package/dist/.setup/{session-history-import-NWKPa4ZO.mjs → session-history-import-CaO8s6ta.mjs} +4 -4
  108. package/dist/.setup/{session-history-read-CNN8zwbD.mjs → session-history-read-BI_2jRED.mjs} +4 -15
  109. package/dist/.setup/{session-history.worker-Cq_4DYgN.mjs → session-history.worker-DJQfek5p.mjs} +147 -159
  110. package/dist/.setup/{session-initialization-D6dtFQkE.mjs → session-initialization-Bi_2DKhc.mjs} +3 -5
  111. package/dist/.setup/{session-permission-policy-BxIUJ0Zd.mjs → session-permission-policy-CD2MAWU8.mjs} +12 -20
  112. package/dist/.setup/{session-retirement-Bo81t4Fb.mjs → session-retirement-CcWVhLVr.mjs} +7 -7
  113. package/dist/.setup/{settled-turn-context-BZsMjkIO.mjs → settled-turn-context-BPL6D3RO.mjs} +1 -1
  114. package/dist/.setup/{settled-turn-finalizer-CFARFqNd.mjs → settled-turn-finalizer-BezKSo-Y.mjs} +12 -11
  115. package/dist/.setup/{shared-client-5NUq43f3.mjs → shared-client-BjiqpbC5.mjs} +164 -227
  116. package/dist/.setup/{side-question-oTlegAz3.mjs → side-question-YQ5FObkD.mjs} +116 -137
  117. package/dist/.setup/{source-1cabQi3x.mjs → source-Ce3XIIsU.mjs} +37 -56
  118. package/dist/.setup/thread-archive-guard-LKdwQKyr.mjs +56 -0
  119. package/dist/.setup/{thread-lifecycle--EPPTNTe.mjs → thread-lifecycle-run-BWy0LDLB.mjs} +338 -478
  120. package/dist/.setup/thread-model-selection-DcVebr8N.mjs +61 -0
  121. package/dist/.setup/{thread-ownership-T7T_iffm.mjs → thread-ownership-5X4197vk.mjs} +5 -5
  122. package/dist/.setup/{thread-ownership-queue-Dp24d7-F.mjs → thread-ownership-queue-CeyYScUC.mjs} +5 -6
  123. package/dist/.setup/{thread-policy-VtqLex1l.mjs → thread-policy-BEecBTJM.mjs} +4 -4
  124. package/dist/.setup/thread-requests-BgzJwJtS.mjs +745 -0
  125. package/dist/.setup/{thread-resume-buZujRcC.mjs → thread-resume-BXY_6o6Z.mjs} +5 -5
  126. package/dist/.setup/{timeout-CXOfNoaX.mjs → timeout-D0mEWSGG.mjs} +6 -12
  127. package/dist/.setup/{transcript-history-projection-B9a7HwUV.mjs → transcript-history-projection-DfKcoZCB.mjs} +3 -4
  128. package/dist/.setup/{transcript-mirror-BfLRARNL.mjs → transcript-mirror-Bee2o6jj.mjs} +68 -68
  129. package/dist/.setup/{transcript-mirror-attestation-YSegaktH.mjs → transcript-mirror-attestation-BzUXnrvv.mjs} +5 -2
  130. package/dist/.setup/{transport-stdio-a0HDa2Mj.mjs → transport-stdio-CRWTkKOn.mjs} +67 -77
  131. package/dist/.setup/{transport-websocket-zqJ0Cmtn.mjs → transport-websocket-DIyPfkHo.mjs} +8 -16
  132. package/dist/.setup/{turn-router-BOKSJmfw.mjs → turn-router-D8DLkZgH.mjs} +30 -31
  133. package/dist/.setup/upstream-prompt-provenance-Ccd9MFRJ.mjs +44 -0
  134. package/dist/.setup/{upstream-session-fork-C4sbIoZb.mjs → upstream-session-fork-DQZbaYMK.mjs} +50 -43
  135. package/dist/.setup/{usage-Cq21xTMZ.mjs → usage-DVR5mNJK.mjs} +4 -4
  136. package/dist/.setup/{usage-limit-error-CGJUoQu8.mjs → usage-limit-error-BEONfgt-.mjs} +12 -21
  137. package/dist/.setup/web-search-item-CvokaZOo.mjs +20 -0
  138. package/dist/.setup/{web-search-provider.runtime-DrVE7-Br.mjs → web-search-provider.runtime-CffHOpYY.mjs} +3 -3
  139. package/dist/.setup/{workspace-write-sandbox-probe-DmUHLrrl.mjs → workspace-write-sandbox-probe-BDWO2Qkh.mjs} +4 -4
  140. package/dist/api.js +15 -15
  141. package/dist/catalog-page.worker.js +1 -1
  142. package/dist/cli-metadata.js +1 -1
  143. package/dist/doctor-contract-api.js +5 -6
  144. package/dist/harness.js +32 -61
  145. package/dist/index.js +302 -416
  146. package/dist/media-understanding-provider.js +32 -43
  147. package/dist/migration-provider-api.js +1 -1
  148. package/dist/native-session-binding-api.js +1 -1
  149. package/dist/native-tool-policy.js +23 -1
  150. package/dist/provider-discovery.js +1 -1
  151. package/dist/session-history-worker-runtime.js +52 -31
  152. package/dist/session-history.worker.js +1 -1
  153. package/openclaw.plugin.json +20 -3
  154. package/package.json +7 -7
  155. package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +0 -5
  156. package/dist/.setup/plugin-thread-config-deadline-C5i1S6RN.mjs +0 -124
  157. package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +0 -15
  158. package/dist/.setup/shell-dynamic-tools-Bmedt1QE.mjs +0 -85
  159. package/dist/.setup/thread-archive-guard-C9frICzX.mjs +0 -60
  160. package/dist/.setup/thread-requests-Bj_Lixmv.mjs +0 -2111
  161. package/dist/.setup/upstream-prompt-provenance-fXkKbPVC.mjs +0 -37
@@ -1,140 +1,50 @@
1
1
  import { i as isJsonObject, r as flattenCodexDynamicToolFunctions } from "./protocol-CANUwXJ3.mjs";
2
- import { n as matchesPendingSupervisionBranch } from "./session-binding-record-codec-z4ZpDn6E.mjs";
3
- import { m as sessionBindingIdentity, n as assertCodexBindingMayBeReplaced } from "./session-binding-record-BZB8RgcF.mjs";
4
- import { u as fingerprintCodexPolicy } from "./config-security-KAPScztc.mjs";
2
+ import { n as matchesPendingSupervisionBranch } from "./session-binding-record-codec-BpH8u_G9.mjs";
3
+ import { m as sessionBindingIdentity, n as assertCodexBindingMayBeReplaced } from "./session-binding-record-DU_0biMD.mjs";
4
+ import { l as fingerprintCodexPolicy } from "./config-security-clxAZYWX.mjs";
5
+ import { f as resolveCodexPluginsPolicy } from "./config-parsing-DsWSCPHO.mjs";
5
6
  import { n as resolveCodexAppServerLocalHomeDir, t as resolveCodexAppServerHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
6
- import { d as readCodexEffectiveConfig, n as codexSandboxPolicyForTurn, s as assertCodexModelBackedReviewerEffectiveConfig, u as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES } from "./config-options-HG_Rr3W_.mjs";
7
- import { S as retainSharedCodexAppServerClientByInstanceId, d as getCurrentSharedClientEntry } from "./auth-cache-key-BE1HXsNo.mjs";
8
- import { t as withCodexAppServerThreadMutation } from "./thread-ownership-queue-Dp24d7-F.mjs";
9
- import { o as isCodexAppServerOverloadError, r as CodexAppServerRpcError, s as isCodexThreadReadMissingError } from "./rpc-error-hmWM21RB.mjs";
7
+ import { d as readCodexEffectiveConfig, s as assertCodexModelBackedReviewerEffectiveConfig, u as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES } from "./config-options-DDzeNQ8m.mjs";
8
+ import { S as retainSharedCodexAppServerClientByInstanceId, d as getCurrentSharedClientEntry } from "./auth-cache-key-tENCQOub.mjs";
9
+ import { t as withCodexAppServerThreadMutation } from "./thread-ownership-queue-CeyYScUC.mjs";
10
+ import { o as isCodexAppServerOverloadError, r as CodexAppServerRpcError, s as isCodexThreadReadMissingError } from "./rpc-error-C98SHchT.mjs";
10
11
  import { t as codexCatalogHomeId } from "./session-catalog-home-id-vlih0B_g.mjs";
11
- import { r as withAbortableTimeout } from "./timeout-CXOfNoaX.mjs";
12
- import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-B9a7HwUV.mjs";
13
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-BW8rd98k.mjs";
12
+ import { r as withAbortableTimeout } from "./timeout-D0mEWSGG.mjs";
13
+ import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-DfKcoZCB.mjs";
14
+ import { a as defaultCodexAppInventoryCache, t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-Bg9DbDI6.mjs";
14
15
  import { n as readCodexSessionMeta } from "./session-catalog-provenance-CmsOE5mh.mjs";
15
- import { t as assertCodexSessionRuntimeOwnership } from "./binding-connection-C-08ez1w.mjs";
16
- import "./config-0Gxk3_eq.mjs";
17
- import { r as invalidInlineImageText } from "./session-history-read-CNN8zwbD.mjs";
18
- import { c as resolveCodexContextEngineProjectionMaxChars, o as neutralizeCodexExplicitMentionSigils } from "./context-engine-projection-CsgYSQhW.mjs";
16
+ import { t as assertCodexSessionRuntimeOwnership } from "./binding-connection-B7HAAZSI.mjs";
17
+ import { c as resolveRecoverableCodexPluginConfigKeys } from "./plugin-inventory-CYgdo14P.mjs";
18
+ import "./config-C1YVVLEA.mjs";
19
+ import { c as resolveCodexContextEngineProjectionMaxChars } from "./context-engine-projection-ps-yn_ci.mjs";
19
20
  import { n as normalizeCodexAppServerBindingModelProvider } from "./auth-profile-CgHQ8Vot.mjs";
20
- import { A as bindCodexInferenceThread, B as isCodexAppServerClientRuntimeLive, C as CodexThreadBindingConflictError, F as consumeCodexAppServerLiveThread, G as releaseCodexAppServerLiveThread, J as unsubscribeCodexAppServerLiveThread, M as getCodexInferenceThreadQualification, N as prepareCodexInferenceThreadConfig, Q as createCodexEphemeralThreadPolicy, S as CodexAdoptedThreadActiveError, T as CodexThreadStartRequestError, V as isCodexAppServerLiveThreadClaimed, j as getCodexInferenceThread, k as assertCodexInferenceRouteConfig, n as captureCodexAppServerClientLifetime, w as CodexThreadClientReplacementError, z as hasCodexAppServerSiblingThreadWork } from "./shared-client-5NUq43f3.mjs";
21
- import { B as getCodexAppServerClientInstanceId, C as resolveCodexThreadRolloutPath, H as resolveCodexAppServerClientInstanceId, S as readSupervisionResponseThreadId, c as isCodexAppServerRequestTimeoutError, g as assertCodexThreadStartResponse, m as assertCodexThreadForkResponse, p as assertCodexThreadAcceptsDirectInput, v as assertExactSupervisionModelSelection } from "./client-ChJtGEdJ.mjs";
22
- import { r as hasCodexAppServerSiblingRouteWork } from "./turn-router-BOKSJmfw.mjs";
23
- import { f as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, o as closeCodexStartupClientBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DPUGAWP2.mjs";
24
- import { $ as legacyFingerprintUserMcpServersConfigPatch, B as hasCodexNativeToolCatalog, Ct as mergeCodexThreadConfigs, D as assertCodexNativeHookRelayAllowed, E as CodexManagedHooksOnlyError, Et as buildCodexAppApprovalOverrides, G as areCodexDynamicToolFingerprintsCompatible, I as attestCodexThreadToolSurface, J as codexLegacyDynamicToolsFingerprint, K as areUserMcpServersFingerprintsCompatible, L as checkCodexThreadAppAvailability, Q as fingerprintUserMcpServersConfigPatch, R as discardUnattestedCodexPluginThread, S as joinPresentSections, St as isCodexPluginThreadBindingStale, U as applyCodexNativeSkillIsolation, V as loadCodexNativeToolCatalog, W as resolveCodexNativeSkillIsolation, X as fingerprintEnvironmentSelection, Y as fingerprintCodexThreadConfig, Z as fingerprintJsonObject, _ as CODEX_NATIVE_PERSONALITY_NONE, at as shouldRotateCodexAppServerBindingForRuntime, b as resolveCodexAppServerThreadModelSelection, bt as buildPluginAppPolicyContext, c as codexThreadSandboxOrPermissions, d as readCodexManagedRequirementsFingerprint, dt as isSystemAgentOnlyCodexDynamicToolAllowlist, et as readActiveCodexTurnIdsFromResume, f as resolveCodexThreadApprovalsReviewer, g as buildDeveloperInstructions, h as mergeCodexNativeShellEnvironment, ht as buildCodexPluginAppsConfigPatchFromPolicyContext, i as buildCodexRuntimeThreadConfigForRun, it as shouldRecheckRecoverablePluginBinding, m as resolveCodexWebSearchPlan, n as buildCodexRingZeroThreadConfigPatch, o as buildThreadResumeParams, ot as shouldRotateCodexGpt56MultiAgentBinding, q as codexDynamicToolsFingerprint, rt as isTransientWebSearchRestriction, s as buildThreadStartParams, t as assertCodexManagedRequirementsDoNotOverrideToolPolicy, tt as shouldStartTransientNoToolThread, u as readCodexInheritedMcpServerNames, ut as isMessageOnlyCodexSourceReply, v as resolveCodexAppServerModelProvider, w as mergeCodexNativeProjectDocThreadConfig, xt as disableUnlistedCodexApps, y as resolveCodexAppServerRequestModelSelection, z as attestCodexRestrictedToolSurfaceMcpServersDisabled } from "./thread-requests-Bj_Lixmv.mjs";
25
- import { a as hashCodexAppServerBindingFingerprint, r as resolveCodexSessionBinding } from "./session-binding-Ce7BqiPN.mjs";
26
- import { r as readCodexMcpToolConnectorId } from "./mcp-tool-metadata-j10HhfTC.mjs";
27
- import { a as refreshCodexThreadInstructions, i as assertCodexSupervisionThreadLineage, n as CodexThreadPolicyHandoffError, o as refreshCodexThreadPolicy, r as assertAdoptedCodexThreadResumeAllowed, t as CodexIncognitoPolicyChangeError } from "./thread-policy-VtqLex1l.mjs";
28
- import { t as resumeCodexAppServerThread } from "./thread-resume-buZujRcC.mjs";
29
- import { c as withExclusiveCodexAppServerThread, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-T7T_iffm.mjs";
21
+ import { A as bindCodexInferenceThread, B as isCodexAppServerClientRuntimeLive, C as CodexThreadBindingConflictError, F as consumeCodexAppServerLiveThread, G as releaseCodexAppServerLiveThread, J as unsubscribeCodexAppServerLiveThread, M as getCodexInferenceThreadQualification, N as prepareCodexInferenceThreadConfig, Q as createCodexEphemeralThreadPolicy, S as CodexAdoptedThreadActiveError, T as CodexThreadStartRequestError, V as isCodexAppServerLiveThreadClaimed, j as getCodexInferenceThread, k as assertCodexInferenceRouteConfig, n as captureCodexAppServerClientLifetime, w as CodexThreadClientReplacementError, z as hasCodexAppServerSiblingThreadWork } from "./shared-client-BjiqpbC5.mjs";
22
+ import { C as resolveCodexThreadRolloutPath, F as getCodexAppServerClientInstanceId, L as resolveCodexAppServerClientInstanceId, S as readSupervisionResponseThreadId, c as isCodexAppServerRequestTimeoutError, g as assertCodexThreadStartResponse, m as assertCodexThreadForkResponse, p as assertCodexThreadAcceptsDirectInput, v as assertExactSupervisionModelSelection } from "./client-zrCKOu_E.mjs";
23
+ import { r as hasCodexAppServerSiblingRouteWork } from "./turn-router-D8DLkZgH.mjs";
24
+ import { f as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, o as closeCodexStartupClientBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-CxX4cTSi.mjs";
25
+ import { a as buildCodexPluginThreadConfigInputFingerprint, c as buildPluginAppPolicyContext, d as mergeCodexThreadConfigs, i as buildCodexPluginThreadConfig, l as disableUnlistedCodexApps, m as buildCodexAppApprovalOverrides, n as mergeCodexNativeProjectDocThreadConfig, o as buildCodexPluginThreadConfigTimeoutFallback, p as shouldBuildCodexPluginThreadConfig, r as buildCodexPluginAppsConfigPatchFromPolicyContext, u as isCodexPluginThreadBindingStale } from "./project-doc-thread-config-BVcvnps8.mjs";
26
+ import { A as isTransientWebSearchRestriction, C as fingerprintEnvironmentSelection, D as readActiveCodexTurnIdsFromResume, E as legacyFingerprintUserMcpServersConfigPatch, I as isMessageOnlyCodexSourceReply, L as isSystemAgentOnlyCodexDynamicToolAllowlist, M as shouldRotateCodexAppServerBindingForRuntime, N as shouldRotateCodexGpt56MultiAgentBinding, O as shouldStartTransientNoToolThread, S as fingerprintCodexThreadConfig, T as fingerprintUserMcpServersConfigPatch, _ as buildDeveloperInstructions, b as codexDynamicToolsFingerprint, c as codexThreadSandboxOrPermissions, d as readCodexManagedRequirementsFingerprint, f as resolveCodexThreadApprovalsReviewer, g as mergeCodexNativeShellEnvironment, h as resolveCodexWebSearchPlan, i as buildCodexRuntimeThreadConfigForRun, j as shouldRecheckRecoverablePluginBinding, n as buildCodexRingZeroThreadConfigPatch, o as buildThreadResumeParams, p as attestCodexRestrictedToolSurfaceMcpServersDisabled, s as buildThreadStartParams, t as assertCodexManagedRequirementsDoNotOverrideToolPolicy, u as readCodexInheritedMcpServerNames, v as areCodexDynamicToolFingerprintsCompatible, w as fingerprintJsonObject, x as codexLegacyDynamicToolsFingerprint, y as areUserMcpServersFingerprintsCompatible } from "./thread-requests-BgzJwJtS.mjs";
27
+ import { i as resolveCodexSessionBinding, o as hashCodexAppServerBindingFingerprint } from "./session-binding-JEHNMPsr.mjs";
28
+ import { i as resolveCodexAppServerThreadModelSelection, n as resolveCodexAppServerModelProvider } from "./thread-model-selection-DcVebr8N.mjs";
29
+ import { c as withExclusiveCodexAppServerThread, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-5X4197vk.mjs";
30
+ import { a as refreshCodexThreadInstructions, i as assertCodexSupervisionThreadLineage, n as CodexThreadPolicyHandoffError, o as refreshCodexThreadPolicy, r as assertAdoptedCodexThreadResumeAllowed, t as CodexIncognitoPolicyChangeError } from "./thread-policy-BEecBTJM.mjs";
31
+ import { t as resumeCodexAppServerThread } from "./thread-resume-BXY_6o6Z.mjs";
32
+ import { r as readCodexMcpToolConnectorId } from "./mcp-tool-metadata-DW41snf3.mjs";
33
+ import { n as disableCodexPluginThreadConfig } from "./dynamic-tool-build-BMiiFROa.mjs";
34
+ import { n as CodexManagedHooksOnlyError, r as assertCodexNativeHookRelayAllowed } from "./native-hook-relay-CSZpcjwq.mjs";
35
+ import { t as defaultCodexPluginMetadataCache } from "./plugin-metadata-cache-Bi8TAPwX.mjs";
36
+ import { a as discardUnattestedCodexPluginThread, i as checkCodexThreadAppAvailability, n as resolveCodexNativeSkillIsolation, o as hasCodexNativeToolCatalog, r as attestCodexThreadToolSurface, s as loadCodexNativeToolCatalog, t as applyCodexNativeSkillIsolation } from "./native-skill-isolation-BAatEJZb.mjs";
30
37
  import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
31
38
  import crypto from "node:crypto";
32
39
  import { isDeepStrictEqual } from "node:util";
33
40
  import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
34
41
  import path from "node:path";
35
42
  import { isIncognitoSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
36
- import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
37
43
  import { createStageTimingTracker, formatStageTimings, racePromiseWithAbortSignal } from "openclaw/plugin-sdk/time-runtime";
38
- import { AgentHarnessPreflightError, buildHarnessVisibleReplyGuidance, buildTemporalContextText, embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, isHostScopedAgentToolActive } from "openclaw/plugin-sdk/agent-harness-runtime";
39
- import { resolveAgentDir as resolveAgentDir$2 } from "openclaw/plugin-sdk/agent-runtime";
40
- import { sanitizeInlineImageDataUrl } from "openclaw/plugin-sdk/inline-image-data-url-runtime";
41
- import { selectSupportedReasoningEffort } from "openclaw/plugin-sdk/agent-harness-attempt-runtime";
44
+ import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
45
+ import { AgentHarnessPreflightError, embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, isHostScopedAgentToolActive } from "openclaw/plugin-sdk/agent-harness-runtime";
42
46
  import { buildCodexUserMcpServersThreadConfigPatchForRun } from "openclaw/plugin-sdk/codex-mcp-projection";
43
47
  import { isDiagnosticFlagEnabled } from "openclaw/plugin-sdk/diagnostic-flags";
44
- //#region extensions/codex/src/app-server/reasoning-effort.ts
45
- const CODEX_REASONING_EFFORTS = [
46
- "minimal",
47
- "low",
48
- "medium",
49
- "high",
50
- "xhigh",
51
- "max"
52
- ];
53
- const LEGACY_PRO_REASONING_EFFORTS = [
54
- "medium",
55
- "high",
56
- "xhigh"
57
- ];
58
- const LEGACY_PRO_MODEL_ID_RE = /^gpt-5\.[45]-pro$/u;
59
- const MODERN_GPT_5_MODEL_ID_RE = /^gpt-5\.(?:[3-9]|[1-9]\d)(?:$|-)/u;
60
- /** Read reasoning metadata after the Codex app-server route has been selected. */
61
- function readCodexSupportedReasoningEfforts(compat) {
62
- return compat && "supportedReasoningEfforts" in compat ? compat.supportedReasoningEfforts : void 0;
63
- }
64
- function resolveCodexAppServerReasoningEffort(params) {
65
- if (params.thinkLevel === "ultra") return "ultra";
66
- if (params.thinkLevel === "off") return params.supportedReasoningEfforts?.includes("none") ? "none" : null;
67
- if (params.thinkLevel === "adaptive") return null;
68
- const modelId = params.modelId.trim().toLowerCase();
69
- const supportedReasoningEfforts = params.supportedReasoningEfforts ?? (LEGACY_PRO_MODEL_ID_RE.test(modelId) ? LEGACY_PRO_REASONING_EFFORTS : void 0);
70
- if (supportedReasoningEfforts) return selectSupportedReasoningEffort({
71
- requested: params.thinkLevel,
72
- supportedEfforts: supportedReasoningEfforts.map((effort) => effort.trim().toLowerCase()),
73
- effortOrder: CODEX_REASONING_EFFORTS
74
- }) ?? null;
75
- if (params.thinkLevel === "minimal" && MODERN_GPT_5_MODEL_ID_RE.test(modelId)) return "low";
76
- return params.thinkLevel === "max" ? null : params.thinkLevel;
77
- }
78
- //#endregion
79
- //#region extensions/codex/src/app-server/thread-context-engine.ts
80
- function buildContextEngineBinding(params, projection) {
81
- const contextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
82
- const engineId = contextEngine?.info?.id?.trim();
83
- if (!contextEngine || !engineId) return;
84
- return {
85
- schemaVersion: 1,
86
- engineId,
87
- policyFingerprint: JSON.stringify({
88
- schemaVersion: 1,
89
- engineId,
90
- engineVersion: contextEngine.info.version,
91
- ownsCompaction: contextEngine.info.ownsCompaction === true,
92
- turnMaintenanceMode: contextEngine.info.turnMaintenanceMode,
93
- citationsMode: params.config?.memory?.citations,
94
- contextTokenBudget: params.contextTokenBudget,
95
- projectionMaxChars: resolveCodexContextEngineProjectionMaxChars({ contextTokenBudget: params.contextTokenBudget })
96
- }),
97
- projection: projection ? {
98
- schemaVersion: 1,
99
- mode: "thread_bootstrap",
100
- epoch: projection.epoch,
101
- fingerprint: projection.fingerprint
102
- } : void 0
103
- };
104
- }
105
- function isContextEngineBindingCompatible(previous, next) {
106
- return previous?.schemaVersion === next.schemaVersion && previous.engineId === next.engineId && previous.policyFingerprint === next.policyFingerprint && areContextEngineProjectionBindingsCompatible(previous.projection, next.projection);
107
- }
108
- function areContextEngineProjectionBindingsCompatible(previous, next) {
109
- if (!next) return previous === void 0;
110
- return previous?.schemaVersion === next.schemaVersion && previous.mode === next.mode && previous.epoch === next.epoch && previous.fingerprint === next.fingerprint;
111
- }
112
- //#endregion
113
- //#region extensions/codex/src/app-server/native-model-input-tools.ts
114
- /** Stock native hooks flatten the configured V2 namespace without a delimiter. */
115
- function resolveCodexNativeModelInputTools(config) {
116
- const features = isJsonObject(config.features) ? config.features : void 0;
117
- const multiAgent = isJsonObject(features?.multi_agent_v2) ? features.multi_agent_v2 : void 0;
118
- const namespace = typeof multiAgent?.tool_namespace === "string" ? multiAgent.tool_namespace.trim() : "collaboration";
119
- return [
120
- "spawn_agent",
121
- "multi_agent_v1send_input",
122
- "send_message",
123
- "followup_task",
124
- ...namespace ? [
125
- `${namespace}spawn_agent`,
126
- `${namespace}send_message`,
127
- `${namespace}followup_task`
128
- ] : []
129
- ];
130
- }
131
- //#endregion
132
- //#region extensions/codex/src/app-server/profiler-flag.ts
133
- const PROFILER_FLAGS = ["profiler", "codex.profiler"];
134
- function isCodexAppServerProfilerEnabled(config, env = process.env) {
135
- return PROFILER_FLAGS.some((flag) => isDiagnosticFlagEnabled(flag, config, env));
136
- }
137
- //#endregion
138
48
  //#region extensions/codex/src/app-server/scheduled-app-tool-policy.ts
139
49
  function normalizeAppToolApprovalMode(value) {
140
50
  return value === "auto" || value === "prompt" || value === "writes" || value === "approve" ? value : void 0;
@@ -168,10 +78,8 @@ function appToolHintsAllowed(tool, policy) {
168
78
  return (policy.allowDestructiveActions || tool?.destructiveHint === false) && (policy.allowOpenWorld !== false || tool?.openWorldHint === false);
169
79
  }
170
80
  function intersectToolApprovalMode(captured, current) {
171
- if (captured === current) return captured;
172
- if (captured === "prompt" || current === "prompt") return "prompt";
81
+ if (captured === current || current === "approve") return captured;
173
82
  if (captured === "approve") return current;
174
- if (current === "approve") return captured;
175
83
  return "prompt";
176
84
  }
177
85
  //#endregion
@@ -319,9 +227,9 @@ async function readCurrentCodexScheduledAppPolicy(params) {
319
227
  async function captureScheduledCodexAppAuthority(params) {
320
228
  const requestedTimeoutMs = params.timeoutMs ?? CODEX_APP_AUTHORITY_CAPTURE_TIMEOUT_MS;
321
229
  const timeoutMs = Math.min(CODEX_APP_AUTHORITY_CAPTURE_TIMEOUT_MS, Math.max(CODEX_APP_AUTHORITY_CAPTURE_MIN_TIMEOUT_MS, Number.isFinite(requestedTimeoutMs) ? Math.floor(requestedTimeoutMs) : CODEX_APP_AUTHORITY_CAPTURE_TIMEOUT_MS));
322
- const deadlineMs = Date.now() + timeoutMs;
230
+ const deadlineMs = performance.now() + timeoutMs;
323
231
  const boundedClient = { request: ((method, requestParams) => {
324
- const remainingTimeoutMs = deadlineMs - Date.now();
232
+ const remainingTimeoutMs = deadlineMs - performance.now();
325
233
  if (remainingTimeoutMs <= 0) throw new CodexScheduledAppAuthorityCaptureTimeoutError();
326
234
  return params.client.request(method, requestParams, {
327
235
  timeoutMs: remainingTimeoutMs,
@@ -435,9 +343,8 @@ function intersectCodexPluginThreadConfigWithScheduledAuthority(config, authorit
435
343
  const appsPatch = asOptionalRecord(configPatch.apps);
436
344
  for (const [appId, captured] of capturedById) {
437
345
  const appPatch = asOptionalRecord(appsPatch?.[appId]);
438
- if (!appPatch || !Object.hasOwn(apps, appId)) continue;
439
- const currentApp = apps[appId];
440
- if (!currentApp) continue;
346
+ const currentApp = Object.hasOwn(apps, appId) ? apps[appId] : void 0;
347
+ if (!appPatch || !currentApp) continue;
441
348
  if (currentApp.destructiveApprovalMode === "ask") Object.assign(appPatch, buildCodexAppApprovalOverrides(currentPolicy.config, {
442
349
  id: appId,
443
350
  approvalOverrideToolConfigKeys: []
@@ -469,7 +376,6 @@ function intersectCodexPluginThreadConfigWithScheduledAuthority(config, authorit
469
376
  policyContext
470
377
  };
471
378
  }
472
- /** Returns the managed-requirements identity captured for a configured app-server job. */
473
379
  function readScheduledCodexAppManagedRequirementsFingerprint(authority) {
474
380
  const auth = parseScheduledCodexAppAuthority(authority)?.auth;
475
381
  return auth?.kind === "configured-app-server" ? auth.managedRequirementsFingerprint : void 0;
@@ -501,9 +407,188 @@ function buildScheduledCodexAppAuthorityInputFingerprint(baseFingerprint, author
501
407
  });
502
408
  }
503
409
  //#endregion
410
+ //#region extensions/codex/src/app-server/plugin-thread-config-deadline.ts
411
+ /** Enforces one bounded startup budget across Codex plugin config discovery. */
412
+ const CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS = 6e4;
413
+ const CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR = 4;
414
+ const CODEX_PLUGIN_THREAD_CONFIG_MIN_TIMEOUT_MS = 100;
415
+ var CodexPluginThreadConfigDeadlineError = class extends Error {
416
+ constructor() {
417
+ super("Codex plugin thread config deadline elapsed");
418
+ this.name = "CodexPluginThreadConfigDeadlineError";
419
+ }
420
+ };
421
+ /** Resolves the plugin policy state reused throughout app-server startup. */
422
+ function resolveCodexPluginThreadConfigStartupPolicy(params) {
423
+ const pluginThreadConfigRequired = params.hostedAppsSupported === false || Boolean(params.scheduledRuntimeAuthority) || !params.nativeToolSurfaceEnabled || shouldBuildCodexPluginThreadConfig(params.pluginConfig);
424
+ const pluginThreadConfigPluginConfig = params.hostedAppsSupported !== false && (params.nativeToolSurfaceEnabled || params.scheduledRuntimeAuthority) ? params.pluginConfig : disableCodexPluginThreadConfig(params.pluginConfig);
425
+ const resolvedPluginPolicy = pluginThreadConfigRequired ? resolveCodexPluginsPolicy(pluginThreadConfigPluginConfig) : void 0;
426
+ return {
427
+ pluginThreadConfigRequired,
428
+ pluginThreadConfigPluginConfig,
429
+ resolvedPluginPolicy,
430
+ enabledPluginConfigKeys: resolvedPluginPolicy ? resolvedPluginPolicy.pluginPolicies.filter((plugin) => plugin.enabled).map((plugin) => plugin.configKey).toSorted() : void 0
431
+ };
432
+ }
433
+ /** Builds plugin config without allowing sequential RPC timeouts to consume the turn. */
434
+ async function buildCodexPluginThreadConfigWithinDeadline(params) {
435
+ const { requestTimeoutMs, signal, request, failClosedOnTimeout, transform, ...buildParams } = params;
436
+ signal.throwIfAborted();
437
+ const timeoutMs = resolveCodexPluginThreadConfigTimeoutMs(requestTimeoutMs);
438
+ const deadlineMs = performance.now() + timeoutMs;
439
+ let requestTimedOut = false;
440
+ const boundedRequest = async (method, requestParams) => {
441
+ const remainingTimeoutMs = deadlineMs - performance.now();
442
+ if (requestTimedOut || remainingTimeoutMs <= 0) throw new CodexPluginThreadConfigDeadlineError();
443
+ try {
444
+ return await request(method, requestParams, {
445
+ timeoutMs: remainingTimeoutMs,
446
+ signal
447
+ });
448
+ } catch (error) {
449
+ requestTimedOut ||= isCodexPluginThreadConfigTimeoutError(error);
450
+ throw error;
451
+ }
452
+ };
453
+ try {
454
+ return await withAbortableTimeout({
455
+ signal,
456
+ timeoutMs,
457
+ promise: (async () => {
458
+ const config = await buildCodexPluginThreadConfig({
459
+ ...buildParams,
460
+ request: boundedRequest
461
+ });
462
+ const result = transform ? await transform(config, boundedRequest) : config;
463
+ if (requestTimedOut || performance.now() >= deadlineMs) throw new CodexPluginThreadConfigDeadlineError();
464
+ return result;
465
+ })(),
466
+ timeoutMessage: "Codex plugin thread config deadline elapsed",
467
+ createTimeoutError: () => new CodexPluginThreadConfigDeadlineError()
468
+ });
469
+ } catch (error) {
470
+ if (signal.aborted || !requestTimedOut && !isCodexPluginThreadConfigTimeoutError(error) && performance.now() < deadlineMs) throw error;
471
+ if (failClosedOnTimeout) throw new AgentHarnessPreflightError(`Codex app policy verification exceeded its ${timeoutMs} ms startup budget. No app tools were executed. Retry after Codex app inventory is responsive.`);
472
+ return buildCodexPluginThreadConfigTimeoutFallback({
473
+ pluginConfig: buildParams.pluginConfig,
474
+ appCacheKey: buildParams.appCacheKey,
475
+ message: `Codex plugin discovery exceeded its ${timeoutMs} ms startup budget; plugin apps were disabled for this turn.`
476
+ });
477
+ }
478
+ }
479
+ /** Captures fingerprint inputs before startup work and binds the provider at admission. */
480
+ function prepareCodexPluginThreadConfigStartupProvider(prepared) {
481
+ const { startupPolicy, appCacheKey } = prepared;
482
+ if (!startupPolicy.pluginThreadConfigRequired) return;
483
+ const { pluginThreadConfigPluginConfig: pluginConfig, resolvedPluginPolicy: policy, enabledPluginConfigKeys } = startupPolicy;
484
+ const inputFingerprint = buildScheduledCodexAppAuthorityInputFingerprint(buildCodexPluginThreadConfigInputFingerprint({
485
+ pluginConfig,
486
+ appCacheKey
487
+ }), prepared.scheduledRuntimeAuthority);
488
+ return (params) => {
489
+ const { client, appCache, metadataCache: configuredMetadataCache, ...buildParams } = params;
490
+ const metadataCache = configuredMetadataCache ?? defaultCodexPluginMetadataCache;
491
+ return {
492
+ enabled: true,
493
+ requiresCurrentPolicyCheck: Boolean(policy?.enabled || params.scheduledRuntimeAuthority),
494
+ inputFingerprint,
495
+ enabledPluginConfigKeys,
496
+ accountAppRecoveryEnabled: policy?.allowAllPlugins,
497
+ recoverablePluginConfigKeys: policy ? resolveRecoverableCodexPluginConfigKeys({
498
+ policy,
499
+ metadataCache,
500
+ appCacheKey,
501
+ configCwd: params.configCwd
502
+ }) : void 0,
503
+ build: async (buildOptions) => {
504
+ const config = await buildCodexPluginThreadConfigWithinDeadline({
505
+ ...buildParams,
506
+ pluginConfig,
507
+ appCacheKey,
508
+ threadId: buildOptions?.threadId,
509
+ appCache: appCache ?? defaultCodexAppInventoryCache,
510
+ metadataCache,
511
+ failClosedOnTimeout: Boolean(params.scheduledRuntimeAuthority),
512
+ transform: params.scheduledRuntimeAuthority ? async (builtConfig, request) => intersectCodexPluginThreadConfigWithScheduledAuthority(builtConfig, params.scheduledRuntimeAuthority, await readCurrentCodexScheduledAppPolicy({
513
+ request,
514
+ configCwd: params.configCwd,
515
+ threadId: buildOptions?.threadId
516
+ })) : void 0,
517
+ request: (method, requestParams, options) => client.request(method, requestParams, options)
518
+ });
519
+ return params.scheduledRuntimeAuthority && inputFingerprint ? {
520
+ ...config,
521
+ inputFingerprint
522
+ } : config;
523
+ }
524
+ };
525
+ };
526
+ }
527
+ function resolveCodexPluginThreadConfigTimeoutMs(requestTimeoutMs) {
528
+ return Math.min(CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS, Math.max(CODEX_PLUGIN_THREAD_CONFIG_MIN_TIMEOUT_MS, Math.floor((Number.isFinite(requestTimeoutMs) && requestTimeoutMs > 0 ? requestTimeoutMs : CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS * CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR) / CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR)));
529
+ }
530
+ function isCodexPluginThreadConfigTimeoutError(error) {
531
+ return error instanceof CodexPluginThreadConfigDeadlineError || error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED" && error.message.endsWith(" timed out");
532
+ }
533
+ //#endregion
534
+ //#region extensions/codex/src/app-server/thread-context-engine.ts
535
+ function buildContextEngineBinding(params, projection) {
536
+ const contextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
537
+ const engineId = contextEngine?.info?.id?.trim();
538
+ if (!contextEngine || !engineId) return;
539
+ return {
540
+ schemaVersion: 1,
541
+ engineId,
542
+ policyFingerprint: JSON.stringify({
543
+ schemaVersion: 1,
544
+ engineId,
545
+ engineVersion: contextEngine.info.version,
546
+ ownsCompaction: contextEngine.info.ownsCompaction === true,
547
+ turnMaintenanceMode: contextEngine.info.turnMaintenanceMode,
548
+ citationsMode: params.config?.memory?.citations,
549
+ contextTokenBudget: params.contextTokenBudget,
550
+ projectionMaxChars: resolveCodexContextEngineProjectionMaxChars({ contextTokenBudget: params.contextTokenBudget })
551
+ }),
552
+ projection: projection ? {
553
+ schemaVersion: 1,
554
+ mode: "thread_bootstrap",
555
+ epoch: projection.epoch,
556
+ fingerprint: projection.fingerprint
557
+ } : void 0
558
+ };
559
+ }
560
+ function isContextEngineBindingCompatible(previous, next) {
561
+ const previousProjection = previous?.projection;
562
+ const nextProjection = next.projection;
563
+ return previous?.schemaVersion === next.schemaVersion && previous.engineId === next.engineId && previous.policyFingerprint === next.policyFingerprint && (!nextProjection ? previousProjection === void 0 : previousProjection?.schemaVersion === nextProjection.schemaVersion && previousProjection.mode === nextProjection.mode && previousProjection.epoch === nextProjection.epoch && previousProjection.fingerprint === nextProjection.fingerprint);
564
+ }
565
+ //#endregion
566
+ //#region extensions/codex/src/app-server/native-model-input-tools.ts
567
+ /** Stock native hooks flatten the configured V2 namespace without a delimiter. */
568
+ function resolveCodexNativeModelInputTools(config) {
569
+ const features = isJsonObject(config.features) ? config.features : void 0;
570
+ const multiAgent = isJsonObject(features?.multi_agent_v2) ? features.multi_agent_v2 : void 0;
571
+ const namespace = typeof multiAgent?.tool_namespace === "string" ? multiAgent.tool_namespace.trim() : "collaboration";
572
+ return [
573
+ "spawn_agent",
574
+ "multi_agent_v1send_input",
575
+ "send_message",
576
+ "followup_task",
577
+ ...namespace ? [
578
+ `${namespace}spawn_agent`,
579
+ `${namespace}send_message`,
580
+ `${namespace}followup_task`
581
+ ] : []
582
+ ];
583
+ }
584
+ //#endregion
585
+ //#region extensions/codex/src/app-server/profiler-flag.ts
586
+ const PROFILER_FLAGS = ["profiler", "codex.profiler"];
587
+ function isCodexAppServerProfilerEnabled(config, env = process.env) {
588
+ return PROFILER_FLAGS.some((flag) => isDiagnosticFlagEnabled(flag, config, env));
589
+ }
590
+ //#endregion
504
591
  //#region extensions/codex/src/app-server/thread-lifecycle-timing.ts
505
- const CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS = 1e3;
506
- const CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS = 500;
507
592
  function createCodexThreadLifecycleTimingTracker(options = {}) {
508
593
  const log = options.log ?? embeddedAgentLog;
509
594
  const timing = createStageTimingTracker(options.now ?? Date.now);
@@ -518,8 +603,8 @@ function createCodexThreadLifecycleTimingTracker(options = {}) {
518
603
  if (didLog) return;
519
604
  const { totalMs, stages: spans } = timing.snapshot();
520
605
  const detailed = options.enabled || log.isEnabled?.("trace");
521
- const totalThresholdMs = options.totalThresholdMs ?? (detailed ? CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS : 1e4);
522
- const stageThresholdMs = options.stageThresholdMs ?? (detailed ? CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS : 5e3);
606
+ const totalThresholdMs = detailed ? 1e3 : 1e4;
607
+ const stageThresholdMs = detailed ? 500 : 5e3;
523
608
  const shouldWarn = totalMs >= totalThresholdMs || spans.some((span) => span.durationMs >= stageThresholdMs);
524
609
  if (!shouldWarn && !log.isEnabled?.("trace")) return;
525
610
  didLog = true;
@@ -566,6 +651,7 @@ async function prepareCodexThreadRequestContext(params, options) {
566
651
  agentDir: params.params.agentDir,
567
652
  config: params.params.config
568
653
  });
654
+ const startModelProvider = startModelSelection.modelProvider;
569
655
  const source = params.params.hostCapabilities.retainSourceAuthority?.();
570
656
  const modelPolicyEnforced = params.nativeModelAdmission === void 0 || options.preflight.nativeModelInputTools !== void 0;
571
657
  let inference;
@@ -601,7 +687,7 @@ async function prepareCodexThreadRequestContext(params, options) {
601
687
  ...options.preflight,
602
688
  bindingIdentity: options.bindingIdentity,
603
689
  startModelSelection,
604
- startModelProvider: startModelSelection.modelProvider,
690
+ startModelProvider,
605
691
  normalizeBindingModelProvider: (authProfileId, modelProvider) => normalizeCodexAppServerBindingModelProvider({
606
692
  authProfileId,
607
693
  modelProvider,
@@ -609,6 +695,18 @@ async function prepareCodexThreadRequestContext(params, options) {
609
695
  agentDir: params.params.agentDir,
610
696
  config: params.params.config
611
697
  }),
698
+ assertInferenceConfig: (config, modelProvider) => assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, config, modelProvider, params.inferenceProviderRoutes),
699
+ buildResumeParams: (binding, authProfileId, config) => buildThreadResumeParams(params.params, {
700
+ ...params,
701
+ threadId: binding.threadId,
702
+ authProfileId,
703
+ model: startModelSelection.model,
704
+ modelProvider: startModelProvider,
705
+ preserveNativeModel: binding.preserveNativeModel === true,
706
+ config,
707
+ hostSystemAgentActive: options.preflight.hostSystemAgentActive,
708
+ restrictedToolSurfaceInheritedMcpServerNames: options.preflight.restrictedToolSurfaceInheritedMcpServerNames
709
+ }),
612
710
  throwIfAborted: options.throwIfAborted
613
711
  };
614
712
  }
@@ -630,7 +728,7 @@ function resolveCodexThreadAgentDir(params) {
630
728
  sessionKey: params.params.sessionKey,
631
729
  agentId: params.agentId ?? params.params.agentId
632
730
  }).sessionAgentId;
633
- return params.agentDir ?? params.params.agentDir ?? resolveAgentDir$2(params.params.config ?? {}, agentId);
731
+ return params.agentDir ?? params.params.agentDir ?? resolveAgentDir$1(params.params.config ?? {}, agentId);
634
732
  }
635
733
  function buildCodexThreadBindingPolicy(params, preflight) {
636
734
  return {
@@ -652,11 +750,14 @@ async function prepareCodexThreadFinalConfigPatch(params, nativeModelInputTools,
652
750
  binding
653
751
  } : { action: "start" },
654
752
  ...nativeModelInputTools ? { nativeModelInputTools } : {}
655
- }) ?? {
656
- configPatch: params.finalConfigPatch,
657
- nativeHookRelayGeneration: params.nativeHookRelayGeneration
753
+ }, params.client) ?? {
754
+ configPatch: void 0,
755
+ nativeHookRelayGeneration: void 0
658
756
  };
659
757
  }
758
+ function buildCodexThreadRequestConfig(params, context, pluginConfigPatch, finalConfigPatch) {
759
+ return applyCodexNativeSkillIsolation(mergeCodexThreadConfigs(params.config, context.userMcpServersConfigPatch, pluginConfigPatch, finalConfigPatch), context.nativeSkillIsolation);
760
+ }
660
761
  async function prepareCodexThreadLifecyclePreflight(params) {
661
762
  let effectiveConfig = await assertCodexModelBackedReviewerEffectiveConfig({
662
763
  client: params.client,
@@ -724,7 +825,7 @@ async function prepareCodexThreadLifecyclePreflight(params) {
724
825
  if (restrictedToolSurface && params.nativeCodeModeEnabled !== false) throw new Error("Codex restricted tool surfaces require native code mode to be disabled");
725
826
  if (!effectiveConfig) effectiveConfig = await lifecycleTiming.measure("effective-config-read", () => readCodexEffectiveConfig(params.client, params.cwd, { signal: params.signal }));
726
827
  params.config = mergeCodexNativeProjectDocThreadConfig(params.config, effectiveConfig);
727
- if (params.shellEnvironment) params.config = mergeCodexNativeShellEnvironment(params.config, effectiveConfig.config.shell_environment_policy);
828
+ if (params.shellEnvironment || params.shellGitConfigParameters) params.config = mergeCodexNativeShellEnvironment(params.config, effectiveConfig.config.shell_environment_policy);
728
829
  const restrictedToolSurfaceInheritedMcpServerNames = restrictedToolSurface ? await lifecycleTiming.measure("restricted-tool-surface-mcp-policy", () => readCodexInheritedMcpServerNames(params.client, params.cwd, params.signal, effectiveConfig)) : [];
729
830
  if (restrictedToolSurface || imageGenerationDenied || params.nativeCodeModeEnabled !== false) await lifecycleTiming.measure("tool-policy-config-requirements-read", () => assertCodexManagedRequirementsDoNotOverrideToolPolicy(params.client, {
730
831
  restrictedToolSurface,
@@ -788,7 +889,7 @@ function recordCodexThreadReady(params, context, threadId, action) {
788
889
  });
789
890
  }
790
891
  async function resumeExistingCodexThread(params, context) {
791
- const { binding: resumeBinding, bindingIdentity, startModelSelection, startModelProvider, userMcpServersConfigPatch, dynamicToolsFingerprint, webSearchThreadConfigFingerprint, ringZeroConfigFingerprint, ringZeroClientInstanceId, hostSystemAgentActive, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, nativeSkillIsolation, lifecycleTiming, normalizeBindingModelProvider, throwIfAborted, stageBindingReplacement } = context;
892
+ const { binding: resumeBinding, bindingIdentity, startModelProvider, dynamicToolsFingerprint, webSearchThreadConfigFingerprint, ringZeroConfigFingerprint, ringZeroClientInstanceId, restrictedToolSurface, lifecycleTiming, normalizeBindingModelProvider, throwIfAborted, stageBindingReplacement } = context;
792
893
  let acceptedConfiguration;
793
894
  let disposeConfiguration;
794
895
  let resumeReservation;
@@ -810,18 +911,8 @@ async function resumeExistingCodexThread(params, context) {
810
911
  const authProfileId = resumeBinding.connectionScope === "supervision" ? void 0 : params.params.authProfileId ?? resumeBinding.authProfileId;
811
912
  const finalConfigPatch = context.prebuiltFinalConfigPatch ?? await prepareCodexThreadFinalConfigPatch(params, context.nativeModelInputTools, resumeBinding);
812
913
  const pluginThreadConfig = context.prebuiltPluginThreadConfig ?? (params.pluginThreadConfig?.enabled ? await lifecycleTiming.measure("plugin-config-build", () => params.pluginThreadConfig?.build()) : void 0);
813
- const resumeConfig = applyCodexNativeSkillIsolation(mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch), nativeSkillIsolation);
814
- const resumeParams = lifecycleTiming.measureSync("thread-resume-params", () => buildThreadResumeParams(params.params, {
815
- ...params,
816
- threadId: resumeBinding.threadId,
817
- authProfileId,
818
- model: startModelSelection.model,
819
- modelProvider: startModelProvider,
820
- preserveNativeModel: resumeBinding.preserveNativeModel === true,
821
- config: resumeConfig,
822
- hostSystemAgentActive,
823
- restrictedToolSurfaceInheritedMcpServerNames
824
- }));
914
+ const resumeConfig = buildCodexThreadRequestConfig(params, context, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch);
915
+ const resumeParams = lifecycleTiming.measureSync("thread-resume-params", () => context.buildResumeParams(resumeBinding, authProfileId, resumeConfig));
825
916
  const requestModelProvider = typeof resumeParams.modelProvider === "string" && resumeParams.modelProvider.trim() ? resumeParams.modelProvider : void 0;
826
917
  throwIfAborted();
827
918
  resumeReservation = params.reserveResumeThread?.(resumeBinding.threadId);
@@ -833,7 +924,7 @@ async function resumeExistingCodexThread(params, context) {
833
924
  withCurrent: params.authority?.withCurrent,
834
925
  assertCurrent: () => {
835
926
  configuration.assertCurrent();
836
- assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, resumeParams.config, requestModelProvider ?? (resumeBinding.preserveNativeModel ? configuration.modelProvider ?? void 0 : void 0), params.inferenceProviderRoutes);
927
+ context.assertInferenceConfig(resumeParams.config, requestModelProvider ?? (resumeBinding.preserveNativeModel ? configuration.modelProvider ?? void 0 : void 0));
837
928
  }
838
929
  }));
839
930
  acceptedConfiguration = configuration;
@@ -903,13 +994,11 @@ async function resumeExistingCodexThread(params, context) {
903
994
  ...resumeBinding,
904
995
  threadId: response.thread.id,
905
996
  ...resumePatch,
906
- liveThreadConfigFingerprint: fingerprintCodexThreadConfig({
907
- ...resumeParams,
908
- model: resumeBinding.preserveNativeModel === true ? null : response.model ?? resumeParams.model ?? null,
909
- requestedModel: resumeBinding.preserveNativeModel === true ? null : resumeParams.model ?? null,
910
- modelProvider: resumeBinding.preserveNativeModel === true ? null : resumePatch.modelProvider ?? null,
911
- requestedModelProvider: resumeBinding.preserveNativeModel === true ? null : resumeParams.modelProvider ?? resumePatch.modelProvider ?? null
912
- }, authProfileId, dynamicToolsFingerprint),
997
+ liveThreadConfigFingerprint: fingerprintCodexThreadConfig(resumeParams, authProfileId, dynamicToolsFingerprint, {
998
+ model: response.model,
999
+ modelProvider: resumePatch.modelProvider ?? null,
1000
+ preserveNativeModel: resumeBinding.preserveNativeModel
1001
+ }),
913
1002
  lifecycle: {
914
1003
  action: "resumed",
915
1004
  ...activeTurnIds.length ? { activeTurnIds } : {}
@@ -946,10 +1035,10 @@ async function resumeExistingCodexThread(params, context) {
946
1035
  }
947
1036
  async function startFreshCodexThread(params, context) {
948
1037
  const clientId = resolveCodexAppServerClientInstanceId(params.client);
949
- const { bindingIdentity, startModelSelection, startModelProvider, userMcpServersConfigPatch, dynamicToolsFingerprint, webSearchThreadConfigFingerprint, ringZeroConfigFingerprint, ringZeroClientInstanceId, contextEngineBinding, hostSystemAgentActive, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, nativeSkillIsolation, lifecycleTiming, normalizeBindingModelProvider, throwIfAborted, prebuiltPluginThreadConfig, preserveExistingBinding, rotatedContextEngineBinding, replacementPredecessor } = context;
1038
+ const { bindingIdentity, startModelSelection, startModelProvider, dynamicToolsFingerprint, webSearchThreadConfigFingerprint, ringZeroConfigFingerprint, ringZeroClientInstanceId, contextEngineBinding, hostSystemAgentActive, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, lifecycleTiming, normalizeBindingModelProvider, throwIfAborted, prebuiltPluginThreadConfig, preserveExistingBinding, rotatedContextEngineBinding, replacementPredecessor } = context;
950
1039
  const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await lifecycleTiming.measure("plugin-config-build", () => params.pluginThreadConfig?.build()) : void 0;
951
1040
  const finalConfigPatch = await prepareCodexThreadFinalConfigPatch(params, context.nativeModelInputTools);
952
- const config = lifecycleTiming.measureSync("merge-thread-config", () => applyCodexNativeSkillIsolation(mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch), nativeSkillIsolation));
1041
+ const config = lifecycleTiming.measureSync("merge-thread-config", () => buildCodexThreadRequestConfig(params, context, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch));
953
1042
  const startParams = lifecycleTiming.measureSync("thread-start-params", () => buildThreadStartParams(params.params, {
954
1043
  ...params,
955
1044
  config,
@@ -966,7 +1055,7 @@ async function startFreshCodexThread(params, context) {
966
1055
  };
967
1056
  const assertInferenceCurrent = () => {
968
1057
  assertCurrent();
969
- assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, startParams.config, requestModelProvider, params.inferenceProviderRoutes);
1058
+ context.assertInferenceConfig(startParams.config, requestModelProvider);
970
1059
  };
971
1060
  const threadStartResponse = await lifecycleTiming.measure("thread-start-request", async () => {
972
1061
  try {
@@ -1076,13 +1165,10 @@ async function startFreshCodexThread(params, context) {
1076
1165
  ...startedBinding,
1077
1166
  modelProvider: response.modelProvider ?? requestModelProvider ?? startModelProvider ?? modelProvider,
1078
1167
  liveThreadEphemeralPolicy: startParams.ephemeral ? createCodexEphemeralThreadPolicy(params) : void 0,
1079
- ...!preserveExistingBinding ? { liveThreadConfigFingerprint: fingerprintCodexThreadConfig({
1080
- ...startParams,
1081
- model: response.model ?? startParams.model ?? null,
1082
- requestedModel: startParams.model ?? null,
1083
- modelProvider: bindingModelProvider ?? null,
1084
- requestedModelProvider: startParams.modelProvider ?? bindingModelProvider ?? null
1085
- }, params.params.authProfileId, dynamicToolsFingerprint) } : {},
1168
+ ...!preserveExistingBinding ? { liveThreadConfigFingerprint: fingerprintCodexThreadConfig(startParams, params.params.authProfileId, dynamicToolsFingerprint, {
1169
+ model: response.model,
1170
+ modelProvider: bindingModelProvider ?? null
1171
+ }) } : {},
1086
1172
  lifecycle: {
1087
1173
  action: "started",
1088
1174
  ...preserveExistingBinding ? { preserveExistingBinding: true } : {},
@@ -1152,7 +1238,7 @@ async function releaseCodexBoundLiveThread(options) {
1152
1238
  }
1153
1239
  /** Reuses one safely owned, fully matching subscription on its original client. */
1154
1240
  async function tryReuseCodexLiveThread(options) {
1155
- const { params, binding, bindingIdentity, clientId, dynamicToolsFingerprint, environmentSelectionFingerprint, hostSystemAgentActive, lifecycleTiming, nativeSkillIsolation, ringZeroActive, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, startModelProvider, startModelSelection, throwIfAborted, userMcpServersConfigPatch } = options;
1241
+ const { params, binding, bindingIdentity, clientId, dynamicToolsFingerprint, environmentSelectionFingerprint, lifecycleTiming, ringZeroActive, restrictedToolSurface, startModelSelection, throwIfAborted } = options;
1156
1242
  const incognito = isIncognitoSessionKey(params.params.sessionKey);
1157
1243
  if (incognito && (binding.preserveNativeModel || binding.connectionScope === "supervision")) {
1158
1244
  if (binding.clientId === clientId && binding.clientId && ((await options.buildLoadedPluginThreadConfig(binding))?.fingerprint ?? binding.pluginAppsFingerprint) === binding.pluginAppsFingerprint) {
@@ -1160,7 +1246,7 @@ async function tryReuseCodexLiveThread(options) {
1160
1246
  action: "resume",
1161
1247
  binding,
1162
1248
  ...options.nativeModelInputTools ? { nativeModelInputTools: options.nativeModelInputTools } : {}
1163
- });
1249
+ }, params.client);
1164
1250
  throwIfAborted();
1165
1251
  params.assertCurrent?.();
1166
1252
  return {
@@ -1212,26 +1298,10 @@ async function tryReuseCodexLiveThread(options) {
1212
1298
  const prebuiltFinalConfigPatch = await prepareCodexThreadFinalConfigPatch(params, options.nativeModelInputTools, binding);
1213
1299
  const pluginAppsConfigPatch = pluginThreadConfig?.configPatch ?? (params.pluginThreadConfig?.enabled && binding.pluginAppPolicyContext ? buildCodexPluginAppsConfigPatchFromPolicyContext(binding.pluginAppPolicyContext) : void 0);
1214
1300
  const resumeAuthProfileId = binding.connectionScope === "supervision" ? void 0 : params.params.authProfileId ?? binding.authProfileId;
1215
- const resumeConfig = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginAppsConfigPatch, prebuiltFinalConfigPatch.configPatch);
1216
- const resumeParams = lifecycleTiming.measureSync("warm-thread-resume-params", () => buildThreadResumeParams(params.params, {
1217
- ...params,
1218
- threadId: binding.threadId,
1219
- authProfileId: resumeAuthProfileId,
1220
- model: startModelSelection.model,
1221
- modelProvider: startModelProvider,
1222
- preserveNativeModel: binding.preserveNativeModel === true,
1223
- config: applyCodexNativeSkillIsolation(resumeConfig, nativeSkillIsolation),
1224
- hostSystemAgentActive,
1225
- restrictedToolSurfaceInheritedMcpServerNames
1226
- }));
1227
- assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, resumeParams.config, resumeParams.modelProvider ?? (binding.preserveNativeModel ? nativeThread?.modelProvider?.trim() || binding.modelProvider : void 0), params.inferenceProviderRoutes);
1228
- const liveThreadConfigFingerprint = incognito ? retainedThread.configFingerprint : fingerprintCodexThreadConfig({
1229
- ...resumeParams,
1230
- model: binding.preserveNativeModel ? null : binding.model ?? resumeParams.model ?? null,
1231
- requestedModel: binding.preserveNativeModel ? null : resumeParams.model ?? null,
1232
- modelProvider: binding.preserveNativeModel ? null : binding.modelProvider ?? resumeParams.modelProvider ?? null,
1233
- requestedModelProvider: binding.preserveNativeModel ? null : resumeParams.modelProvider ?? binding.modelProvider ?? null
1234
- }, resumeAuthProfileId, dynamicToolsFingerprint);
1301
+ const resumeConfig = buildCodexThreadRequestConfig(params, options, pluginAppsConfigPatch, prebuiltFinalConfigPatch.configPatch);
1302
+ const resumeParams = lifecycleTiming.measureSync("warm-thread-resume-params", () => options.buildResumeParams(binding, resumeAuthProfileId, resumeConfig));
1303
+ options.assertInferenceConfig(resumeParams.config, resumeParams.modelProvider ?? (binding.preserveNativeModel ? nativeThread?.modelProvider?.trim() || binding.modelProvider : void 0));
1304
+ const liveThreadConfigFingerprint = incognito ? retainedThread.configFingerprint : fingerprintCodexThreadConfig(resumeParams, resumeAuthProfileId, dynamicToolsFingerprint, binding);
1235
1305
  const ephemeralPolicy = retainedThread.ephemeralPolicy;
1236
1306
  if (incognito && (!ephemeralPolicy || ephemeralPolicy.developerInstructions !== params.developerInstructions || getCodexInferenceThread(params.client, binding.threadId) !== params.inferenceRoute || [...params.inferenceProviderRoutes?.keys() ?? []].some((provider) => !getCodexInferenceThreadQualification(params.client, binding.threadId)?.hasProvider(provider)))) {
1237
1307
  preserveSubscription = true;
@@ -1437,7 +1507,6 @@ async function preparePendingCodexThreadResume(params, binding, dynamicToolsFing
1437
1507
  if (thread.id !== binding.threadId || !isCodexThreadNonRunning(thread.status)) throw fail("the native thread is not idle; wait for its current run to finish");
1438
1508
  assertCodexThreadAcceptsDirectInput(thread);
1439
1509
  const observation = observeCodexThreadConfiguration(params, thread, assertCurrent);
1440
- const dispose = observation.dispose;
1441
1510
  try {
1442
1511
  const rolloutPath = thread.path ?? binding.rolloutPath;
1443
1512
  const metadata = rolloutPath ? await readCodexSessionMeta(path.join(localHome, "sessions"), rolloutPath, binding.threadId) : void 0;
@@ -1450,7 +1519,7 @@ async function preparePendingCodexThreadResume(params, binding, dynamicToolsFing
1450
1519
  assertCurrent
1451
1520
  };
1452
1521
  } catch (error) {
1453
- dispose();
1522
+ observation.dispose();
1454
1523
  throw error;
1455
1524
  }
1456
1525
  }
@@ -1512,16 +1581,11 @@ function withPendingSupervisionCleanup(pending, cleanupThreadIds) {
1512
1581
  }
1513
1582
  async function cleanPendingSupervisionArtifacts(client, pending) {
1514
1583
  const remaining = [];
1515
- for (const threadId of pending.cleanupThreadIds ?? []) if (!await archiveSupervisionArtifact(client, threadId)) remaining.push(threadId);
1516
- return { remaining };
1517
- }
1518
- async function archiveSupervisionArtifact(client, threadId) {
1519
- try {
1584
+ for (const threadId of pending.cleanupThreadIds ?? []) try {
1520
1585
  await client.request("thread/archive", { threadId }, { timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS });
1521
- return true;
1522
1586
  } catch (error) {
1523
1587
  const message = formatErrorMessage(error).toLowerCase();
1524
- if (message.includes("no rollout found for thread id") || message.includes("thread not found") || message.includes("already archived")) return true;
1588
+ if (message.includes("no rollout found for thread id") || message.includes("thread not found") || message.includes("already archived")) continue;
1525
1589
  await unsubscribeCodexThreadBestEffort(client, {
1526
1590
  threadId,
1527
1591
  timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS
@@ -1530,8 +1594,9 @@ async function archiveSupervisionArtifact(client, threadId) {
1530
1594
  threadId,
1531
1595
  error
1532
1596
  });
1533
- return false;
1597
+ remaining.push(threadId);
1534
1598
  }
1599
+ return remaining;
1535
1600
  }
1536
1601
  //#endregion
1537
1602
  //#region extensions/codex/src/app-server/thread-supervision.ts
@@ -1542,6 +1607,15 @@ async function materializePendingSupervisionBranch(params) {
1542
1607
  assertCurrent: params.throwIfAborted,
1543
1608
  withCurrent: params.authority?.withCurrent
1544
1609
  };
1610
+ const requestCreatedThread = (kind, request) => params.lifecycleTiming.measure(kind === "probe" ? "supervision-model-probe-fork" : "supervision-thread-start", async () => {
1611
+ try {
1612
+ return await request();
1613
+ } catch (error) {
1614
+ if (error instanceof CodexAppServerRpcError) throw kind === "probe" ? error : new CodexThreadStartRequestError(error);
1615
+ throw new CodexAppServerUnsafeSubscriptionError(kind === "probe" ? "Codex model test fork may have materialized without a response" : "Canonical Codex branch may have started without a response", { cause: error });
1616
+ }
1617
+ });
1618
+ const attestRestrictedToolSurface = (threadId, config) => params.lifecycleTiming.measure("restricted-tool-surface-mcp-attestation", () => attestCodexRestrictedToolSurfaceMcpServersDisabled(params.client, threadId, config ?? void 0, params.signal));
1545
1619
  const connectionFingerprint = buildCodexAppServerConnectionFingerprint(params.appServer, params.attempt.agentDir);
1546
1620
  if (!pending.connectionFingerprint || pending.connectionFingerprint !== connectionFingerprint) throw new Error("Codex supervision source connection changed before branch materialization");
1547
1621
  pending = await recoverPendingSupervisionArtifacts(params, pending);
@@ -1553,7 +1627,7 @@ async function materializePendingSupervisionBranch(params) {
1553
1627
  params.throwIfAborted();
1554
1628
  const sourceThread = sourceResponse.thread;
1555
1629
  if (sourceThread.id !== pending.sourceThreadId) throw new Error(`Codex supervision source read returned ${sourceThread.id} for ${pending.sourceThreadId}`);
1556
- assertPendingSupervisionSnapshotUnchanged(sourceThread, pending);
1630
+ if (!pending.lastTurnId && (sourceThread.status?.type === "active" || (sourceThread.turns?.length ?? 0) > 0)) throw new Error("Codex source changed after Continue; reopen the source session before sending a message");
1557
1631
  const history = projectBoundedCodexThreadHistory({
1558
1632
  thread: sourceThread,
1559
1633
  throughTurnId: pending.lastTurnId ?? null,
@@ -1590,35 +1664,27 @@ async function materializePendingSupervisionBranch(params) {
1590
1664
  };
1591
1665
  try {
1592
1666
  const probeParams = buildPendingSupervisionProbeForkParams(params, pending);
1593
- const rawProbeResponse = await params.lifecycleTiming.measure("supervision-model-probe-fork", async () => {
1594
- try {
1595
- return await params.client.request("thread/fork", probeParams, requestOptions);
1596
- } catch (error) {
1597
- if (!(error instanceof CodexAppServerRpcError)) throw new CodexAppServerUnsafeSubscriptionError("Codex model probe fork may have materialized without a response", { cause: error });
1598
- throw error;
1599
- }
1600
- });
1667
+ const rawProbeResponse = await requestCreatedThread("probe", () => params.client.request("thread/fork", probeParams, requestOptions));
1601
1668
  const probeThreadId = requireDistinctSupervisionThreadId({
1602
1669
  threadId: readSupervisionResponseThreadId(rawProbeResponse),
1603
1670
  sourceThreadId: pending.sourceThreadId,
1604
- role: "model probe"
1671
+ role: "model test"
1605
1672
  });
1606
1673
  let probeResponse;
1607
1674
  try {
1608
1675
  params.throwIfAborted();
1609
1676
  probeResponse = assertCodexThreadForkResponse(rawProbeResponse);
1610
- if (params.restrictedToolSurface) await params.lifecycleTiming.measure("restricted-tool-surface-mcp-attestation", () => attestCodexRestrictedToolSurfaceMcpServersDisabled(params.client, probeThreadId, probeParams.config ?? void 0, params.signal));
1677
+ if (params.restrictedToolSurface) await attestRestrictedToolSurface(probeThreadId, probeParams.config);
1611
1678
  } finally {
1612
1679
  await unsubscribeCodexAppServerLiveThread(params.client, probeThreadId, CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS).catch((cause) => {
1613
- throw new CodexAppServerUnsafeSubscriptionError(`Codex model probe subscription could not be released: ${probeThreadId}`, { cause });
1680
+ throw new CodexAppServerUnsafeSubscriptionError(`Codex model test subscription could not be released: ${probeThreadId}`, { cause });
1614
1681
  });
1615
1682
  }
1616
1683
  params.throwIfAborted();
1617
1684
  const nativeModel = requireNonBlankSupervisionValue(probeResponse.model, "native model");
1618
- const nativeModelProvider = requireNativeSupervisionModelProvider({
1619
- responseModelProvider: probeResponse.modelProvider,
1620
- responseThreadModelProvider: probeResponse.thread.modelProvider
1621
- });
1685
+ const nativeModelProvider = requireNonBlankSupervisionValue(probeResponse.modelProvider, "native model provider");
1686
+ const threadProvider = probeResponse.thread.modelProvider?.trim();
1687
+ if (threadProvider && threadProvider !== nativeModelProvider) throw new Error(`Codex supervision model provider mismatch: ${nativeModelProvider} != ${threadProvider}`);
1622
1688
  const nativeAttempt = {
1623
1689
  ...params.attempt,
1624
1690
  modelId: nativeModel
@@ -1633,14 +1699,7 @@ async function materializePendingSupervisionBranch(params) {
1633
1699
  modelProvider: nativeModelProvider,
1634
1700
  operation: "thread/start request"
1635
1701
  });
1636
- const rawStartResponse = await params.lifecycleTiming.measure("supervision-thread-start", async () => {
1637
- try {
1638
- return await params.client.request("thread/start", startParams, requestOptions);
1639
- } catch (error) {
1640
- if (error instanceof CodexAppServerRpcError) throw new CodexThreadStartRequestError(error);
1641
- throw new CodexAppServerUnsafeSubscriptionError("Canonical Codex branch may have started without a response", { cause: error });
1642
- }
1643
- });
1702
+ const rawStartResponse = await requestCreatedThread("canonical", () => params.client.request("thread/start", startParams, requestOptions));
1644
1703
  const finalThreadId = requireDistinctSupervisionThreadId({
1645
1704
  threadId: readSupervisionResponseThreadId(rawStartResponse),
1646
1705
  sourceThreadId: pending.sourceThreadId,
@@ -1655,7 +1714,7 @@ async function materializePendingSupervisionBranch(params) {
1655
1714
  modelProvider: nativeModelProvider,
1656
1715
  operation: "thread/start response"
1657
1716
  });
1658
- if (params.restrictedToolSurface) await params.lifecycleTiming.measure("restricted-tool-surface-mcp-attestation", () => attestCodexRestrictedToolSurfaceMcpServersDisabled(params.client, finalThreadId, startParams.config, params.signal));
1717
+ if (params.restrictedToolSurface) await attestRestrictedToolSurface(finalThreadId, startParams.config);
1659
1718
  if (params.provisionalAppIds?.length) try {
1660
1719
  await params.lifecycleTiming.measure("plugin-app-attestation", () => checkCodexThreadAppAvailability({
1661
1720
  client: params.client,
@@ -1705,14 +1764,7 @@ async function materializePendingSupervisionBranch(params) {
1705
1764
  provisionalCleanupSafe = false;
1706
1765
  throw new CodexAppServerUnsafeSubscriptionError(`Canonical Codex branch binding could not be verified: ${finalThreadId}`, { cause: new AggregateError([error, readError]) });
1707
1766
  }
1708
- if (matchesMaterializedSupervisionBranch(current, {
1709
- sourceThreadId: pending.sourceThreadId,
1710
- connectionFingerprint,
1711
- threadId: finalThreadId,
1712
- model: nativeModel,
1713
- modelProvider: bindingModelProvider,
1714
- historyCoveredThrough
1715
- })) committed = true;
1767
+ if (current?.threadId === finalThreadId && current.connectionScope === "supervision" && current.supervisionSourceThreadId === pending.sourceThreadId && current.appServerRuntimeFingerprint === connectionFingerprint && current.pendingSupervisionBranch === void 0 && current.model === nativeModel && current.modelProvider === bindingModelProvider && current.historyCoveredThrough === historyCoveredThrough) committed = true;
1716
1768
  else {
1717
1769
  if (!matchesPendingSupervisionState(current, pending)) {
1718
1770
  provisionalCleanupSafe = false;
@@ -1747,8 +1799,8 @@ async function materializePendingSupervisionBranch(params) {
1747
1799
  await params.abandonClient();
1748
1800
  throw error;
1749
1801
  }
1750
- const cleanup = await cleanPendingSupervisionArtifacts(params.client, pending);
1751
- const nextPending = withPendingSupervisionCleanup(pending, cleanup.remaining);
1802
+ const remaining = await cleanPendingSupervisionArtifacts(params.client, pending);
1803
+ const nextPending = withPendingSupervisionCleanup(pending, remaining);
1752
1804
  let cleanupStateError;
1753
1805
  if (cleanupExpected && !isDeepStrictEqual(cleanupExpected, nextPending)) try {
1754
1806
  await params.bindingStore.mutate(params.bindingIdentity, {
@@ -1759,14 +1811,14 @@ async function materializePendingSupervisionBranch(params) {
1759
1811
  } catch (stateError) {
1760
1812
  cleanupStateError = stateError;
1761
1813
  }
1762
- const unsafeCleanup = cleanup.remaining.length > 0 || error instanceof CodexAppServerUnsafeSubscriptionError;
1814
+ const unsafeCleanup = remaining.length > 0 || error instanceof CodexAppServerUnsafeSubscriptionError;
1763
1815
  if (unsafeCleanup) await params.abandonClient();
1764
1816
  if (cleanupStateError) {
1765
1817
  const cause = new AggregateError([error, cleanupStateError], "Codex supervised branch cleanup state could not be recorded", { cause: error });
1766
1818
  if (unsafeCleanup) throw new CodexAppServerUnsafeSubscriptionError("Codex supervised branch cleanup state could not be recorded", { cause });
1767
1819
  throw cause;
1768
1820
  }
1769
- if (cleanup.remaining.length > 0) throw new CodexAppServerUnsafeSubscriptionError(`Codex supervised branch cleanup remains pending: ${cleanup.remaining.join(", ")}`, { cause: error });
1821
+ if (remaining.length > 0) throw new CodexAppServerUnsafeSubscriptionError(`Codex supervised branch cleanup remains pending: ${remaining.join(", ")}`, { cause: error });
1770
1822
  throw error;
1771
1823
  }
1772
1824
  }
@@ -1781,32 +1833,22 @@ function buildPendingSupervisionProbeForkParams(params, pending) {
1781
1833
  ...codexThreadSandboxOrPermissions(params.appServer),
1782
1834
  ...params.appServer.serviceTier !== void 0 ? { serviceTier: params.appServer.serviceTier } : {},
1783
1835
  config: runtimeConfig,
1784
- developerInstructions: params.developerInstructions ?? buildDeveloperInstructions(params.attempt, { dynamicTools: params.dynamicTools }),
1836
+ developerInstructions: params.developerInstructions ?? buildDeveloperInstructions(params.attempt, {
1837
+ dynamicTools: params.dynamicTools,
1838
+ nativeCodeModeOnlyEnabled: runtimeConfig["features.code_mode_only"] === true
1839
+ }),
1785
1840
  ephemeral: true,
1786
1841
  threadSource: "appServer",
1787
1842
  excludeTurns: true
1788
1843
  };
1789
1844
  }
1790
- function assertPendingSupervisionSnapshotUnchanged(thread, pending) {
1791
- if (pending.lastTurnId) return;
1792
- if (thread.status?.type === "active" || (thread.turns?.length ?? 0) > 0) throw new Error("Codex source changed after Continue; reopen the source session before sending a message");
1793
- }
1794
1845
  function requireNonBlankSupervisionValue(value, label) {
1795
1846
  if (typeof value !== "string" || !value.trim()) throw new Error(`Codex supervision ${label} is missing`);
1796
1847
  return value.trim();
1797
1848
  }
1798
- function requireNativeSupervisionModelProvider(params) {
1799
- const responseProvider = requireNonBlankSupervisionValue(params.responseModelProvider, "native model provider");
1800
- const threadProvider = params.responseThreadModelProvider?.trim();
1801
- if (threadProvider && threadProvider !== responseProvider) throw new Error(`Codex supervision model provider mismatch: ${responseProvider} != ${threadProvider}`);
1802
- return responseProvider;
1803
- }
1804
1849
  function matchesPendingSupervisionState(binding, expected) {
1805
1850
  return binding?.connectionScope === "supervision" && binding.supervisionSourceThreadId === expected.sourceThreadId && matchesPendingSupervisionBranch(binding, expected);
1806
1851
  }
1807
- function matchesMaterializedSupervisionBranch(binding, expected) {
1808
- return binding?.threadId === expected.threadId && binding.connectionScope === "supervision" && binding.supervisionSourceThreadId === expected.sourceThreadId && binding.appServerRuntimeFingerprint === expected.connectionFingerprint && binding.pendingSupervisionBranch === void 0 && binding.model === expected.model && binding.modelProvider === expected.modelProvider && binding.historyCoveredThrough === expected.historyCoveredThrough;
1809
- }
1810
1852
  function requireDistinctSupervisionThreadId(params) {
1811
1853
  let threadId;
1812
1854
  try {
@@ -1819,17 +1861,17 @@ function requireDistinctSupervisionThreadId(params) {
1819
1861
  }
1820
1862
  async function recoverPendingSupervisionArtifacts(params, pending) {
1821
1863
  if (!pending.cleanupThreadIds?.length) return pending;
1822
- const cleanup = await cleanPendingSupervisionArtifacts(params.client, pending);
1823
- const next = withPendingSupervisionCleanup(pending, cleanup.remaining);
1824
- const incomplete = cleanup.remaining.length > 0;
1825
- if (!incomplete || cleanup.remaining.length !== pending.cleanupThreadIds.length) {
1864
+ const remaining = await cleanPendingSupervisionArtifacts(params.client, pending);
1865
+ const next = withPendingSupervisionCleanup(pending, remaining);
1866
+ const incomplete = remaining.length > 0;
1867
+ if (!incomplete || remaining.length !== pending.cleanupThreadIds.length) {
1826
1868
  if (!await params.bindingStore.mutate(params.bindingIdentity, {
1827
1869
  kind: "patch-pending-supervision-branch",
1828
1870
  expected: pending,
1829
1871
  pending: next
1830
1872
  })) throw new CodexThreadBindingConflictError(pending.sourceThreadId, incomplete ? "recording supervised Codex cleanup recovery" : "recovering a supervised Codex branch");
1831
1873
  }
1832
- if (incomplete) throw new Error(`Codex supervised branch cleanup must finish before retry: ${cleanup.remaining.join(", ")}`);
1874
+ if (incomplete) throw new Error(`Codex supervised branch cleanup must finish before retry: ${remaining.join(", ")}`);
1833
1875
  return next;
1834
1876
  }
1835
1877
  //#endregion
@@ -1863,7 +1905,7 @@ async function startOrResumeThread(input) {
1863
1905
  }
1864
1906
  const preflight = await prepareCodexThreadLifecyclePreflight(params);
1865
1907
  const callerConfig = params.config;
1866
- const { contextEngineBinding, dynamicToolsContainDeferred, dynamicToolsFingerprint, hostSystemAgentActive, legacyDynamicToolsFingerprint, legacyUserMcpServersFingerprint, lifecycleTiming, nativeSkillIsolation, nativeSkillIsolationFingerprint, networkProxyConfigFingerprint, ringZeroActive, ringZeroClientInstanceId, ringZeroConfigFingerprint, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, userMcpServersConfigPatch, userMcpServersFingerprint, webSearchThreadConfigFingerprint } = preflight;
1908
+ const { contextEngineBinding, dynamicToolsContainDeferred, dynamicToolsFingerprint, hostSystemAgentActive, legacyDynamicToolsFingerprint, legacyUserMcpServersFingerprint, lifecycleTiming, nativeSkillIsolationFingerprint, networkProxyConfigFingerprint, ringZeroActive, ringZeroClientInstanceId, ringZeroConfigFingerprint, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, userMcpServersFingerprint, webSearchThreadConfigFingerprint } = preflight;
1867
1909
  let replacementPredecessor;
1868
1910
  const initialBoundThreadId = binding?.threadId;
1869
1911
  const initialBoundClientId = binding?.clientId;
@@ -1899,37 +1941,22 @@ async function startOrResumeThread(input) {
1899
1941
  const pendingBinding = binding;
1900
1942
  const pluginThreadConfig = params.pluginThreadConfig?.enabled ? await lifecycleTiming.measure("plugin-config-build", () => params.pluginThreadConfig?.build()) : void 0;
1901
1943
  const finalConfigPatch = await prepareCodexThreadFinalConfigPatch(params, requestContext.nativeModelInputTools);
1902
- const config = lifecycleTiming.measureSync("merge-thread-config", () => applyCodexNativeSkillIsolation(mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch), nativeSkillIsolation));
1944
+ const config = lifecycleTiming.measureSync("merge-thread-config", () => buildCodexThreadRequestConfig(params, preflight, pluginThreadConfig?.configPatch, finalConfigPatch.configPatch));
1903
1945
  return publishCodexThreadInferenceBinding(params, await materializePendingSupervisionBranch({
1904
- client: params.client,
1946
+ ...params,
1905
1947
  abandonClient: params.abandonClient ?? (() => closeCodexStartupClientBestEffort(params.client)),
1906
- bindingStore: params.bindingStore,
1907
1948
  bindingIdentity,
1908
1949
  authority,
1909
1950
  binding: pendingBinding,
1910
1951
  attempt: params.params,
1911
- cwd: params.cwd,
1912
- dynamicTools: params.dynamicTools,
1913
- appServer: params.appServer,
1914
- developerInstructions: params.developerInstructions,
1915
- refreshableInstructions: params.refreshableInstructions,
1916
1952
  config,
1917
- nativeCodeModeEnabled: params.nativeCodeModeEnabled,
1918
- nativeProviderWebSearchSupport: params.nativeProviderWebSearchSupport,
1919
- nativeCodeModeOnlyEnabled: params.nativeCodeModeOnlyEnabled,
1920
- webSearchAllowed: params.webSearchAllowed,
1921
1953
  hostSystemAgentActive,
1922
1954
  restrictedToolSurface,
1923
1955
  restrictedToolSurfaceInheritedMcpServerNames,
1924
- shellEnvironment: params.shellEnvironment,
1925
- shellPathPrepend: params.shellPathPrepend,
1926
- disableLoginShell: params.disableLoginShell,
1927
- environmentSelection: params.environmentSelection,
1928
1956
  provisionalAppIds: pluginThreadConfig?.provisionalAppIds,
1929
- signal: params.signal,
1930
1957
  throwIfAborted: () => {
1931
1958
  params.assertCurrent?.();
1932
- assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, config, void 0, params.inferenceProviderRoutes);
1959
+ requestContext.assertInferenceConfig(config);
1933
1960
  },
1934
1961
  lifecycleTiming,
1935
1962
  normalizeBindingModelProvider: requestContext.normalizeBindingModelProvider,
@@ -1977,30 +2004,30 @@ async function startOrResumeThread(input) {
1977
2004
  releaseRetainedThread: (threadId, assertCurrent) => releaseRetainedThread(threadId, initialBoundClientId, assertCurrent),
1978
2005
  transientRestriction: transientDelegationRestriction || transientNativeToolRestriction || transientWebSearchRestriction
1979
2006
  }));
1980
- if (binding?.threadId && !restrictedToolSurface && binding.nativeToolPolicyRestricted === true) stageBindingReplacement("rotating a host-policy-restricted thread binding");
1981
- if (binding?.threadId && binding.nativeSkillIsolationFingerprint !== nativeSkillIsolationFingerprint) {
1982
- embeddedAgentLog.debug("codex app-server native skill isolation changed; starting a new thread", { threadId: binding.threadId });
1983
- stageBindingReplacement("rotating stale native skill isolation");
1984
- }
1985
- if (binding?.threadId && (binding.ringZeroConfigFingerprint !== ringZeroConfigFingerprint || binding.ringZeroClientInstanceId !== ringZeroClientInstanceId) && (ringZeroActive || binding.ringZeroConfigFingerprint !== void 0)) {
1986
- embeddedAgentLog.debug("codex app-server ring-zero restriction changed; rotating thread", { threadId: binding.threadId });
1987
- stageBindingReplacement("rotating a ring-zero thread binding");
1988
- }
1989
- if (binding?.threadId && shouldRotateCodexAppServerBindingForRuntime({
1990
- connectionClass: params.appServer.connectionClass,
1991
- current: binding.connectionScope === "supervision" ? buildCodexAppServerConnectionFingerprint(params.appServer, params.params.agentDir) : params.appServerRuntimeFingerprint,
1992
- binding: binding.appServerRuntimeFingerprint
1993
- })) rotateStaleBinding(binding, "runtime identity", { connectionClass: params.appServer.connectionClass });
1994
- if (binding?.threadId && shouldRotateCodexGpt56MultiAgentBinding({
1995
- bindingModel: binding.model,
1996
- requestedModel: params.params.modelId
1997
- })) {
1998
- embeddedAgentLog.debug("codex app-server GPT-5.6 multi-agent version changed; starting a new thread", {
1999
- threadId: binding.threadId,
2007
+ if (binding?.threadId) {
2008
+ if (!restrictedToolSurface && binding.nativeToolPolicyRestricted === true) stageBindingReplacement("rotating a host-policy-restricted thread binding");
2009
+ else if (binding.nativeSkillIsolationFingerprint !== nativeSkillIsolationFingerprint) {
2010
+ embeddedAgentLog.debug("codex app-server native skill isolation changed; starting a new thread", { threadId: binding.threadId });
2011
+ stageBindingReplacement("rotating stale native skill isolation");
2012
+ } else if ((binding.ringZeroConfigFingerprint !== ringZeroConfigFingerprint || binding.ringZeroClientInstanceId !== ringZeroClientInstanceId) && (ringZeroActive || binding.ringZeroConfigFingerprint !== void 0)) {
2013
+ embeddedAgentLog.debug("codex app-server ring-zero restriction changed; rotating thread", { threadId: binding.threadId });
2014
+ stageBindingReplacement("rotating a ring-zero thread binding");
2015
+ } else if (shouldRotateCodexAppServerBindingForRuntime({
2016
+ connectionClass: params.appServer.connectionClass,
2017
+ current: binding.connectionScope === "supervision" ? buildCodexAppServerConnectionFingerprint(params.appServer, params.params.agentDir) : params.appServerRuntimeFingerprint,
2018
+ binding: binding.appServerRuntimeFingerprint
2019
+ })) rotateStaleBinding(binding, "runtime identity", { connectionClass: params.appServer.connectionClass });
2020
+ else if (shouldRotateCodexGpt56MultiAgentBinding({
2000
2021
  bindingModel: binding.model,
2001
2022
  requestedModel: params.params.modelId
2002
- });
2003
- stageBindingReplacement("rotating a GPT-5.6 multi-agent thread binding");
2023
+ })) {
2024
+ embeddedAgentLog.debug("codex app-server GPT-5.6 multi-agent version changed; starting a new thread", {
2025
+ threadId: binding.threadId,
2026
+ bindingModel: binding.model,
2027
+ requestedModel: params.params.modelId
2028
+ });
2029
+ stageBindingReplacement("rotating a GPT-5.6 multi-agent thread binding");
2030
+ }
2004
2031
  }
2005
2032
  selectionBinding = binding;
2006
2033
  let preserveExistingBinding = transientDelegationRestriction || !ringZeroActive && params.nativeProviderWebSearchSupport === "unknown" && !binding?.threadId;
@@ -2078,23 +2105,21 @@ async function startOrResumeThread(input) {
2078
2105
  rotatedContextEngineBinding = true;
2079
2106
  }
2080
2107
  }
2081
- if (binding?.threadId && !areUserMcpServersFingerprintsCompatible({
2082
- previous: binding.userMcpServersFingerprint,
2083
- next: userMcpServersFingerprint,
2084
- nextLegacy: legacyUserMcpServersFingerprint
2085
- })) rotateStaleBinding(binding, "user MCP config");
2086
- if (binding?.threadId && (binding.networkProxyConfigFingerprint !== networkProxyConfigFingerprint || binding.networkProxyProfileName !== params.appServer.networkProxy?.profileName)) rotateStaleBinding(binding, "network proxy config");
2087
2108
  if (binding?.threadId) {
2088
- if (isCodexPluginThreadBindingStale({
2109
+ if (!areUserMcpServersFingerprintsCompatible({
2110
+ previous: binding.userMcpServersFingerprint,
2111
+ next: userMcpServersFingerprint,
2112
+ nextLegacy: legacyUserMcpServersFingerprint
2113
+ })) rotateStaleBinding(binding, "user MCP config");
2114
+ else if (binding.networkProxyConfigFingerprint !== networkProxyConfigFingerprint || binding.networkProxyProfileName !== params.appServer.networkProxy?.profileName) rotateStaleBinding(binding, "network proxy config");
2115
+ else if (isCodexPluginThreadBindingStale({
2089
2116
  codexPluginsEnabled: params.pluginThreadConfig?.enabled ?? false,
2090
2117
  bindingFingerprint: binding.pluginAppsFingerprint,
2091
2118
  bindingInputFingerprint: binding.pluginAppsInputFingerprint,
2092
2119
  currentInputFingerprint: params.pluginThreadConfig?.inputFingerprint,
2093
2120
  hasBindingPolicyContext: Boolean(binding.pluginAppPolicyContext)
2094
2121
  })) rotateStaleBinding(binding, "plugin app config");
2095
- }
2096
- if (binding?.threadId) {
2097
- if (binding.dynamicToolsFingerprint && params.dynamicTools.length > 0 && binding.dynamicToolsContainDeferred !== dynamicToolsContainDeferred && (binding.dynamicToolsContainDeferred !== void 0 || !dynamicToolsContainDeferred)) rotateStaleBinding(binding, "dynamic tool loading");
2122
+ else if (binding.dynamicToolsFingerprint && params.dynamicTools.length > 0 && binding.dynamicToolsContainDeferred !== dynamicToolsContainDeferred && (binding.dynamicToolsContainDeferred !== void 0 || !dynamicToolsContainDeferred)) rotateStaleBinding(binding, "dynamic tool loading");
2098
2123
  }
2099
2124
  if (binding?.threadId) {
2100
2125
  if (binding.dynamicToolsFingerprint && !areCodexDynamicToolFingerprintsCompatible({
@@ -2155,169 +2180,4 @@ async function startOrResumeThread(input) {
2155
2180
  });
2156
2181
  }
2157
2182
  //#endregion
2158
- //#region extensions/codex/src/app-server/user-input.ts
2159
- function prependHistoryProvenance(input, historyProvenancePrefix) {
2160
- if (!historyProvenancePrefix) return input;
2161
- const firstTextIndex = input.findIndex((item) => item.type === "text");
2162
- if (firstTextIndex === -1) return [{
2163
- type: "text",
2164
- text: historyProvenancePrefix,
2165
- text_elements: []
2166
- }, ...input];
2167
- return input.map((item, index) => index === firstTextIndex && item.type === "text" ? {
2168
- ...item,
2169
- text: `${historyProvenancePrefix}${item.text}`
2170
- } : item);
2171
- }
2172
- /** Builds ordered Codex user input for both new turns and same-turn steering. */
2173
- function buildCodexUserInput(text, images, contextImageGroups, historyProvenancePrefix) {
2174
- if (text !== void 0 && contextImageGroups?.length) {
2175
- let offset = 0;
2176
- return prependHistoryProvenance([...contextImageGroups.flatMap((group) => {
2177
- const parts = buildCodexUserInput(text.slice(offset, group.end), group.images);
2178
- offset = group.end;
2179
- return parts;
2180
- }), ...buildCodexUserInput(text.slice(offset), images)], historyProvenancePrefix);
2181
- }
2182
- const imageInputs = (images ?? []).map((image) => {
2183
- const imageUrl = sanitizeInlineImageDataUrl(`data:${image.mimeType};base64,${image.data}`);
2184
- return imageUrl ? {
2185
- type: "image",
2186
- url: imageUrl
2187
- } : {
2188
- type: "text",
2189
- text: invalidInlineImageText("codex user input"),
2190
- text_elements: []
2191
- };
2192
- });
2193
- return prependHistoryProvenance([...text === void 0 ? [] : [{
2194
- type: "text",
2195
- text,
2196
- text_elements: []
2197
- }], ...imageInputs], historyProvenancePrefix);
2198
- }
2199
- //#endregion
2200
- //#region extensions/codex/src/app-server/turn-params.ts
2201
- const CODEX_CURRENT_SENDER_FIELD_MAX_CHARS = 256;
2202
- function readCodexCurrentSender(params) {
2203
- const metadata = asOptionalRecord(asOptionalRecord(params.userTurnTranscriptRecorder?.message)?.["__openclaw"]);
2204
- const recorded = [
2205
- normalizeOptionalString(metadata?.["senderId"]),
2206
- normalizeOptionalString(metadata?.["senderName"]),
2207
- normalizeOptionalString(metadata?.["senderUsername"])
2208
- ];
2209
- const [id, name, username] = recorded.some(Boolean) ? recorded : [
2210
- normalizeOptionalString(params.senderId),
2211
- normalizeOptionalString(params.senderName),
2212
- normalizeOptionalString(params.senderUsername)
2213
- ];
2214
- if (!id && !name && !username) return;
2215
- const bound = (value) => truncateUtf16Safe(value, CODEX_CURRENT_SENDER_FIELD_MAX_CHARS);
2216
- return {
2217
- ...id ? { id: bound(id) } : {},
2218
- ...name ? { name: bound(name) } : {},
2219
- ...username ? { username: bound(username) } : {}
2220
- };
2221
- }
2222
- function buildCodexHistoryProvenancePrefix(params) {
2223
- const sender = readCodexCurrentSender(params);
2224
- return sender?.id ? neutralizeCodexExplicitMentionSigils(`[OpenClaw conversation info: sender=${JSON.stringify(sender)}]\n`) : void 0;
2225
- }
2226
- function buildTurnStartParams(params, options) {
2227
- const modelSelection = options.preserveNativeTurnSettings ? void 0 : resolveCodexAppServerRequestModelSelection({
2228
- homeScope: options.appServer.start.homeScope,
2229
- model: options.model ?? params.modelId,
2230
- modelProvider: options.modelProvider,
2231
- authProfileId: params.authProfileId,
2232
- authProfileStore: params.authProfileStore,
2233
- agentDir: params.agentDir,
2234
- config: params.config
2235
- });
2236
- const collaborationMode = modelSelection ? buildTurnCollaborationMode(params, { model: modelSelection.model }) : void 0;
2237
- if (collaborationMode && options.parentLocalEgress) collaborationMode.settings.developer_instructions = null;
2238
- const useThreadPermissionProfile = options.appServer.networkProxy && !options.sandboxPolicy;
2239
- const currentSender = params.trigger === "user" ? readCodexCurrentSender(params) : void 0;
2240
- const additionalContext = {
2241
- ...buildCodexTemporalAdditionalContext(params, { sessionStatusAvailable: options.sessionStatusAvailable === true }),
2242
- openclaw_active_computer: {
2243
- kind: "application",
2244
- value: params.hostCapabilities.activeComputerContext?.() ?? "Current active computer: active_node=unknown (host presence unavailable)"
2245
- },
2246
- openclaw_source_delivery: {
2247
- kind: "application",
2248
- value: ["Current source-delivery policy for this turn (replaces earlier source-delivery guidance):", buildHarnessVisibleReplyGuidance({
2249
- sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
2250
- messageToolAvailable: options.messageToolAvailable === true,
2251
- requireExplicitMessageTarget: options.requireExplicitMessageTarget
2252
- })].join("\n")
2253
- }
2254
- };
2255
- if (currentSender) additionalContext.openclaw_current_sender = {
2256
- kind: "untrusted",
2257
- value: JSON.stringify({ sender: currentSender })
2258
- };
2259
- if (params.permissionChange?.notice) additionalContext.openclaw_permission_change = {
2260
- kind: "application",
2261
- value: params.permissionChange.notice
2262
- };
2263
- return {
2264
- threadId: options.threadId,
2265
- ...params.trigger ? { turnTrigger: params.trigger } : {},
2266
- input: [...buildCodexUserInput(options.promptText ?? params.prompt, params.images, options.contextImageGroups, options.historyProvenancePrefix ?? (params.trigger === "user" ? buildCodexHistoryProvenancePrefix(params) : void 0)), ...options.explicitSkillInputs ?? []],
2267
- additionalContext,
2268
- cwd: options.cwd,
2269
- ...options.appServer.sessionRoot ? { runtimeWorkspaceRoots: [options.appServer.sessionRoot] } : {},
2270
- approvalPolicy: options.appServer.approvalPolicy,
2271
- approvalsReviewer: options.appServer.approvalsReviewer,
2272
- ...useThreadPermissionProfile ? {} : { sandboxPolicy: options.sandboxPolicy ?? codexSandboxPolicyForTurn(options.appServer.sandbox, options.appServer.sessionRoot ?? options.cwd, options.appServer.start?.args) },
2273
- ...modelSelection ? {
2274
- model: modelSelection.model,
2275
- personality: CODEX_NATIVE_PERSONALITY_NONE
2276
- } : {},
2277
- ...options.appServer.serviceTier !== void 0 ? { serviceTier: options.appServer.serviceTier } : options.clearInheritedServiceTier ? { serviceTier: null } : {},
2278
- ...collaborationMode ? {
2279
- effort: collaborationMode.settings.reasoning_effort,
2280
- collaborationMode
2281
- } : {},
2282
- ...params.requireWorkspaceOnly === true ? { environments: [] } : options.environmentSelection ? { environments: options.environmentSelection } : {}
2283
- };
2284
- }
2285
- function buildCodexTemporalAdditionalContext(params, options) {
2286
- return { openclaw_temporal_context: {
2287
- kind: "application",
2288
- value: buildTemporalContextText({
2289
- configuredTimezone: params.config?.agents?.defaults?.userTimezone,
2290
- sessionStatusAvailable: options.sessionStatusAvailable
2291
- })
2292
- } };
2293
- }
2294
- function buildTurnCollaborationMode(params, options = {}) {
2295
- const model = options.model ?? params.modelId;
2296
- return {
2297
- mode: "default",
2298
- settings: {
2299
- model,
2300
- reasoning_effort: resolveCodexAppServerReasoningEffort({
2301
- thinkLevel: params.thinkLevel,
2302
- modelId: model,
2303
- supportedReasoningEfforts: readCodexSupportedReasoningEfforts(params.model?.compat)
2304
- }),
2305
- developer_instructions: params.trigger === "cron" ? buildCronCollaborationInstructions() : null
2306
- }
2307
- };
2308
- }
2309
- function buildCodexParentLocalInstructions(params, options = {}) {
2310
- const contextInstructions = joinPresentSections(options.personaInstructions, options.skillsInstructions, options.memoryInstructions);
2311
- if (params.trigger === "cron") return joinPresentSections(buildCronCollaborationInstructions(), contextInstructions);
2312
- return contextInstructions || null;
2313
- }
2314
- function buildCronCollaborationInstructions() {
2315
- return [
2316
- "This is an OpenClaw cron automation turn. Apply these instructions only to this scheduled job; ordinary chat turns should stay in Codex Default mode.",
2317
- "Execute the cron payload directly. If it asks you to run an exact command, run that command before doing any investigation, planning, memory review, or workspace bootstrap.",
2318
- "Use context already provided by the runtime, but do not spend time loading or re-reading workspace bootstrap, memory, or project-doc files before executing the cron payload. Inspect those files only if the payload asks for them or the command fails and they are needed to diagnose it.",
2319
- "Keep output concise and automation-oriented. Prefer the final command result or a short failure summary over status narration."
2320
- ].join("\n\n");
2321
- }
2322
- //#endregion
2323
- export { buildContextEngineBinding as _, buildTurnStartParams as a, resolveCodexAppServerReasoningEffort as b, assertScheduledCodexAppAuthorityRuntime as c, buildScheduledCodexAppServerConnectionIdentity as d, captureScheduledCodexAppAuthority as f, isCodexAppServerProfilerEnabled as g, resolveScheduledCodexAppCreatorCaptureDecision as h, buildTurnCollaborationMode as i, buildLegacyScheduledCodexAppRecoveryPrompt as l, readCurrentCodexScheduledAppPolicy as m, buildCodexParentLocalInstructions as n, buildCodexUserInput as o, intersectCodexPluginThreadConfigWithScheduledAuthority as p, buildCodexTemporalAdditionalContext as r, startOrResumeThread as s, buildCodexHistoryProvenancePrefix as t, buildScheduledCodexAppAuthorityInputFingerprint as u, isContextEngineBindingCompatible as v, readCodexSupportedReasoningEfforts as y };
2183
+ export { prepareCodexPluginThreadConfigStartupProvider as a, buildLegacyScheduledCodexAppRecoveryPrompt as c, resolveScheduledCodexAppCreatorCaptureDecision as d, isContextEngineBindingCompatible as i, buildScheduledCodexAppServerConnectionIdentity as l, isCodexAppServerProfilerEnabled as n, resolveCodexPluginThreadConfigStartupPolicy as o, buildContextEngineBinding as r, assertScheduledCodexAppAuthorityRuntime as s, startOrResumeThread as t, captureScheduledCodexAppAuthority as u };