@openclaw/codex 2026.9.5 → 2026.9.6
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/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-Eem_WGqY.mjs} +5 -5
- package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-DDOi8uNx.mjs} +22 -28
- package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-CEv1cKwF.mjs} +58 -43
- package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +331 -0
- package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-B2mpaI9D.mjs} +9 -81
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-ThoatDcb.mjs} +1 -1
- package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-yoHrABt-.mjs} +4 -4
- package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-B2HScEgT.mjs} +138 -32
- package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-C7EnDVgr.mjs} +1 -1
- package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-CDXOOFdZ.mjs} +1 -1
- package/dist/.setup/{client-vXs2929Q.mjs → client-Cs08OXVQ.mjs} +583 -559
- package/dist/.setup/client-catalog-response-BMgt_4q4.mjs +285 -0
- package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-B4JuOsOk.mjs} +8 -4
- package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-Bmqvr9tO.mjs} +8 -4
- package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-DW7Lx9oH.mjs} +106 -172
- package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-DixIj3HW.mjs} +36 -21
- package/dist/.setup/{compact-C3i3qlzj.mjs → compact-Du5UvtxA.mjs} +14 -21
- package/dist/.setup/{config-CedDWjM-.mjs → config-BoTP_mrL.mjs} +3 -3
- package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-BvaRs51b.mjs} +46 -30
- package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C8Rw1m1m.mjs} +1 -1
- package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-BEReZ6go.mjs} +35 -120
- package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-DP-gMrBP.mjs} +21 -32
- package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-uK9Jomlc.mjs} +28 -67
- package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-BDXl-8Cw.mjs} +848 -578
- package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CvnvnGIe.mjs} +3 -3
- package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-poidXgek.mjs} +9 -6
- package/dist/.setup/{event-projector-assistant-message-DNUR1s0A.mjs → event-projector-assistant-message-BsruvNrH.mjs} +2 -4
- package/dist/.setup/{event-projector-items-DyTQ_XqL.mjs → event-projector-items-C6L_5ZiT.mjs} +42 -8
- package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-CnBS8Wa3.mjs} +1 -1
- package/dist/.setup/{harness-rxaaoN-o.mjs → harness-a_MsE4-_.mjs} +23 -17
- package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D96l9-ew.mjs} +1 -1
- package/dist/.setup/inference-proxy-b-aJMSxm.mjs +601 -0
- package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-BIZFhTNG.mjs} +17 -10
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-BnshlFag.mjs} +13 -2
- package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-CfXJf9Ay.mjs} +9 -10
- package/dist/.setup/{models-BDFgm_G-.mjs → models-KnqBv0hE.mjs} +3 -3
- package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-rWbGbMn3.mjs} +4 -4
- package/dist/.setup/{native-subagent-history-YXaL6dMd.mjs → native-subagent-history-0nYYgo0k.mjs} +26 -13
- package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-D3filLY2.mjs} +145 -317
- package/dist/.setup/{native-subagent-task-ids-DsuOonKv.mjs → native-subagent-task-ids-wb8CKZGN.mjs} +69 -39
- package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-r3avj02l.mjs} +86 -68
- package/dist/.setup/node-exec-server.runtime-BDwWXVpK.mjs +247 -0
- package/dist/.setup/{plan-xD7WKYTM.mjs → plan-CN3VwfNU.mjs} +74 -76
- package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-DT3MNtqj.mjs} +7 -16
- package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-B2CsSdnV.mjs} +4 -20
- package/dist/.setup/{plugin-approval-roundtrip-CjfzafAZ.mjs → plugin-approval-roundtrip-C0MZzCuP.mjs} +1 -1
- package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-BoRei8Z4.mjs} +16 -7
- package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-CDOi8IFs.mjs} +4 -1
- package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-Ctmo83k_.mjs} +224 -154
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/.setup/{provider-fFh_-VR3.mjs → provider-BOsxQHOM.mjs} +9 -5
- package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-BfE88FZ5.mjs} +31 -3
- package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-CMU3DUD0.mjs} +116 -137
- package/dist/.setup/{request-BioXJLYa.mjs → request-D2L0zMrq.mjs} +23 -15
- package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-BHu11r7h.mjs} +1197 -617
- package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-CLZ8udh-.mjs} +29 -45
- package/dist/.setup/{sandbox-guard-BBP-RbTf.mjs → sandbox-guard-C2sRMOEY.mjs} +1 -1
- package/dist/.setup/{session-binding-_0W_fHRr.mjs → session-binding-Cm0apEbd.mjs} +3 -32
- package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-BGoz8wOK.mjs} +22 -3
- package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-BlB5EvIS.mjs} +48 -45
- package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-Pno1xGcl.mjs} +482 -182
- package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BI6UTDZT.mjs} +57 -25
- package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-lHBqzhaO.mjs} +6 -6
- package/dist/.setup/{session-catalog-events-jMcYfQyd.mjs → session-catalog-events-Bj6j94E_.mjs} +122 -25
- package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-B9_VQIUz.mjs} +178 -78
- package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-hcdz07yN.mjs} +2 -2
- package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-Dgh8ORJm.mjs} +5 -2
- package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-native-projection-DowriLid.mjs} +30 -13
- package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-ITddWx_X.mjs} +24 -12
- package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-6g6qi4A9.mjs} +22 -13
- package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-zK_PUsiE.mjs} +13 -5
- package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-irrD-uo7.mjs} +4 -4
- package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-BrqhSCf9.mjs} +17 -22
- package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-D-3wAgOP.mjs} +4 -4
- package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-CaCh0xF_.mjs} +5 -18
- package/dist/.setup/{session-initialization-DH1z6fXn.mjs → session-initialization-rcgbZiid.mjs} +2 -2
- package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-BI1QK_98.mjs} +2 -2
- package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-BH-S6qkJ.mjs} +25 -6
- package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-DiAi6Kx6.mjs} +8 -8
- package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DA4VR4Eb.mjs} +59 -89
- package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-BJ1wSDcB.mjs} +147 -211
- package/dist/.setup/{source-Bjp4UQij.mjs → source-CUzJq5WN.mjs} +9 -9
- 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-history-page-BTx-4xsg.mjs → thread-history-page-DoVpnHim.mjs} +1 -1
- package/dist/.setup/{thread-lifecycle-Cik28qWn.mjs → thread-lifecycle-B3mfz1TG.mjs} +172 -2271
- package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-DcTtAcXj.mjs} +4 -2
- package/dist/.setup/{thread-policy-Cjs4B8xf.mjs → thread-policy-DGuQsuFC.mjs} +19 -3
- package/dist/.setup/thread-requests-BLvGkP2R.mjs +2205 -0
- package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-DIBXwOpE.mjs} +6 -6
- package/dist/.setup/{timeout-DZF05XrR.mjs → timeout-C910MdAB.mjs} +19 -2
- package/dist/.setup/{transcript-history-projection-DHNBDhCU.mjs → transcript-history-projection-ZZpkFkJ_.mjs} +94 -64
- package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-BtHDBp1G.mjs} +218 -198
- package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-h2VHOskC.mjs} +135 -55
- package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-BUr4OUbC.mjs} +44 -36
- package/dist/.setup/{usage-BOgBEKso.mjs → usage-BML0r-ua.mjs} +5 -4
- package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-DUMbefVY.mjs} +4 -4
- package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-CDKlN-Rv.mjs} +4 -3
- package/dist/api.js +23 -12
- 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 +2 -2
- package/dist/harness.js +1 -1
- package/dist/index.js +221 -170
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +15 -32
- package/dist/session-history.worker.js +1 -1
- package/package.json +9 -6
- package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
- package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
- package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
- package/dist/.setup/version-CoqzXPgK.mjs +0 -12
- package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-umd0tgh4.mjs} +1 -1
package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-D3filLY2.mjs}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { C as readCodexNativeSubagentHistoryOwner, S as matchesCodexNativeSubagentHistoryOwner, y as assertHistoryOwnerMatchesRegistration } from "./session-binding-record-BGoz8wOK.mjs";
|
|
2
|
+
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
3
|
+
import { D as readNullableString$1, S as readItem, a as isNonSuccessItemStatus, c as itemName, d as matchesCodexSnapshotTurn, h as unknownItemStatus, i as isMutatingNativeToolItem, l as itemStatus, m as shouldSynthesizeToolProgressForItem, n as auditNativeToolTerminalStatus, o as isSideEffectingNativeToolItem, p as shouldRecordNativeToolTranscript, s as itemKind, u as itemTitle, x as readHookOutputEntries } from "./event-projector-items-C6L_5ZiT.mjs";
|
|
4
4
|
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.mjs";
|
|
5
|
-
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-
|
|
6
|
-
import { I as hasCodexAppServerLiveThread, M as claimCodexAppServerLiveThread, W as retainCodexAppServerLiveThread } from "./shared-client-
|
|
5
|
+
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-BrqhSCf9.mjs";
|
|
6
|
+
import { I as hasCodexAppServerLiveThread, M as claimCodexAppServerLiveThread, W as retainCodexAppServerLiveThread } from "./shared-client-DA4VR4Eb.mjs";
|
|
7
7
|
import { t as resolveCodexLocalRuntimeAttribution } from "./local-runtime-attribution-B_2mnqhb.mjs";
|
|
8
|
-
import { A as
|
|
9
|
-
import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-
|
|
8
|
+
import { A as formatToolSummary, C as sanitizeCodexToolArguments, D as ToolOutputAccumulator, E as TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS, M as readCodexResponseOutput, N as toolOutputRawEchoSignature, O as collectDynamicToolContentText, P as truncateToolTranscriptText, S as resolveCodexToolProgressDetailMode, _ as readCodeModeNativePatchInput, a as readCodexNativeSubagentRunId, c as isCommandBearingToolItem, d as itemOutputText, f as itemToolArgs, g as projectCodexToolActivity, h as itemTranscriptResultText, i as codexNativeSubagentRunId, j as normalizeToolTranscriptArguments, k as formatToolOutput, l as isNativePostToolUseRelayItem, m as itemToolResult, n as CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX, o as readNativeSubagentThreadIds, p as itemToolError, r as CODEX_NATIVE_SUBAGENT_TASK_KIND, s as readNativeTaskAssignment, t as CODEX_NATIVE_SUBAGENT_RUNTIME, u as itemMeta, v as readInterceptedNativePatchInput, x as isCodexCommandBearingToolCall, y as shouldSuppressChannelProgressForItem } from "./native-subagent-task-ids-wb8CKZGN.mjs";
|
|
9
|
+
import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-C0MZzCuP.mjs";
|
|
10
10
|
import { asFiniteNumber, normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
12
12
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -14,7 +14,7 @@ import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
16
16
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
17
|
-
import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage, inferToolMetaFromArgs, runAgentHarnessAfterToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
17
|
+
import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage, inferToolMetaFromArgs, projectAgentActivityItem, runAgentHarnessAfterToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
18
18
|
import { createAgentHarnessTaskRuntime, deliverAgentHarnessTaskCompletion, isDurableAgentHarnessCompletionDelivery } from "openclaw/plugin-sdk/agent-harness-task-runtime";
|
|
19
19
|
//#region extensions/codex/src/app-server/event-projector-tool-progress.ts
|
|
20
20
|
const TRANSCRIPT_PROGRESS_SUPPRESSED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -26,7 +26,7 @@ const TRANSCRIPT_PROGRESS_SUPPRESSED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
26
26
|
"react",
|
|
27
27
|
"typing"
|
|
28
28
|
]);
|
|
29
|
-
function shouldEmitTranscriptToolProgress(toolName
|
|
29
|
+
function shouldEmitTranscriptToolProgress(toolName) {
|
|
30
30
|
const normalized = typeof toolName === "string" ? toolName.trim().toLowerCase() : "";
|
|
31
31
|
return Boolean(normalized && !TRANSCRIPT_PROGRESS_SUPPRESSED_TOOL_NAMES.has(normalized));
|
|
32
32
|
}
|
|
@@ -38,7 +38,6 @@ var CodexToolProgressProjection = class {
|
|
|
38
38
|
this.resultOutputItemIds = /* @__PURE__ */ new Set();
|
|
39
39
|
this.resultOutputStreamedItemIds = /* @__PURE__ */ new Set();
|
|
40
40
|
this.transcriptProgressSuppressedIds = /* @__PURE__ */ new Set();
|
|
41
|
-
this.transcriptArgumentsById = /* @__PURE__ */ new Map();
|
|
42
41
|
this.resultOutputDeltaState = /* @__PURE__ */ new Map();
|
|
43
42
|
this.output = new ToolOutputAccumulator();
|
|
44
43
|
this.metas = /* @__PURE__ */ new Map();
|
|
@@ -50,6 +49,9 @@ var CodexToolProgressProjection = class {
|
|
|
50
49
|
get outputTextByItem() {
|
|
51
50
|
return this.output.textByItem;
|
|
52
51
|
}
|
|
52
|
+
isOutputTruncated(itemId) {
|
|
53
|
+
return this.output.isTruncated(itemId);
|
|
54
|
+
}
|
|
53
55
|
get toolMetas() {
|
|
54
56
|
return [...this.metas.values()];
|
|
55
57
|
}
|
|
@@ -118,7 +120,7 @@ var CodexToolProgressProjection = class {
|
|
|
118
120
|
streamedDisplay: true
|
|
119
121
|
});
|
|
120
122
|
if (!this.shouldEmitToolOutput()) return;
|
|
121
|
-
if (this.transcriptProgressSuppressedIds.has(itemId) || !shouldEmitTranscriptToolProgress(toolName
|
|
123
|
+
if (this.transcriptProgressSuppressedIds.has(itemId) || !shouldEmitTranscriptToolProgress(toolName)) return;
|
|
122
124
|
const state = this.resultOutputDeltaState.get(itemId) ?? {
|
|
123
125
|
chars: 0,
|
|
124
126
|
messages: 0,
|
|
@@ -126,16 +128,6 @@ var CodexToolProgressProjection = class {
|
|
|
126
128
|
};
|
|
127
129
|
if (state.truncated) return;
|
|
128
130
|
const remainingChars = Math.max(0, TOOL_PROGRESS_OUTPUT_MAX_CHARS - state.chars);
|
|
129
|
-
const remainingMessages = Math.max(0, 20 - state.messages);
|
|
130
|
-
if (remainingChars === 0 || remainingMessages === 0) {
|
|
131
|
-
state.truncated = true;
|
|
132
|
-
this.resultOutputDeltaState.set(itemId, state);
|
|
133
|
-
this.emitToolResultMessage({
|
|
134
|
-
itemId,
|
|
135
|
-
text: formatToolOutput(toolName, void 0, "(output truncated)")
|
|
136
|
-
});
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
131
|
const chunk = delta.length > remainingChars ? truncateUtf16Safe(delta, remainingChars) : delta;
|
|
140
132
|
state.chars += chunk.length;
|
|
141
133
|
state.messages += 1;
|
|
@@ -190,7 +182,7 @@ var CodexToolProgressProjection = class {
|
|
|
190
182
|
if (this.resultSummaryItemIds.has(item.id)) return;
|
|
191
183
|
const toolName = itemName(item);
|
|
192
184
|
const args = itemToolArgs(item);
|
|
193
|
-
if (!toolName || !shouldEmitTranscriptToolProgress(toolName
|
|
185
|
+
if (!toolName || !shouldEmitTranscriptToolProgress(toolName)) return;
|
|
194
186
|
this.resultSummaryItemIds.add(item.id);
|
|
195
187
|
const meta = this.shouldIncludeFormattedMeta(isCommandBearingToolItem(item, args)) ? itemMeta(item, this.toolProgressDetailMode()) : void 0;
|
|
196
188
|
this.emitToolResultMessage({
|
|
@@ -204,7 +196,7 @@ var CodexToolProgressProjection = class {
|
|
|
204
196
|
if (this.resultOutputItemIds.has(item.id) || this.resultOutputStreamedItemIds.has(item.id)) return;
|
|
205
197
|
const toolName = itemName(item);
|
|
206
198
|
const output = itemOutputText(item, this.output.textByItem);
|
|
207
|
-
if (!toolName || !output || !shouldEmitTranscriptToolProgress(toolName
|
|
199
|
+
if (!toolName || !output || !shouldEmitTranscriptToolProgress(toolName)) return;
|
|
208
200
|
const meta = this.shouldIncludeFormattedMeta(isCommandBearingToolItem(item, itemToolArgs(item))) ? itemMeta(item, this.toolProgressDetailMode()) : void 0;
|
|
209
201
|
this.emitToolResultMessage({
|
|
210
202
|
itemId: item.id,
|
|
@@ -231,8 +223,7 @@ var CodexToolProgressProjection = class {
|
|
|
231
223
|
});
|
|
232
224
|
}
|
|
233
225
|
recordTranscriptCall(params) {
|
|
234
|
-
this.
|
|
235
|
-
if (!shouldEmitTranscriptToolProgress(params.name, params.arguments)) this.transcriptProgressSuppressedIds.add(params.id);
|
|
226
|
+
if (!shouldEmitTranscriptToolProgress(params.name)) this.transcriptProgressSuppressedIds.add(params.id);
|
|
236
227
|
else this.transcriptProgressSuppressedIds.delete(params.id);
|
|
237
228
|
this.emitTranscriptToolCallProgress(params);
|
|
238
229
|
}
|
|
@@ -267,7 +258,7 @@ var CodexToolProgressProjection = class {
|
|
|
267
258
|
try {
|
|
268
259
|
Promise.resolve(this.params.onToolResult?.({
|
|
269
260
|
text,
|
|
270
|
-
...(this.params.messageChannel || this.params.messageProvider) && { channelData: { openclawToolProgressId: params.itemId } },
|
|
261
|
+
...(this.params.messageChannel || this.params.messageProvider) && { channelData: { openclawToolProgressId: `tool:${params.itemId}` } },
|
|
271
262
|
...params.isError === true ? { isError: true } : {}
|
|
272
263
|
})).catch(() => {});
|
|
273
264
|
} catch {}
|
|
@@ -283,7 +274,7 @@ var CodexToolProgressProjection = class {
|
|
|
283
274
|
return !commandBearing || !channel && this.shouldEmitToolOutput();
|
|
284
275
|
}
|
|
285
276
|
emitTranscriptToolCallProgress(params) {
|
|
286
|
-
if (params.name === "progress_card" || !shouldEmitTranscriptToolProgress(params.name
|
|
277
|
+
if (params.name === "progress_card" || !shouldEmitTranscriptToolProgress(params.name)) return;
|
|
287
278
|
this.transcriptProgressCallIds.add(params.id);
|
|
288
279
|
const args = normalizeToolTranscriptArguments(params.arguments);
|
|
289
280
|
const meta = this.shouldIncludeFormattedMeta(isCodexCommandBearingToolCall(params.name, args)) ? inferToolMetaFromArgs(params.name, args, { detailMode: this.toolProgressDetailMode() }) : void 0;
|
|
@@ -295,7 +286,7 @@ var CodexToolProgressProjection = class {
|
|
|
295
286
|
});
|
|
296
287
|
}
|
|
297
288
|
emitTranscriptToolResultProgress(params) {
|
|
298
|
-
if (params.name === "progress_card" && !params.isError || this.transcriptProgressSuppressedIds.has(params.id) || !shouldEmitTranscriptToolProgress(params.name
|
|
289
|
+
if (params.name === "progress_card" && !params.isError || this.transcriptProgressSuppressedIds.has(params.id) || !shouldEmitTranscriptToolProgress(params.name)) return;
|
|
299
290
|
if (params.name === "progress_card" && this.shouldEmitToolResult()) this.emitToolResultMessage({
|
|
300
291
|
itemId: params.id,
|
|
301
292
|
text: formatToolSummary(params.name),
|
|
@@ -368,38 +359,11 @@ const ZERO_USAGE = {
|
|
|
368
359
|
};
|
|
369
360
|
const MISSING_TOOL_RESULT_ERROR = "OpenClaw recorded a native Codex tool.call without a matching tool.result before the turn completed.";
|
|
370
361
|
const NATIVE_PATCH_REJECTION_RE = /^\s*patch rejected:\s*writing outside of the project;\s*rejected by user approval settings\s*$/iu;
|
|
371
|
-
const
|
|
372
|
-
const CODE_MODE_NATIVE_PATCH_RESULT_RE = /^\s*Script (completed|failed)\s*\r?\nWall time\s+\d+(?:\.\d+)?\s+seconds\s*\r?\nOutput:\s*([\s\S]*?)\s*$/iu;
|
|
362
|
+
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;
|
|
373
363
|
const MAX_TOOL_APPROVAL_REVIEWS = 16;
|
|
374
364
|
function toolApprovalReviewOutcome(state) {
|
|
375
365
|
return state.denied ? "denied" : state.unresolvedReviewIds === null || state.unresolvedReviewIds.size > 0 ? "reviewing" : "approved";
|
|
376
366
|
}
|
|
377
|
-
function readCodeModeNativePatchInput(source) {
|
|
378
|
-
if (typeof source !== "string") return;
|
|
379
|
-
const match = CODE_MODE_NATIVE_PATCH_SOURCE_RE.exec(source);
|
|
380
|
-
if (!match?.[2]) return;
|
|
381
|
-
try {
|
|
382
|
-
const patch = JSON.parse(match[2]);
|
|
383
|
-
return typeof patch === "string" && /^\*\*\* Begin Patch\r?\n[\s\S]*\r?\n\*\*\* End Patch(?:\r?\n)?$/u.test(patch) ? patch : void 0;
|
|
384
|
-
} catch {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
function readInterceptedNativePatchInput(command) {
|
|
389
|
-
if (typeof command !== "string") return;
|
|
390
|
-
const lines = command.replace(/\r\n?/gu, "\n").split("\n");
|
|
391
|
-
const patchStart = lines.indexOf("*** Begin Patch");
|
|
392
|
-
const invocation = /^[\t ]*(?:cd[\t ]+(?:'([^'\n]+)'|([A-Za-z0-9_./-]+))[\t ]+&&[\t ]+)?apply_patch[\t ]*<<-?[\t ]*'([^'\n]+)'[\t ]*$/u.exec(lines[0] ?? "");
|
|
393
|
-
if (!invocation || patchStart !== 1) return;
|
|
394
|
-
const patchEnd = lines.indexOf("*** End Patch", patchStart + 1);
|
|
395
|
-
const cwd = invocation[1] ?? invocation[2];
|
|
396
|
-
const delimiter = invocation[3];
|
|
397
|
-
if (patchEnd < 0 || lines[patchEnd + 1] !== delimiter || lines.slice(patchEnd + 2).some((line) => line.trim().length > 0)) return;
|
|
398
|
-
return {
|
|
399
|
-
input: `${lines.slice(patchStart, patchEnd + 1).join("\n")}\n`,
|
|
400
|
-
...cwd ? { cwd } : {}
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
367
|
var CodexToolTranscriptProjection = class {
|
|
404
368
|
constructor(params, threadId, turnId, progress, nextTranscriptTimestamp, options = {}) {
|
|
405
369
|
this.params = params;
|
|
@@ -421,7 +385,8 @@ var CodexToolTranscriptProjection = class {
|
|
|
421
385
|
this.nativeMcpAppResultDetailsAttempted = /* @__PURE__ */ new Set();
|
|
422
386
|
this.approvalReviewsByCallId = /* @__PURE__ */ new Map();
|
|
423
387
|
this.rawNativeToolOutputByCallId = /* @__PURE__ */ new Map();
|
|
424
|
-
this.
|
|
388
|
+
this.pendingRawOutputIds = /* @__PURE__ */ new Set();
|
|
389
|
+
this.rawCallsById = /* @__PURE__ */ new Map();
|
|
425
390
|
this.codeModeNativePatchInputsByCallId = /* @__PURE__ */ new Map();
|
|
426
391
|
}
|
|
427
392
|
get transcriptMessages() {
|
|
@@ -488,6 +453,7 @@ var CodexToolTranscriptProjection = class {
|
|
|
488
453
|
name,
|
|
489
454
|
text: approvalTimeoutExplanation ?? this.rawNativeToolOutputByCallId.get(item.id) ?? itemTranscriptResultText(item, this.progress.outputTextByItem),
|
|
490
455
|
isError: isNonSuccessItemStatus(status),
|
|
456
|
+
...item.type === "commandExecution" && item.aggregatedOutput == null && this.progress.isOutputTruncated(item.id) ? { captureTruncated: true } : {},
|
|
491
457
|
details,
|
|
492
458
|
...item.type === "webSearch" ? { resultContentSource: "network" } : {}
|
|
493
459
|
});
|
|
@@ -498,6 +464,14 @@ var CodexToolTranscriptProjection = class {
|
|
|
498
464
|
const type = typeof item.type === "string" ? item.type : void 0;
|
|
499
465
|
const callId = typeof item.call_id === "string" ? item.call_id : typeof item.callId === "string" ? item.callId : void 0;
|
|
500
466
|
if (!callId) return;
|
|
467
|
+
if ((type === "custom_tool_call" || type === "function_call") && typeof item.name === "string") {
|
|
468
|
+
this.rawCallsById.set(callId, {
|
|
469
|
+
id: callId,
|
|
470
|
+
name: item.name,
|
|
471
|
+
arguments: type === "custom_tool_call" ? { input: item.input } : { arguments: item.arguments }
|
|
472
|
+
});
|
|
473
|
+
this.pendingRawOutputIds.add(callId);
|
|
474
|
+
}
|
|
501
475
|
if ((type === "custom_tool_call" || type === "function_call") && (item.name === "apply_patch" || item.name === "exec_command" || item.name === "exec")) {
|
|
502
476
|
let args;
|
|
503
477
|
if (type === "custom_tool_call" && item.name === "apply_patch" && typeof item.input === "string") args = { input: item.input };
|
|
@@ -511,7 +485,8 @@ var CodexToolTranscriptProjection = class {
|
|
|
511
485
|
const parsedArguments = parsed;
|
|
512
486
|
if (item.name === "apply_patch") args = parsedArguments;
|
|
513
487
|
else {
|
|
514
|
-
const
|
|
488
|
+
const command = typeof parsedArguments.cmd === "string" ? parsedArguments.cmd : typeof parsedArguments.command === "string" ? parsedArguments.command : void 0;
|
|
489
|
+
const patch = readInterceptedNativePatchInput(command);
|
|
515
490
|
if (patch) {
|
|
516
491
|
const workdir = typeof parsedArguments.workdir === "string" ? parsedArguments.workdir : typeof parsedArguments.cwd === "string" ? parsedArguments.cwd : void 0;
|
|
517
492
|
const cwd = patch.cwd ? workdir && !path.isAbsolute(patch.cwd) ? path.join(workdir, patch.cwd) : patch.cwd : workdir;
|
|
@@ -526,7 +501,7 @@ var CodexToolTranscriptProjection = class {
|
|
|
526
501
|
return;
|
|
527
502
|
}
|
|
528
503
|
if (args) {
|
|
529
|
-
this.
|
|
504
|
+
this.pendingRawOutputIds.add(callId);
|
|
530
505
|
this.recordToolCall({
|
|
531
506
|
id: callId,
|
|
532
507
|
name: "apply_patch",
|
|
@@ -535,15 +510,17 @@ var CodexToolTranscriptProjection = class {
|
|
|
535
510
|
}
|
|
536
511
|
return;
|
|
537
512
|
}
|
|
538
|
-
if (type !== "custom_tool_call_output" && type !== "function_call_output"
|
|
539
|
-
this.
|
|
540
|
-
const text =
|
|
541
|
-
if (
|
|
513
|
+
if (type !== "custom_tool_call_output" && type !== "function_call_output") return;
|
|
514
|
+
this.pendingRawOutputIds.delete(callId);
|
|
515
|
+
const text = readCodexResponseOutput(item);
|
|
516
|
+
if (text === void 0) return;
|
|
517
|
+
this.rawNativeToolOutputByCallId.set(callId, text);
|
|
518
|
+
const rawCall = this.rawCallsById.get(callId);
|
|
519
|
+
const responseText = typeof item.output === "string" ? item.output : collectDynamicToolContentText(item.output);
|
|
520
|
+
const execution = rawCall?.name === "exec" ? CODE_MODE_RESULT_RE.exec(responseText) : null;
|
|
542
521
|
const codeModePatchInput = this.codeModeNativePatchInputsByCallId.get(callId);
|
|
543
522
|
if (codeModePatchInput) {
|
|
544
523
|
this.codeModeNativePatchInputsByCallId.delete(callId);
|
|
545
|
-
const execution = CODE_MODE_NATIVE_PATCH_RESULT_RE.exec(text);
|
|
546
|
-
if (execution?.[1]?.toLowerCase() === "completed" && execution[2]?.trim() === "{}") return;
|
|
547
524
|
if (execution?.[1]?.toLowerCase() === "failed") {
|
|
548
525
|
const failure = execution[2]?.replace(/^Script error:\s*/iu, "").trim() || text;
|
|
549
526
|
this.recordToolCall({
|
|
@@ -557,13 +534,21 @@ var CodexToolTranscriptProjection = class {
|
|
|
557
534
|
text: failure,
|
|
558
535
|
isError: true
|
|
559
536
|
});
|
|
537
|
+
return;
|
|
560
538
|
}
|
|
561
|
-
return;
|
|
562
539
|
}
|
|
563
|
-
this.rawNativeToolOutputByCallId.set(callId, text);
|
|
564
540
|
const result = this.messages.find((message) => message.role === "toolResult" && message.toolCallId === callId);
|
|
565
541
|
if (!result) {
|
|
566
|
-
if (
|
|
542
|
+
if (!this.callIds.has(callId) && rawCall) {
|
|
543
|
+
this.recordToolCall(rawCall);
|
|
544
|
+
this.recordToolResult({
|
|
545
|
+
id: callId,
|
|
546
|
+
name: rawCall.name,
|
|
547
|
+
text,
|
|
548
|
+
isError: execution?.[1]?.toLowerCase() === "failed",
|
|
549
|
+
...!execution ? { outcomeUnknown: true } : {}
|
|
550
|
+
});
|
|
551
|
+
} else if (this.namesById.get(callId) === "apply_patch" && NATIVE_PATCH_REJECTION_RE.test(text)) this.recordToolResult({
|
|
567
552
|
id: callId,
|
|
568
553
|
name: "apply_patch",
|
|
569
554
|
text,
|
|
@@ -573,10 +558,18 @@ var CodexToolTranscriptProjection = class {
|
|
|
573
558
|
}
|
|
574
559
|
result.content = this.createToolResultMessage({
|
|
575
560
|
id: callId,
|
|
576
|
-
name:
|
|
561
|
+
name: result.toolName,
|
|
577
562
|
text,
|
|
578
563
|
isError: result.isError
|
|
579
564
|
}).content;
|
|
565
|
+
const metadata = Reflect.get(result, "__openclaw");
|
|
566
|
+
Reflect.set(result, "__openclaw", {
|
|
567
|
+
...isJsonObject(metadata) ? metadata : {},
|
|
568
|
+
toolOutput: {
|
|
569
|
+
source: "provider-response",
|
|
570
|
+
modelInput: "unverified"
|
|
571
|
+
}
|
|
572
|
+
});
|
|
580
573
|
}
|
|
581
574
|
async prepareNativeToolResultDetails(item) {
|
|
582
575
|
const preparedDetails = await this.prepareNativeMcpAppResultDetails(item);
|
|
@@ -721,7 +714,7 @@ var CodexToolTranscriptProjection = class {
|
|
|
721
714
|
sessionId: this.params.sessionId,
|
|
722
715
|
sessionKey: this.params.sessionKey,
|
|
723
716
|
sessionTarget: this.params.sessionTarget
|
|
724
|
-
}, void 0,
|
|
717
|
+
}, void 0, signal, this.params.contextTokenBudget) ?? [];
|
|
725
718
|
}
|
|
726
719
|
recordToolCall(params) {
|
|
727
720
|
if (!params.id || !params.name || this.callIds.has(params.id)) return;
|
|
@@ -740,7 +733,7 @@ var CodexToolTranscriptProjection = class {
|
|
|
740
733
|
this.messages.push(message);
|
|
741
734
|
this.options.checkpointMessage?.({
|
|
742
735
|
read: () => message,
|
|
743
|
-
ready: () => !this.
|
|
736
|
+
ready: () => !this.pendingRawOutputIds.has(params.id)
|
|
744
737
|
});
|
|
745
738
|
}
|
|
746
739
|
recordMissingToolError(missingTranscriptIds, missingTrajectoryIds) {
|
|
@@ -773,8 +766,7 @@ var CodexToolTranscriptProjection = class {
|
|
|
773
766
|
type: "toolCall",
|
|
774
767
|
id: params.id,
|
|
775
768
|
name: params.name,
|
|
776
|
-
arguments: args
|
|
777
|
-
input: args
|
|
769
|
+
arguments: args
|
|
778
770
|
}],
|
|
779
771
|
api: attribution.api ?? "openai-chatgpt-responses",
|
|
780
772
|
provider: attribution.provider,
|
|
@@ -785,26 +777,28 @@ var CodexToolTranscriptProjection = class {
|
|
|
785
777
|
};
|
|
786
778
|
}
|
|
787
779
|
createToolResultMessage(params) {
|
|
788
|
-
const
|
|
780
|
+
const response = this.rawNativeToolOutputByCallId.get(params.id);
|
|
781
|
+
const text = response ?? params.text ?? toolResultStatusText(params);
|
|
789
782
|
return {
|
|
790
783
|
role: "toolResult",
|
|
791
784
|
toolCallId: params.id,
|
|
792
785
|
toolName: params.name,
|
|
793
786
|
isError: params.isError,
|
|
794
787
|
content: [{
|
|
795
|
-
type: "
|
|
796
|
-
id: params.id,
|
|
797
|
-
name: params.name,
|
|
798
|
-
toolName: params.name,
|
|
799
|
-
toolCallId: params.id,
|
|
800
|
-
toolUseId: params.id,
|
|
801
|
-
tool_use_id: params.id,
|
|
802
|
-
content: text,
|
|
788
|
+
type: "text",
|
|
803
789
|
text
|
|
804
790
|
}],
|
|
805
791
|
...params.details !== void 0 ? { details: params.details } : {},
|
|
806
|
-
|
|
807
|
-
|
|
792
|
+
timestamp: this.nextTranscriptTimestamp(),
|
|
793
|
+
__openclaw: {
|
|
794
|
+
...params.resultContentSource ? { resultContentSource: params.resultContentSource } : {},
|
|
795
|
+
toolOutput: {
|
|
796
|
+
source: response === void 0 ? "execution" : "provider-response",
|
|
797
|
+
modelInput: "unverified",
|
|
798
|
+
...params.outcomeUnknown ? { outcome: "unknown" } : {},
|
|
799
|
+
...response === void 0 && params.captureTruncated ? { captureTruncated: true } : {}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
808
802
|
};
|
|
809
803
|
}
|
|
810
804
|
};
|
|
@@ -870,7 +864,7 @@ function projectNormalizedToolItem(params) {
|
|
|
870
864
|
status,
|
|
871
865
|
args,
|
|
872
866
|
meta,
|
|
873
|
-
event: shouldEmitTranscriptToolProgress(name
|
|
867
|
+
event: shouldEmitTranscriptToolProgress(name) ? {
|
|
874
868
|
stream: "tool",
|
|
875
869
|
data: {
|
|
876
870
|
phase: params.phase,
|
|
@@ -1159,22 +1153,30 @@ var CodexEventProjection = class {
|
|
|
1159
1153
|
const commandBearing = isCommandBearingToolItem(item, args);
|
|
1160
1154
|
const subagentStatus = readStringField(item, activity ? "kind" : "status");
|
|
1161
1155
|
const interaction = activity && subagentStatus === "interacted";
|
|
1162
|
-
const status = subagent && subagentStatus === "interrupted" ? "failed" : activity ? subagentStatus === "completed" || interaction ? "completed" : "running" : params.phase === "start" ? "running" : itemStatus(item);
|
|
1156
|
+
const status = subagent && subagentStatus === "interrupted" ? "failed" : activity ? subagentStatus === "completed" || interaction ? "completed" : "running" : params.phase === "start" ? "running" : kind === "analysis" ? "completed" : unknownItemStatus(item) ? void 0 : itemStatus(item);
|
|
1163
1157
|
const meta = subagent ? [interaction ? "message sent" : activity ? subagentStatus : status, readStringField(item, activity ? "agentPath" : "tool")].filter(Boolean).join(": ") : itemMeta(item, this.toolProgress.toolProgressDetailMode());
|
|
1164
1158
|
const suppressChannelProgress = shouldSuppressChannelProgressForItem(item);
|
|
1165
1159
|
this.emitAgentEvent({
|
|
1166
1160
|
stream: "item",
|
|
1167
|
-
data: {
|
|
1161
|
+
data: projectAgentActivityItem({
|
|
1168
1162
|
itemId: activity && !interaction ? `subagent:${readStringField(item, "agentThreadId") ?? item.id}` : item.id,
|
|
1169
1163
|
phase: params.phase,
|
|
1170
1164
|
kind,
|
|
1171
1165
|
title: itemTitle(item),
|
|
1172
|
-
status,
|
|
1166
|
+
...status ? { status } : {},
|
|
1167
|
+
...status === void 0 ? {
|
|
1168
|
+
summary: "Outcome unknown",
|
|
1169
|
+
title: `${itemTitle(item)} — outcome unknown`
|
|
1170
|
+
} : {},
|
|
1171
|
+
toolCallId: item.id,
|
|
1173
1172
|
...name ? { name } : {},
|
|
1174
1173
|
...meta ? { meta } : {},
|
|
1175
1174
|
...commandBearing ? { commandBearing: true } : {},
|
|
1176
1175
|
...suppressChannelProgress ? { suppressChannelProgress: true } : {}
|
|
1177
|
-
}
|
|
1176
|
+
}, {
|
|
1177
|
+
args: itemToolArgs(item),
|
|
1178
|
+
...item.type === "collabAgentToolCall" && item.tool === "wait" ? { nativeOperation: "wait" } : {}
|
|
1179
|
+
})
|
|
1178
1180
|
});
|
|
1179
1181
|
}
|
|
1180
1182
|
async emitSnapshotOnlyNativeToolProgress(params) {
|
|
@@ -1232,7 +1234,16 @@ var CodexEventProjection = class {
|
|
|
1232
1234
|
}
|
|
1233
1235
|
return;
|
|
1234
1236
|
}
|
|
1237
|
+
const activity = projectCodexToolActivity(item, params.phase, meta);
|
|
1238
|
+
if (activity && params.phase === "start") this.emitAgentEvent({
|
|
1239
|
+
stream: "item",
|
|
1240
|
+
data: activity
|
|
1241
|
+
});
|
|
1235
1242
|
this.emitAgentEvent(event);
|
|
1243
|
+
if (activity && params.phase !== "start") this.emitAgentEvent({
|
|
1244
|
+
stream: "item",
|
|
1245
|
+
data: activity
|
|
1246
|
+
});
|
|
1236
1247
|
if (params.phase === "result") {
|
|
1237
1248
|
this.toolTranscript.emitAfterToolCallObservation(item);
|
|
1238
1249
|
await this.onNativeToolResultRecorded?.();
|
|
@@ -1987,7 +1998,7 @@ var CodexNativeSubagentCloseOwner = class {
|
|
|
1987
1998
|
const childState = this.callbacks.currentChild(target.childThreadId);
|
|
1988
1999
|
if (loaded.data.includes(target.childThreadId) || !isTargetCurrent(target)) continue;
|
|
1989
2000
|
const forget = forgetters[index];
|
|
1990
|
-
if (childState) this.retireChild(state, childState, "Subagent was closed.",
|
|
2001
|
+
if (childState) this.retireChild(state, childState, "Subagent was closed.", forget);
|
|
1991
2002
|
else forget?.();
|
|
1992
2003
|
}
|
|
1993
2004
|
} catch (error) {
|
|
@@ -2260,10 +2271,7 @@ function extractCodexNativeSubagentCompletions(notification) {
|
|
|
2260
2271
|
const item = isJsonObject(params.item) ? params.item : void 0;
|
|
2261
2272
|
if (!item) return [];
|
|
2262
2273
|
if (notification.method === "rawResponseItem/completed" && item.role === "user") return readTrustedContextualCompletions(item);
|
|
2263
|
-
|
|
2264
|
-
const text = communication?.content;
|
|
2265
|
-
if (typeof text !== "string" || !text) return [];
|
|
2266
|
-
return extractCodexNativeSubagentCompletionsFromText(text).filter((completion) => completion.agentPath === communication?.author);
|
|
2274
|
+
return [];
|
|
2267
2275
|
}
|
|
2268
2276
|
function readTrustedContextualCompletions(item) {
|
|
2269
2277
|
const content = item.content;
|
|
@@ -2278,25 +2286,8 @@ function readTrustedContextualCompletions(item) {
|
|
|
2278
2286
|
return completion ? [completion] : [];
|
|
2279
2287
|
});
|
|
2280
2288
|
}
|
|
2281
|
-
/** Parses one or more tagged subagent completion payloads from commentary text. */
|
|
2282
|
-
function extractCodexNativeSubagentCompletionsFromText(text) {
|
|
2283
|
-
const completions = [];
|
|
2284
|
-
let cursor = 0;
|
|
2285
|
-
while (cursor < text.length) {
|
|
2286
|
-
const start = text.indexOf(CODEX_SUBAGENT_NOTIFICATION_START, cursor);
|
|
2287
|
-
if (start < 0) break;
|
|
2288
|
-
const bodyStart = start + 23;
|
|
2289
|
-
const end = text.indexOf(CODEX_SUBAGENT_NOTIFICATION_END, bodyStart);
|
|
2290
|
-
if (end < 0) break;
|
|
2291
|
-
const parsed = parseCodexNativeSubagentNotificationBody(text.slice(bodyStart, end));
|
|
2292
|
-
if (parsed) completions.push(parsed);
|
|
2293
|
-
cursor = end + 24;
|
|
2294
|
-
}
|
|
2295
|
-
return completions;
|
|
2296
|
-
}
|
|
2297
2289
|
const codexNativeSubagentNotifications = {
|
|
2298
2290
|
fromNotification: extractCodexNativeSubagentCompletions,
|
|
2299
|
-
fromText: extractCodexNativeSubagentCompletionsFromText,
|
|
2300
2291
|
deliveredAgentPaths: readDeliveredNativeCompletionPaths
|
|
2301
2292
|
};
|
|
2302
2293
|
/** Reads native delivery receipts, leaving status and result ownership with the child lifecycle. */
|
|
@@ -2331,79 +2322,35 @@ function parseCodexNativeSubagentNotificationBody(body) {
|
|
|
2331
2322
|
}
|
|
2332
2323
|
if (!isJsonObject(payload)) return;
|
|
2333
2324
|
const agentPath = readStringField(payload, "agent_path")?.trim();
|
|
2334
|
-
const
|
|
2335
|
-
|
|
2336
|
-
const statusEntry = readCompletionStatus(status);
|
|
2337
|
-
if (!statusEntry) return;
|
|
2338
|
-
return {
|
|
2325
|
+
const completion = readCompletionStatus(payload.status);
|
|
2326
|
+
return agentPath && completion ? {
|
|
2339
2327
|
agentPath,
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
result: statusEntry.result
|
|
2343
|
-
};
|
|
2328
|
+
...completion
|
|
2329
|
+
} : void 0;
|
|
2344
2330
|
}
|
|
2345
2331
|
function readCompletionStatus(status) {
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2332
|
+
if (status === "shutdown" || status === "not_found") return {
|
|
2333
|
+
status: status === "shutdown" ? "cancelled" : "failed",
|
|
2334
|
+
statusLabel: status,
|
|
2335
|
+
result: "(no output)"
|
|
2336
|
+
};
|
|
2337
|
+
if (!isJsonObject(status)) return;
|
|
2338
|
+
const completed = status.completed;
|
|
2339
|
+
if (completed === null || typeof completed === "string") {
|
|
2340
|
+
const result = completed?.trim();
|
|
2350
2341
|
return {
|
|
2351
|
-
status:
|
|
2352
|
-
|
|
2353
|
-
result: result.
|
|
2342
|
+
status: "succeeded",
|
|
2343
|
+
statusLabel: result ? "completed" : "completed_without_final_message",
|
|
2344
|
+
result: result || "Subagent completed without a final assistant message."
|
|
2354
2345
|
};
|
|
2355
2346
|
}
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
}
|
|
2362
|
-
function stringifyResult(value, status) {
|
|
2363
|
-
if (typeof value === "string") {
|
|
2364
|
-
const text = value.trim();
|
|
2365
|
-
if (text) return { text };
|
|
2366
|
-
return status === "succeeded" ? completedWithoutFinalAssistantMessage() : { text: "(no output)" };
|
|
2367
|
-
}
|
|
2368
|
-
if (value === null || value === void 0) return status === "succeeded" ? completedWithoutFinalAssistantMessage() : { text: "(no output)" };
|
|
2369
|
-
try {
|
|
2370
|
-
return { text: JSON.stringify(value) };
|
|
2371
|
-
} catch {
|
|
2372
|
-
return { text: "(unserializable output)" };
|
|
2373
|
-
}
|
|
2374
|
-
}
|
|
2375
|
-
function completedWithoutFinalAssistantMessage() {
|
|
2376
|
-
return {
|
|
2377
|
-
text: "Subagent completed without a final assistant message.",
|
|
2378
|
-
kind: "no_final_assistant_message"
|
|
2347
|
+
const error = readStringField(status, "errored");
|
|
2348
|
+
return error === void 0 ? void 0 : {
|
|
2349
|
+
status: "failed",
|
|
2350
|
+
statusLabel: "errored",
|
|
2351
|
+
result: error.trim() || "(no output)"
|
|
2379
2352
|
};
|
|
2380
2353
|
}
|
|
2381
|
-
function readTrustedInterAgentCommunication(item) {
|
|
2382
|
-
if (readStringField(item, "type") !== "message" || readStringField(item, "role") !== "assistant" || readStringField(item, "phase") !== "commentary") return;
|
|
2383
|
-
const text = extractSingleTextPart(item);
|
|
2384
|
-
if (!text) return;
|
|
2385
|
-
let parsed;
|
|
2386
|
-
try {
|
|
2387
|
-
parsed = JSON.parse(text);
|
|
2388
|
-
} catch {
|
|
2389
|
-
return;
|
|
2390
|
-
}
|
|
2391
|
-
if (!isJsonObject(parsed)) return;
|
|
2392
|
-
if (typeof parsed.author !== "string" || typeof parsed.recipient !== "string" || typeof parsed.content !== "string" || parsed.trigger_turn !== false) return;
|
|
2393
|
-
return parsed;
|
|
2394
|
-
}
|
|
2395
|
-
function extractSingleTextPart(item) {
|
|
2396
|
-
const content = item.content;
|
|
2397
|
-
if (!Array.isArray(content) || content.length !== 1) return;
|
|
2398
|
-
const [entry] = content;
|
|
2399
|
-
if (!isJsonObject(entry)) return;
|
|
2400
|
-
const type = readStringField(entry, "type");
|
|
2401
|
-
if (type !== "output_text" && type !== "text") return;
|
|
2402
|
-
return readStringField(entry, "text")?.trim();
|
|
2403
|
-
}
|
|
2404
|
-
function normalizeStatusKey(value) {
|
|
2405
|
-
return value.replace(/[^a-z0-9]/giu, "").toLowerCase();
|
|
2406
|
-
}
|
|
2407
2354
|
//#endregion
|
|
2408
2355
|
//#region extensions/codex/src/app-server/native-subagent-delivery-receipts.ts
|
|
2409
2356
|
function buildCodexNativeSubagentAgentPathKey(parentThreadId, agentPath) {
|
|
@@ -2458,7 +2405,6 @@ var CodexNativeSubagentDeliveryReceipts = class {
|
|
|
2458
2405
|
result = isJsonObject(child) ? readStringField(child, "message") : result;
|
|
2459
2406
|
}
|
|
2460
2407
|
this.pending.push({
|
|
2461
|
-
id,
|
|
2462
2408
|
agentPath,
|
|
2463
2409
|
result: receiptResultKey(result)
|
|
2464
2410
|
});
|
|
@@ -2500,8 +2446,7 @@ var CodexNativeSubagentDeliveryReceipts = class {
|
|
|
2500
2446
|
restored.set(assignment.runId, outcome);
|
|
2501
2447
|
}
|
|
2502
2448
|
for (const [runId, outcome] of this.outcomes) if (!restored.has(runId)) restored.set(runId, outcome);
|
|
2503
|
-
this.outcomes
|
|
2504
|
-
for (const [runId, outcome] of restored) this.outcomes.set(runId, outcome);
|
|
2449
|
+
this.outcomes = restored;
|
|
2505
2450
|
const matched = this.match();
|
|
2506
2451
|
return [.../* @__PURE__ */ new Set([...matched, ...[...restored].filter(([, value]) => value.received).map(([id]) => id)])];
|
|
2507
2452
|
}
|
|
@@ -3071,7 +3016,6 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
3071
3016
|
this.mirrorStateByThreadId = /* @__PURE__ */ new Map();
|
|
3072
3017
|
this.terminalRunIds = /* @__PURE__ */ new Set();
|
|
3073
3018
|
this.authoritativeRunIds = /* @__PURE__ */ new Set();
|
|
3074
|
-
this.expectedAuthoritativeRunIds = /* @__PURE__ */ new Set();
|
|
3075
3019
|
this.runIdsByThreadId = /* @__PURE__ */ new Map();
|
|
3076
3020
|
this.now = params.now ?? Date.now;
|
|
3077
3021
|
}
|
|
@@ -3079,21 +3023,16 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
3079
3023
|
this.authoritativeRunIds.add(runId);
|
|
3080
3024
|
this.terminalRunIds.add(runId);
|
|
3081
3025
|
}
|
|
3082
|
-
markAuthoritativeCompletionExpected(childThreadId) {
|
|
3083
|
-
this.expectedAuthoritativeRunIds.add(this.runId(childThreadId));
|
|
3084
|
-
}
|
|
3085
3026
|
restoreCurrentTaskRun(threadId, runId) {
|
|
3086
3027
|
this.runIdsByThreadId.set(threadId, runId);
|
|
3087
3028
|
this.mirrorStateByThreadId.set(threadId, "mirrored");
|
|
3088
|
-
this.expectedAuthoritativeRunIds.add(runId);
|
|
3089
3029
|
}
|
|
3090
|
-
startFollowupTurn(threadId, turnId, nativeParentThreadId
|
|
3030
|
+
startFollowupTurn(threadId, turnId, nativeParentThreadId) {
|
|
3091
3031
|
const previousRunId = this.runId(threadId);
|
|
3092
3032
|
const previous = this.runtime.listTaskRecords().find((task) => task.runId === previousRunId);
|
|
3093
3033
|
const runId = codexNativeSubagentRunId(threadId, turnId);
|
|
3094
3034
|
this.runIdsByThreadId.set(threadId, runId);
|
|
3095
3035
|
this.mirrorStateByThreadId.delete(threadId);
|
|
3096
|
-
this.expectedAuthoritativeRunIds.add(runId);
|
|
3097
3036
|
this.createRunningTask({
|
|
3098
3037
|
threadId,
|
|
3099
3038
|
turnId,
|
|
@@ -3103,7 +3042,6 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
3103
3042
|
startedAt: this.now(),
|
|
3104
3043
|
progressSummary: "Subagent started follow-up work."
|
|
3105
3044
|
});
|
|
3106
|
-
return runId;
|
|
3107
3045
|
}
|
|
3108
3046
|
recordNativeTurn(runId, turnId) {
|
|
3109
3047
|
const task = this.runtime.listTaskRecords().find((record) => record.runId === runId);
|
|
@@ -3194,24 +3132,11 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
3194
3132
|
return;
|
|
3195
3133
|
}
|
|
3196
3134
|
if (statusType === "systemError") {
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
this.runtime.recordTaskRunProgressByRunId({
|
|
3200
|
-
runId,
|
|
3201
|
-
lastEventAt: eventAt,
|
|
3202
|
-
progressSummary: "Subagent hit a system error; awaiting recovery."
|
|
3203
|
-
});
|
|
3204
|
-
return;
|
|
3205
|
-
}
|
|
3206
|
-
this.terminalRunIds.add(runId);
|
|
3207
|
-
this.runtime.finalizeTaskRunByRunId({
|
|
3135
|
+
this.terminalRunIds.delete(runId);
|
|
3136
|
+
this.runtime.recordTaskRunProgressByRunId({
|
|
3208
3137
|
runId,
|
|
3209
|
-
status: "failed",
|
|
3210
|
-
endedAt: eventAt,
|
|
3211
3138
|
lastEventAt: eventAt,
|
|
3212
|
-
|
|
3213
|
-
progressSummary: "Subagent hit a system error.",
|
|
3214
|
-
terminalSummary: "Subagent failed."
|
|
3139
|
+
progressSummary: "Subagent hit a system error; awaiting recovery."
|
|
3215
3140
|
});
|
|
3216
3141
|
return;
|
|
3217
3142
|
}
|
|
@@ -3340,19 +3265,11 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
3340
3265
|
if (normalizedStatus === "completed") {
|
|
3341
3266
|
this.terminalRunIds.add(runId);
|
|
3342
3267
|
const summary = normalizeOptionalString(message) ?? "Subagent completed.";
|
|
3343
|
-
|
|
3268
|
+
this.runtime.recordTaskRunProgressByRunId({
|
|
3344
3269
|
runId,
|
|
3345
3270
|
lastEventAt: eventAt,
|
|
3346
3271
|
progressSummary: summary
|
|
3347
3272
|
});
|
|
3348
|
-
else this.runtime.finalizeTaskRunByRunId({
|
|
3349
|
-
runId,
|
|
3350
|
-
status: "succeeded",
|
|
3351
|
-
endedAt: eventAt,
|
|
3352
|
-
lastEventAt: eventAt,
|
|
3353
|
-
progressSummary: summary,
|
|
3354
|
-
terminalSummary: summary
|
|
3355
|
-
});
|
|
3356
3273
|
return;
|
|
3357
3274
|
}
|
|
3358
3275
|
if (normalizedStatus === "blocked") {
|
|
@@ -3583,25 +3500,13 @@ var CodexNativeSubagentTurnObservation = class {
|
|
|
3583
3500
|
}
|
|
3584
3501
|
return;
|
|
3585
3502
|
}
|
|
3586
|
-
if (notification.method === "item/agentMessage/delta") {
|
|
3587
|
-
const delta = readStringField(params, "delta");
|
|
3588
|
-
if (delta) {
|
|
3589
|
-
if (!childState.activityObserved) observe("running");
|
|
3590
|
-
emitAgentEvent({
|
|
3591
|
-
...owner,
|
|
3592
|
-
stream: "assistant",
|
|
3593
|
-
data: { delta }
|
|
3594
|
-
});
|
|
3595
|
-
}
|
|
3596
|
-
return;
|
|
3597
|
-
}
|
|
3598
|
-
if (notification.method === "item/reasoning/summaryTextDelta") {
|
|
3503
|
+
if (notification.method === "item/agentMessage/delta" || notification.method === "item/reasoning/summaryTextDelta") {
|
|
3599
3504
|
const delta = readStringField(params, "delta");
|
|
3600
3505
|
if (delta) {
|
|
3601
3506
|
if (!childState.activityObserved) observe("running");
|
|
3602
3507
|
emitAgentEvent({
|
|
3603
3508
|
...owner,
|
|
3604
|
-
stream: "thinking",
|
|
3509
|
+
stream: notification.method === "item/agentMessage/delta" ? "assistant" : "thinking",
|
|
3605
3510
|
data: { delta }
|
|
3606
3511
|
});
|
|
3607
3512
|
}
|
|
@@ -3648,31 +3553,10 @@ var CodexNativeSubagentTurnObservation = class {
|
|
|
3648
3553
|
});
|
|
3649
3554
|
}
|
|
3650
3555
|
}
|
|
3651
|
-
captureChildAssistantMessage(notification) {
|
|
3652
|
-
const params = isJsonObject(notification.params) ? notification.params : void 0;
|
|
3653
|
-
const childThreadId = readStringField(params, "threadId")?.trim();
|
|
3654
|
-
const childState = childThreadId ? this.callbacks.currentChild(childThreadId) : void 0;
|
|
3655
|
-
if (!childState || childState.terminal) return;
|
|
3656
|
-
if (notification.method === "item/agentMessage/delta") {
|
|
3657
|
-
const turnId = readStringField(params, "turnId");
|
|
3658
|
-
const itemId = readStringField(params, "itemId");
|
|
3659
|
-
const delta = readStringField(params, "delta");
|
|
3660
|
-
if (turnId && itemId && delta) this.recordChildAssistantMessage(childState, turnId, itemId, delta);
|
|
3661
|
-
return;
|
|
3662
|
-
}
|
|
3663
|
-
if (notification.method !== "item/started" && notification.method !== "item/completed") return;
|
|
3664
|
-
this.captureChildAssistantMessageItem(childState, readStringField(params, "turnId"), isJsonObject(params?.item) ? params.item : void 0);
|
|
3665
|
-
}
|
|
3666
|
-
captureChildTurnAssistantMessages(childState, turn) {
|
|
3667
|
-
const turnId = readStringField(turn, "id");
|
|
3668
|
-
if (!turnId || !Array.isArray(turn.items)) return;
|
|
3669
|
-
for (const item of turn.items) this.captureChildAssistantMessageItem(childState, turnId, isJsonObject(item) ? item : void 0);
|
|
3670
|
-
}
|
|
3671
3556
|
toChildTurnCompletion(childState, turn) {
|
|
3672
3557
|
const status = normalizeIdentifier(readStringField(turn, "status"));
|
|
3673
3558
|
if (status === "completed") {
|
|
3674
|
-
const
|
|
3675
|
-
const result = turnId ? lastChildAssistantMessage(childState, turnId) : void 0;
|
|
3559
|
+
const result = readLastAgentMessage(turn);
|
|
3676
3560
|
return {
|
|
3677
3561
|
childThreadId: childState.childThreadId,
|
|
3678
3562
|
status: "succeeded",
|
|
@@ -3687,44 +3571,7 @@ var CodexNativeSubagentTurnObservation = class {
|
|
|
3687
3571
|
result: readTurnErrorMessage(turn) ?? "Subagent failed."
|
|
3688
3572
|
};
|
|
3689
3573
|
}
|
|
3690
|
-
captureChildAssistantMessageItem(childState, turnId, item) {
|
|
3691
|
-
if (readStringField(item, "type") !== "agentMessage" || !turnId) return;
|
|
3692
|
-
const itemId = readStringField(item, "id");
|
|
3693
|
-
if (!itemId) return;
|
|
3694
|
-
const messages = this.getChildAssistantMessages(childState, turnId);
|
|
3695
|
-
if (readStringField(item, "phase") === "commentary") messages.commentaryIds.add(itemId);
|
|
3696
|
-
else messages.finalMessageIds.add(itemId);
|
|
3697
|
-
const text = readStringField(item, "text");
|
|
3698
|
-
if (text) this.recordChildAssistantMessage(childState, turnId, itemId, text, { replace: true });
|
|
3699
|
-
}
|
|
3700
|
-
recordChildAssistantMessage(childState, turnId, itemId, text, options = {}) {
|
|
3701
|
-
const messages = this.getChildAssistantMessages(childState, turnId);
|
|
3702
|
-
if (!messages.texts.has(itemId)) messages.order.push(itemId);
|
|
3703
|
-
const existing = messages.texts.get(itemId) ?? "";
|
|
3704
|
-
messages.texts.set(itemId, options.replace ? text : `${existing}${text}`);
|
|
3705
|
-
}
|
|
3706
|
-
getChildAssistantMessages(childState, turnId) {
|
|
3707
|
-
let messages = childState.assistantMessagesByTurn.get(turnId);
|
|
3708
|
-
if (!messages) {
|
|
3709
|
-
messages = {
|
|
3710
|
-
texts: /* @__PURE__ */ new Map(),
|
|
3711
|
-
order: [],
|
|
3712
|
-
commentaryIds: /* @__PURE__ */ new Set(),
|
|
3713
|
-
finalMessageIds: /* @__PURE__ */ new Set()
|
|
3714
|
-
};
|
|
3715
|
-
childState.assistantMessagesByTurn.set(turnId, messages);
|
|
3716
|
-
}
|
|
3717
|
-
return messages;
|
|
3718
|
-
}
|
|
3719
3574
|
};
|
|
3720
|
-
function lastChildAssistantMessage(childState, turnId) {
|
|
3721
|
-
const messages = childState.assistantMessagesByTurn.get(turnId);
|
|
3722
|
-
if (!messages) return;
|
|
3723
|
-
for (const itemId of messages.order.toReversed()) if (messages.finalMessageIds.has(itemId) && !messages.commentaryIds.has(itemId)) {
|
|
3724
|
-
const text = normalizeOptionalString(messages.texts.get(itemId));
|
|
3725
|
-
if (text) return text;
|
|
3726
|
-
}
|
|
3727
|
-
}
|
|
3728
3575
|
//#endregion
|
|
3729
3576
|
//#region extensions/codex/src/app-server/native-subagent-monitor.ts
|
|
3730
3577
|
const NATIVE_SUBAGENT_NOTIFICATION_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -4074,10 +3921,7 @@ var Monitor = class {
|
|
|
4074
3921
|
applyReceipts: (runIds) => this.applyNativeReceipts(parent, runIds)
|
|
4075
3922
|
});
|
|
4076
3923
|
if (childState && !childState.terminal && (!pendingTurns?.length || notification.method === "turn/completed")) this.turnObservation.emitChildTaskActivity(notification, childState);
|
|
4077
|
-
if (!pendingNativeTurn)
|
|
4078
|
-
this.turnObservation.captureChildAssistantMessage(notification);
|
|
4079
|
-
await this.handleChildTurnCompletion(notification, childState);
|
|
4080
|
-
}
|
|
3924
|
+
if (!pendingNativeTurn) await this.handleChildTurnCompletion(notification, childState);
|
|
4081
3925
|
if (!pendingNativeTurn && notification.method === "thread/status/changed" && threadId && threadStatus) {
|
|
4082
3926
|
if (threadStatus !== "systemerror") {
|
|
4083
3927
|
if (childState) this.recovery.clearSystemErrorFallback(childState);
|
|
@@ -4129,7 +3973,6 @@ var Monitor = class {
|
|
|
4129
3973
|
if (status === "interrupted") {
|
|
4130
3974
|
this.removePendingSpawnAdmissionEvidenceForChild(childState.childThreadId);
|
|
4131
3975
|
this.rejectPendingDirectChild(state, childState.childThreadId, "Codex child turn interrupted");
|
|
4132
|
-
if (turnId) childState.assistantMessagesByTurn.delete(turnId);
|
|
4133
3976
|
this.settleResumableChild(childState);
|
|
4134
3977
|
return;
|
|
4135
3978
|
}
|
|
@@ -4142,7 +3985,6 @@ var Monitor = class {
|
|
|
4142
3985
|
}
|
|
4143
3986
|
this.releaseDirectChild(childState);
|
|
4144
3987
|
}
|
|
4145
|
-
this.turnObservation.captureChildTurnAssistantMessages(childState, turn);
|
|
4146
3988
|
const completion = this.turnObservation.toChildTurnCompletion(childState, turn);
|
|
4147
3989
|
if (!completion) return;
|
|
4148
3990
|
await this.processObservedCompletion(state, childState, completion);
|
|
@@ -4280,21 +4122,20 @@ var Monitor = class {
|
|
|
4280
4122
|
this.settleResumableChild(childState);
|
|
4281
4123
|
return false;
|
|
4282
4124
|
}
|
|
4283
|
-
const completion = recovery
|
|
4284
|
-
if (!completion)
|
|
4285
|
-
|
|
4286
|
-
return false;
|
|
4287
|
-
}
|
|
4288
|
-
if (isNoFinalCompletion(completion)) {
|
|
4289
|
-
this.recovery.setRecoveryFallback(childState, completion, completion.completedAt ?? this.now());
|
|
4290
|
-
return false;
|
|
4291
|
-
}
|
|
4292
|
-
await this.processCompletion(state, childState, completion, completion.completedAt);
|
|
4125
|
+
const completion = this.processRecoveredCompletion(state, childState, recovery);
|
|
4126
|
+
if (!completion) return false;
|
|
4127
|
+
await completion;
|
|
4293
4128
|
return true;
|
|
4294
4129
|
} finally {
|
|
4295
4130
|
statusRead.release();
|
|
4296
4131
|
}
|
|
4297
4132
|
}
|
|
4133
|
+
processRecoveredCompletion(state, child, recovery) {
|
|
4134
|
+
const completion = recovery.completion;
|
|
4135
|
+
if (completion && !isNoFinalCompletion(completion)) return this.processCompletion(state, child, completion, completion.completedAt);
|
|
4136
|
+
const fallback = completion ?? recovery.fallbackCompletion;
|
|
4137
|
+
if (fallback) this.recovery.setRecoveryFallback(child, fallback, fallback.completedAt ?? this.now());
|
|
4138
|
+
}
|
|
4298
4139
|
recordRecoveredChildTurn(state, child, recovery) {
|
|
4299
4140
|
if (recovery.assignmentUnresolved) child.fallbackCompletion = void 0;
|
|
4300
4141
|
const known = this.knownChildren.get(child.childThreadId);
|
|
@@ -4456,7 +4297,6 @@ var Monitor = class {
|
|
|
4456
4297
|
parentThreadId,
|
|
4457
4298
|
nativeParentThreadId: known?.nativeParentThreadId ?? parentThreadId,
|
|
4458
4299
|
agentId: state.agentId,
|
|
4459
|
-
assistantMessagesByTurn: /* @__PURE__ */ new Map(),
|
|
4460
4300
|
recoveryAttempt: 0,
|
|
4461
4301
|
terminal: false,
|
|
4462
4302
|
nativeCompletionDelivered: false,
|
|
@@ -4490,7 +4330,6 @@ var Monitor = class {
|
|
|
4490
4330
|
childState.releaseDirectChild = claimDirectChild(childThreadId);
|
|
4491
4331
|
}
|
|
4492
4332
|
this.registerAgentPath(state, childThreadId, childThreadId);
|
|
4493
|
-
state.mirror?.markAuthoritativeCompletionExpected(childThreadId);
|
|
4494
4333
|
const agentPath = normalizeOptionalString(options.agentPath);
|
|
4495
4334
|
if (agentPath) this.registerAgentPath(state, childThreadId, agentPath);
|
|
4496
4335
|
for (const path of this.knownChildren.get(childThreadId)?.agentPaths ?? []) this.registerAgentPath(state, childThreadId, path);
|
|
@@ -5007,20 +4846,9 @@ var Monitor = class {
|
|
|
5007
4846
|
this.settleResumableChild(childState);
|
|
5008
4847
|
return;
|
|
5009
4848
|
}
|
|
5010
|
-
const completion = recovery
|
|
5011
|
-
if (
|
|
5012
|
-
|
|
5013
|
-
this.recovery.setRecoveryFallback(childState, recovery.fallbackCompletion, recovery.fallbackCompletion.completedAt ?? this.now());
|
|
5014
|
-
return;
|
|
5015
|
-
}
|
|
5016
|
-
this.recovery.scheduleRecoveryPoll(childState);
|
|
5017
|
-
return;
|
|
5018
|
-
}
|
|
5019
|
-
if (isNoFinalCompletion(completion)) {
|
|
5020
|
-
this.recovery.setRecoveryFallback(childState, completion, completion.completedAt ?? this.now());
|
|
5021
|
-
return;
|
|
5022
|
-
}
|
|
5023
|
-
await this.processCompletion(state, childState, completion, completion.completedAt);
|
|
4849
|
+
const completion = this.processRecoveredCompletion(state, childState, recovery);
|
|
4850
|
+
if (completion) await completion;
|
|
4851
|
+
else if (!recovery.completion && !recovery.fallbackCompletion) this.recovery.scheduleRecoveryPoll(childState);
|
|
5024
4852
|
} finally {
|
|
5025
4853
|
statusRead.release();
|
|
5026
4854
|
}
|