@openclaw/codex 2026.9.7 → 2026.10.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +8 -0
  2. package/dist/.setup/{account-usage-runtime-DFhbh1zz.mjs → account-usage-runtime-C4GFoef_.mjs} +5 -5
  3. package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
  4. package/dist/.setup/{apply-D3GcSoSa.mjs → apply-D02fLpgN.mjs} +48 -39
  5. package/dist/.setup/attempt-client-cleanup-yLjGwbwT.mjs +155 -0
  6. package/dist/.setup/{attempt-workspace-context-C5HigshI.mjs → attempt-workspace-context-CbSzT6V2.mjs} +11 -15
  7. package/dist/.setup/{auth-binding-BLWz7stm.mjs → auth-binding-BoMwpuPN.mjs} +17 -25
  8. package/dist/.setup/{auth-cache-key-Dbvq-QgB.mjs → auth-cache-key-CEd9QlIs.mjs} +244 -82
  9. package/dist/.setup/{auth-profile-B0okYl2D.mjs → auth-profile-CgHQ8Vot.mjs} +2 -1
  10. package/dist/.setup/{auth-profile-selection-DFu9e167.mjs → auth-profile-selection-hr8ocLtz.mjs} +5 -7
  11. package/dist/.setup/{binding-connection-DTtN1KrX.mjs → binding-connection-C-08ez1w.mjs} +2 -2
  12. package/dist/.setup/{binding-connection.runtime-6TpgD1M6.mjs → binding-connection.runtime-Dn2p-fdy.mjs} +3 -3
  13. package/dist/.setup/{bounded-turn-CbjoN2OW.mjs → bounded-turn-DlHlNTyS.mjs} +14 -13
  14. package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
  15. package/dist/.setup/{build-state-Da1_z0kd.mjs → build-state-CIi3Ckqu.mjs} +1 -1
  16. package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
  17. package/dist/.setup/{client-N0JpgSzF.mjs → client-CBzEVDyb.mjs} +438 -160
  18. package/dist/.setup/{client-catalog-response-5HHLdcde.mjs → client-catalog-response-CmvIiDdj.mjs} +57 -25
  19. package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
  20. package/dist/.setup/{command-dispatch-BeAoaovI.mjs → command-dispatch-BE_RdMou.mjs} +3 -3
  21. package/dist/.setup/{command-formatters-R3ckE3Co.mjs → command-formatters-DV3DHhdr.mjs} +7 -5
  22. package/dist/.setup/{command-handlers-ylTMS00z.mjs → command-handlers-DNoRq5Ps.mjs} +82 -144
  23. package/dist/.setup/{command-rpc-CGJGUQ6Y.mjs → command-rpc-B6xsq2dB.mjs} +23 -31
  24. package/dist/.setup/{compact-C2WamavS.mjs → compact-BLSAd-ru.mjs} +117 -65
  25. package/dist/.setup/{plugin-metadata-cache-DsjsL1dr.mjs → computer-use-DpolvQHw.mjs} +66 -203
  26. package/dist/.setup/{config-DKhXquav.mjs → config-0Gxk3_eq.mjs} +5 -6
  27. package/dist/.setup/{config-options-CzyWLTJt.mjs → config-options-HG_Rr3W_.mjs} +13 -23
  28. package/dist/.setup/{config-parsing-b088LyhT.mjs → config-parsing-BQq-CHTF.mjs} +41 -4
  29. package/dist/.setup/{config-runtime-C0NbLms1.mjs → config-runtime-cUYrqu_a.mjs} +2 -2
  30. package/dist/.setup/{config-security-CE-FcGw9.mjs → config-security-KAPScztc.mjs} +20 -36
  31. package/dist/.setup/{context-engine-projection-PezSESth.mjs → context-engine-projection-CsgYSQhW.mjs} +11 -14
  32. package/dist/.setup/{conversation-binding-3Min8qvP.mjs → conversation-binding-CgSSD1Qz.mjs} +36 -48
  33. package/dist/.setup/{conversation-binding-data-C746z5Pn.mjs → conversation-binding-data-DJ4ix-W5.mjs} +1 -1
  34. package/dist/.setup/{conversation-control-CEP8X5JC.mjs → conversation-control-tCg763cI.mjs} +19 -21
  35. package/dist/.setup/{cyber-failover-XV0nNRZu.mjs → cyber-failover-Bb1J6hS1.mjs} +1 -1
  36. package/dist/.setup/{cyber-failover-notice-RNpGpTyP.mjs → cyber-failover-notice-XR03ef31.mjs} +1 -1
  37. package/dist/.setup/doctor-start-options-DPW9JxIE.mjs +63 -0
  38. package/dist/.setup/dynamic-tool-build-CVrx02cH.mjs +463 -0
  39. package/dist/.setup/{dynamic-tools-DzlsLUuS.mjs → dynamic-tools-DdsymYGQ.mjs} +238 -878
  40. package/dist/.setup/{effective-mcp-catalog-CxUtC-xG.mjs → effective-mcp-catalog-BysTBZCW.mjs} +83 -11
  41. package/dist/.setup/{elicitation-input-DPoK8F7w.mjs → elicitation-input-r9axtppm.mjs} +4 -2
  42. package/dist/.setup/{ephemeral-turn-CDsPJOa2.mjs → ephemeral-turn-oPKxs3ia.mjs} +2 -2
  43. package/dist/.setup/{event-projector-assistant-message-CigreO4K.mjs → event-projector-assistant-message-YCL2wspu.mjs} +2 -2
  44. package/dist/.setup/{event-projector-values-DJSz8BTk.mjs → event-projector-values-DTqZHizf.mjs} +2 -12
  45. package/dist/.setup/{inference-dispatch-CMZtjQyz.mjs → inference-dispatch-B5UKEUyC.mjs} +12 -21
  46. package/dist/.setup/{inference-proxy-DhcXOgUE.mjs → inference-proxy-DUO5E2QQ.mjs} +6 -5
  47. package/dist/.setup/{isolated-completion-Dm3PzxJk.mjs → isolated-completion-D5gbKm6k.mjs} +8 -8
  48. package/dist/.setup/{managed-binary-kiWRhNRE.mjs → managed-binary-C1VFoVPf.mjs} +31 -38
  49. package/dist/.setup/mcp-app-session-preparation-CdqsXwZX.mjs +223 -0
  50. package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
  51. package/dist/.setup/{model-catalog-PAuZgJC6.mjs → model-catalog-Dj_uvusa.mjs} +7 -7
  52. package/dist/.setup/{models-DHXZtVVk.mjs → models-Du_i5G_t.mjs} +10 -7
  53. package/dist/.setup/{native-auth-CuG53tu4.mjs → native-auth-Cjb9y7IZ.mjs} +5 -6
  54. package/dist/.setup/{native-execution-policy-BxZJy5mP.mjs → native-execution-policy-ClzpdG3D.mjs} +1 -12
  55. package/dist/.setup/native-mcp-app-DV7VbfzF.mjs +310 -0
  56. package/dist/.setup/{native-subagent-monitor-Dpsmf2wz.mjs → native-subagent-monitor-CCEFO6qK.mjs} +235 -318
  57. package/dist/.setup/{native-subagent-pending-assignments-DwkCzLvD.mjs → native-subagent-pending-assignments-BDqhOdJp.mjs} +0 -4
  58. package/dist/.setup/{native-task-assignments-DMQ0g3hu.mjs → native-task-assignments-C6KVqiN1.mjs} +9 -8
  59. package/dist/.setup/{node-cli-sessions-HC4W6FLI.mjs → node-cli-sessions-B5oNDkUS.mjs} +11 -17
  60. package/dist/.setup/{node-exec-server.runtime-BgBfWQqo.mjs → node-exec-server.runtime-0xSEjKYt.mjs} +2 -2
  61. package/dist/.setup/{plan-Y-QIvrKB.mjs → plan-CUHSIOep.mjs} +67 -89
  62. package/dist/.setup/{plugin-activation-cNHRfaxU.mjs → plugin-activation-BcyBv8PG.mjs} +4 -4
  63. package/dist/.setup/{plugin-app-cache-key-BL9B5H0L.mjs → plugin-app-cache-key-BW8rd98k.mjs} +11 -15
  64. package/dist/.setup/plugin-approval-roundtrip-uAR-oQfr.mjs +109 -0
  65. package/dist/.setup/{plugin-inventory-Cky2XJUw.mjs → plugin-inventory-Bf0_piTw.mjs} +29 -51
  66. package/dist/.setup/{plugin-marketplace-discovery-D_dV9FXa.mjs → plugin-marketplace-discovery-SQPhSuic.mjs} +2 -16
  67. package/dist/.setup/plugin-metadata-cache-DWnB7VMj.mjs +84 -0
  68. package/dist/.setup/plugin-thread-config-deadline-CdRzGJt4.mjs +124 -0
  69. package/dist/.setup/{provider-DH8NSzGt.mjs → provider-BP8ZaZqn.mjs} +4 -4
  70. package/dist/.setup/provider-capabilities-Z5ZbBxqP.mjs +50 -0
  71. package/dist/.setup/{rate-limits-B7-X2TgG.mjs → rate-limits-CMPy24F5.mjs} +1 -5
  72. package/dist/.setup/{request-BHZ1nz8d.mjs → request-BH3FvYUE.mjs} +189 -49
  73. package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
  74. package/dist/.setup/{run-attempt-D8RZUOzY.mjs → run-attempt-CgvFoW7R.mjs} +553 -727
  75. package/dist/.setup/{run-attempt-lifecycle-C-6O3Exn.mjs → run-attempt-lifecycle-BuZgVbDA.mjs} +19 -3
  76. package/dist/.setup/{runtime-artifact-DDQ-HGXf.mjs → runtime-artifact-CUTOOnKw.mjs} +5 -6
  77. package/dist/.setup/{runtime-artifact-connection-D68qQn1m.mjs → runtime-artifact-connection-CADz3_BY.mjs} +5 -4
  78. package/dist/.setup/{sandbox-guard-DjCz2eOw.mjs → sandbox-guard-WqE8yPge.mjs} +3 -3
  79. package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +15 -0
  80. package/dist/.setup/{session-binding-DGCYAfvD.mjs → session-binding-Ce7BqiPN.mjs} +92 -102
  81. package/dist/.setup/session-binding-meta-Lkm5Lpf4.mjs +15 -0
  82. package/dist/.setup/session-binding-record-BZB8RgcF.mjs +179 -0
  83. package/dist/.setup/session-binding-record-codec-z4ZpDn6E.mjs +216 -0
  84. package/dist/.setup/{session-binding-sidecars-jo6H8dFr.mjs → session-binding-sidecars-BrdV95Fg.mjs} +8 -2
  85. package/dist/.setup/{session-catalog-adoption-BU_pHWG7.mjs → session-catalog-adoption-CPIP4S_y.mjs} +34 -18
  86. package/dist/.setup/{session-catalog-archive-spHfihri.mjs → session-catalog-archive-DcgwvSbF.mjs} +24 -29
  87. package/dist/.setup/{session-catalog-events-DePDzzjc.mjs → session-catalog-events-KIXOoSnQ.mjs} +5 -5
  88. package/dist/.setup/{session-catalog-index-CZvDzC6z.mjs → session-catalog-index-DPICGlxr.mjs} +361 -72
  89. package/dist/.setup/{session-catalog-index-order-BcQpHks3.mjs → session-catalog-index-order-nhyO0wdW.mjs} +1 -1
  90. package/dist/.setup/{session-catalog-limits-DDxOsQeC.mjs → session-catalog-limits-DEU36Qlo.mjs} +1 -1
  91. package/dist/.setup/{session-catalog-index-state-TeO7EyO-.mjs → session-catalog-list-request-tXephOB4.mjs} +180 -6
  92. package/dist/.setup/{session-catalog-native-projection-DjhwGL6x.mjs → session-catalog-native-projection-CTBd4EUm.mjs} +7 -6
  93. package/dist/.setup/{session-catalog-node-adoption-DgXvSGu0.mjs → session-catalog-node-adoption-7-WEQTB1.mjs} +12 -2
  94. package/dist/.setup/{session-catalog-node-continue-DjKXHBbi.mjs → session-catalog-node-continue-DLWBwAAO.mjs} +11 -15
  95. package/dist/.setup/{session-catalog-node-lookup-CtAXI5W5.mjs → session-catalog-node-lookup-Uufckwcm.mjs} +2 -2
  96. package/dist/.setup/{session-catalog-parsing-CPGaPYr-.mjs → session-catalog-parsing-B-qWJh2x.mjs} +70 -28
  97. package/dist/.setup/{session-catalog-projection-Cr5qP5Dj.mjs → session-catalog-projection-CE0_Hffi.mjs} +6 -122
  98. package/dist/.setup/{session-catalog-provenance-DoAvktcj.mjs → session-catalog-provenance-CmsOE5mh.mjs} +6 -1
  99. package/dist/.setup/{session-cli-Cn_nCqfq.mjs → session-cli-kH4vuGod.mjs} +1 -2
  100. package/dist/.setup/{session-history-D83lJWHG.mjs → session-history-BogBHKLk.mjs} +1 -1
  101. package/dist/.setup/{session-history-import-WhX-X33a.mjs → session-history-import-NWKPa4ZO.mjs} +4 -4
  102. package/dist/.setup/{session-history-read-Ov3StuL4.mjs → session-history-read-CNN8zwbD.mjs} +8 -19
  103. package/dist/.setup/{session-history.worker-MnPKncqP.mjs → session-history.worker-Cq_4DYgN.mjs} +3 -3
  104. package/dist/.setup/{session-initialization-6aveB9qb.mjs → session-initialization-D6dtFQkE.mjs} +2 -2
  105. package/dist/.setup/{session-permission-policy-Ci_fVX6y.mjs → session-permission-policy-BxIUJ0Zd.mjs} +8 -37
  106. package/dist/.setup/{session-retirement-qMTxkNx2.mjs → session-retirement-aC60o6P3.mjs} +14 -15
  107. package/dist/.setup/{settled-turn-context-D4yj4rxf.mjs → settled-turn-context-BZsMjkIO.mjs} +13 -6
  108. package/dist/.setup/{settled-turn-finalizer-BsvEabkw.mjs → settled-turn-finalizer-CDxCejjC.mjs} +8 -8
  109. package/dist/.setup/{shared-client-DqyTMYug.mjs → shared-client-DJJ3ljH2.mjs} +291 -272
  110. package/dist/.setup/{provider-capabilities-CAxoF-X1.mjs → shell-dynamic-tools-Do9lIAT1.mjs} +16 -55
  111. package/dist/.setup/{side-question-C4kCmQy1.mjs → side-question-B7T0_GEC.mjs} +99 -91
  112. package/dist/.setup/{source-CS_7GFJZ.mjs → source-DH70LqN0.mjs} +24 -40
  113. package/dist/.setup/{thread-lifecycle-DPflntEJ.mjs → thread-lifecycle-DkcoX9q-.mjs} +262 -305
  114. package/dist/.setup/{thread-ownership-roNP0l1c.mjs → thread-ownership-0aRHD9iK.mjs} +10 -8
  115. package/dist/.setup/{thread-policy-DTd-DtkX.mjs → thread-policy-CXZV97TS.mjs} +22 -21
  116. package/dist/.setup/{thread-requests-B_bRnMGN.mjs → thread-requests-COrRJcZb.mjs} +107 -98
  117. package/dist/.setup/{thread-resume-CdDaoc7T.mjs → thread-resume-rx7J68Rx.mjs} +10 -18
  118. package/dist/.setup/{transcript-history-projection-DRSifI-1.mjs → transcript-history-projection-B9a7HwUV.mjs} +11 -16
  119. package/dist/.setup/{transcript-mirror-kxmCYsuF.mjs → transcript-mirror-BfLRARNL.mjs} +64 -67
  120. package/dist/.setup/{transport-stdio-Bdegpn2V.mjs → transport-stdio-a0HDa2Mj.mjs} +27 -8
  121. package/dist/.setup/{transport-websocket-BTBE-LD9.mjs → transport-websocket-zqJ0Cmtn.mjs} +3 -8
  122. package/dist/.setup/{attempt-client-cleanup-DOP-cW5j.mjs → turn-router-CX1-EoCp.mjs} +75 -170
  123. package/dist/.setup/{upstream-session-fork-CBeVjBpT.mjs → upstream-session-fork-LYlaQnbt.mjs} +35 -46
  124. package/dist/.setup/{usage-BMzNxeR_.mjs → usage-Dmx7B0W2.mjs} +4 -4
  125. package/dist/.setup/{usage-limit-error-QXerDo3i.mjs → usage-limit-error-M8jVnITZ.mjs} +4 -4
  126. package/dist/.setup/{web-search-provider.runtime-P77OUeoo.mjs → web-search-provider.runtime-CsVmqbFm.mjs} +4 -20
  127. package/dist/.setup/websocket-data-XlRvt8Ys.mjs +6 -0
  128. package/dist/.setup/workspace-write-sandbox-probe-DmUHLrrl.mjs +118 -0
  129. package/dist/api.js +34 -54
  130. package/dist/catalog-page.worker.js +1 -1
  131. package/dist/cli-metadata.js +1 -1
  132. package/dist/doctor-contract-api.js +15 -27
  133. package/dist/harness.js +37 -22
  134. package/dist/index.js +2880 -276
  135. package/dist/media-understanding-provider.js +2 -2
  136. package/dist/migration-provider-api.js +1 -1
  137. package/dist/native-session-binding-api.js +2 -0
  138. package/dist/provider-discovery.js +1 -1
  139. package/dist/session-history-worker-runtime.js +33 -4
  140. package/dist/session-history.worker.js +1 -1
  141. package/openclaw.plugin.json +3 -3
  142. package/package.json +6 -6
  143. package/dist/.setup/config-utils-D0CXecki.mjs +0 -57
  144. package/dist/.setup/incognito-session-DWYapfwf.mjs +0 -2
  145. package/dist/.setup/managed-thread-store-BMqgThVL.mjs +0 -100
  146. package/dist/.setup/rpc-error-BlD2vuzn.mjs +0 -31
  147. package/dist/.setup/session-binding-meta-B7aEMU7g.mjs +0 -6
  148. package/dist/.setup/session-binding-record-Oe9L-CNY.mjs +0 -375
  149. package/dist/.setup/session-catalog-4sCdv5qx.mjs +0 -2610
  150. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
  151. package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +0 -153
