@openclaw/codex 2026.9.7 → 2026.10.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/.setup/{account-usage-runtime-DFhbh1zz.mjs → account-usage-runtime-C4GFoef_.mjs} +5 -5
- package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
- package/dist/.setup/{apply-D3GcSoSa.mjs → apply-D02fLpgN.mjs} +48 -39
- package/dist/.setup/attempt-client-cleanup-yLjGwbwT.mjs +155 -0
- package/dist/.setup/{attempt-workspace-context-C5HigshI.mjs → attempt-workspace-context-CbSzT6V2.mjs} +11 -15
- package/dist/.setup/{auth-binding-BLWz7stm.mjs → auth-binding-BoMwpuPN.mjs} +17 -25
- package/dist/.setup/{auth-cache-key-Dbvq-QgB.mjs → auth-cache-key-CEd9QlIs.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-CbjoN2OW.mjs → bounded-turn-DlHlNTyS.mjs} +14 -13
- package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
- package/dist/.setup/{build-state-Da1_z0kd.mjs → build-state-CIi3Ckqu.mjs} +1 -1
- package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
- package/dist/.setup/{client-N0JpgSzF.mjs → client-CBzEVDyb.mjs} +438 -160
- package/dist/.setup/{client-catalog-response-5HHLdcde.mjs → client-catalog-response-CmvIiDdj.mjs} +57 -25
- package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
- package/dist/.setup/{command-dispatch-BeAoaovI.mjs → command-dispatch-BE_RdMou.mjs} +3 -3
- package/dist/.setup/{command-formatters-R3ckE3Co.mjs → command-formatters-DV3DHhdr.mjs} +7 -5
- package/dist/.setup/{command-handlers-ylTMS00z.mjs → command-handlers-DNoRq5Ps.mjs} +82 -144
- package/dist/.setup/{command-rpc-CGJGUQ6Y.mjs → command-rpc-B6xsq2dB.mjs} +23 -31
- package/dist/.setup/{compact-C2WamavS.mjs → compact-BLSAd-ru.mjs} +117 -65
- package/dist/.setup/{plugin-metadata-cache-DsjsL1dr.mjs → computer-use-DpolvQHw.mjs} +66 -203
- 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-3Min8qvP.mjs → conversation-binding-CgSSD1Qz.mjs} +36 -48
- package/dist/.setup/{conversation-binding-data-C746z5Pn.mjs → conversation-binding-data-DJ4ix-W5.mjs} +1 -1
- package/dist/.setup/{conversation-control-CEP8X5JC.mjs → conversation-control-tCg763cI.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-CVrx02cH.mjs +463 -0
- package/dist/.setup/{dynamic-tools-DzlsLUuS.mjs → dynamic-tools-DdsymYGQ.mjs} +238 -878
- package/dist/.setup/{effective-mcp-catalog-CxUtC-xG.mjs → effective-mcp-catalog-BysTBZCW.mjs} +83 -11
- package/dist/.setup/{elicitation-input-DPoK8F7w.mjs → elicitation-input-r9axtppm.mjs} +4 -2
- package/dist/.setup/{ephemeral-turn-CDsPJOa2.mjs → ephemeral-turn-oPKxs3ia.mjs} +2 -2
- package/dist/.setup/{event-projector-assistant-message-CigreO4K.mjs → event-projector-assistant-message-YCL2wspu.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-Dm3PzxJk.mjs → isolated-completion-D5gbKm6k.mjs} +8 -8
- package/dist/.setup/{managed-binary-kiWRhNRE.mjs → managed-binary-C1VFoVPf.mjs} +31 -38
- package/dist/.setup/mcp-app-session-preparation-CdqsXwZX.mjs +223 -0
- package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
- package/dist/.setup/{model-catalog-PAuZgJC6.mjs → model-catalog-Dj_uvusa.mjs} +7 -7
- package/dist/.setup/{models-DHXZtVVk.mjs → models-Du_i5G_t.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-DV7VbfzF.mjs +310 -0
- package/dist/.setup/{native-subagent-monitor-Dpsmf2wz.mjs → native-subagent-monitor-CCEFO6qK.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-Y-QIvrKB.mjs → plan-CUHSIOep.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-uAR-oQfr.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-CdRzGJt4.mjs +124 -0
- package/dist/.setup/{provider-DH8NSzGt.mjs → provider-BP8ZaZqn.mjs} +4 -4
- package/dist/.setup/provider-capabilities-Z5ZbBxqP.mjs +50 -0
- package/dist/.setup/{rate-limits-B7-X2TgG.mjs → rate-limits-CMPy24F5.mjs} +1 -5
- package/dist/.setup/{request-BHZ1nz8d.mjs → request-BH3FvYUE.mjs} +189 -49
- package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
- package/dist/.setup/{run-attempt-D8RZUOzY.mjs → run-attempt-CgvFoW7R.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-DePDzzjc.mjs → session-catalog-events-KIXOoSnQ.mjs} +5 -5
- package/dist/.setup/{session-catalog-index-CZvDzC6z.mjs → session-catalog-index-DPICGlxr.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-DjhwGL6x.mjs → session-catalog-native-projection-CTBd4EUm.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-Cr5qP5Dj.mjs → session-catalog-projection-CE0_Hffi.mjs} +6 -122
- package/dist/.setup/{session-catalog-provenance-DoAvktcj.mjs → session-catalog-provenance-CmsOE5mh.mjs} +6 -1
- package/dist/.setup/{session-cli-Cn_nCqfq.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-qMTxkNx2.mjs → session-retirement-aC60o6P3.mjs} +14 -15
- package/dist/.setup/{settled-turn-context-D4yj4rxf.mjs → settled-turn-context-BZsMjkIO.mjs} +13 -6
- package/dist/.setup/{settled-turn-finalizer-BsvEabkw.mjs → settled-turn-finalizer-CDxCejjC.mjs} +8 -8
- package/dist/.setup/{shared-client-DqyTMYug.mjs → shared-client-DJJ3ljH2.mjs} +291 -272
- package/dist/.setup/{provider-capabilities-CAxoF-X1.mjs → shell-dynamic-tools-Do9lIAT1.mjs} +16 -55
- package/dist/.setup/{side-question-C4kCmQy1.mjs → side-question-B7T0_GEC.mjs} +99 -91
- package/dist/.setup/{source-CS_7GFJZ.mjs → source-DH70LqN0.mjs} +24 -40
- package/dist/.setup/{thread-lifecycle-DPflntEJ.mjs → thread-lifecycle-DkcoX9q-.mjs} +262 -305
- package/dist/.setup/{thread-ownership-roNP0l1c.mjs → thread-ownership-0aRHD9iK.mjs} +10 -8
- package/dist/.setup/{thread-policy-DTd-DtkX.mjs → thread-policy-CXZV97TS.mjs} +22 -21
- package/dist/.setup/{thread-requests-B_bRnMGN.mjs → thread-requests-COrRJcZb.mjs} +107 -98
- package/dist/.setup/{thread-resume-CdDaoc7T.mjs → thread-resume-rx7J68Rx.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-DOP-cW5j.mjs → turn-router-CX1-EoCp.mjs} +75 -170
- package/dist/.setup/{upstream-session-fork-CBeVjBpT.mjs → upstream-session-fork-LYlaQnbt.mjs} +35 -46
- package/dist/.setup/{usage-BMzNxeR_.mjs → usage-Dmx7B0W2.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-QXerDo3i.mjs → usage-limit-error-M8jVnITZ.mjs} +4 -4
- package/dist/.setup/{web-search-provider.runtime-P77OUeoo.mjs → web-search-provider.runtime-CsVmqbFm.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-4sCdv5qx.mjs +0 -2610
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +0 -153
package/dist/.setup/{native-subagent-monitor-Dpsmf2wz.mjs → native-subagent-monitor-CCEFO6qK.mjs}
RENAMED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { c as codexNativeSubagentRunId, d as readNativeSubagentThreadIds, f as readThreadParentThreadId, l as normalizeIdentifier, m as assertHistoryOwnerMatchesRegistration, p as readThreadSpawnSource, t as matchesNativeAssignmentLifecycle, u as readCodexNativeSubagentRunId } from "./native-subagent-pending-assignments-
|
|
1
|
+
import { c as codexNativeSubagentRunId, d as readNativeSubagentThreadIds, f as readThreadParentThreadId, l as normalizeIdentifier, m as assertHistoryOwnerMatchesRegistration, p as readThreadSpawnSource, t as matchesNativeAssignmentLifecycle, u as readCodexNativeSubagentRunId } from "./native-subagent-pending-assignments-BDqhOdJp.mjs";
|
|
2
2
|
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { n as defineCodexBuildState } from "./build-state-CIi3Ckqu.mjs";
|
|
4
|
+
import { a as readHookOutputEntries, o as readItem, s as readNullableString } from "./event-projector-values-DTqZHizf.mjs";
|
|
4
5
|
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-fXkKbPVC.mjs";
|
|
5
|
-
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-
|
|
6
|
-
import { K as retainCodexAppServerLiveThread, P as claimCodexAppServerLiveThread, R as hasCodexAppServerLiveThread
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-BogBHKLk.mjs";
|
|
7
|
+
import { K as retainCodexAppServerLiveThread, P as claimCodexAppServerLiveThread, R as hasCodexAppServerLiveThread } from "./shared-client-DJJ3ljH2.mjs";
|
|
8
|
+
import { L as readCodexAppServerWarningMessage } from "./client-CBzEVDyb.mjs";
|
|
9
|
+
import { _ as itemStatus, c as auditNativeToolName, d as isMutatingNativeToolItem, f as isNonSuccessItemStatus, g as itemName, h as itemKind, l as auditNativeToolTerminalStatus, m as isSideEffectingNativeToolItem, p as isProjectedNativeToolItem, v as itemTitle, x as unknownItemStatus, y as matchesCodexSnapshotTurn } from "./turn-router-CX1-EoCp.mjs";
|
|
10
|
+
import { s as interruptCodexTurnAndWaitBestEffort } from "./attempt-client-cleanup-yLjGwbwT.mjs";
|
|
11
|
+
import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-uAR-oQfr.mjs";
|
|
12
|
+
import { t as __exportAll } from "./session-binding-sidecars-BrdV95Fg.mjs";
|
|
9
13
|
import { asFiniteNumber, asNonArrayRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeTrimmedStringList, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
14
|
import { randomUUID } from "node:crypto";
|
|
11
15
|
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
12
16
|
import path from "node:path";
|
|
13
|
-
import {
|
|
17
|
+
import { toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
14
18
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
15
19
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
16
20
|
import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage as formatErrorMessage$1, inferToolMetaFromArgs, projectAgentActivityItem, projectAgentToolActivity, runAgentHarnessAfterToolCallHook, sanitizeToolArgs } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
17
21
|
import { MAX_TOOL_OUTPUT_DELTA_MESSAGES_PER_ITEM, NativeToolOutputAccumulator, TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS, createAgentHarnessToolCallMessage, createAgentHarnessToolResultMessage, formatNativeToolOutput, formatNativeToolSummary, truncateNativeToolTranscriptText } from "openclaw/plugin-sdk/agent-harness-attempt-runtime";
|
|
18
22
|
import { captureAgentHarnessCompletionCustody, createAgentHarnessCompletionEventSink, deliverAgentHarnessCompletion, isDurableAgentHarnessCompletionDelivery } from "openclaw/plugin-sdk/agent-harness-completion";
|
|
23
|
+
import { compileFunction } from "node:vm";
|
|
19
24
|
//#region extensions/codex/src/app-server/native-subagent-model-lookup.ts
|
|
20
25
|
function waitForNativeModelSourceChange(state, signal) {
|
|
21
26
|
signal?.throwIfAborted();
|
|
@@ -736,7 +741,7 @@ var CodexNativeSubagentRecoveryCoordinator = class {
|
|
|
736
741
|
const fallback = childState.fallbackCompletion;
|
|
737
742
|
const state = this.dependencies.parentState(childState.parentThreadId);
|
|
738
743
|
if (fallback && state && childState.recoveryAttempt >= 2) {
|
|
739
|
-
await this.dependencies.processCompletion(state, childState, fallback, fallback.completedAt ??
|
|
744
|
+
await this.dependencies.processCompletion(state, childState, fallback, fallback.completedAt ?? Date.now());
|
|
740
745
|
return;
|
|
741
746
|
}
|
|
742
747
|
this.scheduleRecoveryPoll(childState);
|
|
@@ -1015,17 +1020,13 @@ var CodexNativeSubagentCompletionDelivery = class {
|
|
|
1015
1020
|
result: completion.result,
|
|
1016
1021
|
replyInstruction: "Use the Codex native subagent result to continue or wrap up the parent task. If this is a Discord/channel session, send the visible response with the message tool instead of only writing a transcript final answer. Reply in your normal assistant voice and do not expose internal notification markup."
|
|
1017
1022
|
});
|
|
1018
|
-
if (!this.
|
|
1023
|
+
if (!this.isCurrent(state, childState)) return;
|
|
1019
1024
|
if (isDurableAgentHarnessCompletionDelivery(delivery)) childState.nativeCompletionDelivered = true;
|
|
1020
1025
|
if (childState.nativeCompletionDelivered) {
|
|
1021
1026
|
this.prepareDelivery(state, childState);
|
|
1022
1027
|
return;
|
|
1023
1028
|
}
|
|
1024
|
-
if (!this.claim(state, childState)) {
|
|
1025
|
-
this.dependencies.unregisterChild(childState);
|
|
1026
|
-
return;
|
|
1027
|
-
}
|
|
1028
|
-
if (delivery.recoveryBlocked) {
|
|
1029
|
+
if (!this.claim(state, childState) || delivery.recoveryBlocked) {
|
|
1029
1030
|
this.dependencies.unregisterChild(childState);
|
|
1030
1031
|
return;
|
|
1031
1032
|
}
|
|
@@ -1036,7 +1037,7 @@ var CodexNativeSubagentCompletionDelivery = class {
|
|
|
1036
1037
|
const error = delivery.error ?? "completion delivery did not produce a parent response";
|
|
1037
1038
|
this.scheduleRetry(childState, error);
|
|
1038
1039
|
} catch (error) {
|
|
1039
|
-
if (!this.
|
|
1040
|
+
if (!this.isCurrent(state, childState)) return;
|
|
1040
1041
|
if (!this.claim(state, childState)) {
|
|
1041
1042
|
this.dependencies.unregisterChild(childState);
|
|
1042
1043
|
return;
|
|
@@ -1170,13 +1171,8 @@ const CODEX_SUBAGENT_NOTIFICATION_START = "<subagent_notification>";
|
|
|
1170
1171
|
const CODEX_SUBAGENT_NOTIFICATION_END = "</subagent_notification>";
|
|
1171
1172
|
function extractCodexNativeSubagentCompletions(notification) {
|
|
1172
1173
|
const params = isJsonObject(notification.params) ? notification.params : void 0;
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
if (!item) return [];
|
|
1176
|
-
if (notification.method === "rawResponseItem/completed" && item.role === "user") return readTrustedContextualCompletions(item);
|
|
1177
|
-
return [];
|
|
1178
|
-
}
|
|
1179
|
-
function readTrustedContextualCompletions(item) {
|
|
1174
|
+
const item = isJsonObject(params?.item) ? params.item : void 0;
|
|
1175
|
+
if (!item || notification.method !== "rawResponseItem/completed" || item.role !== "user") return [];
|
|
1180
1176
|
const content = item.content;
|
|
1181
1177
|
const metadata = item.internal_chat_message_metadata_passthrough;
|
|
1182
1178
|
const kinds = isJsonObject(metadata) ? metadata.content_item_kinds : void 0;
|
|
@@ -1262,11 +1258,6 @@ function isNoFinalCompletion(completion) {
|
|
|
1262
1258
|
function buildCodexNativeSubagentAgentPathKey(parentThreadId, agentPath) {
|
|
1263
1259
|
return `${parentThreadId}\0${agentPath}`;
|
|
1264
1260
|
}
|
|
1265
|
-
function resolveCodexNativeSubagentReceiptOwner(params) {
|
|
1266
|
-
const { state, known } = params;
|
|
1267
|
-
if (known?.parent === state) return known.deliveryReceipts;
|
|
1268
|
-
return state.deliveryReceipts;
|
|
1269
|
-
}
|
|
1270
1261
|
function registerCodexNativeSubagentReceiptAlias(params) {
|
|
1271
1262
|
const { state, childThreadId, agentPath, known, aliases } = params;
|
|
1272
1263
|
if (known?.parent !== state) return [];
|
|
@@ -1416,8 +1407,9 @@ var CodexNativeSubagentHistoryRecovery = class {
|
|
|
1416
1407
|
threadState: "unavailable",
|
|
1417
1408
|
observedPendingTurns: []
|
|
1418
1409
|
};
|
|
1410
|
+
const rawTurns = Array.isArray(thread.turns) ? thread.turns : [];
|
|
1419
1411
|
if (options.predecessorNativeTurnId) {
|
|
1420
|
-
const turns =
|
|
1412
|
+
const turns = rawTurns.filter(isJsonObject);
|
|
1421
1413
|
const predecessor = turns.findIndex((turn) => readStringField(turn, "id") === options.predecessorNativeTurnId);
|
|
1422
1414
|
const target = turns.findIndex((turn) => readStringField(turn, "id") === assignment.nativeTurnId);
|
|
1423
1415
|
if (predecessor < 0 || target <= predecessor || !["completed", "failed"].includes(readStringField(turns[predecessor], "status") ?? "")) return {
|
|
@@ -1426,23 +1418,9 @@ var CodexNativeSubagentHistoryRecovery = class {
|
|
|
1426
1418
|
observedPendingTurns: []
|
|
1427
1419
|
};
|
|
1428
1420
|
}
|
|
1429
|
-
const firstObserved = options.observedTurns?.[0];
|
|
1430
|
-
const observedPredecessor = options.resumeInterrupted && firstObserved?.state && firstObserved.state !== "active" && !firstObserved.startObserved ? firstObserved.turnId : void 0;
|
|
1431
1421
|
let initialTurnId;
|
|
1432
1422
|
if (options.initialAssignment && !assignment.nativeTurnId && !recordedCompletion) {
|
|
1433
|
-
|
|
1434
|
-
parentThreadId: readThreadParentThreadId(thread),
|
|
1435
|
-
resumable: false,
|
|
1436
|
-
threadState: "unavailable",
|
|
1437
|
-
observedPendingTurns: []
|
|
1438
|
-
};
|
|
1439
|
-
for (const turn of Array.isArray(thread.turns) ? thread.turns : []) {
|
|
1440
|
-
const id = readStringField(turn, "id");
|
|
1441
|
-
if (id) {
|
|
1442
|
-
initialTurnId = id;
|
|
1443
|
-
break;
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1423
|
+
initialTurnId = readStringField(thread, "forkedFromId") ? void 0 : readStringField(rawTurns.find((turn) => readStringField(turn, "id")), "id");
|
|
1446
1424
|
if (!initialTurnId) return {
|
|
1447
1425
|
parentThreadId: readThreadParentThreadId(thread),
|
|
1448
1426
|
resumable: false,
|
|
@@ -1450,11 +1428,11 @@ var CodexNativeSubagentHistoryRecovery = class {
|
|
|
1450
1428
|
observedPendingTurns: []
|
|
1451
1429
|
};
|
|
1452
1430
|
}
|
|
1453
|
-
const turnId = assignment.nativeTurnId ?? initialTurnId
|
|
1454
|
-
const pendingTurnIds =
|
|
1431
|
+
const turnId = assignment.nativeTurnId ?? initialTurnId;
|
|
1432
|
+
const pendingTurnIds = new Set(this.queries.getPendingTurnIds(childThreadId));
|
|
1455
1433
|
const unresolvedAssignment = options.resumeInterrupted && !turnId && pendingTurnIds.size > 0;
|
|
1456
1434
|
const observedPendingTurns = [];
|
|
1457
|
-
for (const turn of
|
|
1435
|
+
for (const turn of rawTurns) {
|
|
1458
1436
|
const pendingTurnId = readStringField(turn, "id");
|
|
1459
1437
|
if (pendingTurnId && pendingTurnIds.has(pendingTurnId)) observedPendingTurns.push({
|
|
1460
1438
|
turnId: pendingTurnId,
|
|
@@ -1470,7 +1448,7 @@ var CodexNativeSubagentHistoryRecovery = class {
|
|
|
1470
1448
|
let threadState = threadStatus === "active" ? "active" : threadStatus === "systemerror" ? "system_error" : threadStatus ? "other" : "unavailable";
|
|
1471
1449
|
if (unresolvedAssignment) threadState = "unavailable";
|
|
1472
1450
|
else if (turnId) {
|
|
1473
|
-
const turns =
|
|
1451
|
+
const turns = rawTurns.filter(isJsonObject);
|
|
1474
1452
|
let index = turns.findIndex((turn) => readStringField(turn, "id") === turnId);
|
|
1475
1453
|
while (options.resumeInterrupted && index >= 0 && index + 1 < turns.length && normalizeIdentifier(readStringField(turns[index], "status")) === "interrupted") index += 1;
|
|
1476
1454
|
const turn = turns[index];
|
|
@@ -1481,7 +1459,7 @@ var CodexNativeSubagentHistoryRecovery = class {
|
|
|
1481
1459
|
resumable = turnStatus === "interrupted";
|
|
1482
1460
|
threadState = turnStatus === "inprogress" ? "active" : turnStatus ? "other" : "unavailable";
|
|
1483
1461
|
} else if (threadStatus === "active") {
|
|
1484
|
-
const turn =
|
|
1462
|
+
const turn = rawTurns.at(-1);
|
|
1485
1463
|
if (normalizeIdentifier(readStringField(turn, "status")) === "inprogress") {
|
|
1486
1464
|
nativeTurnId = readStringField(turn, "id");
|
|
1487
1465
|
nativeTurnState = "active";
|
|
@@ -1534,7 +1512,6 @@ var CodexNativeSubagentHistoryRecovery = class {
|
|
|
1534
1512
|
return {
|
|
1535
1513
|
parentThreadId: readThreadParentThreadId(thread),
|
|
1536
1514
|
agentPath: normalizeOptionalString(readStringField(readThreadSpawnSource(thread), "agent_path")),
|
|
1537
|
-
assignmentTurnId: turnId,
|
|
1538
1515
|
nativeTurnId,
|
|
1539
1516
|
nativeTurnState,
|
|
1540
1517
|
observedPendingTurns,
|
|
@@ -1765,13 +1742,10 @@ async function prepareNativeModelToolInput(request, dependencies) {
|
|
|
1765
1742
|
assertCurrent();
|
|
1766
1743
|
const nativeParentThreadId = readThreadParentThreadId(thread);
|
|
1767
1744
|
if (!dependencies.prepareReceiver(state, thread.id, nativeParentThreadId)) throw new Error("Codex native input receiver cannot retain this sender's admitted source");
|
|
1768
|
-
if (!dependencies.knownChildren.has(thread.id) && !dependencies.parents.has(thread.id)) {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
agentPath: readStringField(readThreadSpawnSource(metadata), "agent_path")
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1745
|
+
if (!dependencies.knownChildren.has(thread.id) && !dependencies.parents.has(thread.id)) dependencies.registerChildThread(state, thread.id, {
|
|
1746
|
+
nativeParentThreadId,
|
|
1747
|
+
agentPath: readStringField(readThreadSpawnSource(thread), "agent_path")
|
|
1748
|
+
});
|
|
1775
1749
|
const currentState = dependencies.parents.get(request.threadId) ?? dependencies.knownChildren.get(request.threadId)?.parent;
|
|
1776
1750
|
const currentOwner = currentState && resolveNativeModelParentOwner(currentState, request.turnId, request.threadId, dependencies.children, dependencies.knownChildren);
|
|
1777
1751
|
if (!currentOwner || currentOwner.modelExecutionSettled || currentOwner.modelExecutionCancelled) throw new Error("Codex native input requires its exact admitted sender turn");
|
|
@@ -1859,7 +1833,7 @@ const defaultNativeSubagentMonitorRuntime = {
|
|
|
1859
1833
|
createAgentHarnessCompletionEventSink
|
|
1860
1834
|
};
|
|
1861
1835
|
function createCodexNativeSubagentMonitorRuntime(Monitor) {
|
|
1862
|
-
const monitors = /* @__PURE__ */ new WeakMap();
|
|
1836
|
+
const monitors = defineCodexBuildState("openclaw.codexNativeSubagentMonitors", () => /* @__PURE__ */ new WeakMap())();
|
|
1863
1837
|
async function registerMonitor({ client, runtime, retainClient, retainParentThread, ...registration }) {
|
|
1864
1838
|
let monitor = monitors.get(client);
|
|
1865
1839
|
if (!monitor) {
|
|
@@ -2106,7 +2080,7 @@ async function registerNativeSubagentParent(input, dependencies) {
|
|
|
2106
2080
|
state.assignmentStore ??= params.assignmentStore;
|
|
2107
2081
|
state.owners.set(ownerKey, owner);
|
|
2108
2082
|
state.preparing = void 0;
|
|
2109
|
-
|
|
2083
|
+
dependencies.deliverDetached(state);
|
|
2110
2084
|
dependencies.submissions.restore(state, owner);
|
|
2111
2085
|
} catch (error) {
|
|
2112
2086
|
releaseRootModelBinding();
|
|
@@ -2807,19 +2781,24 @@ function sanitizeCodexToolArguments(value) {
|
|
|
2807
2781
|
return sanitizeCodexAgentEventRecord(value);
|
|
2808
2782
|
}
|
|
2809
2783
|
//#endregion
|
|
2810
|
-
//#region extensions/codex/src/app-server/
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2784
|
+
//#region extensions/codex/src/app-server/web-search-item.ts
|
|
2785
|
+
function projectCodexWebSearchItem(item) {
|
|
2786
|
+
const action = isJsonObject(item.action) ? item.action : void 0;
|
|
2787
|
+
const actionType = normalizeOptionalString(action?.type);
|
|
2788
|
+
const queries = actionType === "search" ? normalizeTrimmedStringList(action?.queries) : [];
|
|
2789
|
+
const query = normalizeOptionalString(item.query) ?? (actionType === "search" ? normalizeOptionalString(action?.query) : void 0) ?? queries[0];
|
|
2790
|
+
const url = normalizeOptionalString(action?.url);
|
|
2791
|
+
const pattern = normalizeOptionalString(action?.pattern);
|
|
2792
|
+
return {
|
|
2793
|
+
...query ? { query } : {},
|
|
2794
|
+
...queries.length > 0 ? { queries } : {},
|
|
2795
|
+
...actionType && actionType !== "search" ? { action: actionType } : {},
|
|
2796
|
+
...url ? { url } : {},
|
|
2797
|
+
...pattern ? { pattern } : {}
|
|
2798
|
+
};
|
|
2822
2799
|
}
|
|
2800
|
+
//#endregion
|
|
2801
|
+
//#region extensions/codex/src/app-server/event-projector-tool-items.ts
|
|
2823
2802
|
function readInterceptedNativePatchInput(command) {
|
|
2824
2803
|
if (typeof command !== "string") return;
|
|
2825
2804
|
const lines = command.replace(/\r\n?/gu, "\n").split("\n");
|
|
@@ -2874,19 +2853,8 @@ function isCommandBearingToolItem(item, args) {
|
|
|
2874
2853
|
return typeof args?.command === "string" && args.command.trim().length > 0;
|
|
2875
2854
|
}
|
|
2876
2855
|
function webSearchToolArgs(item) {
|
|
2877
|
-
const
|
|
2878
|
-
|
|
2879
|
-
const queries = action && actionType === "search" ? normalizeTrimmedStringList(action.queries) : [];
|
|
2880
|
-
const query = normalizeOptionalString$1(item.query) ?? (action && actionType === "search" ? readNonEmptyString(action, "query") : void 0) ?? queries[0];
|
|
2881
|
-
const url = action ? readNonEmptyString(action, "url") : void 0;
|
|
2882
|
-
const pattern = action ? readNonEmptyString(action, "pattern") : void 0;
|
|
2883
|
-
const args = {};
|
|
2884
|
-
if (query) args.query = query;
|
|
2885
|
-
if (queries.length > 0) args.queries = queries;
|
|
2886
|
-
if (actionType && actionType !== "search") args.action = actionType;
|
|
2887
|
-
if (url) args.url = url;
|
|
2888
|
-
if (pattern) args.pattern = pattern;
|
|
2889
|
-
if (!query && !url && !pattern) args.queryUnavailable = true;
|
|
2856
|
+
const args = projectCodexWebSearchItem(item);
|
|
2857
|
+
if (!args.query && !args.url && !args.pattern) args.queryUnavailable = true;
|
|
2890
2858
|
return sanitizeCodexAgentEventRecord(args);
|
|
2891
2859
|
}
|
|
2892
2860
|
function itemToolResult(item) {
|
|
@@ -2920,7 +2888,7 @@ function itemFileChangeRecords(item) {
|
|
|
2920
2888
|
}
|
|
2921
2889
|
function itemFileChanges(item) {
|
|
2922
2890
|
return itemFileChangeRecords(item).flatMap((change) => {
|
|
2923
|
-
const path = normalizeOptionalString
|
|
2891
|
+
const path = normalizeOptionalString(change.path);
|
|
2924
2892
|
if (!path || change.kind === void 0) return [];
|
|
2925
2893
|
return [{
|
|
2926
2894
|
path,
|
|
@@ -2930,7 +2898,7 @@ function itemFileChanges(item) {
|
|
|
2930
2898
|
}
|
|
2931
2899
|
function fileChangeKindType(kind) {
|
|
2932
2900
|
if (typeof kind === "string") return kind;
|
|
2933
|
-
return isJsonObject(kind) ? normalizeOptionalString
|
|
2901
|
+
return isJsonObject(kind) ? normalizeOptionalString(kind.type) : void 0;
|
|
2934
2902
|
}
|
|
2935
2903
|
function countFileContentLines(content) {
|
|
2936
2904
|
if (!content) return 0;
|
|
@@ -2977,7 +2945,7 @@ function truncateFileChangeDiffAtLineBoundary(diff, maxChars) {
|
|
|
2977
2945
|
function itemFileChangesForTranscript(item) {
|
|
2978
2946
|
let remainingDiffChars = 1e4;
|
|
2979
2947
|
return itemFileChangeRecords(item).flatMap((change) => {
|
|
2980
|
-
const path = normalizeOptionalString
|
|
2948
|
+
const path = normalizeOptionalString(change.path);
|
|
2981
2949
|
if (!path || change.kind === void 0) return [];
|
|
2982
2950
|
const result = {
|
|
2983
2951
|
path,
|
|
@@ -3031,124 +2999,6 @@ function stringifyJsonValue(value) {
|
|
|
3031
2999
|
}
|
|
3032
3000
|
}
|
|
3033
3001
|
//#endregion
|
|
3034
|
-
//#region extensions/codex/src/app-server/plugin-approval-roundtrip.ts
|
|
3035
|
-
const DEFAULT_CODEX_APPROVAL_TIMEOUT_MS = 12e4;
|
|
3036
|
-
const MAX_PLUGIN_APPROVAL_TITLE_LENGTH = 80;
|
|
3037
|
-
const MAX_PLUGIN_APPROVAL_DESCRIPTION_LENGTH = 512;
|
|
3038
|
-
const ANSI_OSC_SEQUENCE_RE = new RegExp(String.raw`(?:\u001b]|\u009d)[^\u001b\u009c\u0007]*(?:\u0007|\u001b\\|\u009c)`, "g");
|
|
3039
|
-
const ANSI_CONTROL_SEQUENCE_RE = new RegExp(String.raw`(?:\u001b\[[0-?]*[ -/]*[@-~]|\u009b[0-?]*[ -/]*[@-~]|\u001b[@-Z\\-_])`, "g");
|
|
3040
|
-
const CONTROL_CHARACTER_RE = new RegExp(String.raw`[\u0000-\u001f\u007f-\u009f]+`, "g");
|
|
3041
|
-
const INVISIBLE_FORMATTING_CONTROL_RE = new RegExp(String.raw`[\u00ad\u034f\u061c\u200b-\u200f\u202a-\u202e\u2060-\u206f\ufeff\ufe00-\ufe0f\u{e0100}-\u{e01ef}]`, "gu");
|
|
3042
|
-
const DANGLING_TERMINAL_SEQUENCE_SUFFIX_RE = new RegExp(String.raw`(?:\u001b\][^\u001b\u009c\u0007]*|\u009d[^\u001b\u009c\u0007]*|\u001b\[[0-?]*[ -/]*|\u009b[0-?]*[ -/]*|\u001b)$`);
|
|
3043
|
-
const CODEX_APPROVAL_TIMEOUT_SUBJECTS = {
|
|
3044
|
-
command: "Command approval",
|
|
3045
|
-
"file-change": "File change approval",
|
|
3046
|
-
permissions: "Permission approval",
|
|
3047
|
-
other: "Approval"
|
|
3048
|
-
};
|
|
3049
|
-
function codexApprovalTimeoutText(kind) {
|
|
3050
|
-
return `${CODEX_APPROVAL_TIMEOUT_SUBJECTS[kind]} timed out before an operator responded.`;
|
|
3051
|
-
}
|
|
3052
|
-
/** Starts a two-phase plugin approval request through the OpenClaw gateway. */
|
|
3053
|
-
async function requestPluginApproval(params) {
|
|
3054
|
-
const timeoutMs = DEFAULT_CODEX_APPROVAL_TIMEOUT_MS;
|
|
3055
|
-
return params.hostCapabilities.requestApproval({
|
|
3056
|
-
signal: params.signal,
|
|
3057
|
-
title: truncateCodexApprovalDisplayText(params.title, MAX_PLUGIN_APPROVAL_TITLE_LENGTH),
|
|
3058
|
-
description: truncateCodexApprovalDisplayText(params.description, MAX_PLUGIN_APPROVAL_DESCRIPTION_LENGTH),
|
|
3059
|
-
severity: params.severity,
|
|
3060
|
-
toolName: params.toolName,
|
|
3061
|
-
toolCallId: params.toolCallId,
|
|
3062
|
-
...params.mcpTool ? {
|
|
3063
|
-
mcpTool: params.mcpTool,
|
|
3064
|
-
isMcpToolApprovalActive: params.isMcpToolApprovalActive
|
|
3065
|
-
} : {},
|
|
3066
|
-
timeoutMs,
|
|
3067
|
-
transportTimeoutMs: resolveCodexGatewayTimeoutWithGraceMs(timeoutMs),
|
|
3068
|
-
...params.allowedDecisions ? { allowedDecisions: params.allowedDecisions } : {}
|
|
3069
|
-
});
|
|
3070
|
-
}
|
|
3071
|
-
/** Detects the gateway's explicit null-decision marker for unavailable approvals. */
|
|
3072
|
-
function approvalRequestExplicitlyUnavailable(result) {
|
|
3073
|
-
if (result === null || result === void 0 || typeof result !== "object") return false;
|
|
3074
|
-
let descriptor;
|
|
3075
|
-
try {
|
|
3076
|
-
descriptor = Object.getOwnPropertyDescriptor(result, "decision");
|
|
3077
|
-
} catch {
|
|
3078
|
-
return false;
|
|
3079
|
-
}
|
|
3080
|
-
return descriptor !== void 0 && "value" in descriptor && descriptor.value === null;
|
|
3081
|
-
}
|
|
3082
|
-
/** Waits for the gateway's final approval decision, respecting turn aborts. */
|
|
3083
|
-
async function waitForPluginApprovalDecision(params) {
|
|
3084
|
-
const timeoutMs = DEFAULT_CODEX_APPROVAL_TIMEOUT_MS;
|
|
3085
|
-
const waitPromise = params.hostCapabilities.waitForApproval({
|
|
3086
|
-
approvalId: params.approvalId,
|
|
3087
|
-
timeoutMs,
|
|
3088
|
-
transportTimeoutMs: resolveCodexGatewayTimeoutWithGraceMs(timeoutMs),
|
|
3089
|
-
signal: params.signal
|
|
3090
|
-
}).catch((error) => {
|
|
3091
|
-
if (isApprovalNotFoundError(error)) return;
|
|
3092
|
-
throw error;
|
|
3093
|
-
});
|
|
3094
|
-
if (!params.signal) return await waitPromise;
|
|
3095
|
-
let onAbort;
|
|
3096
|
-
const abortPromise = new Promise((_, reject) => {
|
|
3097
|
-
if (params.signal.aborted) {
|
|
3098
|
-
reject(toErrorObject(params.signal.reason, "Non-Error rejection"));
|
|
3099
|
-
return;
|
|
3100
|
-
}
|
|
3101
|
-
onAbort = () => reject(toErrorObject(params.signal.reason, "Non-Error rejection"));
|
|
3102
|
-
params.signal.addEventListener("abort", onAbort, { once: true });
|
|
3103
|
-
});
|
|
3104
|
-
try {
|
|
3105
|
-
return await Promise.race([waitPromise, abortPromise]);
|
|
3106
|
-
} finally {
|
|
3107
|
-
if (onAbort) params.signal.removeEventListener("abort", onAbort);
|
|
3108
|
-
}
|
|
3109
|
-
}
|
|
3110
|
-
/** Converts a gateway exec approval decision into the app-server approval outcome enum. */
|
|
3111
|
-
function mapExecDecisionToOutcome(decision) {
|
|
3112
|
-
switch (decision) {
|
|
3113
|
-
case "allow-once": return "approved-once";
|
|
3114
|
-
case "allow-always": return "approved-session";
|
|
3115
|
-
case "deny": return "denied";
|
|
3116
|
-
default: return "unavailable";
|
|
3117
|
-
}
|
|
3118
|
-
}
|
|
3119
|
-
/** Runs one complete host approval request and maps transport failures to a closed outcome. */
|
|
3120
|
-
async function requestPluginApprovalOutcome(params) {
|
|
3121
|
-
try {
|
|
3122
|
-
const requestResult = await requestPluginApproval({
|
|
3123
|
-
...params,
|
|
3124
|
-
severity: "warning"
|
|
3125
|
-
});
|
|
3126
|
-
const approvalId = requestResult?.id;
|
|
3127
|
-
if (!approvalId) return "unavailable";
|
|
3128
|
-
const approvalResult = approvalRequestExplicitlyUnavailable(requestResult) ? void 0 : await waitForPluginApprovalDecision({
|
|
3129
|
-
hostCapabilities: params.hostCapabilities,
|
|
3130
|
-
approvalId,
|
|
3131
|
-
signal: params.signal
|
|
3132
|
-
});
|
|
3133
|
-
if (params.signal?.aborted) return "cancelled";
|
|
3134
|
-
if (approvalResult?.terminalReason === "timeout") return "timed-out";
|
|
3135
|
-
const decision = approvalResult?.decision;
|
|
3136
|
-
return mapExecDecisionToOutcome(decision === "allow-always" && params.allowedDecisions?.includes("allow-always") === false ? "allow-once" : decision);
|
|
3137
|
-
} catch {
|
|
3138
|
-
return params.signal?.aborted ? "cancelled" : "denied";
|
|
3139
|
-
}
|
|
3140
|
-
}
|
|
3141
|
-
function truncateCodexApprovalDisplayText(value, maxLength) {
|
|
3142
|
-
return value.length <= maxLength ? value : `${truncateUtf16Safe(value, maxLength - 3)}...`;
|
|
3143
|
-
}
|
|
3144
|
-
function stripDanglingCodexApprovalTerminalSequence(value) {
|
|
3145
|
-
return value.replace(DANGLING_TERMINAL_SEQUENCE_SUFFIX_RE, "");
|
|
3146
|
-
}
|
|
3147
|
-
function sanitizeCodexApprovalVisibleText(value, options = {}) {
|
|
3148
|
-
const terminalSafe = value.replace(ANSI_OSC_SEQUENCE_RE, "").replace(ANSI_CONTROL_SEQUENCE_RE, "");
|
|
3149
|
-
return (options.stripDanglingTerminalSequence ? stripDanglingCodexApprovalTerminalSequence(terminalSafe) : terminalSafe).replace(INVISIBLE_FORMATTING_CONTROL_RE, " ").replace(CONTROL_CHARACTER_RE, " ").replace(/\s+/g, " ").trim();
|
|
3150
|
-
}
|
|
3151
|
-
//#endregion
|
|
3152
3002
|
//#region extensions/codex/src/app-server/event-projector-tool-progress.ts
|
|
3153
3003
|
const TRANSCRIPT_PROGRESS_SUPPRESSED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
3154
3004
|
"message",
|
|
@@ -3169,7 +3019,6 @@ var CodexToolProgressProjection = class {
|
|
|
3169
3019
|
this.echoesByItem = /* @__PURE__ */ new Map();
|
|
3170
3020
|
this.resultSummaryItemIds = /* @__PURE__ */ new Set();
|
|
3171
3021
|
this.resultOutputItemIds = /* @__PURE__ */ new Set();
|
|
3172
|
-
this.resultOutputStreamedItemIds = /* @__PURE__ */ new Set();
|
|
3173
3022
|
this.transcriptProgressSuppressedIds = /* @__PURE__ */ new Set();
|
|
3174
3023
|
this.resultOutputDeltaState = /* @__PURE__ */ new Map();
|
|
3175
3024
|
this.output = new NativeToolOutputAccumulator("Codex");
|
|
@@ -3267,7 +3116,6 @@ var CodexToolProgressProjection = class {
|
|
|
3267
3116
|
const reachedLimit = delta.length > remainingChars || state.chars >= TOOL_PROGRESS_OUTPUT_MAX_CHARS || state.messages >= MAX_TOOL_OUTPUT_DELTA_MESSAGES_PER_ITEM;
|
|
3268
3117
|
if (reachedLimit) state.truncated = true;
|
|
3269
3118
|
this.resultOutputDeltaState.set(itemId, state);
|
|
3270
|
-
this.resultOutputStreamedItemIds.add(itemId);
|
|
3271
3119
|
this.emitToolResultMessage({
|
|
3272
3120
|
itemId,
|
|
3273
3121
|
text: formatNativeToolOutput(toolName, void 0, reachedLimit ? `${chunk}\n...(truncated)...` : chunk)
|
|
@@ -3326,7 +3174,7 @@ var CodexToolProgressProjection = class {
|
|
|
3326
3174
|
emitToolResultOutput(item) {
|
|
3327
3175
|
if (!item || item.type === "dynamicToolCall") return;
|
|
3328
3176
|
if (!this.params.onToolResult || !this.shouldEmitToolOutput()) return;
|
|
3329
|
-
if (this.resultOutputItemIds.has(item.id) || this.
|
|
3177
|
+
if (this.resultOutputItemIds.has(item.id) || this.resultOutputDeltaState.has(item.id)) return;
|
|
3330
3178
|
const toolName = itemName(item);
|
|
3331
3179
|
const output = itemOutputText(item, this.output.textByItem);
|
|
3332
3180
|
if (!toolName || !output || !shouldEmitTranscriptToolProgress(toolName)) return;
|
|
@@ -3408,7 +3256,7 @@ var CodexToolProgressProjection = class {
|
|
|
3408
3256
|
this.transcriptProgressCallIds.add(params.id);
|
|
3409
3257
|
const args = asNonArrayRecord(params.arguments);
|
|
3410
3258
|
const meta = this.shouldIncludeFormattedMeta(isCodexCommandBearingToolCall(params.name, args)) ? inferToolMetaFromArgs(params.name, args, { detailMode: this.toolProgressDetailMode() }) : void 0;
|
|
3411
|
-
if (!this.params.onToolResult || !this.shouldEmitToolResult() || this.resultSummaryItemIds.has(params.id) || this.
|
|
3259
|
+
if (!this.params.onToolResult || !this.shouldEmitToolResult() || this.resultSummaryItemIds.has(params.id) || this.resultOutputDeltaState.has(params.id)) return;
|
|
3412
3260
|
this.resultSummaryItemIds.add(params.id);
|
|
3413
3261
|
this.emitToolResultMessage({
|
|
3414
3262
|
itemId: params.id,
|
|
@@ -3427,7 +3275,7 @@ var CodexToolProgressProjection = class {
|
|
|
3427
3275
|
name: params.name,
|
|
3428
3276
|
arguments: {}
|
|
3429
3277
|
});
|
|
3430
|
-
if (!this.params.onToolResult || !this.shouldEmitToolOutput() || this.resultOutputItemIds.has(params.id) || this.
|
|
3278
|
+
if (!this.params.onToolResult || !this.shouldEmitToolOutput() || this.resultOutputItemIds.has(params.id) || this.resultOutputDeltaState.has(params.id)) return;
|
|
3431
3279
|
const text = params.text?.trim();
|
|
3432
3280
|
if (text) this.emitToolResultMessage({
|
|
3433
3281
|
itemId: params.id,
|
|
@@ -3472,6 +3320,67 @@ var CodexToolProgressProjection = class {
|
|
|
3472
3320
|
}
|
|
3473
3321
|
};
|
|
3474
3322
|
//#endregion
|
|
3323
|
+
//#region extensions/codex/src/app-server/event-projector-code-mode.ts
|
|
3324
|
+
const IDENTIFIER = /[A-Za-z_$][\w$]*/u.source;
|
|
3325
|
+
const STRING = /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|`(?:\\[\s\S]|[^`\\])*`/u.source;
|
|
3326
|
+
const SCALAR = `(?:${STRING}|-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?|true|false|null)`;
|
|
3327
|
+
const PROPERTY = `(?:${IDENTIFIER}|${STRING})\\s*:\\s*${SCALAR}`;
|
|
3328
|
+
const INPUT = `(?:${STRING}|\\{\\s*(?:${PROPERTY}(?:\\s*,\\s*${PROPERTY})*\\s*,?)?\\s*\\})`;
|
|
3329
|
+
const NATIVE_CALL = `await\\s+tools\\.(?<tool>apply_patch|exec_command)\\(\\s*(?<input>${INPUT}|${IDENTIFIER})\\s*\\)`;
|
|
3330
|
+
const SEPARATOR = `\\s*(?:;|[\\r\\n])\\s*`;
|
|
3331
|
+
const WRAPPER = new RegExp(`^\\s*(?://[^\\r\\n]*\\r?\\n\\s*)*(?:(?:const|let)\\s+(?<inputName>${IDENTIFIER})\\s*=\\s*(?<literal>${INPUT})${SEPARATOR})?(?:text\\(\\s*${NATIVE_CALL}\\s*\\)|(?:const|let)\\s+(?<resultName>${IDENTIFIER})\\s*=\\s*await\\s+tools\\.(?<boundTool>apply_patch|exec_command)\\(\\s*(?<boundInput>${INPUT}|${IDENTIFIER})\\s*\\)${SEPARATOR}text\\(\\s*\\k<resultName>\\s*\\))\\s*;?\\s*$`, "u");
|
|
3332
|
+
function readStringLiteral(literal) {
|
|
3333
|
+
const quote = literal[0];
|
|
3334
|
+
let body = literal.slice(1, -1);
|
|
3335
|
+
if (quote !== "`" && /[\r\n]/u.test(body) || quote === "`" && body.includes("${")) throw new Error("not a static string");
|
|
3336
|
+
if (quote === "`") body = body.replace(/\r\n?/gu, "\n");
|
|
3337
|
+
return JSON.parse(`"${body.replace(/\\[\s\S]|["\r\n\t]/gu, (token) => token === "\\'" || token === "\\`" ? token.slice(1) : token.startsWith("\\") ? token : JSON.stringify(token).slice(1, -1))}"`);
|
|
3338
|
+
}
|
|
3339
|
+
function readLiteral(input) {
|
|
3340
|
+
if (!input.startsWith("{")) return readStringLiteral(input);
|
|
3341
|
+
const properties = new RegExp(`(${IDENTIFIER}|${STRING})\\s*:\\s*(${SCALAR})`, "gu");
|
|
3342
|
+
const entries = [];
|
|
3343
|
+
for (const match of input.matchAll(properties)) {
|
|
3344
|
+
const key = /^["'`]/u.test(match[1]) ? readStringLiteral(match[1]) : match[1];
|
|
3345
|
+
if (key === "__proto__") return;
|
|
3346
|
+
const value = match[2];
|
|
3347
|
+
entries.push([key, /^["'`]/u.test(value) ? readStringLiteral(value) : JSON.parse(value)]);
|
|
3348
|
+
}
|
|
3349
|
+
return Object.fromEntries(entries);
|
|
3350
|
+
}
|
|
3351
|
+
/** A literal input binding, one awaited native call, and its unmodified text output. */
|
|
3352
|
+
function readCodeModeNativeCall(source) {
|
|
3353
|
+
if (typeof source !== "string") return;
|
|
3354
|
+
const match = WRAPPER.exec(source)?.groups;
|
|
3355
|
+
if (!match || [match.inputName, match.resultName].some((name) => name === "tools" || name === "text") || match.inputName && match.inputName === match.resultName) return;
|
|
3356
|
+
const operand = match.input ?? match.boundInput;
|
|
3357
|
+
if (!operand || match.inputName && operand !== match.inputName) return;
|
|
3358
|
+
try {
|
|
3359
|
+
compileFunction(`"use strict"; return async () => {\n${source}\n};`);
|
|
3360
|
+
const input = readLiteral(match.literal ?? operand);
|
|
3361
|
+
const tool = match.tool ?? match.boundTool;
|
|
3362
|
+
if (tool === "apply_patch" && typeof input === "string" && /^\*\*\* Begin Patch\r?\n[\s\S]*\r?\n\*\*\* End Patch(?:\r?\n)?$/u.test(input)) return {
|
|
3363
|
+
name: "apply_patch",
|
|
3364
|
+
arguments: { input }
|
|
3365
|
+
};
|
|
3366
|
+
if (tool === "exec_command" && isJsonObject(input) && typeof input.cmd === "string" && (input.workdir === void 0 || typeof input.workdir === "string")) return {
|
|
3367
|
+
name: "bash",
|
|
3368
|
+
arguments: {
|
|
3369
|
+
command: input.cmd,
|
|
3370
|
+
...typeof input.workdir === "string" ? { cwd: input.workdir } : {}
|
|
3371
|
+
}
|
|
3372
|
+
};
|
|
3373
|
+
} catch {}
|
|
3374
|
+
}
|
|
3375
|
+
function codeModeCommandFailed(output) {
|
|
3376
|
+
try {
|
|
3377
|
+
const result = JSON.parse(output);
|
|
3378
|
+
return isJsonObject(result) && typeof result.output === "string" && typeof result.wall_time_seconds === "number" && typeof result.exit_code === "number" && Number.isInteger(result.exit_code) && result.exit_code !== 0 && result.session_id === void 0;
|
|
3379
|
+
} catch {
|
|
3380
|
+
return false;
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
//#endregion
|
|
3475
3384
|
//#region extensions/codex/src/app-server/local-runtime-attribution.ts
|
|
3476
3385
|
const OPENAI_PROVIDER_ID = "openai";
|
|
3477
3386
|
const OPENAI_RESPONSES_API = "openai-responses";
|
|
@@ -3491,6 +3400,7 @@ function resolveCodexLocalRuntimeAttribution(params) {
|
|
|
3491
3400
|
//#region extensions/codex/src/app-server/event-projector-tool-transcript.ts
|
|
3492
3401
|
const MISSING_TOOL_RESULT_ERROR = "OpenClaw recorded a native Codex tool.call without a matching tool.result before the turn completed.";
|
|
3493
3402
|
const NATIVE_PATCH_REJECTION_RE = /^\s*patch rejected:\s*writing outside of the project;\s*rejected by user approval settings\s*$/iu;
|
|
3403
|
+
const NATIVE_COMMAND_WORKSPACE_REJECTION_RE = /^\s*command rejected:\s*writing outside of the project;\s*rejected by user approval settings\s*$/iu;
|
|
3494
3404
|
const CODE_MODE_RESULT_RE = /^\s*Script (completed|failed)\s*\r?\nWall time\s+\d+(?:\.\d+)?\s+seconds\s*\r?\nOutput:\s*([\s\S]*?)\s*$/iu;
|
|
3495
3405
|
const MAX_TOOL_APPROVAL_REVIEWS = 16;
|
|
3496
3406
|
function toolApprovalReviewOutcome(state) {
|
|
@@ -3512,12 +3422,11 @@ var CodexToolTranscriptProjection = class {
|
|
|
3512
3422
|
this.trajectoryItemsById = /* @__PURE__ */ new Map();
|
|
3513
3423
|
this.afterToolCallObservedItemIds = /* @__PURE__ */ new Set();
|
|
3514
3424
|
this.nativeMcpAppResultDetails = /* @__PURE__ */ new Map();
|
|
3515
|
-
this.nativeMcpAppResultDetailsAttempted = /* @__PURE__ */ new Set();
|
|
3516
3425
|
this.approvalReviewsByCallId = /* @__PURE__ */ new Map();
|
|
3517
3426
|
this.rawNativeToolOutputByCallId = /* @__PURE__ */ new Map();
|
|
3518
3427
|
this.pendingRawOutputIds = /* @__PURE__ */ new Set();
|
|
3519
3428
|
this.rawCallsById = /* @__PURE__ */ new Map();
|
|
3520
|
-
this.
|
|
3429
|
+
this.codeModeNativeCallsByCallId = /* @__PURE__ */ new Map();
|
|
3521
3430
|
}
|
|
3522
3431
|
get transcriptMessages() {
|
|
3523
3432
|
return this.messages;
|
|
@@ -3564,31 +3473,39 @@ var CodexToolTranscriptProjection = class {
|
|
|
3564
3473
|
});
|
|
3565
3474
|
}
|
|
3566
3475
|
recordNativeToolCall(item) {
|
|
3567
|
-
if (
|
|
3568
|
-
|
|
3569
|
-
|
|
3476
|
+
if (item) {
|
|
3477
|
+
const call = this.nativeTranscriptCall(item);
|
|
3478
|
+
if (!call) return;
|
|
3479
|
+
const name = call.name;
|
|
3480
|
+
for (const pending of this.codeModeNativeCallsByCallId.values()) if (pending.call.name === name) pending.nativeItemObserved = true;
|
|
3481
|
+
this.recordToolCall(call);
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
recordNativeToolResult(item, details) {
|
|
3485
|
+
if (!item || this.resultIds.has(item.id)) return;
|
|
3486
|
+
const call = this.nativeTranscriptCall(item);
|
|
3487
|
+
if (!call) return;
|
|
3488
|
+
const status = itemStatus(item);
|
|
3489
|
+
const approvalTimeoutExplanation = this.progress.approvalTimeoutExplanation(item.id, status);
|
|
3490
|
+
this.recordToolResult({
|
|
3570
3491
|
id: item.id,
|
|
3571
|
-
name,
|
|
3572
|
-
|
|
3492
|
+
name: call.name,
|
|
3493
|
+
text: approvalTimeoutExplanation ?? this.rawNativeToolOutputByCallId.get(item.id) ?? itemTranscriptResultText(item, this.progress.outputTextByItem),
|
|
3494
|
+
isError: isNonSuccessItemStatus(status),
|
|
3495
|
+
...item.type === "commandExecution" && item.aggregatedOutput == null && this.progress.isOutputTruncated(item.id) ? { captureTruncated: true } : {},
|
|
3496
|
+
details,
|
|
3497
|
+
...item.type === "webSearch" ? { resultContentSource: "network" } : {}
|
|
3573
3498
|
});
|
|
3499
|
+
this.progress.approvalTimeoutKinds.delete(item.id);
|
|
3574
3500
|
}
|
|
3575
|
-
|
|
3576
|
-
if (
|
|
3501
|
+
nativeTranscriptCall(item) {
|
|
3502
|
+
if (item.type === "collabAgentToolCall" || item.type === "subAgentActivity") return this.rawCallsById.get(item.id);
|
|
3577
3503
|
const name = itemName(item);
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
name,
|
|
3584
|
-
text: approvalTimeoutExplanation ?? this.rawNativeToolOutputByCallId.get(item.id) ?? itemTranscriptResultText(item, this.progress.outputTextByItem),
|
|
3585
|
-
isError: isNonSuccessItemStatus(status),
|
|
3586
|
-
...item.type === "commandExecution" && item.aggregatedOutput == null && this.progress.isOutputTruncated(item.id) ? { captureTruncated: true } : {},
|
|
3587
|
-
details,
|
|
3588
|
-
...item.type === "webSearch" ? { resultContentSource: "network" } : {}
|
|
3589
|
-
});
|
|
3590
|
-
this.progress.approvalTimeoutKinds.delete(item.id);
|
|
3591
|
-
}
|
|
3504
|
+
return isProjectedNativeToolItem(item) && name ? {
|
|
3505
|
+
id: item.id,
|
|
3506
|
+
name,
|
|
3507
|
+
arguments: itemToolArgs(item)
|
|
3508
|
+
} : void 0;
|
|
3592
3509
|
}
|
|
3593
3510
|
recordRawNativeToolItem(item) {
|
|
3594
3511
|
const type = readStringField(item, "type");
|
|
@@ -3606,8 +3523,11 @@ var CodexToolTranscriptProjection = class {
|
|
|
3606
3523
|
let args;
|
|
3607
3524
|
if (type === "custom_tool_call" && item.name === "apply_patch" && typeof item.input === "string") args = { input: item.input };
|
|
3608
3525
|
else if (type === "custom_tool_call" && item.name === "exec") {
|
|
3609
|
-
const
|
|
3610
|
-
if (
|
|
3526
|
+
const call = readCodeModeNativeCall(item.input);
|
|
3527
|
+
if (call) this.codeModeNativeCallsByCallId.set(callId, {
|
|
3528
|
+
call,
|
|
3529
|
+
nativeItemObserved: false
|
|
3530
|
+
});
|
|
3611
3531
|
return;
|
|
3612
3532
|
} else if (type === "function_call" && typeof item.arguments === "string") try {
|
|
3613
3533
|
const parsed = JSON.parse(item.arguments);
|
|
@@ -3645,20 +3565,19 @@ var CodexToolTranscriptProjection = class {
|
|
|
3645
3565
|
this.rawNativeToolOutputByCallId.set(callId, text);
|
|
3646
3566
|
const rawCall = this.rawCallsById.get(callId);
|
|
3647
3567
|
const responseText = typeof item.output === "string" ? item.output : collectDynamicToolContentText(item.output);
|
|
3648
|
-
const execution = rawCall?.name === "exec" ? CODE_MODE_RESULT_RE.exec(responseText) : null;
|
|
3649
|
-
const
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
if (execution?.[1]?.toLowerCase() === "failed") {
|
|
3653
|
-
const failure = execution[2]?.replace(/^Script error:\s*/iu, "").trim() || text;
|
|
3568
|
+
const execution = rawCall?.name === "exec" || rawCall?.name === "wait" ? CODE_MODE_RESULT_RE.exec(responseText) : null;
|
|
3569
|
+
const codeModeCall = this.codeModeNativeCallsByCallId.get(callId);
|
|
3570
|
+
this.codeModeNativeCallsByCallId.delete(callId);
|
|
3571
|
+
if (codeModeCall && !codeModeCall.nativeItemObserved) {
|
|
3572
|
+
if (execution?.[1]?.toLowerCase() === "failed" || execution?.[1]?.toLowerCase() === "completed" && codeModeCall.call.name === "bash" && codeModeCommandFailed(execution[2] ?? "")) {
|
|
3573
|
+
const failure = execution?.[2]?.replace(/^Script error:\s*/iu, "").trim() || text;
|
|
3654
3574
|
this.recordToolCall({
|
|
3655
3575
|
id: callId,
|
|
3656
|
-
|
|
3657
|
-
arguments: { input: codeModePatchInput }
|
|
3576
|
+
...codeModeCall.call
|
|
3658
3577
|
});
|
|
3659
3578
|
this.recordToolResult({
|
|
3660
3579
|
id: callId,
|
|
3661
|
-
name:
|
|
3580
|
+
name: codeModeCall.call.name,
|
|
3662
3581
|
text: failure,
|
|
3663
3582
|
isError: true
|
|
3664
3583
|
});
|
|
@@ -3668,13 +3587,31 @@ var CodexToolTranscriptProjection = class {
|
|
|
3668
3587
|
const result = this.messages.find((message) => message.role === "toolResult" && message.toolCallId === callId);
|
|
3669
3588
|
if (!result) {
|
|
3670
3589
|
if (!this.namesById.has(callId) && rawCall) {
|
|
3671
|
-
|
|
3590
|
+
const isCommandFallback = type === "function_call_output" && rawCall.name === "exec_command";
|
|
3591
|
+
const name = isCommandFallback ? "bash" : rawCall.name;
|
|
3592
|
+
let args = rawCall.arguments;
|
|
3593
|
+
if (isCommandFallback && isJsonObject(args) && typeof args.arguments === "string") try {
|
|
3594
|
+
const parsed = JSON.parse(args.arguments);
|
|
3595
|
+
if (isJsonObject(parsed)) {
|
|
3596
|
+
const cwd = readStringField(parsed, "workdir") ?? readStringField(parsed, "cwd");
|
|
3597
|
+
args = {
|
|
3598
|
+
command: readStringField(parsed, "cmd") ?? readStringField(parsed, "command"),
|
|
3599
|
+
...cwd !== void 0 ? { cwd } : {}
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
} catch {}
|
|
3603
|
+
const commandWorkspaceRejected = isCommandFallback && NATIVE_COMMAND_WORKSPACE_REJECTION_RE.test(text);
|
|
3604
|
+
this.recordToolCall({
|
|
3605
|
+
...rawCall,
|
|
3606
|
+
name,
|
|
3607
|
+
arguments: args
|
|
3608
|
+
});
|
|
3672
3609
|
this.recordToolResult({
|
|
3673
3610
|
id: callId,
|
|
3674
|
-
name
|
|
3611
|
+
name,
|
|
3675
3612
|
text,
|
|
3676
|
-
isError: execution?.[1]?.toLowerCase() === "failed",
|
|
3677
|
-
...!execution ? { outcomeUnknown: true } : {}
|
|
3613
|
+
isError: commandWorkspaceRejected || execution?.[1]?.toLowerCase() === "failed",
|
|
3614
|
+
...!execution && !commandWorkspaceRejected ? { outcomeUnknown: true } : {}
|
|
3678
3615
|
});
|
|
3679
3616
|
} else if (this.namesById.get(callId) === "apply_patch" && NATIVE_PATCH_REJECTION_RE.test(text)) this.recordToolResult({
|
|
3680
3617
|
id: callId,
|
|
@@ -3717,8 +3654,8 @@ var CodexToolTranscriptProjection = class {
|
|
|
3717
3654
|
async prepareNativeMcpAppResultDetails(item) {
|
|
3718
3655
|
if (!item || item.type !== "mcpToolCall" || itemStatus(item) === "running") return;
|
|
3719
3656
|
if (this.nativeMcpAppResultDetails.has(item.id)) return this.nativeMcpAppResultDetails.get(item.id);
|
|
3720
|
-
if (
|
|
3721
|
-
this.
|
|
3657
|
+
if (!this.options.prepareNativeMcpAppResultDetails) return;
|
|
3658
|
+
this.nativeMcpAppResultDetails.set(item.id, void 0);
|
|
3722
3659
|
try {
|
|
3723
3660
|
const details = await this.options.prepareNativeMcpAppResultDetails(item);
|
|
3724
3661
|
if (details !== void 0) this.nativeMcpAppResultDetails.set(item.id, details);
|
|
@@ -3787,32 +3724,27 @@ var CodexToolTranscriptProjection = class {
|
|
|
3787
3724
|
}
|
|
3788
3725
|
synthesizeMissingToolResults(params) {
|
|
3789
3726
|
if (!params.synthesize) return;
|
|
3790
|
-
const
|
|
3791
|
-
const
|
|
3792
|
-
if (
|
|
3793
|
-
for (const id of
|
|
3794
|
-
const
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3727
|
+
const missingTranscript = [...this.namesById].filter(([id]) => !this.resultIds.has(id));
|
|
3728
|
+
const missingTrajectory = [...this.trajectoryNamesById].filter(([id]) => !this.trajectoryResultIds.has(id));
|
|
3729
|
+
if (missingTranscript.length === 0 && missingTrajectory.length === 0) return;
|
|
3730
|
+
for (const [id, name] of missingTranscript) {
|
|
3731
|
+
const processId = params.retainedCommands?.get(id);
|
|
3732
|
+
this.recordToolResult({
|
|
3733
|
+
id,
|
|
3734
|
+
name,
|
|
3735
|
+
text: processId ? formatRetainedCommandResult(processId) : formatMissingToolResultError({
|
|
3798
3736
|
id,
|
|
3799
|
-
name
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
processId
|
|
3809
|
-
} : { reason: "missing_tool_result" }
|
|
3810
|
-
});
|
|
3811
|
-
}
|
|
3737
|
+
name
|
|
3738
|
+
}),
|
|
3739
|
+
isError: !processId,
|
|
3740
|
+
...processId ? { outcomeUnknown: true } : {},
|
|
3741
|
+
details: processId ? {
|
|
3742
|
+
status: "running",
|
|
3743
|
+
processId
|
|
3744
|
+
} : { reason: "missing_tool_result" }
|
|
3745
|
+
});
|
|
3812
3746
|
}
|
|
3813
|
-
for (const id of
|
|
3814
|
-
const name = this.trajectoryNamesById.get(id) ?? this.namesById.get(id);
|
|
3815
|
-
if (!name) continue;
|
|
3747
|
+
for (const [id, name] of missingTrajectory) {
|
|
3816
3748
|
this.trajectoryResultIds.add(id);
|
|
3817
3749
|
const processId = params.retainedCommands?.get(id);
|
|
3818
3750
|
const text = processId ? formatRetainedCommandResult(processId) : formatMissingToolResultError({
|
|
@@ -3838,11 +3770,11 @@ var CodexToolTranscriptProjection = class {
|
|
|
3838
3770
|
});
|
|
3839
3771
|
}
|
|
3840
3772
|
if (params.terminalDisposition === "tool_error") {
|
|
3841
|
-
this.recordMissingToolError(
|
|
3773
|
+
this.recordMissingToolError([...missingTranscript, ...missingTrajectory]);
|
|
3842
3774
|
return;
|
|
3843
3775
|
}
|
|
3844
3776
|
if (params.terminalDisposition === "diagnostic_only") return;
|
|
3845
|
-
const missingCount =
|
|
3777
|
+
const missingCount = new Set([...missingTranscript, ...missingTrajectory].map(([id]) => id)).size;
|
|
3846
3778
|
return missingCount === 1 ? MISSING_TOOL_RESULT_ERROR : `${MISSING_TOOL_RESULT_ERROR} missingToolResultCount=${missingCount}`;
|
|
3847
3779
|
}
|
|
3848
3780
|
async readMirroredSessionMessages(signal) {
|
|
@@ -3873,11 +3805,11 @@ var CodexToolTranscriptProjection = class {
|
|
|
3873
3805
|
ready: () => !this.pendingRawOutputIds.has(params.id)
|
|
3874
3806
|
});
|
|
3875
3807
|
}
|
|
3876
|
-
recordMissingToolError(
|
|
3877
|
-
const
|
|
3878
|
-
if (!
|
|
3879
|
-
const
|
|
3880
|
-
|
|
3808
|
+
recordMissingToolError(missing) {
|
|
3809
|
+
const first = missing.find(([, name]) => Boolean(name));
|
|
3810
|
+
if (!first || !first[0]) return;
|
|
3811
|
+
const [firstMissingId, recordedName] = first;
|
|
3812
|
+
const name = this.namesById.get(firstMissingId) ?? recordedName;
|
|
3881
3813
|
const item = this.trajectoryItemsById.get(firstMissingId);
|
|
3882
3814
|
const meta = item ? itemMeta(item, this.progress.toolProgressDetailMode()) : this.progress.getToolMeta(firstMissingId)?.meta;
|
|
3883
3815
|
this.progress.setLastToolError({
|
|
@@ -3968,7 +3900,6 @@ function normalizeApprovalReviewStatus(status) {
|
|
|
3968
3900
|
return status === "inProgress" ? "in_progress" : status === "timedOut" ? "timed_out" : status;
|
|
3969
3901
|
}
|
|
3970
3902
|
const GUARDIAN_TIMEOUT_WARNING = "Automatic approval review timed out while evaluating the requested approval.";
|
|
3971
|
-
const LOG_ONLY_CODEX_WARNING_PATTERNS = [/^Configured service tier `[^`\r\n]+` is not advertised as supported for model `[^`\r\n]+` and will be omitted from requests\.$/, /^Code Mode is enabled in configuration, but model `[^`\r\n]+` does not advertise Code Mode support\. This may degrade model performance\. Disable `features\.code_mode` and `features\.code_mode_only`, or select a model whose metadata enables Code Mode\.$/];
|
|
3972
3903
|
function projectNormalizedToolItem(params) {
|
|
3973
3904
|
const { item } = params;
|
|
3974
3905
|
if (!item || !isProjectedNativeToolItem(item)) return;
|
|
@@ -4113,9 +4044,8 @@ var CodexEventProjection = class {
|
|
|
4113
4044
|
});
|
|
4114
4045
|
}
|
|
4115
4046
|
handleWarning(params) {
|
|
4116
|
-
const message =
|
|
4117
|
-
if (
|
|
4118
|
-
else if (message) this.emitAgentEvent({
|
|
4047
|
+
const message = readCodexAppServerWarningMessage(params);
|
|
4048
|
+
if (message) this.emitAgentEvent({
|
|
4119
4049
|
stream: "notice",
|
|
4120
4050
|
data: {
|
|
4121
4051
|
phase: "warning",
|
|
@@ -4534,7 +4464,6 @@ var Monitor = class {
|
|
|
4534
4464
|
this.childThreadIdsByAgentPath = /* @__PURE__ */ new Map();
|
|
4535
4465
|
this.parentThreadRetentions = /* @__PURE__ */ new Map();
|
|
4536
4466
|
this.disposed = false;
|
|
4537
|
-
this.now = options.now ?? Date.now;
|
|
4538
4467
|
this.interruptModelExecution = options.interruptModelExecution;
|
|
4539
4468
|
this.admissionCustody = new CodexNativeSubagentAdmissionCustody({
|
|
4540
4469
|
parentState: (id) => this.parentStates.get(id),
|
|
@@ -4554,7 +4483,7 @@ var Monitor = class {
|
|
|
4554
4483
|
currentChild: (id) => this.currentChild(id),
|
|
4555
4484
|
isRegisteredChild: (child) => this.childStates.get(child.runId) === child,
|
|
4556
4485
|
captureForget: options.captureChildThreadForget,
|
|
4557
|
-
releaseDirectChild:
|
|
4486
|
+
releaseDirectChild: releaseNativeDirectChild,
|
|
4558
4487
|
clearRecoveryTimers: (child) => this.recovery.clearRecoveryTimers(child),
|
|
4559
4488
|
markTerminalRevision: (id) => this.recovery.markTerminalRevision(id),
|
|
4560
4489
|
unregisterChild: (child) => this.unregisterChild(child, { retainSubscription: false }),
|
|
@@ -4572,7 +4501,6 @@ var Monitor = class {
|
|
|
4572
4501
|
});
|
|
4573
4502
|
this.completionDelivery = new CodexNativeSubagentCompletionDelivery({
|
|
4574
4503
|
deliver: (params) => runtime.deliverAgentHarnessCompletion(params),
|
|
4575
|
-
now: this.now,
|
|
4576
4504
|
retryDelaysMs: options.completionDeliveryRetryDelaysMs,
|
|
4577
4505
|
maxRetries: options.completionDeliveryMaxRetries,
|
|
4578
4506
|
isCurrentChild: (child) => this.childStates.get(child.runId) === child,
|
|
@@ -4603,10 +4531,8 @@ var Monitor = class {
|
|
|
4603
4531
|
isRegisteredChild: (child) => this.childStates.get(child.runId) === child,
|
|
4604
4532
|
currentChild: (id) => this.currentChild(id),
|
|
4605
4533
|
parentState: (id) => this.parentStates.get(id),
|
|
4606
|
-
isRetiredParent: (state) => this.retiredParentStates.has(state),
|
|
4607
4534
|
reconcileChildState: (child) => this.reconcileChildState(child),
|
|
4608
4535
|
processCompletion: (state, child, completion, eventAt) => this.processCompletion(state, child, completion, eventAt),
|
|
4609
|
-
now: this.now,
|
|
4610
4536
|
recoveryPollDelaysMs: options.recoveryPollDelaysMs
|
|
4611
4537
|
});
|
|
4612
4538
|
this.removeNotificationHandler = client.addNotificationHandler(async (notification) => {
|
|
@@ -4677,7 +4603,7 @@ var Monitor = class {
|
|
|
4677
4603
|
if (this.retiredParentStates.has(state) || !this.disposed && this.parentStates.get(state.parentThreadId) !== state) throw new Error("Native assignment parent is no longer current.");
|
|
4678
4604
|
state.assignmentStore?.assertCurrent();
|
|
4679
4605
|
},
|
|
4680
|
-
isCurrent: (state) =>
|
|
4606
|
+
isCurrent: (state) => this.isCurrentParent(state),
|
|
4681
4607
|
readHistory: async (assignment) => {
|
|
4682
4608
|
const revision = this.recovery.retainThreadStatusRevision(assignment.childThreadId);
|
|
4683
4609
|
try {
|
|
@@ -4798,14 +4724,12 @@ var Monitor = class {
|
|
|
4798
4724
|
registerParent(params) {
|
|
4799
4725
|
return registerNativeSubagentParent(params, {
|
|
4800
4726
|
states: this.parentStates,
|
|
4801
|
-
children: this.childStates,
|
|
4802
4727
|
isClosed: () => this.disposed,
|
|
4803
4728
|
isRetired: (state) => this.retiredParentStates.has(state),
|
|
4804
4729
|
runtime: this.runtime,
|
|
4805
4730
|
submissions: this.submissions,
|
|
4806
4731
|
assignments: this.assignments,
|
|
4807
4732
|
closes: this.childCloses,
|
|
4808
|
-
deliverPending: (state, child) => this.completionDelivery.deliverPending(state, child),
|
|
4809
4733
|
deliverDetached: (state) => this.completionDelivery.deliverDetached(state, this.childStates.values()),
|
|
4810
4734
|
drainAdmissions: (state, owner, turnId) => this.drainPendingChildAdmissionEvidence(state, owner, turnId, true),
|
|
4811
4735
|
clearAdmissions: () => this.clearUnconsumablePendingChildAdmissionEvidence(),
|
|
@@ -4993,7 +4917,7 @@ var Monitor = class {
|
|
|
4993
4917
|
} else {
|
|
4994
4918
|
if (childState) {
|
|
4995
4919
|
this.resumeChild(childState, { scheduleRecovery: false });
|
|
4996
|
-
this.recovery.setRecoveryFallback(childState, systemErrorFallbackCompletion(childState.childThreadId),
|
|
4920
|
+
this.recovery.setRecoveryFallback(childState, systemErrorFallbackCompletion(childState.childThreadId), Date.now());
|
|
4997
4921
|
}
|
|
4998
4922
|
this.reconcileChildThread(threadId).catch((error) => {
|
|
4999
4923
|
logRecoveryFailure(threadId, error);
|
|
@@ -5092,7 +5016,7 @@ var Monitor = class {
|
|
|
5092
5016
|
return;
|
|
5093
5017
|
}
|
|
5094
5018
|
this.resumeChild(childState, { scheduleRecovery: false });
|
|
5095
|
-
this.recovery.setRecoveryFallback(childState, completion,
|
|
5019
|
+
this.recovery.setRecoveryFallback(childState, completion, Date.now());
|
|
5096
5020
|
await this.recovery.reconcileRegisteredChild(childState).catch((error) => {
|
|
5097
5021
|
logRecoveryFailure(childState.childThreadId, error);
|
|
5098
5022
|
return false;
|
|
@@ -5145,7 +5069,7 @@ var Monitor = class {
|
|
|
5145
5069
|
const completion = recovery.completion;
|
|
5146
5070
|
if (completion && !isNoFinalCompletion(completion)) return this.processCompletion(state, child, completion, completion.completedAt);
|
|
5147
5071
|
const fallback = completion ?? recovery.fallbackCompletion;
|
|
5148
|
-
if (fallback) this.recovery.setRecoveryFallback(child, fallback, fallback.completedAt ??
|
|
5072
|
+
if (fallback) this.recovery.setRecoveryFallback(child, fallback, fallback.completedAt ?? Date.now());
|
|
5149
5073
|
}
|
|
5150
5074
|
recordRecoveredChildTurn(state, child, recovery) {
|
|
5151
5075
|
const known = this.knownChildren.get(child.childThreadId);
|
|
@@ -5176,7 +5100,7 @@ var Monitor = class {
|
|
|
5176
5100
|
this.submissions.observeKnownChild(child.childThreadId);
|
|
5177
5101
|
return this.admitFollowupChild(known, child.childThreadId);
|
|
5178
5102
|
}
|
|
5179
|
-
async processCompletion(state, childState, completion, eventAt =
|
|
5103
|
+
async processCompletion(state, childState, completion, eventAt = Date.now()) {
|
|
5180
5104
|
if (childState.terminal) return;
|
|
5181
5105
|
const acceptedCompletion = childState.modelExecution?.executionOwner.modelExecutionCancelled || childState.nativeTurnId && childState.cancelledModelTurnId === childState.nativeTurnId ? {
|
|
5182
5106
|
childThreadId: childState.childThreadId,
|
|
@@ -5206,11 +5130,8 @@ var Monitor = class {
|
|
|
5206
5130
|
this.completionDelivery.applyReceipts(state, runIds, this.childStates);
|
|
5207
5131
|
}
|
|
5208
5132
|
resolveChildReceiptOwner(state, childThreadId) {
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
childThreadId,
|
|
5212
|
-
known: this.knownChildren.get(childThreadId)
|
|
5213
|
-
});
|
|
5133
|
+
const known = this.knownChildren.get(childThreadId);
|
|
5134
|
+
return known?.parent === state ? known.deliveryReceipts : state.deliveryReceipts;
|
|
5214
5135
|
}
|
|
5215
5136
|
prepareReceiverChild(state, threadId, nativeParentThreadId) {
|
|
5216
5137
|
const known = this.knownChildren.get(threadId);
|
|
@@ -5602,44 +5523,40 @@ var Monitor = class {
|
|
|
5602
5523
|
}
|
|
5603
5524
|
}
|
|
5604
5525
|
restoreKnownChild(state, assignment, observedTurns = []) {
|
|
5605
|
-
const
|
|
5606
|
-
const
|
|
5607
|
-
const nativeParentThreadId = state.parentThreadId;
|
|
5608
|
-
const currentIndex = observedTurns.findIndex((turn) => turn.turnId === current.nativeTurnId);
|
|
5609
|
-
const pendingTurns = observedTurns.filter((turn, index) => index > currentIndex && turn.turnId !== current.nativeTurnId).map((turn, index, turns) => ({
|
|
5526
|
+
const currentIndex = observedTurns.findIndex((turn) => turn.turnId === assignment.nativeTurnId);
|
|
5527
|
+
const pendingTurns = observedTurns.filter((turn, index) => index > currentIndex && turn.turnId !== assignment.nativeTurnId).map((turn, index, turns) => ({
|
|
5610
5528
|
turnId: turn.turnId,
|
|
5611
5529
|
state: turn.state === "active" && index < turns.length - 1 ? void 0 : turn.state
|
|
5612
5530
|
}));
|
|
5613
5531
|
const previous = this.knownChildren.get(assignment.childThreadId);
|
|
5614
5532
|
const previousRunId = previous?.assignment.runId;
|
|
5615
5533
|
const retainedPending = previous?.pendingTurns.filter((pending) => pending.modelSource) ?? [];
|
|
5616
|
-
const mergedPending = pendingTurns;
|
|
5617
5534
|
for (const retained of retainedPending) {
|
|
5618
|
-
const recovered =
|
|
5535
|
+
const recovered = pendingTurns.find((pending) => pending.turnId === retained.turnId);
|
|
5619
5536
|
if (recovered) {
|
|
5620
5537
|
recovered.modelSource = retained.modelSource;
|
|
5621
5538
|
recovered.completionCustody = retained.completionCustody;
|
|
5622
5539
|
retained.completionCustody = void 0;
|
|
5623
|
-
} else
|
|
5540
|
+
} else pendingTurns.push(retained);
|
|
5624
5541
|
}
|
|
5625
|
-
for (const pending of previous?.pendingTurns ?? []) if (!
|
|
5542
|
+
for (const pending of previous?.pendingTurns ?? []) if (!pendingTurns.includes(pending)) releaseCompletionCustody(pending);
|
|
5626
5543
|
this.knownChildren.set(assignment.childThreadId, {
|
|
5627
5544
|
configurationQualification: previous?.configurationQualification,
|
|
5628
5545
|
parent: state,
|
|
5629
|
-
nativeParentThreadId: this.childStates.get(
|
|
5546
|
+
nativeParentThreadId: this.childStates.get(assignment.runId)?.nativeParentThreadId ?? state.parentThreadId,
|
|
5630
5547
|
deliveryReceipts: this.resolveChildReceiptOwner(state, assignment.childThreadId),
|
|
5631
5548
|
assignment: {
|
|
5632
|
-
...
|
|
5633
|
-
terminal
|
|
5549
|
+
...assignment,
|
|
5550
|
+
terminal: false
|
|
5634
5551
|
},
|
|
5635
|
-
turnId: pendingTurns.at(-1)?.turnId ??
|
|
5636
|
-
observedTurns: new Map([...new Set([
|
|
5637
|
-
pendingTurns
|
|
5552
|
+
turnId: pendingTurns.at(-1)?.turnId ?? assignment.nativeTurnId,
|
|
5553
|
+
observedTurns: new Map([...new Set([assignment.nativeTurnId, ...observedTurns.map((turn) => turn.turnId)].filter((id) => Boolean(id)))].map((turnId) => [turnId, pendingTurns.some((turn) => turn.turnId === turnId) ? { awaitingInteraction: true } : {}])),
|
|
5554
|
+
pendingTurns,
|
|
5638
5555
|
agentPaths: this.knownChildren.get(assignment.childThreadId)?.agentPaths ?? /* @__PURE__ */ new Set([assignment.childThreadId])
|
|
5639
5556
|
});
|
|
5640
|
-
if (previousRunId !==
|
|
5557
|
+
if (previousRunId !== assignment.runId) this.refreshWaitDependency(state, assignment.childThreadId);
|
|
5641
5558
|
}
|
|
5642
5559
|
};
|
|
5643
5560
|
const codexNativeSubagentMonitorRuntime = createCodexNativeSubagentMonitorRuntime(Monitor);
|
|
5644
5561
|
//#endregion
|
|
5645
|
-
export {
|
|
5562
|
+
export { CodexToolTranscriptProjection as a, shouldEmitTranscriptToolProgress as c, resolveCodexToolProgressDetailMode as d, sanitizeCodexAgentEventRecord as f, emitCodexAgentEvent as i, projectCodexWebSearchItem as l, native_subagent_monitor_exports as n, resolveCodexLocalRuntimeAttribution as o, sanitizeCodexToolArguments as p, CodexEventProjection as r, CodexToolProgressProjection as s, codexNativeSubagentMonitorRuntime as t, isCodexCommandBearingToolCall as u };
|