@openclaw/codex 2026.8.1-beta.3 → 2026.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +5 -6
- package/dist/{attempt-client-cleanup-URjUlCHg.js → attempt-client-cleanup-CpVfwctT.js} +47 -5
- package/dist/{auth-binding-B4FfbcCg.js → auth-binding-Ds_QVm-X.js} +18 -3
- package/dist/{binding-connection-DAvZwp96.js → binding-connection-CF7BmrDk.js} +2 -2
- package/dist/{bounded-turn-4BjrZEwW.js → bounded-turn-DRC3hcjm.js} +16 -20
- package/dist/{capabilities-CH3K57v4.js → capabilities-D6m_TdVy.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{command-formatters-D0nZ3qtd.js → command-formatters--UToCokS.js} +4 -3
- package/dist/{command-handlers-DC86lgT4.js → command-handlers-CLFx2Ypa.js} +114 -79
- package/dist/{compact-COqgBRny.js → compact-5xqW1oCh.js} +13 -12
- package/dist/{config-CpNeo5AE.js → config-CcYL77O6.js} +350 -288
- package/dist/{conversation-binding-data-CW2GuupV.js → conversation-binding-data-BiodpIzq.js} +2 -1
- package/dist/doctor-contract-api.js +121 -16
- package/dist/{dynamic-tools-fJZhl4CE.js → dynamic-tools-BmeXjwNZ.js} +243 -1002
- package/dist/{effective-mcp-catalog-4YKn51aG.js → effective-mcp-catalog-XXQKgK1U.js} +2 -2
- package/dist/{event-projector-assistant-message-BwxV4d6N.js → event-projector-assistant-message-C5-Ds8mA.js} +18 -1
- package/dist/{event-projector-usage-CLwNEJqW.js → event-projector-usage-B2r5vhWH.js} +9 -14
- package/dist/{harness-DoKQcF8n.js → harness-BgeB7LnD.js} +42 -52
- package/dist/harness.js +1 -1
- package/dist/index.js +308 -306
- package/dist/{isolated-completion-DPMtlH9r.js → isolated-completion-CxTus3vZ.js} +4 -4
- package/dist/launch-args-sXOAg0SX.js +84 -0
- package/dist/{managed-binary-By4FZC6i.js → managed-binary-ZkGodW19.js} +43 -7
- package/dist/media-understanding-provider.js +1 -1
- package/dist/model-catalog-DULBcniB.js +101 -0
- package/dist/{models-CZw1wClT.js → models-DaWfETQk.js} +27 -29
- package/dist/{native-subagent-monitor-GGq3RnOo.js → native-subagent-monitor-vXYUZH37.js} +226 -129
- package/dist/{node-exec-server.runtime-Bsu1LdFZ.js → node-exec-server.runtime-DirKVZ5h.js} +9 -6
- package/dist/{plugin-approval-roundtrip-C75Yiiwc.js → plugin-approval-roundtrip-CCWQGlAI.js} +2 -1
- package/dist/{plugin-marketplace-discovery-CSWDkMrP.js → plugin-marketplace-discovery-BXjIFEiw.js} +38 -46
- package/dist/{plugin-metadata-cache-BXH5NF-4.js → plugin-metadata-cache-DQQm4gWT.js} +163 -136
- package/dist/{protocol-validators-VAVyEnDp.js → protocol-validators-Bg5rpNxk.js} +148 -5
- package/dist/{rate-limits-BI1dMHDG.js → rate-limits-BqHEHXQJ.js} +3 -2
- package/dist/{sandbox-guard-C1qEeZ5C.js → request-BWxweEdK.js} +183 -2
- package/dist/{run-attempt-BV3HzuCf.js → run-attempt-BVLE4Gbi.js} +706 -517
- package/dist/{runtime-artifact-BvyT1uyd.js → runtime-artifact-D9pYp4zL.js} +3 -3
- package/dist/{session-binding-BTrLf9Qm.js → session-binding-D0zinCP1.js} +195 -122
- package/dist/{session-catalog-ezP_UcRM.js → session-catalog-eMhVm0Ql.js} +448 -313
- package/dist/session-catalog-home-id-Dt2GiG5o.js +112 -0
- package/dist/{session-cli-B1hKvfkI.js → session-cli-B2lyjJA0.js} +1 -1
- package/dist/session-history-C5J1AKzG.js +87 -0
- package/dist/session-permission-policy-ScnAyG90.js +160 -0
- package/dist/session-retirement-CtUtUTr9.js +90 -0
- package/dist/{session-upstream-marker-D_2npHlA.js → session-upstream-marker-gqrYIRHk.js} +2 -3
- package/dist/settled-turn-context-Bk3IUwod.js +290 -0
- package/dist/settled-turn-finalizer-BXLN9PfJ.js +104 -0
- package/dist/{shared-client-Dw-rzii0.js → shared-client-B1tT5U6r.js} +1738 -806
- package/dist/{side-question-DbXkJZzg.js → side-question-CZ-mCw-t.js} +76 -43
- package/dist/{thread-lifecycle-DKdrnTMX.js → thread-lifecycle-CGGKP720.js} +991 -455
- package/dist/{thread-ownership-i2NBwDUL.js → thread-ownership-RkaoZCmQ.js} +18 -8
- package/dist/{plugin-app-cache-key-DMNQ8Zi8.js → thread-resume-BFt1-ZDa.js} +55 -8
- package/dist/{transcript-mirror-BU0_LKAL.js → transcript-mirror-1ep4XjzF.js} +124 -18
- package/dist/transport-stdio-NT_Dpd9V.js +724 -0
- package/dist/{upstream-prompt-provenance-CFmsKwr9.js → upstream-prompt-provenance-LphB8slG.js} +8 -4
- package/dist/{upstream-session-fork-BDVJCLAD.js → upstream-session-fork-Dc8BFExw.js} +76 -90
- package/dist/{usage-9dKJCgcy.js → usage-DUhd58gI.js} +3 -3
- package/dist/{web-search-provider.runtime-DCdx4DGu.js → web-search-provider.runtime-BEmlE7ov.js} +3 -3
- package/openclaw.plugin.json +19 -1
- package/package.json +8 -8
- package/dist/app-server-policy-bg5QPSVP.js +0 -25
- package/dist/command-rpc-xUIIonsO.js +0 -90
- package/dist/incognito-session-ET_ufDH-.js +0 -2
- package/dist/model-catalog-CmGoqVKB.js +0 -48
- package/dist/request-DSK0W6YI.js +0 -157
- package/dist/session-catalog-home-id-BNwAJ9D7.js +0 -18
- package/dist/session-retirement-CE4iMiLh.js +0 -36
- package/dist/settled-turn-finalizer-Dx1onIqg.js +0 -328
- package/dist/thread-resume-CdJk2Ehf.js +0 -30
- package/dist/transport-stdio-DhoGy33Z.js +0 -99
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as
|
|
3
|
-
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-
|
|
4
|
-
import { n as sanitizeCodexHistoryImagePayloads } from "./image-payload-sanitizer-CnfoUPCE.js";
|
|
1
|
+
import { Ct as retainCodexAppServerLiveThread, Ht as isJsonObject, St as releaseCodexAppServerLiveThread, ht as claimCodexAppServerLiveThread } from "./shared-client-B1tT5U6r.js";
|
|
2
|
+
import { A as shouldRecordNativeToolTranscript, C as isNonSuccessItemStatus, D as itemStatus, E as itemName, F as readHookOutputEntries, I as readItem, N as normalizeOptionalString$1, O as itemTitle, R as readNonEmptyString, S as isMutatingNativeToolItem, T as itemKind, V as readNullableString$1, b as auditNativeToolTerminalStatus, j as shouldSynthesizeToolProgressForItem, w as isSideEffectingNativeToolItem, z as readNonEmptyStringArray } from "./attempt-client-cleanup-CpVfwctT.js";
|
|
3
|
+
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
|
|
5
4
|
import { t as resolveCodexLocalRuntimeAttribution } from "./local-runtime-attribution-B_2mnqhb.js";
|
|
6
|
-
import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-
|
|
5
|
+
import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-CCWQGlAI.js";
|
|
6
|
+
import { n as readCodexMirroredSessionHistoryMessages } from "./session-history-C5J1AKzG.js";
|
|
7
7
|
import { asFiniteNumber, asNonArrayRecord, normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
-
import fs from "node:fs/promises";
|
|
9
8
|
import path from "node:path";
|
|
10
9
|
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
11
10
|
import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage, formatToolAggregate, formatToolProgressOutput, inferToolMetaFromArgs, runAgentHarnessAfterToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
12
|
-
import { getSessionEntry, parseSqliteSessionFileMarker, resolveTranscriptSessionKeyBySessionId } from "openclaw/plugin-sdk/session-store-runtime";
|
|
13
11
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
14
12
|
import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
15
|
-
import { readCodexSessionTranscriptEventsBeforeAdmission } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
|
|
16
|
-
import { readSessionTranscriptEvents } from "openclaw/plugin-sdk/session-transcript-runtime";
|
|
17
13
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
18
|
-
import { buildSessionContext, migrateSessionEntries, parseSessionEntries } from "openclaw/plugin-sdk/agent-sessions";
|
|
19
14
|
import { createAgentHarnessTaskRuntime, deliverAgentHarnessTaskCompletion, isDurableAgentHarnessCompletionDelivery } from "openclaw/plugin-sdk/agent-harness-task-runtime";
|
|
20
15
|
//#region extensions/codex/src/app-server/event-projector-tool-output.ts
|
|
21
16
|
const TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS = 1e4;
|
|
@@ -114,7 +109,8 @@ function appendBoundedToolTranscriptText(currentPrefix, delta, originalLength) {
|
|
|
114
109
|
};
|
|
115
110
|
const textBudget = TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS - notice.length;
|
|
116
111
|
const remaining = Math.max(0, textBudget - currentPrefix.length);
|
|
117
|
-
const
|
|
112
|
+
const prefix = remaining > 0 ? `${currentPrefix}${truncateUtf16Safe(delta, remaining)}` : currentPrefix;
|
|
113
|
+
const rawPrefix = truncateUtf16Safe(prefix, textBudget);
|
|
118
114
|
return {
|
|
119
115
|
text: `${rawPrefix}${notice}`,
|
|
120
116
|
rawPrefix
|
|
@@ -127,7 +123,8 @@ function truncateToolTranscriptText(text, originalLength = text.length) {
|
|
|
127
123
|
if (originalLength <= 1e4 && text.length <= 1e4) return text;
|
|
128
124
|
const notice = toolTranscriptTruncationNotice(originalLength);
|
|
129
125
|
if (notice.length >= 1e4) return notice.slice(1, 10001);
|
|
130
|
-
|
|
126
|
+
const textBudget = TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS - notice.length;
|
|
127
|
+
return `${truncateUtf16Safe(text, textBudget)}${notice}`;
|
|
131
128
|
}
|
|
132
129
|
function formatToolSummary(toolName, meta) {
|
|
133
130
|
const trimmedMeta = meta?.trim();
|
|
@@ -570,7 +567,7 @@ var CodexToolProgressProjection = class {
|
|
|
570
567
|
const args = itemToolArgs(item);
|
|
571
568
|
if (!toolName || !shouldEmitTranscriptToolProgress(toolName, args)) return;
|
|
572
569
|
this.resultSummaryItemIds.add(item.id);
|
|
573
|
-
const meta = this.
|
|
570
|
+
const meta = this.shouldIncludeFormattedMeta(isCommandBearingToolItem(item, args)) ? itemMeta(item, this.toolProgressDetailMode()) : void 0;
|
|
574
571
|
this.emitToolResultMessage({
|
|
575
572
|
itemId: item.id,
|
|
576
573
|
text: formatToolSummary(toolName, meta)
|
|
@@ -582,9 +579,10 @@ var CodexToolProgressProjection = class {
|
|
|
582
579
|
const toolName = itemName(item);
|
|
583
580
|
const output = itemOutputText(item, this.output.textByItem);
|
|
584
581
|
if (!toolName || !output || !shouldEmitTranscriptToolProgress(toolName, itemToolArgs(item))) return;
|
|
582
|
+
const meta = this.shouldIncludeFormattedMeta(isCommandBearingToolItem(item, itemToolArgs(item))) ? itemMeta(item, this.toolProgressDetailMode()) : void 0;
|
|
585
583
|
this.emitToolResultMessage({
|
|
586
584
|
itemId: item.id,
|
|
587
|
-
text: formatToolOutput(toolName,
|
|
585
|
+
text: formatToolOutput(toolName, meta, output),
|
|
588
586
|
finalOutput: true,
|
|
589
587
|
isError: isNonSuccessItemStatus(itemStatus(item))
|
|
590
588
|
});
|
|
@@ -643,6 +641,7 @@ var CodexToolProgressProjection = class {
|
|
|
643
641
|
try {
|
|
644
642
|
Promise.resolve(this.params.onToolResult?.({
|
|
645
643
|
text,
|
|
644
|
+
...(this.params.messageChannel || this.params.messageProvider) && { channelData: { openclawToolProgressId: params.itemId } },
|
|
646
645
|
...params.isError === true ? { isError: true } : {}
|
|
647
646
|
})).catch(() => {});
|
|
648
647
|
} catch {}
|
|
@@ -653,11 +652,15 @@ var CodexToolProgressProjection = class {
|
|
|
653
652
|
shouldEmitToolOutput() {
|
|
654
653
|
return typeof this.params.shouldEmitToolOutput === "function" ? this.params.shouldEmitToolOutput() : this.params.verboseLevel === "full";
|
|
655
654
|
}
|
|
655
|
+
shouldIncludeFormattedMeta(commandBearing) {
|
|
656
|
+
const channel = this.params.messageChannel ?? this.params.messageProvider;
|
|
657
|
+
return !commandBearing || !channel && this.shouldEmitToolOutput();
|
|
658
|
+
}
|
|
656
659
|
emitTranscriptToolCallProgress(params) {
|
|
657
660
|
if (!shouldEmitTranscriptToolProgress(params.name, params.arguments)) return;
|
|
658
661
|
this.transcriptProgressCallIds.add(params.id);
|
|
659
662
|
const args = normalizeToolTranscriptArguments(params.arguments);
|
|
660
|
-
const meta = this.
|
|
663
|
+
const meta = this.shouldIncludeFormattedMeta(isCodexCommandBearingToolCall(params.name, args)) ? inferToolMetaFromArgs(params.name, args, { detailMode: this.toolProgressDetailMode() }) : void 0;
|
|
661
664
|
if (!this.params.onToolResult || !this.shouldEmitToolResult() || this.resultSummaryItemIds.has(params.id) || this.resultOutputStreamedItemIds.has(params.id)) return;
|
|
662
665
|
this.resultSummaryItemIds.add(params.id);
|
|
663
666
|
this.emitToolResultMessage({
|
|
@@ -717,85 +720,6 @@ var CodexToolProgressProjection = class {
|
|
|
717
720
|
}
|
|
718
721
|
};
|
|
719
722
|
//#endregion
|
|
720
|
-
//#region extensions/codex/src/app-server/session-history.ts
|
|
721
|
-
/**
|
|
722
|
-
* Reads OpenClaw session history for Codex transcript mirroring and sanitizes
|
|
723
|
-
* image payloads before replaying messages into the app-server projector.
|
|
724
|
-
*/
|
|
725
|
-
function isMissingFileError(error) {
|
|
726
|
-
return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
|
|
727
|
-
}
|
|
728
|
-
/** Returns sanitized session-context messages for a Codex mirrored session file. */
|
|
729
|
-
async function readCodexMirroredSessionHistoryMessages(target, admission) {
|
|
730
|
-
try {
|
|
731
|
-
const entries = await readCodexMirroredSessionEntries(target, admission);
|
|
732
|
-
if (entries.length === 0) return [];
|
|
733
|
-
const firstEntry = entries[0];
|
|
734
|
-
if (firstEntry?.type !== "session") return [];
|
|
735
|
-
if (typeof firstEntry.id !== "string") return;
|
|
736
|
-
if (firstEntry.id !== target.sessionId) return [];
|
|
737
|
-
migrateSessionEntries(entries);
|
|
738
|
-
return sanitizeCodexHistoryImagePayloads(buildSessionContext(entries.filter((entry) => {
|
|
739
|
-
return entry !== null && typeof entry === "object" && !Array.isArray(entry) && entry.type !== "session";
|
|
740
|
-
})).messages, "codex mirrored history");
|
|
741
|
-
} catch (error) {
|
|
742
|
-
if (isMissingFileError(error)) return [];
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
async function readCodexMirroredSessionEntries(target, admission) {
|
|
747
|
-
if (target.sessionTarget) {
|
|
748
|
-
const { agentId, sessionId, sessionKey, storePath } = target.sessionTarget;
|
|
749
|
-
if (!agentId || !sessionId || !sessionKey || !storePath || sessionId !== target.sessionId || target.agentId !== void 0 && agentId !== target.agentId || target.sessionKey !== void 0 && sessionKey !== target.sessionKey) return [];
|
|
750
|
-
const transcriptTarget = {
|
|
751
|
-
agentId,
|
|
752
|
-
sessionId,
|
|
753
|
-
sessionKey,
|
|
754
|
-
storePath
|
|
755
|
-
};
|
|
756
|
-
return await (admission ? readCodexSessionTranscriptEventsBeforeAdmission(transcriptTarget, admission) : readSessionTranscriptEvents(transcriptTarget));
|
|
757
|
-
}
|
|
758
|
-
const sqliteMarker = parseSqliteSessionFileMarker(target.sessionFile);
|
|
759
|
-
if (sqliteMarker) {
|
|
760
|
-
if (sqliteMarker.sessionId !== target.sessionId || target.agentId !== void 0 && sqliteMarker.agentId !== target.agentId) return [];
|
|
761
|
-
const sessionKey = resolveSqliteMarkerSessionKey(target, sqliteMarker);
|
|
762
|
-
if (!sessionKey) return [];
|
|
763
|
-
const transcriptTarget = {
|
|
764
|
-
agentId: sqliteMarker.agentId,
|
|
765
|
-
sessionId: sqliteMarker.sessionId,
|
|
766
|
-
sessionKey,
|
|
767
|
-
storePath: sqliteMarker.storePath
|
|
768
|
-
};
|
|
769
|
-
return await (admission ? readCodexSessionTranscriptEventsBeforeAdmission(transcriptTarget, admission) : readSessionTranscriptEvents(transcriptTarget));
|
|
770
|
-
}
|
|
771
|
-
if (admission) {
|
|
772
|
-
if (admission.sessionId !== target.sessionId || target.agentId !== void 0 && admission.agentId !== target.agentId || target.sessionKey !== void 0 && admission.sessionKey !== target.sessionKey) return [];
|
|
773
|
-
return await readCodexSessionTranscriptEventsBeforeAdmission({
|
|
774
|
-
agentId: admission.agentId,
|
|
775
|
-
sessionId: admission.sessionId,
|
|
776
|
-
sessionKey: admission.sessionKey,
|
|
777
|
-
storePath: admission.storePath
|
|
778
|
-
}, admission);
|
|
779
|
-
}
|
|
780
|
-
return parseSessionEntries(await fs.readFile(target.sessionFile, "utf-8"));
|
|
781
|
-
}
|
|
782
|
-
function resolveSqliteMarkerSessionKey(target, marker) {
|
|
783
|
-
const explicitSessionKey = target.sessionKey?.trim();
|
|
784
|
-
if (explicitSessionKey) {
|
|
785
|
-
const explicitEntry = getSessionEntry({
|
|
786
|
-
agentId: marker.agentId,
|
|
787
|
-
sessionKey: explicitSessionKey,
|
|
788
|
-
storePath: marker.storePath
|
|
789
|
-
});
|
|
790
|
-
if (explicitEntry) return explicitEntry.sessionId === marker.sessionId ? explicitSessionKey : void 0;
|
|
791
|
-
}
|
|
792
|
-
return resolveTranscriptSessionKeyBySessionId({
|
|
793
|
-
agentId: marker.agentId,
|
|
794
|
-
sessionId: marker.sessionId,
|
|
795
|
-
storePath: marker.storePath
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
|
-
//#endregion
|
|
799
723
|
//#region extensions/codex/src/app-server/event-projector-tool-transcript.ts
|
|
800
724
|
const ZERO_USAGE = {
|
|
801
725
|
input: 0,
|
|
@@ -866,6 +790,7 @@ var CodexToolTranscriptProjection = class {
|
|
|
866
790
|
this.nativeMcpAppResultDetailsAttempted = /* @__PURE__ */ new Set();
|
|
867
791
|
this.approvalReviewsByCallId = /* @__PURE__ */ new Map();
|
|
868
792
|
this.rawNativeToolOutputByCallId = /* @__PURE__ */ new Map();
|
|
793
|
+
this.pendingRawPatchOutputIds = /* @__PURE__ */ new Set();
|
|
869
794
|
this.codeModeNativePatchInputsByCallId = /* @__PURE__ */ new Map();
|
|
870
795
|
}
|
|
871
796
|
get transcriptMessages() {
|
|
@@ -969,14 +894,18 @@ var CodexToolTranscriptProjection = class {
|
|
|
969
894
|
} catch {
|
|
970
895
|
return;
|
|
971
896
|
}
|
|
972
|
-
if (args)
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
897
|
+
if (args) {
|
|
898
|
+
this.pendingRawPatchOutputIds.add(callId);
|
|
899
|
+
this.recordToolCall({
|
|
900
|
+
id: callId,
|
|
901
|
+
name: "apply_patch",
|
|
902
|
+
arguments: args
|
|
903
|
+
});
|
|
904
|
+
}
|
|
977
905
|
return;
|
|
978
906
|
}
|
|
979
907
|
if (type !== "custom_tool_call_output" && type !== "function_call_output" || this.namesById.get(callId) !== "apply_patch" && !this.codeModeNativePatchInputsByCallId.has(callId)) return;
|
|
908
|
+
this.pendingRawPatchOutputIds.delete(callId);
|
|
980
909
|
const text = typeof item.output === "string" ? item.output : Array.isArray(item.output) ? collectDynamicToolContentText(item.output) : "";
|
|
981
910
|
if (!text.trim()) return;
|
|
982
911
|
const codeModePatchInput = this.codeModeNativePatchInputsByCallId.get(callId);
|
|
@@ -1168,13 +1097,20 @@ var CodexToolTranscriptProjection = class {
|
|
|
1168
1097
|
this.callIds.add(params.id);
|
|
1169
1098
|
this.namesById.set(params.id, params.name);
|
|
1170
1099
|
this.progress.recordTranscriptCall(params);
|
|
1171
|
-
|
|
1100
|
+
const message = attachCodexMirrorIdentity(this.createToolCallMessage(params), `${this.turnId}:tool:${params.id}:call`);
|
|
1101
|
+
this.messages.push(message);
|
|
1102
|
+
this.options.checkpointMessage?.({ read: () => message });
|
|
1172
1103
|
}
|
|
1173
1104
|
recordToolResult(params) {
|
|
1174
1105
|
if (!params.id || !params.name || this.resultIds.has(params.id)) return;
|
|
1175
1106
|
this.resultIds.add(params.id);
|
|
1176
1107
|
this.progress.recordTranscriptResult(params);
|
|
1177
|
-
|
|
1108
|
+
const message = attachCodexMirrorIdentity(this.createToolResultMessage(params), `${this.turnId}:tool:${params.id}:result`);
|
|
1109
|
+
this.messages.push(message);
|
|
1110
|
+
this.options.checkpointMessage?.({
|
|
1111
|
+
read: () => message,
|
|
1112
|
+
ready: () => !this.pendingRawPatchOutputIds.has(params.id)
|
|
1113
|
+
});
|
|
1178
1114
|
}
|
|
1179
1115
|
recordMissingToolError(missingTranscriptIds, missingTrajectoryIds) {
|
|
1180
1116
|
const firstMissingId = missingTranscriptIds.find((id) => Boolean(this.namesById.get(id))) ?? missingTrajectoryIds.find((id) => Boolean(this.trajectoryNamesById.get(id) ?? this.namesById.get(id)));
|
|
@@ -1253,10 +1189,34 @@ function resolveStartedAtFromDurationMs(durationMs) {
|
|
|
1253
1189
|
}
|
|
1254
1190
|
//#endregion
|
|
1255
1191
|
//#region extensions/codex/src/app-server/event-projector-events.ts
|
|
1192
|
+
/** Downstream event consumers must never corrupt the canonical Codex turn projection. */
|
|
1193
|
+
function emitCodexAgentEvent(params, event) {
|
|
1194
|
+
try {
|
|
1195
|
+
emitAgentEvent({
|
|
1196
|
+
runId: params.runId,
|
|
1197
|
+
stream: event.stream,
|
|
1198
|
+
data: event.data,
|
|
1199
|
+
...params.sessionKey ? { sessionKey: params.sessionKey } : {}
|
|
1200
|
+
});
|
|
1201
|
+
} catch (error) {
|
|
1202
|
+
embeddedAgentLog.debug("codex app-server global agent event emit failed", { error });
|
|
1203
|
+
}
|
|
1204
|
+
try {
|
|
1205
|
+
const maybePromise = params.onAgentEvent?.(event);
|
|
1206
|
+
Promise.resolve(maybePromise).catch((error) => {
|
|
1207
|
+
embeddedAgentLog.debug("codex app-server agent event handler rejected", { error });
|
|
1208
|
+
});
|
|
1209
|
+
} catch (error) {
|
|
1210
|
+
embeddedAgentLog.debug("codex app-server agent event handler threw", { error });
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1256
1213
|
function guardianActionCommand(action) {
|
|
1257
1214
|
if (!action) return;
|
|
1258
|
-
const
|
|
1259
|
-
if (
|
|
1215
|
+
const directLabel = readStringField(action, "command") ?? readStringField(action, "target") ?? readStringField(action, "toolTitle") ?? readStringField(action, "reason");
|
|
1216
|
+
if (directLabel) return directLabel;
|
|
1217
|
+
const server = readStringField(action, "connectorName") ?? readStringField(action, "server");
|
|
1218
|
+
const tool = readStringField(action, "toolName");
|
|
1219
|
+
if (server && tool) return `${server}/${tool}`;
|
|
1260
1220
|
const argv = Array.isArray(action.argv) ? action.argv.filter((value) => typeof value === "string") : [];
|
|
1261
1221
|
return argv.length > 0 ? argv.join(" ") : readStringField(action, "program");
|
|
1262
1222
|
}
|
|
@@ -1264,6 +1224,7 @@ function normalizeApprovalReviewStatus(status) {
|
|
|
1264
1224
|
return status === "inProgress" ? "in_progress" : status === "timedOut" ? "timed_out" : status;
|
|
1265
1225
|
}
|
|
1266
1226
|
const GUARDIAN_TIMEOUT_WARNING = "Automatic approval review timed out while evaluating the requested approval.";
|
|
1227
|
+
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\.$/];
|
|
1267
1228
|
function projectNormalizedToolItem(params) {
|
|
1268
1229
|
const { item } = params;
|
|
1269
1230
|
if (!item || !shouldSynthesizeToolProgressForItem(item)) return;
|
|
@@ -1310,12 +1271,26 @@ var CodexEventProjection = class {
|
|
|
1310
1271
|
get guardianReviewCount() {
|
|
1311
1272
|
return this.reviewCount;
|
|
1312
1273
|
}
|
|
1274
|
+
emitCompactionEnd(itemId, completed) {
|
|
1275
|
+
this.emitAgentEvent({
|
|
1276
|
+
stream: "compaction",
|
|
1277
|
+
data: {
|
|
1278
|
+
phase: "end",
|
|
1279
|
+
backend: "codex-app-server",
|
|
1280
|
+
completed,
|
|
1281
|
+
threadId: this.threadId,
|
|
1282
|
+
turnId: this.turnId,
|
|
1283
|
+
itemId
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1313
1287
|
handleGuardianReview(method, params) {
|
|
1314
1288
|
this.reviewCount += 1;
|
|
1315
1289
|
const review = isJsonObject(params.review) ? params.review : void 0;
|
|
1316
1290
|
const action = isJsonObject(params.action) ? params.action : void 0;
|
|
1317
1291
|
const reviewId = readStringField(params, "reviewId");
|
|
1318
1292
|
const targetItemId = readNullableString$1(params, "targetItemId");
|
|
1293
|
+
const command = guardianActionCommand(action);
|
|
1319
1294
|
const reviewStatus = review ? readStringField(review, "status") : void 0;
|
|
1320
1295
|
const status = normalizeApprovalReviewStatus(reviewStatus);
|
|
1321
1296
|
const riskLevel = review ? readStringField(review, "riskLevel") : void 0;
|
|
@@ -1324,11 +1299,22 @@ var CodexEventProjection = class {
|
|
|
1324
1299
|
const expectedWarning = status === "timed_out" ? GUARDIAN_TIMEOUT_WARNING : rationale && riskLevel && userAuthorization && (status === "approved" || status === "denied") ? `Automatic approval review ${status} (risk: ${riskLevel}, authorization: ${userAuthorization}): ${rationale}` : void 0;
|
|
1325
1300
|
if (Boolean(targetItemId) && Boolean(reviewId) && this.pendingGuardianWarning === expectedWarning) this.pendingGuardianWarning = void 0;
|
|
1326
1301
|
else this.flushPendingGuardianWarning();
|
|
1302
|
+
const threadId = readStringField(params, "threadId") ?? this.threadId;
|
|
1303
|
+
const turnId = readStringField(params, "turnId") ?? this.turnId;
|
|
1304
|
+
if (method.endsWith("/started")) this.activeGuardianReview = {
|
|
1305
|
+
reviewId,
|
|
1306
|
+
targetItemId,
|
|
1307
|
+
command,
|
|
1308
|
+
threadId,
|
|
1309
|
+
turnId
|
|
1310
|
+
};
|
|
1327
1311
|
this.emitAgentEvent({
|
|
1328
1312
|
stream: "codex_app_server.guardian",
|
|
1329
1313
|
data: {
|
|
1330
1314
|
method,
|
|
1331
1315
|
phase: method.endsWith("/started") ? "started" : "completed",
|
|
1316
|
+
threadId,
|
|
1317
|
+
turnId,
|
|
1332
1318
|
reviewId,
|
|
1333
1319
|
targetItemId,
|
|
1334
1320
|
decisionSource: readStringField(params, "decisionSource"),
|
|
@@ -1337,7 +1323,7 @@ var CodexEventProjection = class {
|
|
|
1337
1323
|
userAuthorization,
|
|
1338
1324
|
rationale,
|
|
1339
1325
|
actionType: action ? readStringField(action, "type") : void 0,
|
|
1340
|
-
command
|
|
1326
|
+
command
|
|
1341
1327
|
}
|
|
1342
1328
|
});
|
|
1343
1329
|
if (reviewId && targetItemId && status) {
|
|
@@ -1361,6 +1347,7 @@ var CodexEventProjection = class {
|
|
|
1361
1347
|
}
|
|
1362
1348
|
});
|
|
1363
1349
|
}
|
|
1350
|
+
if (method.endsWith("/completed") && this.activeGuardianReview?.reviewId === reviewId) this.activeGuardianReview = void 0;
|
|
1364
1351
|
}
|
|
1365
1352
|
handleGuardianWarning(params) {
|
|
1366
1353
|
this.flushPendingGuardianWarning();
|
|
@@ -1377,6 +1364,30 @@ var CodexEventProjection = class {
|
|
|
1377
1364
|
}
|
|
1378
1365
|
});
|
|
1379
1366
|
}
|
|
1367
|
+
handleWarning(params) {
|
|
1368
|
+
const message = [readStringField(params, "summary") ?? readStringField(params, "message"), readStringField(params, "details")].filter(Boolean).join("\n");
|
|
1369
|
+
if (LOG_ONLY_CODEX_WARNING_PATTERNS.some((pattern) => pattern.test(message))) embeddedAgentLog.warn(message);
|
|
1370
|
+
else if (message) this.emitAgentEvent({
|
|
1371
|
+
stream: "notice",
|
|
1372
|
+
data: {
|
|
1373
|
+
phase: "warning",
|
|
1374
|
+
message
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
handleModelRerouted(params) {
|
|
1379
|
+
const fromModel = readStringField(params, "fromModel");
|
|
1380
|
+
const toModel = readStringField(params, "toModel");
|
|
1381
|
+
const reason = readStringField(params, "reason");
|
|
1382
|
+
if (fromModel && toModel && fromModel !== toModel) this.emitAgentEvent({
|
|
1383
|
+
stream: "fallback",
|
|
1384
|
+
data: {
|
|
1385
|
+
fromModel,
|
|
1386
|
+
toModel,
|
|
1387
|
+
...reason ? { reason } : {}
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1380
1391
|
flushPendingGuardianWarning() {
|
|
1381
1392
|
const pending = this.pendingGuardianWarning;
|
|
1382
1393
|
if (!pending) return;
|
|
@@ -1389,6 +1400,21 @@ var CodexEventProjection = class {
|
|
|
1389
1400
|
}
|
|
1390
1401
|
});
|
|
1391
1402
|
}
|
|
1403
|
+
handleStrictReviewRequired(params) {
|
|
1404
|
+
this.emitAgentEvent({
|
|
1405
|
+
stream: "codex_app_server.guardian",
|
|
1406
|
+
data: {
|
|
1407
|
+
method: "autoApprovalReview/strictReviewRequired",
|
|
1408
|
+
phase: "strict_review_required",
|
|
1409
|
+
threadId: readStringField(params, "threadId") ?? this.activeGuardianReview?.threadId ?? this.threadId,
|
|
1410
|
+
turnId: readStringField(params, "turnId") ?? this.activeGuardianReview?.turnId ?? this.turnId,
|
|
1411
|
+
reviewId: this.activeGuardianReview?.reviewId,
|
|
1412
|
+
targetItemId: this.activeGuardianReview?.targetItemId,
|
|
1413
|
+
command: this.activeGuardianReview?.command,
|
|
1414
|
+
startedAtMs: asFiniteNumber(params.startedAtMs)
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1392
1418
|
handleHook(method, params) {
|
|
1393
1419
|
const run = isJsonObject(params.run) ? params.run : void 0;
|
|
1394
1420
|
if (!run) return;
|
|
@@ -1513,8 +1539,23 @@ function extractCodexNativeSubagentCompletionsFromText(text) {
|
|
|
1513
1539
|
}
|
|
1514
1540
|
const codexNativeSubagentNotifications = {
|
|
1515
1541
|
fromNotification: extractCodexNativeSubagentCompletions,
|
|
1516
|
-
fromText: extractCodexNativeSubagentCompletionsFromText
|
|
1542
|
+
fromText: extractCodexNativeSubagentCompletionsFromText,
|
|
1543
|
+
deliveredAgentPaths: readDeliveredNativeCompletionPaths
|
|
1517
1544
|
};
|
|
1545
|
+
/** Reads native delivery receipts, leaving status and result ownership with the child lifecycle. */
|
|
1546
|
+
function readDeliveredNativeCompletionPaths(notification) {
|
|
1547
|
+
if (notification.method !== "rawResponseItem/completed") return [];
|
|
1548
|
+
const params = isJsonObject(notification.params) ? notification.params : void 0;
|
|
1549
|
+
const item = isJsonObject(params?.item) ? params.item : void 0;
|
|
1550
|
+
if (!item || readStringField(item, "type") !== "agent_message") return extractCodexNativeSubagentCompletions(notification).map((completion) => completion.agentPath);
|
|
1551
|
+
const author = readStringField(item, "author");
|
|
1552
|
+
const recipient = readStringField(item, "recipient");
|
|
1553
|
+
const content = item.content;
|
|
1554
|
+
if (!author || !recipient || !Array.isArray(content) || content.length !== 1) return [];
|
|
1555
|
+
const part = content[0];
|
|
1556
|
+
if (!isJsonObject(part) || readStringField(part, "type") !== "input_text") return [];
|
|
1557
|
+
return readStringField(part, "text")?.startsWith(`Message Type: FINAL_ANSWER\nTask name: ${recipient}\nSender: ${author}\nPayload:\n`) ? [author] : [];
|
|
1558
|
+
}
|
|
1518
1559
|
function parseCodexNativeSubagentNotificationBody(body) {
|
|
1519
1560
|
let payload;
|
|
1520
1561
|
try {
|
|
@@ -2113,7 +2154,11 @@ var Monitor = class {
|
|
|
2113
2154
|
this.releaseRetainedClient();
|
|
2114
2155
|
for (const release of this.parentThreadRetentions.values()) release();
|
|
2115
2156
|
this.parentThreadRetentions.clear();
|
|
2116
|
-
for (const state of this.parentStates.values())
|
|
2157
|
+
for (const state of this.parentStates.values()) {
|
|
2158
|
+
state.owners.clear();
|
|
2159
|
+
state.turnIds.clear();
|
|
2160
|
+
this.deliverDetachedCompletions(state);
|
|
2161
|
+
}
|
|
2117
2162
|
this.pendingDirectSpawnEvidence.clear();
|
|
2118
2163
|
for (const [parentThreadId] of this.parentStates) if (![...this.childStates.values()].some((childState) => childState.parentThreadId === parentThreadId)) this.parentStates.delete(parentThreadId);
|
|
2119
2164
|
}
|
|
@@ -2126,7 +2171,9 @@ var Monitor = class {
|
|
|
2126
2171
|
if (!state) {
|
|
2127
2172
|
state = {
|
|
2128
2173
|
parentThreadId,
|
|
2129
|
-
owners: /* @__PURE__ */ new Map()
|
|
2174
|
+
owners: /* @__PURE__ */ new Map(),
|
|
2175
|
+
turnIds: /* @__PURE__ */ new Set(),
|
|
2176
|
+
nativeCompletionReceipts: /* @__PURE__ */ new Set()
|
|
2130
2177
|
};
|
|
2131
2178
|
this.parentStates.set(parentThreadId, state);
|
|
2132
2179
|
}
|
|
@@ -2156,6 +2203,7 @@ var Monitor = class {
|
|
|
2156
2203
|
const current = registeredState.owners.get(owner);
|
|
2157
2204
|
if (!current || [...registeredState.owners.values()].some((other) => other !== current && other.turnId === turnId)) return;
|
|
2158
2205
|
current.turnId = turnId;
|
|
2206
|
+
registeredState.turnIds.add(turnId);
|
|
2159
2207
|
this.drainPendingDirectSpawnEvidence(registeredState, current, turnId);
|
|
2160
2208
|
this.clearUnconsumablePendingDirectSpawnEvidence();
|
|
2161
2209
|
},
|
|
@@ -2164,8 +2212,15 @@ var Monitor = class {
|
|
|
2164
2212
|
registered = false;
|
|
2165
2213
|
const current = this.parentStates.get(parentThreadId);
|
|
2166
2214
|
if (current === registeredState) {
|
|
2215
|
+
const turnId = current.owners.get(owner)?.turnId;
|
|
2167
2216
|
current.owners.delete(owner);
|
|
2217
|
+
if (turnId) current.turnIds.delete(turnId);
|
|
2218
|
+
if (current.owners.size === 0) {
|
|
2219
|
+
current.turnIds.clear();
|
|
2220
|
+
current.nativeCompletionReceipts = /* @__PURE__ */ new Set();
|
|
2221
|
+
}
|
|
2168
2222
|
this.clearUnconsumablePendingDirectSpawnEvidence();
|
|
2223
|
+
this.deliverDetachedCompletions(current);
|
|
2169
2224
|
this.pruneParentIfUnused(current);
|
|
2170
2225
|
}
|
|
2171
2226
|
}
|
|
@@ -2203,6 +2258,11 @@ var Monitor = class {
|
|
|
2203
2258
|
const startedThread = isJsonObject(params?.thread) ? params.thread : void 0;
|
|
2204
2259
|
const threadId = readStringField(params, "threadId")?.trim() ?? readStringField(startedThread, "id")?.trim();
|
|
2205
2260
|
const threadStatus = isJsonObject(params?.status) ? normalizeIdentifier(readStringField(params.status, "type")) : void 0;
|
|
2261
|
+
const parent = threadId ? this.parentStates.get(threadId) : void 0;
|
|
2262
|
+
if (parent && parent.owners.size > 0 && notification.method === "turn/started") {
|
|
2263
|
+
const turnId = isJsonObject(params?.turn) ? readStringField(params.turn, "id") : void 0;
|
|
2264
|
+
if (turnId) parent.turnIds.add(turnId);
|
|
2265
|
+
}
|
|
2206
2266
|
const tracksRecoveryRevision = Boolean(threadId && this.threadStatusRevisions.has(threadId));
|
|
2207
2267
|
if (RECOVERY_REVISION_NOTIFICATION_METHODS.has(notification.method) && threadId && tracksRecoveryRevision) this.threadStatusRevisions.get(threadId).value += 1;
|
|
2208
2268
|
if (!state && (!threadId || !this.parentStates.has(threadId) && !this.childStates.has(threadId) && !tracksRecoveryRevision)) return;
|
|
@@ -2216,23 +2276,30 @@ var Monitor = class {
|
|
|
2216
2276
|
}
|
|
2217
2277
|
if (state) this.handleClosedChild(notification, state);
|
|
2218
2278
|
const childState = threadId ? this.childStates.get(threadId) : void 0;
|
|
2219
|
-
if (notification.method === "turn/started" && childState)
|
|
2279
|
+
if (notification.method === "turn/started" && childState) {
|
|
2280
|
+
childState.nativeCompletionDelivered = false;
|
|
2281
|
+
for (const key of childState.agentPathKeys) state?.nativeCompletionReceipts.delete(key);
|
|
2282
|
+
this.resumeChild(childState);
|
|
2283
|
+
}
|
|
2284
|
+
if (parent && parent.turnIds.has(readStringField(params, "turnId") ?? "")) this.recordNativeCompletionDelivery(parent, notification);
|
|
2220
2285
|
if (childState && !childState.terminal) this.emitChildTaskActivity(notification, childState);
|
|
2221
2286
|
this.captureChildAssistantMessage(notification);
|
|
2222
2287
|
await this.handleChildTurnCompletion(notification);
|
|
2223
|
-
if (notification.method === "thread/status/changed" && threadId && threadStatus)
|
|
2224
|
-
if (
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2288
|
+
if (notification.method === "thread/status/changed" && threadId && threadStatus) {
|
|
2289
|
+
if (threadStatus !== "systemerror") {
|
|
2290
|
+
if (childState) this.clearSystemErrorFallback(childState);
|
|
2291
|
+
} else {
|
|
2292
|
+
if (childState) {
|
|
2293
|
+
this.resumeChild(childState, { scheduleRecovery: false });
|
|
2294
|
+
this.setRecoveryFallback(childState, systemErrorFallbackCompletion(childState.childThreadId), this.now());
|
|
2295
|
+
}
|
|
2296
|
+
this.reconcileChildThread(threadId).catch((error) => {
|
|
2297
|
+
this.logRecoveryFailure(threadId, error);
|
|
2298
|
+
return false;
|
|
2299
|
+
}).then((reconciled) => {
|
|
2300
|
+
if (!reconciled && childState && this.childStates.get(threadId) === childState) this.scheduleRecoveryPoll(childState);
|
|
2301
|
+
});
|
|
2229
2302
|
}
|
|
2230
|
-
this.reconcileChildThread(threadId).catch((error) => {
|
|
2231
|
-
this.logRecoveryFailure(threadId, error);
|
|
2232
|
-
return false;
|
|
2233
|
-
}).then((reconciled) => {
|
|
2234
|
-
if (!reconciled && childState && this.childStates.get(threadId) === childState) this.scheduleRecoveryPoll(childState);
|
|
2235
|
-
});
|
|
2236
2303
|
}
|
|
2237
2304
|
await this.handleCompletionNotification(notification);
|
|
2238
2305
|
}
|
|
@@ -2528,6 +2595,7 @@ var Monitor = class {
|
|
|
2528
2595
|
this.unregisterChild(childState);
|
|
2529
2596
|
return false;
|
|
2530
2597
|
}
|
|
2598
|
+
if (recovery.agentPath) this.registerAgentPath(childState, recovery.agentPath);
|
|
2531
2599
|
if (recovery.threadState === "active") {
|
|
2532
2600
|
this.observeActiveChild(childState);
|
|
2533
2601
|
return false;
|
|
@@ -2593,6 +2661,7 @@ var Monitor = class {
|
|
|
2593
2661
|
}
|
|
2594
2662
|
return {
|
|
2595
2663
|
parentThreadId: readThreadParentThreadId(thread),
|
|
2664
|
+
agentPath: normalizeOptionalString(readStringField(readThreadSpawnSource(thread), "agent_path")),
|
|
2596
2665
|
completion,
|
|
2597
2666
|
fallbackCompletion,
|
|
2598
2667
|
resumable,
|
|
@@ -2624,6 +2693,10 @@ var Monitor = class {
|
|
|
2624
2693
|
this.unregisterChild(childState);
|
|
2625
2694
|
return;
|
|
2626
2695
|
}
|
|
2696
|
+
if (childState.nativeCompletionDelivered) {
|
|
2697
|
+
this.finishCompletionDelivery(state, childState);
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2627
2700
|
childState.pendingCompletion = completion;
|
|
2628
2701
|
state.taskRuntime?.setDetachedTaskDeliveryStatusByRunId({
|
|
2629
2702
|
runId: codexNativeSubagentRunId(completion.childThreadId),
|
|
@@ -2635,6 +2708,7 @@ var Monitor = class {
|
|
|
2635
2708
|
async deliverPendingCompletion(state, childState) {
|
|
2636
2709
|
const completion = childState.pendingCompletion;
|
|
2637
2710
|
if (!completion || !state.requesterSessionKey || !state.taskRuntimeScope) return;
|
|
2711
|
+
if (state.owners.size > 0) return;
|
|
2638
2712
|
if (childState.deliveringCompletion || childState.completionDeliveryTimer) return;
|
|
2639
2713
|
childState.deliveringCompletion = true;
|
|
2640
2714
|
try {
|
|
@@ -2652,13 +2726,7 @@ var Monitor = class {
|
|
|
2652
2726
|
});
|
|
2653
2727
|
if (this.childStates.get(childState.childThreadId) !== childState || this.parentStates.get(state.parentThreadId) !== state) return;
|
|
2654
2728
|
if (isDurableAgentHarnessCompletionDelivery(delivery)) {
|
|
2655
|
-
|
|
2656
|
-
childState.completionDeliveryAttempt = 0;
|
|
2657
|
-
state.taskRuntime?.setDetachedTaskDeliveryStatusByRunId({
|
|
2658
|
-
runId: codexNativeSubagentRunId(completion.childThreadId),
|
|
2659
|
-
deliveryStatus: "delivered"
|
|
2660
|
-
});
|
|
2661
|
-
this.unregisterChild(childState);
|
|
2729
|
+
this.finishCompletionDelivery(state, childState);
|
|
2662
2730
|
return;
|
|
2663
2731
|
}
|
|
2664
2732
|
const error = delivery.error ?? "completion delivery did not produce a parent response";
|
|
@@ -2686,6 +2754,29 @@ var Monitor = class {
|
|
|
2686
2754
|
childState.deliveringCompletion = false;
|
|
2687
2755
|
}
|
|
2688
2756
|
}
|
|
2757
|
+
recordNativeCompletionDelivery(state, notification) {
|
|
2758
|
+
for (const agentPath of codexNativeSubagentNotifications.deliveredAgentPaths(notification)) {
|
|
2759
|
+
const key = buildParentAgentPathKey(state.parentThreadId, agentPath);
|
|
2760
|
+
state.nativeCompletionReceipts.add(key);
|
|
2761
|
+
const childThreadId = this.childThreadIdsByAgentPath.get(key);
|
|
2762
|
+
const child = childThreadId ? this.childStates.get(childThreadId) : void 0;
|
|
2763
|
+
if (!child || child.parentThreadId !== state.parentThreadId) continue;
|
|
2764
|
+
child.nativeCompletionDelivered = true;
|
|
2765
|
+
if (child.pendingCompletion && !child.deliveringCompletion) this.finishCompletionDelivery(state, child);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
finishCompletionDelivery(state, child) {
|
|
2769
|
+
child.pendingCompletion = void 0;
|
|
2770
|
+
child.completionDeliveryAttempt = 0;
|
|
2771
|
+
state.taskRuntime?.setDetachedTaskDeliveryStatusByRunId({
|
|
2772
|
+
runId: codexNativeSubagentRunId(child.childThreadId),
|
|
2773
|
+
deliveryStatus: "delivered"
|
|
2774
|
+
});
|
|
2775
|
+
this.unregisterChild(child);
|
|
2776
|
+
}
|
|
2777
|
+
deliverDetachedCompletions(state) {
|
|
2778
|
+
for (const child of this.childStates.values()) if (child.parentThreadId === state.parentThreadId && child.pendingCompletion) this.deliverPendingCompletion(state, child);
|
|
2779
|
+
}
|
|
2689
2780
|
scheduleCompletionDeliveryRetry(childState, error) {
|
|
2690
2781
|
if (!childState.pendingCompletion || childState.completionDeliveryTimer || this.childStates.get(childState.childThreadId) !== childState) return;
|
|
2691
2782
|
if (childState.completionDeliveryAttempt >= this.completionDeliveryMaxRetries) {
|
|
@@ -2735,6 +2826,7 @@ var Monitor = class {
|
|
|
2735
2826
|
assistantMessagesByTurn: /* @__PURE__ */ new Map(),
|
|
2736
2827
|
recoveryAttempt: 0,
|
|
2737
2828
|
terminal: false,
|
|
2829
|
+
nativeCompletionDelivered: false,
|
|
2738
2830
|
settledWithoutCompletion: false,
|
|
2739
2831
|
completionDeliveryAttempt: 0,
|
|
2740
2832
|
deliveringCompletion: false
|
|
@@ -2821,6 +2913,7 @@ var Monitor = class {
|
|
|
2821
2913
|
}
|
|
2822
2914
|
this.childThreadIdsByAgentPath.set(key, childState.childThreadId);
|
|
2823
2915
|
childState.agentPathKeys.add(key);
|
|
2916
|
+
if (this.parentStates.get(childState.parentThreadId)?.nativeCompletionReceipts.has(key)) childState.nativeCompletionDelivered = true;
|
|
2824
2917
|
}
|
|
2825
2918
|
unregisterChild(childState, options = {}) {
|
|
2826
2919
|
this.releaseDirectChild(childState);
|
|
@@ -2970,6 +3063,7 @@ var Monitor = class {
|
|
|
2970
3063
|
const childThreadId = task.runId.slice(13).trim();
|
|
2971
3064
|
candidates.set(childThreadId, {
|
|
2972
3065
|
parentState: state,
|
|
3066
|
+
nativeCompletionReceipts: state.nativeCompletionReceipts,
|
|
2973
3067
|
requesterSessionKey: state.requesterSessionKey,
|
|
2974
3068
|
childThreadId,
|
|
2975
3069
|
recoveryAttempt: 0,
|
|
@@ -3046,6 +3140,8 @@ var Monitor = class {
|
|
|
3046
3140
|
state = {
|
|
3047
3141
|
parentThreadId,
|
|
3048
3142
|
owners: /* @__PURE__ */ new Map(),
|
|
3143
|
+
turnIds: /* @__PURE__ */ new Set(),
|
|
3144
|
+
nativeCompletionReceipts: /* @__PURE__ */ new Set(),
|
|
3049
3145
|
requesterSessionKey: candidate.requesterSessionKey,
|
|
3050
3146
|
taskRuntimeScope: candidate.taskRuntimeScope,
|
|
3051
3147
|
agentId: candidate.agentId,
|
|
@@ -3054,11 +3150,12 @@ var Monitor = class {
|
|
|
3054
3150
|
this.prepareParentTaskRuntime(state);
|
|
3055
3151
|
this.parentStates.set(parentThreadId, state);
|
|
3056
3152
|
}
|
|
3057
|
-
const childState = this.registerChildThread(state, candidate.childThreadId);
|
|
3153
|
+
const childState = this.registerChildThread(state, candidate.childThreadId, recovery.agentPath ? { agentPath: recovery.agentPath } : {});
|
|
3058
3154
|
if (!childState) {
|
|
3059
3155
|
this.pruneParentIfUnused(state);
|
|
3060
3156
|
return;
|
|
3061
3157
|
}
|
|
3158
|
+
if ([...childState.agentPathKeys].some((key) => candidate.nativeCompletionReceipts.has(key))) childState.nativeCompletionDelivered = true;
|
|
3062
3159
|
if (recovery.threadState === "active") this.observeActiveChild(childState);
|
|
3063
3160
|
if (recovery.threadState === "other") this.clearSystemErrorFallback(childState);
|
|
3064
3161
|
if (recovery.resumable) {
|
|
@@ -3222,4 +3319,4 @@ function unrefTimer(timer) {
|
|
|
3222
3319
|
if (typeof timer === "object" && timer && "unref" in timer) timer.unref();
|
|
3223
3320
|
}
|
|
3224
3321
|
//#endregion
|
|
3225
|
-
export { CodexToolProgressProjection as a, isCodexCommandBearingToolCall as c, sanitizeCodexToolResponse as d,
|
|
3322
|
+
export { CodexToolProgressProjection as a, isCodexCommandBearingToolCall as c, sanitizeCodexToolResponse as d, CodexToolTranscriptProjection as i, resolveCodexToolProgressDetailMode as l, CodexEventProjection as n, shouldEmitTranscriptToolProgress as o, emitCodexAgentEvent as r, inferCodexDynamicToolMeta as s, codexNativeSubagentMonitorRuntime as t, sanitizeCodexToolArguments as u };
|