@@ -1,41 +1,43 @@
1
1
  import { i as isJsonObject, r as flattenCodexDynamicToolFunctions } from "./protocol-CANUwXJ3.mjs";
2
- import { a as matchesPendingSupervisionBranch, n as assertCodexBindingMayBeReplaced, v as sessionBindingIdentity } from "./session-binding-record-Oe9L-CNY.mjs";
3
- import { u as stringifyCodexPolicy } from "./config-security-CE-FcGw9.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";
4
5
  import { n as resolveCodexAppServerLocalHomeDir, t as resolveCodexAppServerHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
5
- import { d as readCodexEffectiveConfig, n as codexSandboxPolicyForTurn, s as assertCodexModelBackedReviewerEffectiveConfig, u as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES } from "./config-options-CzyWLTJt.mjs";
6
- import { i as markStartedCodexManagedThread } from "./managed-thread-store-BMqgThVL.mjs";
7
- import { l as retainSharedCodexAppServerClientByInstanceId, n as getCurrentSharedClientEntry } from "./shared-client-lifecycle-DJIgqgMw.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-CEd9QlIs.mjs";
8
8
  import { t as withCodexAppServerThreadMutation } from "./thread-ownership-queue-Dp24d7-F.mjs";
9
- import { t as isIncognitoSessionKey } from "./incognito-session-DWYapfwf.mjs";
10
- import { n as CodexAppServerRpcError, r as isCodexThreadReadMissingError } from "./rpc-error-BlD2vuzn.mjs";
9
+ import { o as isCodexAppServerOverloadError, r as CodexAppServerRpcError, s as isCodexThreadReadMissingError } from "./rpc-error-hmWM21RB.mjs";
11
10
  import { t as codexCatalogHomeId } from "./session-catalog-home-id-vlih0B_g.mjs";
12
11
  import { r as withAbortableTimeout } from "./timeout-CXOfNoaX.mjs";
13
- import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-DRSifI-1.mjs";
14
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-BL9B5H0L.mjs";
15
- import { n as readCodexSessionMeta } from "./session-catalog-provenance-DoAvktcj.mjs";
16
- import { t as assertCodexSessionRuntimeOwnership } from "./binding-connection-DTtN1KrX.mjs";
17
- import "./config-DKhXquav.mjs";
18
- import { i as sanitizeInlineImageDataUrl, r as invalidInlineImageText } from "./session-history-read-Ov3StuL4.mjs";
19
- import { c as resolveCodexContextEngineProjectionMaxChars, o as neutralizeCodexExplicitMentionSigils } from "./context-engine-projection-PezSESth.mjs";
20
- import { n as normalizeCodexAppServerBindingModelProvider } from "./auth-profile-B0okYl2D.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-DqyTMYug.mjs";
22
- import { C as assertExactSupervisionModelSelection, D as readSupervisionResponseThreadId, O as resolveCodexThreadRolloutPath, d as isCodexAppServerRequestTimeoutError, l as isCodexAppServerOverloadError, p as resolveCodexAppServerClientInstanceId, r as getCodexAppServerClientInstanceId, v as assertCodexThreadAcceptsDirectInput, x as assertCodexThreadStartResponse, y as assertCodexThreadForkResponse } from "./client-N0JpgSzF.mjs";
23
- import { c as isCodexAppServerUnsafeSubscriptionError, g as hasCodexAppServerSiblingRouteWork, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, o as closeCodexStartupClientBestEffort, p as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError, u as retireUnsafeCodexTurnClientBestEffort } from "./attempt-client-cleanup-DOP-cW5j.mjs";
24
- import { $ as readActiveCodexTurnIdsFromResume, B as loadCodexNativeToolCatalog, C as mergeCodexNativeProjectDocThreadConfig, E as assertCodexNativeHookRelayAllowed, F as attestCodexThreadToolSurface, G as areUserMcpServersFingerprintsCompatible, H as applyCodexNativeSkillIsolation, I as checkCodexThreadAppAvailability, J as fingerprintCodexThreadConfig, K as codexDynamicToolsFingerprint, L as discardUnattestedCodexPluginThread, Q as legacyFingerprintUserMcpServersConfigPatch, R as attestCodexRestrictedToolSurfaceMcpServersDisabled, St as mergeCodexThreadConfigs, T as CodexManagedHooksOnlyError, Tt as buildCodexAppApprovalOverrides, U as resolveCodexNativeSkillIsolation, W as areCodexDynamicToolFingerprintsCompatible, X as fingerprintJsonObject, Y as fingerprintEnvironmentSelection, Z as fingerprintUserMcpServersConfigPatch, _ as resolveCodexAppServerModelProvider, at as shouldRotateCodexGpt56MultiAgentBinding, bt as disableUnlistedCodexApps, c as codexThreadSandboxOrPermissions, d as resolveCodexThreadApprovalsReviewer, et as shouldStartTransientNoToolThread, g as CODEX_NATIVE_PERSONALITY_NONE, h as buildDeveloperInstructions, i as buildCodexRuntimeThreadConfigForRun, it as shouldRotateCodexAppServerBindingForRuntime, l as readCodexInheritedMcpServerNames, lt as isMessageOnlyCodexSourceReply, m as mergeCodexNativeShellEnvironment, mt as buildCodexPluginAppsConfigPatchFromPolicyContext, n as buildCodexRingZeroThreadConfigPatch, nt as isTransientWebSearchRestriction, o as buildThreadResumeParams, p as resolveCodexWebSearchPlan, q as codexLegacyDynamicToolsFingerprint, rt as shouldRecheckRecoverablePluginBinding, s as buildThreadStartParams, t as assertCodexManagedRequirementsDoNotOverrideToolPolicy, u as readCodexManagedRequirementsFingerprint, ut as isSystemAgentOnlyCodexDynamicToolAllowlist, v as resolveCodexAppServerRequestModelSelection, x as joinPresentSections, xt as isCodexPluginThreadBindingStale, y as resolveCodexAppServerThreadModelSelection, yt as buildPluginAppPolicyContext, z as hasCodexNativeToolCatalog } from "./thread-requests-B_bRnMGN.mjs";
25
- import { o as resolveCodexSessionBinding, r as hashCodexAppServerBindingFingerprint } from "./session-binding-DGCYAfvD.mjs";
26
- import { a as refreshCodexThreadPolicy, i as assertCodexSupervisionThreadLineage, n as CodexThreadPolicyHandoffError, o as refreshCodexThreadSkillsCatalog, r as assertAdoptedCodexThreadResumeAllowed, t as CodexIncognitoPolicyChangeError } from "./thread-policy-DTd-DtkX.mjs";
27
- import { t as resumeCodexAppServerThread } from "./thread-resume-CdDaoc7T.mjs";
28
- import { c as withExclusiveCodexAppServerThread, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-roNP0l1c.mjs";
29
- import "./transcript-mirror-kxmCYsuF.mjs";
12
+ import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-B9a7HwUV.mjs";
13
+ import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-BW8rd98k.mjs";
14
+ 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";
19
+ 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-DJJ3ljH2.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-CBzEVDyb.mjs";
22
+ import { r as hasCodexAppServerSiblingRouteWork } from "./turn-router-CX1-EoCp.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-yLjGwbwT.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-COrRJcZb.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-CXZV97TS.mjs";
28
+ import { t as resumeCodexAppServerThread } from "./thread-resume-rx7J68Rx.mjs";
29
+ import { c as withExclusiveCodexAppServerThread, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-0aRHD9iK.mjs";
30
30
  import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
31
31
  import crypto from "node:crypto";
32
32
  import { isDeepStrictEqual } from "node:util";
33
33
  import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
34
34
  import path from "node:path";
35
+ import { isIncognitoSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
35
36
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
36
37
  import { createStageTimingTracker, formatStageTimings } from "openclaw/plugin-sdk/time-runtime";
37
- import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
38
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";
39
41
  import { selectSupportedReasoningEffort } from "openclaw/plugin-sdk/agent-harness-attempt-runtime";
40
42
  import { buildCodexUserMcpServersThreadConfigPatchForRun } from "openclaw/plugin-sdk/codex-mcp-projection";
41
43
  import { isDiagnosticFlagEnabled } from "openclaw/plugin-sdk/diagnostic-flags";
@@ -115,10 +117,15 @@ function resolveCodexNativeModelInputTools(config) {
115
117
  const multiAgent = isJsonObject(features?.multi_agent_v2) ? features.multi_agent_v2 : void 0;
116
118
  const namespace = typeof multiAgent?.tool_namespace === "string" ? multiAgent.tool_namespace.trim() : "collaboration";
117
119
  return [
120
+ "spawn_agent",
118
121
  "multi_agent_v1send_input",
119
122
  "send_message",
120
123
  "followup_task",
121
- ...namespace ? [`${namespace}send_message`, `${namespace}followup_task`] : []
124
+ ...namespace ? [
125
+ `${namespace}spawn_agent`,
126
+ `${namespace}send_message`,
127
+ `${namespace}followup_task`
128
+ ] : []
122
129
  ];
123
130
  }
124
131
  //#endregion
@@ -128,20 +135,6 @@ function isCodexAppServerProfilerEnabled(config, env = process.env) {
128
135
  return PROFILER_FLAGS.some((flag) => isDiagnosticFlagEnabled(flag, config, env));
129
136
  }
130
137
  //#endregion
131
- //#region extensions/codex/src/app-server/mcp-tool-metadata.ts
132
- /** Hosted app ownership is authoritative only on metadata supplied by Codex. */
133
- function readCodexMcpToolConnectorId(tool) {
134
- const metadata = asOptionalRecord(asOptionalRecord(tool)?.["_meta"]);
135
- return normalizeOptionalString(metadata?.connector_id) ?? normalizeOptionalString(metadata?.connectorId);
136
- }
137
- /** Preserve MCP App visibility so model-only tools cannot become widget authority. */
138
- function readCodexMcpToolUiVisibility(tool) {
139
- const metadata = asOptionalRecord(asOptionalRecord(tool)?.["_meta"]);
140
- const visibility = asOptionalRecord(metadata?.ui)?.visibility;
141
- if (!Array.isArray(visibility)) return;
142
- return [...new Set(visibility.filter((value) => value === "app" || value === "model"))].toSorted();
143
- }
144
- //#endregion
145
138
  //#region extensions/codex/src/app-server/scheduled-app-tool-policy.ts
146
139
  function normalizeAppToolApprovalMode(value) {
147
140
  return value === "auto" || value === "prompt" || value === "writes" || value === "approve" ? value : void 0;
@@ -461,17 +454,16 @@ function intersectCodexPluginThreadConfigWithScheduledAuthority(config, authorit
461
454
  }];
462
455
  }));
463
456
  }
