@openclaw/codex 2026.9.5 → 2026.9.7
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 +2 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
- package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
- package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
- package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
- package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
- package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
- package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
- package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
- package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
- package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
- package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
- package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
- package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
- package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
- package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
- package/dist/.setup/compact-C2WamavS.mjs +776 -0
- package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
- package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
- package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
- package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
- package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
- package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
- package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
- package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
- package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
- package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
- package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
- package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
- package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
- package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
- package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
- package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
- package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
- package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
- package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
- package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
- package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
- package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
- package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
- package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
- package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
- package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
- package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
- package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
- package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
- package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
- package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
- package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
- package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
- package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
- package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
- package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
- package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
- package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
- package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
- package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
- package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
- package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
- package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
- package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
- package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
- package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
- package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
- package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
- package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
- package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
- package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
- package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
- package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
- package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
- package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
- package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
- package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
- package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
- package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
- package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
- package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
- package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
- package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
- package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
- package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
- package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
- package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
- package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
- package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
- package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
- package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
- package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
- package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
- package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
- package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
- package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
- package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
- package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
- package/dist/.setup/thread-lifecycle-DPflntEJ.mjs +2362 -0
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
- package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
- package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
- package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
- package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
- package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
- package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
- package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
- package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
- package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
- package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
- package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
- package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
- package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
- package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
- package/dist/api.js +25 -16
- package/dist/catalog-page-worker-entrypoint.js +12 -0
- package/dist/catalog-page.worker.js +9 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +50 -8
- package/dist/harness.js +344 -1
- package/dist/index.js +345 -346
- package/dist/media-understanding-provider.js +9 -22
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +16 -33
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +14 -2
- package/package.json +11 -7
- package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
- package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
- package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
- package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
- package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
- package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
- package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
- package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
- package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
- package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
- package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
- package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
- package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
- package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
- package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
- package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
- package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
- package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
- package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
- package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
- package/dist/.setup/version-CoqzXPgK.mjs +0 -12
|
@@ -1,30 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
import {
|
|
5
|
-
import { i as resolveCodexAppServerHomeScope, l as resolveCodexModelBackedReviewerPolicyContext } from "./config-options-
|
|
6
|
-
import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-
|
|
7
|
-
import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection } from "./binding-connection-
|
|
8
|
-
import { n as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { a as
|
|
1
|
+
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
2
|
+
import { v as sessionBindingIdentity } from "./session-binding-record-Oe9L-CNY.mjs";
|
|
3
|
+
import { c as shouldAutoApproveCodexAppServerApprovals, l as withMcpElicitationsApprovalPolicy, m as readCodexRequirementsToml, n as hasCodexMcpToolApprovalOverrides } from "./config-security-CE-FcGw9.mjs";
|
|
4
|
+
import { c as isCodexPairedNodeRemoteExecPlacementSandbox, d as readCodexPluginConfig, l as isCodexRemoteExecPlacementSandbox, u as isCodexSandboxExecServerEnabled } from "./config-parsing-b088LyhT.mjs";
|
|
5
|
+
import { i as resolveCodexAppServerHomeScope, l as resolveCodexModelBackedReviewerPolicyContext } from "./config-options-CzyWLTJt.mjs";
|
|
6
|
+
import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-B7-X2TgG.mjs";
|
|
7
|
+
import { i as resolveCodexBindingAppServerConnection, r as requireCodexSupervisionModelSelection } from "./binding-connection-DTtN1KrX.mjs";
|
|
8
|
+
import { n as canUseCodexModelBackedApprovalsReviewerForModel, r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-DKhXquav.mjs";
|
|
9
|
+
import { X as readRecentCodexRateLimits, b as withLeasedCodexAppServerClientStartSelectionRetry, c as getLeasedSharedCodexAppServerClient, m as releaseCodexAppServerClientLease, tt as resolveCodexAppServerPreparedAuthHandoff } from "./shared-client-DqyTMYug.mjs";
|
|
10
|
+
import { A as handleDynamicToolCallWithTimeout, B as resolveCodexToolAbortTerminalReason, P as resolveDynamicToolCallTimeoutMs, S as assertCodexTurnStartResponse, i as isCodexAppServerApprovalRequest, k as createCodexElicitationResponse, s as isCodexAppServerIndeterminateRequestCancellationError, w as readCodexDynamicToolCallParams, y as assertCodexThreadForkResponse, z as toCodexDynamicToolProtocolResponse } from "./client-N0JpgSzF.mjs";
|
|
11
|
+
import { f as terminateCodexBackgroundTerminals, p as unsubscribeCodexThreadBestEffort, s as interruptCodexTurnAndWaitBestEffort, u as retireUnsafeCodexTurnClientBestEffort } from "./attempt-client-cleanup-DOP-cW5j.mjs";
|
|
12
|
+
import { t as CodexEphemeralTurn } from "./ephemeral-turn-CDsPJOa2.mjs";
|
|
13
|
+
import { Ct as refreshCodexPluginAppApprovalPolicy, D as buildCodexNativeHookRelayConfig, M as resolveCodexNativeHookRelayEvents, N as resolveCodexNativeHookRelayTtlMs, O as buildCodexNativeHookRelayDisabledConfig, St as mergeCodexThreadConfigs, ft as resolveCodexDynamicToolsLoading, g as CODEX_NATIVE_PERSONALITY_NONE, p as resolveCodexWebSearchPlan, r as buildCodexRuntimeThreadConfig, y as resolveCodexAppServerThreadModelSelection } from "./thread-requests-B_bRnMGN.mjs";
|
|
14
|
+
import { S as resolveCodexAppServerReasoningEffort, o as buildCodexUserInput, r as buildCodexTemporalAdditionalContext, x as readCodexSupportedReasoningEfforts } from "./thread-lifecycle-DPflntEJ.mjs";
|
|
15
|
+
import { o as resolveCodexSessionBinding } from "./session-binding-DGCYAfvD.mjs";
|
|
16
|
+
import { a as refreshCodexThreadPolicy, i as assertCodexSupervisionThreadLineage, n as CodexThreadPolicyHandoffError } from "./thread-policy-DTd-DtkX.mjs";
|
|
17
|
+
import { t as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DjCz2eOw.mjs";
|
|
18
|
+
import { E as CodexNativeToolLifecycleProjector, a as emitDynamicToolStartedDiagnostic, b as createCodexNativePreToolUseFailureBuffer, c as buildDynamicTools, f as resolveCodexExternalSandboxPolicyForOpenClawSandbox, g as shouldRequireCodexSandboxExecServerEnvironment, h as shouldEnableCodexAppServerNativeToolSurface, i as emitDynamicToolErrorDiagnostic, m as resolveCodexSandboxEnvironmentSelection, o as emitDynamicToolTerminalDiagnostic, p as resolveCodexMessageToolProvider, r as routeCodexAppServerElicitationRequest, s as handleCodexAppServerApprovalRequest, t as createCodexDynamicToolBridge, v as ensureCodexSandboxExecServerEnvironment, y as releaseCodexSandboxExecServerEnvironment } from "./dynamic-tools-DzlsLUuS.mjs";
|
|
19
|
+
import { a as resolveCodexAppServerForModelProvider, i as resolveCodexSessionPermissionCwd, n as applyCodexSessionPermissionPolicy, r as resolveCodexEffectiveSessionPermissionPolicy, t as CODEX_SESSION_PERMISSION_EXEC_MODES } from "./session-permission-policy-Ci_fVX6y.mjs";
|
|
20
|
+
import { n as resolveCodexProviderWebSearchSupportForClient } from "./provider-capabilities-CAxoF-X1.mjs";
|
|
19
21
|
import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
20
22
|
import { randomUUID } from "node:crypto";
|
|
21
23
|
import { isDeepStrictEqual } from "node:util";
|
|
22
24
|
import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
25
|
+
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
23
26
|
import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
24
|
-
import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage
|
|
27
|
+
import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage as formatErrorMessage$1, resolveSandboxContext, runAgentCleanupStep } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
25
28
|
import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
26
29
|
import { loadCodexBundleMcpApprovalConfig, resolveCodexMcpToolOverridesForAgent } from "openclaw/plugin-sdk/codex-mcp-projection";
|
|
27
30
|
import { registerNativeHookRelayForBundledRuntime } from "openclaw/plugin-sdk/native-hook-relay-runtime";
|
|
31
|
+
//#region extensions/codex/src/app-server/side-question-cleanup.ts
|
|
32
|
+
async function cleanupCodexSideQuestion(client, params) {
|
|
33
|
+
const errors = [];
|
|
34
|
+
for (const cleanup of [() => cleanupCodexSideThread(client, params), ...params.afterThreadCleanup]) try {
|
|
35
|
+
const pending = cleanup();
|
|
36
|
+
if (pending) await pending;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
errors.push(error);
|
|
39
|
+
}
|
|
40
|
+
if (errors.length === 0) return;
|
|
41
|
+
if (params.failure) errors.unshift(params.failure.error);
|
|
42
|
+
if (errors.length === 1) throw errors[0];
|
|
43
|
+
throw new AggregateError(errors, errors.map(formatErrorMessage).join("; "), { cause: errors[0] });
|
|
44
|
+
}
|
|
45
|
+
async function cleanupCodexSideThread(client, params) {
|
|
46
|
+
if (!params.threadId) return;
|
|
47
|
+
if (params.interrupt && params.turnId !== void 0) {
|
|
48
|
+
if (!await interruptCodexTurnAndWaitBestEffort(client, {
|
|
49
|
+
threadId: params.threadId,
|
|
50
|
+
turnId: params.turnId,
|
|
51
|
+
timeoutMs: params.timeoutMs
|
|
52
|
+
})) {
|
|
53
|
+
await retireUnsafeCodexTurnClientBestEffort(client, "side turn interrupt");
|
|
54
|
+
throw new Error("Codex /btw cleanup could not confirm the side turn stopped; background terminals may still be running.");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (params.terminateBackgroundTerminals && params.turnId !== void 0) try {
|
|
58
|
+
await terminateCodexBackgroundTerminals(client, params.threadId);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
await retireUnsafeCodexTurnClientBestEffort(client, "side background terminals");
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
if (!await unsubscribeCodexThreadBestEffort(client, {
|
|
64
|
+
threadId: params.threadId,
|
|
65
|
+
timeoutMs: params.timeoutMs
|
|
66
|
+
})) await retireUnsafeCodexTurnClientBestEffort(client, "side thread unsubscribe");
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
28
69
|
//#region extensions/codex/src/app-server/side-question-instructions.ts
|
|
29
70
|
const SIDE_DEVELOPER_INSTRUCTIONS = `You are in a side conversation, not the main thread.
|
|
30
71
|
|
|
@@ -48,10 +89,6 @@ var CodexSideQuestionTimeoutError = class extends Error {
|
|
|
48
89
|
this.name = "TimeoutError";
|
|
49
90
|
}
|
|
50
91
|
};
|
|
51
|
-
const CODEX_SIDE_NATIVE_HOOK_RELAY_MIN_TTL_MS = 18e5;
|
|
52
|
-
const CODEX_SIDE_NATIVE_HOOK_RELAY_TTL_GRACE_MS = 3e5;
|
|
53
|
-
const CODEX_SIDE_NATIVE_HOOK_RELAY_STARTUP_REQUEST_COUNT = 3;
|
|
54
|
-
const CODEX_SIDE_NATIVE_HOOK_RELAY_EVENTS_WITH_APP_SERVER_APPROVALS = CODEX_NATIVE_HOOK_RELAY_EVENTS.filter((event) => event !== "permission_request");
|
|
55
92
|
async function runCodexAppServerSideQuestion(params, options) {
|
|
56
93
|
const bindingIdentity = sessionBindingIdentity({
|
|
57
94
|
sessionId: params.sessionId,
|
|
@@ -103,26 +140,6 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
103
140
|
subscriptionProfileRequiredError: "Prepared Codex subscription route requires a scoped native OAuth or token profile.",
|
|
104
141
|
subscriptionProfileUnusableError: `Prepared Codex auth profile "${preparedRuntimeAuth.plan.forwardedAuthProfileId}" is unusable.`
|
|
105
142
|
});
|
|
106
|
-
const modelProvider = supervisionModelSelection ? supervisionModelSelection.modelProvider : resolveCodexAppServerModelProvider({
|
|
107
|
-
provider: params.provider,
|
|
108
|
-
authProfileId,
|
|
109
|
-
authProfileStore: preparedRuntimeAuth.authProfileStore,
|
|
110
|
-
agentDir: params.agentDir,
|
|
111
|
-
config: params.cfg
|
|
112
|
-
}) ?? resolveCodexBindingModelProviderFallback({
|
|
113
|
-
provider: params.provider,
|
|
114
|
-
currentModel: params.model,
|
|
115
|
-
bindingModel: binding.model,
|
|
116
|
-
bindingModelProvider: binding.modelProvider
|
|
117
|
-
});
|
|
118
|
-
const modelSelection = resolveCodexAppServerRequestModelSelection({
|
|
119
|
-
model: supervisionModelSelection?.model ?? options.runtimeModelId ?? params.model,
|
|
120
|
-
modelProvider,
|
|
121
|
-
authProfileId,
|
|
122
|
-
authProfileStore: preparedRuntimeAuth.authProfileStore,
|
|
123
|
-
agentDir: params.agentDir,
|
|
124
|
-
config: params.cfg
|
|
125
|
-
});
|
|
126
143
|
const reviewerPolicyContext = resolveCodexModelBackedReviewerPolicyContext({
|
|
127
144
|
provider: usesSupervisionConnection ? "codex" : params.provider,
|
|
128
145
|
model: supervisionModelSelection?.model ?? params.model,
|
|
@@ -163,6 +180,18 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
163
180
|
...reviewerContext,
|
|
164
181
|
provider: reviewerContext.modelProvider
|
|
165
182
|
});
|
|
183
|
+
const modelSelection = supervisionModelSelection ?? resolveCodexAppServerThreadModelSelection({
|
|
184
|
+
homeScope: appServer.start.homeScope,
|
|
185
|
+
provider: params.provider,
|
|
186
|
+
model: params.model,
|
|
187
|
+
requestModel: options.runtimeModelId ?? params.model,
|
|
188
|
+
binding,
|
|
189
|
+
inheritBindingAuthProfile: false,
|
|
190
|
+
authProfileId,
|
|
191
|
+
authProfileStore: preparedRuntimeAuth.authProfileStore,
|
|
192
|
+
agentDir: params.agentDir,
|
|
193
|
+
config: params.cfg
|
|
194
|
+
});
|
|
166
195
|
const sessionPermissionPolicy = resolveCodexEffectiveSessionPermissionPolicy({
|
|
167
196
|
appServer,
|
|
168
197
|
permissionMode: params.sessionEntry.permissionMode,
|
|
@@ -241,31 +270,14 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
241
270
|
let collector;
|
|
242
271
|
const runAbortController = new AbortController();
|
|
243
272
|
let nativeToolLifecycleProjector;
|
|
244
|
-
const pendingNativePreToolUseFailures = [];
|
|
245
|
-
let nativePreToolUseFailureFallbackActive = false;
|
|
246
273
|
let nativeToolRunWasAbortedBeforeCleanup;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
signal: runAbortController.signal,
|
|
255
|
-
failure,
|
|
256
|
-
...nativePreToolUseFailureFallbackActive ? { terminalReason: nativePreToolUseFailureFallbackTerminalReason ?? failure.disposition } : {}
|
|
257
|
-
});
|
|
258
|
-
};
|
|
259
|
-
const flushPendingNativePreToolUseFailures = () => {
|
|
260
|
-
for (const failure of pendingNativePreToolUseFailures.splice(0)) emitNativePreToolUseFailure(failure);
|
|
261
|
-
};
|
|
262
|
-
const activateNativePreToolUseFailureFallback = () => {
|
|
263
|
-
if (!nativePreToolUseFailureFallbackActive) {
|
|
264
|
-
nativePreToolUseFailureFallbackTerminalReason = nativeToolRunWasAbortedBeforeCleanup ? resolveCodexToolAbortTerminalReason(runAbortController.signal) : void 0;
|
|
265
|
-
nativePreToolUseFailureFallbackActive = true;
|
|
266
|
-
}
|
|
267
|
-
flushPendingNativePreToolUseFailures();
|
|
268
|
-
};
|
|
274
|
+
const nativePreToolUseFailures = createCodexNativePreToolUseFailureBuffer({
|
|
275
|
+
agentId: sessionAgentId,
|
|
276
|
+
sessionId: params.sessionId,
|
|
277
|
+
sessionKey: params.sessionKey,
|
|
278
|
+
runId: sideRunParams.runId,
|
|
279
|
+
signal: runAbortController.signal
|
|
280
|
+
});
|
|
269
281
|
const abortFromUpstream = () => runAbortController.abort(params.opts?.abortSignal?.reason ?? "codex_side_question_abort");
|
|
270
282
|
if (params.opts?.abortSignal?.aborted) abortFromUpstream();
|
|
271
283
|
else params.opts?.abortSignal?.addEventListener("abort", abortFromUpstream, { once: true });
|
|
@@ -279,6 +291,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
279
291
|
let sandboxEnvironmentClient;
|
|
280
292
|
let nativeHookRelay;
|
|
281
293
|
const activeDynamicToolCalls = /* @__PURE__ */ new Set();
|
|
294
|
+
let primaryFailure;
|
|
282
295
|
const releaseSandboxEnvironment = async () => {
|
|
283
296
|
if (!sandboxEnvironment) return;
|
|
284
297
|
const environment = sandboxEnvironment;
|
|
@@ -318,40 +331,31 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
318
331
|
toolOverrides: params.sessionEntry.toolOverrides
|
|
319
332
|
})
|
|
320
333
|
});
|
|
321
|
-
const approvalPolicy = hasCodexMcpToolApprovalOverrides(params.cfg?.mcp?.servers, Object.keys(projectedMcpServers), projectedMcpServers) ? withMcpElicitationsApprovalPolicy(appServer.approvalPolicy) : appServer.approvalPolicy;
|
|
334
|
+
const approvalPolicy = Object.keys(binding.pluginAppPolicyContext?.apps ?? {}).length > 0 || hasCodexMcpToolApprovalOverrides(params.cfg?.mcp?.servers, Object.keys(projectedMcpServers), projectedMcpServers) ? withMcpElicitationsApprovalPolicy(appServer.approvalPolicy) : appServer.approvalPolicy;
|
|
322
335
|
const sandbox = appServer.sandbox;
|
|
336
|
+
const nativeProviderWebSearchSupport = resolveCodexWebSearchPlan({
|
|
337
|
+
config: params.cfg,
|
|
338
|
+
nativeToolSurfaceEnabled
|
|
339
|
+
}).kind === "native-hosted" ? await resolveCodexProviderWebSearchSupportForClient({
|
|
340
|
+
client,
|
|
341
|
+
timeoutMs: appServer.requestTimeoutMs,
|
|
342
|
+
modelProviderOverride: modelSelection.modelProvider,
|
|
343
|
+
signal: runAbortController.signal
|
|
344
|
+
}) : "unsupported";
|
|
323
345
|
const { toolBridge, webSearchPlan } = await createCodexSideToolBridge({
|
|
324
|
-
params:
|
|
346
|
+
params: sideRunParams,
|
|
325
347
|
cwd,
|
|
348
|
+
resolvedWorkspace: effectiveParams.workspaceDir ?? cwd,
|
|
326
349
|
pluginConfig,
|
|
327
350
|
sessionAgentId,
|
|
328
351
|
nativeToolSurfaceEnabled,
|
|
329
|
-
nativeProviderWebSearchSupport
|
|
330
|
-
config: params.cfg,
|
|
331
|
-
nativeToolSurfaceEnabled
|
|
332
|
-
}).kind === "native-hosted" ? await resolveCodexProviderWebSearchSupportForClient({
|
|
333
|
-
client,
|
|
334
|
-
timeoutMs: appServer.requestTimeoutMs,
|
|
335
|
-
modelProviderOverride: modelSelection.modelProvider,
|
|
336
|
-
signal: runAbortController.signal
|
|
337
|
-
}) : "unsupported",
|
|
352
|
+
nativeProviderWebSearchSupport,
|
|
338
353
|
sessionPermissionPolicy,
|
|
339
|
-
|
|
340
|
-
signal: runAbortController.signal
|
|
341
|
-
});
|
|
342
|
-
ensureCodexAppServerClientRuntime(client, {
|
|
343
|
-
agentDir: params.agentDir,
|
|
344
|
-
authProfileId: startupPreparedAuth?.kind === "api-key" ? void 0 : connection.requestAuthProfileId,
|
|
345
|
-
...!usesSupervisionConnection ? {
|
|
346
|
-
authProfileStore: preparedRuntimeAuth.authProfileStore,
|
|
347
|
-
authMode: startupPreparedAuth?.kind === "api-key" ? "prepared-api-key" : "profile"
|
|
348
|
-
} : {},
|
|
349
|
-
config: params.cfg
|
|
354
|
+
runAbortController
|
|
350
355
|
});
|
|
351
356
|
const handleServerRequest = async (request, _scope, requestSignal, setExecutionTimeoutMs) => {
|
|
352
357
|
const signal = AbortSignal.any([requestSignal, runAbortController.signal]);
|
|
353
|
-
if (signal.aborted) return;
|
|
354
|
-
if (!childThreadId || !turnId) return;
|
|
358
|
+
if (signal.aborted || !childThreadId || !turnId) return;
|
|
355
359
|
if (request.method === "mcpServer/elicitation/request") {
|
|
356
360
|
const approvalResult = await routeCodexAppServerElicitationRequest({
|
|
357
361
|
requestParams: request.params,
|
|
@@ -366,7 +370,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
366
370
|
});
|
|
367
371
|
return approvalResult.kind === "handled" ? approvalResult.response : createCodexElicitationResponse("decline", null, { message: "OpenClaw Codex side questions do not support interactive MCP input." });
|
|
368
372
|
}
|
|
369
|
-
if (request.method === "item/tool/requestUserInput") return isSideUserInputRequest(request.params, childThreadId, turnId) ?
|
|
373
|
+
if (request.method === "item/tool/requestUserInput") return isSideUserInputRequest(request.params, childThreadId, turnId) ? { answers: {} } : void 0;
|
|
370
374
|
if (isCodexAppServerApprovalRequest(request.method)) return handleCodexAppServerApprovalRequest({
|
|
371
375
|
method: request.method,
|
|
372
376
|
requestParams: request.params,
|
|
@@ -411,10 +415,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
411
415
|
response,
|
|
412
416
|
durationMs: Math.max(0, Date.now() - toolStartedAt)
|
|
413
417
|
});
|
|
414
|
-
return
|
|
415
|
-
contentItems: response.contentItems,
|
|
416
|
-
success: response.success
|
|
417
|
-
};
|
|
418
|
+
return toCodexDynamicToolProtocolResponse(response);
|
|
418
419
|
} catch (error) {
|
|
419
420
|
emitDynamicToolErrorDiagnostic({
|
|
420
421
|
...diagnosticContext,
|
|
@@ -426,47 +427,46 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
426
427
|
activeDynamicToolCalls.delete(toolCall);
|
|
427
428
|
}
|
|
428
429
|
};
|
|
429
|
-
const selectClient = (nextClient) => {
|
|
430
|
-
client = nextClient;
|
|
431
|
-
ensureCodexAppServerClientRuntime(client, {
|
|
432
|
-
agentDir: params.agentDir,
|
|
433
|
-
authProfileId: connection.requestAuthProfileId,
|
|
434
|
-
config: params.cfg
|
|
435
|
-
});
|
|
436
|
-
};
|
|
437
430
|
const serviceTier = binding.serviceTier ?? appServer.serviceTier;
|
|
438
|
-
const nativeHookRelayEvents =
|
|
431
|
+
const nativeHookRelayEvents = resolveCodexNativeHookRelayEvents({
|
|
439
432
|
configuredEvents: options.nativeHookRelay?.events,
|
|
440
|
-
|
|
433
|
+
appServer
|
|
441
434
|
});
|
|
442
|
-
nativeHookRelay
|
|
443
|
-
|
|
444
|
-
events: nativeHookRelayEvents,
|
|
445
|
-
agentId: sessionAgentId,
|
|
446
|
-
sessionId: params.sessionId,
|
|
447
|
-
sessionKey: params.sessionKey,
|
|
448
|
-
config: params.cfg,
|
|
449
|
-
autoApproveMcpTools,
|
|
450
|
-
projectedMcpServers,
|
|
451
|
-
runId: sideRunParams.runId,
|
|
452
|
-
channelId: buildAgentHookContextChannelFields({
|
|
435
|
+
if (options.nativeHookRelay && options.nativeHookRelay.enabled !== false) {
|
|
436
|
+
const channelId = buildAgentHookContextChannelFields({
|
|
453
437
|
sessionKey: params.sessionKey,
|
|
454
438
|
messageChannel: params.messageChannel,
|
|
455
439
|
messageProvider: params.messageProvider,
|
|
456
440
|
currentChannelId: params.currentChannelId
|
|
457
|
-
}).channelId
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
441
|
+
}).channelId;
|
|
442
|
+
nativeHookRelay = registerNativeHookRelayForBundledRuntime({
|
|
443
|
+
provider: "codex",
|
|
444
|
+
...sessionAgentId ? { agentId: sessionAgentId } : {},
|
|
445
|
+
sessionId: params.sessionId,
|
|
446
|
+
...params.sessionKey ? { sessionKey: params.sessionKey } : {},
|
|
447
|
+
...params.cfg ? { config: params.cfg } : {},
|
|
448
|
+
autoApproveMcpTools,
|
|
449
|
+
projectedMcpServers,
|
|
450
|
+
runId: sideRunParams.runId,
|
|
451
|
+
...channelId ? { channelId } : {},
|
|
452
|
+
allowedEvents: nativeHookRelayEvents,
|
|
453
|
+
preToolUseLoopDetection: appServer.loopDetectionPreToolUseRelay,
|
|
454
|
+
ttlMs: resolveCodexNativeHookRelayTtlMs({
|
|
455
|
+
explicitTtlMs: options.nativeHookRelay.ttlMs,
|
|
456
|
+
attemptTimeoutMs: SIDE_QUESTION_COMPLETION_TIMEOUT_MS,
|
|
457
|
+
startupTimeoutMs: appServer.requestTimeoutMs * 2,
|
|
458
|
+
turnStartTimeoutMs: appServer.requestTimeoutMs
|
|
459
|
+
}),
|
|
460
|
+
signal: runAbortController.signal,
|
|
461
|
+
runBeforeToolCall: sideRunParams.hostCapabilities.runBeforeToolCall,
|
|
462
|
+
assertActive: assertCurrent,
|
|
463
|
+
onPreToolUseFailure: (failure) => {
|
|
464
|
+
if (!nativePreToolUseFailures.active && nativeToolLifecycleProjector) nativeToolLifecycleProjector.recordPreToolUseFailure(failure, nativeToolRunWasAbortedBeforeCleanup);
|
|
465
|
+
else nativePreToolUseFailures.record(failure);
|
|
466
|
+
},
|
|
467
|
+
command: { timeoutMs: options.nativeHookRelay.gatewayTimeoutMs }
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
470
|
await nativeHookRelay?.prepareInvocation();
|
|
471
471
|
assertCurrent();
|
|
472
472
|
const nativeHookRelayConfig = nativeHookRelay ? buildCodexNativeHookRelayConfig({
|
|
@@ -580,7 +580,9 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
580
580
|
}
|
|
581
581
|
return response.thread.id;
|
|
582
582
|
}),
|
|
583
|
-
onClientChange:
|
|
583
|
+
onClientChange: (nextClient) => {
|
|
584
|
+
client = nextClient;
|
|
585
|
+
}
|
|
584
586
|
});
|
|
585
587
|
const effort = usesSupervisionConnection ? void 0 : resolveCodexAppServerReasoningEffort({
|
|
586
588
|
thinkLevel: params.resolvedThinkLevel ?? "off",
|
|
@@ -624,8 +626,8 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
624
626
|
...sideRunParams,
|
|
625
627
|
agentId: sessionAgentId
|
|
626
628
|
}, sideThreadId, turnId, { runAbortSignal: runAbortController.signal });
|
|
627
|
-
for (const failure of
|
|
628
|
-
|
|
629
|
+
for (const failure of nativePreToolUseFailures.pending) nativeToolLifecycleProjector.recordPreToolUseFailure(failure);
|
|
630
|
+
nativePreToolUseFailures.pending.length = 0;
|
|
629
631
|
if (!collector) throw new Error("Codex side thread route was not reserved");
|
|
630
632
|
let result;
|
|
631
633
|
try {
|
|
@@ -652,36 +654,33 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
652
654
|
text: result.text,
|
|
653
655
|
usage: result.usage
|
|
654
656
|
};
|
|
657
|
+
} catch (error) {
|
|
658
|
+
primaryFailure = { error };
|
|
659
|
+
throw error;
|
|
655
660
|
} finally {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
try {
|
|
680
|
-
await releaseSandboxEnvironment();
|
|
681
|
-
} finally {
|
|
682
|
-
releaseCodexAppServerClientLease(clientLease);
|
|
683
|
-
nativeHookRelay?.unregister();
|
|
684
|
-
await runAgentCleanupStep({
|
|
661
|
+
nativeToolRunWasAbortedBeforeCleanup = runAbortController.signal.aborted;
|
|
662
|
+
params.opts?.abortSignal?.removeEventListener("abort", abortFromUpstream);
|
|
663
|
+
if (!runAbortController.signal.aborted) runAbortController.abort("codex_side_question_finished");
|
|
664
|
+
await Promise.allSettled(activeDynamicToolCalls);
|
|
665
|
+
await cleanupCodexSideQuestion(childClient ?? client, {
|
|
666
|
+
threadId: childThreadId,
|
|
667
|
+
turnId,
|
|
668
|
+
interrupt: !(collector?.completed || collector?.route.completed),
|
|
669
|
+
terminateBackgroundTerminals: nativeToolRunWasAbortedBeforeCleanup,
|
|
670
|
+
timeoutMs: appServer.requestTimeoutMs,
|
|
671
|
+
failure: primaryFailure,
|
|
672
|
+
afterThreadCleanup: [
|
|
673
|
+
async () => {
|
|
674
|
+
if (policyWriteUncertain && childClient) await retireUnsafeCodexTurnClientBestEffort(childClient, "side policy handoff");
|
|
675
|
+
},
|
|
676
|
+
() => collector?.route.release(),
|
|
677
|
+
() => nativeToolLifecycleProjector?.finalizeActive(nativeToolRunWasAbortedBeforeCleanup),
|
|
678
|
+
() => nativePreToolUseFailures.activateFallback(nativeToolRunWasAbortedBeforeCleanup === true),
|
|
679
|
+
nativePreToolUseFailures.flush,
|
|
680
|
+
releaseSandboxEnvironment,
|
|
681
|
+
() => releaseCodexAppServerClientLease(clientLease),
|
|
682
|
+
() => nativeHookRelay?.unregister(),
|
|
683
|
+
() => runAgentCleanupStep({
|
|
685
684
|
runId: sideRunParams.runId,
|
|
686
685
|
sessionId: sideRunParams.sessionId,
|
|
687
686
|
step: "codex-side-native-hook-relay-release",
|
|
@@ -689,46 +688,11 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
689
688
|
cleanup: async () => {
|
|
690
689
|
await nativeHookRelay?.drain();
|
|
691
690
|
}
|
|
692
|
-
})
|
|
693
|
-
|
|
694
|
-
}
|
|
691
|
+
})
|
|
692
|
+
]
|
|
693
|
+
});
|
|
695
694
|
}
|
|
696
695
|
}
|
|
697
|
-
function resolveCodexSideNativeHookRelayEvents(params) {
|
|
698
|
-
if (params.configuredEvents?.length) return params.configuredEvents;
|
|
699
|
-
return params.approvalPolicy === "never" ? CODEX_NATIVE_HOOK_RELAY_EVENTS : CODEX_SIDE_NATIVE_HOOK_RELAY_EVENTS_WITH_APP_SERVER_APPROVALS;
|
|
700
|
-
}
|
|
701
|
-
function registerCodexSideNativeHookRelay(params) {
|
|
702
|
-
if (params.options.enabled === false) return;
|
|
703
|
-
return registerNativeHookRelayForBundledRuntime({
|
|
704
|
-
provider: "codex",
|
|
705
|
-
...params.agentId ? { agentId: params.agentId } : {},
|
|
706
|
-
sessionId: params.sessionId,
|
|
707
|
-
...params.sessionKey ? { sessionKey: params.sessionKey } : {},
|
|
708
|
-
...params.config ? { config: params.config } : {},
|
|
709
|
-
autoApproveMcpTools: params.autoApproveMcpTools,
|
|
710
|
-
projectedMcpServers: params.projectedMcpServers,
|
|
711
|
-
runId: params.runId,
|
|
712
|
-
...params.channelId ? { channelId: params.channelId } : {},
|
|
713
|
-
allowedEvents: params.events,
|
|
714
|
-
preToolUseLoopDetection: params.loopDetectionPreToolUseRelay,
|
|
715
|
-
ttlMs: resolveCodexSideNativeHookRelayTtlMs({
|
|
716
|
-
explicitTtlMs: params.options.ttlMs,
|
|
717
|
-
requestTimeoutMs: params.requestTimeoutMs,
|
|
718
|
-
completionTimeoutMs: params.completionTimeoutMs
|
|
719
|
-
}),
|
|
720
|
-
signal: params.signal,
|
|
721
|
-
runBeforeToolCall: params.hostCapabilities.runBeforeToolCall,
|
|
722
|
-
assertActive: params.assertCurrent,
|
|
723
|
-
onPreToolUseFailure: params.onPreToolUseFailure,
|
|
724
|
-
command: { timeoutMs: params.options.gatewayTimeoutMs }
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
function resolveCodexSideNativeHookRelayTtlMs(params) {
|
|
728
|
-
if (params.explicitTtlMs !== void 0) return params.explicitTtlMs;
|
|
729
|
-
const relayBudgetMs = params.requestTimeoutMs * CODEX_SIDE_NATIVE_HOOK_RELAY_STARTUP_REQUEST_COUNT + params.completionTimeoutMs + CODEX_SIDE_NATIVE_HOOK_RELAY_TTL_GRACE_MS;
|
|
730
|
-
return Math.max(CODEX_SIDE_NATIVE_HOOK_RELAY_MIN_TTL_MS, Math.floor(relayBudgetMs));
|
|
731
|
-
}
|
|
732
696
|
function buildSideRunAttemptParams(params, options) {
|
|
733
697
|
return {
|
|
734
698
|
params,
|
|
@@ -784,144 +748,69 @@ function buildSideRunAttemptParams(params, options) {
|
|
|
784
748
|
},
|
|
785
749
|
onBlockReply: params.opts?.onBlockReply,
|
|
786
750
|
onPartialReply: params.opts?.onPartialReply,
|
|
751
|
+
onToolResult: params.opts?.onToolResult,
|
|
752
|
+
requireExplicitMessageTarget: true,
|
|
787
753
|
hostCapabilities: params.hostCapabilities,
|
|
788
754
|
sandbox: params.sandbox
|
|
789
755
|
};
|
|
790
756
|
}
|
|
791
757
|
async function createCodexSideToolBridge(input) {
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
requesterModel: input.params.runtimeModel ? {
|
|
819
|
-
provider: input.params.runtimeModel.provider,
|
|
820
|
-
model: input.params.runtimeModel.id
|
|
821
|
-
} : void 0,
|
|
822
|
-
sessionKey: sandboxSessionKey,
|
|
823
|
-
runSessionKey: input.params.sessionKey && input.params.sessionKey !== sandboxSessionKey ? input.params.sessionKey : void 0,
|
|
824
|
-
sessionId: input.params.sessionId,
|
|
825
|
-
exec: input.sessionPermissionPolicy && { mode: input.sessionPermissionPolicy.execMode },
|
|
826
|
-
sessionPermissionPolicy: input.sessionPermissionPolicy,
|
|
827
|
-
runId: input.runId,
|
|
828
|
-
agentDir: input.params.agentDir ?? resolveAgentDir$2(input.params.cfg ?? {}, input.sessionAgentId),
|
|
829
|
-
workspaceDir: input.cwd,
|
|
830
|
-
spawnWorkspaceDir: resolveAttemptSpawnWorkspaceDir({
|
|
831
|
-
sandbox,
|
|
832
|
-
resolvedWorkspace: input.params.workspaceDir ?? input.cwd
|
|
833
|
-
}),
|
|
834
|
-
config: input.params.cfg,
|
|
835
|
-
preparedModelRuntime: input.params.preparedModelRuntime,
|
|
836
|
-
abortSignal: input.signal,
|
|
837
|
-
modelProvider: runtimeModel.provider,
|
|
838
|
-
modelId: input.params.model,
|
|
839
|
-
modelCompat: runtimeModel.compat && typeof runtimeModel.compat === "object" ? runtimeModel.compat : void 0,
|
|
840
|
-
modelApi: runtimeModel.api,
|
|
841
|
-
modelContextWindowTokens: runtimeModel.contextWindow,
|
|
842
|
-
modelAuthMode: resolveModelAuthMode(runtimeModel.provider, input.params.cfg, void 0, { workspaceDir: input.cwd }),
|
|
843
|
-
suppressManagedWebSearch: false,
|
|
844
|
-
webFetchHostnameAllowlistRef,
|
|
845
|
-
...input.params.messageProvider || input.params.messageChannel ? {
|
|
846
|
-
messageProvider: messageToolProvider,
|
|
847
|
-
toolPolicyMessageProvider: input.params.messageProvider ?? input.params.messageChannel
|
|
848
|
-
} : {},
|
|
849
|
-
...input.params.chatType ? { chatType: input.params.chatType } : {},
|
|
850
|
-
...input.params.agentAccountId ? { agentAccountId: input.params.agentAccountId } : {},
|
|
851
|
-
...input.params.messageTo ? { messageTo: input.params.messageTo } : {},
|
|
852
|
-
...input.params.messageThreadId !== void 0 ? { messageThreadId: input.params.messageThreadId } : {},
|
|
853
|
-
...input.params.chatId ? { nativeChannelId: input.params.chatId } : {},
|
|
854
|
-
...input.params.messageActionTurnCapability ? { messageActionTurnCapability: input.params.messageActionTurnCapability } : {},
|
|
855
|
-
...input.params.groupId !== void 0 ? { groupId: input.params.groupId } : {},
|
|
856
|
-
...input.params.groupChannel !== void 0 ? { groupChannel: input.params.groupChannel } : {},
|
|
857
|
-
...input.params.groupSpace !== void 0 ? { groupSpace: input.params.groupSpace } : {},
|
|
858
|
-
...input.params.memberRoleIds ? { memberRoleIds: input.params.memberRoleIds } : {},
|
|
859
|
-
...input.params.spawnedBy !== void 0 ? { spawnedBy: input.params.spawnedBy } : {},
|
|
860
|
-
...input.params.senderId !== void 0 ? { senderId: input.params.senderId } : {},
|
|
861
|
-
...input.params.senderName !== void 0 ? { senderName: input.params.senderName } : {},
|
|
862
|
-
...input.params.senderUsername !== void 0 ? { senderUsername: input.params.senderUsername } : {},
|
|
863
|
-
...input.params.senderE164 !== void 0 ? { senderE164: input.params.senderE164 } : {},
|
|
864
|
-
...input.params.senderIsOwner !== void 0 ? { senderIsOwner: input.params.senderIsOwner } : {},
|
|
865
|
-
...input.params.currentChannelId ? { currentChannelId: input.params.currentChannelId } : {},
|
|
866
|
-
hookChannelId: buildAgentHookContextChannelFields({
|
|
867
|
-
sessionKey: input.params.sessionKey,
|
|
868
|
-
messageChannel: input.params.messageChannel,
|
|
869
|
-
messageProvider: input.params.messageProvider,
|
|
870
|
-
currentChannelId: input.params.currentChannelId
|
|
871
|
-
}).channelId,
|
|
872
|
-
sandbox,
|
|
873
|
-
...toolConstructionPlan ? { toolConstructionPlan } : {},
|
|
874
|
-
...questionPrompt ? { questionPrompt } : {},
|
|
875
|
-
emitBeforeToolCallDiagnostics: false,
|
|
876
|
-
modelHasVision: runtimeModel.input?.includes("image") ?? false,
|
|
877
|
-
requireExplicitMessageTarget: true
|
|
878
|
-
});
|
|
879
|
-
const codexFilteredTools = filterCodexDynamicTools(allTools, input.pluginConfig);
|
|
880
|
-
tools = filterCodexVisionTools(codexFilteredTools, {
|
|
881
|
-
modelHasVision: runtimeModel.input?.includes("image") ?? false,
|
|
882
|
-
nativeImageInspectionEnabled: input.nativeToolSurfaceEnabled
|
|
883
|
-
});
|
|
884
|
-
}
|
|
758
|
+
const { params } = input;
|
|
759
|
+
const sandboxSessionKey = params.sandboxSessionKey?.trim() || params.sessionKey?.trim() || params.sessionId || input.sessionAgentId;
|
|
760
|
+
const sandbox = params.sandbox !== void 0 ? params.sandbox : await resolveSandboxContext({
|
|
761
|
+
config: params.config,
|
|
762
|
+
sessionKey: sandboxSessionKey,
|
|
763
|
+
workspaceDir: input.cwd
|
|
764
|
+
});
|
|
765
|
+
let webSearchAllowed = false;
|
|
766
|
+
const tools = await buildDynamicTools({
|
|
767
|
+
params,
|
|
768
|
+
resolvedWorkspace: input.resolvedWorkspace,
|
|
769
|
+
effectiveWorkspace: input.cwd,
|
|
770
|
+
sandboxSessionKey,
|
|
771
|
+
sandbox,
|
|
772
|
+
nativeToolSurfaceEnabled: input.nativeToolSurfaceEnabled,
|
|
773
|
+
nativeProviderWebSearchSupport: input.nativeProviderWebSearchSupport,
|
|
774
|
+
sessionPermissionPolicy: input.sessionPermissionPolicy,
|
|
775
|
+
runAbortController: input.runAbortController,
|
|
776
|
+
sessionAgentId: input.sessionAgentId,
|
|
777
|
+
policyAgentId: input.sessionAgentId,
|
|
778
|
+
pluginConfig: input.pluginConfig,
|
|
779
|
+
onYieldDetected: () => {},
|
|
780
|
+
onWebSearchPolicyResolved: (allowed) => {
|
|
781
|
+
webSearchAllowed = allowed;
|
|
782
|
+
}
|
|
783
|
+
});
|
|
885
784
|
const requestedWebSearchPlan = resolveCodexWebSearchPlan({
|
|
886
|
-
config:
|
|
785
|
+
config: params.config,
|
|
887
786
|
nativeToolSurfaceEnabled: input.nativeToolSurfaceEnabled,
|
|
888
787
|
nativeProviderWebSearchSupport: input.nativeProviderWebSearchSupport,
|
|
889
|
-
webSearchAllowed
|
|
788
|
+
webSearchAllowed
|
|
890
789
|
});
|
|
891
|
-
webFetchHostnameAllowlistRef.value = requestedWebSearchPlan.webFetchHostnameAllowlist;
|
|
892
790
|
const webSearchPlan = requestedWebSearchPlan.kind === "managed" ? resolveCodexWebSearchPlan({
|
|
893
|
-
config:
|
|
791
|
+
config: params.config,
|
|
894
792
|
webSearchAllowed: false
|
|
895
793
|
}) : requestedWebSearchPlan;
|
|
896
|
-
const exposedTools =
|
|
897
|
-
const hookChannelFields = buildAgentHookContextChannelFields({
|
|
898
|
-
sessionKey: input.params.sessionKey,
|
|
899
|
-
messageChannel: input.params.messageChannel,
|
|
900
|
-
messageProvider: input.params.messageProvider,
|
|
901
|
-
currentChannelId: input.params.currentChannelId
|
|
902
|
-
});
|
|
794
|
+
const exposedTools = tools.filter((tool) => tool.name !== "web_search" && tool.name !== "computer");
|
|
903
795
|
return {
|
|
904
796
|
toolBridge: createCodexDynamicToolBridge({
|
|
905
797
|
tools: exposedTools,
|
|
906
|
-
signal: input.signal,
|
|
798
|
+
signal: input.runAbortController.signal,
|
|
907
799
|
loading: resolveCodexDynamicToolsLoading(input.pluginConfig),
|
|
908
800
|
hookContext: {
|
|
909
801
|
agentId: input.sessionAgentId,
|
|
910
|
-
config:
|
|
911
|
-
contextWindowTokens:
|
|
912
|
-
sessionId:
|
|
913
|
-
sessionKey:
|
|
914
|
-
runId:
|
|
915
|
-
currentChannelProvider:
|
|
916
|
-
...
|
|
802
|
+
config: params.config,
|
|
803
|
+
contextWindowTokens: params.model.contextWindow,
|
|
804
|
+
sessionId: params.sessionId,
|
|
805
|
+
sessionKey: params.sessionKey,
|
|
806
|
+
runId: params.runId,
|
|
807
|
+
currentChannelProvider: resolveCodexMessageToolProvider(params),
|
|
808
|
+
...buildAgentHookContextChannelFields(params)
|
|
917
809
|
}
|
|
918
810
|
}),
|
|
919
811
|
webSearchPlan
|
|
920
812
|
};
|
|
921
813
|
}
|
|
922
|
-
function emptySideUserInputResponse() {
|
|
923
|
-
return { answers: {} };
|
|
924
|
-
}
|
|
925
814
|
function isSideUserInputRequest(value, threadId, turnId) {
|
|
926
815
|
return isJsonObject(value) && value.threadId === threadId && value.turnId === turnId;
|
|
927
816
|
}
|
|
@@ -934,26 +823,9 @@ async function forkCodexSideThread(client, params, options) {
|
|
|
934
823
|
}
|
|
935
824
|
}
|
|
936
825
|
function isMissingCodexParentThreadError(error) {
|
|
937
|
-
const message = formatErrorMessage(error);
|
|
826
|
+
const message = formatErrorMessage$1(error);
|
|
938
827
|
return message.includes("no rollout found for thread id") || message.includes("includeTurns is unavailable before first user message");
|
|
939
828
|
}
|
|
940
|
-
async function cleanupCodexSideThread(client, params) {
|
|
941
|
-
if (!params.threadId) return;
|
|
942
|
-
if (params.interrupt && params.turnId !== void 0) {
|
|
943
|
-
if (!await interruptCodexTurnAndWaitBestEffort(client, {
|
|
944
|
-
threadId: params.threadId,
|
|
945
|
-
turnId: params.turnId,
|
|
946
|
-
timeoutMs: params.timeoutMs
|
|
947
|
-
})) {
|
|
948
|
-
await retireUnsafeCodexTurnClientBestEffort(client, "side turn interrupt");
|
|
949
|
-
return;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
if (!await unsubscribeCodexThreadBestEffort(client, {
|
|
953
|
-
threadId: params.threadId,
|
|
954
|
-
timeoutMs: params.timeoutMs
|
|
955
|
-
})) await retireUnsafeCodexTurnClientBestEffort(client, "side thread unsubscribe");
|
|
956
|
-
}
|
|
957
829
|
function formatCodexErrorMessage(params, rateLimits) {
|
|
958
830
|
const error = isJsonObject(params.error) ? params.error : void 0;
|
|
959
831
|
const message = formatCodexUsageLimitErrorMessage({
|
|
@@ -961,7 +833,7 @@ function formatCodexErrorMessage(params, rateLimits) {
|
|
|
961
833
|
codexErrorInfo: error?.codexErrorInfo,
|
|
962
834
|
rateLimits
|
|
963
835
|
}) ?? (error ? readStringField(error, "message") ?? readStringField(error, "error") : void 0) ?? readStringField(params, "message") ?? "Codex /btw side thread failed.";
|
|
964
|
-
return new Error(formatErrorMessage(message));
|
|
836
|
+
return new Error(formatErrorMessage$1(message));
|
|
965
837
|
}
|
|
966
838
|
//#endregion
|
|
967
839
|
export { runCodexAppServerSideQuestion };
|