@openclaw/codex 2026.10.5-beta.4 → 2026.10.10-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.
- package/README.md +10 -3
- package/dist/.setup/{account-usage-runtime-CoVpNIlD.mjs → account-usage-runtime-DDCDkvtl.mjs} +15 -9
- package/dist/.setup/{app-server-policy-D_zv8J7V.mjs → app-server-policy-Cog6mm2i.mjs} +1 -1
- package/dist/.setup/{apply-BXDMd05l.mjs → apply-BVSXYkTV.mjs} +11 -11
- package/dist/.setup/{attempt-client-cleanup-zNuNTKVr.mjs → attempt-client-cleanup-6OcbMH46.mjs} +14 -8
- package/dist/.setup/attempt-terminal-sZutF0WY.mjs +1 -0
- package/dist/.setup/{attempt-workspace-context-CcwP3DA3.mjs → attempt-workspace-context-GYPLawX6.mjs} +2 -2
- package/dist/.setup/{auth-binding-BaxlhaNx.mjs → auth-binding-830RLAJW.mjs} +2 -2
- package/dist/.setup/{auth-cache-key-f8ODJ_OX.mjs → auth-cache-key-CVcYw8HD.mjs} +92 -80
- package/dist/.setup/{auth-profile-CgHQ8Vot.mjs → auth-profile-auwzSwwy.mjs} +14 -8
- package/dist/.setup/{auth-profile-health-oHizqgye.mjs → auth-profile-health-BVPZU9I8.mjs} +15 -8
- package/dist/.setup/{auth-profile-selection-hr8ocLtz.mjs → auth-profile-selection-Bp5PDk3W.mjs} +24 -7
- package/dist/.setup/{binding-connection-B7HAAZSI.mjs → binding-connection-GTgUj9pi.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-DAXn7iFl.mjs → binding-connection.runtime-RcWR3vQu.mjs} +4 -3
- package/dist/.setup/{bounded-turn-isolation-BfDAo-qZ.mjs → bounded-turn-isolation-D8CDrAVX.mjs} +3 -3
- package/dist/.setup/{bounded-turn-DfIJtRlv.mjs → bounded-turn-mN_ekXYW.mjs} +18 -22
- package/dist/.setup/{build-state-Ds14X10-.mjs → build-state-VcujMRqP.mjs} +1 -1
- package/dist/.setup/{capabilities-DbOzOglY.mjs → capabilities-DAS-JX1z.mjs} +1 -1
- package/dist/.setup/{client-D93nbdB8.mjs → client-BS8X7HmG.mjs} +47 -317
- package/dist/.setup/{client-catalog-response-CuVLp4I0.mjs → client-catalog-response-jM38o5w1.mjs} +2 -2
- package/dist/.setup/client-initialize-CjgZcX61.mjs +165 -0
- package/dist/.setup/{command-dispatch-DxdH5a9-.mjs → command-dispatch-DzXbHqCn.mjs} +3 -3
- package/dist/.setup/{command-formatters-xW9KpoSZ.mjs → command-formatters-B_7-QZ1c.mjs} +2 -2
- package/dist/.setup/{command-handlers-fiYvYYq0.mjs → command-handlers-tfb5Uq-O.mjs} +539 -406
- package/dist/.setup/command-rpc-SXqLQukR.mjs +296 -0
- package/dist/.setup/compact-M-JxLcbZ.mjs +823 -0
- package/dist/.setup/{computer-use-DL2v3Kxq.mjs → computer-use-FqQ-Flbl.mjs} +21 -68
- package/dist/.setup/{config-C1YVVLEA.mjs → config-BfrAlTMT.mjs} +3 -3
- package/dist/.setup/{config-options-DDzeNQ8m.mjs → config-options-DMFZkd3X.mjs} +1 -1
- package/dist/.setup/{config-runtime-DWzK-k0n.mjs → config-runtime-BZRizyuG.mjs} +2 -2
- package/dist/.setup/{context-engine-projection-ps-yn_ci.mjs → context-engine-projection-PIeLSnR-.mjs} +16 -30
- package/dist/.setup/{conversation-binding-BieJZRRV.mjs → conversation-binding-C7MZy-Cx.mjs} +228 -116
- package/dist/.setup/{conversation-binding-data-UgLuTSQT.mjs → conversation-binding-data-khgW0n-o.mjs} +4 -2
- package/dist/.setup/{conversation-control-GXM3unE4.mjs → conversation-control-B2EpVZEb.mjs} +53 -23
- package/dist/.setup/{cyber-failover-D4dgNfFf.mjs → cyber-failover-CqEZoQsj.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-ljgGGL0s.mjs → cyber-failover-notice-poL3Advd.mjs} +1 -1
- package/dist/.setup/{doctor-start-options-JjTAl-q_.mjs → doctor-start-options-8uIBXIzR.mjs} +8 -5
- package/dist/.setup/{dynamic-tool-build-DcaPmBlE.mjs → dynamic-tool-build-BjFAIG-f.mjs} +208 -218
- package/dist/.setup/{dynamic-tools-CnQFnNKH.mjs → dynamic-tools-XqWsVjcC.mjs} +344 -118
- package/dist/.setup/{effective-mcp-catalog-B5HKFZNK.mjs → effective-mcp-catalog-C3ta5hHc.mjs} +11 -9
- package/dist/.setup/{ephemeral-turn-De3qb8EQ.mjs → ephemeral-turn-1ZF17fUR.mjs} +5 -4
- package/dist/.setup/{event-projector-assistant-message-CLMKN4x-.mjs → event-projector-assistant-message-ChOAY7rW.mjs} +16 -11
- package/dist/.setup/{event-projector-usage-BpKfdoTm.mjs → event-projector-usage-CBY0Hkga.mjs} +2 -2
- package/dist/.setup/{event-projector-values-CLvG1Hil.mjs → event-projector-values-yf4us9Pf.mjs} +1 -1
- package/dist/.setup/experimental-features-uGnVDtp-.mjs +19 -0
- package/dist/.setup/inference-context-mv_dBpAL.mjs +209 -0
- package/dist/.setup/{inference-dispatch-CO6tTs4q.mjs → inference-dispatch-C2zVSnrr.mjs} +2 -2
- package/dist/.setup/{inference-metadata-DCvcG_N_.mjs → inference-metadata-CYFWLHVk.mjs} +3 -1
- package/dist/.setup/{inference-proxy-BDWV0djM.mjs → inference-proxy-yd3hr2dr.mjs} +8 -8
- package/dist/.setup/installed-probe-lVC1X5ve.mjs +185 -0
- package/dist/.setup/{isolated-completion-BPJdvk5F.mjs → isolated-completion-P-r8NRE4.mjs} +7 -7
- package/dist/.setup/managed-binary-DbKvGXKl.mjs +395 -0
- package/dist/.setup/{mcp-app-session-preparation-Dz2GOwyE.mjs → mcp-app-session-preparation-fnsnCovu.mjs} +18 -14
- package/dist/.setup/{model-catalog-ZNwltCKl.mjs → model-catalog-Y_esgRPY.mjs} +28 -17
- package/dist/.setup/{models-BHpbAuz8.mjs → models-BWLEUo2E.mjs} +3 -3
- package/dist/.setup/{native-auth-esN5MdIv.mjs → native-auth-DpZIaY8N.mjs} +7 -4
- package/dist/.setup/native-execution-policy-D09tLP-u.mjs +152 -0
- package/dist/.setup/{native-hook-relay-wq7jrNLk.mjs → native-hook-relay-C7aaLJaP.mjs} +45 -10
- package/dist/.setup/{native-mcp-app-DX3nyTtc.mjs → native-mcp-app-CsWj-v_x.mjs} +5 -5
- package/dist/.setup/{native-skill-isolation-DSBeF-Yy.mjs → native-skill-isolation-CMimsKYy.mjs} +7 -7
- package/dist/.setup/{native-subagent-monitor-DOLEIf9r.mjs → native-subagent-monitor-CFE7b4oC.mjs} +485 -239
- package/dist/.setup/{native-subagent-pending-assignments-DmVhedNs.mjs → native-subagent-pending-assignments-CTinVtjo.mjs} +1 -1
- package/dist/.setup/{native-task-assignments-DimsQ9Qa.mjs → native-task-assignments-YJopbaVO.mjs} +9 -5
- package/dist/.setup/{node-cli-sessions-CzKg2nGq.mjs → node-cli-sessions-BuJnBnEq.mjs} +7 -4
- package/dist/.setup/{node-exec-server.runtime-BWkULhBM.mjs → node-exec-server.runtime-CP7RC1Nd.mjs} +3 -3
- package/dist/.setup/{plan-41-YOBMq.mjs → plan-B4cHgqNv.mjs} +7 -20
- package/dist/.setup/{plugin-activation-D7WkJMvU.mjs → plugin-activation-CXPWe-hl.mjs} +4 -4
- package/dist/.setup/{plugin-app-cache-key-Bg9DbDI6.mjs → plugin-app-cache-key-DRb-niJc.mjs} +17 -55
- package/dist/.setup/{plugin-approval-roundtrip-CD88q3yx.mjs → plugin-approval-roundtrip-DIZHLbAM.mjs} +1 -1
- package/dist/.setup/{plugin-inventory-CYgdo14P.mjs → plugin-inventory-DE9wcaeH.mjs} +2 -2
- package/dist/.setup/{plugin-metadata-cache-Bi8TAPwX.mjs → plugin-metadata-cache-BqC-a6Fb.mjs} +2 -15
- package/dist/.setup/{project-doc-thread-config-BVcvnps8.mjs → project-doc-thread-config-B0UI3f1D.mjs} +6 -6
- package/dist/.setup/protocol-CaPAVwe9.mjs +12 -0
- package/dist/.setup/{provider-capabilities-Dn2WwH4P.mjs → provider-capabilities-DjcKunHS.mjs} +1 -1
- package/dist/.setup/{provider-LWKll6dV.mjs → provider-wj_LFJH3.mjs} +4 -4
- package/dist/.setup/{rate-limits-CI8pTPqL.mjs → rate-limits-BpfURnuy.mjs} +1 -1
- package/dist/.setup/{request-Bo0kKABI.mjs → request-ePeNJrOd.mjs} +132 -136
- package/dist/.setup/{responses-oauth-twnuTaAa.mjs → responses-oauth-CCV7aVYF.mjs} +6 -6
- package/dist/.setup/{rpc-error-C98SHchT.mjs → rpc-error-DemqqaxE.mjs} +7 -3
- package/dist/.setup/{run-attempt-ClU8MxhZ.mjs → run-attempt-BcWArowv.mjs} +595 -426
- package/dist/.setup/{run-attempt-lifecycle-KN4oh-7O.mjs → run-attempt-lifecycle-DN-ATDp9.mjs} +1 -1
- package/dist/.setup/{runtime-artifact-C13pR7tD.mjs → runtime-artifact-CmLWeyJB.mjs} +3 -3
- package/dist/.setup/{runtime-artifact-connection-jS5DeCok.mjs → runtime-artifact-connection-DpWlZ02e.mjs} +3 -3
- package/dist/.setup/{sandbox-guard-DIImwCy1.mjs → sandbox-guard-DneAfNye.mjs} +70 -30
- package/dist/.setup/{session-binding-JEHNMPsr.mjs → session-binding-BgsWcbdY.mjs} +25 -23
- package/dist/.setup/{session-binding-record-DU_0biMD.mjs → session-binding-record-C_THntMe.mjs} +27 -12
- package/dist/.setup/{session-binding-record-codec-BpH8u_G9.mjs → session-binding-record-codec-DvmOI7g_.mjs} +1 -0
- package/dist/.setup/{session-binding-sidecars-DD-enC8w.mjs → session-binding-sidecars-BNSS6WL4.mjs} +55 -63
- package/dist/.setup/session-cancellation-DLBSJO5n.mjs +43 -0
- package/dist/.setup/{session-catalog-adoption-Ca3OYGYM.mjs → session-catalog-adoption-ppsLlVLB.mjs} +24 -38
- package/dist/.setup/{session-catalog-archive-Bv6gV7x9.mjs → session-catalog-archive-CqLRHJ6z.mjs} +11 -13
- package/dist/.setup/{session-catalog-events-kR2Ot6nX.mjs → session-catalog-events-DK0opVp3.mjs} +5 -5
- package/dist/.setup/{session-catalog-index-CrnfVEnT.mjs → session-catalog-index-BfzfdtH7.mjs} +96 -271
- package/dist/.setup/{session-catalog-index-order-CTfoefow.mjs → session-catalog-index-order-0Zqng2u8.mjs} +1 -1
- package/dist/.setup/{session-catalog-limits-BynIoOYm.mjs → session-catalog-limits-Dc6E0BZz.mjs} +1 -1
- package/dist/.setup/{session-catalog-list-request-D4MYNgDB.mjs → session-catalog-list-request-CAjoWjaH.mjs} +3 -4
- package/dist/.setup/{session-catalog-native-projection-CWqCU1I_.mjs → session-catalog-native-projection-G3lSDYYG.mjs} +5 -5
- package/dist/.setup/{session-catalog-node-adoption-BdP9Zjqo.mjs → session-catalog-node-adoption-e9v8mGgx.mjs} +5 -5
- package/dist/.setup/{session-catalog-node-continue-CNJibO4_.mjs → session-catalog-node-continue-H7nrzcUD.mjs} +5 -5
- package/dist/.setup/{session-catalog-node-lookup-BH_DBGa9.mjs → session-catalog-node-lookup-BrZfDkA8.mjs} +2 -2
- package/dist/.setup/{session-catalog-parsing-DkeoVn60.mjs → session-catalog-parsing-V6jyFg9g.mjs} +2 -2
- package/dist/.setup/{session-catalog-projection-BzHiV818.mjs → session-catalog-projection-BjWE414G.mjs} +8 -7
- package/dist/.setup/{session-catalog-provenance-CmsOE5mh.mjs → session-catalog-provenance-Dg9s12z-.mjs} +50 -30
- package/dist/.setup/{session-catalog-source-DGuRdGvM.mjs → session-catalog-source-DqyuNxCe.mjs} +2 -6
- package/dist/.setup/{session-cli-GwU0izn-.mjs → session-cli-CBGKiqdv.mjs} +1 -1
- package/dist/.setup/{session-history-BO6i_pfk.mjs → session-history-7W0cgTXF.mjs} +11 -9
- package/dist/.setup/{session-history-import-CaO8s6ta.mjs → session-history-import-BwPKwcNi.mjs} +4 -4
- package/dist/.setup/{session-initialization-Bi_2DKhc.mjs → session-initialization-Dn3vveGv.mjs} +2 -2
- package/dist/.setup/{session-retirement-B3U5hpGJ.mjs → session-retirement-Ci_JvOfH.mjs} +8 -8
- package/dist/.setup/{session-history.worker-DJQfek5p.mjs → settled-turn-evidence--tRW6fSm.mjs} +2 -18
- package/dist/.setup/{settled-turn-finalizer-CYCVpTv2.mjs → settled-turn-finalizer-D3-KXsbP.mjs} +8 -8
- package/dist/.setup/{shared-client-BCx1wbyA.mjs → shared-client-CE_uY0A1.mjs} +380 -557
- package/dist/.setup/side-question-OM18H9WJ.mjs +998 -0
- package/dist/.setup/{source-DipMO9hL.mjs → source-uGKgKWm8.mjs} +5 -5
- package/dist/.setup/{thread-archive-guard-LKdwQKyr.mjs → thread-archive-guard-BWjSsA92.mjs} +1 -1
- package/dist/.setup/{thread-lifecycle-run-C_aYiYqk.mjs → thread-lifecycle-run-mLueY6pH.mjs} +172 -75
- package/dist/.setup/{thread-model-selection-DcVebr8N.mjs → thread-model-selection-DxposL4X.mjs} +9 -9
- package/dist/.setup/{thread-ownership-BoUd0i6L.mjs → thread-ownership-t6Y9fLQS.mjs} +7 -7
- package/dist/.setup/{thread-policy-B3wBRNph.mjs → thread-policy-Cy301Or8.mjs} +6 -6
- package/dist/.setup/{thread-requests-BgzJwJtS.mjs → thread-requests-BjawdIVV.mjs} +14 -14
- package/dist/.setup/{thread-resume-D-3bsr1j.mjs → thread-resume-BUbsUfgF.mjs} +6 -6
- package/dist/.setup/{transcript-history-projection-DfKcoZCB.mjs → transcript-history-projection-i-FVpyha.mjs} +1 -1
- package/dist/.setup/{transcript-mirror-Bee2o6jj.mjs → transcript-mirror-CEQJZlF3.mjs} +6 -9
- package/dist/.setup/{transport-stdio-CRWTkKOn.mjs → transport-stdio-Bq160Dhv.mjs} +63 -64
- package/dist/.setup/{transport-websocket-DIyPfkHo.mjs → transport-websocket-0YqiI_MH.mjs} +1 -1
- package/dist/.setup/{turn-router-DBVMToGo.mjs → turn-router-Dbw17k3K.mjs} +2 -2
- package/dist/.setup/{upstream-session-fork-p5fwKi7w.mjs → upstream-session-fork-_LYkh0nZ.mjs} +46 -219
- package/dist/.setup/{usage-limit-error-BQX8RHAd.mjs → usage-limit-error-DcOSH3J4.mjs} +4 -4
- package/dist/.setup/{usage-C2Kq7oej.mjs → usage-w_93wnnR.mjs} +4 -4
- package/dist/.setup/{web-search-item-CvokaZOo.mjs → web-search-item-DHVuNSqk.mjs} +1 -1
- package/dist/.setup/{web-search-provider.runtime-D89djc7e.mjs → web-search-provider.runtime-DMHxve5v.mjs} +3 -3
- package/dist/.setup/{workspace-write-sandbox-probe-BDWO2Qkh.mjs → workspace-write-sandbox-probe-DJxOXcF3.mjs} +2 -2
- package/dist/api.js +7 -28
- package/dist/catalog-page.worker.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-version-api.js +25 -0
- package/dist/doctor-contract-api.js +5 -5
- package/dist/harness.js +59 -36
- package/dist/index.js +259 -295
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +1 -2
- package/dist/native-session-binding-api.js +1 -2
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-entrypoint.js +12 -0
- package/dist/session-history-worker-runtime.js +7 -18
- package/dist/session-history.worker.js +18 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +6 -6
- package/dist/.setup/attempt-terminal-jO5IMj9K.mjs +0 -2
- package/dist/.setup/command-rpc-HIvsy3wS.mjs +0 -247
- package/dist/.setup/compact-ClZ7Ar7L.mjs +0 -808
- package/dist/.setup/inference-context-DNlGwzwy.mjs +0 -91
- package/dist/.setup/managed-binary-BtIjV7yN.mjs +0 -175
- package/dist/.setup/native-execution-policy-MXEe7PB3.mjs +0 -75
- package/dist/.setup/protocol-CANUwXJ3.mjs +0 -17
- package/dist/.setup/side-question-Bz2UQW0l.mjs +0 -826
|
@@ -1,60 +1,125 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { r as isJsonObject } from "./protocol-CaPAVwe9.mjs";
|
|
2
|
+
import { g as sessionBindingIdentity, n as assertCodexBindingMayBeReplaced } from "./session-binding-record-C_THntMe.mjs";
|
|
3
3
|
import { d as readCodexRequirementsToml } from "./config-security-clxAZYWX.mjs";
|
|
4
4
|
import { d as readCodexPluginConfig } from "./config-parsing-DsWSCPHO.mjs";
|
|
5
|
-
import { d as readCodexEffectiveConfig, n as codexSandboxPolicyForTurn } from "./config-options-
|
|
6
|
-
import {
|
|
7
|
-
import { o as resolveCodexDefaultWorkspaceDir } from "./conversation-binding-data-
|
|
8
|
-
import { o as isCodexAppServerOverloadError } from "./rpc-error-
|
|
9
|
-
import { n as projectBoundedCodexVisibleSessionHistory } from "./transcript-history-projection-
|
|
10
|
-
import { n as canUseCodexModelBackedApprovalsReviewerForModel, r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-
|
|
11
|
-
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-
|
|
12
|
-
import { n as normalizeCodexAppServerBindingModelProvider,
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { a as isCodexNotificationForTurn, n as getCodexAppServerTurnRouter } from "./turn-router-
|
|
16
|
-
import { f as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, o as closeCodexStartupClientBestEffort, r as CodexAppServerUnsafeSubscriptionError, s as interruptCodexTurnAndWaitBestEffort } from "./attempt-client-cleanup-
|
|
17
|
-
import { d as mergeCodexThreadConfigs, s as buildDisabledAppsConfigPatch, t as buildCodexProjectDocThreadConfig } from "./project-doc-thread-config-
|
|
18
|
-
import "./session-binding-
|
|
19
|
-
import { r as resolveCodexAppServerRequestModelSelection, t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-model-selection-
|
|
20
|
-
import { a as rollbackCodexAppServerBindingSubscription, c as withExclusiveCodexAppServerThread, n as releaseCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-
|
|
21
|
-
import {
|
|
5
|
+
import { d as readCodexEffectiveConfig, n as codexSandboxPolicyForTurn } from "./config-options-DMFZkd3X.mjs";
|
|
6
|
+
import { T as retainSharedCodexAppServerClientByInstanceId } from "./auth-cache-key-CVcYw8HD.mjs";
|
|
7
|
+
import { o as resolveCodexDefaultWorkspaceDir } from "./conversation-binding-data-khgW0n-o.mjs";
|
|
8
|
+
import { o as isCodexAppServerOverloadError } from "./rpc-error-DemqqaxE.mjs";
|
|
9
|
+
import { n as projectBoundedCodexVisibleSessionHistory } from "./transcript-history-projection-i-FVpyha.mjs";
|
|
10
|
+
import { n as canUseCodexModelBackedApprovalsReviewerForModel, r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-BfrAlTMT.mjs";
|
|
11
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BZRizyuG.mjs";
|
|
12
|
+
import { n as normalizeCodexAppServerBindingModelProvider, o as resolveModelBackedReviewerPolicyProvider } from "./auth-profile-auwzSwwy.mjs";
|
|
13
|
+
import { A as hasCodexAppServerLiveThread, D as consumeCodexAppServerLiveThread, M as isCodexAppServerClientRuntimeLive, N as isCodexAppServerLiveThreadClaimed, d as releaseCodexAppServerClientLease, h as withCodexAppServerClientRequestScope, o as getLeasedSharedCodexAppServerClient, z as releaseCodexAppServerLiveThread } from "./shared-client-CE_uY0A1.mjs";
|
|
14
|
+
import { f as assertCodexThreadAcceptsDirectInput, h as assertCodexThreadStartResponse, i as isCodexAppServerIndeterminateRequestCancellationError, l as CodexThreadDirectInputError } from "./client-BS8X7HmG.mjs";
|
|
15
|
+
import { a as isCodexNotificationForTurn, n as getCodexAppServerTurnRouter } from "./turn-router-Dbw17k3K.mjs";
|
|
16
|
+
import { f as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, o as closeCodexStartupClientBestEffort, r as CodexAppServerUnsafeSubscriptionError, s as interruptCodexTurnAndWaitBestEffort } from "./attempt-client-cleanup-6OcbMH46.mjs";
|
|
17
|
+
import { d as mergeCodexThreadConfigs, s as buildDisabledAppsConfigPatch, t as buildCodexProjectDocThreadConfig } from "./project-doc-thread-config-B0UI3f1D.mjs";
|
|
18
|
+
import "./session-binding-BgsWcbdY.mjs";
|
|
19
|
+
import { r as resolveCodexAppServerRequestModelSelection, t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-model-selection-DxposL4X.mjs";
|
|
20
|
+
import { a as rollbackCodexAppServerBindingSubscription, c as withExclusiveCodexAppServerThread, n as releaseCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-t6Y9fLQS.mjs";
|
|
21
|
+
import { i as resolveCodexNativeExecutionPolicy } from "./native-execution-policy-D09tLP-u.mjs";
|
|
22
|
+
import { i as resolveCodexNativeExecutionBlock, t as assertNativeConversationApprovalPolicySupported } from "./sandbox-guard-DneAfNye.mjs";
|
|
23
|
+
import { t as resumeCodexAppServerThread } from "./thread-resume-BUbsUfgF.mjs";
|
|
22
24
|
import { i as resolveCodexSessionPermissionCwd, n as applyCodexSessionPermissionPolicy, t as CODEX_SESSION_PERMISSION_EXEC_MODES } from "./session-permission-policy-CD2MAWU8.mjs";
|
|
23
|
-
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-
|
|
24
|
-
import { f as trackCodexConversationActiveTurn, o as resolveThreadRequestModelProvider, t as buildCodexConversationAgentLookup } from "./conversation-control-
|
|
25
|
+
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-Cog6mm2i.mjs";
|
|
26
|
+
import { f as trackCodexConversationActiveTurn, o as resolveThreadRequestModelProvider, t as buildCodexConversationAgentLookup } from "./conversation-control-B2EpVZEb.mjs";
|
|
25
27
|
import { asOptionalRecord, normalizeOptionalString, readNonEmptyStringPreservingWhitespace } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
26
28
|
import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
27
29
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
28
30
|
import path from "node:path";
|
|
31
|
+
import { isIncognitoSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
|
|
32
|
+
import { parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
|
|
29
33
|
import { fileURLToPath } from "node:url";
|
|
30
34
|
import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
31
35
|
import { embeddedAgentLog, formatErrorMessage, resolveActiveEmbeddedRunSessionId, resolveSandboxContext } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
36
|
+
import { loadExecApprovalsReadOnlyAsync } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
37
|
+
import { getSessionEntryByIdAsync, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
34
38
|
import { readVisibleSessionTranscriptMessageEntries } from "openclaw/plugin-sdk/session-transcript-runtime";
|
|
39
|
+
import { captureSessionEntryCurrentCheckAsync, composeSessionEntryCommitGuards } from "openclaw/plugin-sdk/session-binding-runtime";
|
|
40
|
+
//#region extensions/codex/src/conversation-binding-history.ts
|
|
41
|
+
async function projectConversationSourceHistory(source, target, config, assertCurrent) {
|
|
42
|
+
const storePath = source.storePath ?? resolveStorePath(config?.session?.store, { agentId: source.agentId });
|
|
43
|
+
const sessionKey = source.sessionKey ?? (await getSessionEntryByIdAsync({
|
|
44
|
+
agentId: source.agentId,
|
|
45
|
+
sessionId: source.sessionId,
|
|
46
|
+
storePath
|
|
47
|
+
}))?.sessionKey;
|
|
48
|
+
if (!sessionKey) return;
|
|
49
|
+
const entries = await readVisibleSessionTranscriptMessageEntries({
|
|
50
|
+
agentId: source.agentId,
|
|
51
|
+
sessionId: source.sessionId,
|
|
52
|
+
sessionKey,
|
|
53
|
+
storePath
|
|
54
|
+
});
|
|
55
|
+
const history = projectBoundedCodexVisibleSessionHistory(entries);
|
|
56
|
+
if (history.length === 0) return;
|
|
57
|
+
const clientLease = await retainSharedCodexAppServerClientByInstanceId(target.clientId);
|
|
58
|
+
if (!clientLease) throw new Error("Codex conversation source history lost its bound client owner.");
|
|
59
|
+
try {
|
|
60
|
+
await clientLease.client.request("thread/inject_items", {
|
|
61
|
+
threadId: target.threadId,
|
|
62
|
+
items: history
|
|
63
|
+
}, { withCurrent: async (write) => {
|
|
64
|
+
await assertCurrent();
|
|
65
|
+
write();
|
|
66
|
+
} });
|
|
67
|
+
} finally {
|
|
68
|
+
await clientLease.release();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
35
72
|
//#region extensions/codex/src/conversation-binding-preparation.ts
|
|
36
73
|
/** Canonical conversation thread preparation, policy, and binding ownership. */
|
|
37
|
-
const NATIVE_CONVERSATION_INTERACTIVE_APPROVALS_UNAVAILABLE = "OpenClaw native Codex conversation binding cannot route interactive approvals yet; use the Codex harness or explicit /acp spawn codex for that workflow.";
|
|
38
74
|
async function resolveConversationAppServerRuntime(params) {
|
|
39
75
|
const source = params.source;
|
|
40
76
|
const agentId = source?.agentId ?? params.agentId ?? (params.config ? resolveSessionAgentIdsStrict({
|
|
41
77
|
sessionKey: params.sessionKey,
|
|
42
78
|
config: params.config
|
|
43
79
|
}).sessionAgentId : void 0);
|
|
44
|
-
const storePath = agentId && (source || params.sessionKey) ? resolveStorePath(params.config?.session?.store, { agentId }) : void 0;
|
|
45
|
-
const
|
|
80
|
+
const storePath = agentId && (source || params.sessionKey) ? source?.storePath ?? params.storePath ?? resolveStorePath(params.config?.session?.store, { agentId }) : void 0;
|
|
81
|
+
const selectedById = source && !source.sessionKey && storePath ? await getSessionEntryByIdAsync({
|
|
46
82
|
agentId: source.agentId,
|
|
47
83
|
sessionId: source.sessionId,
|
|
48
84
|
storePath
|
|
49
|
-
}) : void 0
|
|
50
|
-
const
|
|
85
|
+
}) : void 0;
|
|
86
|
+
const sessionKey = source ? source.sessionKey ?? selectedById?.sessionKey : params.sessionKey;
|
|
87
|
+
const ownsSession = source || (parseAgentSessionKey(sessionKey)?.agentId ?? agentId) === agentId;
|
|
88
|
+
const current = sessionKey && storePath && agentId && ownsSession ? await captureSessionEntryCurrentCheckAsync({
|
|
51
89
|
agentId,
|
|
52
90
|
storePath,
|
|
53
91
|
sessionKey,
|
|
54
|
-
|
|
92
|
+
fields: [
|
|
93
|
+
"permissionMode",
|
|
94
|
+
"sessionRoot",
|
|
95
|
+
"execHost",
|
|
96
|
+
"execNode",
|
|
97
|
+
"sandbox",
|
|
98
|
+
"sandboxMode",
|
|
99
|
+
"incognito"
|
|
100
|
+
],
|
|
101
|
+
...selectedById ? { expected: selectedById.entry } : {}
|
|
55
102
|
}) : void 0;
|
|
103
|
+
let transferred = false;
|
|
104
|
+
using currentCleanup = { [Symbol.dispose]: () => !transferred && current?.release() };
|
|
105
|
+
const storedEntry = current?.entry;
|
|
56
106
|
const entry = !source || storedEntry?.sessionId === source.sessionId ? storedEntry : void 0;
|
|
57
107
|
if (source && !entry) throw new Error("Codex conversation source session is missing or no longer current; rebind this conversation before retrying.");
|
|
108
|
+
const block = resolveCodexNativeExecutionBlock({
|
|
109
|
+
config: params.config,
|
|
110
|
+
agentId,
|
|
111
|
+
sessionKey,
|
|
112
|
+
storePath,
|
|
113
|
+
executionPolicy: resolveCodexNativeExecutionPolicy({
|
|
114
|
+
config: params.config,
|
|
115
|
+
agentId,
|
|
116
|
+
sessionKey,
|
|
117
|
+
sessionEntry: entry ?? null,
|
|
118
|
+
readRuntimeSessionEntry: false
|
|
119
|
+
}),
|
|
120
|
+
surface: "conversation binding"
|
|
121
|
+
});
|
|
122
|
+
if (block) throw new Error(block);
|
|
58
123
|
const permissionMode = entry?.permissionMode;
|
|
59
124
|
const sessionRoot = permissionMode ? entry?.sessionRoot : void 0;
|
|
60
125
|
const agentWorkspaceDir = params.config && agentId ? resolveAgentWorkspaceDir(params.config, agentId) : resolveCodexDefaultWorkspaceDir(params.pluginConfig);
|
|
@@ -63,13 +128,14 @@ async function resolveConversationAppServerRuntime(params) {
|
|
|
63
128
|
agentId,
|
|
64
129
|
permissionMode,
|
|
65
130
|
execOverrides: permissionMode ? { mode: CODEX_SESSION_PERMISSION_EXEC_MODES[permissionMode] } : void 0,
|
|
66
|
-
approvals: permissionMode === "full" ? void 0 :
|
|
131
|
+
approvals: permissionMode === "full" ? void 0 : await loadExecApprovalsReadOnlyAsync()
|
|
67
132
|
});
|
|
68
133
|
const sandboxForPolicy = execPolicy.touched && execPolicy.security === "full" && execPolicy.ask !== "off" ? await resolveSandboxContext({
|
|
69
134
|
config: params.config,
|
|
70
135
|
sessionKey,
|
|
71
136
|
workspaceDir: agentWorkspaceDir
|
|
72
137
|
}) : void 0;
|
|
138
|
+
using _ = { [Symbol.dispose]: () => sandboxForPolicy?.[Symbol.dispose]?.() };
|
|
73
139
|
const configuredRuntime = resolveCodexAppServerRuntimeOptions({
|
|
74
140
|
pluginConfig: params.pluginConfig,
|
|
75
141
|
execPolicy,
|
|
@@ -96,7 +162,12 @@ async function resolveConversationAppServerRuntime(params) {
|
|
|
96
162
|
requirementsToml: readCodexRequirementsToml({}),
|
|
97
163
|
execMode: execPolicy.mode
|
|
98
164
|
});
|
|
99
|
-
|
|
165
|
+
await current?.assertCurrent();
|
|
166
|
+
const resolved = {
|
|
167
|
+
release: current?.release ?? (() => {}),
|
|
168
|
+
assertCurrent: current?.assertCurrent ?? (async () => {}),
|
|
169
|
+
source: current?.source,
|
|
170
|
+
incognito: source || sessionKey ? entry?.incognito === true || isIncognitoSessionKey(sessionKey) : void 0,
|
|
100
171
|
runtime: resolveCodexAppServerForModelProvider({
|
|
101
172
|
appServer: runtime,
|
|
102
173
|
provider: params.modelProvider,
|
|
@@ -113,38 +184,48 @@ async function resolveConversationAppServerRuntime(params) {
|
|
|
113
184
|
fallbackCwd: params.workspaceDir
|
|
114
185
|
})
|
|
115
186
|
};
|
|
187
|
+
transferred = true;
|
|
188
|
+
return resolved;
|
|
116
189
|
}
|
|
117
190
|
const CODEX_CONVERSATION_THREAD_DEVELOPER_INSTRUCTIONS = "This Codex thread is bound to an OpenClaw conversation. Answer normally; OpenClaw will deliver your final response back to the conversation.";
|
|
118
191
|
async function resolveThreadBindingRuntime(params) {
|
|
119
192
|
const agentLookup = buildCodexConversationAgentLookup(params);
|
|
120
|
-
const modelProvider = resolveThreadRequestModelProvider({
|
|
193
|
+
const modelProvider = await resolveThreadRequestModelProvider({
|
|
121
194
|
authProfileId: params.authProfileId,
|
|
122
195
|
modelProvider: params.modelProvider,
|
|
123
196
|
...agentLookup
|
|
124
197
|
});
|
|
125
|
-
const modelSelection = params.model?.trim() ? resolveCodexAppServerRequestModelSelection({
|
|
198
|
+
const modelSelection = params.model?.trim() ? await resolveCodexAppServerRequestModelSelection({
|
|
126
199
|
model: params.model,
|
|
127
200
|
modelProvider,
|
|
128
201
|
authProfileId: params.authProfileId,
|
|
129
202
|
...agentLookup
|
|
130
203
|
}) : void 0;
|
|
131
|
-
const reviewerModelProvider = resolveModelBackedReviewerPolicyProvider({
|
|
204
|
+
const reviewerModelProvider = await resolveModelBackedReviewerPolicyProvider({
|
|
132
205
|
authProfileId: params.authProfileId,
|
|
133
206
|
modelProvider: params.modelProvider,
|
|
134
207
|
...agentLookup
|
|
135
208
|
});
|
|
136
|
-
const { runtime, workspaceDir } = await resolveConversationAppServerRuntime({
|
|
209
|
+
const { runtime, workspaceDir, assertCurrent, source, incognito, release } = await resolveConversationAppServerRuntime({
|
|
137
210
|
...params,
|
|
138
211
|
modelProvider: reviewerModelProvider
|
|
139
212
|
});
|
|
213
|
+
let transferred = false;
|
|
214
|
+
using _ = { [Symbol.dispose]: () => !transferred && release() };
|
|
140
215
|
assertNativeConversationApprovalPolicySupported(runtime);
|
|
141
216
|
const clientOptions = {
|
|
217
|
+
assertCurrentAsync: assertCurrent,
|
|
142
218
|
startOptions: runtime.start,
|
|
143
219
|
timeoutMs: runtime.requestTimeoutMs,
|
|
144
220
|
authProfileId: params.authProfileId,
|
|
145
221
|
...agentLookup
|
|
146
222
|
};
|
|
223
|
+
transferred = true;
|
|
147
224
|
return {
|
|
225
|
+
release,
|
|
226
|
+
assertCurrent,
|
|
227
|
+
source,
|
|
228
|
+
incognito: incognito ?? params.incognito,
|
|
148
229
|
runtime,
|
|
149
230
|
workspaceDir,
|
|
150
231
|
agentLookup,
|
|
@@ -154,8 +235,10 @@ async function resolveThreadBindingRuntime(params) {
|
|
|
154
235
|
};
|
|
155
236
|
}
|
|
156
237
|
async function buildConversationThreadRequestForClient(client, resolved, serviceTier, requestOptions) {
|
|
238
|
+
await resolved.assertCurrent();
|
|
157
239
|
const effectiveConfig = await readCodexEffectiveConfig(client, resolved.workspaceDir, requestOptions());
|
|
158
240
|
requestOptions();
|
|
241
|
+
await resolved.assertCurrent();
|
|
159
242
|
const { runtime } = resolved;
|
|
160
243
|
const config = buildCodexProjectDocThreadConfig(mergeCodexThreadConfigs(runtime.networkProxy?.configPatch, buildDisabledAppsConfigPatch()), effectiveConfig);
|
|
161
244
|
return {
|
|
@@ -177,9 +260,9 @@ async function writeThreadBindingFromResponse(params, resolved, client, response
|
|
|
177
260
|
let retained = false;
|
|
178
261
|
let sameOwner = false;
|
|
179
262
|
try {
|
|
180
|
-
const current = params.bindingStore.
|
|
263
|
+
const current = await params.bindingStore.readAsync(params.identity);
|
|
181
264
|
assertCodexBindingMayBeReplaced(current, "storing a conversation-bound Codex thread");
|
|
182
|
-
const trackSubscription = !
|
|
265
|
+
const trackSubscription = !resolved.incognito && isCodexAppServerClientRuntimeLive(client);
|
|
183
266
|
sameOwner = isSameCodexAppServerThreadOwner(current, {
|
|
184
267
|
threadId: response.thread.id,
|
|
185
268
|
clientId: client.getInstanceId()
|
|
@@ -191,9 +274,10 @@ async function writeThreadBindingFromResponse(params, resolved, client, response
|
|
|
191
274
|
if (!retained) throw new Error("Codex conversation thread lost its native subscription owner.");
|
|
192
275
|
}
|
|
193
276
|
if (current && !sameOwner) {
|
|
194
|
-
const { assertCurrent } = requestOptions();
|
|
277
|
+
const { assertCurrent, withCurrent } = requestOptions();
|
|
195
278
|
await releaseCodexAppServerBindingSubscription(current, {
|
|
196
279
|
assertCurrent,
|
|
280
|
+
withCurrent,
|
|
197
281
|
retainedClientId: client.getInstanceId()
|
|
198
282
|
});
|
|
199
283
|
}
|
|
@@ -204,9 +288,10 @@ async function writeThreadBindingFromResponse(params, resolved, client, response
|
|
|
204
288
|
threadId: response.thread.id,
|
|
205
289
|
clientId: client.getInstanceId(),
|
|
206
290
|
cwd: resolved.workspaceDir,
|
|
291
|
+
...resolved.incognito ? { conversationIncognito: true } : {},
|
|
207
292
|
authProfileId: params.authProfileId,
|
|
208
293
|
model: response.model ?? resolved.model ?? params.model,
|
|
209
|
-
modelProvider: normalizeCodexAppServerBindingModelProvider({
|
|
294
|
+
modelProvider: await normalizeCodexAppServerBindingModelProvider({
|
|
210
295
|
authProfileId: params.authProfileId,
|
|
211
296
|
modelProvider: response.modelProvider ?? resolved.modelProvider ?? params.modelProvider,
|
|
212
297
|
...resolved.agentLookup
|
|
@@ -215,22 +300,37 @@ async function writeThreadBindingFromResponse(params, resolved, client, response
|
|
|
215
300
|
networkProxyProfileName: resolved.runtime.networkProxy?.profileName,
|
|
216
301
|
networkProxyConfigFingerprint: resolved.runtime.networkProxy?.configFingerprint
|
|
217
302
|
}
|
|
218
|
-
},
|
|
303
|
+
}, composeSessionEntryCommitGuards([() => {
|
|
304
|
+
requestOptions();
|
|
305
|
+
}, resolved.source]))) throw new Error("Codex conversation binding changed while storing its thread.");
|
|
219
306
|
} catch (error) {
|
|
220
307
|
if (retained && !sameOwner || !hasCodexAppServerLiveThread(client, response.thread.id)) await rollbackCodexAppServerBindingSubscription(client, response.thread.id, retained);
|
|
221
308
|
throw error;
|
|
222
309
|
}
|
|
223
310
|
}
|
|
224
311
|
async function bindThread(params, threadId) {
|
|
225
|
-
const current = params.bindingStore.
|
|
312
|
+
const current = await params.bindingStore.readAsync(params.identity);
|
|
226
313
|
assertCodexBindingMayBeReplaced(current, "binding a conversation-bound Codex thread");
|
|
227
314
|
const resolved = await resolveThreadBindingRuntime(params);
|
|
315
|
+
let transferred = false;
|
|
316
|
+
using _ = { [Symbol.dispose]: () => !transferred && resolved.release() };
|
|
228
317
|
const clientLease = { client: await getLeasedSharedCodexAppServerClient(resolved.clientOptions) };
|
|
229
318
|
try {
|
|
230
|
-
await
|
|
319
|
+
await withCodexAppServerClientRequestScope({
|
|
231
320
|
lease: clientLease,
|
|
232
321
|
options: resolved.clientOptions,
|
|
233
|
-
run: async (client,
|
|
322
|
+
run: async (client, connectionRequestOptions) => {
|
|
323
|
+
const requestOptions = () => {
|
|
324
|
+
const options = connectionRequestOptions();
|
|
325
|
+
return {
|
|
326
|
+
...options,
|
|
327
|
+
withCurrent: async (write) => {
|
|
328
|
+
await resolved.assertCurrent();
|
|
329
|
+
options.assertCurrent();
|
|
330
|
+
write();
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
};
|
|
234
334
|
const request = await buildConversationThreadRequestForClient(client, resolved, params.serviceTier ?? resolved.runtime.serviceTier, requestOptions);
|
|
235
335
|
let response;
|
|
236
336
|
if (threadId && !resolved.runtime.networkProxy) {
|
|
@@ -240,8 +340,8 @@ async function bindThread(params, threadId) {
|
|
|
240
340
|
includeTurns: false
|
|
241
341
|
}, requestOptions());
|
|
242
342
|
assertCodexThreadAcceptsDirectInput(thread);
|
|
243
|
-
const { assertCurrent } = requestOptions();
|
|
244
|
-
await releaseCodexAppServerLiveThread(client, threadId, assertCurrent);
|
|
343
|
+
const { assertCurrent, withCurrent } = requestOptions();
|
|
344
|
+
await releaseCodexAppServerLiveThread(client, threadId, assertCurrent, withCurrent);
|
|
245
345
|
if (isCodexAppServerLiveThreadClaimed(client, threadId)) throw new Error(`Codex thread ${threadId} has an active run; stop it before binding its conversation.`);
|
|
246
346
|
response = await resumeCodexAppServerThread({
|
|
247
347
|
client,
|
|
@@ -256,7 +356,7 @@ async function bindThread(params, threadId) {
|
|
|
256
356
|
...request,
|
|
257
357
|
developerInstructions: CODEX_CONVERSATION_THREAD_DEVELOPER_INSTRUCTIONS,
|
|
258
358
|
experimentalRawEvents: true,
|
|
259
|
-
...
|
|
359
|
+
...resolved.incognito ? { ephemeral: true } : {}
|
|
260
360
|
}, requestOptions());
|
|
261
361
|
await writeThreadBindingFromResponse(params, resolved, client, response, requestOptions);
|
|
262
362
|
}
|
|
@@ -264,18 +364,21 @@ async function bindThread(params, threadId) {
|
|
|
264
364
|
} finally {
|
|
265
365
|
releaseCodexAppServerClientLease(clientLease);
|
|
266
366
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
367
|
+
transferred = true;
|
|
368
|
+
return {
|
|
369
|
+
assertCurrent: resolved.assertCurrent,
|
|
370
|
+
source: resolved.source,
|
|
371
|
+
release: resolved.release
|
|
372
|
+
};
|
|
270
373
|
}
|
|
271
374
|
async function prepareCodexConversationBinding(params, options = {}) {
|
|
272
375
|
const identity = {
|
|
273
376
|
kind: "conversation",
|
|
274
377
|
bindingId: params.data.bindingId
|
|
275
378
|
};
|
|
276
|
-
const snapshot = params.bindingStore.
|
|
379
|
+
const snapshot = await params.bindingStore.readAsync(identity);
|
|
277
380
|
const run = () => params.bindingStore.withLease(identity, async () => {
|
|
278
|
-
const current = params.bindingStore.
|
|
381
|
+
const current = await params.bindingStore.readAsync(identity);
|
|
279
382
|
if (current?.threadId !== snapshot?.threadId || current?.clientId !== snapshot?.clientId) throw new Error("Codex conversation binding changed before preparation.");
|
|
280
383
|
const requested = params.data.start && current?.conversationStartId !== params.data.start.id ? params.data.start : void 0;
|
|
281
384
|
if (current && !requested && !options.forceNew) return;
|
|
@@ -285,7 +388,7 @@ async function prepareCodexConversationBinding(params, options = {}) {
|
|
|
285
388
|
sessionKey: params.data.source.sessionKey,
|
|
286
389
|
config: params.config
|
|
287
390
|
}) : void 0;
|
|
288
|
-
const sourceBinding = sourceIdentity ? params.bindingStore.
|
|
391
|
+
const sourceBinding = sourceIdentity ? await params.bindingStore.readAsync(sourceIdentity) : void 0;
|
|
289
392
|
assertCodexBindingMayBeReplaced(current, "initializing a conversation-bound Codex thread");
|
|
290
393
|
assertCodexBindingMayBeReplaced(sourceBinding, "transferring a session into a conversation-bound Codex thread");
|
|
291
394
|
const inherited = current ?? sourceBinding;
|
|
@@ -310,26 +413,33 @@ async function prepareCodexConversationBinding(params, options = {}) {
|
|
|
310
413
|
agentId: params.data.source?.agentId ?? params.data.agentId
|
|
311
414
|
};
|
|
312
415
|
const threadId = requested?.threadId;
|
|
313
|
-
await bindThread(bindingParams, options.forceNew ? void 0 : threadId);
|
|
314
|
-
|
|
416
|
+
const sourceAuthority = await bindThread(bindingParams, options.forceNew ? void 0 : threadId);
|
|
417
|
+
using _ = { [Symbol.dispose]: sourceAuthority.release };
|
|
418
|
+
await sourceAuthority.assertCurrent();
|
|
419
|
+
const sourceGuard = sourceAuthority.source;
|
|
420
|
+
const stored = await params.bindingStore.readAsync(identity);
|
|
315
421
|
if (!stored) throw new Error("Codex conversation binding disappeared while initializing its thread.");
|
|
316
422
|
if (sourceIdentity && params.data.source && !current?.conversationSourceTransferComplete) await params.bindingStore.withLease(sourceIdentity, async () => {
|
|
317
|
-
|
|
423
|
+
await sourceAuthority.assertCurrent();
|
|
424
|
+
const source = await params.bindingStore.readAsync(sourceIdentity);
|
|
318
425
|
if (source && source.threadId === params.data.source?.threadId) {
|
|
319
|
-
const sourceSessionKey = sourceIdentity.sessionKey ??
|
|
426
|
+
const sourceSessionKey = sourceIdentity.sessionKey ?? (await getSessionEntryByIdAsync({
|
|
320
427
|
agentId: sourceIdentity.agentId,
|
|
321
428
|
sessionId: sourceIdentity.sessionId,
|
|
322
|
-
storePath: resolveStorePath(params.config?.session?.store, { agentId: sourceIdentity.agentId })
|
|
323
|
-
});
|
|
429
|
+
storePath: params.data.source.storePath ?? resolveStorePath(params.config?.session?.store, { agentId: sourceIdentity.agentId })
|
|
430
|
+
}))?.sessionKey;
|
|
324
431
|
if (sourceSessionKey && resolveActiveEmbeddedRunSessionId(sourceSessionKey) === sourceIdentity.sessionId) throw new Error("Codex source session has an active run; stop it before binding this conversation.");
|
|
325
432
|
if (source.threadId !== stored.threadId) {
|
|
326
|
-
await releaseCodexAppServerBindingSubscription(source)
|
|
327
|
-
|
|
433
|
+
await releaseCodexAppServerBindingSubscription(source, { withCurrent: async (write) => {
|
|
434
|
+
await sourceAuthority.assertCurrent();
|
|
435
|
+
write();
|
|
436
|
+
} });
|
|
437
|
+
await projectConversationSourceHistory(params.data.source, stored, params.config, sourceAuthority.assertCurrent);
|
|
328
438
|
}
|
|
329
439
|
await params.bindingStore.mutate(sourceIdentity, {
|
|
330
440
|
kind: "clear",
|
|
331
441
|
threadId: source.threadId
|
|
332
|
-
});
|
|
442
|
+
}, sourceAuthority.source);
|
|
333
443
|
}
|
|
334
444
|
});
|
|
335
445
|
if (!await params.bindingStore.mutate(identity, {
|
|
@@ -339,7 +449,7 @@ async function prepareCodexConversationBinding(params, options = {}) {
|
|
|
339
449
|
...params.data.start ? { conversationStartId: params.data.start.id } : {},
|
|
340
450
|
...sourceIdentity ? { conversationSourceTransferComplete: true } : {}
|
|
341
451
|
}
|
|
342
|
-
})) throw new Error("Codex conversation binding changed while initializing its thread.");
|
|
452
|
+
}, sourceGuard)) throw new Error("Codex conversation binding changed while initializing its thread.");
|
|
343
453
|
});
|
|
344
454
|
const threadId = params.data.start?.threadId ?? snapshot?.threadId;
|
|
345
455
|
if (threadId) await withExclusiveCodexAppServerThread({
|
|
@@ -350,38 +460,6 @@ async function prepareCodexConversationBinding(params, options = {}) {
|
|
|
350
460
|
});
|
|
351
461
|
else await run();
|
|
352
462
|
}
|
|
353
|
-
async function projectConversationSourceHistory(source, target, config) {
|
|
354
|
-
const storePath = resolveStorePath(config?.session?.store, { agentId: source.agentId });
|
|
355
|
-
const sessionKey = source.sessionKey ?? resolveTranscriptSessionKeyBySessionId({
|
|
356
|
-
agentId: source.agentId,
|
|
357
|
-
sessionId: source.sessionId,
|
|
358
|
-
storePath
|
|
359
|
-
});
|
|
360
|
-
if (!sessionKey) return;
|
|
361
|
-
const entries = await readVisibleSessionTranscriptMessageEntries({
|
|
362
|
-
agentId: source.agentId,
|
|
363
|
-
sessionId: source.sessionId,
|
|
364
|
-
sessionKey,
|
|
365
|
-
storePath
|
|
366
|
-
});
|
|
367
|
-
const history = projectBoundedCodexVisibleSessionHistory(entries);
|
|
368
|
-
if (history.length === 0) return;
|
|
369
|
-
const clientLease = await retainSharedCodexAppServerClientByInstanceId(target.clientId);
|
|
370
|
-
if (!clientLease) throw new Error("Codex conversation source history lost its bound client owner.");
|
|
371
|
-
try {
|
|
372
|
-
await clientLease.client.request("thread/inject_items", {
|
|
373
|
-
threadId: target.threadId,
|
|
374
|
-
items: history
|
|
375
|
-
});
|
|
376
|
-
} finally {
|
|
377
|
-
await clientLease.release();
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
function resolveModelBackedReviewerPolicyProvider(params) {
|
|
381
|
-
const modelProvider = params.modelProvider?.trim();
|
|
382
|
-
if (modelProvider && modelProvider.toLowerCase() !== "codex") return modelProvider.toLowerCase() === "openai" ? "openai" : modelProvider;
|
|
383
|
-
return isCodexAppServerNativeAuthProfile(params) ? "openai" : void 0;
|
|
384
|
-
}
|
|
385
463
|
//#endregion
|
|
386
464
|
//#region extensions/codex/src/conversation-turn-collector.ts
|
|
387
465
|
/** Identifies a timer that expired in the bound-turn collector itself. */
|
|
@@ -544,24 +622,24 @@ async function runBoundTurn(params) {
|
|
|
544
622
|
kind: "conversation",
|
|
545
623
|
bindingId: params.data.bindingId
|
|
546
624
|
};
|
|
547
|
-
const binding = params.bindingStore.
|
|
625
|
+
const binding = await params.bindingStore.readAsync(identity);
|
|
548
626
|
if (!binding?.threadId) throw new Error("bound Codex conversation has no thread binding");
|
|
549
627
|
return await withExclusiveCodexAppServerThread({
|
|
550
628
|
bindingStore: params.bindingStore,
|
|
551
629
|
identity,
|
|
552
630
|
threadId: binding.threadId,
|
|
553
631
|
run: async () => {
|
|
554
|
-
const current = params.bindingStore.
|
|
632
|
+
const current = await params.bindingStore.readAsync(identity);
|
|
555
633
|
if (!isSameCodexAppServerThreadOwner(current, binding)) throw new Error("Codex conversation binding changed before its turn.");
|
|
556
634
|
assertCodexBindingMayBeReplaced(binding, "running a conversation-bound Codex thread");
|
|
557
635
|
let threadId = binding.threadId;
|
|
558
636
|
const requestedWorkspaceDir = binding.cwd || params.data.workspaceDir;
|
|
559
|
-
const reviewerModelProvider = resolveModelBackedReviewerPolicyProvider({
|
|
637
|
+
const reviewerModelProvider = await resolveModelBackedReviewerPolicyProvider({
|
|
560
638
|
authProfileId: binding.authProfileId,
|
|
561
639
|
modelProvider: binding.modelProvider,
|
|
562
640
|
...agentLookup
|
|
563
641
|
});
|
|
564
|
-
const { runtime, workspaceDir } = await resolveConversationAppServerRuntime({
|
|
642
|
+
const { runtime, workspaceDir, assertCurrent, release, source, incognito: sourceIncognito } = await resolveConversationAppServerRuntime({
|
|
565
643
|
pluginConfig: params.pluginConfig,
|
|
566
644
|
config: params.config,
|
|
567
645
|
agentId: params.data.source?.agentId ?? params.data.agentId,
|
|
@@ -572,6 +650,8 @@ async function runBoundTurn(params) {
|
|
|
572
650
|
model: binding.model,
|
|
573
651
|
agentDir: params.data.agentDir
|
|
574
652
|
});
|
|
653
|
+
using _ = { [Symbol.dispose]: release };
|
|
654
|
+
const incognito = sourceIncognito ?? params.incognito;
|
|
575
655
|
const { sessionRoot, approvalPolicy, sandbox } = runtime;
|
|
576
656
|
const permissionProfile = runtime.networkProxy?.profileName;
|
|
577
657
|
const networkProxyConfigFingerprint = runtime.networkProxy?.configFingerprint;
|
|
@@ -579,7 +659,7 @@ async function runBoundTurn(params) {
|
|
|
579
659
|
const serviceTier = binding.serviceTier ?? runtime.serviceTier;
|
|
580
660
|
let useStickyNetworkProfile = permissionProfile !== void 0 && !networkProxyBindingChanged;
|
|
581
661
|
assertNativeConversationApprovalPolicySupported(runtime);
|
|
582
|
-
const modelSelection = binding.model ? resolveCodexAppServerRequestModelSelection({
|
|
662
|
+
const modelSelection = binding.model ? await resolveCodexAppServerRequestModelSelection({
|
|
583
663
|
model: binding.model,
|
|
584
664
|
modelProvider: binding.modelProvider,
|
|
585
665
|
authProfileId: binding.authProfileId,
|
|
@@ -588,15 +668,19 @@ async function runBoundTurn(params) {
|
|
|
588
668
|
const threadRequestRuntime = {
|
|
589
669
|
runtime,
|
|
590
670
|
workspaceDir,
|
|
671
|
+
assertCurrent,
|
|
672
|
+
source,
|
|
673
|
+
incognito,
|
|
591
674
|
...modelSelection
|
|
592
675
|
};
|
|
593
676
|
const clientOptions = {
|
|
677
|
+
assertCurrentAsync: assertCurrent,
|
|
594
678
|
startOptions: runtime.start,
|
|
595
679
|
timeoutMs: runtime.requestTimeoutMs,
|
|
596
680
|
authProfileId: binding.authProfileId,
|
|
597
681
|
...agentLookup
|
|
598
682
|
};
|
|
599
|
-
|
|
683
|
+
const client = await getLeasedSharedCodexAppServerClient(clientOptions);
|
|
600
684
|
const clientLease = { client };
|
|
601
685
|
let activeTurnId;
|
|
602
686
|
let activeTurnCleanup = () => void 0;
|
|
@@ -605,16 +689,23 @@ async function runBoundTurn(params) {
|
|
|
605
689
|
let liveThreadOwnership;
|
|
606
690
|
let ownsNativeSubscription = false;
|
|
607
691
|
let turnSucceeded = false;
|
|
692
|
+
const withCurrent = async (write) => {
|
|
693
|
+
await assertCurrent();
|
|
694
|
+
write();
|
|
695
|
+
};
|
|
608
696
|
const assertResumeInputAllowed = async () => {
|
|
609
697
|
const { thread } = await client.request("thread/read", {
|
|
610
698
|
threadId,
|
|
611
699
|
includeTurns: false
|
|
612
|
-
}, {
|
|
700
|
+
}, {
|
|
701
|
+
timeoutMs: runtime.requestTimeoutMs,
|
|
702
|
+
withCurrent
|
|
703
|
+
});
|
|
613
704
|
assertCodexThreadAcceptsDirectInput(thread);
|
|
614
705
|
};
|
|
615
706
|
try {
|
|
616
707
|
if (!networkProxyBindingChanged && binding.clientId !== client.getInstanceId()) await assertResumeInputAllowed();
|
|
617
|
-
if (!
|
|
708
|
+
if (!incognito && isCodexAppServerClientRuntimeLive(client)) {
|
|
618
709
|
const ownership = await consumeCodexAppServerLiveThread(client, threadId);
|
|
619
710
|
if (ownership) {
|
|
620
711
|
liveThreadOwnership = {
|
|
@@ -625,18 +716,29 @@ async function runBoundTurn(params) {
|
|
|
625
716
|
ownsNativeSubscription = true;
|
|
626
717
|
}
|
|
627
718
|
}
|
|
628
|
-
if (networkProxyBindingChanged || binding.clientId !== client.getInstanceId() || isCodexAppServerClientRuntimeLive(client) && !
|
|
719
|
+
if (networkProxyBindingChanged || binding.clientId !== client.getInstanceId() || isCodexAppServerClientRuntimeLive(client) && !incognito && !liveThreadOwnership) {
|
|
629
720
|
if (!networkProxyBindingChanged && binding.clientId === client.getInstanceId()) await assertResumeInputAllowed();
|
|
630
|
-
const result = await
|
|
721
|
+
const result = await withCodexAppServerClientRequestScope({
|
|
631
722
|
lease: clientLease,
|
|
632
723
|
options: clientOptions,
|
|
633
|
-
run: async (requestClient,
|
|
724
|
+
run: async (requestClient, connectionRequestOptions) => {
|
|
725
|
+
const requestOptions = () => {
|
|
726
|
+
const options = connectionRequestOptions();
|
|
727
|
+
return {
|
|
728
|
+
...options,
|
|
729
|
+
withCurrent: async (write) => {
|
|
730
|
+
await assertCurrent();
|
|
731
|
+
options.assertCurrent();
|
|
732
|
+
write();
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
};
|
|
634
736
|
const threadRequest = await buildConversationThreadRequestForClient(requestClient, threadRequestRuntime, serviceTier, requestOptions);
|
|
635
737
|
if (networkProxyBindingChanged) return await requestClient.request("thread/start", {
|
|
636
738
|
...threadRequest,
|
|
637
739
|
developerInstructions: CODEX_CONVERSATION_THREAD_DEVELOPER_INSTRUCTIONS,
|
|
638
740
|
experimentalRawEvents: true,
|
|
639
|
-
...
|
|
741
|
+
...incognito ? { ephemeral: true } : {}
|
|
640
742
|
}, requestOptions());
|
|
641
743
|
return await resumeCodexAppServerThread({
|
|
642
744
|
client: requestClient,
|
|
@@ -653,9 +755,6 @@ async function runBoundTurn(params) {
|
|
|
653
755
|
},
|
|
654
756
|
requestResume: (request) => requestClient.request("thread/resume", request, requestOptions())
|
|
655
757
|
});
|
|
656
|
-
},
|
|
657
|
-
onClientChange: (nextClient) => {
|
|
658
|
-
client = nextClient;
|
|
659
758
|
}
|
|
660
759
|
});
|
|
661
760
|
const response = networkProxyBindingChanged ? assertCodexThreadStartResponse(result) : result;
|
|
@@ -675,12 +774,16 @@ async function runBoundTurn(params) {
|
|
|
675
774
|
} else if (networkProxyBindingChanged ? binding.threadId !== threadId : !isSameCodexAppServerThreadOwner(binding, {
|
|
676
775
|
threadId,
|
|
677
776
|
clientId: client.getInstanceId()
|
|
678
|
-
})) await releaseCodexAppServerBindingSubscription(binding, {
|
|
777
|
+
})) await releaseCodexAppServerBindingSubscription(binding, {
|
|
778
|
+
withCurrent,
|
|
779
|
+
retainedClientId: client.getInstanceId()
|
|
780
|
+
});
|
|
679
781
|
const patch = {
|
|
782
|
+
...incognito ? { conversationIncognito: true } : {},
|
|
680
783
|
clientId: client.getInstanceId(),
|
|
681
784
|
cwd: response.thread.cwd ?? (networkProxyBindingChanged ? workspaceDir : binding.cwd),
|
|
682
785
|
model: response.model ?? modelSelection?.model ?? binding.model,
|
|
683
|
-
modelProvider: normalizeCodexAppServerBindingModelProvider({
|
|
786
|
+
modelProvider: await normalizeCodexAppServerBindingModelProvider({
|
|
684
787
|
authProfileId: binding.authProfileId,
|
|
685
788
|
modelProvider: response.modelProvider ?? modelSelection?.modelProvider ?? binding.modelProvider,
|
|
686
789
|
...agentLookup
|
|
@@ -703,8 +806,14 @@ async function runBoundTurn(params) {
|
|
|
703
806
|
kind: "patch",
|
|
704
807
|
threadId: binding.threadId,
|
|
705
808
|
patch
|
|
706
|
-
})) throw new Error(networkProxyBindingChanged ? "Codex conversation binding changed while rotating its thread." : "Codex conversation binding changed while resuming on a new client.");
|
|
809
|
+
}, source)) throw new Error(networkProxyBindingChanged ? "Codex conversation binding changed while rotating its thread." : "Codex conversation binding changed while resuming on a new client.");
|
|
707
810
|
if (networkProxyBindingChanged) useStickyNetworkProfile = runtime.networkProxy !== void 0;
|
|
811
|
+
} else if (incognito && !binding.conversationIncognito) {
|
|
812
|
+
if (!await params.bindingStore.mutate(identity, {
|
|
813
|
+
kind: "patch",
|
|
814
|
+
threadId,
|
|
815
|
+
patch: { conversationIncognito: true }
|
|
816
|
+
}, source)) throw new Error("Codex conversation binding changed while recording its source lifecycle.");
|
|
708
817
|
}
|
|
709
818
|
const turnCollector = createCodexConversationTurnCollector(threadId);
|
|
710
819
|
turnRoute = getCodexAppServerTurnRouter(client).reserveThread({
|
|
@@ -726,7 +835,10 @@ async function runBoundTurn(params) {
|
|
|
726
835
|
...modelSelection?.model ? { model: modelSelection.model } : {},
|
|
727
836
|
personality: CODEX_NATIVE_PERSONALITY_NONE,
|
|
728
837
|
...serviceTier ? { serviceTier } : {}
|
|
729
|
-
}, {
|
|
838
|
+
}, {
|
|
839
|
+
timeoutMs: runtime.requestTimeoutMs,
|
|
840
|
+
withCurrent
|
|
841
|
+
})).turn.id;
|
|
730
842
|
activeTurnCleanup = trackCodexConversationActiveTurn({
|
|
731
843
|
identity,
|
|
732
844
|
client,
|
|
@@ -742,7 +854,7 @@ async function runBoundTurn(params) {
|
|
|
742
854
|
} catch (error) {
|
|
743
855
|
if (isCodexAppServerOverloadError(error) && error.method === "thread/resume") throw error;
|
|
744
856
|
if (error instanceof CodexThreadDirectInputError) {
|
|
745
|
-
if (
|
|
857
|
+
if (incognito && ownsNativeSubscription) {
|
|
746
858
|
if (!await unsubscribeCodexThreadBestEffort(client, {
|
|
747
859
|
threadId,
|
|
748
860
|
timeoutMs: 5e3
|
|
@@ -759,7 +871,7 @@ async function runBoundTurn(params) {
|
|
|
759
871
|
isolatedSubscriptionClient = client;
|
|
760
872
|
}
|
|
761
873
|
}
|
|
762
|
-
if (
|
|
874
|
+
if (incognito) {
|
|
763
875
|
if (await params.bindingStore.mutate(identity, {
|
|
764
876
|
kind: "clear",
|
|
765
877
|
threadId
|
|
@@ -775,7 +887,7 @@ async function runBoundTurn(params) {
|
|
|
775
887
|
activeTurnCleanup();
|
|
776
888
|
turnRoute?.release();
|
|
777
889
|
try {
|
|
778
|
-
if (ownsNativeSubscription && isolatedSubscriptionClient !== client && !
|
|
890
|
+
if (ownsNativeSubscription && isolatedSubscriptionClient !== client && !incognito && isCodexAppServerClientRuntimeLive(client)) {
|
|
779
891
|
const currentLiveThreadOwnership = liveThreadOwnership?.client === client && liveThreadOwnership.threadId === threadId ? liveThreadOwnership.ownership : void 0;
|
|
780
892
|
let retained = false;
|
|
781
893
|
if (turnSucceeded) retained = await params.bindingStore.withLease(identity, async () => {
|