464
- const fingerprint = crypto.createHash("sha256").update(stringifyCodexPolicy({
465
- version: 1,
466
- namespace: CODEX_SCHEDULED_APP_AUTHORITY_NAMESPACE,
467
- authority: scheduled,
468
- inputFingerprint: config.inputFingerprint,
469
- policyContext,
470
- configPatch
471
- })).digest("hex");
472
457
  return {
473
458
  ...config,
474
- fingerprint,
459
+ fingerprint: fingerprintCodexPolicy({
460
+ version: 1,
461
+ namespace: CODEX_SCHEDULED_APP_AUTHORITY_NAMESPACE,
462
+ authority: scheduled,
463
+ inputFingerprint: config.inputFingerprint,
464
+ policyContext,
465
+ configPatch
466
+ }),
475
467
  configPatch,
476
468
  provisionalAppIds: Object.keys(apps).toSorted(),
477
469
  policyContext
@@ -501,12 +493,12 @@ function buildLegacyScheduledCodexAppRecoveryPrompt(params) {
501
493
  function buildScheduledCodexAppAuthorityInputFingerprint(baseFingerprint, authority) {
502
494
  const scheduled = parseScheduledCodexAppAuthority(authority);
503
495
  if (!scheduled) return baseFingerprint;
504
- return crypto.createHash("sha256").update(stringifyCodexPolicy({
496
+ return fingerprintCodexPolicy({
505
497
  version: 1,
506
498
  namespace: CODEX_SCHEDULED_APP_AUTHORITY_NAMESPACE,
507
499
  baseFingerprint,
508
500
  authority: scheduled
509
- })).digest("hex");
501
+ });
510
502
  }
511
503
  //#endregion
512
504
  //#region extensions/codex/src/app-server/thread-lifecycle-timing.ts
@@ -620,14 +612,17 @@ async function prepareCodexThreadRequestContext(params, options) {
620
612
  throwIfAborted: options.throwIfAborted
621
613
  };
622
614
  }
623
- function publishCodexThreadInferenceBinding(params, binding, reusedConfiguration = false) {
624
- params.assertCurrent?.();
625
- params.signal?.throwIfAborted();
626
- assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, params.config, binding.modelProvider, params.inferenceProviderRoutes);
627
- if (reusedConfiguration) {
628
- if (getCodexInferenceThread(params.client, binding.threadId) !== params.inferenceRoute) throw new Error("Codex inference thread configuration changed before reuse");
629
- } else bindCodexInferenceThread(params.client, binding.threadId, params.inferenceRoute, params.inferenceProviderRoutes);
630
- return binding;
615
+ async function publishCodexThreadInferenceBinding(params, binding, reusedConfiguration = false) {
616
+ const publish = () => {
617
+ params.assertCurrent?.();
618
+ params.signal?.throwIfAborted();
619
+ assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, params.config, binding.modelProvider, params.inferenceProviderRoutes);
620
+ if (reusedConfiguration) {
621
+ if (getCodexInferenceThread(params.client, binding.threadId) !== params.inferenceRoute) throw new Error("Codex inference thread configuration changed before reuse");
622
+ } else bindCodexInferenceThread(params.client, binding.threadId, params.inferenceRoute, params.inferenceProviderRoutes);
623
+ return binding;
624
+ };
625
+ return params.authority ? await params.authority.withCurrent(publish) : publish();
631
626
  }
