@openclaw/codex 2026.10.5-beta.4 → 2026.10.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/.setup/{account-usage-runtime-CoVpNIlD.mjs → account-usage-runtime-BVO-lpvn.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-tJl5mopa.mjs} +11 -11
- package/dist/.setup/{attempt-client-cleanup-zNuNTKVr.mjs → attempt-client-cleanup-DMJWXGxM.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-BW1YeaIk.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-DfIJtRlv.mjs → bounded-turn-BQkmyyjB.mjs} +18 -22
- package/dist/.setup/{bounded-turn-isolation-BfDAo-qZ.mjs → bounded-turn-isolation-D8CDrAVX.mjs} +3 -3
- package/dist/.setup/{build-state-Ds14X10-.mjs → build-state-CjLCC0wm.mjs} +1 -1
- package/dist/.setup/{capabilities-DbOzOglY.mjs → capabilities-DAS-JX1z.mjs} +1 -1
- package/dist/.setup/{client-D93nbdB8.mjs → client--P8jwXvA.mjs} +47 -317
- package/dist/.setup/{client-catalog-response-CuVLp4I0.mjs → client-catalog-response-CsDxVVOZ.mjs} +2 -2
- package/dist/.setup/client-initialize-CjgZcX61.mjs +165 -0
- package/dist/.setup/{command-dispatch-DxdH5a9-.mjs → command-dispatch-DqaVBeR3.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-i6mEjvfo.mjs} +539 -406
- package/dist/.setup/command-rpc-B65jEc0r.mjs +296 -0
- package/dist/.setup/compact-AO2H4RJe.mjs +823 -0
- package/dist/.setup/{computer-use-DL2v3Kxq.mjs → computer-use-YUnu0JVx.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-CfnUR-IM.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-DOub3CB5.mjs} +208 -218
- package/dist/.setup/{dynamic-tools-CnQFnNKH.mjs → dynamic-tools-Us5mvq_N.mjs} +344 -118
- package/dist/.setup/{effective-mcp-catalog-B5HKFZNK.mjs → effective-mcp-catalog-DfUUoeeM.mjs} +11 -9
- package/dist/.setup/{ephemeral-turn-De3qb8EQ.mjs → ephemeral-turn-B2z0RIeF.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-HRw3PDwn.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-CiLbHMLf.mjs} +8 -8
- package/dist/.setup/installed-probe-lVC1X5ve.mjs +185 -0
- package/dist/.setup/{isolated-completion-BPJdvk5F.mjs → isolated-completion-CybgD6uU.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-zUgpDLWR.mjs} +18 -14
- package/dist/.setup/{model-catalog-ZNwltCKl.mjs → model-catalog-CWY3wo0B.mjs} +28 -17
- package/dist/.setup/{models-BHpbAuz8.mjs → models-CmOBxsKF.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-CocOW9YS.mjs} +45 -10
- package/dist/.setup/{native-mcp-app-DX3nyTtc.mjs → native-mcp-app-DrQeLxXj.mjs} +5 -5
- package/dist/.setup/{native-skill-isolation-DSBeF-Yy.mjs → native-skill-isolation-DL4-PQa4.mjs} +7 -7
- package/dist/.setup/{native-subagent-monitor-DOLEIf9r.mjs → native-subagent-monitor-C3CIIaZG.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-Bqj6VQvQ.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-CGEiG7hG.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-LWKll6dV.mjs → provider-C_1fMsyD.mjs} +4 -4
- package/dist/.setup/{provider-capabilities-Dn2WwH4P.mjs → provider-capabilities-C7pYYpvh.mjs} +1 -1
- package/dist/.setup/{rate-limits-CI8pTPqL.mjs → rate-limits-BpfURnuy.mjs} +1 -1
- package/dist/.setup/{request-Bo0kKABI.mjs → request-C6U8q2uz.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-BhuXanLv.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-DCN1FcBZ.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-CEi6SuLQ.mjs} +5 -5
- package/dist/.setup/{session-catalog-index-order-CTfoefow.mjs → session-catalog-index-order-0Zqng2u8.mjs} +1 -1
- package/dist/.setup/{session-catalog-index-CrnfVEnT.mjs → session-catalog-index-qt4UWBua.mjs} +96 -271
- 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-BqBYi6kV.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-CNyhjZze.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-z_mNyQdX.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-RZStisKb.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-gioXygEX.mjs} +8 -8
- package/dist/.setup/{shared-client-BCx1wbyA.mjs → shared-client-CkyTrNB8.mjs} +380 -557
- package/dist/.setup/side-question-DHPWKgO3.mjs +998 -0
- package/dist/.setup/{source-DipMO9hL.mjs → source-63MLSmLJ.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-zCXYFW8W.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-Bmk5a2Gu.mjs} +7 -7
- package/dist/.setup/{thread-policy-B3wBRNph.mjs → thread-policy-DYtvZ5Ay.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-vBShG3-o.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-BGj67FMK.mjs} +2 -2
- package/dist/.setup/{upstream-session-fork-p5fwKi7w.mjs → upstream-session-fork-CWKjpdtW.mjs} +46 -219
- package/dist/.setup/{usage-C2Kq7oej.mjs → usage-AhrLFxZP.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-BQX8RHAd.mjs → usage-limit-error-BdNbGJC3.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-Yk6lnJBG.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,66 +1,65 @@
|
|
|
1
1
|
import { n as readCodexRuntimeModelId } from "./model-runtime-BdqzOMkU.mjs";
|
|
2
|
-
import { g as createCodexNativeSubagentHistoryOwner } from "./native-subagent-pending-assignments-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as defineCodexBuildState } from "./build-state-
|
|
2
|
+
import { g as createCodexNativeSubagentHistoryOwner } from "./native-subagent-pending-assignments-CTinVtjo.mjs";
|
|
3
|
+
import { n as flattenCodexDynamicToolFunctions, r as isJsonObject, t as CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE } from "./protocol-CaPAVwe9.mjs";
|
|
4
|
+
import { g as sessionBindingIdentity, i as matchesCodexNativeSubagentSubmissionBinding, n as assertCodexBindingMayBeReplaced } from "./session-binding-record-C_THntMe.mjs";
|
|
5
|
+
import { n as defineCodexBuildState } from "./build-state-CjLCC0wm.mjs";
|
|
6
6
|
import { c as withMcpElicitationsApprovalPolicy, d as readCodexRequirementsToml, n as hasCodexMcpToolApprovalOverrides, s as shouldAutoApproveCodexAppServerApprovals } from "./config-security-clxAZYWX.mjs";
|
|
7
7
|
import { c as isCodexPairedNodeRemoteExecPlacementSandbox, d as readCodexPluginConfig, f as resolveCodexPluginsPolicy, l as isCodexRemoteExecPlacementSandbox, u as isCodexSandboxExecServerEnabled } from "./config-parsing-DsWSCPHO.mjs";
|
|
8
8
|
import { n as isCodexAppServerProxyLaunch } from "./launch-args-DbFCehO7.mjs";
|
|
9
9
|
import { t as resolveCodexAppServerHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
|
|
10
|
-
import { i as resolveCodexAppServerHomeScope, l as resolveCodexModelBackedReviewerPolicyContext, o as resolveCodexComputerUseConfig } from "./config-options-
|
|
11
|
-
import {
|
|
12
|
-
import { i as withCodexAppServerGitConfig } from "./transport-stdio-
|
|
13
|
-
import { o as formatCodexDisplayText } from "./command-formatters-
|
|
14
|
-
import { a as codexPrewriteRejectionCause,
|
|
10
|
+
import { i as resolveCodexAppServerHomeScope, l as resolveCodexModelBackedReviewerPolicyContext, o as resolveCodexComputerUseConfig } from "./config-options-DMFZkd3X.mjs";
|
|
11
|
+
import { D as retireSharedCodexAppServerClientIfCurrent, _ as observeAcquire, c as resolveCodexAppServerPreparedApiKeyCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey } from "./auth-cache-key-BW1YeaIk.mjs";
|
|
12
|
+
import { i as withCodexAppServerGitConfig } from "./transport-stdio-Bq160Dhv.mjs";
|
|
13
|
+
import { o as formatCodexDisplayText } from "./command-formatters-B_7-QZ1c.mjs";
|
|
14
|
+
import { a as codexPrewriteRejectionCause, r as CodexAppServerRpcError } from "./rpc-error-DemqqaxE.mjs";
|
|
15
15
|
import { n as waitForPromiseOrAbort } from "./timeout-D0mEWSGG.mjs";
|
|
16
16
|
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
17
|
-
import { i as readCodexProviderRefusal, n as extractRawResponseItemText, o as readItem, r as readCodexErrorNotificationMessage, s as readNullableString } from "./event-projector-values-
|
|
17
|
+
import { i as readCodexProviderRefusal, n as extractRawResponseItemText, o as readItem, r as readCodexErrorNotificationMessage, s as readNullableString } from "./event-projector-values-yf4us9Pf.mjs";
|
|
18
18
|
import { i as readMirrorIdentity, n as attachCodexMirrorIdentity, t as attachCodexAssistantItemIds } from "./upstream-prompt-provenance-Ccd9MFRJ.mjs";
|
|
19
|
-
import { n as buildCodexAppServerRuntimeFingerprint, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-
|
|
20
|
-
import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection, t as assertCodexSessionRuntimeOwnership } from "./binding-connection-
|
|
21
|
-
import { n as
|
|
22
|
-
import {
|
|
23
|
-
import { a as isCodexDurableCustomMessage, c as resolveCodexContextEngineProjectionMaxChars, i as fitCodexProjectedContextForTurnStart, l as resolveCodexContinuityProjectionMaxChars, n as CodexContextAttachmentError, o as neutralizeCodexExplicitMentionSigils, r as buildCodexContinuityCalibration, s as projectContextEngineAssemblyForCodex, t as CODEX_TURN_START_TEXT_INPUT_MAX_CHARS, u as resolveProjectionPromptBudgetTokens } from "./context-engine-projection-
|
|
19
|
+
import { n as buildCodexAppServerRuntimeFingerprint, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-DRb-niJc.mjs";
|
|
20
|
+
import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection, t as assertCodexSessionRuntimeOwnership } from "./binding-connection-GTgUj9pi.mjs";
|
|
21
|
+
import { n as canUseCodexModelBackedApprovalsReviewerForModel, r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-BfrAlTMT.mjs";
|
|
22
|
+
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-7W0cgTXF.mjs";
|
|
23
|
+
import { a as isCodexDurableCustomMessage, c as resolveCodexContextEngineProjectionMaxChars, i as fitCodexProjectedContextForTurnStart, l as resolveCodexContinuityProjectionMaxChars, n as CodexContextAttachmentError, o as neutralizeCodexExplicitMentionSigils, r as buildCodexContinuityCalibration, s as projectContextEngineAssemblyForCodex, t as CODEX_TURN_START_TEXT_INPUT_MAX_CHARS, u as resolveProjectionPromptBudgetTokens } from "./context-engine-projection-PIeLSnR-.mjs";
|
|
24
24
|
import { a as buildCodexMirrorIdempotencyKey, i as buildCodexMirrorDedupeIdentity, s as hasCodexMirrorOrigin, t as applyCodexTranscriptTaint } from "./transcript-mirror-attestation-BzUXnrvv.mjs";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { a as
|
|
29
|
-
import {
|
|
30
|
-
import { n as
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import { r as
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import { i as
|
|
39
|
-
import {
|
|
40
|
-
import { a as resolveCodexPromptError, i as refreshCodexUsageLimitPromptError, n as formatCodexTurnStartUsageLimitError, r as markCodexAuthProfileBlockedFromRateLimits, t as CodexUsageLimitPromptError } from "./usage-limit-error-BQX8RHAd.mjs";
|
|
41
|
-
import { c as withExclusiveCodexAppServerThread, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-BoUd0i6L.mjs";
|
|
25
|
+
import { i as resolveCodexAppServerAuthProfileIdForAgent, r as resolveCodexAppServerAuthProfileId } from "./auth-profile-auwzSwwy.mjs";
|
|
26
|
+
import { C as getCodexInferenceThread, F as prepareCodexWorkspaceReferences, I as protectCodexAppServerLiveThread, J as recordCodexTurnForkSettings, O as ensureCodexAppServerClientRuntime, Q as resolveCodexAppServerPreparedAuthHandoff, U as readCodexRateLimitsRevision, W as readRecentCodexRateLimits, Z as resolveCodexAppServerAuthAccountCacheKey, a as createIsolatedCodexAppServerClient, ct as TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS, dt as resolveCodexStartupTimeoutMs, f as releaseLeasedSharedCodexAppServerClient, ft as withCodexStartupTimeout, l as readCodexAppServerClientDesktopGenerationFingerprint, o as getLeasedSharedCodexAppServerClient, ot as CodexAppServerStartupError, p as retainSharedCodexAppServerClientIfCurrent, r as clearSharedCodexAppServerClientIfCurrentAndUnclaimed, s as getSharedCodexAppServerClient, st as TURN_FINALIZE_DRAIN_ABORT_GRACE_MS, v as CodexThreadClientReplacementError, w as getCodexInferenceThreadQualification } from "./shared-client-CkyTrNB8.mjs";
|
|
27
|
+
import { a as isCodexResponsesOAuthRun, r as isCodexResponsesOAuth } from "./responses-oauth-CCV7aVYF.mjs";
|
|
28
|
+
import { C as createCodexElicitationResponse, D as toCodexDynamicToolProtocolResponse, E as toCodexDynamicToolProgressResponse, P as resolveCodexAppServerClientInstanceId, T as resolveDynamicToolCallTimeoutMs, a as isCodexAppServerIndeterminateTransportError, b as readCodexTurnCompletedNotification, c as CodexServerRequestResolvedError, g as assertCodexTurnStartResponse, i as isCodexAppServerIndeterminateRequestCancellationError, j as readCodexAppServerWarningMessage, r as isCodexAppServerApprovalRequest, v as readCodexDynamicToolCallParams, w as handleDynamicToolCallWithTimeout } from "./client--P8jwXvA.mjs";
|
|
29
|
+
import { s as CODEX_APP_SERVER_OPT_OUT_NOTIFICATION_METHODS } from "./client-initialize-CjgZcX61.mjs";
|
|
30
|
+
import { S as shouldClearTerminalPresentationForNativeItem, _ as itemName, a as isCodexNotificationForTurn, b as matchesCodexSnapshotTurn, i as CodexProjectionDiagnostics, n as getCodexAppServerTurnRouter, o as readCodexNotificationScope, s as readCodexNotificationThreadId, t as CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS, x as shouldAdvancePersistableAssistantBarrier } from "./turn-router-BGj67FMK.mjs";
|
|
31
|
+
import { d as terminateCodexBackgroundTerminals, f as unsubscribeCodexThreadBestEffort, l as retireUnsafeCodexTurnClientBestEffort, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, o as closeCodexStartupClientBestEffort, r as CodexAppServerUnsafeSubscriptionError, s as interruptCodexTurnAndWaitBestEffort, u as shouldRetireCodexStartupClient } from "./attempt-client-cleanup-DMJWXGxM.mjs";
|
|
32
|
+
import { r as prepareCodexAppServerAuthBinding } from "./auth-binding-830RLAJW.mjs";
|
|
33
|
+
import { a as isRawFunctionToolOutputCompletionNotification, c as readRawResponseToolCallId, i as isCodexTurnAbortMarkerNotification, l as updateActiveTurnItemIds, o as isTerminalTurnStatus, r as completePendingOpenClawDynamicToolNotification, s as readCodexNotificationItem, t as CodexUsageProjection } from "./event-projector-usage-CBY0Hkga.mjs";
|
|
34
|
+
import { d as mergeCodexThreadConfigs } from "./project-doc-thread-config-B0UI3f1D.mjs";
|
|
35
|
+
import { B as resolveCodexDynamicToolsLoadingForRuntime, L as isSystemAgentOnlyCodexDynamicToolAllowlist, P as filterCodexDynamicTools, V as joinPresentSections, _ as buildDeveloperInstructions, b as codexDynamicToolsFingerprint, h as resolveCodexWebSearchPlan, k as stabilizeJsonValue, l as isCodexNativeDelegationDisabledForRun, v as areCodexDynamicToolFingerprintsCompatible, w as fingerprintJsonObject, x as codexLegacyDynamicToolsFingerprint } from "./thread-requests-BjawdIVV.mjs";
|
|
36
|
+
import { i as resolveCodexSessionBinding, n as createCodexSessionGenerationSupersededError, t as clearCodexBindingForClient } from "./session-binding-BgsWcbdY.mjs";
|
|
37
|
+
import { i as resolveCodexAppServerThreadModelSelection } from "./thread-model-selection-DxposL4X.mjs";
|
|
38
|
+
import { a as resolveCodexPromptError, i as refreshCodexUsageLimitPromptError, n as formatCodexTurnStartUsageLimitError, r as markCodexAuthProfileBlockedFromRateLimits, t as CodexUsageLimitPromptError } from "./usage-limit-error-BdNbGJC3.mjs";
|
|
39
|
+
import { c as withExclusiveCodexAppServerThread, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-Bmk5a2Gu.mjs";
|
|
42
40
|
import { t as persistCodexContextCompactionActivity } from "./context-compaction-activity-CMla5FPJ.mjs";
|
|
43
|
-
import { a as CodexToolTranscriptProjection, c as
|
|
44
|
-
import { a as requestPluginApprovalOutcome } from "./plugin-approval-roundtrip-
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import { t as
|
|
49
|
-
import "./inference-
|
|
50
|
-
import
|
|
51
|
-
import {
|
|
52
|
-
import { a as
|
|
53
|
-
import { a as
|
|
41
|
+
import { a as CodexToolTranscriptProjection, c as asCodexToolArguments, i as emitCodexAgentEvent, l as isCodexCommandBearingToolCall, o as CodexToolProgressProjection, r as CodexEventProjection, s as shouldEmitTranscriptToolProgress, t as codexNativeSubagentMonitorRuntime, u as resolveCodexToolProgressDetailMode } from "./native-subagent-monitor-C3CIIaZG.mjs";
|
|
42
|
+
import { a as requestPluginApprovalOutcome } from "./plugin-approval-roundtrip-CGEiG7hG.mjs";
|
|
43
|
+
import { r as prepareCodexNativeExecutionPolicyForRun } from "./native-execution-policy-D09tLP-u.mjs";
|
|
44
|
+
import { n as CodexThreadPolicyHandoffError, s as restoreCodexThreadInstructionsAfterCompaction } from "./thread-policy-DYtvZ5Ay.mjs";
|
|
45
|
+
import { t as attemptTerminal } from "./attempt-terminal-sZutF0WY.mjs";
|
|
46
|
+
import { a as runCodexAgentEndHook, c as withCodexAppServerFastModeServiceTier, i as reportCodexBackgroundCleanupFailure, n as ensureCodexWorkspaceDirOnce, o as runCodexCleanupStep, r as estimateCodexAppServerProjectedTurnTokens, s as shouldKeepCodexSharedAbortOpen, t as emitCodexAppServerEvent } from "./run-attempt-lifecycle-DN-ATDp9.mjs";
|
|
47
|
+
import { t as CODEX_INFERENCE_GENERATION_KEY } from "./inference-metadata-CYFWLHVk.mjs";
|
|
48
|
+
import "./inference-context-HRw3PDwn.mjs";
|
|
49
|
+
import { i as createAssistantReasoningMessage, n as createAssistantCommentaryMessage, r as createAssistantMessage, t as createAssistantAsyncDelivery } from "./event-projector-assistant-message-ChOAY7rW.mjs";
|
|
50
|
+
import { a as resolveCodexExternalSandboxPolicyForOpenClawSandbox, c as shouldEnableCodexAppServerNativeToolSurface, i as resolveCodexAppServerHookChannelId, l as shouldRequireCodexSandboxExecServerEnvironment, o as resolveCodexMessageToolProvider, p as mapCodexAppServerRemoteWorkspacePath, r as resolveCodexAppServerExecutionCwd, s as resolveCodexSandboxEnvironmentSelection, t as buildDynamicTools, u as shouldWarnCodexDynamicToolBuildStageSummary } from "./dynamic-tool-build-DOub3CB5.mjs";
|
|
51
|
+
import { a as buildCodexNativeHookRelayDisabledConfig, d as scheduleCodexNativeHookRelayUnregister, i as buildCodexNativeHookRelayConfig, l as resolveCodexNativeHookRelayEvents, n as CodexManagedHooksOnlyError, r as assertCodexNativeHookRelayAllowed, s as createCodexNativeHookRelay, t as CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS, u as resolveCodexNativeHookRelayTtlMs } from "./native-hook-relay-CocOW9YS.mjs";
|
|
52
|
+
import { a as prepareCodexPluginThreadConfigStartupProvider, c as buildLegacyScheduledCodexAppRecoveryPrompt, d as resolveScheduledCodexAppCreatorCaptureDecision, i as isContextEngineBindingCompatible, l as buildScheduledCodexAppServerConnectionIdentity, n as isCodexAppServerProfilerEnabled, o as resolveCodexPluginThreadConfigStartupPolicy, r as buildContextEngineBinding, s as assertScheduledCodexAppAuthorityRuntime, t as startOrResumeThread, u as captureScheduledCodexAppAuthority } from "./thread-lifecycle-run-zCXYFW8W.mjs";
|
|
54
53
|
import { i as resolveCodexSessionPermissionCwd, n as applyCodexSessionPermissionPolicy, r as resolveCodexEffectiveSessionPermissionPolicy } from "./session-permission-policy-CD2MAWU8.mjs";
|
|
55
|
-
import { o as hasCodexNativeToolCatalog, s as loadCodexNativeToolCatalog } from "./native-skill-isolation-
|
|
56
|
-
import { r as prepareCodexNativeMcpFormResourceContext, t as createCodexNativeMcpAppResultDetailsPreparer } from "./native-mcp-app-
|
|
57
|
-
import { _ as invalidateCodexComputerFrame, a as handleCodexAppServerApprovalRequest, c as createCodexNativePreToolUseFailureBuffer, f as buildTurnCollaborationMode, g as buildCodexUserInput, h as readCodexRetainedBackgroundCommands, i as createCodexDynamicToolDiagnostics, l as buildCodexHistoryProvenancePrefix, m as CodexNativeProcessAuthority, n as projectCodexExecutableDynamicTools, o as ensureCodexSandboxExecServerEnvironment, p as buildTurnStartParams, r as routeCodexAppServerElicitationRequest, s as releaseCodexSandboxExecServerEnvironment, t as createCodexDynamicToolBridge, u as buildCodexParentLocalInstructions, v as createCodexRemoteWorkspaceFileReader, y as CodexNativeToolLifecycleProjector } from "./dynamic-tools-
|
|
58
|
-
import { c as promptSnapshot, i as mirrorPromptAtTurnStartBestEffort, n as createCodexAppServerUserMessagePersistenceNotifier, o as buildCodexUserPromptMessage, s as buildResolvedCodexUserPromptMessage, t as codexTranscriptMirrorRuntime } from "./transcript-mirror-
|
|
59
|
-
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-
|
|
60
|
-
import { a as getCodexContextFileDisplayBasename, i as getCodexContextFileBasename, n as CODEX_NATIVE_PROJECT_DOC_BASENAMES, o as isNonEmptyString, r as buildCodexWorkspaceBootstrapContext, s as normalizeCodexContextFilePath } from "./attempt-workspace-context-
|
|
54
|
+
import { o as hasCodexNativeToolCatalog, s as loadCodexNativeToolCatalog } from "./native-skill-isolation-DL4-PQa4.mjs";
|
|
55
|
+
import { r as prepareCodexNativeMcpFormResourceContext, t as createCodexNativeMcpAppResultDetailsPreparer } from "./native-mcp-app-DrQeLxXj.mjs";
|
|
56
|
+
import { _ as invalidateCodexComputerFrame, a as handleCodexAppServerApprovalRequest, c as createCodexNativePreToolUseFailureBuffer, f as buildTurnCollaborationMode, g as buildCodexUserInput, h as readCodexRetainedBackgroundCommands, i as createCodexDynamicToolDiagnostics, l as buildCodexHistoryProvenancePrefix, m as CodexNativeProcessAuthority, n as projectCodexExecutableDynamicTools, o as ensureCodexSandboxExecServerEnvironment, p as buildTurnStartParams, r as routeCodexAppServerElicitationRequest, s as releaseCodexSandboxExecServerEnvironment, t as createCodexDynamicToolBridge, u as buildCodexParentLocalInstructions, v as createCodexRemoteWorkspaceFileReader, y as CodexNativeToolLifecycleProjector } from "./dynamic-tools-Us5mvq_N.mjs";
|
|
57
|
+
import { c as promptSnapshot, i as mirrorPromptAtTurnStartBestEffort, n as createCodexAppServerUserMessagePersistenceNotifier, o as buildCodexUserPromptMessage, s as buildResolvedCodexUserPromptMessage, t as codexTranscriptMirrorRuntime } from "./transcript-mirror-CEQJZlF3.mjs";
|
|
58
|
+
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-Cog6mm2i.mjs";
|
|
59
|
+
import { a as getCodexContextFileDisplayBasename, i as getCodexContextFileBasename, n as CODEX_NATIVE_PROJECT_DOC_BASENAMES, o as isNonEmptyString, r as buildCodexWorkspaceBootstrapContext, s as normalizeCodexContextFilePath } from "./attempt-workspace-context-GYPLawX6.mjs";
|
|
61
60
|
import { n as captureCodexSettledTurnFinalizationContext } from "./settled-turn-context-BPL6D3RO.mjs";
|
|
62
|
-
import { t as resolveCodexProviderWebSearchSupport } from "./provider-capabilities-
|
|
63
|
-
import { a as runCodexComputerUseLiveTest, i as createComputerUseRequest, t as ensureCodexComputerUse } from "./computer-use-
|
|
61
|
+
import { t as resolveCodexProviderWebSearchSupport } from "./provider-capabilities-C7pYYpvh.mjs";
|
|
62
|
+
import { a as runCodexComputerUseLiveTest, i as createComputerUseRequest, t as ensureCodexComputerUse } from "./computer-use-YUnu0JVx.mjs";
|
|
64
63
|
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, readNonBlankString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
65
64
|
import { createHash, randomUUID } from "node:crypto";
|
|
66
65
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -70,23 +69,23 @@ import { truncateUtf16Safe, truncateUtf8Prefix } from "openclaw/plugin-sdk/text-
|
|
|
70
69
|
import path from "node:path";
|
|
71
70
|
import fs from "node:fs/promises";
|
|
72
71
|
import { isPathStrictlyInside, readFileWindowFully, root } from "openclaw/plugin-sdk/file-access-runtime";
|
|
72
|
+
import { createStageTimingTracker, formatStageTimings } from "openclaw/plugin-sdk/time-runtime";
|
|
73
73
|
import { addAbortListener } from "node:events";
|
|
74
74
|
import { isIncognitoSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
|
|
75
75
|
import { Type } from "typebox";
|
|
76
76
|
import { createDiagnosticTraceContextFromActiveScope, emitTrustedDiagnosticEvent, emitTrustedDiagnosticEventWithPrivateData, freezeDiagnosticTraceContext, onInternalDiagnosticEvent, resolveDiagnosticModelContentCapturePolicy } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
77
77
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
78
|
-
import { createStageTimingTracker, formatStageTimings } from "openclaw/plugin-sdk/time-runtime";
|
|
79
78
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
80
79
|
import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
|
|
81
80
|
import { AgentHarnessPreflightError, CODEX_APP_SERVER_CONTEXT_ENGINE_HOST, FAST_MODE_AUTO_PROGRESS_KIND, HEARTBEAT_RESPONSE_TOOL_NAME, agentHarnessStructuredInput, applyEmbeddedAttemptToolsAllow, assembleHarnessContextEngine, assertContextEngineHostSupport, bootstrapHarnessContextEngine, buildAgentHookContextChannelFields, buildEmbeddedForegroundPromptContext, buildHarnessContextEngineRuntimeContext, cancelPendingAgentQuestionForSession, claimPendingAgentQuestionAnswer, classifyAgentHarnessTerminalOutcome, clearActiveEmbeddedRun, detectAndLoadAgentHarnessPromptImages, embeddedAgentLog, emptyAgentHarnessUserInputAnswers, formatErrorMessage, formatFastModeAutoProgressText, getAgentHarnessHookRunner, hasBeforeToolCallPolicy, inferToolMetaFromArgs, isActiveHarnessContextEngine, isHostScopedAgentToolActive, loadCodexBundleMcpThreadConfig, materializeRequesterScopedMcpToolsForHarnessRun, normalizeHeartbeatToolResponse, prepareWatchedSessionsHarnessContext, projectAgentHarnessTranscriptMessageForDisplay, projectAgentToolActivity, projectProgressCardChannelUpdate, resolveAgentDir as resolveAgentDir$2, resolveAgentHarnessBeforePromptBuildResult, resolveAgentRunAbortLifecycleFields, resolveAttemptFsWorkspaceOnly, resolveContextEngineOwnerPluginId, resolveFastModeForElapsed, resolveSandboxContext, resolveUserPath, runAgentHarnessAfterCompactionHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
82
|
-
import {
|
|
81
|
+
import { loadExecApprovalsReadOnlyAsync } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
83
82
|
import { AgentHarnessProjectionSettlement, createAgentHarnessAttemptCancellation, createAgentHarnessAttemptDeadlineController, createAgentHarnessAttemptLifecycle, shouldIncludeAgentHarnessRuntimeContext } from "openclaw/plugin-sdk/agent-harness-attempt-runtime";
|
|
84
|
-
import {
|
|
83
|
+
import { getSessionEntryAsync, prepareSessionEntryPatch, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
84
|
+
import { appendSessionYieldContext, composeSessionTranscriptWriteAssertion, hasPromptImageInput } from "openclaw/plugin-sdk/session-transcript-runtime";
|
|
85
85
|
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
86
|
-
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
87
86
|
import { acknowledgeInternalToolResult, createAgentHarnessToolExecutionRegistry } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
87
|
+
import { createNativeSessionBindingScope, createPreparedNativeSessionBindingAuthority, retainNativeSessionGenerationAuthority } from "openclaw/plugin-sdk/agent-harness-session-runtime";
|
|
88
|
+
import { captureSessionEntryCurrentCheckAsync } from "openclaw/plugin-sdk/session-binding-runtime";
|
|
90
89
|
import { captureFinalCodexCronCreatorToolAllowlist, formatMcpCodexApprovalRemedy, materializeStaticMcpToolsForHarnessRun, resolveCodexMcpToolOverridesForAgent, resolveCodexTtsProvenanceTransfer } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
91
90
|
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-local-roots";
|
|
92
91
|
import { isSilentReplyPayloadText } from "openclaw/plugin-sdk/reply-chunking";
|
|
@@ -156,10 +155,7 @@ function createCodexQuestionInputHandlers(sessionKey, assertActive) {
|
|
|
156
155
|
sessionKey,
|
|
157
156
|
text,
|
|
158
157
|
authority: questionAuthority(authorityKind, assertCurrent, toolAuthorityPreparation),
|
|
159
|
-
sourceRecorder: optionsLocal.userTurnTranscriptRecorder
|
|
160
|
-
persist: optionsLocal.userTurnTranscriptRecorder ? async () => {
|
|
161
|
-
await optionsLocal.userTurnTranscriptRecorder?.persistApproved();
|
|
162
|
-
} : void 0
|
|
158
|
+
sourceRecorder: optionsLocal.userTurnTranscriptRecorder
|
|
163
159
|
});
|
|
164
160
|
};
|
|
165
161
|
const cancelPendingUserInput = (resolvedBy, assertCurrent, authorityKind = assertCurrent ? "source-bound" : "run", toolAuthorityPreparation) => cancelPendingAgentQuestionForSession({
|
|
@@ -536,12 +532,13 @@ var CodexSteeringAssistantSegments = class {
|
|
|
536
532
|
//#endregion
|
|
537
533
|
//#region extensions/codex/src/app-server/event-projector-assistant.ts
|
|
538
534
|
var CodexAssistantProjection = class {
|
|
539
|
-
constructor(params, emitAgentEvent, matchesToolProgressEcho, nextTranscriptTimestamp, checkpointCommentary) {
|
|
535
|
+
constructor(params, emitAgentEvent, matchesToolProgressEcho, nextTranscriptTimestamp, checkpointCommentary, hasDeliveredFinalSourceReply) {
|
|
540
536
|
this.params = params;
|
|
541
537
|
this.emitAgentEvent = emitAgentEvent;
|
|
542
538
|
this.matchesToolProgressEcho = matchesToolProgressEcho;
|
|
543
539
|
this.nextTranscriptTimestamp = nextTranscriptTimestamp;
|
|
544
540
|
this.checkpointCommentary = checkpointCommentary;
|
|
541
|
+
this.hasDeliveredFinalSourceReply = hasDeliveredFinalSourceReply;
|
|
545
542
|
this.assistantTextByItem = /* @__PURE__ */ new Map();
|
|
546
543
|
this.assistantItemOrder = [];
|
|
547
544
|
this.assistantTimestampByItem = /* @__PURE__ */ new Map();
|
|
@@ -565,7 +562,7 @@ var CodexAssistantProjection = class {
|
|
|
565
562
|
async handleAssistantDelta(params) {
|
|
566
563
|
const itemId = readStringField(params, "itemId") ?? "assistant";
|
|
567
564
|
const delta = readStringField(params, "delta") ?? "";
|
|
568
|
-
if (!delta) return;
|
|
565
|
+
if (!delta || this.hasDeliveredFinalSourceReply?.()) return;
|
|
569
566
|
if (itemId !== this.pendingRawTerminalAssistantEchoItemId) this.pendingRawTerminalAssistantEchoItemId = void 0;
|
|
570
567
|
const isCommentary = this.isCommentaryAssistantItem(itemId);
|
|
571
568
|
const isAsync = this.isAsyncAssistantItem(itemId);
|
|
@@ -574,6 +571,7 @@ var CodexAssistantProjection = class {
|
|
|
574
571
|
this.assistantStarted = true;
|
|
575
572
|
await this.params.onAssistantMessageStart?.();
|
|
576
573
|
}
|
|
574
|
+
if (this.hasDeliveredFinalSourceReply?.()) return;
|
|
577
575
|
this.rememberAssistantItem(itemId);
|
|
578
576
|
const text = `${this.assistantTextByItem.get(itemId) ?? ""}${delta}`;
|
|
579
577
|
this.assistantTextByItem.set(itemId, text);
|
|
@@ -606,6 +604,7 @@ var CodexAssistantProjection = class {
|
|
|
606
604
|
if (knownFinalAnswer && !replaceable) await this.params.onPartialReply?.(streamPayload);
|
|
607
605
|
}
|
|
608
606
|
async recordItemStarted(item, itemId) {
|
|
607
|
+
if (item?.type === "agentMessage" && this.hasDeliveredFinalSourceReply?.()) return;
|
|
609
608
|
this.noteNativeWorkBarrier(item);
|
|
610
609
|
this.rememberAssistantPhase(item);
|
|
611
610
|
if (item?.type === "agentMessage" && itemId && !this.isNonTerminalAssistantItem(itemId) && itemId !== this.pendingRawTerminalAssistantEchoItemId) this.pendingRawTerminalAssistantEchoItemId = void 0;
|
|
@@ -620,6 +619,7 @@ var CodexAssistantProjection = class {
|
|
|
620
619
|
});
|
|
621
620
|
}
|
|
622
621
|
recordItemCompleted(item, notification) {
|
|
622
|
+
if (item?.type === "agentMessage" && this.hasDeliveredFinalSourceReply?.()) return;
|
|
623
623
|
this.adoptSteeringPrefixForCompletion(item);
|
|
624
624
|
if (item?.type === "agentMessage" && (!notification || notification.itemId)) this.steeringSegments.recordCompletion(notification?.itemId ?? item.id);
|
|
625
625
|
if (notification) this.noteNativeWorkBarrier(item);
|
|
@@ -660,7 +660,7 @@ var CodexAssistantProjection = class {
|
|
|
660
660
|
const isPendingTerminalAssistantEcho = role === "assistant" && phase !== "commentary" && pendingTerminalAssistantEchoItemId !== void 0 && (rawItemId === void 0 || rawItemId === pendingTerminalAssistantEchoItemId);
|
|
661
661
|
if (pendingTerminalAssistantEchoItemId !== void 0 && !isPendingTerminalAssistantEcho) this.pendingRawTerminalAssistantEchoItemId = void 0;
|
|
662
662
|
if (!isPendingTerminalAssistantEcho) this.markTerminalAssistantCandidateSupersededBy(rawItemId);
|
|
663
|
-
if (role !== "assistant") return;
|
|
663
|
+
if (role !== "assistant" || this.hasDeliveredFinalSourceReply?.()) return;
|
|
664
664
|
if (phase === "commentary" && this.pendingRawCommentaryEchoes > 0) {
|
|
665
665
|
this.pendingRawCommentaryEchoes -= 1;
|
|
666
666
|
return;
|
|
@@ -756,7 +756,7 @@ var CodexAssistantProjection = class {
|
|
|
756
756
|
this.persistedAssistantBoundary = true;
|
|
757
757
|
}
|
|
758
758
|
finalizeAnswerCandidate(turn) {
|
|
759
|
-
if (turn.status !== "completed") {
|
|
759
|
+
if (turn.status !== "completed" || this.hasDeliveredFinalSourceReply?.()) {
|
|
760
760
|
this.supersedeVisibleAnswerCandidate();
|
|
761
761
|
return;
|
|
762
762
|
}
|
|
@@ -957,15 +957,7 @@ var CodexAssistantProjection = class {
|
|
|
957
957
|
});
|
|
958
958
|
}
|
|
959
959
|
createAsyncDelivery(itemId) {
|
|
960
|
-
|
|
961
|
-
const text = this.assistantTextByItem.get(itemId);
|
|
962
|
-
const timestamp = this.assistantTimestampByItem.get(itemId);
|
|
963
|
-
if (!text?.trim() || timestamp === void 0) return;
|
|
964
|
-
return {
|
|
965
|
-
itemId,
|
|
966
|
-
message: createAssistantAsyncMessage(this.params, text, itemId, timestamp, this.assistantQuestionsByItem.get(itemId)),
|
|
967
|
-
text
|
|
968
|
-
};
|
|
960
|
+
return this.isAsyncAssistantItem(itemId) ? createAssistantAsyncDelivery(this.params, this.assistantTextByItem.get(itemId), itemId, this.assistantTimestampByItem.get(itemId), this.assistantQuestionsByItem.get(itemId)) : void 0;
|
|
969
961
|
}
|
|
970
962
|
isToolProgressEchoText(itemId, text) {
|
|
971
963
|
return this.rawPromotedAssistantItemIds.has(itemId) && this.matchesToolProgressEcho(text);
|
|
@@ -997,7 +989,7 @@ var CodexAsyncDeliveryProjection = class {
|
|
|
997
989
|
return [...this.pendingDeliveries.values()];
|
|
998
990
|
}
|
|
999
991
|
async deliver(delivery) {
|
|
1000
|
-
if (this.settledItemIds.has(delivery.itemId)) return;
|
|
992
|
+
if (this.options.hasDeliveredFinalSourceReply?.() || this.settledItemIds.has(delivery.itemId)) return;
|
|
1001
993
|
const settlement = await this.options.onAsyncDelivery?.(delivery);
|
|
1002
994
|
if (settlement === "settled") {
|
|
1003
995
|
this.settledItemIds.add(delivery.itemId);
|
|
@@ -1516,7 +1508,7 @@ var CodexTranscriptCheckpoint = class {
|
|
|
1516
1508
|
});
|
|
1517
1509
|
try {
|
|
1518
1510
|
await codexTranscriptMirrorRuntime.mirror({
|
|
1519
|
-
assertWriteCurrent:
|
|
1511
|
+
assertWriteCurrent: createNativeSessionBindingScope(() => {
|
|
1520
1512
|
if (this.state === "abandoned") throw new Error("Codex transcript checkpoint was retired before write");
|
|
1521
1513
|
}).assertLegacyCurrent,
|
|
1522
1514
|
...this.params.sessionTarget,
|
|
@@ -1597,7 +1589,9 @@ var CodexTurnProjection = class {
|
|
|
1597
1589
|
});
|
|
1598
1590
|
this.toolSearchEvidenceProjection = options.trajectoryRecorder && process.env.OPENCLAW_BUILD_PRIVATE_QA === "1" ? new CodexToolSearchEvidenceProjection(options.trajectoryRecorder, threadId, turnId) : void 0;
|
|
1599
1591
|
this.eventProjection = new CodexEventProjection(params.provider, threadId, turnId, (event) => this.emitAgentEvent(event), this.toolProgressProjection, this.toolTranscriptProjection, options.onNativeToolResultRecorded);
|
|
1600
|
-
this.assistantProjection = new CodexAssistantProjection(this.settlement.params, (event) =>
|
|
1592
|
+
this.assistantProjection = new CodexAssistantProjection(this.settlement.params, (event) => {
|
|
1593
|
+
if (!options.hasDeliveredFinalSourceReply?.()) this.emitAgentEvent(event);
|
|
1594
|
+
}, (text) => this.toolProgressProjection.matchesEcho(text), this.transcriptCheckpoint.nextTimestamp, this.transcriptCheckpoint.enqueueCommentary, options.hasDeliveredFinalSourceReply);
|
|
1601
1595
|
this.reasoningProjection = new CodexReasoningProjection(this.settlement.params, (event) => this.emitAgentEvent(event), options.onNativePlanUpdate);
|
|
1602
1596
|
}
|
|
1603
1597
|
get projectionClosed() {
|
|
@@ -1619,7 +1613,7 @@ var CodexTurnProjection = class {
|
|
|
1619
1613
|
for (const [id, processId] of options?.readRetainedNativeCommands?.() ?? []) if (pending.has(id) && (pending.get(id) === null || pending.get(id) === processId)) retainedCommands.set(id, processId);
|
|
1620
1614
|
}
|
|
1621
1615
|
this.nativeToolLifecycleProjector.finalizeActive(void 0, retainedCommands);
|
|
1622
|
-
const assistantTexts = this.assistantProjection.collectAssistantTexts();
|
|
1616
|
+
const assistantTexts = toolTelemetry.finalSourceReplyDelivered ? [] : this.assistantProjection.collectAssistantTexts();
|
|
1623
1617
|
const asyncMessages = this.assistantProjection.collectAsyncMessages();
|
|
1624
1618
|
const commentaryMessages = this.assistantProjection.collectCommentaryMessages();
|
|
1625
1619
|
const reasoningText = this.reasoningProjection.reasoningText();
|
|
@@ -1650,7 +1644,15 @@ var CodexTurnProjection = class {
|
|
|
1650
1644
|
providerRefusal
|
|
1651
1645
|
};
|
|
1652
1646
|
const lastAssistant = providerRefusal ? this.assistantProjection.createAssistantMessage("", assistantMessageOptions) : assistantTexts.length ? this.assistantProjection.createAssistantMessage(assistantTexts.join("\n\n"), assistantMessageOptions) : void 0;
|
|
1653
|
-
|
|
1647
|
+
let currentAttemptAssistant = toolTelemetry.finalSourceReplyDelivered ? void 0 : providerRefusal ? lastAssistant : this.assistantProjection.createCurrentAttemptAssistantMessage(assistantMessageOptions);
|
|
1648
|
+
if (toolTelemetry.messagingToolSourceReplyPayloads?.some((reply) => reply.toolAuthoredForTurnId === turnId)) {
|
|
1649
|
+
currentAttemptAssistant ??= this.assistantProjection.createAssistantMessage("", assistantMessageOptions);
|
|
1650
|
+
currentAttemptAssistant = {
|
|
1651
|
+
...currentAttemptAssistant,
|
|
1652
|
+
turnId
|
|
1653
|
+
};
|
|
1654
|
+
if (lastAssistant) lastAssistant.turnId = turnId;
|
|
1655
|
+
}
|
|
1654
1656
|
const messagesSnapshot = buildCodexMessagesSnapshot({
|
|
1655
1657
|
runParams,
|
|
1656
1658
|
turnId,
|
|
@@ -1744,6 +1746,15 @@ var CodexTurnProjection = class {
|
|
|
1744
1746
|
//#endregion
|
|
1745
1747
|
//#region extensions/codex/src/app-server/event-projector.ts
|
|
1746
1748
|
const optedOutNotificationMethods = new Set(CODEX_APP_SERVER_OPT_OUT_NOTIFICATION_METHODS);
|
|
1749
|
+
const RAW_TOOL_ITEM_PHASE = {
|
|
1750
|
+
function_call: "started",
|
|
1751
|
+
custom_tool_call: "started",
|
|
1752
|
+
local_shell_call: "started",
|
|
1753
|
+
tool_search_call: "started",
|
|
1754
|
+
function_call_output: "completed",
|
|
1755
|
+
custom_tool_call_output: "completed",
|
|
1756
|
+
tool_search_output: "completed"
|
|
1757
|
+
};
|
|
1747
1758
|
var CodexAppServerEventProjector = class extends CodexTurnProjection {
|
|
1748
1759
|
constructor(..._args) {
|
|
1749
1760
|
super(..._args);
|
|
@@ -2192,6 +2203,17 @@ var CodexAppServerEventProjector = class extends CodexTurnProjection {
|
|
|
2192
2203
|
async handleRawResponseItemCompleted(params) {
|
|
2193
2204
|
const item = isJsonObject(params.item) ? params.item : void 0;
|
|
2194
2205
|
if (!item) return;
|
|
2206
|
+
const type = readStringField(item, "type");
|
|
2207
|
+
const phase = type && Object.hasOwn(RAW_TOOL_ITEM_PHASE, type) ? RAW_TOOL_ITEM_PHASE[type] : void 0;
|
|
2208
|
+
const itemId = readStringField(item, "call_id");
|
|
2209
|
+
if (phase && itemId) this.emitAgentEvent({
|
|
2210
|
+
stream: "codex_app_server.item",
|
|
2211
|
+
data: {
|
|
2212
|
+
phase,
|
|
2213
|
+
itemId,
|
|
2214
|
+
type
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2195
2217
|
if (item.role === "assistant" && extractRawResponseItemText(item)) this.eventProjection.markSafetyBufferingAssistantStarted();
|
|
2196
2218
|
this.toolSearchEvidenceProjection?.recordRawResponseItem(item);
|
|
2197
2219
|
this.toolTranscriptProjection.recordRawNativeToolItem(item);
|
|
@@ -2626,20 +2648,24 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2626
2648
|
}
|
|
2627
2649
|
}, resourceState.thread.threadId, activeTurnId, {
|
|
2628
2650
|
agentHookContext: hookContext,
|
|
2651
|
+
hasDeliveredFinalSourceReply: () => toolBridge.telemetry.finalSourceReplyDelivered === true,
|
|
2629
2652
|
initialContextTokens: connection.mutable.startupContextTokens,
|
|
2630
2653
|
nativePostToolUseRelayEnabled: resourceState.nativeHookRelay?.allowedEvents.includes("post_tool_use") === true && resourceState.nativeHookRelay.shouldRelayEvent("post_tool_use"),
|
|
2631
2654
|
asyncUserMessageAllowed: params.disableTools !== true && (params.toolsAllow === void 0 || toolBridge.availableTools.some((tool) => tool.name === "message")),
|
|
2632
2655
|
onAsyncDelivery: async (delivery) => {
|
|
2633
2656
|
return await codexTranscriptMirrorRuntime.deliverAsyncMessageBestEffort({
|
|
2634
|
-
params:
|
|
2657
|
+
params: projectionParams.onBlockReply ? {
|
|
2635
2658
|
...projectionParams,
|
|
2636
2659
|
onBlockReply: async (payload, options) => {
|
|
2637
|
-
const prepared = await prepareReplyMedia({
|
|
2660
|
+
const prepared = prepareReplyMedia ? await prepareReplyMedia({
|
|
2638
2661
|
kind: "payload",
|
|
2639
2662
|
payload
|
|
2640
|
-
})
|
|
2663
|
+
}) : {
|
|
2664
|
+
kind: "payload",
|
|
2665
|
+
payload
|
|
2666
|
+
};
|
|
2641
2667
|
if (prepared.kind !== "payload") throw new Error("Reply media preparation returned the wrong result kind");
|
|
2642
|
-
await projectionParams.onBlockReply?.(prepared.payload, options);
|
|
2668
|
+
if (!toolBridge.telemetry.finalSourceReplyDelivered) await projectionParams.onBlockReply?.(prepared.payload, options);
|
|
2643
2669
|
}
|
|
2644
2670
|
} : projectionParams,
|
|
2645
2671
|
cwd: effectiveCwd,
|
|
@@ -2799,7 +2825,7 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2799
2825
|
const messages = activeProjector.buildSteeringTranscriptPrefix();
|
|
2800
2826
|
if (params.sessionTarget && messages.length > 0) {
|
|
2801
2827
|
await codexTranscriptMirrorRuntime.mirror({
|
|
2802
|
-
assertCurrent: composeSessionTranscriptWriteAssertion([connection.assertLegacyCurrent,
|
|
2828
|
+
assertCurrent: composeSessionTranscriptWriteAssertion([connection.assertLegacyCurrent, createNativeSessionBindingScope(assertSteeringActive).assertLegacyCurrent]),
|
|
2803
2829
|
agentId: sessionAgentId,
|
|
2804
2830
|
sessionKey: contextSessionKey,
|
|
2805
2831
|
sessionId: params.sessionId,
|
|
@@ -3089,8 +3115,9 @@ function scopeCodexRunBindingStore(params) {
|
|
|
3089
3115
|
return {
|
|
3090
3116
|
...params.bindingStore,
|
|
3091
3117
|
read: (identity) => params.bindingStore.read(mapIdentity(identity)),
|
|
3118
|
+
readAsync: (identity) => params.bindingStore.readAsync(mapIdentity(identity)),
|
|
3092
3119
|
readMany: (identities) => params.bindingStore.readMany(identities.map(mapIdentity)),
|
|
3093
|
-
readNativeSubagentAssignments: (identity, owner) => (params.bindingStore.readNativeSubagentAssignments?.(mapIdentity(identity), mapHistoryOwner(identity, owner)) ?? []).map((assignment) => Object.assign({}, assignment, { owner: {
|
|
3120
|
+
readNativeSubagentAssignments: async (identity, owner) => (await params.bindingStore.readNativeSubagentAssignments?.(mapIdentity(identity), mapHistoryOwner(identity, owner)) ?? []).map((assignment) => Object.assign({}, assignment, { owner: {
|
|
3094
3121
|
...assignment.owner,
|
|
3095
3122
|
sessionId: owner.sessionId
|
|
3096
3123
|
} })),
|
|
@@ -3339,6 +3366,7 @@ async function rotateOversizedCodexAppServerStartupBinding(params) {
|
|
|
3339
3366
|
//#region extensions/codex/src/app-server/run-attempt-connection.ts
|
|
3340
3367
|
async function prepareCodexAttemptConnection({ params, options }) {
|
|
3341
3368
|
const attemptStartedAt = Date.now();
|
|
3369
|
+
const attemptStartedAtMonotonicMs = performance.now();
|
|
3342
3370
|
const profilerEnabled = isCodexAppServerProfilerEnabled(params.config);
|
|
3343
3371
|
const codexModelCallTrace = freezeDiagnosticTraceContext(createDiagnosticTraceContextFromActiveScope());
|
|
3344
3372
|
const codexModelContentCapture = resolveDiagnosticModelContentCapturePolicy(params.config);
|
|
@@ -3371,12 +3399,17 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3371
3399
|
sessionKey: sandboxSessionKey,
|
|
3372
3400
|
workspaceDir: resolvedWorkspace
|
|
3373
3401
|
});
|
|
3402
|
+
const ownedSandbox = params.sandbox === void 0 ? sandbox : void 0;
|
|
3403
|
+
let sandboxTransferred = false;
|
|
3404
|
+
using _ = { [Symbol.dispose]: () => {
|
|
3405
|
+
if (!sandboxTransferred) ownedSandbox?.[Symbol.dispose]?.();
|
|
3406
|
+
} };
|
|
3374
3407
|
const attemptClientFactory = options.clientFactory ?? (isCodexPairedNodeRemoteExecPlacementSandbox(sandbox) ? createIsolatedCodexAppServerClient : getLeasedSharedCodexAppServerClient);
|
|
3375
3408
|
preDynamicStartupStages.mark("sandbox");
|
|
3376
3409
|
const execPolicy = resolveOpenClawExecPolicyForCodexAppServer({
|
|
3377
3410
|
permissionMode: params.permissionMode,
|
|
3378
3411
|
execOverrides: params.execOverrides,
|
|
3379
|
-
approvals: params.permissionMode === "full" ? void 0 :
|
|
3412
|
+
approvals: params.permissionMode === "full" ? void 0 : await loadExecApprovalsReadOnlyAsync(),
|
|
3380
3413
|
config: params.config,
|
|
3381
3414
|
agentId: policyAgentId
|
|
3382
3415
|
});
|
|
@@ -3433,15 +3466,23 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3433
3466
|
preDynamicStartupStages.mark("session-agent");
|
|
3434
3467
|
let activeContextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
|
|
3435
3468
|
const isInactiveThreadBootstrapBinding = (binding) => !activeContextEngine && binding?.contextEngine?.projection?.mode === "thread_bootstrap";
|
|
3469
|
+
let generationAuthority;
|
|
3470
|
+
let generationAuthorityTransferred = false;
|
|
3471
|
+
using captures = new DisposableStack();
|
|
3472
|
+
captures.defer(() => {
|
|
3473
|
+
if (!generationAuthorityTransferred) generationAuthority?.release();
|
|
3474
|
+
});
|
|
3436
3475
|
if (bindingIdentity.kind === "session" && bindingIdentity.sessionKey) {
|
|
3437
|
-
|
|
3476
|
+
generationAuthority = await retainNativeSessionGenerationAuthority({
|
|
3438
3477
|
config: params.config,
|
|
3439
3478
|
storePath: params.sessionTarget?.storePath,
|
|
3440
3479
|
target: bindingIdentity,
|
|
3441
3480
|
createSupersededError: createCodexSessionGenerationSupersededError
|
|
3442
3481
|
});
|
|
3443
|
-
if (
|
|
3444
|
-
if (
|
|
3482
|
+
if (generationAuthority.state === "superseded") throw createCodexSessionGenerationSupersededError(bindingIdentity.sessionId);
|
|
3483
|
+
if (generationAuthority.state === "ephemeral") {
|
|
3484
|
+
generationAuthority.release();
|
|
3485
|
+
generationAuthority = void 0;
|
|
3445
3486
|
const logicalIdentity = bindingIdentity;
|
|
3446
3487
|
const physicalIdentity = {
|
|
3447
3488
|
kind: "session",
|
|
@@ -3458,8 +3499,10 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3458
3499
|
}
|
|
3459
3500
|
let modelExecution;
|
|
3460
3501
|
const assertModelExecutionCurrent = () => modelExecution?.assertCurrent();
|
|
3461
|
-
|
|
3502
|
+
generationAuthorityTransferred = true;
|
|
3503
|
+
const { binding: admittedBinding, authority: bindingAuthority, release: releaseBindingAuthority } = await resolveCodexSessionBinding({
|
|
3462
3504
|
reclaimStale: true,
|
|
3505
|
+
generationAuthority,
|
|
3463
3506
|
bindingStore,
|
|
3464
3507
|
identity: bindingIdentity,
|
|
3465
3508
|
config: params.config,
|
|
@@ -3468,11 +3511,15 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3468
3511
|
signal: params.abortSignal,
|
|
3469
3512
|
assertBinding: params.expectedSessionRuntimeOwnership ? (binding) => assertCodexSessionRuntimeOwnership(binding, params.expectedSessionRuntimeOwnership) : void 0
|
|
3470
3513
|
});
|
|
3514
|
+
let bindingAuthorityTransferred = false;
|
|
3515
|
+
captures.defer(() => {
|
|
3516
|
+
if (!bindingAuthorityTransferred) releaseBindingAuthority();
|
|
3517
|
+
});
|
|
3471
3518
|
const assertCurrent = () => {
|
|
3472
3519
|
bindingAuthority.assertCurrent();
|
|
3473
3520
|
assertModelExecutionCurrent();
|
|
3474
3521
|
};
|
|
3475
|
-
const authority =
|
|
3522
|
+
const authority = bindingAuthority.withLiveness(assertCurrent);
|
|
3476
3523
|
let startupBinding = admittedBinding;
|
|
3477
3524
|
preDynamicStartupStages.mark("read-binding");
|
|
3478
3525
|
const usesSupervisionConnection = startupBinding?.connectionScope === "supervision";
|
|
@@ -3500,7 +3547,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3500
3547
|
authProfileId: startupAuthProfileCandidate,
|
|
3501
3548
|
store: params.authProfileStore,
|
|
3502
3549
|
config: params.config
|
|
3503
|
-
}) : resolveCodexAppServerAuthProfileIdForAgent({
|
|
3550
|
+
}) : await resolveCodexAppServerAuthProfileIdForAgent({
|
|
3504
3551
|
authProfileId: startupAuthProfileCandidate,
|
|
3505
3552
|
agentDir,
|
|
3506
3553
|
config: params.config
|
|
@@ -3667,6 +3714,8 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3667
3714
|
};
|
|
3668
3715
|
const resolveRuntimeOptionsForCurrentBinding = async (selection) => resolveFinalAppServer(await resolveRuntimeOptionsForBinding(mutable.startupBinding, selection), selection);
|
|
3669
3716
|
assertCurrent();
|
|
3717
|
+
sandboxTransferred = true;
|
|
3718
|
+
bindingAuthorityTransferred = true;
|
|
3670
3719
|
return {
|
|
3671
3720
|
params,
|
|
3672
3721
|
prepareInputAttachments: async (request) => {
|
|
@@ -3701,6 +3750,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3701
3750
|
},
|
|
3702
3751
|
assertCurrent,
|
|
3703
3752
|
authority,
|
|
3753
|
+
releaseBindingAuthority,
|
|
3704
3754
|
withCurrent: authority.withCurrent,
|
|
3705
3755
|
assertLegacyCurrent: authority.assertLegacyCurrent,
|
|
3706
3756
|
assertModelExecutionCurrent,
|
|
@@ -3708,6 +3758,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3708
3758
|
releaseModelExecution,
|
|
3709
3759
|
options,
|
|
3710
3760
|
attemptStartedAt,
|
|
3761
|
+
attemptStartedAtMonotonicMs,
|
|
3711
3762
|
profilerEnabled,
|
|
3712
3763
|
codexModelCallTrace,
|
|
3713
3764
|
codexModelContentCapture,
|
|
@@ -3725,6 +3776,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3725
3776
|
sandboxSessionKey,
|
|
3726
3777
|
contextSessionKey,
|
|
3727
3778
|
sandbox,
|
|
3779
|
+
releaseSandboxContext: () => ownedSandbox?.[Symbol.dispose]?.(),
|
|
3728
3780
|
agentDir,
|
|
3729
3781
|
shellEnvironment,
|
|
3730
3782
|
shellPathPrepend,
|
|
@@ -4057,6 +4109,7 @@ async function prepareCodexAttemptContext(runtime, attemptTools) {
|
|
|
4057
4109
|
};
|
|
4058
4110
|
const hookContext = {
|
|
4059
4111
|
runId: params.runId,
|
|
4112
|
+
config: params.config,
|
|
4060
4113
|
agentId: sessionAgentId,
|
|
4061
4114
|
sessionKey: contextSessionKey,
|
|
4062
4115
|
sessionId: params.sessionId,
|
|
@@ -4633,7 +4686,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4633
4686
|
const completedTurnStatus = activeProjector.getCompletedTurnStatus();
|
|
4634
4687
|
const locallyCompletedTurn = state.completed && state.localCompletionRequested && !state.timeout && clientClosedPromptErrorForFinal === void 0;
|
|
4635
4688
|
const turnSucceeded = !finalAborted && !effectiveTimedOut && (finalPromptError === null || finalPromptError === void 0) && (completedTurnStatus === "completed" || locallyCompletedTurn);
|
|
4636
|
-
if (toolBridge.telemetry.messagingToolSentTargets.some((target) => target.sourceReplyFinal === true)) result.agentHarnessResultClassification = void 0;
|
|
4689
|
+
if (toolBridge.telemetry.finalSourceReplyDelivered || toolBridge.telemetry.messagingToolSentTargets.some((target) => target.sourceReplyFinal === true)) result.agentHarnessResultClassification = void 0;
|
|
4637
4690
|
const attemptSucceeded = turnSucceeded && result.agentHarnessResultClassification === void 0;
|
|
4638
4691
|
result.terminal = attemptTerminal.normalize({
|
|
4639
4692
|
settlementWarning: state.settlementWarning,
|
|
@@ -4674,7 +4727,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4674
4727
|
const mirrorTerminal = projectTerminalOutcome();
|
|
4675
4728
|
state.pendingSettlementStage = "transcript/mirror";
|
|
4676
4729
|
return codexTranscriptMirrorRuntime.mirrorBestEffort({
|
|
4677
|
-
assertWriteCurrent:
|
|
4730
|
+
assertWriteCurrent: createNativeSessionBindingScope(() => {
|
|
4678
4731
|
if (!isSettlementActive() || state.settlementWarning !== warning) throw new Error("Codex transcript settlement is no longer active");
|
|
4679
4732
|
const current = projectTerminalOutcome();
|
|
4680
4733
|
if (current.finalAborted !== mirrorTerminal.finalAborted || current.effectiveTimedOut !== mirrorTerminal.effectiveTimedOut || current.finalPromptError !== mirrorTerminal.finalPromptError) throw new Error("Codex transcript terminal outcome changed before write");
|
|
@@ -4912,24 +4965,42 @@ function createCodexAttemptLifecycleController(resources, turnRuntime) {
|
|
|
4912
4965
|
const { connection } = prompt.context.runtime;
|
|
4913
4966
|
const { params, attemptStartedAt, runAbortController, fastModeAutoStartedAtMs, fastModeAutoProgressState } = connection;
|
|
4914
4967
|
const { state, activeTurnItemIds, pendingOpenClawDynamicToolCompletionIds } = turnRuntime;
|
|
4915
|
-
|
|
4968
|
+
let modelResponse;
|
|
4969
|
+
let lastClosedResponseId;
|
|
4970
|
+
const resolveAuthoredResponse = () => {
|
|
4971
|
+
if (!modelResponse?.closed || modelResponse.calls.size === 0) return;
|
|
4972
|
+
const results = [];
|
|
4973
|
+
for (const { result } of modelResponse.calls.values()) {
|
|
4974
|
+
if (!result?.response.success || result.response.terminate !== true) return;
|
|
4975
|
+
results.push(result);
|
|
4976
|
+
}
|
|
4977
|
+
const payloads = results.flatMap((result) => result.response.toolAuthoredSourceReply ? [result.response.toolAuthoredSourceReply] : []);
|
|
4978
|
+
const value = results[0];
|
|
4979
|
+
return value && payloads.length > 0 ? {
|
|
4980
|
+
value,
|
|
4981
|
+
payloads
|
|
4982
|
+
} : void 0;
|
|
4983
|
+
};
|
|
4916
4984
|
const scheduleTerminalDynamicToolReleaseCheck = () => {
|
|
4917
|
-
if (state.terminalDynamicToolReleaseCheckScheduled || !state.pendingTerminalDynamicToolRelease && !state.currentTurnHadNonTerminalDynamicToolResult) return;
|
|
4985
|
+
if (state.terminalDynamicToolReleaseCheckScheduled || !state.pendingTerminalDynamicToolRelease && !state.currentTurnHadNonTerminalDynamicToolResult && !resolveAuthoredResponse()) return;
|
|
4918
4986
|
state.terminalDynamicToolReleaseCheckScheduled = true;
|
|
4919
4987
|
setImmediate(() => {
|
|
4920
4988
|
state.terminalDynamicToolReleaseCheckScheduled = false;
|
|
4921
|
-
if (
|
|
4989
|
+
if (modelResponse && (!modelResponse.closed || [...modelResponse.calls.values()].some((call) => call.direct && !call.result))) return;
|
|
4990
|
+
const deliveredFinal = state.pendingTerminalDynamicToolRelease?.response.finalSourceReplyDelivered === true;
|
|
4991
|
+
const authored = deliveredFinal ? void 0 : resolveAuthoredResponse();
|
|
4992
|
+
if (!authored && (deliveredFinal || state.pendingTerminalDynamicToolRelease?.response.success === true) && (deliveredFinal || !state.currentTurnHadNonTerminalDynamicToolResult) && state.activeAppServerTurnRequests === 0 && pendingOpenClawDynamicToolCompletionIds.size === 0) turnRuntime.steeringQueueRef.current?.cancel();
|
|
4922
4993
|
if (state.activeAppServerTurnRequests > 0 || activeTurnItemIds.size > 0 || pendingOpenClawDynamicToolCompletionIds.size > 0) return;
|
|
4923
|
-
if (
|
|
4994
|
+
if (!authored && !deliveredFinal && state.currentTurnHadNonTerminalDynamicToolResult) {
|
|
4924
4995
|
state.pendingTerminalDynamicToolRelease = void 0;
|
|
4925
4996
|
state.currentTurnHadNonTerminalDynamicToolResult = false;
|
|
4926
|
-
state.currentTurnHadToolAuthoredFinalReply = false;
|
|
4927
4997
|
return;
|
|
4928
4998
|
}
|
|
4929
|
-
const value = state.pendingTerminalDynamicToolRelease;
|
|
4930
|
-
if (!value || state.completed || runAbortController.signal.aborted || !value.response.success
|
|
4999
|
+
const value = authored?.value ?? state.pendingTerminalDynamicToolRelease;
|
|
5000
|
+
if (!value || state.completed || runAbortController.signal.aborted || !value.response.success && !deliveredFinal) return;
|
|
4931
5001
|
state.pendingTerminalDynamicToolRelease = void 0;
|
|
4932
|
-
|
|
5002
|
+
modelResponse = void 0;
|
|
5003
|
+
if (authored) prompt.context.attemptTools.toolBridge.telemetry.messagingToolSourceReplyPayloads.push(...authored.payloads);
|
|
4933
5004
|
trajectoryRecorder?.recordEvent("turn.dynamic_tool_terminal_release", {
|
|
4934
5005
|
threadId: value.call.threadId,
|
|
4935
5006
|
turnId: value.call.turnId,
|
|
@@ -4950,16 +5021,47 @@ function createCodexAttemptLifecycleController(resources, turnRuntime) {
|
|
|
4950
5021
|
}).unref?.();
|
|
4951
5022
|
};
|
|
4952
5023
|
const recordDynamicToolResult = (value) => {
|
|
4953
|
-
|
|
4954
|
-
if (
|
|
4955
|
-
|
|
5024
|
+
const modelCall = modelResponse?.calls.get(value.call.callId);
|
|
5025
|
+
if (modelCall) modelCall.result = value;
|
|
5026
|
+
if (value.response.toolAuthoredSourceReply) {
|
|
5027
|
+
if (modelCall && !state.pendingTerminalDynamicToolRelease?.response.finalSourceReplyDelivered) state.pendingTerminalDynamicToolRelease = void 0;
|
|
4956
5028
|
scheduleTerminalDynamicToolReleaseCheck();
|
|
4957
|
-
|
|
5029
|
+
return;
|
|
5030
|
+
}
|
|
5031
|
+
if (value.response.terminate === true && (value.response.success || value.response.finalSourceReplyDelivered)) {
|
|
5032
|
+
if (value.response.finalSourceReplyDelivered || !state.pendingTerminalDynamicToolRelease?.response.finalSourceReplyDelivered && ![...modelResponse?.calls.values() ?? []].some((call) => call.result?.response.toolAuthoredSourceReply)) state.pendingTerminalDynamicToolRelease = value;
|
|
5033
|
+
scheduleTerminalDynamicToolReleaseCheck();
|
|
5034
|
+
} else if (value.response.success && value.response.asyncStarted === true) scheduleTerminalDynamicToolReleaseCheck();
|
|
4958
5035
|
else {
|
|
4959
5036
|
state.currentTurnHadNonTerminalDynamicToolResult = true;
|
|
4960
|
-
if (!state.
|
|
5037
|
+
if (!state.pendingTerminalDynamicToolRelease?.response.finalSourceReplyDelivered) state.pendingTerminalDynamicToolRelease = void 0;
|
|
4961
5038
|
}
|
|
4962
5039
|
};
|
|
5040
|
+
const recordModelResponseNotification = (notification) => {
|
|
5041
|
+
const notificationParams = notification.params;
|
|
5042
|
+
if (!isJsonObject(notificationParams)) return;
|
|
5043
|
+
if (notification.method === "rawResponse/completed") {
|
|
5044
|
+
const responseId = notificationParams.responseId;
|
|
5045
|
+
if (typeof responseId !== "string" || !responseId || responseId === lastClosedResponseId) return;
|
|
5046
|
+
lastClosedResponseId = responseId;
|
|
5047
|
+
if (!modelResponse || modelResponse.closed) modelResponse = {
|
|
5048
|
+
closed: false,
|
|
5049
|
+
calls: /* @__PURE__ */ new Map()
|
|
5050
|
+
};
|
|
5051
|
+
modelResponse.closed = true;
|
|
5052
|
+
scheduleTerminalDynamicToolReleaseCheck();
|
|
5053
|
+
return;
|
|
5054
|
+
}
|
|
5055
|
+
if (notification.method !== "rawResponseItem/completed" || !isJsonObject(notificationParams.item)) return;
|
|
5056
|
+
const callId = readRawResponseToolCallId(notification);
|
|
5057
|
+
const item = notificationParams.item;
|
|
5058
|
+
if (!(callId !== void 0 || item.type === "reasoning" || item.type === "message" && item.role === "assistant")) return;
|
|
5059
|
+
if (!modelResponse || modelResponse.closed) modelResponse = {
|
|
5060
|
+
closed: false,
|
|
5061
|
+
calls: /* @__PURE__ */ new Map()
|
|
5062
|
+
};
|
|
5063
|
+
if (callId && !modelResponse.calls.has(callId)) modelResponse.calls.set(callId, { direct: item.namespace === CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE });
|
|
5064
|
+
};
|
|
4963
5065
|
const { emitLifecycleStart, emitLifecycleTerminal, emitExecutionPhaseOnce } = createAgentHarnessAttemptLifecycle({
|
|
4964
5066
|
attempt: params,
|
|
4965
5067
|
backend: "codex-app-server",
|
|
@@ -5038,6 +5140,7 @@ function createCodexAttemptLifecycleController(resources, turnRuntime) {
|
|
|
5038
5140
|
}
|
|
5039
5141
|
};
|
|
5040
5142
|
return {
|
|
5143
|
+
recordModelResponseNotification,
|
|
5041
5144
|
recordDynamicToolResult,
|
|
5042
5145
|
scheduleTerminalDynamicToolReleaseCheck,
|
|
5043
5146
|
emitLifecycleStart,
|
|
@@ -5082,14 +5185,14 @@ async function projectCodexSessionWarning(params) {
|
|
|
5082
5185
|
return await params.project();
|
|
5083
5186
|
};
|
|
5084
5187
|
try {
|
|
5085
|
-
await
|
|
5188
|
+
await prepareSessionEntryPatch({
|
|
5086
5189
|
agentId: session.agentId,
|
|
5087
5190
|
sessionKey: session.sessionKey,
|
|
5088
5191
|
storePath: session.storePath,
|
|
5089
5192
|
preserveActivity: true,
|
|
5090
5193
|
requireWriteSuccess: true,
|
|
5091
5194
|
skipMaintenance: true,
|
|
5092
|
-
|
|
5195
|
+
prepare: async (entry) => {
|
|
5093
5196
|
foundSession = true;
|
|
5094
5197
|
params.assertCurrent();
|
|
5095
5198
|
if (entry.sessionId !== session.sessionId || session.expectedLifecycleRevision !== void 0 && entry.lifecycleRevision !== session.expectedLifecycleRevision) return null;
|
|
@@ -5130,7 +5233,7 @@ function createCodexAttemptNotificationController(resources, turnRuntime, lifecy
|
|
|
5130
5233
|
const { appServer, runAbortController } = runtime.connection;
|
|
5131
5234
|
const { allocateCodexToolOutcomeOrdinal } = attemptTools;
|
|
5132
5235
|
const { state, turnIdRef, steeringQueueRef, activeTurnItemIds, pendingOpenClawDynamicToolCompletionIds, openClawDynamicToolExecutions, completeTurn, noteProgress, deadlines } = turnRuntime;
|
|
5133
|
-
const { scheduleTerminalDynamicToolReleaseCheck, reportExecutionNotification, maybeAnnounceFastModeAutoOff } = lifecycle;
|
|
5236
|
+
const { recordModelResponseNotification, scheduleTerminalDynamicToolReleaseCheck, reportExecutionNotification, maybeAnnounceFastModeAutoOff } = lifecycle;
|
|
5134
5237
|
const pendingNativeCommandItems = /* @__PURE__ */ new Set();
|
|
5135
5238
|
let nativeItemsCompletion;
|
|
5136
5239
|
const waitForNativeTerminalItems = async (signal) => {
|
|
@@ -5246,6 +5349,7 @@ function createCodexAttemptNotificationController(resources, turnRuntime, lifecy
|
|
|
5246
5349
|
deadlines.beginSettlement(receivedAtMs);
|
|
5247
5350
|
}
|
|
5248
5351
|
if (scope.turnId === turnId) {
|
|
5352
|
+
recordModelResponseNotification(notification);
|
|
5249
5353
|
const modelToolCallId = readRawResponseToolCallId(notification);
|
|
5250
5354
|
if (modelToolCallId) allocateCodexToolOutcomeOrdinal?.(modelToolCallId);
|
|
5251
5355
|
const nativeItem = readCodexNotificationItem(notification.params);
|
|
@@ -5283,12 +5387,13 @@ async function prepareCodexAttemptPrompt(context) {
|
|
|
5283
5387
|
const { toolBridge } = attemptTools;
|
|
5284
5388
|
const availableToolNames = () => flattenCodexDynamicToolFunctions(toolBridge.availableSpecs).map((tool) => tool.name).filter(isNonEmptyString);
|
|
5285
5389
|
const nativeHistoryProvenancePrefix = params.trigger === "user" ? buildCodexHistoryProvenancePrefix(params) : void 0;
|
|
5286
|
-
const forkedSession = !mutable.startupBinding?.threadId && params.sessionTarget ?
|
|
5390
|
+
const forkedSession = !mutable.startupBinding?.threadId && params.sessionTarget ? await getSessionEntryAsync({
|
|
5287
5391
|
...params.sessionTarget,
|
|
5288
5392
|
sessionKey: contextSessionKey,
|
|
5289
5393
|
hydrateSkillPromptRefs: false,
|
|
5290
5394
|
readConsistency: "latest"
|
|
5291
5395
|
}) : void 0;
|
|
5396
|
+
connection.assertCurrent();
|
|
5292
5397
|
const preserveForkedToolResults = Boolean(forkedSession?.sessionId === params.sessionId && forkedSession.createdVia === "spawn" && forkedSession.parentSessionKey && forkedSession.parentSessionKey !== contextSessionKey && forkedSession.forkSource?.sessionKey === forkedSession.parentSessionKey && forkedSession.forkSource.sessionId !== params.sessionId);
|
|
5293
5398
|
let contextImageGroups = [];
|
|
5294
5399
|
let turnContextImageGroups = [];
|
|
@@ -5332,7 +5437,8 @@ async function prepareCodexAttemptPrompt(context) {
|
|
|
5332
5437
|
maxRenderedContextChars: codexContinuityProjectionMaxChars,
|
|
5333
5438
|
toolPayloadMode: params.continuation || params.pluginRuntimeRefreshMessages || preserveForkedToolResults ? "preserve" : "elide",
|
|
5334
5439
|
prepareFileContext,
|
|
5335
|
-
currentUserTurnIdempotencyKey
|
|
5440
|
+
currentUserTurnIdempotencyKey,
|
|
5441
|
+
currentUserMessage: admittedMessage
|
|
5336
5442
|
});
|
|
5337
5443
|
assertProjectionCurrent();
|
|
5338
5444
|
contextImageGroups = projection.imageGroups ?? [];
|
|
@@ -5381,7 +5487,8 @@ async function prepareCodexAttemptPrompt(context) {
|
|
|
5381
5487
|
maxRenderedContextChars: codexContextProjectionMaxChars,
|
|
5382
5488
|
toolPayloadMode: contextEngineProjection || params.continuation || params.pluginRuntimeRefreshMessages || preserveForkedToolResults ? "preserve" : "elide",
|
|
5383
5489
|
...projectionDecision.project ? { prepareFileContext } : {},
|
|
5384
|
-
currentUserTurnIdempotencyKey
|
|
5490
|
+
currentUserTurnIdempotencyKey,
|
|
5491
|
+
currentUserMessage: admittedMessage
|
|
5385
5492
|
});
|
|
5386
5493
|
assertProjectionCurrent();
|
|
5387
5494
|
contextImageGroups = projectionDecision.project ? projection.imageGroups ?? [] : [];
|
|
@@ -5639,6 +5746,16 @@ function buildCodexHookRequester(params) {
|
|
|
5639
5746
|
}
|
|
5640
5747
|
//#endregion
|
|
5641
5748
|
//#region extensions/codex/src/app-server/native-subagent-assignment-store.ts
|
|
5749
|
+
/** Accepted child writes retain the captured parent lifecycle beyond foreground settlement. */
|
|
5750
|
+
function createNativeSubagentSessionAuthority(parent) {
|
|
5751
|
+
if (!parent) return;
|
|
5752
|
+
return createPreparedNativeSessionBindingAuthority({
|
|
5753
|
+
lineage: [],
|
|
5754
|
+
source: parent.source,
|
|
5755
|
+
entryChecks: parent.entryCurrent ? [parent.entryCurrent] : [],
|
|
5756
|
+
assertCurrent: () => parent.source.assertScopeCurrent()
|
|
5757
|
+
});
|
|
5758
|
+
}
|
|
5642
5759
|
function createNativeSubagentAssignmentStore(params) {
|
|
5643
5760
|
const { bindingStore, identity, owner } = params;
|
|
5644
5761
|
const assertCurrent = () => {
|
|
@@ -5646,6 +5763,10 @@ function createNativeSubagentAssignmentStore(params) {
|
|
|
5646
5763
|
const binding = bindingStore.read(identity);
|
|
5647
5764
|
if (!binding || !matchesCodexNativeSubagentSubmissionBinding(binding, owner)) throw new Error("Native assignment binding is no longer current.");
|
|
5648
5765
|
};
|
|
5766
|
+
const assertCurrentAsync = async () => {
|
|
5767
|
+
await params.assertLifecycleCurrentAsync?.();
|
|
5768
|
+
assertCurrent();
|
|
5769
|
+
};
|
|
5649
5770
|
const mutate = (kind) => (assignment, assertSourceCurrent) => bindingStore.mutate(identity, {
|
|
5650
5771
|
kind,
|
|
5651
5772
|
owner,
|
|
@@ -5653,17 +5774,44 @@ function createNativeSubagentAssignmentStore(params) {
|
|
|
5653
5774
|
}, () => {
|
|
5654
5775
|
assertCurrent();
|
|
5655
5776
|
assertSourceCurrent();
|
|
5656
|
-
});
|
|
5777
|
+
}, params.authority);
|
|
5657
5778
|
return {
|
|
5658
5779
|
assertCurrent,
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5780
|
+
assertCurrentAsync,
|
|
5781
|
+
read: async () => {
|
|
5782
|
+
const assignments = await bindingStore.readNativeSubagentAssignments?.(identity, owner) ?? [];
|
|
5783
|
+
await assertCurrentAsync();
|
|
5784
|
+
return assignments;
|
|
5662
5785
|
},
|
|
5663
5786
|
record: mutate("record-native-subagent-assignment"),
|
|
5664
5787
|
consume: mutate("consume-native-subagent-assignment")
|
|
5665
5788
|
};
|
|
5666
5789
|
}
|
|
5790
|
+
function createNativeSubagentSubmissionStore(params) {
|
|
5791
|
+
const { bindingStore, identity, owner } = params;
|
|
5792
|
+
const assertCurrent = () => {
|
|
5793
|
+
const current = bindingStore.read(identity);
|
|
5794
|
+
if (!current || !matchesCodexNativeSubagentSubmissionBinding(current, owner)) throw new Error("Native submission binding is no longer current.");
|
|
5795
|
+
};
|
|
5796
|
+
return {
|
|
5797
|
+
assertCurrent,
|
|
5798
|
+
assertCurrentAsync: async () => {
|
|
5799
|
+
await params.assertLifecycleCurrentAsync();
|
|
5800
|
+
assertCurrent();
|
|
5801
|
+
},
|
|
5802
|
+
read: () => bindingStore.readNativeSubagentSubmissions(identity, owner),
|
|
5803
|
+
record: (receipt, assertSourceCurrent) => bindingStore.mutate(identity, {
|
|
5804
|
+
kind: "record-native-subagent-submission",
|
|
5805
|
+
owner,
|
|
5806
|
+
receipt
|
|
5807
|
+
}, assertSourceCurrent, params.authority),
|
|
5808
|
+
consume: (receipt, assertSourceCurrent) => bindingStore.mutate(identity, {
|
|
5809
|
+
kind: "consume-native-subagent-submission",
|
|
5810
|
+
owner,
|
|
5811
|
+
receipt
|
|
5812
|
+
}, assertSourceCurrent, params.authority)
|
|
5813
|
+
};
|
|
5814
|
+
}
|
|
5667
5815
|
//#endregion
|
|
5668
5816
|
//#region extensions/codex/src/app-server/run-attempt-resources.ts
|
|
5669
5817
|
function prepareCodexAttemptResources(prompt) {
|
|
@@ -5679,7 +5827,7 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5679
5827
|
modelAdmissionSource?.release();
|
|
5680
5828
|
}
|
|
5681
5829
|
let nativeProcessAuthorityReleased = false;
|
|
5682
|
-
const cleanupAuthority =
|
|
5830
|
+
const cleanupAuthority = connection.authority.withLiveness(() => {
|
|
5683
5831
|
params.hostCapabilities.assertActive();
|
|
5684
5832
|
if (nativeProcessAuthorityReleased) throw new Error("Codex attempt cleanup authority has ended");
|
|
5685
5833
|
});
|
|
@@ -5787,103 +5935,110 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5787
5935
|
await nativeSubagentMonitorSettlement;
|
|
5788
5936
|
};
|
|
5789
5937
|
const registerNativeSubagentMonitor = async (parentThreadId) => {
|
|
5938
|
+
const requestCustody = params.hostCapabilities.captureRequestCustody?.();
|
|
5790
5939
|
const { client, thread, nativeHookRelay, turnRoute } = state;
|
|
5791
|
-
|
|
5792
|
-
connection.assertCurrent();
|
|
5793
|
-
const generation = ++nativeSubagentMonitorGeneration;
|
|
5794
|
-
const sessionKey = params.sessionKey;
|
|
5940
|
+
const sessionKey = params.sessionTarget?.sessionKey ?? params.sessionKey;
|
|
5795
5941
|
const storePath = params.sessionTarget?.storePath;
|
|
5796
|
-
const
|
|
5797
|
-
agentId: sessionAgentId,
|
|
5942
|
+
const parent = sessionKey && storePath ? await captureSessionEntryCurrentCheckAsync({
|
|
5943
|
+
agentId: params.sessionTarget?.agentId ?? sessionAgentId,
|
|
5798
5944
|
sessionKey,
|
|
5799
5945
|
storePath,
|
|
5800
|
-
|
|
5801
|
-
hydrateSkillPromptRefs: false
|
|
5802
|
-
}) : void 0;
|
|
5803
|
-
const parentSession = readParentSession();
|
|
5804
|
-
const historyOwner = createCodexNativeSubagentHistoryOwner({
|
|
5805
|
-
parentThreadId,
|
|
5806
|
-
sessionId: params.sessionId,
|
|
5807
|
-
...parentSession?.sessionId === params.sessionId ? { lifecycleRevision: parentSession.lifecycleRevision } : {},
|
|
5808
|
-
binding: thread
|
|
5809
|
-
});
|
|
5810
|
-
const { bindingStore, bindingIdentity } = connection;
|
|
5811
|
-
const assertParentSessionCurrent = () => {
|
|
5812
|
-
if (historyOwner?.lifecycleRevision && sessionKey && storePath) {
|
|
5813
|
-
if (readParentSession()?.lifecycleRevision !== historyOwner.lifecycleRevision) throw new Error("Native submission session lifecycle is no longer current.");
|
|
5814
|
-
}
|
|
5815
|
-
};
|
|
5816
|
-
const submissionStore = historyOwner && thread.lifecycle.preserveExistingBinding !== true ? {
|
|
5817
|
-
assertCurrent: () => {
|
|
5818
|
-
const current = bindingStore.read(bindingIdentity);
|
|
5819
|
-
if (!current || !matchesCodexNativeSubagentSubmissionBinding(current, historyOwner)) throw new Error("Native submission binding is no longer current.");
|
|
5820
|
-
assertParentSessionCurrent();
|
|
5821
|
-
},
|
|
5822
|
-
read: () => bindingStore.readNativeSubagentSubmissions(bindingIdentity, historyOwner),
|
|
5823
|
-
record: (receipt, assertCurrent) => bindingStore.mutate(bindingIdentity, {
|
|
5824
|
-
kind: "record-native-subagent-submission",
|
|
5825
|
-
owner: historyOwner,
|
|
5826
|
-
receipt
|
|
5827
|
-
}, assertCurrent),
|
|
5828
|
-
consume: (receipt, assertCurrent) => bindingStore.mutate(bindingIdentity, {
|
|
5829
|
-
kind: "consume-native-subagent-submission",
|
|
5830
|
-
owner: historyOwner,
|
|
5831
|
-
receipt
|
|
5832
|
-
}, assertCurrent)
|
|
5833
|
-
} : void 0;
|
|
5834
|
-
const assignmentStore = historyOwner && submissionStore ? createNativeSubagentAssignmentStore({
|
|
5835
|
-
bindingStore,
|
|
5836
|
-
identity: bindingIdentity,
|
|
5837
|
-
owner: historyOwner,
|
|
5838
|
-
assertLifecycleCurrent: () => submissionStore.assertCurrent()
|
|
5946
|
+
errorMessage: "Native submission session lifecycle is no longer current."
|
|
5839
5947
|
}) : void 0;
|
|
5840
|
-
|
|
5841
|
-
runAbortController.signal.throwIfAborted();
|
|
5842
|
-
params.hostCapabilities.assertActive();
|
|
5843
|
-
connection.assertCurrent();
|
|
5844
|
-
if (submissionStore) submissionStore.assertCurrent();
|
|
5845
|
-
else assertParentSessionCurrent();
|
|
5846
|
-
thread.liveThreadOwnership?.assertCurrent();
|
|
5847
|
-
if (generation !== nativeSubagentMonitorGeneration || state.client !== client || state.thread !== thread || state.nativeHookRelay !== nativeHookRelay || state.turnRoute !== turnRoute) throw new Error("Codex native subagent registration was superseded during setup");
|
|
5848
|
-
};
|
|
5849
|
-
const retainModelSource = params.hostCapabilities.retainSourceAuthority;
|
|
5850
|
-
const modelSource = retainModelSource?.();
|
|
5948
|
+
let parentTransferred = false;
|
|
5851
5949
|
try {
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5950
|
+
await unregisterNativeSubagentMonitor();
|
|
5951
|
+
connection.assertCurrent();
|
|
5952
|
+
const generation = ++nativeSubagentMonitorGeneration;
|
|
5953
|
+
const parentSession = parent?.entry;
|
|
5954
|
+
const historyOwner = createCodexNativeSubagentHistoryOwner({
|
|
5855
5955
|
parentThreadId,
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
onUnqualifiedModelCancelled: connection.abortExplicitly,
|
|
5860
|
-
requesterSessionKey: params.sessionKey,
|
|
5861
|
-
completionScope: params.agentHarnessCompletionScope,
|
|
5862
|
-
historyOwner,
|
|
5863
|
-
submissionStore,
|
|
5864
|
-
assignmentStore,
|
|
5865
|
-
agentId: sessionAgentId,
|
|
5866
|
-
assertCurrent: assertRegistrationCurrent,
|
|
5867
|
-
isTurnYielded: () => attemptTools.toolState.yieldDetected,
|
|
5868
|
-
retainClient: () => retainSharedCodexAppServerClientIfCurrent(client),
|
|
5869
|
-
retainParentThread: (protectedThreadId) => protectCodexAppServerLiveThread(client, protectedThreadId),
|
|
5870
|
-
claimDirectChild: (childThreadId) => nativeHookRelay?.claimDirectChild(childThreadId),
|
|
5871
|
-
rejectPendingDirectChild: (childThreadId, reason) => nativeHookRelay?.rejectPendingDirectChild(childThreadId, reason),
|
|
5872
|
-
...params.sessionKey && params.agentHarnessCompletionScope ? { onDirectChildAccepted: () => {
|
|
5873
|
-
state.runtimeContinuationStarted = true;
|
|
5874
|
-
} } : {}
|
|
5956
|
+
sessionId: params.sessionId,
|
|
5957
|
+
...parentSession?.sessionId === params.sessionId ? { lifecycleRevision: parentSession.lifecycleRevision } : {},
|
|
5958
|
+
binding: thread
|
|
5875
5959
|
});
|
|
5960
|
+
const { bindingStore, bindingIdentity } = connection;
|
|
5961
|
+
const assertParentSessionCurrent = async () => {
|
|
5962
|
+
await parent?.assertCurrent();
|
|
5963
|
+
};
|
|
5964
|
+
const parentWriteAuthority = createNativeSubagentSessionAuthority(parent);
|
|
5965
|
+
const submissionStore = historyOwner && thread.lifecycle.preserveExistingBinding !== true ? {
|
|
5966
|
+
...createNativeSubagentSubmissionStore({
|
|
5967
|
+
bindingStore,
|
|
5968
|
+
identity: bindingIdentity,
|
|
5969
|
+
owner: historyOwner,
|
|
5970
|
+
assertLifecycleCurrentAsync: assertParentSessionCurrent,
|
|
5971
|
+
authority: parentWriteAuthority
|
|
5972
|
+
}),
|
|
5973
|
+
release: () => parent?.release()
|
|
5974
|
+
} : void 0;
|
|
5975
|
+
const assignmentStore = historyOwner && submissionStore ? createNativeSubagentAssignmentStore({
|
|
5976
|
+
bindingStore,
|
|
5977
|
+
identity: bindingIdentity,
|
|
5978
|
+
owner: historyOwner,
|
|
5979
|
+
assertLifecycleCurrent: () => submissionStore.assertCurrent(),
|
|
5980
|
+
assertLifecycleCurrentAsync: () => assertParentSessionCurrent(),
|
|
5981
|
+
authority: parentWriteAuthority
|
|
5982
|
+
}) : void 0;
|
|
5983
|
+
const assertRegistrationCurrent = () => {
|
|
5984
|
+
runAbortController.signal.throwIfAborted();
|
|
5985
|
+
params.hostCapabilities.assertActive();
|
|
5986
|
+
connection.assertCurrent();
|
|
5987
|
+
if (submissionStore) submissionStore.assertCurrent();
|
|
5988
|
+
thread.liveThreadOwnership?.assertCurrent();
|
|
5989
|
+
if (generation !== nativeSubagentMonitorGeneration || state.client !== client || state.thread !== thread || state.nativeHookRelay !== nativeHookRelay || state.turnRoute !== turnRoute) throw new Error("Codex native subagent registration was superseded during setup");
|
|
5990
|
+
};
|
|
5991
|
+
const retainModelSource = params.hostCapabilities.retainSourceAuthority;
|
|
5992
|
+
const modelSource = retainModelSource?.();
|
|
5876
5993
|
try {
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5994
|
+
const configurationQualification = getCodexInferenceThreadQualification(client, parentThreadId);
|
|
5995
|
+
const registration = await codexNativeSubagentMonitorRuntime.register({
|
|
5996
|
+
client,
|
|
5997
|
+
parentThreadId,
|
|
5998
|
+
...retainModelSource ? { modelSource } : {},
|
|
5999
|
+
configurationQualification,
|
|
6000
|
+
unqualifiedModelExecution: modelSource && !configurationQualification ? true : void 0,
|
|
6001
|
+
onUnqualifiedModelCancelled: connection.abortExplicitly,
|
|
6002
|
+
requesterSessionKey: params.sessionKey,
|
|
6003
|
+
requesterTurnRunId: params.runId,
|
|
6004
|
+
requestCustody,
|
|
6005
|
+
completionScope: params.agentHarnessCompletionScope,
|
|
6006
|
+
historyOwner,
|
|
6007
|
+
submissionStore,
|
|
6008
|
+
assignmentStore,
|
|
6009
|
+
agentId: sessionAgentId,
|
|
6010
|
+
assertCurrent: assertRegistrationCurrent,
|
|
6011
|
+
assertCurrentAsync: assertParentSessionCurrent,
|
|
6012
|
+
isTurnYielded: () => attemptTools.toolState.yieldDetected,
|
|
6013
|
+
retainClient: () => retainSharedCodexAppServerClientIfCurrent(client),
|
|
6014
|
+
retainParentThread: (protectedThreadId) => protectCodexAppServerLiveThread(client, protectedThreadId),
|
|
6015
|
+
claimDirectChild: (childThreadId) => nativeHookRelay?.claimDirectChild(childThreadId),
|
|
6016
|
+
rejectPendingDirectChild: (childThreadId, reason) => nativeHookRelay?.rejectPendingDirectChild(childThreadId, reason),
|
|
6017
|
+
...params.sessionKey && params.agentHarnessCompletionScope ? { onDirectChildAccepted: () => {
|
|
6018
|
+
state.runtimeContinuationStarted = true;
|
|
6019
|
+
} } : {}
|
|
6020
|
+
});
|
|
6021
|
+
parentTransferred = submissionStore !== void 0;
|
|
6022
|
+
try {
|
|
6023
|
+
await registration.ready;
|
|
6024
|
+
await assertParentSessionCurrent();
|
|
6025
|
+
assertRegistrationCurrent();
|
|
6026
|
+
if (!submissionStore) {
|
|
6027
|
+
const unregister = registration.unregister;
|
|
6028
|
+
registration.unregister = () => unregister().finally(parent?.release);
|
|
6029
|
+
}
|
|
6030
|
+
state.nativeSubagentMonitor = registration;
|
|
6031
|
+
parentTransferred = true;
|
|
6032
|
+
} catch (error) {
|
|
6033
|
+
await registration.unregister();
|
|
6034
|
+
throw error;
|
|
6035
|
+
}
|
|
5880
6036
|
} catch (error) {
|
|
5881
|
-
|
|
6037
|
+
modelSource?.release();
|
|
5882
6038
|
throw error;
|
|
5883
6039
|
}
|
|
5884
|
-
}
|
|
5885
|
-
|
|
5886
|
-
throw error;
|
|
6040
|
+
} finally {
|
|
6041
|
+
if (!parentTransferred) parent?.release();
|
|
5887
6042
|
}
|
|
5888
6043
|
};
|
|
5889
6044
|
const releaseCurrentRoute = async () => {
|
|
@@ -6011,8 +6166,14 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
6011
6166
|
connection.assertCurrent();
|
|
6012
6167
|
const requiresProcessAdmission = nativeProcessAuthority?.requiresProcessAdmission && runtime.nativeToolSurfaceEnabled;
|
|
6013
6168
|
const requiresModelAdmission = nativeModelAdmission !== void 0 && decision.nativeModelInputTools !== void 0;
|
|
6014
|
-
const
|
|
6015
|
-
const
|
|
6169
|
+
const workspaceReadiness = runtime.nativeToolSurfaceEnabled ? params.hostCapabilities.workspaceReadiness : void 0;
|
|
6170
|
+
const requiresWorkspaceAdmission = workspaceReadiness !== void 0 && decision.nativeModelInputTools !== void 0;
|
|
6171
|
+
if (workspaceReadiness && !requiresWorkspaceAdmission) {
|
|
6172
|
+
await workspaceReadiness.waitUntilReady();
|
|
6173
|
+
connection.assertCurrent();
|
|
6174
|
+
}
|
|
6175
|
+
const requiresExecutionAdmission = requiresProcessAdmission || requiresModelAdmission || requiresWorkspaceAdmission;
|
|
6176
|
+
const relayEvents = requiresExecutionAdmission && !nativeHookRelayEvents.includes("pre_tool_use") ? [...nativeHookRelayEvents, "pre_tool_use"] : [...nativeHookRelayEvents];
|
|
6016
6177
|
if (params.pluginHarnessToolPolicyRestricted === true) {
|
|
6017
6178
|
state.nativeHookRelay = void 0;
|
|
6018
6179
|
return {
|
|
@@ -6067,7 +6228,11 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
6067
6228
|
timeoutMs: appServer.requestTimeoutMs,
|
|
6068
6229
|
onCleanupFailure: (error) => reportCodexBackgroundCleanupFailure(params, error)
|
|
6069
6230
|
},
|
|
6070
|
-
assertCurrent:
|
|
6231
|
+
assertCurrent: () => {
|
|
6232
|
+
connection.assertLegacyCurrent();
|
|
6233
|
+
},
|
|
6234
|
+
assertCurrentAsync: runtime.nativeExecutionPolicy.assertCurrent,
|
|
6235
|
+
retainExecutionPolicy: runtime.nativeExecutionPolicy.retain,
|
|
6071
6236
|
onPreToolUseFailure: (failure) => {
|
|
6072
6237
|
const projector = projectorRef.current;
|
|
6073
6238
|
if (projector) projector.recordNativeToolPreToolUseFailure(failure);
|
|
@@ -6087,7 +6252,7 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
6087
6252
|
configPatch: state.nativeHookRelay ? buildCodexNativeHookRelayConfig({
|
|
6088
6253
|
relay: state.nativeHookRelay,
|
|
6089
6254
|
events: relayEvents,
|
|
6090
|
-
hookTimeoutSec: options.nativeHookRelay?.hookTimeoutSec
|
|
6255
|
+
hookTimeoutSec: requiresWorkspaceAdmission ? Math.max(options.nativeHookRelay?.hookTimeoutSec ?? 0, params.timeoutMs / 1e3) : options.nativeHookRelay?.hookTimeoutSec
|
|
6091
6256
|
}) : options.nativeHookRelay?.enabled === false ? buildCodexNativeHookRelayDisabledConfig() : void 0,
|
|
6092
6257
|
nativeHookRelayGeneration: state.nativeHookRelay?.generation
|
|
6093
6258
|
};
|
|
@@ -6291,94 +6456,108 @@ async function prepareCodexAttemptRuntime(connection) {
|
|
|
6291
6456
|
});
|
|
6292
6457
|
preDynamicStartupStages.mark("bundle-mcp");
|
|
6293
6458
|
const sandboxExecServerEnabled = isCodexSandboxExecServerEnabled(pluginConfig, sandbox);
|
|
6294
|
-
|
|
6459
|
+
const nativeExecutionPolicy = await prepareCodexNativeExecutionPolicyForRun(runtimeParams, {
|
|
6295
6460
|
agentId: policyAgentId,
|
|
6296
6461
|
runtimeSessionKey: sandboxSessionKey,
|
|
6297
|
-
|
|
6462
|
+
sandbox
|
|
6298
6463
|
});
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
agentId:
|
|
6464
|
+
let handedOff = false;
|
|
6465
|
+
try {
|
|
6466
|
+
connection.assertCurrent();
|
|
6467
|
+
let nativeToolSurfaceEnabled = shouldEnableCodexAppServerNativeToolSurface(runtimeParams, sandbox, {
|
|
6468
|
+
agentId: policyAgentId,
|
|
6469
|
+
runtimeSessionKey: sandboxSessionKey,
|
|
6470
|
+
sandboxExecServerEnabled,
|
|
6471
|
+
nativeExecutionPolicy
|
|
6304
6472
|
});
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6473
|
+
if (nativeToolSurfaceEnabled && sandbox?.enabled && sandbox.backend && params.hostCapabilities.retainSourceAuthority) {
|
|
6474
|
+
const client = await attemptClientFactory({
|
|
6475
|
+
...clientOptions,
|
|
6476
|
+
assertCurrent: connection.assertCurrent,
|
|
6477
|
+
agentId: sessionAgentId
|
|
6478
|
+
});
|
|
6479
|
+
try {
|
|
6480
|
+
connection.assertCurrent();
|
|
6481
|
+
await assertCodexNativeHookRelayAllowed(client, runAbortController.signal, appServer.requestTimeoutMs);
|
|
6482
|
+
connection.assertCurrent();
|
|
6483
|
+
} catch (error) {
|
|
6484
|
+
if (!(error instanceof CodexManagedHooksOnlyError)) throw error;
|
|
6485
|
+
connection.assertCurrent();
|
|
6486
|
+
nativeToolSurfaceEnabled = false;
|
|
6487
|
+
embeddedAgentLog.info("Codex managed-only hooks require sandbox-backed OpenClaw tools");
|
|
6488
|
+
} finally {
|
|
6489
|
+
if (attemptClientFactory === createIsolatedCodexAppServerClient) await client.closeAndWait();
|
|
6490
|
+
else releaseLeasedSharedCodexAppServerClient(client);
|
|
6491
|
+
}
|
|
6317
6492
|
}
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
preparedAuth: startupPreparedAuth,
|
|
6336
|
-
agentDir,
|
|
6337
|
-
config: params.config,
|
|
6338
|
-
expectedNativeModelProvider: usesSupervisionConnection ? mutable.startupBinding?.modelProvider : void 0,
|
|
6339
|
-
modelProviderOverride: usesSupervisionConnection ? void 0 : resolveCodexAppServerThreadModelSelection({
|
|
6340
|
-
homeScope: appServer.start.homeScope,
|
|
6341
|
-
provider: params.provider,
|
|
6342
|
-
model: params.modelId,
|
|
6343
|
-
binding: mutable.startupBinding,
|
|
6344
|
-
authProfileId: startupAuthProfileId,
|
|
6345
|
-
authProfileStore: attemptAuthProfileStore,
|
|
6493
|
+
const configuredMcpSurface = params.requireWorkspaceOnly === true ? void 0 : scheduledConfiguredMcpSurface ? "scheduled" : !nativeToolSurfaceEnabled && bundleMcpThreadConfig.staticServerNames.length > 0 ? "transient" : void 0;
|
|
6494
|
+
preDynamicStartupStages.mark("native-tool-surface");
|
|
6495
|
+
const webSearchPlan = resolveCodexWebSearchPlan({
|
|
6496
|
+
config: params.config,
|
|
6497
|
+
disableTools: params.disableTools,
|
|
6498
|
+
nativeToolSurfaceEnabled
|
|
6499
|
+
});
|
|
6500
|
+
const supervisedSearchFingerprint = usesSupervisionConnection && !mutable.startupBinding?.pendingSupervisionBranch ? mutable.startupBinding?.webSearchThreadConfigFingerprint : void 0;
|
|
6501
|
+
let nativeProviderWebSearchSupport;
|
|
6502
|
+
if (isCodexResponsesOAuth(startupPreparedAuth)) nativeProviderWebSearchSupport = "supported";
|
|
6503
|
+
else if (webSearchPlan.kind !== "native-hosted" || supervisedSearchFingerprint === fingerprintJsonObject(resolveCodexWebSearchPlan({ disableTools: true }).threadConfig)) nativeProviderWebSearchSupport = "unsupported";
|
|
6504
|
+
else if (supervisedSearchFingerprint === fingerprintJsonObject(webSearchPlan.threadConfig)) nativeProviderWebSearchSupport = "supported";
|
|
6505
|
+
else nativeProviderWebSearchSupport = await resolveCodexProviderWebSearchSupport({
|
|
6506
|
+
clientFactory: attemptClientFactory,
|
|
6507
|
+
appServer,
|
|
6508
|
+
authProfileId: startupClientAuthProfileId,
|
|
6509
|
+
preparedAuth: startupPreparedAuth,
|
|
6346
6510
|
agentDir,
|
|
6347
|
-
config: params.config
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6511
|
+
config: params.config,
|
|
6512
|
+
expectedNativeModelProvider: usesSupervisionConnection ? mutable.startupBinding?.modelProvider : void 0,
|
|
6513
|
+
modelProviderOverride: usesSupervisionConnection ? void 0 : (await resolveCodexAppServerThreadModelSelection({
|
|
6514
|
+
homeScope: appServer.start.homeScope,
|
|
6515
|
+
provider: params.provider,
|
|
6516
|
+
model: params.modelId,
|
|
6517
|
+
binding: mutable.startupBinding,
|
|
6518
|
+
authProfileId: startupAuthProfileId,
|
|
6519
|
+
authProfileStore: attemptAuthProfileStore,
|
|
6520
|
+
agentDir,
|
|
6521
|
+
config: params.config
|
|
6522
|
+
})).modelProvider,
|
|
6523
|
+
signal: runAbortController.signal
|
|
6524
|
+
});
|
|
6525
|
+
preDynamicStartupStages.mark("provider-capabilities");
|
|
6526
|
+
for (const diagnostic of bundleMcpThreadConfig.diagnostics) embeddedAgentLog.warn(`bundle-mcp: ${diagnostic.pluginId}: ${diagnostic.message}`);
|
|
6527
|
+
if (activeContextEngine) assertContextEngineHostSupport({
|
|
6528
|
+
contextEngine: activeContextEngine,
|
|
6529
|
+
operation: "agent-run",
|
|
6530
|
+
host: CODEX_APP_SERVER_CONTEXT_ENGINE_HOST
|
|
6531
|
+
});
|
|
6532
|
+
const hookChannelId = resolveCodexAppServerHookChannelId(params, sandboxSessionKey);
|
|
6533
|
+
preDynamicStartupStages.mark("context-engine-support");
|
|
6534
|
+
handedOff = true;
|
|
6535
|
+
return {
|
|
6536
|
+
connection,
|
|
6537
|
+
clientOptions,
|
|
6538
|
+
preparedAuthBinding,
|
|
6539
|
+
runtimeParams,
|
|
6540
|
+
effectiveContextWindowInfo,
|
|
6541
|
+
effectiveContextTokenBudget,
|
|
6542
|
+
effectiveRuntimeProviderId,
|
|
6543
|
+
effectiveRuntimeModelId,
|
|
6544
|
+
startupAuthAccountCacheKey,
|
|
6545
|
+
startupEnvApiKeyCacheKey,
|
|
6546
|
+
bundleMcpThreadConfig,
|
|
6547
|
+
bundleManifestRegistry,
|
|
6548
|
+
authenticatedScheduledMode,
|
|
6549
|
+
configuredMcpSurface,
|
|
6550
|
+
canResolveScheduledConfiguredMcpCreatorAuthority: mayResolveScheduledConfiguredMcpCreatorAuthority,
|
|
6551
|
+
codexMcpToolOverrides,
|
|
6552
|
+
sandboxExecServerEnabled,
|
|
6553
|
+
nativeToolSurfaceEnabled,
|
|
6554
|
+
nativeExecutionPolicy,
|
|
6555
|
+
nativeProviderWebSearchSupport,
|
|
6556
|
+
hookChannelId
|
|
6557
|
+
};
|
|
6558
|
+
} finally {
|
|
6559
|
+
if (!handedOff) nativeExecutionPolicy.release();
|
|
6560
|
+
}
|
|
6382
6561
|
}
|
|
6383
6562
|
//#endregion
|
|
6384
6563
|
//#region extensions/codex/src/app-server/dynamic-tool-result-projection.ts
|
|
@@ -6399,10 +6578,9 @@ function recordCodexDynamicToolResult(projector, call, response, protocolRespons
|
|
|
6399
6578
|
//#endregion
|
|
6400
6579
|
//#region extensions/codex/src/app-server/run-attempt-tools.ts
|
|
6401
6580
|
function toTranscriptToolResult(response) {
|
|
6402
|
-
const
|
|
6403
|
-
const contentItems = Array.isArray(sanitized.contentItems) ? sanitized.contentItems : [];
|
|
6581
|
+
const contentItems = Array.isArray(response.contentItems) ? response.contentItems : [];
|
|
6404
6582
|
const result = {
|
|
6405
|
-
...
|
|
6583
|
+
...response,
|
|
6406
6584
|
content: contentItems.map(toTranscriptToolResultContentItem)
|
|
6407
6585
|
};
|
|
6408
6586
|
delete result.contentItems;
|
|
@@ -6547,7 +6725,7 @@ function createCodexAttemptServerRequestController(resources, turnRuntime, lifec
|
|
|
6547
6725
|
toolCallId: call.callId
|
|
6548
6726
|
});
|
|
6549
6727
|
const toolMeta = inferToolMetaFromArgs(call.tool, call.arguments, { detailMode: resolveCodexToolProgressDetailMode(params.toolProgressDetail) });
|
|
6550
|
-
const toolArgs =
|
|
6728
|
+
const toolArgs = asCodexToolArguments(call.arguments);
|
|
6551
6729
|
const commandBearing = isCodexCommandBearingToolCall(call.tool, toolArgs);
|
|
6552
6730
|
const shouldEmitDynamicToolProgress = shouldEmitTranscriptToolProgress(call.tool);
|
|
6553
6731
|
if (shouldEmitDynamicToolProgress) {
|
|
@@ -6689,6 +6867,14 @@ function createCodexAttemptServerRequestController(resources, turnRuntime, lifec
|
|
|
6689
6867
|
return protocolResponse;
|
|
6690
6868
|
} catch (error) {
|
|
6691
6869
|
pendingOpenClawDynamicToolCompletionIds.delete(call.callId);
|
|
6870
|
+
recordDynamicToolResult({
|
|
6871
|
+
call,
|
|
6872
|
+
response: {
|
|
6873
|
+
contentItems: [],
|
|
6874
|
+
success: false
|
|
6875
|
+
},
|
|
6876
|
+
durationMs: Math.max(0, Date.now() - toolStartedAt)
|
|
6877
|
+
});
|
|
6692
6878
|
if (!terminalDiagnosticObserved && !diagnostics.hasPendingTerminal()) diagnostics.error(Math.max(0, Date.now() - toolStartedAt));
|
|
6693
6879
|
await settlePluginRuntimeRefresh(turnId);
|
|
6694
6880
|
throw error;
|
|
@@ -6710,7 +6896,7 @@ function createCodexAttemptServerRequestController(resources, turnRuntime, lifec
|
|
|
6710
6896
|
//#region extensions/codex/src/app-server/attempt-runtime-artifact.ts
|
|
6711
6897
|
async function verifyStartupArtifact(params) {
|
|
6712
6898
|
if (!params.request) return;
|
|
6713
|
-
const { readCodexAppServerClientRuntimeArtifact, validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-
|
|
6899
|
+
const { readCodexAppServerClientRuntimeArtifact, validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-CmLWeyJB.mjs");
|
|
6714
6900
|
const runtimeArtifact = readCodexAppServerClientRuntimeArtifact(params.client);
|
|
6715
6901
|
const expected = params.request.expected;
|
|
6716
6902
|
const matchesExpected = !expected || runtimeArtifact?.id === expected.id && runtimeArtifact.fingerprint === expected.fingerprint;
|
|
@@ -6807,7 +6993,6 @@ function clearComputerUseHealthMonitor(client, monitor) {
|
|
|
6807
6993
|
}
|
|
6808
6994
|
//#endregion
|
|
6809
6995
|
//#region extensions/codex/src/app-server/attempt-startup.ts
|
|
6810
|
-
const CODEX_APP_SERVER_STARTUP_MAX_ATTEMPTS = 3;
|
|
6811
6996
|
/**
|
|
6812
6997
|
* Starts or resumes the Codex app-server thread and returns the resources the
|
|
6813
6998
|
* run loop must later release.
|
|
@@ -6819,6 +7004,17 @@ async function startCodexAttemptThread(params) {
|
|
|
6819
7004
|
let releaseSharedClientLease;
|
|
6820
7005
|
let startupClientForAbandonedRequestCleanup;
|
|
6821
7006
|
let releaseStartupResourcesOnTimeout;
|
|
7007
|
+
const startupStartedAt = performance.now();
|
|
7008
|
+
let stage = "configuration";
|
|
7009
|
+
let stageStartedAt = startupStartedAt;
|
|
7010
|
+
let acquireBoundary;
|
|
7011
|
+
let startupIdentity;
|
|
7012
|
+
let startupAttemptNumber = 0;
|
|
7013
|
+
const enterStartupStage = (nextStage) => {
|
|
7014
|
+
stage = nextStage;
|
|
7015
|
+
stageStartedAt = performance.now();
|
|
7016
|
+
acquireBoundary = void 0;
|
|
7017
|
+
};
|
|
6822
7018
|
const startupAbandonController = new AbortController();
|
|
6823
7019
|
const abandonStartupAcquire = () => startupAbandonController.abort();
|
|
6824
7020
|
params.signal.addEventListener("abort", abandonStartupAcquire, { once: true });
|
|
@@ -6827,6 +7023,21 @@ async function startCodexAttemptThread(params) {
|
|
|
6827
7023
|
timeoutMs: params.startupTimeoutMs,
|
|
6828
7024
|
signal: params.signal,
|
|
6829
7025
|
onTimeout: async () => {
|
|
7026
|
+
try {
|
|
7027
|
+
const client = startupClientForAbandonedRequestCleanup;
|
|
7028
|
+
const now = performance.now();
|
|
7029
|
+
embeddedAgentLog.warn("codex app-server startup timed out", {
|
|
7030
|
+
...startupIdentity,
|
|
7031
|
+
attempt: startupAttemptNumber,
|
|
7032
|
+
stage,
|
|
7033
|
+
stageElapsedMs: Math.max(0, Math.round(now - stageStartedAt)),
|
|
7034
|
+
elapsedMs: Math.max(0, Math.round(now - startupStartedAt)),
|
|
7035
|
+
timeoutMs: params.startupTimeoutMs,
|
|
7036
|
+
acquireBoundary,
|
|
7037
|
+
clientInstanceId: client?.getInstanceId(),
|
|
7038
|
+
clientPendingRequestMethods: client?.getPendingRequestMethods() ?? []
|
|
7039
|
+
});
|
|
7040
|
+
} catch {}
|
|
6830
7041
|
startupAbandonController.abort();
|
|
6831
7042
|
await params.onStartupTimeout();
|
|
6832
7043
|
await releaseStartupResourcesOnTimeout?.();
|
|
@@ -6848,18 +7059,27 @@ async function startCodexAttemptThread(params) {
|
|
|
6848
7059
|
...params.appServer,
|
|
6849
7060
|
approvalPolicy: withMcpElicitationsApprovalPolicy(params.appServer.approvalPolicy)
|
|
6850
7061
|
} : params.appServer;
|
|
6851
|
-
let attemptedClient;
|
|
6852
7062
|
const startupAttempt = async () => {
|
|
7063
|
+
startupAttemptNumber += 1;
|
|
6853
7064
|
let startupClientLease;
|
|
6854
7065
|
let startupClient;
|
|
6855
7066
|
let startupAttemptError;
|
|
6856
7067
|
let startupAttemptSucceeded = false;
|
|
6857
7068
|
try {
|
|
6858
7069
|
const attemptParams = params.buildAttemptParams();
|
|
7070
|
+
startupIdentity = {
|
|
7071
|
+
runId: attemptParams.runId,
|
|
7072
|
+
sessionId: attemptParams.sessionId
|
|
7073
|
+
};
|
|
6859
7074
|
params.assertCurrent?.();
|
|
6860
7075
|
if (startupAbandonController.signal.aborted) throw new CodexAppServerStartupError("aborted");
|
|
7076
|
+
enterStartupStage("client-acquire");
|
|
6861
7077
|
startupClient = await params.attemptClientFactory({
|
|
6862
7078
|
...params.clientOptions,
|
|
7079
|
+
onAcquireObservation: (observation) => {
|
|
7080
|
+
if (stage === "client-acquire") acquireBoundary = observation.boundary;
|
|
7081
|
+
observeAcquire(params.clientOptions, observation);
|
|
7082
|
+
},
|
|
6863
7083
|
assertCurrent: () => {
|
|
6864
7084
|
params.assertCurrent?.();
|
|
6865
7085
|
params.authority?.assertLegacyCurrent();
|
|
@@ -6886,9 +7106,9 @@ async function startCodexAttemptThread(params) {
|
|
|
6886
7106
|
else releaseLeasedSharedCodexAppServerClient(activeStartupClient);
|
|
6887
7107
|
};
|
|
6888
7108
|
releaseSharedClientLease = startupClientLease;
|
|
6889
|
-
attemptedClient = activeStartupClient;
|
|
6890
7109
|
startupClientForAbandonedRequestCleanup = activeStartupClient;
|
|
6891
7110
|
if (startupAbandonController.signal.aborted) throw new CodexAppServerStartupError("aborted");
|
|
7111
|
+
enterStartupStage("runtime-artifact");
|
|
6892
7112
|
const runtimeArtifact = await verifyStartupArtifact({
|
|
6893
7113
|
client: activeStartupClient,
|
|
6894
7114
|
startOptions: params.appServer.start,
|
|
@@ -6907,6 +7127,7 @@ async function startCodexAttemptThread(params) {
|
|
|
6907
7127
|
let computerUseTools = [];
|
|
6908
7128
|
let computerUseConfig = params.computerUseConfig;
|
|
6909
7129
|
try {
|
|
7130
|
+
enterStartupStage("computer-use");
|
|
6910
7131
|
const computerUseStatus = await ensureCodexComputerUse({
|
|
6911
7132
|
client: activeStartupClient,
|
|
6912
7133
|
pluginConfig: params.pluginConfig,
|
|
@@ -6922,7 +7143,7 @@ async function startCodexAttemptThread(params) {
|
|
|
6922
7143
|
mcpServerName: computerUseStatus.mcpServerName
|
|
6923
7144
|
};
|
|
6924
7145
|
} catch (error) {
|
|
6925
|
-
if (startupAbandonController.signal.aborted
|
|
7146
|
+
if (startupAbandonController.signal.aborted) throw error;
|
|
6926
7147
|
throw new AgentHarnessPreflightError(`Codex Computer Use readiness failed: ${formatErrorMessage(error)}`, {
|
|
6927
7148
|
cause: error,
|
|
6928
7149
|
scope: "harness"
|
|
@@ -6975,6 +7196,7 @@ async function startCodexAttemptThread(params) {
|
|
|
6975
7196
|
nativeToolSurfaceEnabled: params.nativeToolSurfaceEnabled,
|
|
6976
7197
|
sandboxExecServerEnabled: params.sandboxExecServerEnabled
|
|
6977
7198
|
});
|
|
7199
|
+
enterStartupStage("sandbox-environment");
|
|
6978
7200
|
startupSandboxEnvironment = sandboxEnvironmentRequired ? await ensureCodexSandboxExecServerEnvironment({
|
|
6979
7201
|
client: activeStartupClient,
|
|
6980
7202
|
sandbox: params.sandbox ?? null,
|
|
@@ -7015,6 +7237,7 @@ async function startCodexAttemptThread(params) {
|
|
|
7015
7237
|
return { release: releaseStartupReservation };
|
|
7016
7238
|
};
|
|
7017
7239
|
const releaseStartupResources = async () => {
|
|
7240
|
+
enterStartupStage("resource-cleanup");
|
|
7018
7241
|
releaseStartupReservation();
|
|
7019
7242
|
await releaseStartupSandboxEnvironment();
|
|
7020
7243
|
};
|
|
@@ -7065,10 +7288,12 @@ async function startCodexAttemptThread(params) {
|
|
|
7065
7288
|
})
|
|
7066
7289
|
});
|
|
7067
7290
|
try {
|
|
7291
|
+
enterStartupStage("thread-lifecycle");
|
|
7068
7292
|
const startupThread = await startOrResumeThread(buildThreadLifecycleParams(startupAbandonController.signal, reserveStartupThread));
|
|
7069
7293
|
try {
|
|
7070
7294
|
reserveStartupThread(startupThread.threadId);
|
|
7071
7295
|
} catch (error) {
|
|
7296
|
+
enterStartupStage("subscription-cleanup");
|
|
7072
7297
|
if (!await unsubscribeCodexThreadBestEffort(activeStartupClient, {
|
|
7073
7298
|
threadId: startupThread.threadId,
|
|
7074
7299
|
timeoutMs: 5e3
|
|
@@ -7096,16 +7321,10 @@ async function startCodexAttemptThread(params) {
|
|
|
7096
7321
|
sandboxPolicy: startupSandboxPolicy,
|
|
7097
7322
|
...runtimeArtifact ? { runtimeArtifact } : {},
|
|
7098
7323
|
restartContextEngineCodexThread: async () => {
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
});
|
|
7104
|
-
} catch (error) {
|
|
7105
|
-
if (!isCodexAppServerStartSelectionChangedError(error)) throw error;
|
|
7106
|
-
retireSharedCodexAppServerClientIfCurrent(activeStartupClient);
|
|
7107
|
-
throw Object.assign(new Error("codex app-server client is closed", { cause: error }), { code: CODEX_APP_SERVER_CONTEXT_RESTART_SELECTION_CHANGED });
|
|
7108
|
-
}
|
|
7324
|
+
return await startOrResumeThread({
|
|
7325
|
+
...buildThreadLifecycleParams(params.signal),
|
|
7326
|
+
contextEngineProjection: void 0
|
|
7327
|
+
});
|
|
7109
7328
|
}
|
|
7110
7329
|
};
|
|
7111
7330
|
} catch (error) {
|
|
@@ -7126,45 +7345,23 @@ async function startCodexAttemptThread(params) {
|
|
|
7126
7345
|
startupClientLease?.();
|
|
7127
7346
|
if (shouldRetireCodexStartupClient(startupAttemptError, params.spawnedBy, startupAbandonController.signal)) {
|
|
7128
7347
|
if (startupClientForAbandonedRequestCleanup === startupClient) startupClientForAbandonedRequestCleanup = void 0;
|
|
7348
|
+
enterStartupStage("client-retirement");
|
|
7129
7349
|
await closeCodexStartupClientBestEffort(startupClient);
|
|
7130
7350
|
}
|
|
7131
7351
|
}
|
|
7132
7352
|
}
|
|
7133
7353
|
if (startupAttemptError instanceof CodexThreadClientReplacementError && startupClient) {
|
|
7354
|
+
enterStartupStage("client-retirement");
|
|
7134
7355
|
if (!(await startupClient.closeAndWait()).exited) throw new AgentHarnessPreflightError("The previous conversation process did not confirm shutdown; the conversation was preserved.");
|
|
7135
7356
|
}
|
|
7136
7357
|
throw startupAttemptError;
|
|
7137
7358
|
};
|
|
7138
|
-
|
|
7139
|
-
for (let attempt = 1; attempt <= CODEX_APP_SERVER_STARTUP_MAX_ATTEMPTS; attempt += 1) try {
|
|
7359
|
+
try {
|
|
7140
7360
|
return await startupAttempt();
|
|
7141
7361
|
} catch (error) {
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
if (startupAbandonController.signal.aborted || isCodexWebSocketOpenFailure(error) || clientRetired && replacedSettledFailureClient || !clientRetired && !selectionChanged && !isCodexAppServerConnectionClosedError(error)) throw error;
|
|
7145
|
-
replacedSettledFailureClient ||= clientRetired;
|
|
7146
|
-
const refreshedSharedClient = clientRetired ? void 0 : selectionChanged ? retireSharedCodexAppServerClientIfCurrent(attemptedClient) : clearSharedCodexAppServerClientIfCurrent(attemptedClient);
|
|
7147
|
-
if (startupClientForAbandonedRequestCleanup === attemptedClient) startupClientForAbandonedRequestCleanup = void 0;
|
|
7148
|
-
if (attempt >= CODEX_APP_SERVER_STARTUP_MAX_ATTEMPTS) {
|
|
7149
|
-
embeddedAgentLog.warn(selectionChanged ? "codex app-server executable selection kept changing during startup; retries exhausted" : "codex app-server connection closed during startup; retries exhausted", {
|
|
7150
|
-
attempt,
|
|
7151
|
-
maxAttempts: CODEX_APP_SERVER_STARTUP_MAX_ATTEMPTS,
|
|
7152
|
-
refreshedSharedClient,
|
|
7153
|
-
error: formatErrorMessage(error)
|
|
7154
|
-
});
|
|
7155
|
-
throw error;
|
|
7156
|
-
}
|
|
7157
|
-
const retryDelayMs = selectionChanged || clientRetired ? 0 : 1e3 * 2 ** (attempt - 1);
|
|
7158
|
-
embeddedAgentLog.warn(clientRetired ? "codex app-server retired a settled failed client; resuming on a fresh client" : selectionChanged ? "codex app-server executable selection changed during startup; restarting app-server and retrying" : "codex app-server connection closed during startup; restarting app-server and retrying", {
|
|
7159
|
-
attempt,
|
|
7160
|
-
nextAttempt: attempt + 1,
|
|
7161
|
-
maxAttempts: CODEX_APP_SERVER_STARTUP_MAX_ATTEMPTS,
|
|
7162
|
-
refreshedSharedClient,
|
|
7163
|
-
error: formatErrorMessage(error)
|
|
7164
|
-
});
|
|
7165
|
-
await sleepWithAbort(retryDelayMs, startupAbandonController.signal);
|
|
7362
|
+
if (startupAbandonController.signal.aborted || !(error instanceof CodexThreadClientReplacementError)) throw error;
|
|
7363
|
+
return await startupAttempt();
|
|
7166
7364
|
}
|
|
7167
|
-
throw new Error("codex app-server startup retry loop exited unexpectedly");
|
|
7168
7365
|
}
|
|
7169
7366
|
});
|
|
7170
7367
|
startupClientForAbandonedRequestCleanup = void 0;
|
|
@@ -7431,6 +7628,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7431
7628
|
let resolveCreatorAuthorityImpl;
|
|
7432
7629
|
const runtimeYieldCompletionClaim = {};
|
|
7433
7630
|
const commonToolParams = {
|
|
7631
|
+
nativeExecutionPolicy: runtime.nativeExecutionPolicy,
|
|
7434
7632
|
nodeExecAvailability: {},
|
|
7435
7633
|
params: dynamicToolParams,
|
|
7436
7634
|
resolvedWorkspace,
|
|
@@ -7671,6 +7869,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7671
7869
|
}) : void 0;
|
|
7672
7870
|
const registeredFallbackTools = params.trigger === "heartbeat" || params.enableHeartbeatTool === true || params.forceHeartbeatTool === true || !heartbeatFallbackTool ? void 0 : params.hostCapabilities.bindToolSurface([heartbeatFallbackTool], { cwd: effectiveCwd ?? effectiveWorkspace });
|
|
7673
7871
|
const toolBridge = createCodexDynamicToolBridge({
|
|
7872
|
+
assertCurrentAsync: runtime.nativeExecutionPolicy.assertCurrent,
|
|
7674
7873
|
tools: toolsWithScopedMcp,
|
|
7675
7874
|
registeredTools: registeredWithScopedMcp,
|
|
7676
7875
|
registeredFallbackTools,
|
|
@@ -7876,40 +8075,6 @@ async function prepareCodexProviderReviewContinuation(params) {
|
|
|
7876
8075
|
}
|
|
7877
8076
|
}
|
|
7878
8077
|
//#endregion
|
|
7879
|
-
//#region extensions/codex/src/app-server/service-tier.ts
|
|
7880
|
-
/** Validate an explicit Ultrafast selection against this turn's native model and client. */
|
|
7881
|
-
async function resolveCodexUltrafastServiceTier(params) {
|
|
7882
|
-
if (!params.enabled || params.modelProvider !== "openai" && params.modelProvider !== "openclaw_token_sharing" || !params.model) return params.serviceTier;
|
|
7883
|
-
params.signal.throwIfAborted();
|
|
7884
|
-
params.assertCurrent();
|
|
7885
|
-
const deadline = Date.now() + params.timeoutMs;
|
|
7886
|
-
try {
|
|
7887
|
-
const catalog = await listAllCodexAppServerModels({
|
|
7888
|
-
includeHidden: true,
|
|
7889
|
-
request: (request) => {
|
|
7890
|
-
const timeoutMs = deadline - Date.now();
|
|
7891
|
-
if (timeoutMs <= 0) throw new Error("Codex Ultrafast catalog deadline exceeded");
|
|
7892
|
-
return requestCodexAppServerClientJson({
|
|
7893
|
-
...request,
|
|
7894
|
-
client: params.client,
|
|
7895
|
-
signal: params.signal,
|
|
7896
|
-
assertCurrent: params.assertCurrent,
|
|
7897
|
-
timeoutMs,
|
|
7898
|
-
config: params.config
|
|
7899
|
-
});
|
|
7900
|
-
}
|
|
7901
|
-
});
|
|
7902
|
-
params.signal.throwIfAborted();
|
|
7903
|
-
params.assertCurrent();
|
|
7904
|
-
return catalog.models.find((entry) => entry.model === params.model)?.serviceTiers?.includes("ultrafast") ? "ultrafast" : params.serviceTier;
|
|
7905
|
-
} catch (error) {
|
|
7906
|
-
params.signal.throwIfAborted();
|
|
7907
|
-
params.assertCurrent();
|
|
7908
|
-
if (error instanceof CodexAppServerScopedRequestRejectedError) throw error;
|
|
7909
|
-
return params.serviceTier;
|
|
7910
|
-
}
|
|
7911
|
-
}
|
|
7912
|
-
//#endregion
|
|
7913
8078
|
//#region extensions/codex/src/app-server/run-attempt-turn-request.ts
|
|
7914
8079
|
async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurrentThreadRoute, waitForActiveNativeTurnCompletion) {
|
|
7915
8080
|
const { prompt, state: resourceState, releaseCurrentRoute } = resources;
|
|
@@ -7976,7 +8141,7 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
7976
8141
|
const turnAppServer = withCodexAppServerFastModeServiceTier(connection.mutable.pluginAppServer, { fastMode }, connection.appServer);
|
|
7977
8142
|
const references = prepareWorkspaceReferences();
|
|
7978
8143
|
const inferenceRoute = getCodexInferenceThread(resourceState.client, resourceState.thread.threadId);
|
|
7979
|
-
const turnStartParams = buildTurnStartParams(runtimeParams, {
|
|
8144
|
+
const turnStartParams = await buildTurnStartParams(runtimeParams, {
|
|
7980
8145
|
threadId: resourceState.thread.threadId,
|
|
7981
8146
|
cwd: resourceState.codexExecutionCwd,
|
|
7982
8147
|
appServer: turnAppServer,
|
|
@@ -7997,17 +8162,7 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
7997
8162
|
requireExplicitMessageTarget: attemptTools.requireExplicitMessageTarget,
|
|
7998
8163
|
sessionStatusAvailable: toolBridge.availableTools.some((tool) => tool.name === "session_status")
|
|
7999
8164
|
});
|
|
8000
|
-
const serviceTier =
|
|
8001
|
-
enabled: fastMode === "ultrafast" && turnAppServer.enableUltrafast !== false,
|
|
8002
|
-
serviceTier: turnStartParams.serviceTier,
|
|
8003
|
-
model: turnStartParams.model ?? model,
|
|
8004
|
-
modelProvider: modelProvider ?? effectiveRuntimeProviderId,
|
|
8005
|
-
client: turnClient,
|
|
8006
|
-
timeoutMs: Math.min(params.timeoutMs, 2500),
|
|
8007
|
-
signal: runAbortController.signal,
|
|
8008
|
-
assertCurrent: assertTurnCurrent,
|
|
8009
|
-
config: params.config
|
|
8010
|
-
});
|
|
8165
|
+
const serviceTier = fastMode === "ultrafast" ? selectedThread.preparedServiceTier : turnStartParams.serviceTier;
|
|
8011
8166
|
assertTurnCurrent();
|
|
8012
8167
|
turnStartParams.serviceTier = serviceTier;
|
|
8013
8168
|
connection.mutable.pluginAppServer = {
|
|
@@ -8103,6 +8258,7 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8103
8258
|
}
|
|
8104
8259
|
}));
|
|
8105
8260
|
acceptedTurnId = startedTurn.turn.id;
|
|
8261
|
+
recordCodexTurnForkSettings(turnClient, turnStartParams);
|
|
8106
8262
|
resources.nativeProcessAuthority?.bindTurn(turnClient, threadId, acceptedTurnId);
|
|
8107
8263
|
assertTurnCurrent();
|
|
8108
8264
|
resourceState.nativeSubagentMonitor?.bindTurn(acceptedTurnId, modelMapping);
|
|
@@ -8305,7 +8461,7 @@ async function startCodexAttemptTurn(resources, turnRuntime, notifications, requ
|
|
|
8305
8461
|
authProfileId: startupAuthProfileId,
|
|
8306
8462
|
rateLimits: usageLimitError.rateLimitsForProfile
|
|
8307
8463
|
});
|
|
8308
|
-
else
|
|
8464
|
+
else throw turnStartError;
|
|
8309
8465
|
const result = buildCodexTurnStartFailureResult({
|
|
8310
8466
|
params,
|
|
8311
8467
|
message,
|
|
@@ -8353,7 +8509,6 @@ var CodexAttemptState = class {
|
|
|
8353
8509
|
this.projectionClosed = false;
|
|
8354
8510
|
this.terminalDynamicToolReleaseCheckScheduled = false;
|
|
8355
8511
|
this.currentTurnHadNonTerminalDynamicToolResult = false;
|
|
8356
|
-
this.currentTurnHadToolAuthoredFinalReply = false;
|
|
8357
8512
|
}
|
|
8358
8513
|
};
|
|
8359
8514
|
function createCodexAttemptTurnState(resources) {
|
|
@@ -8432,6 +8587,7 @@ function createCodexAttemptTurnState(resources) {
|
|
|
8432
8587
|
};
|
|
8433
8588
|
const deadlines = createAgentHarnessAttemptDeadlineController({
|
|
8434
8589
|
startedAtMs: connection.attemptStartedAt,
|
|
8590
|
+
startedAtMonotonicMs: connection.attemptStartedAtMonotonicMs,
|
|
8435
8591
|
timeoutMs: params.timeoutMs,
|
|
8436
8592
|
settlementTimeoutMs: TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS,
|
|
8437
8593
|
signal: runAbortController.signal,
|
|
@@ -8500,66 +8656,79 @@ async function runCodexAppServerAttempt(params, options) {
|
|
|
8500
8656
|
}));
|
|
8501
8657
|
try {
|
|
8502
8658
|
const runtime = await preparation.measure("runtime", () => prepareCodexAttemptRuntime(connection));
|
|
8503
|
-
const attemptTools = await preparation.measure("tools", () => prepareCodexAttemptTools(runtime));
|
|
8504
8659
|
try {
|
|
8505
|
-
const
|
|
8506
|
-
const resources = prepareCodexAttemptResources(await preparation.measure("prompt", () => prepareCodexAttemptPrompt(attemptContext)));
|
|
8507
|
-
attemptTools.runtimeYieldCompletionClaim.current = () => resources.state.nativeHookRelay?.hasClaimedDirectChild() ?? false;
|
|
8508
|
-
let activeTurnOwnsCleanup = false;
|
|
8660
|
+
const attemptTools = await preparation.measure("tools", () => prepareCodexAttemptTools(runtime));
|
|
8509
8661
|
try {
|
|
8510
|
-
await preparation.measure("
|
|
8511
|
-
const
|
|
8662
|
+
const attemptContext = await preparation.measure("context", () => prepareCodexAttemptContext(runtime, attemptTools));
|
|
8663
|
+
const resources = prepareCodexAttemptResources(await preparation.measure("prompt", () => prepareCodexAttemptPrompt(attemptContext)));
|
|
8664
|
+
attemptTools.runtimeYieldCompletionClaim.current = () => {
|
|
8665
|
+
if (resources.state.nativeHookRelay?.hasClaimedDirectChild()) return true;
|
|
8666
|
+
const pendingChildren = resources.state.nativeSubagentMonitor?.listPendingChildren() ?? [];
|
|
8667
|
+
return pendingChildren.length > 0 ? { pendingChildren } : false;
|
|
8668
|
+
};
|
|
8669
|
+
let activeTurnOwnsCleanup = false;
|
|
8512
8670
|
try {
|
|
8513
|
-
|
|
8514
|
-
const
|
|
8515
|
-
const serverRequests = createCodexAttemptServerRequestController(resources, turnRuntime, lifecycle, notifications.waitForNativeTerminalItems);
|
|
8516
|
-
const { ensureCurrentThreadRoute } = await preparation.measure("thread-route", () => prepareCodexAttemptRoute(resources, turnRuntime, notifications, serverRequests.handleServerRequest));
|
|
8517
|
-
const turnRequest = await preparation.measure("turn-request", () => prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurrentThreadRoute, notifications.waitForActiveNativeTurnCompletion));
|
|
8518
|
-
preparation.ready();
|
|
8519
|
-
const turnStart = await startCodexAttemptTurn(resources, turnRuntime, notifications, turnRequest);
|
|
8520
|
-
if ("result" in turnStart) {
|
|
8521
|
-
connection.assertModelExecutionCurrent();
|
|
8522
|
-
return turnStart.result;
|
|
8523
|
-
}
|
|
8524
|
-
const activeTurn = activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notifications, turnStart);
|
|
8525
|
-
activeTurnOwnsCleanup = true;
|
|
8526
|
-
let finalizedResult;
|
|
8671
|
+
await preparation.measure("runtime-start", () => startCodexAttemptRuntime(resources));
|
|
8672
|
+
const turnRuntime = createCodexAttemptTurnState(resources);
|
|
8527
8673
|
try {
|
|
8674
|
+
const lifecycle = createCodexAttemptLifecycleController(resources, turnRuntime);
|
|
8675
|
+
const notifications = createCodexAttemptNotificationController(resources, turnRuntime, lifecycle);
|
|
8676
|
+
const serverRequests = createCodexAttemptServerRequestController(resources, turnRuntime, lifecycle, notifications.waitForNativeTerminalItems);
|
|
8677
|
+
const { ensureCurrentThreadRoute } = await preparation.measure("thread-route", () => prepareCodexAttemptRoute(resources, turnRuntime, notifications, serverRequests.handleServerRequest));
|
|
8678
|
+
const turnRequest = await preparation.measure("turn-request", () => prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurrentThreadRoute, notifications.waitForActiveNativeTurnCompletion));
|
|
8679
|
+
preparation.ready();
|
|
8680
|
+
const turnStart = await startCodexAttemptTurn(resources, turnRuntime, notifications, turnRequest);
|
|
8681
|
+
if ("result" in turnStart) {
|
|
8682
|
+
connection.assertModelExecutionCurrent();
|
|
8683
|
+
return turnStart.result;
|
|
8684
|
+
}
|
|
8685
|
+
const activeTurn = activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notifications, turnStart);
|
|
8686
|
+
activeTurnOwnsCleanup = true;
|
|
8687
|
+
let finalizedResult;
|
|
8528
8688
|
try {
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8689
|
+
try {
|
|
8690
|
+
await activeTurn.ready;
|
|
8691
|
+
finalizedResult = await finalizeCodexAttempt(resources, turnRuntime, lifecycle, notifications, turnRequest, activeTurn);
|
|
8692
|
+
} finally {
|
|
8693
|
+
await cleanupCodexAttempt(resources, turnRuntime, lifecycle, turnRequest, activeTurn);
|
|
8694
|
+
}
|
|
8695
|
+
} catch (error) {
|
|
8696
|
+
connection.assertModelExecutionCurrent();
|
|
8697
|
+
if (!finalizedResult || !turnRuntime.state.pluginRuntimeRefreshStop) throw error;
|
|
8698
|
+
const original = attemptTerminal.project(finalizedResult.terminal).promptError;
|
|
8699
|
+
finalizedResult.terminal = attemptTerminal.merge(finalizedResult.terminal, {
|
|
8700
|
+
kind: "failed",
|
|
8701
|
+
source: "prompt",
|
|
8702
|
+
error: new AggregateError(original ? [original, error] : [error], "Plugin runtime changed, but native continuation failed. Inspect the existing thread before continuing; do not repeat completed actions.")
|
|
8703
|
+
});
|
|
8704
|
+
delete finalizedResult.pluginRuntimeRefreshMessages;
|
|
8705
|
+
delete finalizedResult.settledTurnFinalizationContext;
|
|
8533
8706
|
}
|
|
8534
|
-
|
|
8707
|
+
if (resources.state.executionDisconnectError && !connection.terminalState.explicitCancellationObserved) throw resources.state.executionDisconnectError;
|
|
8535
8708
|
connection.assertModelExecutionCurrent();
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
kind: "failed",
|
|
8540
|
-
source: "prompt",
|
|
8541
|
-
error: new AggregateError(original ? [original, error] : [error], "Plugin runtime changed, but native continuation failed. Inspect the existing thread before continuing; do not repeat completed actions.")
|
|
8542
|
-
});
|
|
8543
|
-
delete finalizedResult.pluginRuntimeRefreshMessages;
|
|
8544
|
-
delete finalizedResult.settledTurnFinalizationContext;
|
|
8709
|
+
return finalizedResult;
|
|
8710
|
+
} finally {
|
|
8711
|
+
turnRuntime.deadlines.dispose();
|
|
8545
8712
|
}
|
|
8546
|
-
if (resources.state.executionDisconnectError && !connection.terminalState.explicitCancellationObserved) throw resources.state.executionDisconnectError;
|
|
8547
|
-
connection.assertModelExecutionCurrent();
|
|
8548
|
-
return finalizedResult;
|
|
8549
8713
|
} finally {
|
|
8550
|
-
|
|
8714
|
+
if (!activeTurnOwnsCleanup) await resources.cleanupBeforeActiveTurn();
|
|
8551
8715
|
}
|
|
8552
8716
|
} finally {
|
|
8553
|
-
|
|
8717
|
+
await attemptTools.disposeTools(connection.runAbortController.signal.aborted ? "cancel" : "error");
|
|
8554
8718
|
}
|
|
8555
8719
|
} finally {
|
|
8556
|
-
|
|
8720
|
+
runtime.nativeExecutionPolicy.release();
|
|
8557
8721
|
}
|
|
8558
8722
|
} catch (error) {
|
|
8559
8723
|
throw codexPrewriteRejectionCause(error);
|
|
8560
8724
|
} finally {
|
|
8561
|
-
|
|
8562
|
-
|
|
8725
|
+
try {
|
|
8726
|
+
connection.cancellation.dispose();
|
|
8727
|
+
connection.releaseModelExecution();
|
|
8728
|
+
connection.releaseSandboxContext();
|
|
8729
|
+
} finally {
|
|
8730
|
+
connection.releaseBindingAuthority();
|
|
8731
|
+
}
|
|
8563
8732
|
}
|
|
8564
8733
|
}
|
|
8565
8734
|
//#endregion
|