@openclaw/codex 2026.9.8 → 2026.10.1-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 +8 -0
- package/dist/.setup/{account-usage-runtime-G348lY1q.mjs → account-usage-runtime-DGqFpAud.mjs} +5 -5
- package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
- package/dist/.setup/{apply-Cqb-YoCS.mjs → apply-CXTudl9p.mjs} +48 -39
- package/dist/.setup/attempt-client-cleanup-BH0hW2xU.mjs +155 -0
- package/dist/.setup/{attempt-workspace-context-BJ5Z_olH.mjs → attempt-workspace-context-BY0jprWJ.mjs} +11 -15
- package/dist/.setup/{auth-binding-BLWz7stm.mjs → auth-binding-BoMwpuPN.mjs} +17 -25
- package/dist/.setup/{auth-cache-key-Dnps4W4_.mjs → auth-cache-key-CGm0UJOr.mjs} +244 -82
- package/dist/.setup/{auth-profile-B0okYl2D.mjs → auth-profile-CgHQ8Vot.mjs} +2 -1
- package/dist/.setup/{auth-profile-selection-DFu9e167.mjs → auth-profile-selection-hr8ocLtz.mjs} +5 -7
- package/dist/.setup/{binding-connection-DTtN1KrX.mjs → binding-connection-C-08ez1w.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-6TpgD1M6.mjs → binding-connection.runtime-Dn2p-fdy.mjs} +3 -3
- package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
- package/dist/.setup/{bounded-turn-BNunZPtz.mjs → bounded-turn-pGsfXcmH.mjs} +14 -13
- package/dist/.setup/{build-state-DIQ5O_-S.mjs → build-state-CqQnsg7T.mjs} +1 -1
- package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
- package/dist/.setup/{client-qyUBJlGZ.mjs → client-C8lgBOoO.mjs} +438 -160
- package/dist/.setup/{client-catalog-response-DRvx_wCC.mjs → client-catalog-response-Bqp7WG51.mjs} +57 -25
- package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
- package/dist/.setup/{command-dispatch-Btrs1D6f.mjs → command-dispatch-DhBbFIQ5.mjs} +3 -3
- package/dist/.setup/{command-formatters-R3ckE3Co.mjs → command-formatters-DV3DHhdr.mjs} +7 -5
- package/dist/.setup/{command-handlers-DvlCHJch.mjs → command-handlers-ztOOzm6O.mjs} +82 -144
- package/dist/.setup/{command-rpc-skzRq4wD.mjs → command-rpc-CuC5fPom.mjs} +23 -31
- package/dist/.setup/{compact-8ttks5U5.mjs → compact-tUb9AYfH.mjs} +117 -65
- package/dist/.setup/{plugin-metadata-cache-BRwtRct9.mjs → computer-use-BBN9y326.mjs} +65 -202
- package/dist/.setup/{config-DKhXquav.mjs → config-0Gxk3_eq.mjs} +5 -6
- package/dist/.setup/{config-options-CzyWLTJt.mjs → config-options-HG_Rr3W_.mjs} +13 -23
- package/dist/.setup/{config-parsing-b088LyhT.mjs → config-parsing-BQq-CHTF.mjs} +41 -4
- package/dist/.setup/{config-runtime-C0NbLms1.mjs → config-runtime-cUYrqu_a.mjs} +2 -2
- package/dist/.setup/{config-security-CE-FcGw9.mjs → config-security-KAPScztc.mjs} +20 -36
- package/dist/.setup/{context-engine-projection-PezSESth.mjs → context-engine-projection-CsgYSQhW.mjs} +11 -14
- package/dist/.setup/{conversation-binding-74LaGGH-.mjs → conversation-binding-B3MNMVzb.mjs} +36 -48
- package/dist/.setup/{conversation-binding-data-C746z5Pn.mjs → conversation-binding-data-DJ4ix-W5.mjs} +1 -1
- package/dist/.setup/{conversation-control-OrN6zuaY.mjs → conversation-control-CYsMlCuE.mjs} +19 -21
- package/dist/.setup/{cyber-failover-XV0nNRZu.mjs → cyber-failover-Bb1J6hS1.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-RNpGpTyP.mjs → cyber-failover-notice-XR03ef31.mjs} +1 -1
- package/dist/.setup/doctor-start-options-DPW9JxIE.mjs +63 -0
- package/dist/.setup/dynamic-tool-build-C8xGEXmR.mjs +463 -0
- package/dist/.setup/{dynamic-tools-Db2sY5cZ.mjs → dynamic-tools-DyERJnR6.mjs} +238 -878
- package/dist/.setup/{effective-mcp-catalog-Bi6-SQ7i.mjs → effective-mcp-catalog-C26Mio5l.mjs} +83 -11
- package/dist/.setup/{elicitation-input-DPoK8F7w.mjs → elicitation-input-r9axtppm.mjs} +4 -2
- package/dist/.setup/{ephemeral-turn-DiCS1ijR.mjs → ephemeral-turn-D8VcDTNo.mjs} +2 -2
- package/dist/.setup/{event-projector-assistant-message-MV_1dj-3.mjs → event-projector-assistant-message-BN7CNUB5.mjs} +2 -2
- package/dist/.setup/{event-projector-values-DJSz8BTk.mjs → event-projector-values-DTqZHizf.mjs} +2 -12
- package/dist/.setup/{inference-dispatch-CMZtjQyz.mjs → inference-dispatch-B5UKEUyC.mjs} +12 -21
- package/dist/.setup/{inference-proxy-DhcXOgUE.mjs → inference-proxy-DUO5E2QQ.mjs} +6 -5
- package/dist/.setup/{isolated-completion-D80IXfQF.mjs → isolated-completion-C0jrcplS.mjs} +8 -8
- package/dist/.setup/{managed-binary-kiWRhNRE.mjs → managed-binary-C1VFoVPf.mjs} +31 -38
- package/dist/.setup/mcp-app-session-preparation-BxN0_CYe.mjs +223 -0
- package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
- package/dist/.setup/{model-catalog-DiC0Tkha.mjs → model-catalog-DZyNeDKG.mjs} +7 -7
- package/dist/.setup/{models-DfLmPV0k.mjs → models-DSseKSMg.mjs} +10 -7
- package/dist/.setup/{native-auth-CuG53tu4.mjs → native-auth-Cjb9y7IZ.mjs} +5 -6
- package/dist/.setup/{native-execution-policy-BxZJy5mP.mjs → native-execution-policy-ClzpdG3D.mjs} +1 -12
- package/dist/.setup/native-mcp-app-CqcPVmhH.mjs +310 -0
- package/dist/.setup/{native-subagent-monitor-BwkQXf9e.mjs → native-subagent-monitor-BUYOUp9X.mjs} +235 -318
- package/dist/.setup/{native-subagent-pending-assignments-DwkCzLvD.mjs → native-subagent-pending-assignments-BDqhOdJp.mjs} +0 -4
- package/dist/.setup/{native-task-assignments-DMQ0g3hu.mjs → native-task-assignments-C6KVqiN1.mjs} +9 -8
- package/dist/.setup/{node-cli-sessions-HC4W6FLI.mjs → node-cli-sessions-B5oNDkUS.mjs} +11 -17
- package/dist/.setup/{node-exec-server.runtime-BgBfWQqo.mjs → node-exec-server.runtime-0xSEjKYt.mjs} +2 -2
- package/dist/.setup/{plan-DPdMk1Oy.mjs → plan-BJ37d2Og.mjs} +67 -89
- package/dist/.setup/{plugin-activation-cNHRfaxU.mjs → plugin-activation-BcyBv8PG.mjs} +4 -4
- package/dist/.setup/{plugin-app-cache-key-BL9B5H0L.mjs → plugin-app-cache-key-BW8rd98k.mjs} +11 -15
- package/dist/.setup/plugin-approval-roundtrip-CuahdPLC.mjs +109 -0
- package/dist/.setup/{plugin-inventory-Cky2XJUw.mjs → plugin-inventory-Bf0_piTw.mjs} +29 -51
- package/dist/.setup/{plugin-marketplace-discovery-D_dV9FXa.mjs → plugin-marketplace-discovery-SQPhSuic.mjs} +2 -16
- package/dist/.setup/plugin-metadata-cache-DWnB7VMj.mjs +84 -0
- package/dist/.setup/plugin-thread-config-deadline-B8LGaZNW.mjs +124 -0
- package/dist/.setup/{provider-D6F_7p1I.mjs → provider-BnwHVD_z.mjs} +4 -4
- package/dist/.setup/provider-capabilities-D68Whix6.mjs +50 -0
- package/dist/.setup/{rate-limits-B7-X2TgG.mjs → rate-limits-CMPy24F5.mjs} +1 -5
- package/dist/.setup/{request-BZOfsSXW.mjs → request-jSbhc1sg.mjs} +189 -49
- package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
- package/dist/.setup/{run-attempt-dYJhjZrp.mjs → run-attempt-BLDZeYLD.mjs} +553 -727
- package/dist/.setup/{run-attempt-lifecycle-C-6O3Exn.mjs → run-attempt-lifecycle-BuZgVbDA.mjs} +19 -3
- package/dist/.setup/{runtime-artifact-DDQ-HGXf.mjs → runtime-artifact-CUTOOnKw.mjs} +5 -6
- package/dist/.setup/{runtime-artifact-connection-D68qQn1m.mjs → runtime-artifact-connection-CADz3_BY.mjs} +5 -4
- package/dist/.setup/{sandbox-guard-DjCz2eOw.mjs → sandbox-guard-WqE8yPge.mjs} +3 -3
- package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +15 -0
- package/dist/.setup/{session-binding-DGCYAfvD.mjs → session-binding-Ce7BqiPN.mjs} +92 -102
- package/dist/.setup/session-binding-meta-Lkm5Lpf4.mjs +15 -0
- package/dist/.setup/session-binding-record-BZB8RgcF.mjs +179 -0
- package/dist/.setup/session-binding-record-codec-z4ZpDn6E.mjs +216 -0
- package/dist/.setup/{session-binding-sidecars-jo6H8dFr.mjs → session-binding-sidecars-BrdV95Fg.mjs} +8 -2
- package/dist/.setup/{session-catalog-adoption-BU_pHWG7.mjs → session-catalog-adoption-CPIP4S_y.mjs} +34 -18
- package/dist/.setup/{session-catalog-archive-spHfihri.mjs → session-catalog-archive-DcgwvSbF.mjs} +24 -29
- package/dist/.setup/{session-catalog-events-BMCFMZw-.mjs → session-catalog-events-Bdjw9HEn.mjs} +5 -5
- package/dist/.setup/{session-catalog-index-DwJjnF5k.mjs → session-catalog-index-DufISKJ6.mjs} +361 -72
- package/dist/.setup/{session-catalog-index-order-BcQpHks3.mjs → session-catalog-index-order-nhyO0wdW.mjs} +1 -1
- package/dist/.setup/{session-catalog-limits-DDxOsQeC.mjs → session-catalog-limits-DEU36Qlo.mjs} +1 -1
- package/dist/.setup/{session-catalog-index-state-TeO7EyO-.mjs → session-catalog-list-request-tXephOB4.mjs} +180 -6
- package/dist/.setup/{session-catalog-native-projection-CuaFZuQE.mjs → session-catalog-native-projection-D6IiLtMb.mjs} +7 -6
- package/dist/.setup/{session-catalog-node-adoption-DgXvSGu0.mjs → session-catalog-node-adoption-7-WEQTB1.mjs} +12 -2
- package/dist/.setup/{session-catalog-node-continue-DjKXHBbi.mjs → session-catalog-node-continue-DLWBwAAO.mjs} +11 -15
- package/dist/.setup/{session-catalog-node-lookup-CtAXI5W5.mjs → session-catalog-node-lookup-Uufckwcm.mjs} +2 -2
- package/dist/.setup/{session-catalog-parsing-CPGaPYr-.mjs → session-catalog-parsing-B-qWJh2x.mjs} +70 -28
- package/dist/.setup/{session-catalog-projection-CGfzfP93.mjs → session-catalog-projection-8aHNwzWD.mjs} +6 -122
- package/dist/.setup/{session-catalog-provenance-DoAvktcj.mjs → session-catalog-provenance-CmsOE5mh.mjs} +6 -1
- package/dist/.setup/{session-cli-DlmBHYIe.mjs → session-cli-kH4vuGod.mjs} +1 -2
- package/dist/.setup/{session-history-D83lJWHG.mjs → session-history-BogBHKLk.mjs} +1 -1
- package/dist/.setup/{session-history-import-WhX-X33a.mjs → session-history-import-NWKPa4ZO.mjs} +4 -4
- package/dist/.setup/{session-history-read-Ov3StuL4.mjs → session-history-read-CNN8zwbD.mjs} +8 -19
- package/dist/.setup/{session-history.worker-MnPKncqP.mjs → session-history.worker-Cq_4DYgN.mjs} +3 -3
- package/dist/.setup/{session-initialization-6aveB9qb.mjs → session-initialization-D6dtFQkE.mjs} +2 -2
- package/dist/.setup/{session-permission-policy-Ci_fVX6y.mjs → session-permission-policy-BxIUJ0Zd.mjs} +8 -37
- package/dist/.setup/{session-retirement-LlYWBKTJ.mjs → session-retirement-Czbchv_O.mjs} +14 -15
- package/dist/.setup/{settled-turn-context-D4yj4rxf.mjs → settled-turn-context-BZsMjkIO.mjs} +13 -6
- package/dist/.setup/{settled-turn-finalizer-DW9W3gza.mjs → settled-turn-finalizer-DjZsIwbZ.mjs} +8 -8
- package/dist/.setup/{shared-client-CJCTeFpQ.mjs → shared-client-qhyYWbew.mjs} +291 -272
- package/dist/.setup/{provider-capabilities-DG5qbsUZ.mjs → shell-dynamic-tools-D3Brj3g9.mjs} +16 -55
- package/dist/.setup/{side-question-BLeGj7TQ.mjs → side-question-D3NJlgbl.mjs} +99 -91
- package/dist/.setup/{source-CJis_1EF.mjs → source-BYu0T780.mjs} +24 -40
- package/dist/.setup/{thread-lifecycle-_bAbjedG.mjs → thread-lifecycle-Cbz_7ySv.mjs} +262 -305
- package/dist/.setup/{thread-ownership-B6pPt21M.mjs → thread-ownership-DwuSrt3s.mjs} +10 -8
- package/dist/.setup/{thread-policy-gNPzzpVp.mjs → thread-policy-DoNxbhqt.mjs} +22 -21
- package/dist/.setup/{thread-requests-OWGOiDaV.mjs → thread-requests-CL1e8Wmx.mjs} +107 -98
- package/dist/.setup/{thread-resume-GOry0AYh.mjs → thread-resume-BT6NHMkM.mjs} +10 -18
- package/dist/.setup/{transcript-history-projection-DRSifI-1.mjs → transcript-history-projection-B9a7HwUV.mjs} +11 -16
- package/dist/.setup/{transcript-mirror-kxmCYsuF.mjs → transcript-mirror-BfLRARNL.mjs} +64 -67
- package/dist/.setup/{transport-stdio-Bdegpn2V.mjs → transport-stdio-a0HDa2Mj.mjs} +27 -8
- package/dist/.setup/{transport-websocket-BTBE-LD9.mjs → transport-websocket-zqJ0Cmtn.mjs} +3 -8
- package/dist/.setup/{attempt-client-cleanup-B-S7ngS_.mjs → turn-router-sS69wYnI.mjs} +75 -170
- package/dist/.setup/{upstream-session-fork-gkdRj2yH.mjs → upstream-session-fork-ChSld66u.mjs} +35 -46
- package/dist/.setup/{usage-CApUvLOV.mjs → usage-D8e8Xiqf.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-wSMQkbpV.mjs → usage-limit-error-GbT-5NcW.mjs} +4 -4
- package/dist/.setup/{web-search-provider.runtime-UKgeiBUG.mjs → web-search-provider.runtime-dL2GD1Kl.mjs} +4 -20
- package/dist/.setup/websocket-data-XlRvt8Ys.mjs +6 -0
- package/dist/.setup/workspace-write-sandbox-probe-DmUHLrrl.mjs +118 -0
- package/dist/api.js +34 -54
- package/dist/catalog-page.worker.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +15 -27
- package/dist/harness.js +37 -22
- package/dist/index.js +2880 -276
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +1 -1
- package/dist/native-session-binding-api.js +2 -0
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +33 -4
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +3 -3
- package/package.json +6 -6
- package/dist/.setup/config-utils-D0CXecki.mjs +0 -57
- package/dist/.setup/incognito-session-DWYapfwf.mjs +0 -2
- package/dist/.setup/managed-thread-store-BMqgThVL.mjs +0 -100
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +0 -31
- package/dist/.setup/session-binding-meta-B7aEMU7g.mjs +0 -6
- package/dist/.setup/session-binding-record-Oe9L-CNY.mjs +0 -375
- package/dist/.setup/session-catalog-BFafIiF6.mjs +0 -2599
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
- package/dist/.setup/shared-client-lifecycle-7xgtlo15.mjs +0 -153
|
@@ -1,60 +1,63 @@
|
|
|
1
1
|
import { n as readCodexRuntimeModelId } from "./model-runtime-BdqzOMkU.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { g as createCodexNativeSubagentHistoryOwner } from "./native-subagent-pending-assignments-DwkCzLvD.mjs";
|
|
2
|
+
import { g as createCodexNativeSubagentHistoryOwner } from "./native-subagent-pending-assignments-BDqhOdJp.mjs";
|
|
4
3
|
import { i as isJsonObject, r as flattenCodexDynamicToolFunctions } from "./protocol-CANUwXJ3.mjs";
|
|
5
|
-
import { i as matchesCodexNativeSubagentSubmissionBinding,
|
|
6
|
-
import { n as defineCodexBuildState } from "./build-state-
|
|
7
|
-
import { c as shouldAutoApproveCodexAppServerApprovals,
|
|
8
|
-
import { c as isCodexPairedNodeRemoteExecPlacementSandbox, d as readCodexPluginConfig, f as resolveCodexPluginsPolicy, l as isCodexRemoteExecPlacementSandbox, u as isCodexSandboxExecServerEnabled } from "./config-parsing-
|
|
4
|
+
import { i as matchesCodexNativeSubagentSubmissionBinding, m as sessionBindingIdentity, n as assertCodexBindingMayBeReplaced } from "./session-binding-record-BZB8RgcF.mjs";
|
|
5
|
+
import { n as defineCodexBuildState } from "./build-state-CqQnsg7T.mjs";
|
|
6
|
+
import { c as shouldAutoApproveCodexAppServerApprovals, f as readCodexRequirementsToml, l as withMcpElicitationsApprovalPolicy, n as hasCodexMcpToolApprovalOverrides } from "./config-security-KAPScztc.mjs";
|
|
7
|
+
import { c as isCodexPairedNodeRemoteExecPlacementSandbox, d as readCodexPluginConfig, f as resolveCodexPluginsPolicy, l as isCodexRemoteExecPlacementSandbox, u as isCodexSandboxExecServerEnabled } from "./config-parsing-BQq-CHTF.mjs";
|
|
9
8
|
import { n as isCodexAppServerProxyLaunch } from "./launch-args-DbFCehO7.mjs";
|
|
10
9
|
import { t as resolveCodexAppServerHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
|
|
11
|
-
import { i as resolveCodexAppServerHomeScope, l as resolveCodexModelBackedReviewerPolicyContext, o as resolveCodexComputerUseConfig } from "./config-options-
|
|
12
|
-
import { c as resolveCodexAppServerPreparedApiKeyCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey } from "./auth-cache-key-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
|
|
17
|
-
import { n as waitForPromiseOrAbort, r as withAbortableTimeout } from "./timeout-CXOfNoaX.mjs";
|
|
10
|
+
import { i as resolveCodexAppServerHomeScope, l as resolveCodexModelBackedReviewerPolicyContext, o as resolveCodexComputerUseConfig } from "./config-options-HG_Rr3W_.mjs";
|
|
11
|
+
import { c as resolveCodexAppServerPreparedApiKeyCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey, w as retireSharedCodexAppServerClientIfCurrent } from "./auth-cache-key-CGm0UJOr.mjs";
|
|
12
|
+
import { o as formatCodexDisplayText } from "./command-formatters-DV3DHhdr.mjs";
|
|
13
|
+
import { a as codexPrewriteRejectionCause, i as CodexAppServerScopedRequestRejectedError, r as CodexAppServerRpcError } from "./rpc-error-hmWM21RB.mjs";
|
|
14
|
+
import { n as waitForPromiseOrAbort } from "./timeout-CXOfNoaX.mjs";
|
|
18
15
|
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
19
|
-
import {
|
|
16
|
+
import { i as readCodexProviderRefusal, n as extractRawAssistantText, o as readItem, r as readCodexErrorNotificationMessage, s as readNullableString } from "./event-projector-values-DTqZHizf.mjs";
|
|
20
17
|
import { r as readMirrorIdentity, t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-fXkKbPVC.mjs";
|
|
21
|
-
import {
|
|
22
|
-
import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection, t as assertCodexSessionRuntimeOwnership } from "./binding-connection-
|
|
23
|
-
import {
|
|
24
|
-
import { n as canUseCodexModelBackedApprovalsReviewerForModel, r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-
|
|
25
|
-
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 } from "./context-engine-projection-
|
|
18
|
+
import { n as buildCodexAppServerRuntimeFingerprint, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BW8rd98k.mjs";
|
|
19
|
+
import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection, t as assertCodexSessionRuntimeOwnership } from "./binding-connection-C-08ez1w.mjs";
|
|
20
|
+
import { n as requestCodexAppServerClientJson } from "./request-jSbhc1sg.mjs";
|
|
21
|
+
import { n as canUseCodexModelBackedApprovalsReviewerForModel, r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-0Gxk3_eq.mjs";
|
|
22
|
+
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-CsgYSQhW.mjs";
|
|
26
23
|
import { o as hasCodexMirrorOrigin, t as applyCodexTranscriptTaint } from "./transcript-mirror-attestation-YSegaktH.mjs";
|
|
27
|
-
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-
|
|
28
|
-
import { i as resolveCodexAppServerAuthProfileIdForAgent, r as resolveCodexAppServerAuthProfileId } from "./auth-profile-
|
|
29
|
-
import { E as isCodexContextRestartSelectionChangedError, H as prepareCodexWorkspaceReferences, I as ensureCodexAppServerClientRuntime, M as getCodexInferenceThreadQualification, U as protectCodexAppServerLiveThread, X as readRecentCodexRateLimits, Y as readCodexRateLimitsRevision, _ as retainSharedCodexAppServerClientIfCurrent, a as clearSharedCodexAppServerClientIfCurrentAndUnclaimed, c as getLeasedSharedCodexAppServerClient, dt as TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS, et as resolveCodexAppServerAuthAccountCacheKey, f as readCodexAppServerClientDesktopGenerationFingerprint, h as releaseLeasedSharedCodexAppServerClient, ht as withCodexStartupTimeout, i as clearSharedCodexAppServerClientIfCurrent, j as getCodexInferenceThread, l as getSharedCodexAppServerClient, lt as CodexAppServerStartupError, mt as resolveCodexStartupTimeoutMs, s as createIsolatedCodexAppServerClient, tt as resolveCodexAppServerPreparedAuthHandoff, u as isCodexAppServerStartSelectionChangedError, ut as TURN_FINALIZE_DRAIN_ABORT_GRACE_MS, w as CodexThreadClientReplacementError, x as CODEX_APP_SERVER_CONTEXT_RESTART_SELECTION_CHANGED } from "./shared-client-
|
|
24
|
+
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-BogBHKLk.mjs";
|
|
25
|
+
import { i as resolveCodexAppServerAuthProfileIdForAgent, r as resolveCodexAppServerAuthProfileId } from "./auth-profile-CgHQ8Vot.mjs";
|
|
26
|
+
import { E as isCodexContextRestartSelectionChangedError, H as prepareCodexWorkspaceReferences, I as ensureCodexAppServerClientRuntime, M as getCodexInferenceThreadQualification, U as protectCodexAppServerLiveThread, X as readRecentCodexRateLimits, Y as readCodexRateLimitsRevision, _ as retainSharedCodexAppServerClientIfCurrent, a as clearSharedCodexAppServerClientIfCurrentAndUnclaimed, c as getLeasedSharedCodexAppServerClient, dt as TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS, et as resolveCodexAppServerAuthAccountCacheKey, f as readCodexAppServerClientDesktopGenerationFingerprint, h as releaseLeasedSharedCodexAppServerClient, ht as withCodexStartupTimeout, i as clearSharedCodexAppServerClientIfCurrent, j as getCodexInferenceThread, l as getSharedCodexAppServerClient, lt as CodexAppServerStartupError, mt as resolveCodexStartupTimeoutMs, s as createIsolatedCodexAppServerClient, tt as resolveCodexAppServerPreparedAuthHandoff, u as isCodexAppServerStartSelectionChangedError, ut as TURN_FINALIZE_DRAIN_ABORT_GRACE_MS, w as CodexThreadClientReplacementError, x as CODEX_APP_SERVER_CONTEXT_RESTART_SELECTION_CHANGED } from "./shared-client-qhyYWbew.mjs";
|
|
30
27
|
import { a as isCodexResponsesOAuthRun, r as isCodexResponsesOAuth } from "./responses-oauth-twnuTaAa.mjs";
|
|
31
|
-
import { A as
|
|
32
|
-
import { n as isCodexWebSocketOpenFailure } from "./transport-websocket-
|
|
33
|
-
import {
|
|
34
|
-
import { r as
|
|
28
|
+
import { A as resolveTerminalDynamicToolBatchAction, D as isDynamicToolTerminalDiagnosticEvent, E as hasPendingDynamicToolTerminalDiagnostic, H as resolveCodexAppServerClientInstanceId, M as toCodexDynamicToolProgressResponse, N as toCodexDynamicToolProtocolResponse, O as isMatchingDynamicToolTerminalDiagnostic, T as handleDynamicToolCallWithTimeout, _ as assertCodexTurnStartResponse, a as isCodexAppServerIndeterminateRequestCancellationError, i as isCodexAppServerConnectionClosedError, j as shouldReleaseTurnAfterTerminalDynamicTool, k as resolveDynamicToolCallTimeoutMs, l as CodexServerRequestResolvedError, o as isCodexAppServerIndeterminateTransportError, r as isCodexAppServerApprovalRequest, w as createCodexElicitationResponse, x as readCodexTurnCompletedNotification, y as readCodexDynamicToolCallParams, z as CODEX_APP_SERVER_OPT_OUT_NOTIFICATION_METHODS } from "./client-C8lgBOoO.mjs";
|
|
29
|
+
import { n as isCodexWebSocketOpenFailure } from "./transport-websocket-zqJ0Cmtn.mjs";
|
|
30
|
+
import { a as isCodexNotificationForTurn, b as shouldClearTerminalPresentationForNativeItem, g as itemName, i as CodexProjectionDiagnostics, n as getCodexAppServerTurnRouter, o as readCodexNotificationThreadId, t as CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS, y as matchesCodexSnapshotTurn } from "./turn-router-sS69wYnI.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-BH0hW2xU.mjs";
|
|
32
|
+
import { r as prepareCodexAppServerAuthBinding } from "./auth-binding-BoMwpuPN.mjs";
|
|
35
33
|
import { a as isRawFunctionToolOutputCompletionNotification, c as readNotificationItemId, i as isPendingOpenClawDynamicToolCompletionNotification, l as readRawResponseToolCallId, o as isTerminalTurnStatus, r as isCodexTurnAbortMarkerNotification, s as readCodexNotificationItem, t as CodexUsageProjection, u as updateActiveTurnItemIds } from "./event-projector-usage-03R0I2dM.mjs";
|
|
36
|
-
import { n as listAllCodexAppServerModels } from "./models-
|
|
37
|
-
import {
|
|
38
|
-
import { _ as
|
|
39
|
-
import {
|
|
40
|
-
import { a as CodexToolTranscriptProjection,
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import { c as
|
|
44
|
-
import { a as resolveCodexPromptError, i as refreshCodexUsageLimitPromptError, n as formatCodexTurnStartUsageLimitError, r as markCodexAuthProfileBlockedFromRateLimits, t as CodexUsageLimitPromptError } from "./usage-limit-error-
|
|
34
|
+
import { n as listAllCodexAppServerModels } from "./models-DSseKSMg.mjs";
|
|
35
|
+
import { B as hasCodexNativeToolCatalog, Ct as mergeCodexThreadConfigs, D as assertCodexNativeHookRelayAllowed, E as CodexManagedHooksOnlyError, F as scheduleCodexNativeHookRelayUnregister, G as areCodexDynamicToolFingerprintsCompatible, J as codexLegacyDynamicToolsFingerprint, N as resolveCodexNativeHookRelayEvents, O as buildCodexNativeHookRelayConfig, P as resolveCodexNativeHookRelayTtlMs, S as joinPresentSections, T as CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS, V as loadCodexNativeToolCatalog, Z as fingerprintJsonObject, _t as buildCodexPluginThreadConfigInputFingerprint, b as resolveCodexAppServerThreadModelSelection, dt as isSystemAgentOnlyCodexDynamicToolAllowlist, g as buildDeveloperInstructions, j as createCodexNativeHookRelay, k as buildCodexNativeHookRelayDisabledConfig, l as isCodexNativeDelegationDisabledForRun, m as resolveCodexWebSearchPlan, mt as resolveCodexDynamicToolsLoadingForRuntime, nt as stabilizeJsonValue, q as codexDynamicToolsFingerprint, st as filterCodexDynamicTools } from "./thread-requests-CL1e8Wmx.mjs";
|
|
36
|
+
import { _ as buildContextEngineBinding, a as buildTurnStartParams, c as assertScheduledCodexAppAuthorityRuntime, d as buildScheduledCodexAppServerConnectionIdentity, f as captureScheduledCodexAppAuthority, g as isCodexAppServerProfilerEnabled, h as resolveScheduledCodexAppCreatorCaptureDecision, i as buildTurnCollaborationMode, l as buildLegacyScheduledCodexAppRecoveryPrompt, n as buildCodexParentLocalInstructions, o as buildCodexUserInput, s as startOrResumeThread, t as buildCodexHistoryProvenancePrefix, u as buildScheduledCodexAppAuthorityInputFingerprint, v as isContextEngineBindingCompatible } from "./thread-lifecycle-Cbz_7ySv.mjs";
|
|
37
|
+
import { o as createCodexSessionGenerationSupersededError, r as resolveCodexSessionBinding, s as resolveCodexRunSessionBindingAuthority, t as clearCodexBindingForClient } from "./session-binding-Ce7BqiPN.mjs";
|
|
38
|
+
import { a as CodexToolTranscriptProjection, c as shouldEmitTranscriptToolProgress, d as resolveCodexToolProgressDetailMode, f as sanitizeCodexAgentEventRecord, i as emitCodexAgentEvent, p as sanitizeCodexToolArguments, r as CodexEventProjection, s as CodexToolProgressProjection, t as codexNativeSubagentMonitorRuntime, u as isCodexCommandBearingToolCall } from "./native-subagent-monitor-BUYOUp9X.mjs";
|
|
39
|
+
import { a as requestPluginApprovalOutcome } from "./plugin-approval-roundtrip-CuahdPLC.mjs";
|
|
40
|
+
import { n as CodexThreadPolicyHandoffError, s as restoreCodexThreadInstructionsAfterCompaction } from "./thread-policy-DoNxbhqt.mjs";
|
|
41
|
+
import { c as withExclusiveCodexAppServerThread, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-DwuSrt3s.mjs";
|
|
42
|
+
import { a as resolveCodexPromptError, i as refreshCodexUsageLimitPromptError, n as formatCodexTurnStartUsageLimitError, r as markCodexAuthProfileBlockedFromRateLimits, t as CodexUsageLimitPromptError } from "./usage-limit-error-GbT-5NcW.mjs";
|
|
45
43
|
import { t as persistCodexContextCompactionActivity } from "./context-compaction-activity-CMla5FPJ.mjs";
|
|
46
44
|
import { t as attemptTerminal } from "./attempt-terminal-gZrxQ35N.mjs";
|
|
47
|
-
import { a as
|
|
45
|
+
import { a as runCodexAgentEndHook, i as reportCodexBackgroundCleanupFailure, n as ensureCodexWorkspaceDirOnce, o as shouldKeepCodexSharedAbortOpen, r as estimateCodexAppServerProjectedTurnTokens, s as withCodexAppServerFastModeServiceTier, t as emitCodexAppServerEvent } from "./run-attempt-lifecycle-BuZgVbDA.mjs";
|
|
48
46
|
import { t as CODEX_INFERENCE_GENERATION_KEY } from "./inference-metadata-CgIf7sOx.mjs";
|
|
49
47
|
import "./inference-context-D-9gWlTR.mjs";
|
|
50
|
-
import { i as createAssistantReasoningMessage, n as createAssistantCommentaryMessage, r as createAssistantMessage, t as createAssistantAsyncMessage } from "./event-projector-assistant-message-
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import { t as
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
48
|
+
import { i as createAssistantReasoningMessage, n as createAssistantCommentaryMessage, r as createAssistantMessage, t as createAssistantAsyncMessage } from "./event-projector-assistant-message-BN7CNUB5.mjs";
|
|
49
|
+
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-C8xGEXmR.mjs";
|
|
50
|
+
import { n as resolveCodexPluginThreadConfigStartupPolicy, t as createCodexPluginThreadConfigStartupProvider } from "./plugin-thread-config-deadline-B8LGaZNW.mjs";
|
|
51
|
+
import { i as resolveCodexSessionPermissionCwd, n as applyCodexSessionPermissionPolicy, r as resolveCodexEffectiveSessionPermissionPolicy } from "./session-permission-policy-BxIUJ0Zd.mjs";
|
|
52
|
+
import { r as prepareCodexNativeMcpFormResourceContext, t as createCodexNativeMcpAppResultDetailsPreparer } from "./native-mcp-app-CqcPVmhH.mjs";
|
|
53
|
+
import { a as emitDynamicToolStartedDiagnostic, c as ensureCodexSandboxExecServerEnvironment, d as CodexNativeProcessAuthority, f as readCodexRetainedBackgroundCommands, i as emitDynamicToolErrorDiagnostic, l as releaseCodexSandboxExecServerEnvironment, m as CodexNativeToolLifecycleProjector, n as projectCodexExecutableDynamicTools, o as emitDynamicToolTerminalDiagnostic, p as createCodexRemoteWorkspaceFileReader, r as routeCodexAppServerElicitationRequest, s as handleCodexAppServerApprovalRequest, t as createCodexDynamicToolBridge, u as createCodexNativePreToolUseFailureBuffer } from "./dynamic-tools-DyERJnR6.mjs";
|
|
54
|
+
import { c as promptSnapshot, i as mirrorPromptAtTurnStartBestEffort, n as createCodexAppServerUserMessagePersistenceNotifier, o as buildCodexUserPromptMessage, s as buildResolvedCodexUserPromptMessage, t as codexTranscriptMirrorRuntime } from "./transcript-mirror-BfLRARNL.mjs";
|
|
55
|
+
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-Bg4FZw1f.mjs";
|
|
56
|
+
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-BY0jprWJ.mjs";
|
|
57
|
+
import { n as captureCodexSettledTurnFinalizationContext } from "./settled-turn-context-BZsMjkIO.mjs";
|
|
58
|
+
import { t as resolveCodexProviderWebSearchSupport } from "./provider-capabilities-D68Whix6.mjs";
|
|
59
|
+
import { a as runCodexComputerUseLiveTest, i as createComputerUseRequest, t as ensureCodexComputerUse } from "./computer-use-BBN9y326.mjs";
|
|
60
|
+
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, readNonBlankString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
58
61
|
import { createHash } from "node:crypto";
|
|
59
62
|
import { isDeepStrictEqual } from "node:util";
|
|
60
63
|
import { resolveAgentConfig, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
@@ -63,25 +66,28 @@ import path from "node:path";
|
|
|
63
66
|
import fs from "node:fs/promises";
|
|
64
67
|
import { isPathStrictlyInside, readFileWindowFully, root } from "openclaw/plugin-sdk/file-access-runtime";
|
|
65
68
|
import { addAbortListener } from "node:events";
|
|
69
|
+
import { isIncognitoSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
|
|
66
70
|
import { Type } from "typebox";
|
|
67
71
|
import { truncateUtf16Safe, truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
68
72
|
import { createDiagnosticTraceContextFromActiveScope, emitTrustedDiagnosticEvent, emitTrustedDiagnosticEventWithPrivateData, freezeDiagnosticTraceContext, onInternalDiagnosticEvent, resolveDiagnosticModelContentCapturePolicy } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
69
73
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
70
74
|
import { createStageTimingTracker, formatStageTimings } from "openclaw/plugin-sdk/time-runtime";
|
|
71
75
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
72
|
-
import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
|
|
73
|
-
import {
|
|
76
|
+
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$1, resolveAgentHarnessBeforePromptBuildResult, resolveAgentRunAbortLifecycleFields, resolveAttemptFsWorkspaceOnly, resolveContextEngineOwnerPluginId, resolveFastModeForElapsed, resolveSandboxContext, resolveUserPath, runAgentCleanupStep, runAgentHarnessAfterCompactionHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
77
|
+
import { resolveAgentDir as resolveAgentDir$2 } from "openclaw/plugin-sdk/agent-runtime";
|
|
74
78
|
import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
75
79
|
import { AgentHarnessProjectionSettlement, createAgentHarnessAttemptCancellation, createAgentHarnessAttemptDeadlineController, createAgentHarnessAttemptLifecycle, shouldIncludeAgentHarnessRuntimeContext } from "openclaw/plugin-sdk/agent-harness-attempt-runtime";
|
|
76
80
|
import { getSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
|
|
77
|
-
import { acknowledgeInternalToolResult, createAgentHarnessToolExecutionRegistry } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
78
81
|
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
82
|
+
import { acknowledgeInternalToolResult, createAgentHarnessToolExecutionRegistry } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
83
|
+
import { createNativeSessionBindingAuthority } from "openclaw/plugin-sdk/agent-harness-session-runtime";
|
|
79
84
|
import { captureFinalCodexCronCreatorToolAllowlist, formatMcpCodexApprovalRemedy, materializeStaticMcpToolsForHarnessRun, resolveCodexMcpToolOverridesForAgent, resolveCodexTtsProvenanceTransfer } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
80
85
|
import { appendSessionYieldContext, hasPromptImageInput } from "openclaw/plugin-sdk/session-transcript-runtime";
|
|
81
86
|
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-local-roots";
|
|
82
87
|
import { isSilentReplyPayloadText } from "openclaw/plugin-sdk/reply-chunking";
|
|
83
88
|
import { generatedImageAssetFromBase64 } from "openclaw/plugin-sdk/image-generation";
|
|
84
89
|
import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
|
|
90
|
+
import { estimateBase64DecodedBytes } from "openclaw/plugin-sdk/media-runtime";
|
|
85
91
|
import { normalizeMediaReferenceForComparison, saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
|
|
86
92
|
import { stripInvisibleUnicode } from "openclaw/plugin-sdk/web-content-extractor";
|
|
87
93
|
import { prepareAgentWorkspaceAttachments } from "openclaw/plugin-sdk/agent-workspace-runtime";
|
|
@@ -175,6 +181,7 @@ function createCodexSteeringQueue(params) {
|
|
|
175
181
|
acceptItem(item);
|
|
176
182
|
item.settled = true;
|
|
177
183
|
pendingMessages.delete(item);
|
|
184
|
+
item.onQueueSettled?.();
|
|
178
185
|
item.resolve();
|
|
179
186
|
};
|
|
180
187
|
const rejectItem = (item, error) => {
|
|
@@ -182,6 +189,7 @@ function createCodexSteeringQueue(params) {
|
|
|
182
189
|
item.settled = true;
|
|
183
190
|
pendingMessages.delete(item);
|
|
184
191
|
reportItemAcceptance(item, false);
|
|
192
|
+
item.onQueueSettled?.();
|
|
185
193
|
item.reject(item.acceptance === "accepted" ? new CodexSteeringAcceptedUnconfirmedError("Codex accepted steering but did not confirm transcript consumption", { cause: error }) : error);
|
|
186
194
|
};
|
|
187
195
|
const closeQueue = (error) => {
|
|
@@ -249,7 +257,7 @@ function createCodexSteeringQueue(params) {
|
|
|
249
257
|
if (liveItems.length === 0) return;
|
|
250
258
|
}
|
|
251
259
|
clientUserMessageId = `openclaw:${params.turnId}:steer:${++batchSequence}`;
|
|
252
|
-
dispatchedBatches.set(clientUserMessageId, liveItems);
|
|
260
|
+
if (!params.withCurrent) dispatchedBatches.set(clientUserMessageId, liveItems);
|
|
253
261
|
const request = {
|
|
254
262
|
threadId: params.threadId,
|
|
255
263
|
expectedTurnId: params.turnId,
|
|
@@ -259,6 +267,8 @@ function createCodexSteeringQueue(params) {
|
|
|
259
267
|
await params.client.request("turn/steer", request, {
|
|
260
268
|
timeoutMs: params.requestTimeoutMs,
|
|
261
269
|
signal: params.signal,
|
|
270
|
+
...params.withCurrent ? { withCurrent: params.withCurrent } : {},
|
|
271
|
+
onIngressRejected: () => dispatchedBatches.delete(request.clientUserMessageId),
|
|
262
272
|
assertCurrent: () => {
|
|
263
273
|
assertActive();
|
|
264
274
|
liveItems = liveItems.filter(isCurrent);
|
|
@@ -279,7 +289,11 @@ function createCodexSteeringQueue(params) {
|
|
|
279
289
|
throw error;
|
|
280
290
|
}
|
|
281
291
|
};
|
|
282
|
-
const
|
|
292
|
+
const flushBatch = () => {
|
|
293
|
+
clearBatchTimer();
|
|
294
|
+
const items = batchedMessages;
|
|
295
|
+
batchedMessages = [];
|
|
296
|
+
if (items.length === 0) return sendChain;
|
|
283
297
|
const send = sendChain.then(() => sendBatch(items));
|
|
284
298
|
sendChain = send;
|
|
285
299
|
send.catch((error) => {
|
|
@@ -288,32 +302,6 @@ function createCodexSteeringQueue(params) {
|
|
|
288
302
|
});
|
|
289
303
|
return send;
|
|
290
304
|
};
|
|
291
|
-
const flushBatch = () => {
|
|
292
|
-
clearBatchTimer();
|
|
293
|
-
const items = batchedMessages;
|
|
294
|
-
batchedMessages = [];
|
|
295
|
-
if (items.length === 0) return sendChain;
|
|
296
|
-
const send = enqueueSend(items);
|
|
297
|
-
send.catch(() => void 0);
|
|
298
|
-
return send;
|
|
299
|
-
};
|
|
300
|
-
const createPendingMessage = (text, options, assertCurrent = () => {}) => {
|
|
301
|
-
const { promise: delivery, resolve, reject } = createDeferred();
|
|
302
|
-
const item = {
|
|
303
|
-
...options,
|
|
304
|
-
assertCurrent,
|
|
305
|
-
acceptance: "open",
|
|
306
|
-
text,
|
|
307
|
-
resolve,
|
|
308
|
-
reject,
|
|
309
|
-
settled: false
|
|
310
|
-
};
|
|
311
|
-
pendingMessages.add(item);
|
|
312
|
-
return {
|
|
313
|
-
item,
|
|
314
|
-
delivery
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
305
|
params.signal.addEventListener("abort", abortQueue, { once: true });
|
|
318
306
|
if (params.signal.aborted) abortQueue();
|
|
319
307
|
return {
|
|
@@ -323,9 +311,20 @@ function createCodexSteeringQueue(params) {
|
|
|
323
311
|
assertCurrent();
|
|
324
312
|
} catch (error) {
|
|
325
313
|
options?.onQueueAccepted?.(false);
|
|
314
|
+
options?.onQueueSettled?.();
|
|
326
315
|
throw error;
|
|
327
316
|
}
|
|
328
|
-
const {
|
|
317
|
+
const { promise: delivery, resolve, reject } = createDeferred();
|
|
318
|
+
const item = {
|
|
319
|
+
...options,
|
|
320
|
+
assertCurrent,
|
|
321
|
+
acceptance: "open",
|
|
322
|
+
text,
|
|
323
|
+
resolve,
|
|
324
|
+
reject,
|
|
325
|
+
settled: false
|
|
326
|
+
};
|
|
327
|
+
pendingMessages.add(item);
|
|
329
328
|
batchedMessages.push(item);
|
|
330
329
|
clearBatchTimer();
|
|
331
330
|
const debounceMs = normalizeCodexSteerDebounceMs(options?.debounceMs);
|
|
@@ -523,7 +522,7 @@ var CodexAssistantProjection = class {
|
|
|
523
522
|
if (this.persistedAssistantBoundary) return [];
|
|
524
523
|
const recoveredAudible = this.collectPersistableAssistantTexts(0).filter((text) => !isSilentReplyPayloadText(text));
|
|
525
524
|
if (recoveredAudible.length > 0) return recoveredAudible.slice(-1);
|
|
526
|
-
const recovered = this.
|
|
525
|
+
const recovered = this.resolveFinalAssistantText();
|
|
527
526
|
return recovered ? [recovered] : [];
|
|
528
527
|
}
|
|
529
528
|
collectCommentaryMessages() {
|
|
@@ -600,13 +599,7 @@ var CodexAssistantProjection = class {
|
|
|
600
599
|
this.emitAnswerCandidate(itemId, "selected");
|
|
601
600
|
}
|
|
602
601
|
hasAssistantItemTextForSynthesis() {
|
|
603
|
-
|
|
604
|
-
const itemId = this.assistantItemOrder[i];
|
|
605
|
-
if (!itemId || this.isNonTerminalAssistantItem(itemId)) continue;
|
|
606
|
-
const text = this.assistantTextByItem.get(itemId);
|
|
607
|
-
if (text && text.length > 0) return true;
|
|
608
|
-
}
|
|
609
|
-
return false;
|
|
602
|
+
return this.assistantItemOrder.some((itemId) => Boolean(itemId) && !this.isNonTerminalAssistantItem(itemId) && Boolean(this.assistantTextByItem.get(itemId)));
|
|
610
603
|
}
|
|
611
604
|
createCurrentAttemptAssistantMessage(options) {
|
|
612
605
|
for (let i = this.assistantItemOrder.length - 1; i >= 0; i -= 1) {
|
|
@@ -717,16 +710,13 @@ var CodexAssistantProjection = class {
|
|
|
717
710
|
this.terminalAssistantCandidateEarlierActiveItemIds.clear();
|
|
718
711
|
this.supersedeVisibleAnswerCandidate();
|
|
719
712
|
}
|
|
720
|
-
|
|
713
|
+
resolveFinalAssistantText() {
|
|
721
714
|
for (let i = this.assistantItemOrder.length - 1; i >= 0; i -= 1) {
|
|
722
715
|
const itemId = this.assistantItemOrder[i];
|
|
723
716
|
if (!itemId) continue;
|
|
724
717
|
const text = this.assistantTextByItem.get(itemId)?.trim();
|
|
725
718
|
if (this.isNonTerminalAssistantItem(itemId)) continue;
|
|
726
|
-
if (text && !this.isToolProgressEchoText(itemId, text)) return
|
|
727
|
-
itemId,
|
|
728
|
-
text
|
|
729
|
-
};
|
|
719
|
+
if (text && !this.isToolProgressEchoText(itemId, text)) return text;
|
|
730
720
|
}
|
|
731
721
|
}
|
|
732
722
|
collectPersistableAssistantTexts(minIndex) {
|
|
@@ -860,19 +850,19 @@ var CodexGeneratedMediaProjection = class {
|
|
|
860
850
|
return;
|
|
861
851
|
}
|
|
862
852
|
try {
|
|
863
|
-
const
|
|
853
|
+
const bytes = await this.remote.readFile({
|
|
864
854
|
path: savedPath,
|
|
865
855
|
maxBytes: resolveGeneratedMediaMaxBytes(this.config, "image"),
|
|
866
856
|
signal: this.remote.signal,
|
|
867
857
|
timeoutMs: this.remote.requestTimeoutMs
|
|
868
858
|
});
|
|
869
|
-
if (!
|
|
859
|
+
if (!bytes.length) {
|
|
870
860
|
embeddedAgentLog.warn("codex remote image file returned no inline bytes", { itemId: item.id });
|
|
871
861
|
return;
|
|
872
862
|
}
|
|
873
863
|
await this.recordImage({
|
|
874
864
|
itemId: item.id,
|
|
875
|
-
result:
|
|
865
|
+
result: bytes.toString("base64"),
|
|
876
866
|
revisedPrompt: readStringField(item, "revisedPrompt"),
|
|
877
867
|
source: "native"
|
|
878
868
|
});
|
|
@@ -884,8 +874,9 @@ var CodexGeneratedMediaProjection = class {
|
|
|
884
874
|
}
|
|
885
875
|
return;
|
|
886
876
|
}
|
|
887
|
-
this.
|
|
888
|
-
|
|
877
|
+
const existing = this.mediaByItemId.get(item.id);
|
|
878
|
+
if (!existing?.mediaUrl) this.mediaByItemId.set(item.id, {
|
|
879
|
+
...existing,
|
|
889
880
|
mediaUrl: savedPath
|
|
890
881
|
});
|
|
891
882
|
}
|
|
@@ -922,7 +913,7 @@ var CodexGeneratedMediaProjection = class {
|
|
|
922
913
|
async materializeImage(params) {
|
|
923
914
|
const maxBytes = resolveGeneratedMediaMaxBytes(this.config, "image");
|
|
924
915
|
const estimatedDecodedBytes = estimateBase64DecodedBytes(params.result);
|
|
925
|
-
if (estimatedDecodedBytes
|
|
916
|
+
if (estimatedDecodedBytes > maxBytes) {
|
|
926
917
|
embeddedAgentLog.warn(`codex app-server ${params.source} image generation result exceeds media limit`, {
|
|
927
918
|
itemId: params.itemId,
|
|
928
919
|
estimatedDecodedBytes,
|
|
@@ -941,10 +932,9 @@ var CodexGeneratedMediaProjection = class {
|
|
|
941
932
|
try {
|
|
942
933
|
const saved = await saveMediaBuffer(asset.buffer, asset.mimeType, GENERATED_IMAGE_MEDIA_SUBDIR, maxBytes, asset.fileName);
|
|
943
934
|
this.gatewayMaterializedItemIds.add(params.itemId);
|
|
944
|
-
this.
|
|
945
|
-
|
|
946
|
-
mediaUrl: saved.path
|
|
947
|
-
replaceExisting: true
|
|
935
|
+
this.mediaByItemId.set(params.itemId, {
|
|
936
|
+
...this.mediaByItemId.get(params.itemId),
|
|
937
|
+
mediaUrl: saved.path
|
|
948
938
|
});
|
|
949
939
|
} catch (error) {
|
|
950
940
|
embeddedAgentLog.warn(`codex app-server ${params.source} image generation result save failed`, {
|
|
@@ -990,38 +980,7 @@ var CodexGeneratedMediaProjection = class {
|
|
|
990
980
|
})
|
|
991
981
|
};
|
|
992
982
|
}
|
|
993
|
-
recordUrl(params) {
|
|
994
|
-
const existing = this.mediaByItemId.get(params.itemId);
|
|
995
|
-
if (existing?.mediaUrl && params.replaceExisting !== true) {
|
|
996
|
-
this.itemIds.add(params.itemId);
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
999
|
-
this.mediaByItemId.set(params.itemId, {
|
|
1000
|
-
...existing,
|
|
1001
|
-
mediaUrl: params.mediaUrl
|
|
1002
|
-
});
|
|
1003
|
-
this.itemIds.add(params.itemId);
|
|
1004
|
-
}
|
|
1005
983
|
};
|
|
1006
|
-
function estimateBase64DecodedBytes(base64) {
|
|
1007
|
-
let nonWhitespaceLength = 0;
|
|
1008
|
-
let previousCode = -1;
|
|
1009
|
-
let lastCode = -1;
|
|
1010
|
-
for (let i = 0; i < base64.length; i += 1) {
|
|
1011
|
-
const code = base64.charCodeAt(i);
|
|
1012
|
-
if (isBase64WhitespaceCode(code)) continue;
|
|
1013
|
-
nonWhitespaceLength += 1;
|
|
1014
|
-
previousCode = lastCode;
|
|
1015
|
-
lastCode = code;
|
|
1016
|
-
}
|
|
1017
|
-
if (nonWhitespaceLength === 0) return;
|
|
1018
|
-
const equalsCode = "=".charCodeAt(0);
|
|
1019
|
-
const padding = lastCode === equalsCode ? previousCode === equalsCode ? 2 : 1 : 0;
|
|
1020
|
-
return Math.max(0, Math.floor(nonWhitespaceLength * 3 / 4) - padding);
|
|
1021
|
-
}
|
|
1022
|
-
function isBase64WhitespaceCode(code) {
|
|
1023
|
-
return code === 32 || code === 9 || code === 10 || code === 13;
|
|
1024
|
-
}
|
|
1025
984
|
//#endregion
|
|
1026
985
|
//#region extensions/codex/src/app-server/event-projector-reasoning.ts
|
|
1027
986
|
var CodexReasoningProjection = class {
|
|
@@ -1044,7 +1003,8 @@ var CodexReasoningProjection = class {
|
|
|
1044
1003
|
content: /* @__PURE__ */ new Map()
|
|
1045
1004
|
};
|
|
1046
1005
|
this.reasoningTextByItem.set(itemId, item);
|
|
1047
|
-
const
|
|
1006
|
+
const index = params[method === "item/reasoning/textDelta" ? "contentIndex" : "summaryIndex"];
|
|
1007
|
+
const groupIndex = typeof index === "number" && Number.isInteger(index) && index >= 0 ? index : 0;
|
|
1048
1008
|
const sections = method === "item/reasoning/textDelta" ? item.content : item.summary;
|
|
1049
1009
|
sections.set(groupIndex, `${sections.get(groupIndex) ?? ""}${delta}`);
|
|
1050
1010
|
await this.params.onReasoningStream?.({
|
|
@@ -1056,15 +1016,7 @@ var CodexReasoningProjection = class {
|
|
|
1056
1016
|
const itemId = readStringField(params, "itemId") ?? "plan";
|
|
1057
1017
|
const delta = readStringField(params, "delta") ?? "";
|
|
1058
1018
|
if (!delta) return;
|
|
1059
|
-
|
|
1060
|
-
this.planTextByItem.set(itemId, text);
|
|
1061
|
-
this.emitPlanUpdate({
|
|
1062
|
-
explanation: void 0,
|
|
1063
|
-
steps: splitPlanText(text).map((step) => ({
|
|
1064
|
-
step,
|
|
1065
|
-
status: "pending"
|
|
1066
|
-
}))
|
|
1067
|
-
});
|
|
1019
|
+
this.recordPlanText(itemId, `${this.planTextByItem.get(itemId) ?? ""}${delta}`);
|
|
1068
1020
|
}
|
|
1069
1021
|
async handleTurnPlanUpdated(params, source = "codex-app-server") {
|
|
1070
1022
|
const explanation = readNullableString(params, "explanation");
|
|
@@ -1106,16 +1058,7 @@ var CodexReasoningProjection = class {
|
|
|
1106
1058
|
}
|
|
1107
1059
|
return;
|
|
1108
1060
|
}
|
|
1109
|
-
if (item?.type === "plan" && typeof item.text === "string" && item.text)
|
|
1110
|
-
this.planTextByItem.set(item.id, item.text);
|
|
1111
|
-
this.emitPlanUpdate({
|
|
1112
|
-
explanation: void 0,
|
|
1113
|
-
steps: splitPlanText(item.text).map((step) => ({
|
|
1114
|
-
step,
|
|
1115
|
-
status: "pending"
|
|
1116
|
-
}))
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1061
|
+
if (item?.type === "plan" && typeof item.text === "string" && item.text) this.recordPlanText(item.id, item.text);
|
|
1119
1062
|
}
|
|
1120
1063
|
async maybeEndReasoning() {
|
|
1121
1064
|
if (!this.reasoningStarted || this.reasoningEnded) return;
|
|
@@ -1128,6 +1071,13 @@ var CodexReasoningProjection = class {
|
|
|
1128
1071
|
planText() {
|
|
1129
1072
|
return this.turnPlanText ?? [...this.planTextByItem.values()].filter((text) => text.trim().length > 0).join("\n\n");
|
|
1130
1073
|
}
|
|
1074
|
+
recordPlanText(itemId, text) {
|
|
1075
|
+
this.planTextByItem.set(itemId, text);
|
|
1076
|
+
this.emitPlanUpdate({ steps: text.split(/\r?\n/).map((line) => line.trim().replace(/^[-*]\s+/, "")).filter((line) => line.length > 0).map((step) => ({
|
|
1077
|
+
step,
|
|
1078
|
+
status: "pending"
|
|
1079
|
+
})) });
|
|
1080
|
+
}
|
|
1131
1081
|
emitPlanUpdate(params, source = "codex-app-server") {
|
|
1132
1082
|
if (!params.explanation && params.steps === void 0) return;
|
|
1133
1083
|
this.emitAgentEvent({
|
|
@@ -1238,6 +1188,136 @@ var CodexTerminalFailureProjection = class {
|
|
|
1238
1188
|
}
|
|
1239
1189
|
};
|
|
1240
1190
|
//#endregion
|
|
1191
|
+
//#region extensions/codex/src/app-server/event-projector-tool-search-evidence.ts
|
|
1192
|
+
const MAX_RETAINED_SEARCHES = 16;
|
|
1193
|
+
const MAX_RETAINED_DYNAMIC_CALLS = 32;
|
|
1194
|
+
const MAX_DISCOVERED_TOOLS = 32;
|
|
1195
|
+
const MAX_ID_CHARS = 256;
|
|
1196
|
+
const MAX_NAME_CHARS = 128;
|
|
1197
|
+
function readBoundedString(value, maxChars) {
|
|
1198
|
+
if (typeof value !== "string") return;
|
|
1199
|
+
const normalized = value.trim();
|
|
1200
|
+
if (!normalized) return;
|
|
1201
|
+
return normalized.slice(0, maxChars);
|
|
1202
|
+
}
|
|
1203
|
+
function trimOldest(map, maxSize) {
|
|
1204
|
+
while (map.size > maxSize) {
|
|
1205
|
+
const oldest = map.keys().next().value;
|
|
1206
|
+
if (oldest === void 0) return;
|
|
1207
|
+
map.delete(oldest);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
function collectToolRefs(values, output, seen, inheritedNamespace) {
|
|
1211
|
+
if (!Array.isArray(values)) return false;
|
|
1212
|
+
let truncated = false;
|
|
1213
|
+
for (const value of values) {
|
|
1214
|
+
if (!isJsonObject(value)) continue;
|
|
1215
|
+
const type = readBoundedString(value.type, MAX_NAME_CHARS);
|
|
1216
|
+
const name = readBoundedString(value.name, MAX_NAME_CHARS);
|
|
1217
|
+
if (type === "namespace" && name) {
|
|
1218
|
+
truncated = collectToolRefs(value.tools, output, seen, name) || truncated;
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
if (type !== "function" || !name) continue;
|
|
1222
|
+
const namespace = readBoundedString(value.namespace, MAX_NAME_CHARS) ?? inheritedNamespace;
|
|
1223
|
+
const key = `${namespace ?? ""}\u0000${name}`;
|
|
1224
|
+
if (seen.has(key)) continue;
|
|
1225
|
+
if (output.length >= MAX_DISCOVERED_TOOLS) {
|
|
1226
|
+
truncated = true;
|
|
1227
|
+
continue;
|
|
1228
|
+
}
|
|
1229
|
+
seen.add(key);
|
|
1230
|
+
output.push({
|
|
1231
|
+
...namespace ? { namespace } : {},
|
|
1232
|
+
name
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
return truncated;
|
|
1236
|
+
}
|
|
1237
|
+
/** Private-QA projection of searchable discovery receipts; never enters chat history. */
|
|
1238
|
+
var CodexToolSearchEvidenceProjection = class {
|
|
1239
|
+
constructor(recorder, threadId, turnId) {
|
|
1240
|
+
this.recorder = recorder;
|
|
1241
|
+
this.threadId = threadId;
|
|
1242
|
+
this.turnId = turnId;
|
|
1243
|
+
this.calls = /* @__PURE__ */ new Map();
|
|
1244
|
+
this.outputs = /* @__PURE__ */ new Map();
|
|
1245
|
+
this.dynamicCalls = /* @__PURE__ */ new Map();
|
|
1246
|
+
}
|
|
1247
|
+
recordRawResponseItem(item) {
|
|
1248
|
+
const type = readBoundedString(item.type, MAX_NAME_CHARS);
|
|
1249
|
+
const callId = readBoundedString(item.call_id, MAX_ID_CHARS);
|
|
1250
|
+
if (!callId) return;
|
|
1251
|
+
if (type === "tool_search_call") {
|
|
1252
|
+
const execution = readBoundedString(item.execution, MAX_NAME_CHARS);
|
|
1253
|
+
const status = readBoundedString(item.status, MAX_NAME_CHARS);
|
|
1254
|
+
this.calls.set(callId, {
|
|
1255
|
+
callId,
|
|
1256
|
+
...execution ? { execution } : {},
|
|
1257
|
+
...status ? { status } : {}
|
|
1258
|
+
});
|
|
1259
|
+
trimOldest(this.calls, MAX_RETAINED_SEARCHES);
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
if (type !== "tool_search_output") return;
|
|
1263
|
+
const call = this.calls.get(callId);
|
|
1264
|
+
if (!call) return;
|
|
1265
|
+
const tools = [];
|
|
1266
|
+
const truncated = collectToolRefs(item.tools, tools, /* @__PURE__ */ new Set());
|
|
1267
|
+
const execution = readBoundedString(item.execution, MAX_NAME_CHARS);
|
|
1268
|
+
const status = readBoundedString(item.status, MAX_NAME_CHARS);
|
|
1269
|
+
this.outputs.set(callId, {
|
|
1270
|
+
call,
|
|
1271
|
+
...execution ? { execution } : {},
|
|
1272
|
+
...status ? { status } : {},
|
|
1273
|
+
tools,
|
|
1274
|
+
truncated
|
|
1275
|
+
});
|
|
1276
|
+
trimOldest(this.outputs, MAX_RETAINED_SEARCHES);
|
|
1277
|
+
}
|
|
1278
|
+
recordDynamicToolCall(params) {
|
|
1279
|
+
const callId = readBoundedString(params.callId, MAX_ID_CHARS);
|
|
1280
|
+
const tool = readBoundedString(params.tool, MAX_NAME_CHARS);
|
|
1281
|
+
const requestedNamespace = readBoundedString(params.namespace, MAX_NAME_CHARS);
|
|
1282
|
+
if (!callId || !tool || !requestedNamespace || requestedNamespace !== params.namespace) return;
|
|
1283
|
+
const search = [...this.outputs.values()].toReversed().find((candidate) => candidate.tools.some((ref) => ref.name === tool && ref.namespace === requestedNamespace));
|
|
1284
|
+
if (!search) return;
|
|
1285
|
+
this.dynamicCalls.set(callId, {
|
|
1286
|
+
search,
|
|
1287
|
+
namespace: requestedNamespace,
|
|
1288
|
+
tool
|
|
1289
|
+
});
|
|
1290
|
+
trimOldest(this.dynamicCalls, MAX_RETAINED_DYNAMIC_CALLS);
|
|
1291
|
+
}
|
|
1292
|
+
recordDynamicToolResult(params) {
|
|
1293
|
+
const callId = readBoundedString(params.callId, MAX_ID_CHARS);
|
|
1294
|
+
const tool = readBoundedString(params.tool, MAX_NAME_CHARS);
|
|
1295
|
+
if (!callId || !tool) return;
|
|
1296
|
+
const link = this.dynamicCalls.get(callId);
|
|
1297
|
+
if (!link || link.tool !== tool) return;
|
|
1298
|
+
this.dynamicCalls.delete(callId);
|
|
1299
|
+
this.recorder.recordEvent("tool.search.discovery", {
|
|
1300
|
+
threadId: this.threadId,
|
|
1301
|
+
turnId: this.turnId,
|
|
1302
|
+
search: {
|
|
1303
|
+
callId: link.search.call.callId,
|
|
1304
|
+
...link.search.call.execution ? { callExecution: link.search.call.execution } : {},
|
|
1305
|
+
...link.search.call.status ? { callStatus: link.search.call.status } : {},
|
|
1306
|
+
...link.search.execution ? { outputExecution: link.search.execution } : {},
|
|
1307
|
+
...link.search.status ? { outputStatus: link.search.status } : {},
|
|
1308
|
+
tools: link.search.tools,
|
|
1309
|
+
...link.search.truncated ? { truncated: true } : {}
|
|
1310
|
+
},
|
|
1311
|
+
target: {
|
|
1312
|
+
callId,
|
|
1313
|
+
namespace: link.namespace,
|
|
1314
|
+
name: tool,
|
|
1315
|
+
success: params.success
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
//#endregion
|
|
1241
1321
|
//#region extensions/codex/src/app-server/transcript-checkpoint.ts
|
|
1242
1322
|
/** Commits completed work in receipt order without waiting for the enclosing turn. */
|
|
1243
1323
|
var CodexTranscriptCheckpoint = class {
|
|
@@ -1358,6 +1438,7 @@ var CodexTurnProjection = class {
|
|
|
1358
1438
|
trajectoryRecorder: options.trajectoryRecorder,
|
|
1359
1439
|
checkpointMessage: this.transcriptCheckpoint.enqueue
|
|
1360
1440
|
});
|
|
1441
|
+
this.toolSearchEvidenceProjection = options.trajectoryRecorder && process.env.OPENCLAW_BUILD_PRIVATE_QA === "1" ? new CodexToolSearchEvidenceProjection(options.trajectoryRecorder, threadId, turnId) : void 0;
|
|
1361
1442
|
this.eventProjection = new CodexEventProjection(params.provider, threadId, turnId, (event) => this.emitAgentEvent(event), this.toolProgressProjection, this.toolTranscriptProjection, options.onNativeToolResultRecorded);
|
|
1362
1443
|
this.assistantProjection = new CodexAssistantProjection(this.settlement.params, (event) => this.emitAgentEvent(event), (text) => this.toolProgressProjection.matchesEcho(text), this.transcriptCheckpoint.nextTimestamp, this.transcriptCheckpoint.enqueueCommentary);
|
|
1363
1444
|
this.reasoningProjection = new CodexReasoningProjection(this.settlement.params, (event) => this.emitAgentEvent(event), options.onNativePlanUpdate);
|
|
@@ -1699,6 +1780,7 @@ var CodexAppServerEventProjector = class extends CodexTurnProjection {
|
|
|
1699
1780
|
});
|
|
1700
1781
|
}
|
|
1701
1782
|
recordDynamicToolCall(params) {
|
|
1783
|
+
this.toolSearchEvidenceProjection?.recordDynamicToolCall(params);
|
|
1702
1784
|
this.toolTranscriptProjection.recordDynamicToolCall(params);
|
|
1703
1785
|
}
|
|
1704
1786
|
/** Projects a successful OpenClaw progress_card call through the native plan stream. */
|
|
@@ -1714,6 +1796,7 @@ var CodexAppServerEventProjector = class extends CodexTurnProjection {
|
|
|
1714
1796
|
}
|
|
1715
1797
|
}
|
|
1716
1798
|
recordDynamicToolResult(params) {
|
|
1799
|
+
this.toolSearchEvidenceProjection?.recordDynamicToolResult(params);
|
|
1717
1800
|
this.toolProgressProjection.recordDynamicToolResult(params);
|
|
1718
1801
|
const source = this.options.resolveDynamicToolResultContentSource?.(params.tool);
|
|
1719
1802
|
this.toolTranscriptProjection.recordDynamicToolResult(params, source);
|
|
@@ -1941,6 +2024,7 @@ var CodexAppServerEventProjector = class extends CodexTurnProjection {
|
|
|
1941
2024
|
const item = isJsonObject(params.item) ? params.item : void 0;
|
|
1942
2025
|
if (!item) return;
|
|
1943
2026
|
if (item.role === "assistant" && extractRawAssistantText(item)) this.eventProjection.markSafetyBufferingAssistantStarted();
|
|
2027
|
+
this.toolSearchEvidenceProjection?.recordRawResponseItem(item);
|
|
1944
2028
|
this.toolTranscriptProjection.recordRawNativeToolItem(item);
|
|
1945
2029
|
this.assistantProjection.handleRawResponseItemCompleted(item, this.activeItemIds);
|
|
1946
2030
|
await this.settlement.project("media_projection", () => this.generatedMediaProjection.recordRaw(item));
|
|
@@ -1952,145 +2036,6 @@ var CodexAppServerEventProjector = class extends CodexTurnProjection {
|
|
|
1952
2036
|
}
|
|
1953
2037
|
};
|
|
1954
2038
|
//#endregion
|
|
1955
|
-
//#region extensions/codex/src/app-server/native-mcp-app.ts
|
|
1956
|
-
const CODEX_APPS_MCP_SERVER = "codex_apps";
|
|
1957
|
-
function readMcpAppResourceUri(item) {
|
|
1958
|
-
const appContext = asOptionalRecord(item.appContext);
|
|
1959
|
-
const uri = normalizeOptionalString(appContext?.resourceUri) ?? normalizeOptionalString(item.mcpAppResourceUri);
|
|
1960
|
-
return uri?.startsWith("ui://") ? uri : void 0;
|
|
1961
|
-
}
|
|
1962
|
-
function readMcpToolResult(item) {
|
|
1963
|
-
const result = asOptionalRecord(item.result);
|
|
1964
|
-
if (!result || !Array.isArray(result.content)) return;
|
|
1965
|
-
const resultMeta = asOptionalRecord(result["_meta"]);
|
|
1966
|
-
return {
|
|
1967
|
-
content: result.content,
|
|
1968
|
-
...result.structuredContent !== void 0 ? { structuredContent: result.structuredContent } : {},
|
|
1969
|
-
...result.isError === true ? { isError: true } : {},
|
|
1970
|
-
...resultMeta ? { _meta: resultMeta } : {}
|
|
1971
|
-
};
|
|
1972
|
-
}
|
|
1973
|
-
function statusTools(status) {
|
|
1974
|
-
return Object.entries(status.tools).map(([name, value]) => Object.assign({}, asOptionalRecord(value) ?? {}, { name }));
|
|
1975
|
-
}
|
|
1976
|
-
function createNativeMcpRuntime(params) {
|
|
1977
|
-
let catalog = null;
|
|
1978
|
-
let statuses;
|
|
1979
|
-
const createdAt = Date.now();
|
|
1980
|
-
const loadStatuses = async () => {
|
|
1981
|
-
if (statuses) return statuses;
|
|
1982
|
-
statuses = (await params.client.request("mcpServerStatus/list", {
|
|
1983
|
-
threadId: params.threadId,
|
|
1984
|
-
detail: "full"
|
|
1985
|
-
})).data;
|
|
1986
|
-
return statuses;
|
|
1987
|
-
};
|
|
1988
|
-
const getCatalog = async () => {
|
|
1989
|
-
if (catalog) return catalog;
|
|
1990
|
-
const loaded = await loadStatuses();
|
|
1991
|
-
catalog = {
|
|
1992
|
-
version: 1,
|
|
1993
|
-
generatedAt: Date.now(),
|
|
1994
|
-
servers: Object.fromEntries(loaded.map((status) => [status.name, {
|
|
1995
|
-
serverName: status.name,
|
|
1996
|
-
launchSummary: "Codex native MCP connection",
|
|
1997
|
-
toolCount: Object.keys(status.tools).length
|
|
1998
|
-
}])),
|
|
1999
|
-
tools: loaded.flatMap((status) => statusTools(status).map((tool) => {
|
|
2000
|
-
const uiVisibility = readCodexMcpToolUiVisibility(tool);
|
|
2001
|
-
return Object.assign({
|
|
2002
|
-
serverName: status.name,
|
|
2003
|
-
safeServerName: status.name,
|
|
2004
|
-
toolName: String(tool.name),
|
|
2005
|
-
inputSchema: asOptionalRecord(tool.inputSchema) ?? { type: "object" },
|
|
2006
|
-
fallbackDescription: normalizeOptionalString(tool.description) ?? String(tool.name)
|
|
2007
|
-
}, uiVisibility ? { uiVisibility } : {});
|
|
2008
|
-
}))
|
|
2009
|
-
};
|
|
2010
|
-
return catalog;
|
|
2011
|
-
};
|
|
2012
|
-
const runtime = {
|
|
2013
|
-
sessionId: params.attempt.sessionId,
|
|
2014
|
-
sessionKey: params.attempt.sessionKey,
|
|
2015
|
-
workspaceDir: params.attempt.workspaceDir,
|
|
2016
|
-
configFingerprint: `${getCodexAppServerClientInstanceId(params.client)}:${params.threadId}`,
|
|
2017
|
-
mcpAppsEnabled: true,
|
|
2018
|
-
createdAt,
|
|
2019
|
-
lastUsedAt: createdAt,
|
|
2020
|
-
acquireLease: () => retainSharedCodexAppServerClientIfCurrent(params.client) ?? (() => {}),
|
|
2021
|
-
getCatalog,
|
|
2022
|
-
peekCatalog: () => catalog,
|
|
2023
|
-
markUsed: () => {
|
|
2024
|
-
runtime.lastUsedAt = Date.now();
|
|
2025
|
-
},
|
|
2026
|
-
callTool: async (serverName, toolName, input) => await params.client.request("mcpServer/tool/call", {
|
|
2027
|
-
threadId: params.threadId,
|
|
2028
|
-
server: serverName,
|
|
2029
|
-
tool: toolName,
|
|
2030
|
-
arguments: asOptionalRecord(input) ?? {}
|
|
2031
|
-
}),
|
|
2032
|
-
listTools: async (serverName) => {
|
|
2033
|
-
const status = (await loadStatuses()).find((entry) => entry.name === serverName);
|
|
2034
|
-
return { tools: status ? statusTools(status) : [] };
|
|
2035
|
-
},
|
|
2036
|
-
readResource: async (serverName, uri) => {
|
|
2037
|
-
const isCodexAppsServer = serverName === CODEX_APPS_MCP_SERVER;
|
|
2038
|
-
const response = await params.client.request("mcpServer/resource/read", {
|
|
2039
|
-
threadId: params.threadId,
|
|
2040
|
-
...isCodexAppsServer ? { originCallId: params.originCallId } : {},
|
|
2041
|
-
server: serverName,
|
|
2042
|
-
uri,
|
|
2043
|
-
...params.connectorId ? { connectorId: params.connectorId } : {}
|
|
2044
|
-
});
|
|
2045
|
-
if (isCodexAppsServer && response.originCallId !== params.originCallId) throw new Error(`Codex MCP resource response originCallId mismatch: expected ${params.originCallId}, received ${response.originCallId}`);
|
|
2046
|
-
return response;
|
|
2047
|
-
},
|
|
2048
|
-
listResources: async (serverName) => {
|
|
2049
|
-
return { resources: (await loadStatuses()).find((entry) => entry.name === serverName)?.resources ?? [] };
|
|
2050
|
-
},
|
|
2051
|
-
listResourceTemplates: async (serverName) => {
|
|
2052
|
-
return { resourceTemplates: (await loadStatuses()).find((entry) => entry.name === serverName)?.resourceTemplates ?? [] };
|
|
2053
|
-
},
|
|
2054
|
-
joinCleanup: async () => {},
|
|
2055
|
-
dispose: async () => {}
|
|
2056
|
-
};
|
|
2057
|
-
return runtime;
|
|
2058
|
-
}
|
|
2059
|
-
function createCodexNativeMcpAppResultDetailsPreparer(params) {
|
|
2060
|
-
if (params.attempt.config?.mcp?.apps?.enabled !== true) return;
|
|
2061
|
-
return async (item) => {
|
|
2062
|
-
const serverName = normalizeOptionalString(item.server);
|
|
2063
|
-
const toolName = normalizeOptionalString(item.tool);
|
|
2064
|
-
const uiResourceUri = readMcpAppResourceUri(item);
|
|
2065
|
-
const connectorId = normalizeOptionalString(asOptionalRecord(item.appContext)?.connectorId);
|
|
2066
|
-
const toolResult = readMcpToolResult(item);
|
|
2067
|
-
if (!serverName || !toolName || !uiResourceUri || !toolResult) return;
|
|
2068
|
-
if (serverName === CODEX_APPS_MCP_SERVER && !connectorId) return;
|
|
2069
|
-
const runtime = createNativeMcpRuntime({
|
|
2070
|
-
...params,
|
|
2071
|
-
originCallId: item.id,
|
|
2072
|
-
...connectorId ? { connectorId } : {}
|
|
2073
|
-
});
|
|
2074
|
-
const tools = (await runtime.listTools?.(serverName))?.tools ?? [];
|
|
2075
|
-
const allowedAppToolNames = new Set(tools.filter((tool) => {
|
|
2076
|
-
const uiVisibility = readCodexMcpToolUiVisibility(tool);
|
|
2077
|
-
return (uiVisibility === void 0 || uiVisibility.includes("app")) && (serverName !== CODEX_APPS_MCP_SERVER || readCodexMcpToolConnectorId(tool) === connectorId);
|
|
2078
|
-
}).map((tool) => tool.name));
|
|
2079
|
-
if (!allowedAppToolNames.has(toolName)) return;
|
|
2080
|
-
return await prepareHarnessNativeMcpAppPreview({
|
|
2081
|
-
runtime,
|
|
2082
|
-
serverName,
|
|
2083
|
-
toolName,
|
|
2084
|
-
uiResourceUri,
|
|
2085
|
-
toolCallId: item.id,
|
|
2086
|
-
toolInput: item.arguments ?? {},
|
|
2087
|
-
toolResult,
|
|
2088
|
-
allowedAppToolNames,
|
|
2089
|
-
...toolResult["_meta"] !== void 0 ? { resultMetaState: "unavailable" } : {}
|
|
2090
|
-
});
|
|
2091
|
-
};
|
|
2092
|
-
}
|
|
2093
|
-
//#endregion
|
|
2094
2039
|
//#region extensions/codex/src/app-server/plan-compaction-state.ts
|
|
2095
2040
|
const RESTORED_PLAN_PREAMBLE = "OpenClaw restored the session progress card after context compaction. This is application state, not a new user request. Continue the current task and call progress_card whenever the status meaningfully changes.";
|
|
2096
2041
|
const PROGRESS_CARD_MAX_STEPS = 50;
|
|
@@ -2229,13 +2174,14 @@ async function restoreCodexAttemptCompactionContext(resources) {
|
|
|
2229
2174
|
error: formatErrorMessage(error)
|
|
2230
2175
|
});
|
|
2231
2176
|
}
|
|
2232
|
-
thread.liveThreadEphemeralPolicy = await
|
|
2177
|
+
thread.liveThreadEphemeralPolicy = await restoreCodexThreadInstructionsAfterCompaction({
|
|
2233
2178
|
client,
|
|
2234
2179
|
threadId: thread.threadId,
|
|
2235
2180
|
ephemeralPolicy: thread.liveThreadEphemeralPolicy,
|
|
2236
2181
|
timeoutMs: connection.appServer.requestTimeoutMs,
|
|
2237
2182
|
signal: runAbortController.signal,
|
|
2238
|
-
assertCurrent
|
|
2183
|
+
assertCurrent,
|
|
2184
|
+
withCurrent: connection.withCurrent
|
|
2239
2185
|
});
|
|
2240
2186
|
}
|
|
2241
2187
|
//#endregion
|
|
@@ -2317,9 +2263,10 @@ function createCodexUserInputBridge(params) {
|
|
|
2317
2263
|
},
|
|
2318
2264
|
async handleElicitationRequest(request, requestSignal) {
|
|
2319
2265
|
if (readOwnDataString(request.params, "threadId") !== params.threadId) return;
|
|
2320
|
-
const
|
|
2266
|
+
const mode = readOwnDataString(request.params, "mode");
|
|
2267
|
+
const requestSnapshot = agentHarnessStructuredInput.snapshot(request.params, { richForm: mode === "openaiForm" || mode === "openai/form" });
|
|
2321
2268
|
if (agentHarnessStructuredInput.isRecord(requestSnapshot) && readOwnDataString(requestSnapshot, "threadId") !== params.threadId) return;
|
|
2322
|
-
const { compileCodexOrdinaryElicitation } = await import("./elicitation-input-
|
|
2269
|
+
const { compileCodexOrdinaryElicitation } = await import("./elicitation-input-r9axtppm.mjs");
|
|
2323
2270
|
const compiled = agentHarnessStructuredInput.isRecord(requestSnapshot) ? compileCodexOrdinaryElicitation({
|
|
2324
2271
|
snapshot: requestSnapshot,
|
|
2325
2272
|
turnId: params.turnId
|
|
@@ -2337,13 +2284,29 @@ function createCodexUserInputBridge(params) {
|
|
|
2337
2284
|
cancelValue,
|
|
2338
2285
|
failureValue: declineElicitation("OpenClaw could not handle this elicitation."),
|
|
2339
2286
|
run: async (signal) => {
|
|
2340
|
-
const
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2287
|
+
const resource = params.prepareResourceContext && agentHarnessStructuredInput.isRecord(requestSnapshot) && hasResourceInput(requestSnapshot) ? await params.prepareResourceContext({
|
|
2288
|
+
requestId: request.id,
|
|
2289
|
+
snapshot: requestSnapshot,
|
|
2290
|
+
signal
|
|
2291
|
+
}) : void 0;
|
|
2292
|
+
try {
|
|
2293
|
+
signal.throwIfAborted();
|
|
2294
|
+
const withResources = resource && agentHarnessStructuredInput.isRecord(requestSnapshot) ? compileCodexOrdinaryElicitation({
|
|
2295
|
+
snapshot: requestSnapshot,
|
|
2296
|
+
turnId: params.turnId,
|
|
2297
|
+
resourceContext: resource.context
|
|
2298
|
+
}) : compiled;
|
|
2299
|
+
if (withResources.kind === "ignored") return cancelValue;
|
|
2300
|
+
const result = await execute(withResources.input, timeoutMs, signal);
|
|
2301
|
+
if (result.status === "answered") {
|
|
2302
|
+
const content = compiled.input.kind === "ready" && compiled.input.plan.kind === "url" ? null : result.content;
|
|
2303
|
+
return createCodexElicitationResponse("accept", content);
|
|
2304
|
+
}
|
|
2305
|
+
if (result.status === "declined" || result.status === "unsupported") return declineElicitation(result.message);
|
|
2306
|
+
return cancelValue;
|
|
2307
|
+
} finally {
|
|
2308
|
+
await resource?.dispose();
|
|
2344
2309
|
}
|
|
2345
|
-
if (result.status === "declined" || result.status === "unsupported") return declineElicitation(result.message);
|
|
2346
|
-
return cancelValue;
|
|
2347
2310
|
}
|
|
2348
2311
|
}, requestSignal);
|
|
2349
2312
|
},
|
|
@@ -2431,6 +2394,11 @@ function gatewayAnswersToCodexResponse(answers) {
|
|
|
2431
2394
|
function declineElicitation(message) {
|
|
2432
2395
|
return createCodexElicitationResponse("decline", null, message ? { message } : null);
|
|
2433
2396
|
}
|
|
2397
|
+
function hasResourceInput(snapshot) {
|
|
2398
|
+
const schema = snapshot.requestedSchema;
|
|
2399
|
+
const properties = agentHarnessStructuredInput.isRecord(schema) ? schema.properties : void 0;
|
|
2400
|
+
return agentHarnessStructuredInput.isRecord(properties) && Object.values(properties).some((field) => agentHarnessStructuredInput.isRecord(field) && Object.hasOwn(field, "x-openai-input"));
|
|
2401
|
+
}
|
|
2434
2402
|
//#endregion
|
|
2435
2403
|
//#region extensions/codex/src/app-server/run-attempt-active-turn.ts
|
|
2436
2404
|
function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notifications, { turn, upstreamUserText }) {
|
|
@@ -2462,28 +2430,22 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2462
2430
|
} : dynamicToolParams;
|
|
2463
2431
|
const hostPrepareReplyMedia = params.hostCapabilities.prepareReplyMedia;
|
|
2464
2432
|
const remoteWorkspaceRoot = connection.appServer.remoteWorkspaceRoot;
|
|
2465
|
-
const
|
|
2433
|
+
const readRemoteWorkspaceFile = createCodexRemoteWorkspaceFileReader(resourceState.client, connection.authority);
|
|
2466
2434
|
const prepareReplyMedia = hostPrepareReplyMedia && remoteWorkspaceRoot ? async (content, transferSignal) => hostPrepareReplyMedia({
|
|
2467
2435
|
...content,
|
|
2468
2436
|
workspaceRoot: remoteWorkspaceRoot,
|
|
2469
2437
|
signal: runAbortController.signal,
|
|
2470
|
-
readWorkspaceFile:
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
signal: transferSignal ? AbortSignal.any([signal, transferSignal]) : signal,
|
|
2482
|
-
timeoutMs: connection.appServer.requestTimeoutMs
|
|
2483
|
-
});
|
|
2484
|
-
connection.assertCurrent();
|
|
2485
|
-
return Buffer.from(file.dataBase64, "base64");
|
|
2486
|
-
}
|
|
2438
|
+
readWorkspaceFile: (relativePath, { maxBytes, signal }) => readRemoteWorkspaceFile({
|
|
2439
|
+
path: mapCodexAppServerRemoteWorkspacePath({
|
|
2440
|
+
value: path.resolve(params.workspaceDir, relativePath),
|
|
2441
|
+
localWorkspaceRoot: params.workspaceDir,
|
|
2442
|
+
remoteWorkspaceRoot
|
|
2443
|
+
}),
|
|
2444
|
+
workspaceRoot: remoteWorkspaceRoot,
|
|
2445
|
+
maxBytes,
|
|
2446
|
+
signal: transferSignal ? AbortSignal.any([signal, transferSignal]) : signal,
|
|
2447
|
+
timeoutMs: connection.appServer.requestTimeoutMs
|
|
2448
|
+
})
|
|
2487
2449
|
}) : void 0;
|
|
2488
2450
|
const progressCardTool = toolBridge.availableTools.find((tool) => tool.name === "progress_card");
|
|
2489
2451
|
let nativePlanUpdateOrdinal = 0;
|
|
@@ -2533,13 +2495,7 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2533
2495
|
runAbortSignal: runAbortController.signal,
|
|
2534
2496
|
remoteWorkspaceRoot: connection.appServer.remoteWorkspaceRoot,
|
|
2535
2497
|
remoteWorkspaceRequestTimeoutMs: connection.appServer.requestTimeoutMs,
|
|
2536
|
-
readRemoteWorkspaceFile
|
|
2537
|
-
client: resourceState.client,
|
|
2538
|
-
path: remotePath,
|
|
2539
|
-
maxBytes,
|
|
2540
|
-
signal,
|
|
2541
|
-
timeoutMs
|
|
2542
|
-
}),
|
|
2498
|
+
readRemoteWorkspaceFile,
|
|
2543
2499
|
trajectoryRecorder,
|
|
2544
2500
|
resolveDynamicToolResultContentSource: toolBridge.resultContentSourceForTool,
|
|
2545
2501
|
onNativeToolResultRecorded: maybeAnnounceFastModeAutoOff,
|
|
@@ -2633,6 +2589,7 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2633
2589
|
requestTimeoutMs: connection.appServer.requestTimeoutMs,
|
|
2634
2590
|
signal: runAbortController.signal,
|
|
2635
2591
|
assertActive: assertSteeringActive,
|
|
2592
|
+
withCurrent: connection.withCurrent,
|
|
2636
2593
|
prepareMessage: async (text, options, assertMessageCurrent) => {
|
|
2637
2594
|
const attachmentNote = await connection.prepareInputAttachments({
|
|
2638
2595
|
maxChars: Math.max(0, CODEX_TURN_START_TEXT_INPUT_MAX_CHARS - text.length - 2),
|
|
@@ -2683,7 +2640,10 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2683
2640
|
const messages = activeProjector.buildSteeringTranscriptPrefix();
|
|
2684
2641
|
if (params.sessionTarget && messages.length > 0) {
|
|
2685
2642
|
await codexTranscriptMirrorRuntime.mirror({
|
|
2686
|
-
assertCurrent:
|
|
2643
|
+
assertCurrent: () => {
|
|
2644
|
+
connection.assertLegacyCurrent();
|
|
2645
|
+
assertSteeringActive();
|
|
2646
|
+
},
|
|
2687
2647
|
agentId: sessionAgentId,
|
|
2688
2648
|
sessionKey: contextSessionKey,
|
|
2689
2649
|
sessionId: params.sessionId,
|
|
@@ -2741,6 +2701,7 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2741
2701
|
const canClaim = injectionGuard(assertCurrent);
|
|
2742
2702
|
if (await claimPendingUserInputAnswer(text, optionsLocal, assertCurrent, authorityKind)) {
|
|
2743
2703
|
optionsLocal?.onQueueAccepted?.(true);
|
|
2704
|
+
optionsLocal?.onQueueSettled?.();
|
|
2744
2705
|
return;
|
|
2745
2706
|
}
|
|
2746
2707
|
if (optionsLocal?.isInboundUserMessage === true && hasPromptImageInput(optionsLocal)) {
|
|
@@ -2775,6 +2736,7 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2775
2736
|
runId: params.runId,
|
|
2776
2737
|
startedAtMs: params.startedAtMs,
|
|
2777
2738
|
toolAuthorityFingerprint: params.toolAuthorityFingerprint,
|
|
2739
|
+
supportsCrossProfileSteering: isCodexNativeDelegationDisabledForRun(params) || resourceState.nativeSpawnAdmissionInstalled,
|
|
2778
2740
|
permissionChangeOwner: params.permissionChange?.owner,
|
|
2779
2741
|
applyPermissionMode: async (mode, revokeApprovals) => {
|
|
2780
2742
|
if (!params.permissionChange || terminalState.terminalOutcomeFrozen || params.abortSignal?.aborted || !state.permissionChangeRestart && (state.completed || runAbortController.signal.aborted)) return false;
|
|
@@ -2810,6 +2772,13 @@ function activateCodexAttemptTurn(resources, turnRuntime, lifecycle, notificatio
|
|
|
2810
2772
|
emitExecutionPhaseOnce("turn_accepted", { phase: "turn_accepted" });
|
|
2811
2773
|
userInputBridgeRef.current = createCodexUserInputBridge({
|
|
2812
2774
|
paramsForRun: params,
|
|
2775
|
+
prepareResourceContext: (request) => prepareCodexNativeMcpFormResourceContext({
|
|
2776
|
+
client: resourceState.client,
|
|
2777
|
+
threadId: resourceState.thread.threadId,
|
|
2778
|
+
attempt: params,
|
|
2779
|
+
request,
|
|
2780
|
+
readOrigin: (serverName) => activeProjector.getActiveMcpToolCall(serverName)
|
|
2781
|
+
}),
|
|
2813
2782
|
onOrdinaryResponse: (response) => activeProjector.recordUserInputResponse(response),
|
|
2814
2783
|
threadId: resourceState.thread.threadId,
|
|
2815
2784
|
turnId: activeTurnId,
|
|
@@ -2922,17 +2891,14 @@ async function cleanupCodexAttempt(resources, turnRuntime, lifecycle, requestRun
|
|
|
2922
2891
|
run: () => bindingStore.withLease(bindingIdentity, async () => {
|
|
2923
2892
|
if (!isSameCodexAppServerThreadOwner(bindingStore.read(bindingIdentity), resourceState.thread)) throw new Error("Codex plugin refresh lost its managed thread binding.");
|
|
2924
2893
|
if (!await releaseThreadSubscription(connection.assertCurrent)) throw new Error("Plugin reload could not release the previous Codex thread.");
|
|
2925
|
-
if (!await bindingStore
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2894
|
+
if (!await clearCodexBindingForClient(bindingStore, bindingIdentity, resourceState.thread, connection.authority)) throw new Error("Codex plugin refresh lost its managed thread binding.");
|
|
2895
|
+
}, {
|
|
2896
|
+
assertCurrent: connection.assertCurrent,
|
|
2897
|
+
authority: connection.authority
|
|
2929
2898
|
})
|
|
2930
2899
|
});
|
|
2931
2900
|
else {
|
|
2932
|
-
const bindingReleased = isIncognitoSessionKey(params.sessionKey) && !retainLiveThread ? await
|
|
2933
|
-
kind: "clear",
|
|
2934
|
-
threadId: resourceState.thread.threadId
|
|
2935
|
-
}) : true;
|
|
2901
|
+
const bindingReleased = isIncognitoSessionKey(params.sessionKey) && !retainLiveThread ? await resources.clearThreadBinding() : true;
|
|
2936
2902
|
if (!retainLiveThread && bindingReleased && !await releaseThreadSubscription() && params.oneShotCliRun) await runCleanupStep("codex-one-shot-unsubscribe", async () => {
|
|
2937
2903
|
throw new Error("Codex one-shot thread unsubscribe was not confirmed");
|
|
2938
2904
|
});
|
|
@@ -2973,13 +2939,6 @@ async function cleanupCodexAttempt(resources, turnRuntime, lifecycle, requestRun
|
|
|
2973
2939
|
}
|
|
2974
2940
|
//#endregion
|
|
2975
2941
|
//#region extensions/codex/src/app-server/session-binding-scope.ts
|
|
2976
|
-
/** Both read and write projections must leave retained assignment facts unchanged. */
|
|
2977
|
-
function projectAssignmentOwner(assignment, owner) {
|
|
2978
|
-
return {
|
|
2979
|
-
...assignment,
|
|
2980
|
-
owner
|
|
2981
|
-
};
|
|
2982
|
-
}
|
|
2983
2942
|
/** Carries one prepared run identity through callers that rederive it from public params. */
|
|
2984
2943
|
function scopeCodexRunBindingStore(params) {
|
|
2985
2944
|
const mapSessionIdentity = (identity) => identity.agentId === params.logicalIdentity.agentId && identity.sessionId === params.logicalIdentity.sessionId && identity.sessionKey?.trim() === params.logicalIdentity.sessionKey?.trim() ? params.physicalIdentity : identity;
|
|
@@ -2991,40 +2950,40 @@ function scopeCodexRunBindingStore(params) {
|
|
|
2991
2950
|
sessionId: mapped.sessionId
|
|
2992
2951
|
} : owner;
|
|
2993
2952
|
};
|
|
2994
|
-
const readMany = params.bindingStore.readMany?.bind(params.bindingStore);
|
|
2995
2953
|
return {
|
|
2996
2954
|
...params.bindingStore,
|
|
2997
2955
|
read: (identity) => params.bindingStore.read(mapIdentity(identity)),
|
|
2998
|
-
|
|
2999
|
-
readNativeSubagentAssignments: (identity, owner) => (params.bindingStore.readNativeSubagentAssignments?.(mapIdentity(identity), mapHistoryOwner(identity, owner)) ?? []).map((assignment) =>
|
|
2956
|
+
readMany: (identities) => params.bindingStore.readMany(identities.map(mapIdentity)),
|
|
2957
|
+
readNativeSubagentAssignments: (identity, owner) => (params.bindingStore.readNativeSubagentAssignments?.(mapIdentity(identity), mapHistoryOwner(identity, owner)) ?? []).map((assignment) => Object.assign({}, assignment, { owner: {
|
|
3000
2958
|
...assignment.owner,
|
|
3001
2959
|
sessionId: owner.sessionId
|
|
3002
|
-
})),
|
|
2960
|
+
} })),
|
|
3003
2961
|
readNativeSubagentSubmissions: (identity, owner) => params.bindingStore.readNativeSubagentSubmissions(mapIdentity(identity), mapHistoryOwner(identity, owner)),
|
|
3004
2962
|
hasOtherThreadOwner: (threadId, identity) => params.bindingStore.hasOtherThreadOwner(threadId, identity ? mapIdentity(identity) : void 0),
|
|
3005
|
-
mutate: (identity, mutation, assertCurrent) => params.bindingStore.mutate(mapIdentity(identity), mutation.kind === "record-native-subagent-assignment" || mutation.kind === "consume-native-subagent-assignment" ? {
|
|
2963
|
+
mutate: (identity, mutation, assertCurrent, authority) => params.bindingStore.mutate(mapIdentity(identity), mutation.kind === "record-native-subagent-assignment" || mutation.kind === "consume-native-subagent-assignment" ? {
|
|
3006
2964
|
...mutation,
|
|
3007
2965
|
owner: mapHistoryOwner(identity, mutation.owner),
|
|
3008
|
-
assignment:
|
|
2966
|
+
assignment: {
|
|
2967
|
+
...mutation.assignment,
|
|
2968
|
+
owner: mapHistoryOwner(identity, mutation.assignment.owner)
|
|
2969
|
+
}
|
|
3009
2970
|
} : mutation.kind === "record-native-subagent-submission" || mutation.kind === "consume-native-subagent-submission" ? {
|
|
3010
2971
|
...mutation,
|
|
3011
2972
|
owner: mapHistoryOwner(identity, mutation.owner)
|
|
3012
|
-
} : mutation, assertCurrent),
|
|
2973
|
+
} : mutation, assertCurrent, authority),
|
|
3013
2974
|
prepareSessionGenerationReclaim: (identity) => params.bindingStore.prepareSessionGenerationReclaim(mapSessionIdentity(identity)),
|
|
3014
|
-
adoptSessionGeneration: (identity, expectedPreviousSessionId, assertCurrent) => params.bindingStore.adoptSessionGeneration(mapSessionIdentity(identity), expectedPreviousSessionId, assertCurrent),
|
|
2975
|
+
adoptSessionGeneration: (identity, expectedPreviousSessionId, assertCurrent, authority) => params.bindingStore.adoptSessionGeneration(mapSessionIdentity(identity), expectedPreviousSessionId, assertCurrent, authority),
|
|
3015
2976
|
resetSessionGeneration: (identity) => params.bindingStore.resetSessionGeneration(mapSessionIdentity(identity)),
|
|
3016
2977
|
retireSessionGeneration: (identity) => params.bindingStore.retireSessionGeneration(mapSessionIdentity(identity)),
|
|
3017
2978
|
withSessionDeletion: (identity, assertCurrent, run) => params.bindingStore.withSessionDeletion(mapSessionIdentity(identity), assertCurrent, run),
|
|
3018
2979
|
withThreadArchiveFence: (run) => params.bindingStore.withThreadArchiveFence(run),
|
|
3019
|
-
withLease: (identity, run) => params.bindingStore.withLease(mapIdentity(identity), run)
|
|
2980
|
+
withLease: (identity, run, options) => params.bindingStore.withLease(mapIdentity(identity), run, options)
|
|
3020
2981
|
};
|
|
3021
2982
|
}
|
|
3022
2983
|
//#endregion
|
|
3023
2984
|
//#region extensions/codex/src/app-server/startup-binding.ts
|
|
3024
2985
|
const CODEX_APP_SERVER_NATIVE_THREAD_FALLBACK_MAX_TOKENS = 3e5;
|
|
3025
2986
|
const CODEX_APP_SERVER_NATIVE_THREAD_DEFAULT_RESERVE_TOKENS = 2e4;
|
|
3026
|
-
const CODEX_APP_SERVER_NATIVE_THREAD_MIN_PROMPT_BUDGET_TOKENS = 8e3;
|
|
3027
|
-
const CODEX_APP_SERVER_NATIVE_THREAD_MIN_PROMPT_BUDGET_RATIO = .5;
|
|
3028
2987
|
const CODEX_APP_SERVER_ROLLOUT_TAIL_READ_BYTES = 65536;
|
|
3029
2988
|
const CODEX_APP_SERVER_BYTE_UNITS = {
|
|
3030
2989
|
b: 1,
|
|
@@ -3076,10 +3035,7 @@ async function listCodexAppServerRolloutFilesForThread(agentDir, threadId, codex
|
|
|
3076
3035
|
}];
|
|
3077
3036
|
} catch {}
|
|
3078
3037
|
const files = [];
|
|
3079
|
-
const
|
|
3080
|
-
for (const root of roots) {
|
|
3081
|
-
if (visited.has(root)) continue;
|
|
3082
|
-
visited.add(root);
|
|
3038
|
+
for (const root of new Set(roots)) {
|
|
3083
3039
|
const stack = [root];
|
|
3084
3040
|
while (stack.length > 0) {
|
|
3085
3041
|
const dir = stack.pop();
|
|
@@ -3172,32 +3128,36 @@ function readCodexAppServerRolloutTokenSnapshotLine(line) {
|
|
|
3172
3128
|
return;
|
|
3173
3129
|
}
|
|
3174
3130
|
}
|
|
3175
|
-
function readCompactionConfig(config) {
|
|
3176
|
-
return isJsonObject(config?.agents?.defaults?.compaction) ? config.agents.defaults.compaction : void 0;
|
|
3177
|
-
}
|
|
3178
3131
|
function resolveCodexAppServerNativeThreadTokenFuse(params) {
|
|
3179
3132
|
const projectedTurnTokens = typeof params.projectedTurnTokens === "number" && Number.isFinite(params.projectedTurnTokens) && params.projectedTurnTokens > 0 ? Math.floor(params.projectedTurnTokens) : 0;
|
|
3180
3133
|
const contextWindow = params.modelContextWindow ?? CODEX_APP_SERVER_NATIVE_THREAD_FALLBACK_MAX_TOKENS;
|
|
3181
|
-
const
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
}
|
|
3185
|
-
|
|
3186
|
-
const nums = values.filter((value) => typeof value === "number" && Number.isFinite(value));
|
|
3187
|
-
if (nums.length === 0) return;
|
|
3188
|
-
return Math.max(...nums);
|
|
3134
|
+
const promptBudget = resolveProjectionPromptBudgetTokens({
|
|
3135
|
+
contextTokenBudget: contextWindow,
|
|
3136
|
+
reserveTokens: params.reserveTokens
|
|
3137
|
+
});
|
|
3138
|
+
return Math.max(1, promptBudget - projectedTurnTokens);
|
|
3189
3139
|
}
|
|
3190
|
-
function
|
|
3191
|
-
|
|
3140
|
+
function maxDefinedNumber(values) {
|
|
3141
|
+
const nums = values.filter((value) => value !== void 0);
|
|
3142
|
+
return nums.length ? Math.max(...nums) : void 0;
|
|
3192
3143
|
}
|
|
3193
3144
|
/** Clears and drops a binding when the native Codex thread is too large to resume safely. */
|
|
3194
3145
|
async function rotateOversizedCodexAppServerStartupBinding(params) {
|
|
3195
3146
|
const binding = params.binding;
|
|
3196
3147
|
if (!binding?.threadId) return { binding };
|
|
3197
3148
|
if (binding.connectionScope === "supervision") return { binding };
|
|
3149
|
+
const clearBinding = async () => {
|
|
3150
|
+
if (!await params.bindingStore.mutate(params.identity, {
|
|
3151
|
+
kind: "clear",
|
|
3152
|
+
threadId: binding.threadId,
|
|
3153
|
+
clientId: binding.clientId
|
|
3154
|
+
}, params.assertCurrent, params.authority)) throw new Error("Codex startup binding changed during rotation; retry with its current owner.");
|
|
3155
|
+
return { binding: void 0 };
|
|
3156
|
+
};
|
|
3198
3157
|
const rolloutFiles = await listCodexAppServerRolloutFilesForThread(params.agentDir, binding.threadId, params.codexHome, binding.rolloutPath);
|
|
3199
|
-
const
|
|
3200
|
-
|
|
3158
|
+
const compaction = params.config?.agents?.defaults?.compaction;
|
|
3159
|
+
const maxBytes = parseCodexAppServerByteLimit(compaction?.maxActiveTranscriptBytes);
|
|
3160
|
+
if (maxBytes !== void 0 && params.contextEngineActive === true && binding.contextEngine?.projection?.mode === "thread_bootstrap") embeddedAgentLog.debug("codex app-server deferring native transcript byte guard for context-engine thread bootstrap", {
|
|
3201
3161
|
threadId: binding.threadId,
|
|
3202
3162
|
engineId: binding.contextEngine?.engineId,
|
|
3203
3163
|
epoch: binding.contextEngine?.projection?.epoch,
|
|
@@ -3218,16 +3178,12 @@ async function rotateOversizedCodexAppServerStartupBinding(params) {
|
|
|
3218
3178
|
bytes: file.bytes
|
|
3219
3179
|
}))
|
|
3220
3180
|
});
|
|
3221
|
-
await
|
|
3222
|
-
kind: "clear",
|
|
3223
|
-
threadId: binding.threadId
|
|
3224
|
-
}, params.assertCurrent);
|
|
3225
|
-
return { binding: void 0 };
|
|
3181
|
+
return await clearBinding();
|
|
3226
3182
|
}
|
|
3227
3183
|
}
|
|
3228
3184
|
const nativeTokenSnapshots = await Promise.all(rolloutFiles.map(async (file) => readCodexAppServerRolloutTokenSnapshot(file.path, file.handle)));
|
|
3229
|
-
const nativeTokens =
|
|
3230
|
-
const nativeModelContextWindow =
|
|
3185
|
+
const nativeTokens = maxDefinedNumber(nativeTokenSnapshots.map((snapshot) => snapshot?.totalTokens));
|
|
3186
|
+
const nativeModelContextWindow = maxDefinedNumber(nativeTokenSnapshots.map((snapshot) => snapshot?.modelContextWindow));
|
|
3231
3187
|
const reserveTokens = CODEX_APP_SERVER_NATIVE_THREAD_DEFAULT_RESERVE_TOKENS;
|
|
3232
3188
|
const maxTokens = resolveCodexAppServerNativeThreadTokenFuse({
|
|
3233
3189
|
modelContextWindow: nativeModelContextWindow,
|
|
@@ -3244,11 +3200,7 @@ async function rotateOversizedCodexAppServerStartupBinding(params) {
|
|
|
3244
3200
|
reserveTokens,
|
|
3245
3201
|
projectedTurnTokens: params.projectedTurnTokens
|
|
3246
3202
|
});
|
|
3247
|
-
await
|
|
3248
|
-
kind: "clear",
|
|
3249
|
-
threadId: binding.threadId
|
|
3250
|
-
}, params.assertCurrent);
|
|
3251
|
-
return { binding: void 0 };
|
|
3203
|
+
return await clearBinding();
|
|
3252
3204
|
}
|
|
3253
3205
|
return {
|
|
3254
3206
|
binding,
|
|
@@ -3300,7 +3252,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3300
3252
|
config: params.config,
|
|
3301
3253
|
agentId: policyAgentId
|
|
3302
3254
|
});
|
|
3303
|
-
const agentDir = params.agentDir ?? resolveAgentDir$
|
|
3255
|
+
const agentDir = params.agentDir ?? resolveAgentDir$2(params.config ?? {}, sessionAgentId);
|
|
3304
3256
|
const preparedEnvironment = params.hostCapabilities.preparedEnvironment?.();
|
|
3305
3257
|
const remoteExec = isCodexRemoteExecPlacementSandbox(sandbox);
|
|
3306
3258
|
const assertLocalTargetSupported = (unsupported) => {
|
|
@@ -3347,7 +3299,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3347
3299
|
let activeContextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
|
|
3348
3300
|
const isInactiveThreadBootstrapBinding = (binding) => !activeContextEngine && binding?.contextEngine?.projection?.mode === "thread_bootstrap";
|
|
3349
3301
|
if (bindingIdentity.kind === "session" && bindingIdentity.sessionKey) {
|
|
3350
|
-
const authority = resolveCodexRunSessionBindingAuthority({
|
|
3302
|
+
const authority = await resolveCodexRunSessionBindingAuthority({
|
|
3351
3303
|
identity: bindingIdentity,
|
|
3352
3304
|
config: params.config,
|
|
3353
3305
|
storePath: params.sessionTarget?.storePath
|
|
@@ -3370,7 +3322,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3370
3322
|
}
|
|
3371
3323
|
let modelExecution;
|
|
3372
3324
|
const assertModelExecutionCurrent = () => modelExecution?.assertCurrent();
|
|
3373
|
-
const { binding: admittedBinding,
|
|
3325
|
+
const { binding: admittedBinding, authority: bindingAuthority } = await resolveCodexSessionBinding({
|
|
3374
3326
|
reclaimStale: true,
|
|
3375
3327
|
bindingStore,
|
|
3376
3328
|
identity: bindingIdentity,
|
|
@@ -3381,9 +3333,10 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3381
3333
|
assertBinding: params.expectedSessionRuntimeOwnership ? (binding) => assertCodexSessionRuntimeOwnership(binding, params.expectedSessionRuntimeOwnership) : void 0
|
|
3382
3334
|
});
|
|
3383
3335
|
const assertCurrent = () => {
|
|
3384
|
-
|
|
3336
|
+
bindingAuthority.assertCurrent();
|
|
3385
3337
|
assertModelExecutionCurrent();
|
|
3386
3338
|
};
|
|
3339
|
+
const authority = createNativeSessionBindingAuthority(bindingAuthority.lineage, assertCurrent);
|
|
3387
3340
|
let startupBinding = admittedBinding;
|
|
3388
3341
|
preDynamicStartupStages.mark("read-binding");
|
|
3389
3342
|
const usesSupervisionConnection = startupBinding?.connectionScope === "supervision";
|
|
@@ -3541,6 +3494,7 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3541
3494
|
const startupBindingBeforeRotation = startupBinding;
|
|
3542
3495
|
const startupBindingResolution = await rotateOversizedCodexAppServerStartupBinding({
|
|
3543
3496
|
assertCurrent,
|
|
3497
|
+
authority,
|
|
3544
3498
|
binding: startupBinding,
|
|
3545
3499
|
bindingStore,
|
|
3546
3500
|
identity: bindingIdentity,
|
|
@@ -3617,6 +3571,9 @@ async function prepareCodexAttemptConnection({ params, options }) {
|
|
|
3617
3571
|
return note;
|
|
3618
3572
|
},
|
|
3619
3573
|
assertCurrent,
|
|
3574
|
+
authority,
|
|
3575
|
+
withCurrent: authority.withCurrent,
|
|
3576
|
+
assertLegacyCurrent: authority.assertLegacyCurrent,
|
|
3620
3577
|
assertModelExecutionCurrent,
|
|
3621
3578
|
bindModelExecution,
|
|
3622
3579
|
releaseModelExecution,
|
|
@@ -3747,7 +3704,8 @@ function buildCodexSystemPromptReport(params) {
|
|
|
3747
3704
|
bootstrapFiles: params.workspaceBootstrapContext.bootstrapFiles,
|
|
3748
3705
|
injectedFiles: params.workspaceBootstrapContext.promptContextFiles ?? [],
|
|
3749
3706
|
omitReferenceFiles: params.omitWorkspaceReferences,
|
|
3750
|
-
|
|
3707
|
+
omitPersonalProfiles: !params.parentLocalEgress,
|
|
3708
|
+
developerInstructionFiles: [...params.workspaceBootstrapContext.threadDeveloperInstructionFiles ?? [], ...params.workspaceBootstrapContext.personaFiles ?? []],
|
|
3751
3709
|
memoryToolRoutedBootstrapFiles: params.workspaceBootstrapContext.memoryToolRoutedBootstrapFiles ?? [],
|
|
3752
3710
|
memoryToolRouted: params.workspaceBootstrapContext.memoryToolRouted === true
|
|
3753
3711
|
}),
|
|
@@ -3825,7 +3783,7 @@ function buildCodexBootstrapInjectionStats(params) {
|
|
|
3825
3783
|
injectedChars: null,
|
|
3826
3784
|
truncated: null
|
|
3827
3785
|
};
|
|
3828
|
-
const omitted = memoryToolRoutedFile || params.omitReferenceFiles && readCodexIndexedContextFileContent(injectedIndex, pathValue, fileName) !== void 0;
|
|
3786
|
+
const omitted = params.omitPersonalProfiles && file.personalUser === true || memoryToolRoutedFile || params.omitReferenceFiles && readCodexIndexedContextFileContent(injectedIndex, pathValue, fileName) !== void 0;
|
|
3829
3787
|
const injectedChars = omitted ? 0 : injected?.length ?? 0;
|
|
3830
3788
|
const truncated = omitted ? false : !file.missing && injectedChars < rawChars;
|
|
3831
3789
|
return {
|
|
@@ -3881,22 +3839,29 @@ function buildCodexOpenClawPromptContext(params) {
|
|
|
3881
3839
|
* Sessions section must be re-surfaced here or Codex-backed main sessions
|
|
3882
3840
|
* keep refusing cross-session questions (openclaw#114797).
|
|
3883
3841
|
*/
|
|
3884
|
-
function
|
|
3842
|
+
async function prepareCodexWatchedSessionsContext(params) {
|
|
3885
3843
|
if (!shouldIncludeAgentHarnessRuntimeContext(params.attempt)) return;
|
|
3886
|
-
return
|
|
3844
|
+
return prepareWatchedSessionsHarnessContext({
|
|
3887
3845
|
config: params.attempt.config,
|
|
3888
3846
|
sessionKey: params.sessionKey,
|
|
3889
3847
|
sandboxed: params.sandboxed,
|
|
3890
|
-
|
|
3848
|
+
assertCurrent: params.assertCurrent,
|
|
3849
|
+
toolNames: flattenCodexDynamicToolFunctions(params.dynamicTools).map((tool) => normalizeLowercaseStringOrEmpty(tool.name))
|
|
3891
3850
|
});
|
|
3892
3851
|
}
|
|
3893
3852
|
function renderCodexSkillsInstructions(params) {
|
|
3894
3853
|
if (!shouldIncludeAgentHarnessRuntimeContext(params.attempt)) return;
|
|
3895
|
-
|
|
3854
|
+
const names = new Set(flattenCodexDynamicToolFunctions(params.dynamicTools ?? []).map((tool) => normalizeLowercaseStringOrEmpty(tool.name)));
|
|
3855
|
+
const prompt = params.skillsPrompt?.trim();
|
|
3856
|
+
const search = names.has("skills_search");
|
|
3857
|
+
const read = names.has("skills_read");
|
|
3858
|
+
if (!prompt && !search) return;
|
|
3859
|
+
return [
|
|
3896
3860
|
"## OpenClaw Skills",
|
|
3897
|
-
"",
|
|
3898
|
-
|
|
3899
|
-
|
|
3861
|
+
...search ? ["The directory is bounded. Use OpenClaw's skills_search tool to find relevant installed skills omitted from it. Search does not install skills."] : [],
|
|
3862
|
+
...read ? ["Use OpenClaw's skills_read tool with an exact name for complete instructions; a known name does not require search first."] : [],
|
|
3863
|
+
...prompt ? [prompt] : []
|
|
3864
|
+
].join("\n");
|
|
3900
3865
|
}
|
|
3901
3866
|
/**
|
|
3902
3867
|
* Prepends OpenClaw context while preserving leading delivery metadata as
|
|
@@ -3967,8 +3932,10 @@ async function prepareCodexAttemptContext(runtime, attemptTools) {
|
|
|
3967
3932
|
...transcriptReadFence ? { admission: transcriptReadFence } : {}
|
|
3968
3933
|
});
|
|
3969
3934
|
connection.runAbortController.signal.throwIfAborted();
|
|
3970
|
-
connection.
|
|
3971
|
-
|
|
3935
|
+
return await connection.withCurrent(() => {
|
|
3936
|
+
connection.assertCurrent();
|
|
3937
|
+
return messages;
|
|
3938
|
+
});
|
|
3972
3939
|
};
|
|
3973
3940
|
const historyState = { messages: !activeContextEngine && initialStartupBindingHadInactiveThreadBootstrap ? [] : await readFencedHistory() ?? [] };
|
|
3974
3941
|
const hadSessionTranscriptState = historyState.messages.length > 0;
|
|
@@ -3999,6 +3966,8 @@ async function prepareCodexAttemptContext(runtime, attemptTools) {
|
|
|
3999
3966
|
agentAccountId: params.agentAccountId
|
|
4000
3967
|
}),
|
|
4001
3968
|
channelContext: params.channelContext,
|
|
3969
|
+
...params.memoryAudience ? { memoryAudience: params.memoryAudience } : {},
|
|
3970
|
+
sandboxed: sandbox?.enabled === true,
|
|
4002
3971
|
...hookContextWindowFields
|
|
4003
3972
|
};
|
|
4004
3973
|
const hookRunner = getAgentHarnessHookRunner();
|
|
@@ -4049,14 +4018,20 @@ async function prepareCodexAttemptContext(runtime, attemptTools) {
|
|
|
4049
4018
|
const agentWorkspaceDeveloperInstructions = workspaceBootstrapContext.threadDeveloperInstructions;
|
|
4050
4019
|
const skillsInstructions = renderCodexSkillsInstructions({
|
|
4051
4020
|
attempt: runtimeParams,
|
|
4052
|
-
skillsPrompt: params.skillsSnapshot?.prompt
|
|
4021
|
+
skillsPrompt: params.skillsSnapshot?.prompt,
|
|
4022
|
+
dynamicTools: toolBridge.availableSpecs
|
|
4053
4023
|
});
|
|
4024
|
+
const refreshableInstructions = joinPresentSections(skillsInstructions, workspaceBootstrapContext.sharedPersonaInstructions, workspaceBootstrapContext.memoryInstructions) || void 0;
|
|
4054
4025
|
const baseDeveloperInstructions = joinPresentSections(buildDeveloperInstructions(runtimeParams, { dynamicTools: toolBridge.availableSpecs }), agentWorkspaceDeveloperInstructions);
|
|
4055
|
-
const watchedSessionsContext =
|
|
4026
|
+
const watchedSessionsContext = await prepareCodexWatchedSessionsContext({
|
|
4056
4027
|
attempt: runtimeParams,
|
|
4057
4028
|
dynamicTools: toolBridge.availableSpecs,
|
|
4058
4029
|
sessionKey: contextSessionKey,
|
|
4059
|
-
sandboxed: sandbox?.enabled === true
|
|
4030
|
+
sandboxed: sandbox?.enabled === true,
|
|
4031
|
+
assertCurrent: () => {
|
|
4032
|
+
connection.runAbortController.signal.throwIfAborted();
|
|
4033
|
+
connection.assertCurrent();
|
|
4034
|
+
}
|
|
4060
4035
|
});
|
|
4061
4036
|
const buildOpenClawPromptContext = (includeWorkspaceReferences) => buildCodexOpenClawPromptContext({
|
|
4062
4037
|
params: runtimeParams,
|
|
@@ -4077,6 +4052,7 @@ async function prepareCodexAttemptContext(runtime, attemptTools) {
|
|
|
4077
4052
|
baseDeveloperInstructions,
|
|
4078
4053
|
buildOpenClawPromptContext,
|
|
4079
4054
|
skillsInstructions,
|
|
4055
|
+
refreshableInstructions,
|
|
4080
4056
|
promptState: {
|
|
4081
4057
|
promptText: params.prompt,
|
|
4082
4058
|
promptContextRange: void 0,
|
|
@@ -4281,6 +4257,7 @@ async function beginCodexAttemptSettlement(resources, turnRuntime, notifications
|
|
|
4281
4257
|
if (settlementPhase !== "active" || drainGraceTimer) return;
|
|
4282
4258
|
drainGraceTimer = setTimeout(() => {
|
|
4283
4259
|
settlementPhase = "expired";
|
|
4260
|
+
resourceState.nativeSettlementExpired = true;
|
|
4284
4261
|
drainGraceElapsed.resolve();
|
|
4285
4262
|
}, TURN_FINALIZE_DRAIN_ABORT_GRACE_MS);
|
|
4286
4263
|
drainGraceTimer.unref?.();
|
|
@@ -4346,25 +4323,26 @@ async function beginCodexAttemptSettlement(resources, turnRuntime, notifications
|
|
|
4346
4323
|
}
|
|
4347
4324
|
//#endregion
|
|
4348
4325
|
//#region extensions/codex/src/app-server/run-attempt-state.ts
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
embeddedAgentLog.warn("codex app-server image payload error detected for unbound thread; preserving thread binding", {
|
|
4355
|
-
...fields,
|
|
4356
|
-
boundThreadId: currentBinding.threadId
|
|
4326
|
+
function canClearCodexBindingForRecovery(thread, expectedSessionRuntimeOwnership, operation) {
|
|
4327
|
+
if (expectedSessionRuntimeOwnership) {
|
|
4328
|
+
embeddedAgentLog.warn("codex app-server preserved native binding instead of recovery rotation", {
|
|
4329
|
+
threadId: thread.threadId,
|
|
4330
|
+
operation
|
|
4357
4331
|
});
|
|
4358
|
-
return;
|
|
4332
|
+
return false;
|
|
4359
4333
|
}
|
|
4360
|
-
|
|
4334
|
+
assertCodexBindingMayBeReplaced(thread, operation);
|
|
4335
|
+
return true;
|
|
4336
|
+
}
|
|
4337
|
+
async function clearCodexBindingAfterInvalidImagePayload(bindingStore, identity, fields, authority, expected) {
|
|
4338
|
+
if (expected) {
|
|
4361
4339
|
embeddedAgentLog.warn("codex app-server image payload error detected for native-owned thread; preserving binding", fields);
|
|
4362
4340
|
return;
|
|
4363
4341
|
}
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4342
|
+
const cleared = await clearCodexBindingForClient(bindingStore, identity, fields, authority);
|
|
4343
|
+
embeddedAgentLog.warn("codex app-server image payload recovery completed", {
|
|
4344
|
+
...fields,
|
|
4345
|
+
bindingCleared: cleared
|
|
4368
4346
|
});
|
|
4369
4347
|
}
|
|
4370
4348
|
function shouldUseFreshCodexThreadAfterContextEngineOverflow(params) {
|
|
@@ -4383,9 +4361,8 @@ function prependCurrentInboundContext(prompt, context) {
|
|
|
4383
4361
|
}
|
|
4384
4362
|
//#endregion
|
|
4385
4363
|
//#region extensions/codex/src/app-server/trajectory.ts
|
|
4386
|
-
function createCodexTrajectoryRecorder(
|
|
4387
|
-
if (!
|
|
4388
|
-
const trajectory = params.trajectory;
|
|
4364
|
+
function createCodexTrajectoryRecorder(trajectory) {
|
|
4365
|
+
if (!trajectory) return null;
|
|
4389
4366
|
return {
|
|
4390
4367
|
recordEvent: (type, data) => {
|
|
4391
4368
|
try {
|
|
@@ -4453,17 +4430,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4453
4430
|
const { effectiveRuntimeProviderId, effectiveRuntimeModelId } = runtime;
|
|
4454
4431
|
const { params, terminalState, runAbortController, activeContextEngine, bindingStore, bindingIdentity, appServer, usesSupervisionConnection, sessionAgentId, contextSessionKey, effectiveCwd, agentDir, attemptStartedAt, startupAuthProfileId } = connection;
|
|
4455
4432
|
const { toolBridge, toolState } = attemptTools;
|
|
4456
|
-
const canClearBindingForRecovery = (operation) =>
|
|
4457
|
-
if (params.expectedSessionRuntimeOwnership) {
|
|
4458
|
-
embeddedAgentLog.warn("codex app-server preserved native binding instead of recovery rotation", {
|
|
4459
|
-
threadId: resourceState.thread.threadId,
|
|
4460
|
-
operation
|
|
4461
|
-
});
|
|
4462
|
-
return false;
|
|
4463
|
-
}
|
|
4464
|
-
assertCodexBindingMayBeReplaced(resourceState.thread, operation);
|
|
4465
|
-
return true;
|
|
4466
|
-
};
|
|
4433
|
+
const canClearBindingForRecovery = (operation) => canClearCodexBindingForRecovery(resourceState.thread, Boolean(params.expectedSessionRuntimeOwnership), operation);
|
|
4467
4434
|
const { state, completion } = turnRuntime;
|
|
4468
4435
|
const { emitLifecycleTerminal, buildLifecycleTerminalMeta } = lifecycle;
|
|
4469
4436
|
const { codexModelCallDiagnostics, buildLlmOutputEvent } = requestRuntime;
|
|
@@ -4495,9 +4462,10 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4495
4462
|
if (isInvalidCodexImagePayloadError(enrichedPromptErrorMessage)) await clearCodexBindingAfterInvalidImagePayload(bindingStore, bindingIdentity, {
|
|
4496
4463
|
phase: "turn_completed",
|
|
4497
4464
|
threadId: resourceState.thread.threadId,
|
|
4465
|
+
clientId: resourceState.thread.clientId,
|
|
4498
4466
|
turnId: activeTurnId,
|
|
4499
4467
|
error: enrichedPromptErrorMessage
|
|
4500
|
-
}, params.expectedSessionRuntimeOwnership);
|
|
4468
|
+
}, connection.authority, params.expectedSessionRuntimeOwnership);
|
|
4501
4469
|
if (resourceState.thread.connectionScope !== "supervision" && shouldUseFreshCodexThreadAfterContextEngineOverflow({
|
|
4502
4470
|
error: enrichedPromptError,
|
|
4503
4471
|
contextEngineActive: Boolean(activeContextEngine),
|
|
@@ -4508,10 +4476,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4508
4476
|
turnId: activeTurnId,
|
|
4509
4477
|
error: enrichedPromptErrorMessage
|
|
4510
4478
|
});
|
|
4511
|
-
await bindingStore
|
|
4512
|
-
kind: "clear",
|
|
4513
|
-
threadId: resourceState.thread.threadId
|
|
4514
|
-
});
|
|
4479
|
+
await clearCodexBindingForClient(bindingStore, bindingIdentity, resourceState.thread, connection.authority);
|
|
4515
4480
|
}
|
|
4516
4481
|
const refreshedUsageLimitPromptError = await refreshCodexUsageLimitPromptError({
|
|
4517
4482
|
client: resourceState.client,
|
|
@@ -4639,7 +4604,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4639
4604
|
config: params.config,
|
|
4640
4605
|
message: toolState.yieldMessage,
|
|
4641
4606
|
assertCurrent: () => {
|
|
4642
|
-
connection.
|
|
4607
|
+
connection.assertLegacyCurrent();
|
|
4643
4608
|
if (!isSettlementActive() || !projectTerminalOutcome().turnSucceeded) throw new Error("Codex yield settlement is no longer active");
|
|
4644
4609
|
}
|
|
4645
4610
|
}),
|
|
@@ -4672,7 +4637,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4672
4637
|
else if (finalPromptError) codexModelCallDiagnostics.emitError(finalPromptError);
|
|
4673
4638
|
else codexModelCallDiagnostics.emitCompleted(result);
|
|
4674
4639
|
const { assistantTranscriptOwned, assistantTranscriptIdempotencyKey, terminalAnchor } = mirrorOutcome;
|
|
4675
|
-
const settledTurnFinalizationContext = result.assistantTexts.every((text) => !text.trim()) && result.messagesSnapshot.some((message) => message.role === "toolResult") && (!finalPromptError || activeProjector.settledTurnFailureFinalizationAllowed) ? (!usesSupervisionConnection ? await captureCodexSettledTurnFinalizationContext({
|
|
4640
|
+
const settledTurnFinalizationContext = result.assistantTexts.every((text) => !text.trim()) && result.messagesSnapshot.some((message) => message.role === "toolResult") && (!finalPromptError || activeProjector.settledTurnFailureFinalizationAllowed) ? (!usesSupervisionConnection && !resourceState.nativeSettlementExpired ? await captureCodexSettledTurnFinalizationContext({
|
|
4676
4641
|
...activeTranscriptTarget,
|
|
4677
4642
|
model: resourceState.thread.model,
|
|
4678
4643
|
modelProvider: resourceState.thread.modelProvider,
|
|
@@ -4681,7 +4646,8 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4681
4646
|
settledMessages: result.messagesSnapshot,
|
|
4682
4647
|
turnId: activeTurnId,
|
|
4683
4648
|
signal: params.abortSignal,
|
|
4684
|
-
assertActive: connection.assertCurrent
|
|
4649
|
+
assertActive: connection.assertCurrent,
|
|
4650
|
+
withCurrent: connection.withCurrent
|
|
4685
4651
|
}) : void 0) ?? Object.freeze({ source: "unavailable" }) : void 0;
|
|
4686
4652
|
if (settledTurnFinalizationContext?.source === "unavailable") embeddedAgentLog.warn("codex settled-turn finalization context is unavailable", {
|
|
4687
4653
|
runId: params.runId,
|
|
@@ -4725,7 +4691,7 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4725
4691
|
hookRunner
|
|
4726
4692
|
});
|
|
4727
4693
|
state.shouldDelayNativeHookRelayUnregister = completedTurnStatus === "completed" && !effectiveTimedOut && !runAbortController.signal.aborted && !finalAborted && !finalPromptError;
|
|
4728
|
-
if (turnSucceeded && !runAbortController.signal.aborted && !state.pluginRuntimeRefreshStop) try {
|
|
4694
|
+
if (turnSucceeded && !runAbortController.signal.aborted && !state.pluginRuntimeRefreshStop && !resourceState.nativeSettlementExpired) try {
|
|
4729
4695
|
const continuityCalibration = context.promptState.noEngineContinuityProjectionApplied ? buildCodexContinuityCalibration({
|
|
4730
4696
|
promptChars: prompt.turnState.codexTurnPromptText.length,
|
|
4731
4697
|
inputTokens: result.attemptUsage?.contextUsage?.state === "available" ? result.attemptUsage.contextUsage.promptTokens ?? 0 : 0
|
|
@@ -4733,18 +4699,16 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4733
4699
|
await bindingStore.mutate(bindingIdentity, {
|
|
4734
4700
|
kind: "patch",
|
|
4735
4701
|
threadId: resourceState.thread.threadId,
|
|
4702
|
+
clientId: resourceState.thread.clientId,
|
|
4736
4703
|
patch: {
|
|
4737
4704
|
historyCoveredThrough: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4738
4705
|
...continuityCalibration ? { continuityCalibration } : {}
|
|
4739
4706
|
}
|
|
4740
|
-
}, connection.assertCurrent);
|
|
4707
|
+
}, connection.assertCurrent, connection.authority);
|
|
4741
4708
|
} catch (error) {
|
|
4742
4709
|
if (resourceState.thread.connectionScope === "supervision") throw error;
|
|
4743
4710
|
if (canClearBindingForRecovery("clearing native coverage after a completed turn")) {
|
|
4744
|
-
if (!await bindingStore
|
|
4745
|
-
kind: "clear",
|
|
4746
|
-
threadId: resourceState.thread.threadId
|
|
4747
|
-
}, connection.assertCurrent)) throw error;
|
|
4711
|
+
if (!await clearCodexBindingForClient(bindingStore, bindingIdentity, resourceState.thread, connection.authority)) throw error;
|
|
4748
4712
|
embeddedAgentLog.warn("codex app-server binding coverage update failed after completed turn; cleared stale binding", {
|
|
4749
4713
|
threadId: resourceState.thread.threadId,
|
|
4750
4714
|
turnId: activeTurnId,
|
|
@@ -4753,7 +4717,6 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4753
4717
|
}
|
|
4754
4718
|
}
|
|
4755
4719
|
recordCodexTrajectoryCompletion(trajectoryRecorder, {
|
|
4756
|
-
attempt: params,
|
|
4757
4720
|
result,
|
|
4758
4721
|
threadId: resourceState.thread.threadId,
|
|
4759
4722
|
turnId: activeTurnId,
|
|
@@ -4813,29 +4776,6 @@ async function finalizeCodexAttempt(resources, turnRuntime, lifecycle, notificat
|
|
|
4813
4776
|
}
|
|
4814
4777
|
}
|
|
4815
4778
|
//#endregion
|
|
4816
|
-
//#region extensions/codex/src/app-server/attempt-notification-state.ts
|
|
4817
|
-
/** Emits coarse execution phases exactly once from app-server notifications. */
|
|
4818
|
-
function reportCodexExecutionNotification(params) {
|
|
4819
|
-
const { notification } = params;
|
|
4820
|
-
if (notification.method === "turn/started") {
|
|
4821
|
-
params.emitExecutionPhaseOnce("turn_accepted", { phase: "turn_accepted" });
|
|
4822
|
-
return;
|
|
4823
|
-
}
|
|
4824
|
-
if (notification.method === "item/agentMessage/delta") {
|
|
4825
|
-
params.emitExecutionPhaseOnce("assistant_output_started", { phase: "assistant_output_started" });
|
|
4826
|
-
return;
|
|
4827
|
-
}
|
|
4828
|
-
if (notification.method !== "item/started") return;
|
|
4829
|
-
const item = readCodexNotificationItem(notification.params);
|
|
4830
|
-
const tool = item ? itemName(item) : void 0;
|
|
4831
|
-
if (!item || !tool) return;
|
|
4832
|
-
params.emitExecutionPhaseOnce(`tool:${item.id}`, {
|
|
4833
|
-
phase: "tool_execution_started",
|
|
4834
|
-
tool,
|
|
4835
|
-
itemId: item.id
|
|
4836
|
-
});
|
|
4837
|
-
}
|
|
4838
|
-
//#endregion
|
|
4839
4779
|
//#region extensions/codex/src/app-server/run-attempt-lifecycle-terminal.ts
|
|
4840
4780
|
function buildCodexLifecycleTerminalMeta(input) {
|
|
4841
4781
|
if (input.timedOut || input.abortStopReason === "timeout") return {
|
|
@@ -4932,9 +4872,21 @@ function createCodexAttemptLifecycleController(resources, turnRuntime) {
|
|
|
4932
4872
|
});
|
|
4933
4873
|
};
|
|
4934
4874
|
const reportExecutionNotification = (notification) => {
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4875
|
+
if (notification.method === "turn/started") {
|
|
4876
|
+
emitExecutionPhaseOnce("turn_accepted", { phase: "turn_accepted" });
|
|
4877
|
+
return;
|
|
4878
|
+
}
|
|
4879
|
+
if (notification.method === "item/agentMessage/delta") {
|
|
4880
|
+
emitExecutionPhaseOnce("assistant_output_started", { phase: "assistant_output_started" });
|
|
4881
|
+
return;
|
|
4882
|
+
}
|
|
4883
|
+
if (notification.method !== "item/started") return;
|
|
4884
|
+
const item = readCodexNotificationItem(notification.params);
|
|
4885
|
+
const tool = item ? itemName(item) : void 0;
|
|
4886
|
+
if (item && tool) emitExecutionPhaseOnce(`tool:${item.id}`, {
|
|
4887
|
+
phase: "tool_execution_started",
|
|
4888
|
+
tool,
|
|
4889
|
+
itemId: item.id
|
|
4938
4890
|
});
|
|
4939
4891
|
};
|
|
4940
4892
|
const emitFastModeAutoProgress = async (payload) => {
|
|
@@ -5139,7 +5091,7 @@ function createCodexAttemptNotificationController(resources, turnRuntime, lifecy
|
|
|
5139
5091
|
//#endregion
|
|
5140
5092
|
//#region extensions/codex/src/app-server/run-attempt-prompt.ts
|
|
5141
5093
|
async function prepareCodexAttemptPrompt(context) {
|
|
5142
|
-
const { runtime, attemptTools, historyState, hookContext, workspaceBootstrapContext, buildActiveContextEngineRuntimeContext, baseDeveloperInstructions, buildOpenClawPromptContext, skillsInstructions, promptState, codexContextProjectionMaxChars, codexContinuityProjectionMaxChars } = context;
|
|
5094
|
+
const { runtime, attemptTools, historyState, hookContext, workspaceBootstrapContext, buildActiveContextEngineRuntimeContext, baseDeveloperInstructions, buildOpenClawPromptContext, skillsInstructions, refreshableInstructions, promptState, codexContextProjectionMaxChars, codexContinuityProjectionMaxChars } = context;
|
|
5143
5095
|
const { connection, runtimeParams, effectiveContextTokenBudget, effectiveRuntimeModelId, effectiveRuntimeProviderId } = runtime;
|
|
5144
5096
|
const { params, activeContextEngine, usesSupervisionConnection, mutable, isInactiveThreadBootstrapBinding, bindingStore, bindingIdentity, agentDir, appServer, contextSessionKey, effectiveWorkspace, sandbox } = connection;
|
|
5145
5097
|
const { toolBridge } = attemptTools;
|
|
@@ -5287,46 +5239,43 @@ async function prepareCodexAttemptPrompt(context) {
|
|
|
5287
5239
|
toolAuthority: {
|
|
5288
5240
|
fingerprint: params.toolAuthorityFingerprint,
|
|
5289
5241
|
activeToolNames: () => flattenCodexDynamicToolFunctions(toolBridge.availableSpecs).map((tool) => tool.name).filter(isNonEmptyString),
|
|
5290
|
-
assertActive: connection.
|
|
5242
|
+
assertActive: connection.assertLegacyCurrent
|
|
5291
5243
|
}
|
|
5292
5244
|
});
|
|
5293
|
-
const
|
|
5294
|
-
if (!promptInputRange || promptInputRange.start < 0 || promptInputRange.end < promptInputRange.start || promptInputRange.end > prompt.length || !turnPromptText.endsWith(prompt)) return;
|
|
5245
|
+
const resolveShiftedPromptRanges = (prompt, promptInputRange, turnPromptText) => {
|
|
5246
|
+
if (!promptInputRange || promptInputRange.start < 0 || promptInputRange.end < promptInputRange.start || promptInputRange.end > prompt.length || !turnPromptText.endsWith(prompt)) return {};
|
|
5295
5247
|
const turnPromptOffset = turnPromptText.length - prompt.length;
|
|
5296
|
-
|
|
5248
|
+
const inputRange = {
|
|
5297
5249
|
start: turnPromptOffset + promptInputRange.start,
|
|
5298
5250
|
end: turnPromptOffset + promptInputRange.end
|
|
5299
5251
|
};
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
const
|
|
5303
|
-
if (!promptState.promptContextRange || !promptInputRange || promptTextInputOffset === void 0 || promptInputRange.start < 0 || promptInputRange.end < promptInputRange.start || promptInputRange.end > prompt.length || promptTextInputOffset < promptInputRange.start || prompt.slice(promptTextInputOffset, promptInputRange.end) !== promptState.promptText || !turnPromptText.endsWith(prompt)) return;
|
|
5304
|
-
const promptTextOffset = prompt.endsWith(promptState.promptText) ? prompt.length - promptState.promptText.length : promptTextInputOffset;
|
|
5305
|
-
if (promptTextOffset < 0) return;
|
|
5306
|
-
const turnPromptOffset = turnPromptText.length - prompt.length + promptTextOffset;
|
|
5252
|
+
const promptTextInputOffset = promptInputRange.end - promptState.promptText.length;
|
|
5253
|
+
if (!promptState.promptContextRange || promptTextInputOffset < promptInputRange.start || prompt.slice(promptTextInputOffset, promptInputRange.end) !== promptState.promptText) return { inputRange };
|
|
5254
|
+
const contextOffset = turnPromptOffset + (prompt.endsWith(promptState.promptText) ? prompt.length - promptState.promptText.length : promptTextInputOffset);
|
|
5307
5255
|
const contextRange = {
|
|
5308
|
-
start:
|
|
5309
|
-
end:
|
|
5256
|
+
start: contextOffset + promptState.promptContextRange.start,
|
|
5257
|
+
end: contextOffset + promptState.promptContextRange.end
|
|
5310
5258
|
};
|
|
5311
5259
|
return {
|
|
5260
|
+
inputRange,
|
|
5312
5261
|
contextRange,
|
|
5313
5262
|
requestRange: {
|
|
5314
5263
|
start: contextRange.end,
|
|
5315
|
-
end:
|
|
5264
|
+
end: contextOffset + promptState.promptText.length
|
|
5316
5265
|
}
|
|
5317
5266
|
};
|
|
5318
5267
|
};
|
|
5319
5268
|
const decorateCodexTurnPromptText = (promptBuildResult, includeWorkspaceReferences = true) => {
|
|
5320
5269
|
const turnPromptText = prependCodexOpenClawPromptContext(promptBuildResult.prompt, buildOpenClawPromptContext(includeWorkspaceReferences), { preservePromptWithoutContext: params.bootstrapContextMode === "lightweight" && params.bootstrapContextRunKind === "cron" });
|
|
5321
|
-
const projectedRanges =
|
|
5322
|
-
const preservedRange =
|
|
5270
|
+
const projectedRanges = resolveShiftedPromptRanges(promptBuildResult.prompt, promptBuildResult.promptInputRange, turnPromptText);
|
|
5271
|
+
const preservedRange = projectedRanges.inputRange ?? resolveCodexDeliveryHintPreservedInputRange({
|
|
5323
5272
|
prompt: promptBuildResult.prompt,
|
|
5324
5273
|
promptInputRange: promptBuildResult.promptInputRange,
|
|
5325
5274
|
decoratedPrompt: turnPromptText
|
|
5326
5275
|
});
|
|
5327
|
-
const imageOffset = projectedRanges && promptState.promptContextRange ? projectedRanges.contextRange.start - promptState.promptContextRange.start : void 0;
|
|
5276
|
+
const imageOffset = projectedRanges.contextRange && promptState.promptContextRange ? projectedRanges.contextRange.start - promptState.promptContextRange.start : void 0;
|
|
5328
5277
|
const inputLimit = CODEX_TURN_START_TEXT_INPUT_MAX_CHARS - (nativeHistoryProvenancePrefix?.length ?? 0);
|
|
5329
|
-
const requiredInputChars = turnPromptText.length - (projectedRanges ? projectedRanges.contextRange.end - projectedRanges.contextRange.start : 0);
|
|
5278
|
+
const requiredInputChars = turnPromptText.length - (projectedRanges.contextRange ? projectedRanges.contextRange.end - projectedRanges.contextRange.start : 0);
|
|
5330
5279
|
const attachmentNote = inputAttachmentNote && requiredInputChars + inputAttachmentNote.length + 2 <= inputLimit ? inputAttachmentNote : void 0;
|
|
5331
5280
|
const fitted = fitCodexProjectedContextForTurnStart({
|
|
5332
5281
|
promptText: turnPromptText,
|
|
@@ -5350,13 +5299,13 @@ async function prepareCodexAttemptPrompt(context) {
|
|
|
5350
5299
|
};
|
|
5351
5300
|
let parentLocalEgress = false;
|
|
5352
5301
|
const parentLocalContext = {
|
|
5353
|
-
|
|
5354
|
-
|
|
5302
|
+
personaInstructions: workspaceBootstrapContext.personaInstructions,
|
|
5303
|
+
memoryInstructions: workspaceBootstrapContext.memoryInstructions
|
|
5355
5304
|
};
|
|
5356
|
-
const buildRenderedCodexDeveloperInstructions = () => joinPresentSections(turnState.promptBuild.developerInstructions, parentLocalEgress ? void 0 :
|
|
5305
|
+
const buildRenderedCodexDeveloperInstructions = () => joinPresentSections(turnState.promptBuild.developerInstructions, parentLocalEgress ? void 0 : refreshableInstructions, (parentLocalEgress ? buildCodexParentLocalInstructions(params, {
|
|
5357
5306
|
...parentLocalContext,
|
|
5358
5307
|
skillsInstructions
|
|
5359
|
-
}) : buildTurnCollaborationMode(params
|
|
5308
|
+
}) : buildTurnCollaborationMode(params).settings.developer_instructions) ?? void 0);
|
|
5360
5309
|
const rebuildCodexPromptBuildFromCurrentProjection = async () => {
|
|
5361
5310
|
turnState.promptBuild = await buildPromptFromCurrentInputs();
|
|
5362
5311
|
turnState.codexTurnPromptText = decorateCodexTurnPromptText(turnState.promptBuild);
|
|
@@ -5419,6 +5368,7 @@ async function prepareCodexAttemptPrompt(context) {
|
|
|
5419
5368
|
const hadInactiveThreadBootstrapBinding = isInactiveThreadBootstrapBinding(binding);
|
|
5420
5369
|
const startupBindingResolution = await rotateOversizedCodexAppServerStartupBinding({
|
|
5421
5370
|
assertCurrent: connection.assertCurrent,
|
|
5371
|
+
authority: connection.authority,
|
|
5422
5372
|
binding,
|
|
5423
5373
|
bindingStore,
|
|
5424
5374
|
identity: bindingIdentity,
|
|
@@ -5459,6 +5409,7 @@ async function prepareCodexAttemptPrompt(context) {
|
|
|
5459
5409
|
developerInstructions: buildRenderedCodexDeveloperInstructions(),
|
|
5460
5410
|
workspaceBootstrapContext,
|
|
5461
5411
|
omitWorkspaceReferences,
|
|
5412
|
+
parentLocalEgress,
|
|
5462
5413
|
skillsPrompt: skillsInstructions ? params.skillsSnapshot?.prompt ?? "" : "",
|
|
5463
5414
|
tools: toolBridge.availableSpecs
|
|
5464
5415
|
});
|
|
@@ -5538,11 +5489,10 @@ function createNativeSubagentAssignmentStore(params) {
|
|
|
5538
5489
|
//#endregion
|
|
5539
5490
|
//#region extensions/codex/src/app-server/run-attempt-resources.ts
|
|
5540
5491
|
function prepareCodexAttemptResources(prompt) {
|
|
5541
|
-
const { context
|
|
5492
|
+
const { context } = prompt;
|
|
5542
5493
|
const { runtime, attemptTools } = context;
|
|
5543
5494
|
const { connection, hookChannelId } = runtime;
|
|
5544
5495
|
const { appServer, params, effectiveCwd, sessionAgentId, contextSessionKey, runAbortController, sandbox, options, nativeHookRelayEvents } = connection;
|
|
5545
|
-
const { toolBridge } = attemptTools;
|
|
5546
5496
|
const modelAdmissionSource = runtime.nativeToolSurfaceEnabled ? params.hostCapabilities.retainSourceAuthority?.() : void 0;
|
|
5547
5497
|
let nativeModelAdmission;
|
|
5548
5498
|
try {
|
|
@@ -5551,20 +5501,18 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5551
5501
|
modelAdmissionSource?.release();
|
|
5552
5502
|
}
|
|
5553
5503
|
let nativeProcessAuthorityReleased = false;
|
|
5504
|
+
const cleanupAuthority = createNativeSessionBindingAuthority(connection.authority.lineage, () => {
|
|
5505
|
+
params.hostCapabilities.assertActive();
|
|
5506
|
+
if (nativeProcessAuthorityReleased) throw new Error("Codex attempt cleanup authority has ended");
|
|
5507
|
+
});
|
|
5508
|
+
const clearThreadBinding = () => clearCodexBindingForClient(connection.bindingStore, connection.bindingIdentity, state.thread, cleanupAuthority);
|
|
5554
5509
|
const releaseNativeProcessAuthority = () => {
|
|
5555
5510
|
if (!nativeProcessAuthorityReleased) {
|
|
5556
5511
|
nativeProcessAuthorityReleased = true;
|
|
5557
5512
|
nativeProcessAuthority?.release();
|
|
5558
5513
|
}
|
|
5559
5514
|
};
|
|
5560
|
-
const trajectoryRecorder = createCodexTrajectoryRecorder(
|
|
5561
|
-
attempt: params,
|
|
5562
|
-
cwd: effectiveCwd,
|
|
5563
|
-
developerInstructions: buildRenderedCodexDeveloperInstructions(),
|
|
5564
|
-
prompt: turnState.codexTurnPromptText,
|
|
5565
|
-
trajectory: params.hostCapabilities.trajectory,
|
|
5566
|
-
tools: toolBridge.availableSpecs
|
|
5567
|
-
});
|
|
5515
|
+
const trajectoryRecorder = createCodexTrajectoryRecorder(params.hostCapabilities.trajectory);
|
|
5568
5516
|
const state = {
|
|
5569
5517
|
client: void 0,
|
|
5570
5518
|
thread: void 0,
|
|
@@ -5575,11 +5523,13 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5575
5523
|
detachRouteAbort: (() => void 0),
|
|
5576
5524
|
trajectoryEndRecorded: false,
|
|
5577
5525
|
nativeHookRelay: void 0,
|
|
5526
|
+
nativeSpawnAdmissionInstalled: false,
|
|
5578
5527
|
nativeSubagentMonitor: void 0,
|
|
5579
5528
|
runtimeContinuationStarted: false,
|
|
5580
5529
|
releaseSharedClientLease: void 0,
|
|
5581
5530
|
startupClientUnsafe: false,
|
|
5582
5531
|
turnStartAttempted: false,
|
|
5532
|
+
nativeSettlementExpired: false,
|
|
5583
5533
|
sharedCodexClientRetiredForOneShotCleanup: false,
|
|
5584
5534
|
sandboxExecEnvironment: void 0,
|
|
5585
5535
|
executionDisconnectError: void 0,
|
|
@@ -5785,24 +5735,39 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5785
5735
|
if (subscriptionSettlement?.thread === thread) return subscriptionSettlement.retained;
|
|
5786
5736
|
if (!thread || thread.clientId !== resolveCodexAppServerClientInstanceId(client)) return false;
|
|
5787
5737
|
const { bindingStore, bindingIdentity } = connection;
|
|
5738
|
+
if (state.nativeSettlementExpired) return false;
|
|
5788
5739
|
const retained = await bindingStore.withLease(bindingIdentity, async () => {
|
|
5789
|
-
if (
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5740
|
+
if (state.nativeSettlementExpired) return false;
|
|
5741
|
+
let publicationStarted = false;
|
|
5742
|
+
let pending;
|
|
5743
|
+
const publish = (rowFailure) => {
|
|
5744
|
+
publicationStarted = true;
|
|
5745
|
+
if (state.nativeSettlementExpired || thread.clientId !== resolveCodexAppServerClientInstanceId(client) || !isSameCodexAppServerThreadOwner(bindingStore.read(bindingIdentity), thread)) return;
|
|
5746
|
+
if (!nativeProcessAuthority?.hasCurrentProcesses(client, thread.threadId)) {
|
|
5747
|
+
if (rowFailure) throw rowFailure.error;
|
|
5793
5748
|
params.hostCapabilities.assertActive();
|
|
5794
5749
|
connection.assertCurrent();
|
|
5795
5750
|
}
|
|
5751
|
+
if (!state.turnStartAttempted) runAbortController.signal.throwIfAborted();
|
|
5796
5752
|
thread.liveThreadOwnership?.assertCurrent();
|
|
5797
|
-
|
|
5798
|
-
|
|
5753
|
+
pending = retainCodexAppServerBindingSubscription(client, thread.threadId, {
|
|
5754
|
+
release: thread.liveThreadOwnership?.release,
|
|
5755
|
+
configFingerprint: thread.liveThreadConfigFingerprint,
|
|
5756
|
+
serviceTier: state.turnStartAttempted ? connection.mutable.pluginAppServer.serviceTier : thread.liveThreadOwnership?.serviceTier,
|
|
5757
|
+
ephemeralPolicy: thread.liveThreadEphemeralPolicy
|
|
5758
|
+
});
|
|
5759
|
+
};
|
|
5760
|
+
if (nativeProcessAuthority?.hasCurrentProcesses(client, thread.threadId)) publish();
|
|
5761
|
+
else try {
|
|
5762
|
+
await connection.withCurrent(() => publish());
|
|
5763
|
+
} catch (error) {
|
|
5764
|
+
if (publicationStarted) {
|
|
5765
|
+
await pending;
|
|
5766
|
+
throw error;
|
|
5767
|
+
}
|
|
5768
|
+
publish({ error });
|
|
5799
5769
|
}
|
|
5800
|
-
return await
|
|
5801
|
-
release: thread.liveThreadOwnership?.release,
|
|
5802
|
-
configFingerprint: thread.liveThreadConfigFingerprint,
|
|
5803
|
-
serviceTier: state.turnStartAttempted ? connection.mutable.pluginAppServer.serviceTier : thread.liveThreadOwnership?.serviceTier,
|
|
5804
|
-
ephemeralPolicy: thread.liveThreadEphemeralPolicy
|
|
5805
|
-
});
|
|
5770
|
+
return pending ? await pending : false;
|
|
5806
5771
|
});
|
|
5807
5772
|
if (retained) subscriptionSettlement = {
|
|
5808
5773
|
thread,
|
|
@@ -5818,16 +5783,21 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5818
5783
|
retained: false
|
|
5819
5784
|
};
|
|
5820
5785
|
if (thread.liveThreadOwnership) try {
|
|
5821
|
-
await thread.liveThreadOwnership.release(thread.threadId
|
|
5786
|
+
await thread.liveThreadOwnership.release(thread.threadId);
|
|
5822
5787
|
return true;
|
|
5823
5788
|
} catch (error) {
|
|
5824
5789
|
await closeCodexStartupClientBestEffort(client);
|
|
5825
5790
|
throw error;
|
|
5826
5791
|
}
|
|
5792
|
+
if (state.nativeSettlementExpired) {
|
|
5793
|
+
await closeCodexStartupClientBestEffort(client);
|
|
5794
|
+
return false;
|
|
5795
|
+
}
|
|
5827
5796
|
const released = await unsubscribeCodexThreadBestEffort(client, {
|
|
5828
5797
|
threadId: thread.threadId,
|
|
5829
5798
|
timeoutMs: CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS,
|
|
5830
|
-
assertCurrent
|
|
5799
|
+
assertCurrent,
|
|
5800
|
+
withCurrent: cleanupAuthority.withCurrent
|
|
5831
5801
|
});
|
|
5832
5802
|
if (!released) await closeCodexStartupClientBestEffort(client);
|
|
5833
5803
|
return released;
|
|
@@ -5841,11 +5811,10 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5841
5811
|
try {
|
|
5842
5812
|
retained = Boolean(!state.turnStartAttempted && !runAbortController.signal.aborted && params.cleanupBundleMcpOnRunEnd !== true && thread.liveThreadOwnership && await retainThreadSubscription());
|
|
5843
5813
|
} finally {
|
|
5844
|
-
if (!retained) {
|
|
5845
|
-
if (!isIncognitoSessionKey(params.sessionKey) || await
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
})) await releaseThreadSubscription();
|
|
5814
|
+
if (!retained) try {
|
|
5815
|
+
if (!isIncognitoSessionKey(params.sessionKey) || await clearThreadBinding()) await releaseThreadSubscription();
|
|
5816
|
+
} finally {
|
|
5817
|
+
if (thread.liveThreadOwnership) await releaseThreadSubscription();
|
|
5849
5818
|
}
|
|
5850
5819
|
}
|
|
5851
5820
|
});
|
|
@@ -5868,6 +5837,7 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5868
5837
|
const requesterChannel = params.messageChannel ?? params.messageProvider;
|
|
5869
5838
|
const requester = buildCodexHookRequester(params);
|
|
5870
5839
|
const buildNativeHookRelayFinalConfigPatch = async (decision) => {
|
|
5840
|
+
state.nativeSpawnAdmissionInstalled = false;
|
|
5871
5841
|
const previousRelay = state.nativeHookRelay;
|
|
5872
5842
|
previousRelay?.unregister();
|
|
5873
5843
|
await previousRelay?.drain();
|
|
@@ -5924,7 +5894,7 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5924
5894
|
tools: decision.nativeModelInputTools,
|
|
5925
5895
|
readQualification: (threadId) => getCodexInferenceThreadQualification(state.client, threadId)
|
|
5926
5896
|
} : void 0,
|
|
5927
|
-
assertCurrent: connection.
|
|
5897
|
+
assertCurrent: connection.assertLegacyCurrent,
|
|
5928
5898
|
onPreToolUseFailure: (failure) => {
|
|
5929
5899
|
const projector = projectorRef.current;
|
|
5930
5900
|
if (projector) projector.recordNativeToolPreToolUseFailure(failure);
|
|
@@ -5933,6 +5903,13 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5933
5903
|
});
|
|
5934
5904
|
await state.nativeHookRelay?.prepareInvocation();
|
|
5935
5905
|
connection.assertCurrent();
|
|
5906
|
+
state.nativeSpawnAdmissionInstalled = Boolean(state.nativeHookRelay && requiresModelAdmission && decision.nativeModelInputTools?.includes("spawn_agent") && params.hostCapabilities.assertNativeSubagentSpawnAllowed);
|
|
5907
|
+
if (!state.nativeSpawnAdmissionInstalled && !isCodexNativeDelegationDisabledForRun(params)) try {
|
|
5908
|
+
params.hostCapabilities.assertNativeSubagentSpawnAllowed?.();
|
|
5909
|
+
} catch (cause) {
|
|
5910
|
+
if (!(cause instanceof Error) || !cause.message.startsWith("Several people have steered this turn:")) throw cause;
|
|
5911
|
+
throw new Error("Several people have steered this turn, and this Codex setup cannot run native sub-agents safely for more than one person without native hook admission. Send the request again as a new message so it runs as its own turn.", { cause });
|
|
5912
|
+
}
|
|
5936
5913
|
return {
|
|
5937
5914
|
configPatch: state.nativeHookRelay ? buildCodexNativeHookRelayConfig({
|
|
5938
5915
|
relay: state.nativeHookRelay,
|
|
@@ -5942,21 +5919,7 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5942
5919
|
nativeHookRelayGeneration: state.nativeHookRelay?.generation
|
|
5943
5920
|
};
|
|
5944
5921
|
};
|
|
5945
|
-
const nativeProcessAuthority = params.hostCapabilities.retainSourceAuthority ? new CodexNativeProcessAuthority(params.hostCapabilities, (error) =>
|
|
5946
|
-
const message = formatErrorMessage(error);
|
|
5947
|
-
embeddedAgentLog.warn("codex native background work remains unsettled", {
|
|
5948
|
-
runId: params.runId,
|
|
5949
|
-
sessionId: params.sessionId,
|
|
5950
|
-
error: message
|
|
5951
|
-
});
|
|
5952
|
-
emitCodexAppServerEvent(params, {
|
|
5953
|
-
stream: "codex_app_server.lifecycle",
|
|
5954
|
-
data: {
|
|
5955
|
-
phase: "background_cleanup_failed",
|
|
5956
|
-
error: message
|
|
5957
|
-
}
|
|
5958
|
-
});
|
|
5959
|
-
}, Boolean(sandbox?.enabled && sandbox.backend)) : void 0;
|
|
5922
|
+
const nativeProcessAuthority = params.hostCapabilities.retainSourceAuthority ? new CodexNativeProcessAuthority(params.hostCapabilities, (error) => reportCodexBackgroundCleanupFailure(params, error), Boolean(sandbox?.enabled && sandbox.backend)) : void 0;
|
|
5960
5923
|
return {
|
|
5961
5924
|
prompt,
|
|
5962
5925
|
trajectoryRecorder,
|
|
@@ -5974,6 +5937,7 @@ function prepareCodexAttemptResources(prompt) {
|
|
|
5974
5937
|
runCleanupStep,
|
|
5975
5938
|
registerNativeSubagentMonitor,
|
|
5976
5939
|
releaseCurrentRoute,
|
|
5940
|
+
clearThreadBinding,
|
|
5977
5941
|
retainThreadSubscription,
|
|
5978
5942
|
releaseThreadSubscription,
|
|
5979
5943
|
cleanupBeforeActiveTurn,
|
|
@@ -6043,7 +6007,7 @@ function prewarmCodexAttemptClient(params) {
|
|
|
6043
6007
|
const { appServer, attemptClientFactory, options, pluginConfig, runtimeArtifactRequest, startupAuthRequirement, startupClientAuthProfileId, startupPreparedAuth, agentDir, params: runParams, runAbortController } = connection;
|
|
6044
6008
|
if (options.clientFactory || attemptClientFactory !== getLeasedSharedCodexAppServerClient || runtimeArtifactRequest) return;
|
|
6045
6009
|
getSharedCodexAppServerClient({
|
|
6046
|
-
assertCurrent: connection.
|
|
6010
|
+
assertCurrent: connection.assertLegacyCurrent,
|
|
6047
6011
|
startOptions: appServer.start,
|
|
6048
6012
|
pluginConfig,
|
|
6049
6013
|
...startupPreparedAuth ? { preparedAuth: startupPreparedAuth } : { authProfileId: startupClientAuthProfileId },
|
|
@@ -6066,10 +6030,6 @@ function canResolveScheduledConfiguredMcpCreatorAuthority(params) {
|
|
|
6066
6030
|
}
|
|
6067
6031
|
//#endregion
|
|
6068
6032
|
//#region extensions/codex/src/app-server/run-attempt-runtime.ts
|
|
6069
|
-
function resolveCodexAttemptBundleManifestRegistry(preparedModelRuntime) {
|
|
6070
|
-
const metadataSnapshot = preparedModelRuntime?.metadataSnapshot;
|
|
6071
|
-
return metadataSnapshot?.pluginIds === void 0 ? metadataSnapshot?.manifestRegistry : void 0;
|
|
6072
|
-
}
|
|
6073
6033
|
async function prepareCodexAttemptRuntime(connection) {
|
|
6074
6034
|
const { params, pluginConfig, usesSupervisionConnection, appServer, startupAuthProfileId, startupPreparedAuth, startupClientAuthProfileId, agentDir, preDynamicStartupStages, effectiveWorkspace, contextSessionKey, sandboxSessionKey, sessionAgentId, policyAgentId, sandbox, attemptClientFactory, runAbortController, activeContextEngine, mutable } = connection;
|
|
6075
6035
|
const preparedAuthBinding = !usesSupervisionConnection && appServer.start.homeScope !== "user" && startupAuthProfileId ? await prepareCodexAppServerAuthBinding({
|
|
@@ -6134,13 +6094,14 @@ async function prepareCodexAttemptRuntime(connection) {
|
|
|
6134
6094
|
agentId: sessionAgentId,
|
|
6135
6095
|
toolOverrides: params.toolOverrides
|
|
6136
6096
|
});
|
|
6137
|
-
const
|
|
6097
|
+
const metadataSnapshot = params.preparedModelRuntime?.metadataSnapshot;
|
|
6098
|
+
const bundleManifestRegistry = metadataSnapshot?.pluginIds === void 0 ? metadataSnapshot?.manifestRegistry : void 0;
|
|
6138
6099
|
const bundleMcpThreadConfig = await loadCodexBundleMcpThreadConfig({
|
|
6139
6100
|
workspaceDir: effectiveWorkspace,
|
|
6140
6101
|
agentId: sessionAgentId,
|
|
6141
6102
|
cfg: params.config,
|
|
6142
6103
|
toolsEnabled: usesSupervisionConnection || supportsModelTools(params.model),
|
|
6143
|
-
disableTools: params.disableTools,
|
|
6104
|
+
disableTools: params.disableTools || params.requireWorkspaceOnly === true,
|
|
6144
6105
|
toolsAllow: params.toolsAllow,
|
|
6145
6106
|
manifestRegistry: bundleManifestRegistry,
|
|
6146
6107
|
toolOverrides: codexMcpToolOverrides
|
|
@@ -6206,7 +6167,7 @@ async function prepareCodexAttemptRuntime(connection) {
|
|
|
6206
6167
|
else releaseLeasedSharedCodexAppServerClient(client);
|
|
6207
6168
|
}
|
|
6208
6169
|
}
|
|
6209
|
-
const configuredMcpSurface = scheduledConfiguredMcpSurface ? "scheduled" : !nativeToolSurfaceEnabled && bundleMcpThreadConfig.staticServerNames.length > 0 ? "transient" : void 0;
|
|
6170
|
+
const configuredMcpSurface = params.requireWorkspaceOnly === true ? void 0 : scheduledConfiguredMcpSurface ? "scheduled" : !nativeToolSurfaceEnabled && bundleMcpThreadConfig.staticServerNames.length > 0 ? "transient" : void 0;
|
|
6210
6171
|
preDynamicStartupStages.mark("native-tool-surface");
|
|
6211
6172
|
const webSearchPlan = resolveCodexWebSearchPlan({
|
|
6212
6173
|
config: params.config,
|
|
@@ -6435,6 +6396,7 @@ function createCodexAttemptServerRequestController(resources, turnRuntime, lifec
|
|
|
6435
6396
|
});
|
|
6436
6397
|
projector?.recordDynamicToolCall({
|
|
6437
6398
|
callId: call.callId,
|
|
6399
|
+
namespace: call.namespace,
|
|
6438
6400
|
tool: call.tool,
|
|
6439
6401
|
arguments: call.arguments
|
|
6440
6402
|
});
|
|
@@ -6590,7 +6552,7 @@ function createCodexAttemptServerRequestController(resources, turnRuntime, lifec
|
|
|
6590
6552
|
response,
|
|
6591
6553
|
durationMs: toolDurationMs
|
|
6592
6554
|
});
|
|
6593
|
-
else if (
|
|
6555
|
+
else if (response.asyncStarted === true) scheduleTerminalDynamicToolReleaseCheck();
|
|
6594
6556
|
else {
|
|
6595
6557
|
state.currentTurnHadNonTerminalDynamicToolResult = true;
|
|
6596
6558
|
state.pendingTerminalDynamicToolRelease = void 0;
|
|
@@ -6622,7 +6584,7 @@ function createCodexAttemptServerRequestController(resources, turnRuntime, lifec
|
|
|
6622
6584
|
//#region extensions/codex/src/app-server/attempt-runtime-artifact.ts
|
|
6623
6585
|
async function verifyStartupArtifact(params) {
|
|
6624
6586
|
if (!params.request) return;
|
|
6625
|
-
const { readCodexAppServerClientRuntimeArtifact, validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-
|
|
6587
|
+
const { readCodexAppServerClientRuntimeArtifact, validateCodexAppServerRuntimeArtifact } = await import("./runtime-artifact-CUTOOnKw.mjs");
|
|
6626
6588
|
const runtimeArtifact = readCodexAppServerClientRuntimeArtifact(params.client);
|
|
6627
6589
|
const expected = params.request.expected;
|
|
6628
6590
|
const matchesExpected = !expected || runtimeArtifact?.id === expected.id && runtimeArtifact.fingerprint === expected.fingerprint;
|
|
@@ -6645,7 +6607,14 @@ function startCodexComputerUseHealthMonitor(params) {
|
|
|
6645
6607
|
reason: params.config.enabled ? "health_disabled" : "disabled"
|
|
6646
6608
|
};
|
|
6647
6609
|
}
|
|
6648
|
-
const fingerprint =
|
|
6610
|
+
const fingerprint = JSON.stringify({
|
|
6611
|
+
autoRepair: params.config.autoRepair,
|
|
6612
|
+
healthCheckIntervalMinutes: params.config.healthCheckIntervalMinutes,
|
|
6613
|
+
liveTestTimeoutMs: params.config.liveTestTimeoutMs,
|
|
6614
|
+
mcpServerName: params.config.mcpServerName,
|
|
6615
|
+
toolCallTimeoutMs: params.config.toolCallTimeoutMs,
|
|
6616
|
+
tools: params.tools?.toSorted()
|
|
6617
|
+
});
|
|
6649
6618
|
const intervalMs = params.config.healthCheckIntervalMinutes * 6e4;
|
|
6650
6619
|
if (existing?.fingerprint === fingerprint) return {
|
|
6651
6620
|
started: false,
|
|
@@ -6672,16 +6641,6 @@ function startCodexComputerUseHealthMonitor(params) {
|
|
|
6672
6641
|
intervalMs
|
|
6673
6642
|
};
|
|
6674
6643
|
}
|
|
6675
|
-
function buildComputerUseHealthMonitorFingerprint(config, tools) {
|
|
6676
|
-
return JSON.stringify({
|
|
6677
|
-
autoRepair: config.autoRepair,
|
|
6678
|
-
healthCheckIntervalMinutes: config.healthCheckIntervalMinutes,
|
|
6679
|
-
liveTestTimeoutMs: config.liveTestTimeoutMs,
|
|
6680
|
-
mcpServerName: config.mcpServerName,
|
|
6681
|
-
toolCallTimeoutMs: config.toolCallTimeoutMs,
|
|
6682
|
-
tools: tools?.toSorted()
|
|
6683
|
-
});
|
|
6684
|
-
}
|
|
6685
6644
|
async function runCodexComputerUseHealthProbe(client, config, monitor, tools) {
|
|
6686
6645
|
if (monitor.running) return;
|
|
6687
6646
|
monitor.running = true;
|
|
@@ -6721,121 +6680,12 @@ function clearComputerUseHealthMonitor(client, monitor) {
|
|
|
6721
6680
|
getComputerUseHealthMonitorState().monitors.delete(client);
|
|
6722
6681
|
}
|
|
6723
6682
|
//#endregion
|
|
6724
|
-
//#region extensions/codex/src/app-server/plugin-thread-config-deadline.ts
|
|
6725
|
-
/** Enforces one bounded startup budget across Codex plugin config discovery. */
|
|
6726
|
-
const CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS = 6e4;
|
|
6727
|
-
const CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR = 4;
|
|
6728
|
-
const CODEX_PLUGIN_THREAD_CONFIG_MIN_TIMEOUT_MS = 100;
|
|
6729
|
-
var CodexPluginThreadConfigDeadlineError = class extends Error {
|
|
6730
|
-
constructor() {
|
|
6731
|
-
super("Codex plugin thread config deadline elapsed");
|
|
6732
|
-
this.name = "CodexPluginThreadConfigDeadlineError";
|
|
6733
|
-
}
|
|
6734
|
-
};
|
|
6735
|
-
/** Resolves the plugin policy state reused throughout app-server startup. */
|
|
6736
|
-
function resolveCodexPluginThreadConfigStartupPolicy(params) {
|
|
6737
|
-
const pluginThreadConfigRequired = params.hostedAppsSupported === false || Boolean(params.scheduledRuntimeAuthority) || !params.nativeToolSurfaceEnabled || shouldBuildCodexPluginThreadConfig(params.pluginConfig);
|
|
6738
|
-
const pluginThreadConfigPluginConfig = params.hostedAppsSupported !== false && (params.nativeToolSurfaceEnabled || params.scheduledRuntimeAuthority) ? params.pluginConfig : disableCodexPluginThreadConfig(params.pluginConfig);
|
|
6739
|
-
const resolvedPluginPolicy = pluginThreadConfigRequired ? resolveCodexPluginsPolicy(pluginThreadConfigPluginConfig) : void 0;
|
|
6740
|
-
return {
|
|
6741
|
-
pluginThreadConfigRequired,
|
|
6742
|
-
pluginThreadConfigPluginConfig,
|
|
6743
|
-
resolvedPluginPolicy,
|
|
6744
|
-
enabledPluginConfigKeys: resolvedPluginPolicy ? resolvedPluginPolicy.pluginPolicies.filter((plugin) => plugin.enabled).map((plugin) => plugin.configKey).toSorted() : void 0
|
|
6745
|
-
};
|
|
6746
|
-
}
|
|
6747
|
-
/** Builds plugin config without allowing sequential RPC timeouts to consume the turn. */
|
|
6748
|
-
async function buildCodexPluginThreadConfigWithinDeadline(params) {
|
|
6749
|
-
const { requestTimeoutMs, signal, request, failClosedOnTimeout, transform, ...buildParams } = params;
|
|
6750
|
-
signal.throwIfAborted();
|
|
6751
|
-
const timeoutMs = resolveCodexPluginThreadConfigTimeoutMs(requestTimeoutMs);
|
|
6752
|
-
const deadlineMs = performance.now() + timeoutMs;
|
|
6753
|
-
let requestTimedOut = false;
|
|
6754
|
-
const boundedRequest = async (method, requestParams) => {
|
|
6755
|
-
const remainingTimeoutMs = deadlineMs - performance.now();
|
|
6756
|
-
if (requestTimedOut || remainingTimeoutMs <= 0) throw new CodexPluginThreadConfigDeadlineError();
|
|
6757
|
-
try {
|
|
6758
|
-
return await request(method, requestParams, {
|
|
6759
|
-
timeoutMs: remainingTimeoutMs,
|
|
6760
|
-
signal
|
|
6761
|
-
});
|
|
6762
|
-
} catch (error) {
|
|
6763
|
-
requestTimedOut ||= isCodexPluginThreadConfigTimeoutError(error);
|
|
6764
|
-
throw error;
|
|
6765
|
-
}
|
|
6766
|
-
};
|
|
6767
|
-
try {
|
|
6768
|
-
return await withAbortableTimeout({
|
|
6769
|
-
signal,
|
|
6770
|
-
timeoutMs,
|
|
6771
|
-
promise: (async () => {
|
|
6772
|
-
const config = await buildCodexPluginThreadConfig({
|
|
6773
|
-
...buildParams,
|
|
6774
|
-
request: boundedRequest
|
|
6775
|
-
});
|
|
6776
|
-
const result = transform ? await transform(config, boundedRequest) : config;
|
|
6777
|
-
if (requestTimedOut || performance.now() >= deadlineMs) throw new CodexPluginThreadConfigDeadlineError();
|
|
6778
|
-
return result;
|
|
6779
|
-
})(),
|
|
6780
|
-
timeoutMessage: "Codex plugin thread config deadline elapsed",
|
|
6781
|
-
createTimeoutError: () => new CodexPluginThreadConfigDeadlineError()
|
|
6782
|
-
});
|
|
6783
|
-
} catch (error) {
|
|
6784
|
-
if (signal.aborted || !requestTimedOut && !isCodexPluginThreadConfigTimeoutError(error) && performance.now() < deadlineMs) throw error;
|
|
6785
|
-
if (failClosedOnTimeout) throw new AgentHarnessPreflightError(`Codex app policy verification exceeded its ${timeoutMs} ms startup budget. No app tools were executed. Retry after Codex app inventory is responsive.`);
|
|
6786
|
-
return buildCodexPluginThreadConfigTimeoutFallback({
|
|
6787
|
-
pluginConfig: buildParams.pluginConfig,
|
|
6788
|
-
appCacheKey: buildParams.appCacheKey,
|
|
6789
|
-
message: `Codex plugin discovery exceeded its ${timeoutMs} ms startup budget; plugin apps were disabled for this turn.`
|
|
6790
|
-
});
|
|
6791
|
-
}
|
|
6792
|
-
}
|
|
6793
|
-
/** Creates the recovery metadata and bounded builder used by thread startup. */
|
|
6794
|
-
function createCodexPluginThreadConfigStartupProvider(params) {
|
|
6795
|
-
const { client, policy, inputFingerprint, enabledPluginConfigKeys, appCache, metadataCache: configuredMetadataCache, ...buildParams } = params;
|
|
6796
|
-
const metadataCache = configuredMetadataCache ?? defaultCodexPluginMetadataCache;
|
|
6797
|
-
return {
|
|
6798
|
-
enabled: true,
|
|
6799
|
-
requiresCurrentPolicyCheck: Boolean(policy?.enabled || params.scheduledRuntimeAuthority),
|
|
6800
|
-
inputFingerprint,
|
|
6801
|
-
enabledPluginConfigKeys,
|
|
6802
|
-
accountAppRecoveryEnabled: policy?.allowAllPlugins,
|
|
6803
|
-
recoverablePluginConfigKeys: policy ? resolveRecoverableCodexPluginConfigKeys({
|
|
6804
|
-
policy,
|
|
6805
|
-
metadataCache,
|
|
6806
|
-
appCacheKey: params.appCacheKey,
|
|
6807
|
-
configCwd: params.configCwd
|
|
6808
|
-
}) : void 0,
|
|
6809
|
-
build: async (buildOptions) => {
|
|
6810
|
-
const config = await buildCodexPluginThreadConfigWithinDeadline({
|
|
6811
|
-
...buildParams,
|
|
6812
|
-
threadId: buildOptions?.threadId,
|
|
6813
|
-
appCache: appCache ?? defaultCodexAppInventoryCache,
|
|
6814
|
-
metadataCache,
|
|
6815
|
-
failClosedOnTimeout: Boolean(params.scheduledRuntimeAuthority),
|
|
6816
|
-
transform: params.scheduledRuntimeAuthority ? async (builtConfig, request) => intersectCodexPluginThreadConfigWithScheduledAuthority(builtConfig, params.scheduledRuntimeAuthority, await readCurrentCodexScheduledAppPolicy({
|
|
6817
|
-
request,
|
|
6818
|
-
configCwd: params.configCwd,
|
|
6819
|
-
threadId: buildOptions?.threadId
|
|
6820
|
-
})) : void 0,
|
|
6821
|
-
request: (method, requestParams, options) => client.request(method, requestParams, options)
|
|
6822
|
-
});
|
|
6823
|
-
return params.scheduledRuntimeAuthority && params.inputFingerprint ? {
|
|
6824
|
-
...config,
|
|
6825
|
-
inputFingerprint: params.inputFingerprint
|
|
6826
|
-
} : config;
|
|
6827
|
-
}
|
|
6828
|
-
};
|
|
6829
|
-
}
|
|
6830
|
-
function resolveCodexPluginThreadConfigTimeoutMs(requestTimeoutMs) {
|
|
6831
|
-
return Math.min(CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS, Math.max(CODEX_PLUGIN_THREAD_CONFIG_MIN_TIMEOUT_MS, Math.floor((Number.isFinite(requestTimeoutMs) && requestTimeoutMs > 0 ? requestTimeoutMs : CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS * CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR) / CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR)));
|
|
6832
|
-
}
|
|
6833
|
-
function isCodexPluginThreadConfigTimeoutError(error) {
|
|
6834
|
-
return error instanceof CodexPluginThreadConfigDeadlineError || error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED" && error.message.endsWith(" timed out");
|
|
6835
|
-
}
|
|
6836
|
-
//#endregion
|
|
6837
6683
|
//#region extensions/codex/src/app-server/attempt-startup.ts
|
|
6838
6684
|
const CODEX_APP_SERVER_STARTUP_MAX_ATTEMPTS = 3;
|
|
6685
|
+
/**
|
|
6686
|
+
* Starts or resumes the Codex app-server thread and returns the resources the
|
|
6687
|
+
* run loop must later release.
|
|
6688
|
+
*/
|
|
6839
6689
|
async function startCodexAttemptThread(params) {
|
|
6840
6690
|
let pluginAppServer = params.appServer;
|
|
6841
6691
|
const startupRuntimeAuthProfileId = params.startupPreparedAuth?.kind === "profile" ? params.startupPreparedAuth.profileId : params.startupAuthProfileId ?? void 0;
|
|
@@ -6882,7 +6732,10 @@ async function startCodexAttemptThread(params) {
|
|
|
6882
6732
|
params.assertCurrent?.();
|
|
6883
6733
|
if (startupAbandonController.signal.aborted) throw new CodexAppServerStartupError("aborted");
|
|
6884
6734
|
startupClient = await params.attemptClientFactory({
|
|
6885
|
-
assertCurrent:
|
|
6735
|
+
assertCurrent: () => {
|
|
6736
|
+
params.assertCurrent?.();
|
|
6737
|
+
params.authority?.assertLegacyCurrent();
|
|
6738
|
+
},
|
|
6886
6739
|
startOptions: params.appServer.start,
|
|
6887
6740
|
pluginConfig: params.pluginConfig,
|
|
6888
6741
|
...params.startupPreparedAuth ? { preparedAuth: params.startupPreparedAuth } : { authProfileId: params.startupAuthProfileId },
|
|
@@ -7050,6 +6903,7 @@ async function startCodexAttemptThread(params) {
|
|
|
7050
6903
|
reserveResumeThread,
|
|
7051
6904
|
bindingStore: params.bindingStore,
|
|
7052
6905
|
assertCurrent: params.assertCurrent,
|
|
6906
|
+
authority: params.authority,
|
|
7053
6907
|
params: params.buildAttemptParams(),
|
|
7054
6908
|
runtimeModelId: params.runtimeModelId,
|
|
7055
6909
|
agentId: params.sessionAgentId,
|
|
@@ -7060,7 +6914,7 @@ async function startCodexAttemptThread(params) {
|
|
|
7060
6914
|
webSearchAllowed: params.webSearchAllowed,
|
|
7061
6915
|
appServer: pluginAppServer,
|
|
7062
6916
|
developerInstructions: params.developerInstructions,
|
|
7063
|
-
|
|
6917
|
+
refreshableInstructions: params.refreshableInstructions,
|
|
7064
6918
|
agentWorkspaceDeveloperInstructions: params.agentWorkspaceDeveloperInstructions,
|
|
7065
6919
|
config: threadConfig,
|
|
7066
6920
|
shellEnvironment: params.shellEnvironment,
|
|
@@ -7236,6 +7090,7 @@ async function startCodexAttemptRuntime(resources) {
|
|
|
7236
7090
|
});
|
|
7237
7091
|
const startupResult = await startCodexAttemptThread({
|
|
7238
7092
|
assertCurrent: connection.assertCurrent,
|
|
7093
|
+
authority: connection.authority,
|
|
7239
7094
|
attemptClientFactory,
|
|
7240
7095
|
bindingStore,
|
|
7241
7096
|
runtime: connection.options.runtime,
|
|
@@ -7263,11 +7118,11 @@ async function startCodexAttemptRuntime(resources) {
|
|
|
7263
7118
|
persistentWebSearchAllowed: toolState.persistentWebSearchAllowed,
|
|
7264
7119
|
webSearchAllowed: toolState.webSearchAllowed,
|
|
7265
7120
|
developerInstructions,
|
|
7266
|
-
|
|
7121
|
+
refreshableInstructions: context.refreshableInstructions,
|
|
7267
7122
|
agentWorkspaceDeveloperInstructions: context.agentWorkspaceDeveloperInstructions,
|
|
7268
7123
|
buildFinalConfigPatch: buildNativeHookRelayFinalConfigPatch,
|
|
7269
7124
|
nativeModelAdmission: resources.nativeModelAdmission,
|
|
7270
|
-
nativeHookRelayRequired: nativeToolSurfaceEnabled && params.pluginHarnessToolPolicyRestricted !== true && (resources.nativeProcessAuthority?.requiresProcessAdmission || resources.nativeModelAdmission === "required") || connection.options.nativeHookRelay?.enabled !== false && params.pluginHarnessToolPolicyRestricted !== true && connection.nativeHookRelayEvents.includes("pre_tool_use") && (hasBeforeToolCallPolicy() || appServer.loopDetectionPreToolUseRelay && Boolean(connection.sandboxSessionKey) && loopDetectionEnabled),
|
|
7125
|
+
nativeHookRelayRequired: params.requireWorkspaceOnly !== true && (nativeToolSurfaceEnabled && params.pluginHarnessToolPolicyRestricted !== true && (resources.nativeProcessAuthority?.requiresProcessAdmission || resources.nativeModelAdmission === "required") || connection.options.nativeHookRelay?.enabled !== false && params.pluginHarnessToolPolicyRestricted !== true && connection.nativeHookRelayEvents.includes("pre_tool_use") && (hasBeforeToolCallPolicy() || appServer.loopDetectionPreToolUseRelay && Boolean(connection.sandboxSessionKey) && loopDetectionEnabled)),
|
|
7271
7126
|
bundleMcpThreadConfig,
|
|
7272
7127
|
configuredMcpDynamicSurface: attemptTools.configuredMcp !== void 0,
|
|
7273
7128
|
configuredMcpOwnershipVersion: attemptTools.configuredMcpOwnershipVersion,
|
|
@@ -7296,14 +7151,7 @@ async function startCodexAttemptRuntime(resources) {
|
|
|
7296
7151
|
state.restartContextEngineCodexThread = startupResult.restartContextEngineCodexThread;
|
|
7297
7152
|
await attemptTools.captureCronCreatorToolAllowlist();
|
|
7298
7153
|
pluginAppServer = startupResult.pluginAppServer;
|
|
7299
|
-
toolBridge.setRemoteWorkspaceFileReader?.((
|
|
7300
|
-
client: startupResult.client,
|
|
7301
|
-
path,
|
|
7302
|
-
maxBytes,
|
|
7303
|
-
workspaceRoot,
|
|
7304
|
-
signal,
|
|
7305
|
-
timeoutMs
|
|
7306
|
-
}));
|
|
7154
|
+
toolBridge.setRemoteWorkspaceFileReader?.(createCodexRemoteWorkspaceFileReader(startupResult.client, connection.authority));
|
|
7307
7155
|
if (usesSupervisionConnection && (state.thread.connectionScope !== "supervision" || state.thread.supervisionSourceThreadId !== connection.mutable.startupBinding?.supervisionSourceThreadId)) throw new Error("Codex supervised thread lost its private connection ownership");
|
|
7308
7156
|
if (state.thread.lifecycle.action === "started" || state.thread.lifecycle.action === "forked") {
|
|
7309
7157
|
const activePolicy = resolveReviewerPolicyContext(state.thread);
|
|
@@ -7361,14 +7209,7 @@ async function startCodexAttemptRuntime(resources) {
|
|
|
7361
7209
|
//#region extensions/codex/src/app-server/heartbeat-tool-fallback.ts
|
|
7362
7210
|
const InactiveHeartbeatResponseParameters = Type.Object({}, { additionalProperties: true });
|
|
7363
7211
|
function resolveInactiveCodexHeartbeatResponseDescriptor(params) {
|
|
7364
|
-
|
|
7365
|
-
const spec = flattenCodexDynamicToolFunctions(params.registeredSpecs).find((tool) => tool.name === HEARTBEAT_RESPONSE_TOOL_NAME);
|
|
7366
|
-
return spec ? {
|
|
7367
|
-
name: spec.name,
|
|
7368
|
-
description: spec.description
|
|
7369
|
-
} : void 0;
|
|
7370
|
-
}
|
|
7371
|
-
const descriptor = params.registeredTools.find((tool) => tool.name === HEARTBEAT_RESPONSE_TOOL_NAME);
|
|
7212
|
+
const descriptor = (params.registeredSpecs ? flattenCodexDynamicToolFunctions(params.registeredSpecs) : params.registeredTools).find((tool) => tool.name === HEARTBEAT_RESPONSE_TOOL_NAME);
|
|
7372
7213
|
return descriptor ? {
|
|
7373
7214
|
name: descriptor.name,
|
|
7374
7215
|
description: descriptor.description
|
|
@@ -7406,9 +7247,6 @@ function selectInactiveCodexHeartbeatResponseTool(params) {
|
|
|
7406
7247
|
}
|
|
7407
7248
|
//#endregion
|
|
7408
7249
|
//#region extensions/codex/src/app-server/run-attempt-tool-setup.ts
|
|
7409
|
-
function isAuthorityResolutionOperationAbort(error, signal) {
|
|
7410
|
-
return signal?.aborted === true && error === signal.reason;
|
|
7411
|
-
}
|
|
7412
7250
|
async function prepareCodexAttemptTools(runtime) {
|
|
7413
7251
|
const { connection, bundleMcpThreadConfig, bundleManifestRegistry, runtimeParams, effectiveRuntimeModelId, nativeToolSurfaceEnabled, nativeProviderWebSearchSupport, hookChannelId, codexMcpToolOverrides, authenticatedScheduledMode, configuredMcpSurface, canResolveScheduledConfiguredMcpCreatorAuthority } = runtime;
|
|
7414
7252
|
const { params, preDynamicStartupStages, mutable, resolvedWorkspace, effectiveWorkspace, effectiveCwd, sandboxSessionKey, contextSessionKey, sandbox, sessionPermissionPolicy, runAbortController, sessionAgentId, policyAgentId, pluginConfig, profilerEnabled, agentDir } = connection;
|
|
@@ -7518,7 +7356,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7518
7356
|
const pending = resolveCreatorAuthorityImpl(options);
|
|
7519
7357
|
creatorAuthorityPromise = pending;
|
|
7520
7358
|
pending.catch((error) => {
|
|
7521
|
-
if (creatorAuthorityPromise === pending &&
|
|
7359
|
+
if (creatorAuthorityPromise === pending && options?.signal?.aborted === true && error === options.signal.reason) creatorAuthorityPromise = void 0;
|
|
7522
7360
|
});
|
|
7523
7361
|
return pending;
|
|
7524
7362
|
} } : {}
|
|
@@ -7528,7 +7366,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7528
7366
|
runAbortController.signal.throwIfAborted();
|
|
7529
7367
|
connection.assertCurrent();
|
|
7530
7368
|
const client = await connection.attemptClientFactory({
|
|
7531
|
-
assertCurrent: connection.
|
|
7369
|
+
assertCurrent: connection.assertLegacyCurrent,
|
|
7532
7370
|
startOptions: connection.appServer.start,
|
|
7533
7371
|
authProfileId: connection.startupClientAuthProfileId,
|
|
7534
7372
|
agentDir,
|
|
@@ -7538,6 +7376,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7538
7376
|
try {
|
|
7539
7377
|
nativeSpecs = await loadCodexNativeToolCatalog({
|
|
7540
7378
|
client,
|
|
7379
|
+
authority: connection.authority,
|
|
7541
7380
|
binding: mutable.startupBinding,
|
|
7542
7381
|
appServer: connection.appServer,
|
|
7543
7382
|
agentDir,
|
|
@@ -7602,7 +7441,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7602
7441
|
sessionId: params.sessionId,
|
|
7603
7442
|
runId: params.runId,
|
|
7604
7443
|
agentId: policyAgentId,
|
|
7605
|
-
agentDir: agentDir ?? resolveAgentDir$
|
|
7444
|
+
agentDir: agentDir ?? resolveAgentDir$1(params.config ?? {}, sessionAgentId),
|
|
7606
7445
|
agentAccountId: params.agentAccountId,
|
|
7607
7446
|
messageProvider: params.messageProvider ?? params.messageChannel,
|
|
7608
7447
|
messageChannel: params.messageChannel,
|
|
@@ -7668,7 +7507,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7668
7507
|
policyContext,
|
|
7669
7508
|
warn: (message) => embeddedAgentLog.warn(message)
|
|
7670
7509
|
};
|
|
7671
|
-
configuredMcp = configuredMcpSurface ? await materializeStaticMcpToolsForHarnessRun({
|
|
7510
|
+
configuredMcp = params.requireWorkspaceOnly !== true && configuredMcpSurface ? await materializeStaticMcpToolsForHarnessRun({
|
|
7672
7511
|
...mcpOptions,
|
|
7673
7512
|
sessionId: params.sessionId,
|
|
7674
7513
|
sessionKey: params.sessionKey,
|
|
@@ -7681,7 +7520,7 @@ async function prepareCodexAttemptTools(runtime) {
|
|
|
7681
7520
|
"deny"
|
|
7682
7521
|
]) } : {}
|
|
7683
7522
|
}) : void 0;
|
|
7684
|
-
scopedMcpTools = authenticatedScheduledMode ? void 0 : await materializeRequesterScopedMcpToolsForHarnessRun({
|
|
7523
|
+
scopedMcpTools = authenticatedScheduledMode || params.requireWorkspaceOnly === true ? void 0 : await materializeRequesterScopedMcpToolsForHarnessRun({
|
|
7685
7524
|
...mcpOptions,
|
|
7686
7525
|
sessionId: params.sessionId,
|
|
7687
7526
|
sessionKey: params.sessionKey,
|
|
@@ -7944,7 +7783,7 @@ async function prepareCodexProviderReviewContinuation(params) {
|
|
|
7944
7783
|
}
|
|
7945
7784
|
//#endregion
|
|
7946
7785
|
//#region extensions/codex/src/app-server/service-tier.ts
|
|
7947
|
-
/**
|
|
7786
|
+
/** Validate an explicit Ultrafast selection against this turn's native model and client. */
|
|
7948
7787
|
async function resolveCodexUltrafastServiceTier(params) {
|
|
7949
7788
|
if (!params.enabled || params.modelProvider !== "openai" && params.modelProvider !== "openclaw_token_sharing" || !params.model) return params.serviceTier;
|
|
7950
7789
|
params.signal.throwIfAborted();
|
|
@@ -8045,7 +7884,7 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8045
7884
|
const assertTurnCurrent = () => {
|
|
8046
7885
|
connection.assertCurrent();
|
|
8047
7886
|
liveThreadOwnership?.assertCurrent();
|
|
8048
|
-
if (resourceState.thread !== selectedThread || selectedThread.threadId !== threadId || selectedThread.liveThreadOwnership !== liveThreadOwnership || selectedThread.model !== model || selectedThread.modelProvider !== modelProvider) throw new Error("Codex native model or thread ownership changed during turn start.");
|
|
7887
|
+
if (resourceState.client !== turnClient || resourceState.thread !== selectedThread || selectedThread.threadId !== threadId || selectedThread.liveThreadOwnership !== liveThreadOwnership || selectedThread.model !== model || selectedThread.modelProvider !== modelProvider) throw new Error("Codex native model or thread ownership changed during turn start.");
|
|
8049
7888
|
};
|
|
8050
7889
|
const fastMode = typeof runtimeParams.fastMode === "function" ? runtimeParams.fastMode() : runtimeParams.fastMode;
|
|
8051
7890
|
const turnAppServer = withCodexAppServerFastModeServiceTier(connection.mutable.pluginAppServer, { fastMode }, connection.appServer);
|
|
@@ -8066,8 +7905,6 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8066
7905
|
model: resourceState.thread.model,
|
|
8067
7906
|
modelProvider: resourceState.thread.modelProvider
|
|
8068
7907
|
},
|
|
8069
|
-
turnScopedDeveloperInstructions: workspaceBootstrapContext.turnScopedDeveloperInstructions,
|
|
8070
|
-
memoryCollaborationInstructions: workspaceBootstrapContext.memoryCollaborationInstructions,
|
|
8071
7908
|
preserveNativeTurnSettings: usesSupervisionConnection,
|
|
8072
7909
|
parentLocalEgress: inferenceRoute !== void 0,
|
|
8073
7910
|
messageToolAvailable: toolBridge.availableTools.some((tool) => tool.name === "message"),
|
|
@@ -8075,7 +7912,7 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8075
7912
|
sessionStatusAvailable: toolBridge.availableTools.some((tool) => tool.name === "session_status")
|
|
8076
7913
|
});
|
|
8077
7914
|
const serviceTier = await resolveCodexUltrafastServiceTier({
|
|
8078
|
-
enabled:
|
|
7915
|
+
enabled: fastMode === "ultrafast" && turnAppServer.enableUltrafast !== false,
|
|
8079
7916
|
serviceTier: turnStartParams.serviceTier,
|
|
8080
7917
|
model: turnStartParams.model ?? model,
|
|
8081
7918
|
modelProvider,
|
|
@@ -8117,14 +7954,14 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8117
7954
|
const registration = inferenceRoute.context.register({
|
|
8118
7955
|
threadId: resourceState.thread.threadId,
|
|
8119
7956
|
text: usesSupervisionConnection ? "" : buildCodexParentLocalInstructions(runtimeParams, {
|
|
8120
|
-
|
|
7957
|
+
personaInstructions: workspaceBootstrapContext.personaInstructions,
|
|
8121
7958
|
skillsInstructions: context.skillsInstructions,
|
|
8122
|
-
|
|
7959
|
+
memoryInstructions: workspaceBootstrapContext.memoryInstructions
|
|
8123
7960
|
}) ?? "",
|
|
8124
7961
|
signal: runAbortController.signal,
|
|
8125
7962
|
assertCurrent: () => {
|
|
8126
7963
|
params.hostCapabilities.assertActive();
|
|
8127
|
-
connection.
|
|
7964
|
+
connection.assertLegacyCurrent();
|
|
8128
7965
|
if (resourceState.thread !== inferenceThread || getCodexInferenceThread(resourceState.client, inferenceThread.threadId) !== inferenceRoute) throw new Error("Codex inference thread ownership changed");
|
|
8129
7966
|
inferenceThread.liveThreadOwnership?.assertCurrent();
|
|
8130
7967
|
}
|
|
@@ -8134,20 +7971,7 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8134
7971
|
...turnStartParams.responsesapiClientMetadata,
|
|
8135
7972
|
[CODEX_INFERENCE_GENERATION_KEY]: registration.generation
|
|
8136
7973
|
};
|
|
8137
|
-
} else if (
|
|
8138
|
-
embeddedAgentLog.warn("Codex parent-local egress workaround is unavailable for this connection or native network profile; legacy collaboration delivery is not guaranteed.");
|
|
8139
|
-
prompt.systemPromptReport.source = "estimate";
|
|
8140
|
-
prompt.systemPromptReport.injectedWorkspaceFiles = prompt.systemPromptReport.injectedWorkspaceFiles.map((file) => [
|
|
8141
|
-
"SOUL.MD",
|
|
8142
|
-
"IDENTITY.MD",
|
|
8143
|
-
"USER.MD"
|
|
8144
|
-
].includes(file.name.toUpperCase()) ? {
|
|
8145
|
-
...file,
|
|
8146
|
-
injectionStatus: "native_unverified",
|
|
8147
|
-
injectedChars: null,
|
|
8148
|
-
truncated: null
|
|
8149
|
-
} : file);
|
|
8150
|
-
}
|
|
7974
|
+
} else if (workspaceBootstrapContext.personaFiles?.some((file) => file.personalUser)) embeddedAgentLog.warn("Personal USER.md was omitted: this Codex connection has no parent-only inference relay. Shared workspace persona is still delivered.");
|
|
8151
7975
|
const continuation = await prepareCodexProviderReviewContinuation({
|
|
8152
7976
|
acknowledgment: params.providerReviewAcknowledgment,
|
|
8153
7977
|
client: resourceState.client,
|
|
@@ -8162,7 +7986,6 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8162
7986
|
codexModelCallDiagnostics.setRequestPayloadBytes(utf8JsonByteLength(turnStartParams));
|
|
8163
7987
|
recordCodexTrajectoryContext(resources.trajectoryRecorder, {
|
|
8164
7988
|
attempt: params,
|
|
8165
|
-
cwd: connection.effectiveCwd,
|
|
8166
7989
|
developerInstructions: joinPresentSections(buildRenderedCodexDeveloperInstructions(), attemptTools.configuredMcp?.diagnosticNotice),
|
|
8167
7990
|
prompt: turnState.codexTurnPromptText,
|
|
8168
7991
|
tools: toolBridge.availableSpecs
|
|
@@ -8187,6 +8010,7 @@ async function prepareCodexAttemptTurnRequest(resources, turnRuntime, ensureCurr
|
|
|
8187
8010
|
const startedTurn = assertCodexTurnStartResponse(await turnClient.request("turn/start", turnStartParams, {
|
|
8188
8011
|
timeoutMs: params.timeoutMs,
|
|
8189
8012
|
signal: runAbortController.signal,
|
|
8013
|
+
withCurrent: connection.withCurrent,
|
|
8190
8014
|
assertCurrent: () => {
|
|
8191
8015
|
assertTurnCurrent();
|
|
8192
8016
|
continuation?.dispatch();
|
|
@@ -8304,10 +8128,7 @@ async function startCodexAttemptTurn(resources, turnRuntime, notifications, requ
|
|
|
8304
8128
|
threadId: resourceState.thread.threadId,
|
|
8305
8129
|
error: formatErrorMessage(turnStartError)
|
|
8306
8130
|
});
|
|
8307
|
-
if (!await bindingStore.
|
|
8308
|
-
kind: "clear",
|
|
8309
|
-
threadId: resourceState.thread.threadId
|
|
8310
|
-
}, connection.assertCurrent)) embeddedAgentLog.warn("codex app-server preserved newer context-engine binding after resume overflow; skipping fresh retry", {
|
|
8131
|
+
if (!await clearCodexBindingForClient(bindingStore, bindingIdentity, resourceState.thread, connection.authority)) embeddedAgentLog.warn("codex app-server preserved newer context-engine binding after resume overflow; skipping fresh retry", {
|
|
8311
8132
|
threadId: resourceState.thread.threadId,
|
|
8312
8133
|
error: formatErrorMessage(turnStartError)
|
|
8313
8134
|
});
|
|
@@ -8342,8 +8163,9 @@ async function startCodexAttemptTurn(resources, turnRuntime, notifications, requ
|
|
|
8342
8163
|
if (!params.providerReviewAcknowledgment && isInvalidCodexImagePayloadError(message)) await clearCodexBindingAfterInvalidImagePayload(bindingStore, bindingIdentity, {
|
|
8343
8164
|
phase: "turn_start",
|
|
8344
8165
|
threadId: resourceState.thread.threadId,
|
|
8166
|
+
clientId: resourceState.thread.clientId,
|
|
8345
8167
|
error: message
|
|
8346
|
-
}, params.expectedSessionRuntimeOwnership);
|
|
8168
|
+
}, connection.authority, params.expectedSessionRuntimeOwnership);
|
|
8347
8169
|
emitCodexAppServerEvent(params, {
|
|
8348
8170
|
stream: "codex_app_server.lifecycle",
|
|
8349
8171
|
data: {
|
|
@@ -8587,6 +8409,7 @@ function createCodexAttemptTurnState(resources) {
|
|
|
8587
8409
|
//#endregion
|
|
8588
8410
|
//#region extensions/codex/src/app-server/run-attempt.ts
|
|
8589
8411
|
async function runCodexAppServerAttempt(params, options) {
|
|
8412
|
+
if (params.requireWorkspaceOnly === true && (params.disableTools === true || typeof params.hostCapabilities?.createToolSurface !== "function")) throw new Error("Codex required-root execution requires an enabled host-mediated tool surface");
|
|
8590
8413
|
const preparation = createCodexAttemptPreparationTiming(params);
|
|
8591
8414
|
const connection = await preparation.measure("connection", () => prepareCodexAttemptConnection({
|
|
8592
8415
|
params,
|
|
@@ -8626,6 +8449,7 @@ async function runCodexAppServerAttempt(params, options) {
|
|
|
8626
8449
|
await cleanupCodexAttempt(resources, turnRuntime, lifecycle, turnRequest, activeTurn);
|
|
8627
8450
|
}
|
|
8628
8451
|
} catch (error) {
|
|
8452
|
+
connection.assertModelExecutionCurrent();
|
|
8629
8453
|
if (!finalizedResult || !turnRuntime.state.pluginRuntimeRefreshStop) throw error;
|
|
8630
8454
|
const original = attemptTerminal.project(finalizedResult.terminal).promptError;
|
|
8631
8455
|
finalizedResult.terminal = attemptTerminal.merge(finalizedResult.terminal, {
|
|
@@ -8648,6 +8472,8 @@ async function runCodexAppServerAttempt(params, options) {
|
|
|
8648
8472
|
} finally {
|
|
8649
8473
|
await attemptTools.disposeTools(connection.runAbortController.signal.aborted ? "cancel" : "error");
|
|
8650
8474
|
}
|
|
8475
|
+
} catch (error) {
|
|
8476
|
+
throw codexPrewriteRejectionCause(error);
|
|
8651
8477
|
} finally {
|
|
8652
8478
|
connection.cancellation.dispose();
|
|
8653
8479
|
connection.releaseModelExecution();
|