632
627
  function resolveCodexThreadAgentDir(params) {
633
628
  const agentId = resolveSessionAgentIdsStrict({
@@ -635,7 +630,7 @@ function resolveCodexThreadAgentDir(params) {
635
630
  sessionKey: params.params.sessionKey,
636
631
  agentId: params.agentId ?? params.params.agentId
637
632
  }).sessionAgentId;
638
- return params.agentDir ?? params.params.agentDir ?? resolveAgentDir$1(params.params.config ?? {}, agentId);
633
+ return params.agentDir ?? params.params.agentDir ?? resolveAgentDir$2(params.params.config ?? {}, agentId);
639
634
  }
640
635
  function buildCodexThreadBindingPolicy(params, preflight) {
641
636
  return {
@@ -723,8 +718,8 @@ async function prepareCodexThreadLifecyclePreflight(params) {
723
718
  const hostSystemAgentActive = params.hostSystemAgentActive ?? isHostScopedAgentToolActive("openclaw");
724
719
  const ringZeroActive = hostSystemAgentActive && isSystemAgentOnlyCodexDynamicToolAllowlist(params.params.toolsAllow);
725
720
  const messageOnlySourceReply = isMessageOnlyCodexSourceReply(params.params);
726
- const restrictedToolSurface = ringZeroActive || messageOnlySourceReply || params.params.pluginHarnessToolPolicyRestricted === true;
727
- const allowConfiguredManagedHooks = params.params.pluginHarnessToolPolicyRestricted === true && !ringZeroActive && !messageOnlySourceReply && params.params.scheduledRuntimeAuthority === void 0;
721
+ const restrictedToolSurface = ringZeroActive || messageOnlySourceReply || params.params.requireWorkspaceOnly === true || params.params.pluginHarnessToolPolicyRestricted === true;
722
+ const allowConfiguredManagedHooks = params.params.pluginHarnessToolPolicyRestricted === true && params.params.requireWorkspaceOnly !== true && !ringZeroActive && !messageOnlySourceReply && params.params.scheduledRuntimeAuthority === void 0;
728
723
  const imageGenerationDenied = params.params.pluginHarnessToolPolicySafeDeniedTools?.includes("image_generate") === true;
729
724
  if (restrictedToolSurface && params.nativeCodeModeEnabled !== false) throw new Error("Codex restricted tool surfaces require native code mode to be disabled");
730
725
  if (!effectiveConfig) effectiveConfig = await lifecycleTiming.measure("effective-config-read", () => readCodexEffectiveConfig(params.client, params.cwd, { signal: params.signal }));
@@ -735,7 +730,7 @@ async function prepareCodexThreadLifecyclePreflight(params) {
735
730
  restrictedToolSurface,
736
731
  requiredNativeShell: params.nativeCodeModeEnabled !== false,
737
732
  additionalDeniedFeatures: imageGenerationDenied ? ["image_generation"] : void 0,
738
- allowedManagedRequirementsFingerprint: readScheduledCodexAppManagedRequirementsFingerprint(params.params.scheduledRuntimeAuthority),
733
+ allowedManagedRequirementsFingerprint: params.params.requireWorkspaceOnly === true ? void 0 : readScheduledCodexAppManagedRequirementsFingerprint(params.params.scheduledRuntimeAuthority),
739
734
  allowConfiguredManagedHooks
740
735
  }, params.signal));
741
736
  const features = effectiveConfig?.config.features;
@@ -772,8 +767,28 @@ async function prepareCodexThreadLifecyclePreflight(params) {
772
767
  }
773
768
  //#endregion
774
769
  //#region extensions/codex/src/app-server/thread-lifecycle-io.ts
770
+ function recordCodexThreadReady(params, context, threadId, action) {
771
+ const { contextEngineBinding, lifecycleTiming } = context;
772
+ const event = {
773
+ sessionId: params.params.sessionId,
774
+ sessionKey: params.params.sessionKey,
775
+ threadId,
776
+ action
777
+ };
778
+ if (contextEngineBinding) embeddedAgentLog.info("codex app-server wrote context-engine thread binding", {
779
+ ...event,
780
+ engineId: contextEngineBinding.engineId,
781
+ epoch: contextEngineBinding.projection?.epoch,
782
+ fingerprint: contextEngineBinding.projection?.fingerprint
783
+ });
784
+ lifecycleTiming.mark("thread-ready");
785
+ lifecycleTiming.logSummary({
786
+ runId: params.params.runId,
787
+ ...event
788
+ });
789
+ }
775
790
  async function resumeExistingCodexThread(params, context) {
776
- const { binding: resumeBinding, bindingIdentity, startModelSelection, startModelProvider, userMcpServersConfigPatch, dynamicToolsFingerprint, webSearchThreadConfigFingerprint, ringZeroConfigFingerprint, ringZeroClientInstanceId, contextEngineBinding, hostSystemAgentActive, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, nativeSkillIsolation, lifecycleTiming, normalizeBindingModelProvider, throwIfAborted, clearCurrentBinding } = context;
791
+ const { binding: resumeBinding, bindingIdentity, startModelSelection, startModelProvider, userMcpServersConfigPatch, dynamicToolsFingerprint, webSearchThreadConfigFingerprint, ringZeroConfigFingerprint, ringZeroClientInstanceId, hostSystemAgentActive, restrictedToolSurface, restrictedToolSurfaceInheritedMcpServerNames, nativeSkillIsolation, lifecycleTiming, normalizeBindingModelProvider, throwIfAborted, stageBindingReplacement } = context;
777
792
  let acceptedConfiguration;
778
793
  let disposeConfiguration;
779
794
  let resumeReservation;
@@ -815,6 +830,7 @@ async function resumeExistingCodexThread(params, context) {
815
830
  abandonClient,
816
831
  request: resumeParams,
817
832
  signal: params.signal,
833
+ withCurrent: params.authority?.withCurrent,
818
834
  assertCurrent: () => {
819
835
  configuration.assertCurrent();
820
836
  assertCodexInferenceRouteConfig(params.client, params.inferenceRoute, resumeParams.config, requestModelProvider ?? (resumeBinding.preserveNativeModel ? configuration.modelProvider ?? void 0 : void 0), params.inferenceProviderRoutes);
@@ -838,7 +854,8 @@ async function resumeExistingCodexThread(params, context) {
838
854
  threadConfig: resumeParams.config,
839
855
  restrictedToolSurface,
840
856
  lifecycleTiming,
841
- assertCurrent: assertHandoffCurrent
857
+ assertCurrent: assertHandoffCurrent,
858
+ withCurrent: params.authority?.withCurrent
842
859
  });
843
860
  throwIfAborted();
844
861
  await refreshCodexThreadPolicy({
@@ -847,7 +864,8 @@ async function resumeExistingCodexThread(params, context) {
847
864
  developerInstructions: resumeParams.developerInstructions,
848
865
  timeoutMs: params.appServer.requestTimeoutMs,
849
866
  signal: params.signal,
850
- assertCurrent: assertHandoffCurrent
867
+ assertCurrent: assertHandoffCurrent,
868
+ withCurrent: params.authority?.withCurrent
851
869
  });
852
870
  policyOutcome = "acknowledged";
853
871
  assertHandoffCurrent();
@@ -877,25 +895,9 @@ async function resumeExistingCodexThread(params, context) {
877
895
  kind: "patch",
878
896
  threadId: resumeBinding.threadId,
879
897
  patch: resumePatch
880
- }, assertHandoffCurrent))) throw new CodexThreadBindingConflictError(resumeBinding.threadId, "committing a resumed thread");
898
+ }, assertHandoffCurrent, params.authority))) throw new CodexThreadBindingConflictError(resumeBinding.threadId, "committing a resumed thread");
881
899
  assertHandoffCurrent();
882
- if (contextEngineBinding) embeddedAgentLog.info("codex app-server wrote context-engine thread binding", {
883
- sessionId: params.params.sessionId,
884
- sessionKey: params.params.sessionKey,
885
- threadId: response.thread.id,
886
- engineId: contextEngineBinding.engineId,
887
- epoch: contextEngineBinding.projection?.epoch,
888
- fingerprint: contextEngineBinding.projection?.fingerprint,
889
- action: "resumed"
890
- });
891
- lifecycleTiming.mark("thread-ready");
892
- lifecycleTiming.logSummary({
893
- runId: params.params.runId,
894
- sessionId: params.params.sessionId,
895
- sessionKey: params.params.sessionKey,
896
- threadId: response.thread.id,
897
- action: "resumed"
898
- });
900
+ recordCodexThreadReady(params, context, response.thread.id, "resumed");
899
901
  const activeTurnIds = readActiveCodexTurnIdsFromResume(response);
900
902
  return {
901
903
  ...resumeBinding,
@@ -921,7 +923,8 @@ async function resumeExistingCodexThread(params, context) {
921
923
  const subscriptionReleased = await unsubscribeCodexThreadBestEffort(params.client, {
922
924
  threadId: resumeBinding.threadId,
923
925
  timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS,
924
- assertCurrent: acceptedConfiguration.assertCurrent
926
+ assertCurrent: acceptedConfiguration.assertCurrent,
927
+ withCurrent: params.authority?.withCurrent
925
928
  }).catch(() => false);
926
929
  if (!subscriptionReleased || handoffError instanceof CodexThreadPolicyHandoffError && handoffError.outcome === "unknown") {
927
930
  if (resumeBinding.connectionScope === "supervision") await retireUnsafeCodexTurnClientBestEffort(params.client, "session policy handoff");
@@ -936,7 +939,7 @@ async function resumeExistingCodexThread(params, context) {
936
939
  }
937
940
  if (resumeBinding.pendingResumeConfiguration || resumeBinding.preserveNativeModel || resumeBinding.connectionScope === "supervision" || params.signal?.aborted) throw error;
938
941
  embeddedAgentLog.warn("codex app-server thread resume failed; starting a new thread", { error });
939
- await clearCurrentBinding("rotating a stale thread binding");
942
+ stageBindingReplacement("rotating a stale thread binding");
940
943
  } finally {
941
944
  disposeConfiguration?.();
942
945
  }
@@ -970,7 +973,8 @@ async function startFreshCodexThread(params, context) {
970
973
  assertCurrent();
971
974
  return await params.client.request("thread/start", startParams, {
972
975
  signal: params.signal,
973
- assertCurrent: assertInferenceCurrent
976
+ assertCurrent: assertInferenceCurrent,
977
+ withCurrent: params.authority?.withCurrent
974
978
  });
975
979
  } catch (error) {
976
980
  if (error instanceof CodexAppServerRpcError) throw new CodexThreadStartRequestError(error);
@@ -999,7 +1003,8 @@ async function startFreshCodexThread(params, context) {
999
1003
  threadConfig: startParams.config,
1000
1004
  restrictedToolSurface,
1001
1005
  lifecycleTiming,
1002
- assertCurrent
1006
+ assertCurrent,
1007
+ withCurrent: params.authority?.withCurrent
1003
1008
  });
1004
1009
  assertCurrent();
1005
1010
  } catch (error) {
@@ -1044,7 +1049,7 @@ async function startFreshCodexThread(params, context) {
1044
1049
  const managedSourceHomeId = codexCatalogHomeId(resolveCodexAppServerLocalHomeDir(params.appServer.start, resolveCodexThreadAgentDir(params)));
1045
1050
  let committed;
1046
1051
  try {
1047
- await lifecycleTiming.measure("thread-start-mark-managed", () => markStartedCodexManagedThread(params.bindingStore.managedThreads, {
1052
+ await lifecycleTiming.measure("thread-start-mark-managed", () => params.bindingStore.managedThreads?.mark({
1048
1053
  sourceHomeId: managedSourceHomeId,
1049
1054
  threadId: response.thread.id,
1050
1055
  ...rolloutPath ? { rolloutPath } : {}
@@ -1057,29 +1062,16 @@ async function startFreshCodexThread(params, context) {
1057
1062
  kind: "set",
1058
1063
  if: { kind: "absent" },
1059
1064
  binding: nextBinding
1060
- }, assertCurrent));
1065
+ }, assertCurrent, params.authority));
1061
1066
  } catch (error) {
1062
1067
  return await rejectUncommittedThread(error);
1063
1068
  }
1064
1069
  if (!committed) return await rejectUncommittedThread(new CodexThreadBindingConflictError(replacementPredecessor?.threadId ?? response.thread.id, "committing a fresh thread"));
1065
- if (contextEngineBinding) embeddedAgentLog.info("codex app-server wrote context-engine thread binding", {
1066
- sessionId: params.params.sessionId,
1067
- sessionKey: params.params.sessionKey,
1068
- threadId: response.thread.id,
1069
- engineId: contextEngineBinding.engineId,
1070
- epoch: contextEngineBinding.projection?.epoch,
1071
- fingerprint: contextEngineBinding.projection?.fingerprint,
1072
- action: rotatedContextEngineBinding ? "rotated" : "started"
1073
- });
1074
1070
  }
1075
- lifecycleTiming.mark("thread-ready");
1076
- lifecycleTiming.logSummary({
1077
- runId: params.params.runId,
1078
- sessionId: params.params.sessionId,
1079
- sessionKey: params.params.sessionKey,
1080
- threadId: response.thread.id,
1081
- action: rotatedContextEngineBinding ? "rotated" : "started"
1082
- });
1071
+ recordCodexThreadReady(params, {
1072
+ lifecycleTiming,
1073
+ contextEngineBinding: preserveExistingBinding ? void 0 : contextEngineBinding
1074
+ }, response.thread.id, rotatedContextEngineBinding ? "rotated" : "started");
1083
1075
  return {
1084
1076
  ...startedBinding,
1085
1077
  modelProvider: response.modelProvider ?? requestModelProvider ?? startModelProvider ?? modelProvider,
@@ -1114,9 +1106,10 @@ async function releaseCodexConsumedLiveThread(options) {
1114
1106
  if (await options.lifecycleTiming.measure("retained-thread-unsubscribe", () => unsubscribeCodexThreadBestEffort(options.client, {
1115
1107
  threadId: options.threadId,
1116
1108
  timeoutMs: 5e3,
1117
- assertCurrent: options.assertCurrent
1109
+ assertCurrent: options.assertCurrent,
1110
+ withCurrent: options.withCurrent
1118
1111
  }))) return;
1119
- return await abandonCodexLiveThreadRelease(options, options.cause);
1112
+ return await abandonCodexLiveThreadRelease(options);
1120
1113
  }
1121
1114
  async function abandonCodexLiveThreadRelease(options, cause) {
1122
1115
  options.assertCurrent?.();
@@ -1126,9 +1119,9 @@ async function abandonCodexLiveThreadRelease(options, cause) {
1126
1119
  /** Releases through the retained owner, preserving its guarded callback and rollback. */
1127
1120
  async function releaseCodexRetainedLiveThread(options) {
1128
1121
  try {
1129
- return await options.lifecycleTiming.measure("retained-thread-unsubscribe", () => releaseCodexAppServerLiveThread(options.client, options.threadId, options.assertCurrent));
1122
+ return await options.lifecycleTiming.measure("retained-thread-unsubscribe", () => releaseCodexAppServerLiveThread(options.client, options.threadId, options.assertCurrent, options.withCurrent));
1130
1123
  } catch (error) {
1131
- if (isCodexAppServerUnsafeSubscriptionError(error)) throw error;
1124
+ if (error instanceof CodexAppServerUnsafeSubscriptionError) throw error;
1132
1125
  return await abandonCodexLiveThreadRelease(options, error);
1133
1126
  }
1134
1127
  }
@@ -1248,25 +1241,32 @@ async function tryReuseCodexLiveThread(options) {
1248
1241
  prebuiltFinalConfigPatch
1249
1242
  };
1250
1243
  }
1251
- await attestCodexThreadToolSurface({
1252
- client: params.client,
1253
- threadId: binding.threadId,
1254
- appIds: pluginThreadConfig?.provisionalAppIds ?? [],
1255
- signal: params.signal,
1256
- threadConfig: resumeParams.config,
1257
- restrictedToolSurface,
1258
- lifecycleTiming,
1259
- assertCurrent: assertWarmOwner
1260
- });
1244
+ try {
1245
+ await attestCodexThreadToolSurface({
1246
+ client: params.client,
1247
+ threadId: binding.threadId,
1248
+ appIds: pluginThreadConfig?.provisionalAppIds ?? [],
1249
+ signal: params.signal,
1250
+ threadConfig: resumeParams.config,
1251
+ restrictedToolSurface,
1252
+ lifecycleTiming,
1253
+ assertCurrent: assertWarmOwner,
1254
+ withCurrent: params.authority?.withCurrent
1255
+ });
1256
+ } catch (error) {
1257
+ assertWarmOwner();
1258
+ throw error;
1259
+ }
1261
1260
  assertWarmOwner();
1262
- if (ephemeralPolicy && ephemeralPolicy.skillsInstructions !== params.skillsInstructions) try {
1263
- await refreshCodexThreadSkillsCatalog({
1261
+ if (ephemeralPolicy && ephemeralPolicy.refreshableInstructions !== params.refreshableInstructions) try {
1262
+ await refreshCodexThreadInstructions({
1264
1263
  client: params.client,
1265
1264
  threadId: binding.threadId,
1266
- skillsInstructions: params.skillsInstructions,
1265
+ refreshableInstructions: params.refreshableInstructions,
1267
1266
  timeoutMs: params.appServer.requestTimeoutMs,
1268
1267
  signal: params.signal,
1269
- assertCurrent: assertWarmOwner
1268
+ assertCurrent: assertWarmOwner,
1269
+ withCurrent: params.authority?.withCurrent
1270
1270
  });
1271
1271
  } catch (error) {
1272
1272
  preserveSubscription = true;
@@ -1275,17 +1275,18 @@ async function tryReuseCodexLiveThread(options) {
1275
1275
  const nativeHookRelayGeneration = prebuiltFinalConfigPatch.nativeHookRelayGeneration ?? binding.nativeHookRelayGeneration;
1276
1276
  const model = binding.preserveNativeModel ? nativeThread?.model?.trim() || binding.model : startModelSelection.model;
1277
1277
  const modelProvider = binding.preserveNativeModel ? nativeThread?.modelProvider?.trim() || binding.modelProvider : binding.modelProvider;
1278
+ const bindingPatch = {
1279
+ cwd: params.cwd,
1280
+ model,
1281
+ modelProvider,
1282
+ nativeHookRelayGeneration,
1283
+ environmentSelectionFingerprint
1284
+ };
1278
1285
  if (!(incognito || await lifecycleTiming.measure("warm-thread-write-binding", () => params.bindingStore.mutate(bindingIdentity, {
1279
1286
  kind: "patch",
1280
1287
  threadId: binding.threadId,
1281
- patch: {
1282
- cwd: params.cwd,
1283
- model,
1284
- modelProvider,
1285
- nativeHookRelayGeneration,
1286
- environmentSelectionFingerprint
1287
- }
1288
- }, assertWarmOwner)))) throw new CodexThreadBindingConflictError(binding.threadId, "committing a reused thread");
1288
+ patch: bindingPatch
1289
+ }, assertWarmOwner, params.authority)))) throw new CodexThreadBindingConflictError(binding.threadId, "committing a reused thread");
1289
1290
  assertWarmOwner();
1290
1291
  lifecycleTiming.mark("thread-ready");
1291
1292
  lifecycleTiming.logSummary({
@@ -1300,17 +1301,11 @@ async function tryReuseCodexLiveThread(options) {
1300
1301
  kind: "ready",
1301
1302
  binding: {
1302
1303
  ...binding,
1303
- ...!incognito ? {
1304
- cwd: params.cwd,
1305
- model,
1306
- modelProvider,
1307
- nativeHookRelayGeneration,
1308
- environmentSelectionFingerprint
1309
- } : {},
1304
+ ...!incognito ? bindingPatch : {},
1310
1305
  liveThreadConfigFingerprint,
1311
1306
  liveThreadEphemeralPolicy: ephemeralPolicy && {
1312
1307
  ...ephemeralPolicy,
1313
- skillsInstructions: params.skillsInstructions
1308
+ refreshableInstructions: params.refreshableInstructions
1314
1309
  },
1315
1310
  liveThreadOwnership: retainedThread,
1316
1311
  ...!incognito && retainedThread.serviceTier && resumeParams.serviceTier === void 0 ? { clearInheritedServiceTier: true } : {},
@@ -1321,14 +1316,19 @@ async function tryReuseCodexLiveThread(options) {
1321
1316
  if (!ownershipTransferred) {
1322
1317
  let failure;
1323
1318
  try {
1324
- if (preserveSubscription) try {
1325
- assertWarmOwner();
1326
- preserveSubscription = isSameCodexAppServerThreadOwner(params.bindingStore.read(bindingIdentity), binding);
1327
- } catch {
1328
- preserveSubscription = false;
1329
- }
1319
+ let pendingRetention;
1330
1320
  if (preserveSubscription) {
1331
- if (!await retainCodexAppServerBindingSubscription(params.client, binding.threadId, retainedThread)) failure = { cause: /* @__PURE__ */ new Error("Codex live thread ownership could not be returned to its session") };
1321
+ const retain = () => {
1322
+ assertWarmOwner();
1323
+ if (isSameCodexAppServerThreadOwner(params.bindingStore.read(bindingIdentity), binding)) pendingRetention = retainCodexAppServerBindingSubscription(params.client, binding.threadId, retainedThread);
1324
+ };
1325
+ try {
1326
+ if (params.authority) await params.authority.withCurrent(retain);
1327
+ else retain();
1328
+ } catch {}
1329
+ }
1330
+ if (pendingRetention) {
1331
+ if (!await pendingRetention) failure = { cause: /* @__PURE__ */ new Error("Codex live thread ownership could not be returned to its session") };
1332
1332
  } else await retainedThread.release(binding.threadId);
1333
1333
  } catch (cause) {
1334
1334
  failure = { cause };
@@ -1352,8 +1352,9 @@ async function withCodexThreadLifecycleBinding(params, run) {
1352
1352
  agentId: params.agentId ?? params.params.agentId,
1353
1353
  config: params.params.config
1354
1354
  });
1355
- const { binding: snapshot, assertCurrent } = await resolveCodexSessionBinding({
1355
+ const { binding: snapshot, authority } = await resolveCodexSessionBinding({
1356
1356
  reclaimStale: true,
1357
+ authority: params.authority,
1357
1358
  bindingStore: params.bindingStore,
1358
1359
  identity,
1359
1360
  config: params.params.config,
@@ -1365,12 +1366,16 @@ async function withCodexThreadLifecycleBinding(params, run) {
1365
1366
  signal: params.signal,
1366
1367
  assertBinding: params.params.expectedSessionRuntimeOwnership ? (binding) => assertCodexSessionRuntimeOwnership(binding, params.params.expectedSessionRuntimeOwnership) : void 0
1367
1368
  });
1369
+ const assertCurrent = authority.assertCurrent;
1368
1370
  const runWithLease = () => params.bindingStore.withLease(identity, async () => {
1369
1371
  const binding = params.bindingStore.read(identity);
1370
1372
  assertCodexSessionRuntimeOwnership(binding, params.params.expectedSessionRuntimeOwnership);
1371
1373
  if (binding?.threadId !== snapshot?.threadId || binding?.clientId !== snapshot?.clientId) throw new CodexThreadBindingConflictError(binding?.threadId ?? snapshot?.threadId ?? params.params.sessionId, "acquiring thread lifecycle ownership");
1372
1374
  assertCurrent();
1373
- return await run(identity, binding, assertCurrent);
1375
+ return await run(identity, binding, authority);
1376
+ }, {
1377
+ assertCurrent,
1378
+ authority
1374
1379
  });
1375
1380
  return snapshot?.pendingResumeConfiguration ? await withExclusiveCodexAppServerThread({
1376
1381
  bindingStore: params.bindingStore,
@@ -1400,7 +1405,8 @@ async function resumePendingCodexThread(params, context) {
1400
1405
  abandonClient: params.abandonClient,
1401
1406
  lifecycleTiming,
1402
1407
  threadId: binding.threadId,
1403
- assertCurrent
1408
+ assertCurrent,
1409
+ withCurrent: params.authority?.withCurrent
1404
1410
  });
1405
1411
  }
1406
1412
  });
@@ -1414,21 +1420,15 @@ async function preparePendingCodexThreadResume(params, binding, dynamicToolsFing
1414
1420
  const localHome = resolveCodexAppServerLocalHomeDir(params.appServer.start, agentDir);
1415
1421
  if (params.appServer.start.transport !== "stdio" || params.appServer.start.homeScope === "user" || path.resolve(localHome) !== resolveCodexAppServerHomeDir(agentDir) || binding.connectionScope === "supervision" || binding.preserveNativeModel === true) throw fail("configuration adoption requires an OpenClaw-owned local Codex home");
1416
1422
  if (isCodexAppServerLiveThreadClaimed(params.client, binding.threadId)) throw fail("the thread is claimed by active work; stop that run before resuming");
1417
- const assertClient = captureCodexAppServerClientLifetime(params.client, "native-process");
1418
- const assertCurrent = () => {
1419
- params.params.hostCapabilities.assertActive();
1420
- params.assertCurrent?.();
1421
- params.signal?.throwIfAborted();
1422
- assertClient();
1423
- if (isCodexAppServerLiveThreadClaimed(params.client, binding.threadId)) throw new CodexAdoptedThreadActiveError();
1424
- };
1423
+ const assertCurrent = captureCodexThreadResumeAuthority(params, binding, "native-process");
1425
1424
  assertCurrent();
1426
1425
  const { thread } = await params.client.request("thread/read", {
1427
1426
  threadId: binding.threadId,
1428
1427
  includeTurns: false
1429
1428
  }, {
1430
1429
  signal: params.signal,
1431
- assertCurrent
1430
+ assertCurrent,
1431
+ withCurrent: params.authority?.withCurrent
1432
1432
  });
1433
1433
  assertCurrent();
1434
1434
  if (thread.id !== binding.threadId || !isCodexThreadNonRunning(thread.status)) throw fail("the native thread is not idle; wait for its current run to finish");
@@ -1453,14 +1453,7 @@ async function preparePendingCodexThreadResume(params, binding, dynamicToolsFing
1453
1453
  }
1454
1454
  /** Observe teardown before release; a successful resume alone can acknowledge ignored overrides. */
1455
1455
  async function prepareCodexThreadResume(params, binding, context) {
1456
- const assertClient = captureCodexAppServerClientLifetime(params.client, binding.connectionScope === "supervision" ? "connection" : "thread-configuration");
1457
- const assertCurrent = () => {
1458
- params.params.hostCapabilities.assertActive();
1459
- params.assertCurrent?.();
1460
- params.signal?.throwIfAborted();
1461
- assertClient();
1462
- if (isCodexAppServerLiveThreadClaimed(params.client, binding.threadId)) throw new CodexAdoptedThreadActiveError();
1463
- };
1456
+ const assertCurrent = captureCodexThreadResumeAuthority(params, binding, binding.connectionScope === "supervision" ? "connection" : "thread-configuration");
1464
1457
  assertCurrent();
1465
1458
  let thread;
1466
1459
  try {
@@ -1474,6 +1467,16 @@ async function prepareCodexThreadResume(params, binding, context) {
1474
1467
  assertCurrent
1475
1468
  };
1476
1469
  }
1470
+ function captureCodexThreadResumeAuthority(params, binding, scope) {
1471
+ const assertClient = captureCodexAppServerClientLifetime(params.client, scope);
1472
+ return () => {
1473
+ params.params.hostCapabilities.assertActive();
1474
+ params.assertCurrent?.();
1475
+ params.signal?.throwIfAborted();
1476
+ assertClient();
1477
+ if (isCodexAppServerLiveThreadClaimed(params.client, binding.threadId)) throw new CodexAdoptedThreadActiveError();
1478
+ };
1479
+ }
1477
1480
  function isCodexThreadNonRunning(status) {
1478
1481
  return status?.type === "idle" || status?.type === "notLoaded" || status?.type === "systemError";
1479
1482
  }
@@ -1495,12 +1498,46 @@ function observeCodexThreadConfiguration(params, thread, assertCurrent) {
1495
1498
  };
1496
1499
  }
1497
1500
  //#endregion
1501
+ //#region extensions/codex/src/app-server/thread-supervision-cleanup.ts
1502
+ function withPendingSupervisionCleanup(pending, cleanupThreadIds) {
1503
+ return {
1504
+ sourceThreadId: pending.sourceThreadId,
1505
+ ...pending.connectionFingerprint ? { connectionFingerprint: pending.connectionFingerprint } : {},
1506
+ ...pending.lastTurnId ? { lastTurnId: pending.lastTurnId } : {},
1507
+ ...cleanupThreadIds.length > 0 ? { cleanupThreadIds } : {}
1508
+ };
1509
+ }
1510
+ async function cleanPendingSupervisionArtifacts(client, pending) {
1511
+ const remaining = [];
1512
+ for (const threadId of pending.cleanupThreadIds ?? []) if (!await archiveSupervisionArtifact(client, threadId)) remaining.push(threadId);
1513
+ return { remaining };
1514
+ }
1515
+ async function archiveSupervisionArtifact(client, threadId) {
1516
+ try {
1517
+ await client.request("thread/archive", { threadId }, { timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS });
1518
+ return true;
1519
+ } catch (error) {
1520
+ const message = formatErrorMessage(error).toLowerCase();
1521
+ if (message.includes("no rollout found for thread id") || message.includes("thread not found") || message.includes("already archived")) return true;
1522
+ await unsubscribeCodexThreadBestEffort(client, {
1523
+ threadId,
1524
+ timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS
1525
+ });
1526
+ embeddedAgentLog.warn("failed to archive temporary Codex supervision thread", {
1527
+ threadId,
1528
+ error
1529
+ });
1530
+ return false;
1531
+ }
1532
+ }
1533
+ //#endregion
1498
1534
  //#region extensions/codex/src/app-server/thread-supervision.ts
1499
1535
  async function materializePendingSupervisionBranch(params) {
1500
1536
  let pending = params.binding.pendingSupervisionBranch;
1501
1537
  const requestOptions = {
1502
1538
  signal: params.signal,
1503
- assertCurrent: params.throwIfAborted
1539
+ assertCurrent: params.throwIfAborted,
1540
+ withCurrent: params.authority?.withCurrent
1504
1541
  };
1505
1542
  const connectionFingerprint = buildCodexAppServerConnectionFingerprint(params.appServer, params.attempt.agentDir);
1506
1543
  if (!pending.connectionFingerprint || pending.connectionFingerprint !== connectionFingerprint) throw new Error("Codex supervision source connection changed before branch materialization");
@@ -1656,7 +1693,7 @@ async function materializePendingSupervisionBranch(params) {
1656
1693
  modelProvider: bindingModelProvider,
1657
1694
  historyCoveredThrough
1658
1695
  }
1659
- }, params.throwIfAborted);
1696
+ }, params.throwIfAborted, params.authority);
1660
1697
  } catch (error) {
1661
1698
  let current;
1662
1699
  try {
@@ -1719,7 +1756,7 @@ async function materializePendingSupervisionBranch(params) {
1719
1756
  } catch (stateError) {
1720
1757
  cleanupStateError = stateError;
1721
1758
  }
1722
- const unsafeCleanup = cleanup.remaining.length > 0 || isCodexAppServerUnsafeSubscriptionError(error);
1759
+ const unsafeCleanup = cleanup.remaining.length > 0 || error instanceof CodexAppServerUnsafeSubscriptionError;
1723
1760
  if (unsafeCleanup) await params.abandonClient();
1724
1761
  if (cleanupStateError) {
1725
1762
  const cause = new AggregateError([error, cleanupStateError], "Codex supervised branch cleanup state could not be recorded", { cause: error });
@@ -1781,63 +1818,28 @@ async function recoverPendingSupervisionArtifacts(params, pending) {
1781
1818
  if (!pending.cleanupThreadIds?.length) return pending;
1782
1819
  const cleanup = await cleanPendingSupervisionArtifacts(params.client, pending);
1783
1820
  const next = withPendingSupervisionCleanup(pending, cleanup.remaining);
1784
- if (cleanup.remaining.length > 0) {
1785
- if (cleanup.remaining.length !== pending.cleanupThreadIds.length) {
1786
- if (!await params.bindingStore.mutate(params.bindingIdentity, {
1787
- kind: "patch-pending-supervision-branch",
1788
- expected: pending,
1789
- pending: next
1790
- })) throw new CodexThreadBindingConflictError(pending.sourceThreadId, "recording supervised Codex cleanup recovery");
1791
- }
1792
- throw new Error(`Codex supervised branch cleanup must finish before retry: ${cleanup.remaining.join(", ")}`);
1821
+ const incomplete = cleanup.remaining.length > 0;
1822
+ if (!incomplete || cleanup.remaining.length !== pending.cleanupThreadIds.length) {
1823
+ if (!await params.bindingStore.mutate(params.bindingIdentity, {
1824
+ kind: "patch-pending-supervision-branch",
1825
+ expected: pending,
1826
+ pending: next
1827
+ })) throw new CodexThreadBindingConflictError(pending.sourceThreadId, incomplete ? "recording supervised Codex cleanup recovery" : "recovering a supervised Codex branch");
1793
1828
  }
1794
- if (!await params.bindingStore.mutate(params.bindingIdentity, {
1795
- kind: "patch-pending-supervision-branch",
1796
- expected: pending,
1797
- pending: next
1798
- })) throw new CodexThreadBindingConflictError(pending.sourceThreadId, "recovering a supervised Codex branch");
1829
+ if (incomplete) throw new Error(`Codex supervised branch cleanup must finish before retry: ${cleanup.remaining.join(", ")}`);
1799
1830
  return next;
1800
1831
  }
1801
- function withPendingSupervisionCleanup(pending, cleanupThreadIds) {
1802
- return {
1803
- sourceThreadId: pending.sourceThreadId,
1804
- ...pending.connectionFingerprint ? { connectionFingerprint: pending.connectionFingerprint } : {},
1805
- ...pending.lastTurnId ? { lastTurnId: pending.lastTurnId } : {},
1806
- ...cleanupThreadIds.length > 0 ? { cleanupThreadIds } : {}
1807
- };
1808
- }
1809
- async function cleanPendingSupervisionArtifacts(client, pending) {
1810
- const remaining = [];
1811
- for (const threadId of pending.cleanupThreadIds ?? []) if (!await archiveSupervisionArtifact(client, threadId)) remaining.push(threadId);
1812
- return { remaining };
1813
- }
1814
- async function archiveSupervisionArtifact(client, threadId) {
1815
- try {
1816
- await client.request("thread/archive", { threadId }, { timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS });
1817
- return true;
1818
- } catch (error) {
1819
- const message = formatErrorMessage(error).toLowerCase();
1820
- if (message.includes("no rollout found for thread id") || message.includes("thread not found") || message.includes("already archived")) return true;
1821
- await unsubscribeCodexThreadBestEffort(client, {
1822
- threadId,
1823
- timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS
1824
- });
1825
- embeddedAgentLog.warn("failed to archive temporary Codex supervision thread", {
1826
- threadId,
1827
- error
1828
- });
1829
- return false;
1830
- }
1831
- }
1832
1832
  //#endregion
1833
1833
  //#region extensions/codex/src/app-server/thread-lifecycle-run.ts
1834
1834
  async function startOrResumeThread(input) {
1835
1835
  const incognito = isIncognitoSessionKey(input.params.sessionKey);
1836
1836
  const clientId = resolveCodexAppServerClientInstanceId(input.client);
1837
- return await withCodexThreadLifecycleBinding(input, async (bindingIdentity, saved, assert) => {
1837
+ return await withCodexThreadLifecycleBinding(input, async (bindingIdentity, saved, authority) => {
1838
+ const assert = authority.assertCurrent;
1838
1839
  const params = {
1839
1840
  ...input,
1840
- assertCurrent: assert
1841
+ assertCurrent: assert,
1842
+ authority
1841
1843
  };
1842
1844
  const expectedOwnership = params.params.expectedSessionRuntimeOwnership;
1843
1845
  let binding = saved;
@@ -1848,6 +1850,7 @@ async function startOrResumeThread(input) {
1848
1850
  binding,
1849
1851
  appServer: params.appServer,
1850
1852
  agentDir: resolveCodexThreadAgentDir(params),
1853
+ authority,
1851
1854
  assertCurrent: () => {
1852
1855
  params.signal?.throwIfAborted();
1853
1856
  assert();
@@ -1873,7 +1876,7 @@ async function startOrResumeThread(input) {
1873
1876
  assertCurrent: assert,
1874
1877
  throwIfAborted
1875
1878
  });
1876
- params.skillsInstructions = params.inferenceRoute ? void 0 : input.skillsInstructions;
1879
+ params.refreshableInstructions = params.inferenceRoute ? void 0 : input.refreshableInstructions;
1877
1880
  return context;
1878
1881
  };
1879
1882
  const releaseRetainedThread = (threadId, ownerClientId = initialBoundClientId, assertCurrent) => releaseCodexBoundLiveThread({
@@ -1883,7 +1886,8 @@ async function startOrResumeThread(input) {
1883
1886
  abandonClient: params.abandonClient,
1884
1887
  lifecycleTiming,
1885
1888
  threadId,
1886
- assertCurrent
1889
+ assertCurrent,
1890
+ withCurrent: authority.withCurrent
1887
1891
  });
1888
1892
  if (binding?.pendingSupervisionBranch) {
1889
1893
  const requestContext = await prepareRequestContext();
@@ -1897,13 +1901,14 @@ async function startOrResumeThread(input) {
1897
1901
  abandonClient: params.abandonClient ?? (() => closeCodexStartupClientBestEffort(params.client)),
1898
1902
  bindingStore: params.bindingStore,
1899
1903
  bindingIdentity,
1904
+ authority,
1900
1905
  binding: pendingBinding,
1901
1906
  attempt: params.params,
1902
1907
  cwd: params.cwd,
1903
1908
  dynamicTools: params.dynamicTools,
1904
1909
  appServer: params.appServer,
1905
1910
  developerInstructions: params.developerInstructions,
1906
- skillsInstructions: params.skillsInstructions,
1911
+ refreshableInstructions: params.refreshableInstructions,
1907
1912
  config,
1908
1913
  nativeCodeModeEnabled: params.nativeCodeModeEnabled,
1909
1914
  nativeProviderWebSearchSupport: params.nativeProviderWebSearchSupport,
@@ -1942,16 +1947,21 @@ async function startOrResumeThread(input) {
1942
1947
  }
1943
1948
  }));
1944
1949
  }
1945
- const clearCurrentBinding = async (operation) => {
1950
+ const stageBindingReplacement = (operation) => {
1946
1951
  const current = binding;
1947
1952
  if (!current?.threadId) return;
1948
1953
  assertCodexBindingMayBeReplaced(current, operation, expectedOwnership);
1949
- if (!await params.bindingStore.mutate(bindingIdentity, {
1950
- kind: "clear",
1951
- threadId: current.threadId
1952
- }, assert)) throw new CodexThreadBindingConflictError(current.threadId, operation);
1954
+ assert();
1955
+ replacementPredecessor = current;
1953
1956
  binding = void 0;
1954
1957
  };
1958
+ const rotateStaleBinding = (current, changed, details) => {
1959
+ embeddedAgentLog.debug(`codex app-server ${changed} changed; starting a new thread`, {
1960
+ threadId: current.threadId,
1961
+ ...details
1962
+ });
1963
+ stageBindingReplacement("rotating a stale thread binding");
1964
+ };
1955
1965
  const transientDelegationRestriction = params.params.delegationCapability === "report_only";
1956
1966
  const persistentWebSearchRestriction = params.webSearchAllowed === false && params.persistentWebSearchAllowed === false;
1957
1967
  const transientNativeToolRestriction = params.nativeCodeModeEnabled === false && !persistentWebSearchRestriction;
@@ -1959,30 +1969,24 @@ async function startOrResumeThread(input) {
1959
1969
  if (binding?.pendingResumeConfiguration) return publishCodexThreadInferenceBinding(params, await resumePendingCodexThread(params, {
1960
1970
  ...await prepareRequestContext(),
1961
1971
  binding,
1962
- clearCurrentBinding,
1972
+ stageBindingReplacement,
1963
1973
  releaseRetainedThread: (threadId, assertCurrent) => releaseRetainedThread(threadId, initialBoundClientId, assertCurrent),
1964
1974
  transientRestriction: transientDelegationRestriction || transientNativeToolRestriction || transientWebSearchRestriction
1965
1975
  }));
1966
- if (binding?.threadId && !restrictedToolSurface && binding.nativeToolPolicyRestricted === true) await clearCurrentBinding("rotating a host-policy-restricted thread binding");
1976
+ if (binding?.threadId && !restrictedToolSurface && binding.nativeToolPolicyRestricted === true) stageBindingReplacement("rotating a host-policy-restricted thread binding");
1967
1977
  if (binding?.threadId && binding.nativeSkillIsolationFingerprint !== nativeSkillIsolationFingerprint) {
1968
1978
  embeddedAgentLog.debug("codex app-server native skill isolation changed; starting a new thread", { threadId: binding.threadId });
1969
- await clearCurrentBinding("rotating stale native skill isolation");
1979
+ stageBindingReplacement("rotating stale native skill isolation");
1970
1980
  }
1971
1981
  if (binding?.threadId && (binding.ringZeroConfigFingerprint !== ringZeroConfigFingerprint || binding.ringZeroClientInstanceId !== ringZeroClientInstanceId) && (ringZeroActive || binding.ringZeroConfigFingerprint !== void 0)) {
1972
1982
  embeddedAgentLog.debug("codex app-server ring-zero restriction changed; rotating thread", { threadId: binding.threadId });
1973
- await clearCurrentBinding("rotating a ring-zero thread binding");
1983
+ stageBindingReplacement("rotating a ring-zero thread binding");
1974
1984
  }
1975
1985
  if (binding?.threadId && shouldRotateCodexAppServerBindingForRuntime({
1976
1986
  connectionClass: params.appServer.connectionClass,
1977
1987
  current: binding.connectionScope === "supervision" ? buildCodexAppServerConnectionFingerprint(params.appServer, params.params.agentDir) : params.appServerRuntimeFingerprint,
1978
1988
  binding: binding.appServerRuntimeFingerprint
1979
- })) {
1980
- embeddedAgentLog.debug("codex app-server runtime identity changed; starting a new thread", {
1981
- threadId: binding.threadId,
1982
- connectionClass: params.appServer.connectionClass
1983
- });
1984
- await clearCurrentBinding("rotating a stale thread binding");
1985
- }
1989
+ })) rotateStaleBinding(binding, "runtime identity", { connectionClass: params.appServer.connectionClass });
1986
1990
  if (binding?.threadId && shouldRotateCodexGpt56MultiAgentBinding({
1987
1991
  bindingModel: binding.model,
1988
1992
  requestedModel: params.params.modelId
@@ -1992,7 +1996,7 @@ async function startOrResumeThread(input) {
1992
1996
  bindingModel: binding.model,
1993
1997
  requestedModel: params.params.modelId
1994
1998
  });
1995
- await clearCurrentBinding("rotating a GPT-5.6 multi-agent thread binding");
1999
+ stageBindingReplacement("rotating a GPT-5.6 multi-agent thread binding");
1996
2000
  }
1997
2001
  selectionBinding = binding;
1998
2002
  let preserveExistingBinding = transientDelegationRestriction || !ringZeroActive && params.nativeProviderWebSearchSupport === "unknown" && !binding?.threadId;
@@ -2020,12 +2024,11 @@ async function startOrResumeThread(input) {
2020
2024
  const webSearchBindingChanged = binding?.threadId && binding.webSearchThreadConfigFingerprint !== webSearchThreadConfigFingerprint;
2021
2025
  const explicitTransientWebSearchRestriction = params.webSearchAllowed === false && params.persistentWebSearchAllowed !== false && transientWebSearchRestriction;
2022
2026
  const unknownProviderWebSearchSupport = params.nativeProviderWebSearchSupport === "unknown";
2023
- if (binding?.threadId && (params.configuredMcpOwnershipVersion === 1 && (binding.configuredMcpOwnershipVersion !== 1 || binding.dynamicToolsFingerprint === void 0 || binding.mcpServersFingerprint !== void 0 || binding.userMcpServersFingerprint !== void 0) || params.configuredMcpOwnershipVersion !== 1 && binding.configuredMcpOwnershipVersion === 1) && binding?.threadId) {
2027
+ const configuredMcpOwnershipChanged = binding?.threadId && (params.configuredMcpOwnershipVersion === 1 && (binding.configuredMcpOwnershipVersion !== 1 || binding.dynamicToolsFingerprint === void 0 || binding.mcpServersFingerprint !== void 0 || binding.userMcpServersFingerprint !== void 0) || params.configuredMcpOwnershipVersion !== 1 && binding.configuredMcpOwnershipVersion === 1);
2028
+ if (configuredMcpOwnershipChanged && binding?.threadId) {
2024
2029
  const predecessorBinding = binding;
2025
- assertCodexBindingMayBeReplaced(predecessorBinding, "changing configured MCP ownership", expectedOwnership);
2030
+ stageBindingReplacement("changing configured MCP ownership");
2026
2031
  embeddedAgentLog.debug("codex app-server configured MCP ownership changed; starting a new thread", { threadId: predecessorBinding.threadId });
2027
- replacementPredecessor = predecessorBinding;
2028
- binding = void 0;
2029
2032
  preserveExistingBinding = false;
2030
2033
  }
2031
2034
  if (binding?.threadId && params.mcpServersFingerprintEvaluated === true && binding.mcpServersFingerprint !== params.mcpServersFingerprint) {
@@ -2033,10 +2036,7 @@ async function startOrResumeThread(input) {
2033
2036
  if (!ringZeroActive && (transientNativeToolRestriction || webSearchBindingChanged && (explicitTransientWebSearchRestriction || unknownProviderWebSearchSupport))) {
2034
2037
  embeddedAgentLog.debug("codex app-server MCP config changed during transient restricted turn; starting transient thread", { threadId: binding.threadId });
2035
2038
  preserveExistingBinding = true;
2036
- } else {
2037
- embeddedAgentLog.debug("codex app-server MCP config changed; starting a new thread", { threadId: binding.threadId });
2038
- await clearCurrentBinding("rotating a stale thread binding");
2039
- }
2039
+ } else rotateStaleBinding(binding, "MCP config");
2040
2040
  binding = void 0;
2041
2041
  }
2042
2042
  const deferLegacyWebSearchRotationToTransientNativeSurface = params.nativeCodeModeEnabled === false && binding?.webSearchThreadConfigFingerprint === void 0 && !persistentWebSearchRestriction;
@@ -2045,10 +2045,7 @@ async function startOrResumeThread(input) {
2045
2045
  if (!ringZeroActive && transientWebSearchRestriction) {
2046
2046
  embeddedAgentLog.debug("codex app-server tool surface restricted for turn; starting transient thread", { threadId: binding.threadId });
2047
2047
  preserveExistingBinding = true;
2048
- } else {
2049
- embeddedAgentLog.debug("codex app-server web search config changed; starting a new thread", { threadId: binding.threadId });
2050
- await clearCurrentBinding("rotating a stale thread binding");
2051
- }
2048
+ } else rotateStaleBinding(binding, "web search config");
2052
2049
  binding = void 0;
2053
2050
  }
2054
2051
  if (binding?.threadId && transientNativeToolRestriction && !ringZeroActive) {
@@ -2064,8 +2061,7 @@ async function startOrResumeThread(input) {
2064
2061
  }
2065
2062
  if (binding?.threadId && (binding.contextEngine || contextEngineBinding)) {
2066
2063
  if (!contextEngineBinding || !isContextEngineBindingCompatible(binding.contextEngine, contextEngineBinding)) {
2067
- embeddedAgentLog.debug("codex app-server context-engine binding changed; starting a new thread", {
2068
- threadId: binding.threadId,
2064
+ rotateStaleBinding(binding, "context-engine binding", {
2069
2065
  engineId: contextEngineBinding?.engineId,
2070
2066
  previousEngineId: binding.contextEngine?.engineId,
2071
2067
  epoch: contextEngineBinding?.projection?.epoch,
@@ -2075,7 +2071,6 @@ async function startOrResumeThread(input) {
2075
2071
  policyFingerprint: contextEngineBinding?.policyFingerprint,
2076
2072
  previousPolicyFingerprint: binding.contextEngine?.policyFingerprint
2077
2073
  });
2078
- await clearCurrentBinding("rotating a stale thread binding");
2079
2074
  rotatedContextEngineBinding = true;
2080
2075
  }
2081
2076
  }
@@ -2083,14 +2078,8 @@ async function startOrResumeThread(input) {
2083
2078
  previous: binding.userMcpServersFingerprint,
2084
2079
  next: userMcpServersFingerprint,
2085
2080
  nextLegacy: legacyUserMcpServersFingerprint
2086
- })) {
2087
- embeddedAgentLog.debug("codex app-server user MCP config changed; starting a new thread", { threadId: binding.threadId });
2088
- await clearCurrentBinding("rotating a stale thread binding");
2089
- }
2090
- if (binding?.threadId && (binding.networkProxyConfigFingerprint !== networkProxyConfigFingerprint || binding.networkProxyProfileName !== params.appServer.networkProxy?.profileName)) {
2091
- embeddedAgentLog.debug("codex app-server network proxy config changed; starting a new thread", { threadId: binding.threadId });
2092
- await clearCurrentBinding("rotating a stale thread binding");
2093
- }
2081
+ })) rotateStaleBinding(binding, "user MCP config");
2082
+ if (binding?.threadId && (binding.networkProxyConfigFingerprint !== networkProxyConfigFingerprint || binding.networkProxyProfileName !== params.appServer.networkProxy?.profileName)) rotateStaleBinding(binding, "network proxy config");
2094
2083
  if (binding?.threadId) {
2095
2084
  if (isCodexPluginThreadBindingStale({
2096
2085
  codexPluginsEnabled: params.pluginThreadConfig?.enabled ?? false,
@@ -2098,16 +2087,10 @@ async function startOrResumeThread(input) {
2098
2087
  bindingInputFingerprint: binding.pluginAppsInputFingerprint,
2099
2088
  currentInputFingerprint: params.pluginThreadConfig?.inputFingerprint,
2100
2089
  hasBindingPolicyContext: Boolean(binding.pluginAppPolicyContext)
2101
- })) {
2102
- embeddedAgentLog.debug("codex app-server plugin app config changed; starting a new thread", { threadId: binding.threadId });
2103
- await clearCurrentBinding("rotating a stale thread binding");
2104
- }
2090
+ })) rotateStaleBinding(binding, "plugin app config");
2105
2091
  }
2106
2092
  if (binding?.threadId) {
2107
- if (binding.dynamicToolsFingerprint && params.dynamicTools.length > 0 && binding.dynamicToolsContainDeferred !== dynamicToolsContainDeferred && (binding.dynamicToolsContainDeferred !== void 0 || !dynamicToolsContainDeferred)) {
2108
- embeddedAgentLog.debug("codex app-server dynamic tool loading changed; starting a new thread", { threadId: binding.threadId });
2109
- await clearCurrentBinding("rotating a stale thread binding");
2110
- }
2093
+ if (binding.dynamicToolsFingerprint && params.dynamicTools.length > 0 && binding.dynamicToolsContainDeferred !== dynamicToolsContainDeferred && (binding.dynamicToolsContainDeferred !== void 0 || !dynamicToolsContainDeferred)) rotateStaleBinding(binding, "dynamic tool loading");
2111
2094
  }
2112
2095
  if (binding?.threadId) {
2113
2096
  if (binding.dynamicToolsFingerprint && !areCodexDynamicToolFingerprintsCompatible({
@@ -2121,10 +2104,7 @@ async function startOrResumeThread(input) {
2121
2104
  nextHasDynamicTools: params.dynamicTools.length > 0
2122
2105
  });
2123
2106
  if (preserveExistingBinding) embeddedAgentLog.debug("codex app-server dynamic tools unavailable for turn; starting transient thread", { threadId: binding.threadId });
2124
- else {
2125
- embeddedAgentLog.debug("codex app-server dynamic tool catalog changed; starting a new thread", { threadId: binding.threadId });
2126
- await clearCurrentBinding("rotating a stale thread binding");
2127
- }
2107
+ else rotateStaleBinding(binding, "dynamic tool catalog");
2128
2108
  } else {
2129
2109
  const requestContext = await prepareRequestContext();
2130
2110
  const warmReuse = await tryReuseCodexLiveThread({
@@ -2137,13 +2117,13 @@ async function startOrResumeThread(input) {
2137
2117
  if (warmReuse.kind === "ready") return publishCodexThreadInferenceBinding(params, warmReuse.binding, true);
2138
2118
  if (incognito || warmReuse.kind === "rotate") {
2139
2119
  throwIfAborted();
2140
- await clearCurrentBinding(incognito ? "rotating an unavailable ephemeral thread binding" : "rotating a stale plugin app binding");
2120
+ stageBindingReplacement(incognito ? "rotating an unavailable ephemeral thread binding" : "rotating a stale plugin app binding");
2141
2121
  } else {
2142
2122
  const resumeBinding = binding;
2143
2123
  const resumed = await resumeExistingCodexThread(params, {
2144
2124
  ...requestContext,
2145
2125
  binding: resumeBinding,
2146
- clearCurrentBinding,
2126
+ stageBindingReplacement,
2147
2127
  prebuiltFinalConfigPatch: warmReuse.prebuiltFinalConfigPatch,
2148
2128
  prebuiltPluginThreadConfig,
2149
2129
  buildLoadedPluginThreadConfig,
@@ -2158,7 +2138,7 @@ async function startOrResumeThread(input) {
2158
2138
  }
2159
2139
  assertCodexBindingMayBeReplaced(binding, "starting a fresh native thread", expectedOwnership);
2160
2140
  const requestContext = await prepareRequestContext();
2161
- if (initialBoundThreadId && !preserveExistingBinding && !replacementPredecessor) await releaseRetainedThread(initialBoundThreadId);
2141
+ if (initialBoundThreadId && !preserveExistingBinding && !configuredMcpOwnershipChanged) await releaseRetainedThread(initialBoundThreadId);
2162
2142
  const started = await startFreshCodexThread(params, {
2163
2143
  ...requestContext,
2164
2144
  prebuiltPluginThreadConfig,
@@ -2166,7 +2146,7 @@ async function startOrResumeThread(input) {
2166
2146
  rotatedContextEngineBinding,
2167
2147
  replacementPredecessor
2168
2148
  });
2169
- if (replacementPredecessor) await releaseRetainedThread(replacementPredecessor.threadId, replacementPredecessor.clientId);
2149
+ if (replacementPredecessor && !preserveExistingBinding && configuredMcpOwnershipChanged) await releaseRetainedThread(replacementPredecessor.threadId, replacementPredecessor.clientId);
2170
2150
  return publishCodexThreadInferenceBinding(params, started);
2171
2151
  });
2172
2152
  }
@@ -2249,11 +2229,7 @@ function buildTurnStartParams(params, options) {
2249
2229
  agentDir: params.agentDir,
2250
2230
  config: params.config
2251
2231
  });
2252
- const collaborationMode = modelSelection ? buildTurnCollaborationMode(params, {
2253
- model: modelSelection.model,
2254
- turnScopedDeveloperInstructions: options.turnScopedDeveloperInstructions,
2255
- memoryCollaborationInstructions: options.memoryCollaborationInstructions
2256
- }) : void 0;
2232
+ const collaborationMode = modelSelection ? buildTurnCollaborationMode(params, { model: modelSelection.model }) : void 0;
2257
2233
  if (collaborationMode && options.parentLocalEgress) collaborationMode.settings.developer_instructions = null;
2258
2234
  const useThreadPermissionProfile = options.appServer.networkProxy && !options.sandboxPolicy;
2259
2235
  const currentSender = params.trigger === "user" ? readCodexCurrentSender(params) : void 0;
@@ -2299,7 +2275,7 @@ function buildTurnStartParams(params, options) {
2299
2275
  effort: collaborationMode.settings.reasoning_effort,
2300
2276
  collaborationMode
2301
2277
  } : {},
2302
- ...options.environmentSelection ? { environments: options.environmentSelection } : {}
2278
+ ...params.requireWorkspaceOnly === true ? { environments: [] } : options.environmentSelection ? { environments: options.environmentSelection } : {}
2303
2279
  };
2304
2280
  }
2305
2281
  function buildCodexTemporalAdditionalContext(params, options) {
@@ -2322,34 +2298,15 @@ function buildTurnCollaborationMode(params, options = {}) {
2322
2298
  modelId: model,
2323
2299
  supportedReasoningEfforts: readCodexSupportedReasoningEfforts(params.model?.compat)
2324
2300
  }),
2325
- developer_instructions: buildTurnScopedCollaborationInstructions(params, options)
2301
+ developer_instructions: params.trigger === "cron" ? buildCronCollaborationInstructions() : null
2326
2302
  }
2327
2303
  };
2328
2304
  }
2329
2305
  function buildCodexParentLocalInstructions(params, options = {}) {
2330
- const contextInstructions = joinPresentSections(options.turnScopedDeveloperInstructions, options.skillsInstructions, options.memoryCollaborationInstructions);
2306
+ const contextInstructions = joinPresentSections(options.personaInstructions, options.skillsInstructions, options.memoryInstructions);
2331
2307
  if (params.trigger === "cron") return joinPresentSections(buildCronCollaborationInstructions(), contextInstructions);
2332
2308
  return contextInstructions || null;
2333
2309
  }
2334
- function buildTurnScopedCollaborationInstructions(params, options) {
2335
- const instructions = buildCodexParentLocalInstructions(params, options);
2336
- return instructions && params.trigger !== "cron" ? joinPresentSections(buildDefaultCollaborationInstructions(), instructions) : instructions;
2337
- }
2338
- function buildDefaultCollaborationInstructions() {
2339
- return [
2340
- "# Collaboration Mode: Default",
2341
- "",
2342
- "You are now in Default mode. Any previous instructions for other modes (e.g. Plan mode) are no longer active.",
2343
- "",
2344
- "Your active mode changes only when new developer instructions with a different `<collaboration_mode>...</collaboration_mode>` change it; user requests or tool descriptions do not change mode by themselves. Known mode names are Default and Plan.",
2345
- "",
2346
- "## request_user_input availability",
2347
- "",
2348
- "Use the `request_user_input` tool only when it is listed in the available tools for this turn.",
2349
- "",
2350
- "In Default mode, strongly prefer making reasonable assumptions and executing the user's request rather than stopping to ask questions. When a missing preference, constraint, or clarification warrants a question, use `request_user_input_async` if it is available and continue independent work. Answers arrive as ordinary user messages. A suggested or preselected answer is not consent; wait for explicit approval before dependent actions that require it. If neither question tool is available, ask a concise plain-text question. Never write a multiple choice question as a textual assistant message."
2351
- ].join("\n");
2352
- }
2353
2310
  function buildCronCollaborationInstructions() {
2354
2311
  return [
2355
2312
  "This is an OpenClaw cron automation turn. Apply these instructions only to this scheduled job; ordinary chat turns should stay in Codex Default mode.",
@@ -2359,4 +2316,4 @@ function buildCronCollaborationInstructions() {
2359
2316
  ].join("\n\n");
2360
2317
  }
2361
2318
  //#endregion
2362
- export { resolveCodexAppServerReasoningEffort as S, readCodexMcpToolUiVisibility as _, buildTurnStartParams as a, isContextEngineBindingCompatible as b, assertScheduledCodexAppAuthorityRuntime as c, buildScheduledCodexAppServerConnectionIdentity as d, captureScheduledCodexAppAuthority as f, readCodexMcpToolConnectorId 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, isCodexAppServerProfilerEnabled as v, readCodexSupportedReasoningEfforts as x, buildContextEngineBinding as y };
2319
+ 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 };