@openclaw/codex 2026.9.3 → 2026.9.4
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 +26 -18
- package/dist/{apply-B6el6hdO.js → apply-CvT8tW5i.js} +11 -12
- package/dist/{attempt-client-cleanup-D6cR54TV.js → attempt-client-cleanup-DKHzbwt5.js} +8 -204
- package/dist/{attempt-context-AO4DSjE0.js → attempt-context-D44yeDII.js} +3 -3
- package/dist/{attempt-notifications--H8zXR5-.js → attempt-notifications-C9XufG6l.js} +1 -1
- package/dist/{auth-binding-Co2Vfcf_.js → auth-binding-CWlKVccJ.js} +1 -1
- package/dist/{auth-cache-key-Kq6oerr6.js → auth-cache-key-7orQae_j.js} +2 -2
- package/dist/{binding-connection-QqgcPCgk.js → binding-connection-D3udKbIE.js} +3 -3
- package/dist/{bounded-turn-lRpmZHFv.js → bounded-turn-C_Hneydj.js} +12 -12
- package/dist/{build-state-6RL6qohz.js → build-state-BCmg9-5p.js} +1 -1
- package/dist/{capabilities-BeqLPbtM.js → capabilities-8vx68WLH.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-BEKu4yDx.js → client-B57KWPQx.js} +27 -5
- package/dist/{command-dispatch-CisT9Jqq.js → command-dispatch-BpduNGVf.js} +3 -3
- package/dist/{command-formatters-DeTfrapr.js → command-formatters-lxlkNZgU.js} +4 -3
- package/dist/{command-handlers-BfIsJEuA.js → command-handlers-tiL9iWj7.js} +783 -140
- package/dist/{command-rpc-BMqRQOFX.js → command-rpc-CR5EOEZX.js} +26 -19
- package/dist/{compact-CGJZ2rlb.js → compact-B_H3AOd7.js} +14 -14
- package/dist/{config-JDfTI4VI.js → config-oIORaQ5T.js} +4 -4
- package/dist/{config-options-jnIFvwxD.js → config-options-CXMq1T-C.js} +5 -5
- package/dist/{config-runtime-BWf6JLWG.js → config-runtime-D0zGNIHu.js} +1 -1
- package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
- package/dist/{conversation-binding-CxOlHiix.js → conversation-binding-DsB4-O7U.js} +53 -42
- package/dist/{conversation-control-CUCrSIQI.js → conversation-control-CtUu1b3m.js} +8 -8
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{dynamic-tools-D-JBoaLt.js → dynamic-tools-CmN5RAip.js} +76 -15
- package/dist/{effective-mcp-catalog-J_5Ep5Um.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
- package/dist/{ephemeral-turn-DSwzP8YY.js → ephemeral-turn-D78_VmzO.js} +5 -5
- package/dist/event-projector-items-5VhsECCO.js +200 -0
- package/dist/{event-projector-usage-CIyrYYid.js → event-projector-usage-BfXmpOec.js} +1 -1
- package/dist/{harness-FR6eQgyO.js → harness-C7rRa7bm.js} +33 -16
- package/dist/harness.js +1 -1
- package/dist/index.js +39 -84
- package/dist/inference-context-Dr_mzvk4.js +94 -0
- package/dist/inference-proxy-HGXKUIre.js +311 -0
- package/dist/{isolated-completion-DHBefrzg.js → isolated-completion-DWVb5U2J.js} +6 -6
- package/dist/{managed-binary-DrjjRRUD.js → managed-binary-D22rNEcR.js} +10 -1
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +2 -0
- package/dist/{model-catalog-B_6M04Wo.js → model-catalog-Dq2n8f_p.js} +6 -6
- package/dist/{models-P9k2qAof.js → models-PCKOim-h.js} +3 -3
- package/dist/native-subagent-history-DjtPloaU.js +140 -0
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
- package/dist/{native-subagent-monitor-BbCUKRwC.js → native-subagent-monitor-fQ7eIXEf.js} +52 -424
- package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
- package/dist/{node-cli-sessions-rj0ysJwM.js → node-cli-sessions-DKaOmVUh.js} +1 -1
- package/dist/{node-exec-server.runtime-BY_ctYnT.js → node-exec-server.runtime-Cl2vapEi.js} +3 -3
- package/dist/{plan-BMJdMOEF.js → plan-7uG-Fp36.js} +288 -52
- package/dist/{plugin-activation-BQK-f5sV.js → plugin-activation-BYQculil.js} +24 -19
- package/dist/{plugin-app-cache-key-CdSQzWyX.js → plugin-app-cache-key-d0eKxy7b.js} +1 -1
- package/dist/{plugin-approval-roundtrip-DeW95wB5.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
- package/dist/{plugin-inventory-CoRCzWW4.js → plugin-inventory-oL4Na1ZG.js} +7 -4
- package/dist/{plugin-marketplace-discovery-3akBizzF.js → plugin-marketplace-discovery-P-Vndfqq.js} +18 -15
- package/dist/{plugin-metadata-cache-DgNfRAGA.js → plugin-metadata-cache-ClPJpRio.js} +13 -9
- package/dist/{protocol-CAAcVIKF.js → protocol-5bh1G-H7.js} +1 -1
- package/dist/provider-MQ8PVkuE.js +50 -0
- package/dist/{provider-capabilities-W4tfK5Y5.js → provider-capabilities-BvCUL69A.js} +2 -2
- package/dist/{rate-limits-Bqnx1N4z.js → rate-limits-CBMmWBr9.js} +1 -1
- package/dist/{request-CGvGOpeR.js → request-B7hEkBGq.js} +72 -58
- package/dist/rpc-error-ttN_QjEm.js +30 -0
- package/dist/{run-attempt-DwKds3DN.js → run-attempt-CvsAAGa0.js} +108 -37
- package/dist/{runtime-artifact-T-NwqeSH.js → runtime-artifact-BJ0rXBZ_.js} +1 -1
- package/dist/{sandbox-guard-BcT66fWy.js → sandbox-guard-BxgyoM8M.js} +2 -1
- package/dist/{session-binding-CKSepwIC.js → session-binding-CI8UuilT.js} +3 -3
- package/dist/{session-binding-record-CaZjYwNS.js → session-binding-record-Bcvslnhf.js} +1 -1
- package/dist/{session-catalog-adoption-BKLtSrwi.js → session-catalog-adoption-tcZi1IfX.js} +5 -5
- package/dist/{session-catalog-archive-D0i2pGj2.js → session-catalog-archive-CwKg8Xz2.js} +6 -6
- package/dist/{session-catalog-HaDcp7Sv.js → session-catalog-ct-AH01I.js} +31 -87
- package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
- package/dist/{session-catalog-node-adoption-BUuDYY8R.js → session-catalog-node-adoption-B1tgDW-m.js} +2 -2
- package/dist/{session-catalog-node-continue-CBtc4wkI.js → session-catalog-node-continue-Ci-DXyJP.js} +4 -4
- package/dist/{session-catalog-provenance-DkJHo735.js → session-catalog-provenance-D-dIfRAH.js} +2 -30
- package/dist/{session-cli-CbgaHh0f.js → session-cli-DNN_jhGc.js} +2 -2
- package/dist/{session-history-import-DFN7sWRU.js → session-history-import-DwyijFI6.js} +4 -4
- package/dist/session-history-worker-runtime.js +1 -1
- package/dist/{session-history.worker-CNEvGaU5.js → session-history.worker-BeK1YOyT.js} +187 -83
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-Jo86C60I.js → session-initialization-Ct0_Hzmg.js} +2 -2
- package/dist/{session-permission-policy-B22InTp_.js → session-permission-policy-BBmXA8Eg.js} +2 -2
- package/dist/{session-retirement-BSNG_mhf.js → session-retirement-B2YfbAAT.js} +5 -5
- package/dist/{settled-turn-finalizer-BuLUrZl2.js → settled-turn-finalizer-Dn91stmc.js} +5 -5
- package/dist/{shared-client-CVhez2Uo.js → shared-client-CscigXXL.js} +228 -30
- package/dist/{side-question-DLbr2vUU.js → side-question-BGMJQf4U.js} +18 -18
- package/dist/{source-Da-h6f7e.js → source-CElXU0Oy.js} +12 -12
- package/dist/{thread-archive-guard-D1bP04Tf.js → thread-archive-guard-DfpBr-Sz.js} +1 -1
- package/dist/{session-catalog-parsing-CdD3JhdM.js → thread-history-page-D0JIp48V.js} +83 -2
- package/dist/{thread-lifecycle-D1pzRwHB.js → thread-lifecycle-DXl1-I6b.js} +96 -44
- package/dist/{thread-ownership-D6oASVRu.js → thread-ownership-BsDRTsyp.js} +2 -2
- package/dist/{thread-policy-D8kI7yAO.js → thread-policy-BuEQfE0g.js} +3 -3
- package/dist/{thread-resume-T5cveyxA.js → thread-resume-DsDOZpFg.js} +5 -5
- package/dist/{session-catalog-home-id-D7-aLiNt.js → transcript-history-projection-v17wXgdK.js} +66 -18
- package/dist/{transcript-mirror-t5TOccct.js → transcript-mirror-C5CKgNy6.js} +1 -1
- package/dist/{upstream-session-fork-De-sLJ2r.js → upstream-session-fork-BZerMte_.js} +20 -20
- package/dist/{usage-CPPTmBvZ.js → usage-tCk-mg_x.js} +4 -4
- package/dist/{web-search-provider.runtime-CSVgQL0w.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
- package/openclaw.plugin.json +1 -0
- package/package.json +4 -4
|
@@ -1,385 +1,18 @@
|
|
|
1
|
-
import { o as isJsonObject } from "./protocol-
|
|
1
|
+
import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
|
|
2
|
+
import { E as readNullableString$1, a as isNonSuccessItemStatus, b as readHookOutputEntries, c as itemName, d as matchesCodexSnapshotTurn, 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 readItem } from "./event-projector-items-5VhsECCO.js";
|
|
2
3
|
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
|
|
3
4
|
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-Cz-tOOYj.js";
|
|
4
|
-
import {
|
|
5
|
-
import { A as shouldRecordNativeToolTranscript, B as readNonEmptyStringArray, C as isSideEffectingNativeToolItem, D as itemTitle, E as itemStatus, H as readNullableString$1, I as readHookOutputEntries, L as readItem, N as normalizeOptionalString$1, O as matchesCodexSnapshotTurn, S as isNonSuccessItemStatus, T as itemName, j as shouldSynthesizeToolProgressForItem, w as itemKind, x as isMutatingNativeToolItem, y as auditNativeToolTerminalStatus, z as readNonEmptyString } from "./attempt-client-cleanup-D6cR54TV.js";
|
|
5
|
+
import { J as retainCodexAppServerLiveThread, L as claimCodexAppServerLiveThread, q as releaseCodexAppServerLiveThread } from "./shared-client-CscigXXL.js";
|
|
6
6
|
import { t as resolveCodexLocalRuntimeAttribution } from "./local-runtime-attribution-B_2mnqhb.js";
|
|
7
|
-
import { n as
|
|
8
|
-
import {
|
|
7
|
+
import { C as formatToolSummary, E as truncateToolTranscriptText, S as formatToolOutput, T as toolOutputRawEchoSignature, a as isNativePostToolUseRelayItem, b as ToolOutputAccumulator, c as itemToolArgs, d as itemTranscriptResultText, f as shouldSuppressChannelProgressForItem, g as sanitizeCodexToolArguments, h as resolveCodexToolProgressDetailMode, i as isCommandBearingToolItem, l as itemToolError, m as isCodexCommandBearingToolCall, n as CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX, o as itemMeta, r as CODEX_NATIVE_SUBAGENT_TASK_KIND, s as itemOutputText, t as CODEX_NATIVE_SUBAGENT_RUNTIME, u as itemToolResult, w as normalizeToolTranscriptArguments, x as collectDynamicToolContentText, y as TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS } from "./native-subagent-task-ids-BzTdT0Uw.js";
|
|
8
|
+
import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-Bz3FT8W5.js";
|
|
9
|
+
import { asFiniteNumber, normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
10
|
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
10
11
|
import path from "node:path";
|
|
11
12
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
12
13
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
13
|
-
import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage,
|
|
14
|
-
import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
14
|
+
import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage, inferToolMetaFromArgs, runAgentHarnessAfterToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
15
15
|
import { createAgentHarnessTaskRuntime, deliverAgentHarnessTaskCompletion, isDurableAgentHarnessCompletionDelivery } from "openclaw/plugin-sdk/agent-harness-task-runtime";
|
|
16
|
-
//#region extensions/codex/src/app-server/event-projector-tool-output.ts
|
|
17
|
-
const TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS = 1e4;
|
|
18
|
-
const TOOL_OUTPUT_TRUNCATION_NOTICE_PREFIX = "...(OpenClaw truncated Codex native tool output";
|
|
19
|
-
var ToolOutputAccumulator = class {
|
|
20
|
-
constructor() {
|
|
21
|
-
this.prefixByItem = /* @__PURE__ */ new Map();
|
|
22
|
-
this.originalLengthByItem = /* @__PURE__ */ new Map();
|
|
23
|
-
this.trimStateByItem = /* @__PURE__ */ new Map();
|
|
24
|
-
this.truncatedItemIds = /* @__PURE__ */ new Set();
|
|
25
|
-
this.textByItem = /* @__PURE__ */ new Map();
|
|
26
|
-
}
|
|
27
|
-
append(itemId, delta) {
|
|
28
|
-
const originalLength = (this.originalLengthByItem.get(itemId) ?? this.textByItem.get(itemId)?.length ?? 0) + delta.length;
|
|
29
|
-
this.originalLengthByItem.set(itemId, originalLength);
|
|
30
|
-
const normalizedLength = updateToolOutputTrimState(this.trimStateByItem, itemId, delta);
|
|
31
|
-
const next = appendBoundedToolTranscriptText(this.prefixByItem.get(itemId) ?? this.textByItem.get(itemId) ?? "", this.truncatedItemIds.has(itemId) ? "" : delta, originalLength);
|
|
32
|
-
this.prefixByItem.set(itemId, next.rawPrefix);
|
|
33
|
-
this.textByItem.set(itemId, next.text);
|
|
34
|
-
if (originalLength > 1e4) this.truncatedItemIds.add(itemId);
|
|
35
|
-
return {
|
|
36
|
-
text: next.text,
|
|
37
|
-
originalLength,
|
|
38
|
-
normalizedLength,
|
|
39
|
-
rawPrefix: next.rawPrefix
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
function updateToolOutputTrimState(trimStateByItem, itemId, delta) {
|
|
44
|
-
const state = trimStateByItem.get(itemId) ?? {
|
|
45
|
-
totalLength: 0,
|
|
46
|
-
leadingWhitespaceLength: 0,
|
|
47
|
-
trailingWhitespaceLength: 0,
|
|
48
|
-
sawNonWhitespace: false
|
|
49
|
-
};
|
|
50
|
-
state.totalLength += delta.length;
|
|
51
|
-
const firstNonWhitespace = delta.search(/\S/u);
|
|
52
|
-
if (firstNonWhitespace === -1) {
|
|
53
|
-
if (!state.sawNonWhitespace) state.leadingWhitespaceLength += delta.length;
|
|
54
|
-
state.trailingWhitespaceLength += delta.length;
|
|
55
|
-
trimStateByItem.set(itemId, state);
|
|
56
|
-
return state.sawNonWhitespace ? state.totalLength - state.leadingWhitespaceLength - state.trailingWhitespaceLength : 0;
|
|
57
|
-
}
|
|
58
|
-
if (!state.sawNonWhitespace) {
|
|
59
|
-
state.leadingWhitespaceLength += firstNonWhitespace;
|
|
60
|
-
state.sawNonWhitespace = true;
|
|
61
|
-
}
|
|
62
|
-
state.trailingWhitespaceLength = delta.match(/\s*$/u)?.[0].length ?? 0;
|
|
63
|
-
trimStateByItem.set(itemId, state);
|
|
64
|
-
return state.totalLength - state.leadingWhitespaceLength - state.trailingWhitespaceLength;
|
|
65
|
-
}
|
|
66
|
-
function toolOutputRawEchoSignature(text) {
|
|
67
|
-
const trimmed = text.trim();
|
|
68
|
-
if (!trimmed) return;
|
|
69
|
-
return {
|
|
70
|
-
rawLength: trimmed.length,
|
|
71
|
-
rawPrefix: trimmed.slice(0, TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS)
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function normalizeToolTranscriptArguments(value) {
|
|
75
|
-
return asNonArrayRecord(value);
|
|
76
|
-
}
|
|
77
|
-
function collectDynamicToolContentText(contentItems) {
|
|
78
|
-
if (!Array.isArray(contentItems)) return "";
|
|
79
|
-
return contentItems.flatMap((entry) => {
|
|
80
|
-
if (!isJsonObject(entry)) return [];
|
|
81
|
-
const text = readStringField(entry, "text");
|
|
82
|
-
return text ? [text] : [];
|
|
83
|
-
}).join("\n");
|
|
84
|
-
}
|
|
85
|
-
function appendBoundedToolTranscriptText(currentPrefix, delta, originalLength) {
|
|
86
|
-
if (originalLength <= 1e4) {
|
|
87
|
-
const rawPrefix = currentPrefix + delta;
|
|
88
|
-
return {
|
|
89
|
-
text: rawPrefix,
|
|
90
|
-
rawPrefix
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
const notice = toolTranscriptTruncationNotice(originalLength);
|
|
94
|
-
if (notice.length >= 1e4) return {
|
|
95
|
-
text: notice.slice(0, TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS),
|
|
96
|
-
rawPrefix: ""
|
|
97
|
-
};
|
|
98
|
-
const textBudget = TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS - notice.length;
|
|
99
|
-
const remaining = Math.max(0, textBudget - currentPrefix.length);
|
|
100
|
-
const prefix = remaining > 0 ? `${currentPrefix}${truncateUtf16Safe(delta, remaining)}` : currentPrefix;
|
|
101
|
-
const rawPrefix = truncateUtf16Safe(prefix, textBudget);
|
|
102
|
-
return {
|
|
103
|
-
text: `${rawPrefix}${notice}`,
|
|
104
|
-
rawPrefix
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function toolTranscriptTruncationNotice(originalLength) {
|
|
108
|
-
return `\n${`${TOOL_OUTPUT_TRUNCATION_NOTICE_PREFIX}: original ${originalLength} chars, showing ${TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS}; rerun with narrower args.)`}`;
|
|
109
|
-
}
|
|
110
|
-
function truncateToolTranscriptText(text, originalLength = text.length) {
|
|
111
|
-
if (originalLength <= 1e4 && text.length <= 1e4) return text;
|
|
112
|
-
const notice = toolTranscriptTruncationNotice(originalLength);
|
|
113
|
-
if (notice.length >= 1e4) return notice.slice(1, 10001);
|
|
114
|
-
const textBudget = TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS - notice.length;
|
|
115
|
-
return `${truncateUtf16Safe(text, textBudget)}${notice}`;
|
|
116
|
-
}
|
|
117
|
-
function formatToolSummary(toolName, meta) {
|
|
118
|
-
const trimmedMeta = meta?.trim();
|
|
119
|
-
return formatToolAggregate(toolName, trimmedMeta ? [trimmedMeta] : void 0, { markdown: true });
|
|
120
|
-
}
|
|
121
|
-
function formatToolOutput(toolName, meta, output) {
|
|
122
|
-
const formattedOutput = formatToolProgressOutput(output);
|
|
123
|
-
if (!formattedOutput) return formatToolSummary(toolName, meta);
|
|
124
|
-
const fence = markdownFenceForText(formattedOutput);
|
|
125
|
-
return `${formatToolSummary(toolName, meta)}\n${fence}txt\n${formattedOutput}\n${fence}`;
|
|
126
|
-
}
|
|
127
|
-
function markdownFenceForText(text) {
|
|
128
|
-
return "`".repeat(Math.max(3, longestBacktickRun(text) + 1));
|
|
129
|
-
}
|
|
130
|
-
function longestBacktickRun(value) {
|
|
131
|
-
let longest = 0;
|
|
132
|
-
let current = 0;
|
|
133
|
-
for (const char of value) {
|
|
134
|
-
if (char === "`") {
|
|
135
|
-
current += 1;
|
|
136
|
-
longest = Math.max(longest, current);
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
current = 0;
|
|
140
|
-
}
|
|
141
|
-
return longest;
|
|
142
|
-
}
|
|
143
|
-
//#endregion
|
|
144
|
-
//#region extensions/codex/src/app-server/tool-progress-normalization.ts
|
|
145
|
-
/**
|
|
146
|
-
* Normalizes and sanitizes Codex dynamic-tool progress payloads before they are
|
|
147
|
-
* emitted into OpenClaw events or logs.
|
|
148
|
-
*/
|
|
149
|
-
/** Maps OpenClaw tool-progress config to the mode used by Codex progress metadata. */
|
|
150
|
-
function resolveCodexToolProgressDetailMode(value) {
|
|
151
|
-
return value === "raw" ? "raw" : "explain";
|
|
152
|
-
}
|
|
153
|
-
function isCodexCommandBearingToolCall(name, args) {
|
|
154
|
-
const normalizedName = name?.trim().toLowerCase();
|
|
155
|
-
return normalizedName === "exec" || normalizedName === "bash" || normalizedName === "shell" || typeof args?.command === "string" && args.command.trim().length > 0;
|
|
156
|
-
}
|
|
157
|
-
/** Recursively redacts sensitive strings and handles circular values in event payloads. */
|
|
158
|
-
function sanitizeCodexAgentEventValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
159
|
-
if (typeof value === "string") return redactToolPayloadText(value);
|
|
160
|
-
if (Array.isArray(value)) {
|
|
161
|
-
if (seen.has(value)) return "[Circular]";
|
|
162
|
-
seen.add(value);
|
|
163
|
-
return value.map((entry) => sanitizeCodexAgentEventValue(entry, seen));
|
|
164
|
-
}
|
|
165
|
-
if (value && typeof value === "object") {
|
|
166
|
-
if (seen.has(value)) return "[Circular]";
|
|
167
|
-
seen.add(value);
|
|
168
|
-
const out = {};
|
|
169
|
-
for (const [key, child] of Object.entries(value)) out[key] = typeof child === "string" ? redactSensitiveFieldValue(key, child) : sanitizeCodexAgentEventValue(child, seen);
|
|
170
|
-
return out;
|
|
171
|
-
}
|
|
172
|
-
return value;
|
|
173
|
-
}
|
|
174
|
-
/** Sanitizes a record-shaped Codex agent event payload. */
|
|
175
|
-
function sanitizeCodexAgentEventRecord(value) {
|
|
176
|
-
return sanitizeCodexAgentEventValue(value);
|
|
177
|
-
}
|
|
178
|
-
/** Sanitizes dynamic-tool arguments before diagnostic/event emission. */
|
|
179
|
-
function sanitizeCodexToolArguments(value) {
|
|
180
|
-
if (!isJsonObject(value)) return;
|
|
181
|
-
return sanitizeCodexAgentEventRecord(value);
|
|
182
|
-
}
|
|
183
|
-
/** Sanitizes a Codex dynamic-tool response before diagnostic/event emission. */
|
|
184
|
-
function sanitizeCodexToolResponse(response) {
|
|
185
|
-
return sanitizeCodexAgentEventRecord({ ...response });
|
|
186
|
-
}
|
|
187
|
-
/** Infers compact human-readable tool metadata from Codex dynamic-tool arguments. */
|
|
188
|
-
function inferCodexDynamicToolMeta(call, detailMode) {
|
|
189
|
-
return inferToolMetaFromArgs(call.tool, call.arguments, { detailMode });
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
//#region extensions/codex/src/app-server/event-projector-tool-items.ts
|
|
193
|
-
function isNativePostToolUseRelayItem(item) {
|
|
194
|
-
switch (item.type) {
|
|
195
|
-
case "commandExecution":
|
|
196
|
-
case "fileChange":
|
|
197
|
-
case "mcpToolCall": return true;
|
|
198
|
-
default: return false;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
function shouldSuppressChannelProgressForItem(item) {
|
|
202
|
-
if (shouldSynthesizeToolProgressForItem(item)) return true;
|
|
203
|
-
return item.type === "dynamicToolCall";
|
|
204
|
-
}
|
|
205
|
-
function itemToolArgs(item) {
|
|
206
|
-
if (item.type === "commandExecution") return sanitizeCodexAgentEventRecord({
|
|
207
|
-
command: item.command,
|
|
208
|
-
...typeof item.cwd === "string" ? { cwd: item.cwd } : {}
|
|
209
|
-
});
|
|
210
|
-
if (item.type === "fileChange") return sanitizeCodexAgentEventRecord({ changes: itemFileChangesForTranscript(item) });
|
|
211
|
-
if (item.type === "webSearch") return webSearchToolArgs(item);
|
|
212
|
-
if (item.type === "dynamicToolCall" || item.type === "mcpToolCall") return sanitizeCodexToolArguments(item.arguments);
|
|
213
|
-
}
|
|
214
|
-
function isCommandBearingToolItem(item, args) {
|
|
215
|
-
if (item.type === "commandExecution") return true;
|
|
216
|
-
return typeof args?.command === "string" && args.command.trim().length > 0;
|
|
217
|
-
}
|
|
218
|
-
function webSearchToolArgs(item) {
|
|
219
|
-
const action = isJsonObject(item.action) ? item.action : void 0;
|
|
220
|
-
const actionType = action ? readNonEmptyString(action, "type") : void 0;
|
|
221
|
-
const queries = action && actionType === "search" ? readNonEmptyStringArray(action, "queries") : [];
|
|
222
|
-
const query = normalizeOptionalString$1(item.query) ?? (action && actionType === "search" ? readNonEmptyString(action, "query") : void 0) ?? queries[0];
|
|
223
|
-
const url = action ? readNonEmptyString(action, "url") : void 0;
|
|
224
|
-
const pattern = action ? readNonEmptyString(action, "pattern") : void 0;
|
|
225
|
-
const args = {};
|
|
226
|
-
if (query) args.query = query;
|
|
227
|
-
if (queries.length > 0) args.queries = queries;
|
|
228
|
-
if (actionType && actionType !== "search") args.action = actionType;
|
|
229
|
-
if (url) args.url = url;
|
|
230
|
-
if (pattern) args.pattern = pattern;
|
|
231
|
-
if (!query && !url && !pattern) args.queryUnavailable = true;
|
|
232
|
-
return sanitizeCodexAgentEventRecord(args);
|
|
233
|
-
}
|
|
234
|
-
function itemToolResult(item) {
|
|
235
|
-
if (item.type === "commandExecution") return { result: sanitizeCodexAgentEventRecord({
|
|
236
|
-
status: item.status,
|
|
237
|
-
exitCode: item.exitCode,
|
|
238
|
-
durationMs: item.durationMs
|
|
239
|
-
}) };
|
|
240
|
-
if (item.type === "fileChange") return { result: sanitizeCodexAgentEventRecord({
|
|
241
|
-
status: item.status,
|
|
242
|
-
changes: itemFileChanges(item)
|
|
243
|
-
}) };
|
|
244
|
-
if (item.type === "mcpToolCall") return { result: sanitizeCodexAgentEventRecord({
|
|
245
|
-
status: item.status,
|
|
246
|
-
durationMs: item.durationMs,
|
|
247
|
-
...item.error ? { error: item.error } : {},
|
|
248
|
-
...item.result ? { result: item.result } : {}
|
|
249
|
-
}) };
|
|
250
|
-
if (item.type === "webSearch") return { result: webSearchToolResult(item) };
|
|
251
|
-
return {};
|
|
252
|
-
}
|
|
253
|
-
function webSearchToolResult(item) {
|
|
254
|
-
return sanitizeCodexAgentEventRecord({
|
|
255
|
-
status: itemStatus(item),
|
|
256
|
-
...typeof item.durationMs === "number" ? { durationMs: item.durationMs } : {},
|
|
257
|
-
...webSearchToolArgs(item)
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
function itemFileChangeRecords(item) {
|
|
261
|
-
const changes = item.changes;
|
|
262
|
-
return Array.isArray(changes) ? changes.filter(isJsonObject) : [];
|
|
263
|
-
}
|
|
264
|
-
function itemFileChanges(item) {
|
|
265
|
-
return itemFileChangeRecords(item).flatMap((change) => {
|
|
266
|
-
const path = normalizeOptionalString$1(change.path);
|
|
267
|
-
if (!path || change.kind === void 0) return [];
|
|
268
|
-
return [{
|
|
269
|
-
path,
|
|
270
|
-
kind: change.kind
|
|
271
|
-
}];
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
function fileChangeKindType(kind) {
|
|
275
|
-
if (typeof kind === "string") return kind;
|
|
276
|
-
return isJsonObject(kind) ? normalizeOptionalString$1(kind.type) : void 0;
|
|
277
|
-
}
|
|
278
|
-
function countFileContentLines(content) {
|
|
279
|
-
if (!content) return 0;
|
|
280
|
-
const lines = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
281
|
-
if (lines.length > 1 && lines.at(-1) === "") lines.pop();
|
|
282
|
-
return lines.length;
|
|
283
|
-
}
|
|
284
|
-
function fileChangeDiffStat(diff, kind) {
|
|
285
|
-
const kindType = fileChangeKindType(kind);
|
|
286
|
-
if (kindType === "add") return {
|
|
287
|
-
added: countFileContentLines(diff),
|
|
288
|
-
removed: 0
|
|
289
|
-
};
|
|
290
|
-
if (kindType === "delete") return {
|
|
291
|
-
added: 0,
|
|
292
|
-
removed: countFileContentLines(diff)
|
|
293
|
-
};
|
|
294
|
-
let added = 0;
|
|
295
|
-
let removed = 0;
|
|
296
|
-
let inHunk = false;
|
|
297
|
-
for (const line of diff.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n")) {
|
|
298
|
-
if (line.startsWith("@@")) {
|
|
299
|
-
inHunk = true;
|
|
300
|
-
continue;
|
|
301
|
-
}
|
|
302
|
-
if (!inHunk) continue;
|
|
303
|
-
if (line.startsWith("+")) added += 1;
|
|
304
|
-
else if (line.startsWith("-")) removed += 1;
|
|
305
|
-
}
|
|
306
|
-
return {
|
|
307
|
-
added,
|
|
308
|
-
removed
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
function truncateFileChangeDiffAtLineBoundary(diff, maxChars) {
|
|
312
|
-
if (diff.length <= maxChars) return { diff };
|
|
313
|
-
if (maxChars <= 0) return { diffTruncated: true };
|
|
314
|
-
const boundary = diff.lastIndexOf("\n", maxChars - 1);
|
|
315
|
-
return boundary >= 0 ? {
|
|
316
|
-
diff: diff.slice(0, boundary + 1),
|
|
317
|
-
diffTruncated: true
|
|
318
|
-
} : { diffTruncated: true };
|
|
319
|
-
}
|
|
320
|
-
function itemFileChangesForTranscript(item) {
|
|
321
|
-
let remainingDiffChars = 1e4;
|
|
322
|
-
return itemFileChangeRecords(item).flatMap((change) => {
|
|
323
|
-
const path = normalizeOptionalString$1(change.path);
|
|
324
|
-
if (!path || change.kind === void 0) return [];
|
|
325
|
-
const result = {
|
|
326
|
-
path,
|
|
327
|
-
kind: change.kind
|
|
328
|
-
};
|
|
329
|
-
if (typeof change.diff !== "string") return [result];
|
|
330
|
-
result.stat = fileChangeDiffStat(change.diff, change.kind);
|
|
331
|
-
const bounded = truncateFileChangeDiffAtLineBoundary(change.diff, remainingDiffChars);
|
|
332
|
-
if (bounded.diff !== void 0) {
|
|
333
|
-
result.diff = bounded.diff;
|
|
334
|
-
remainingDiffChars -= bounded.diff.length;
|
|
335
|
-
}
|
|
336
|
-
if (bounded.diffTruncated) result.diffTruncated = true;
|
|
337
|
-
return [result];
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
function itemToolError(item, status, outputTextByItem) {
|
|
341
|
-
if (status === "blocked") return "codex native tool blocked";
|
|
342
|
-
if (status !== "failed") return;
|
|
343
|
-
return itemOutputText(item, outputTextByItem) ?? "codex native tool failed";
|
|
344
|
-
}
|
|
345
|
-
function itemMeta(item, detailMode = "explain") {
|
|
346
|
-
if (item.type === "commandExecution" && typeof item.command === "string") return inferToolMetaFromArgs("exec", {
|
|
347
|
-
command: item.command,
|
|
348
|
-
cwd: typeof item.cwd === "string" ? item.cwd : void 0
|
|
349
|
-
}, { detailMode });
|
|
350
|
-
if (item.type === "webSearch") return inferToolMetaFromArgs("web_search", webSearchToolArgs(item), { detailMode });
|
|
351
|
-
const toolName = itemName(item);
|
|
352
|
-
if ((item.type === "dynamicToolCall" || item.type === "mcpToolCall") && toolName) return inferToolMetaFromArgs(toolName, item.arguments, { detailMode });
|
|
353
|
-
}
|
|
354
|
-
function itemOutputText(item, outputTextByItem) {
|
|
355
|
-
if (item.type === "commandExecution") {
|
|
356
|
-
const output = item.aggregatedOutput?.trim() || outputTextByItem?.get(item.id)?.trim();
|
|
357
|
-
return output ? truncateToolTranscriptText(output) : void 0;
|
|
358
|
-
}
|
|
359
|
-
if (item.type === "dynamicToolCall") {
|
|
360
|
-
const output = collectDynamicToolContentText(item.contentItems).trim();
|
|
361
|
-
return output ? truncateToolTranscriptText(output) : void 0;
|
|
362
|
-
}
|
|
363
|
-
if (item.type === "mcpToolCall") {
|
|
364
|
-
const output = item.error ? stringifyJsonValue(item.error) : item.result ? stringifyJsonValue(item.result) : void 0;
|
|
365
|
-
return output ? truncateToolTranscriptText(output) : void 0;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
function itemTranscriptResultText(item, outputTextByItem) {
|
|
369
|
-
const output = itemOutputText(item, outputTextByItem);
|
|
370
|
-
if (output) return output;
|
|
371
|
-
const result = itemToolResult(item).result;
|
|
372
|
-
const resultText = result ? stringifyJsonValue(result) : void 0;
|
|
373
|
-
return resultText ? truncateToolTranscriptText(resultText) : itemStatus(item);
|
|
374
|
-
}
|
|
375
|
-
function stringifyJsonValue(value) {
|
|
376
|
-
try {
|
|
377
|
-
return JSON.stringify(value, null, 2);
|
|
378
|
-
} catch {
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
//#endregion
|
|
383
16
|
//#region extensions/codex/src/app-server/event-projector-tool-progress.ts
|
|
384
17
|
const TRANSCRIPT_PROGRESS_SUPPRESSED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
385
18
|
"message",
|
|
@@ -1455,7 +1088,8 @@ var CodexEventProjection = class {
|
|
|
1455
1088
|
const kind = subagent ? "tool" : itemKind(item);
|
|
1456
1089
|
if (!kind) return;
|
|
1457
1090
|
const name = subagent ? "subagents" : itemName(item);
|
|
1458
|
-
const
|
|
1091
|
+
const args = itemToolArgs(item);
|
|
1092
|
+
const commandBearing = isCommandBearingToolItem(item, args);
|
|
1459
1093
|
const subagentStatus = readStringField(item, activity ? "kind" : "status");
|
|
1460
1094
|
const interaction = activity && subagentStatus === "interacted";
|
|
1461
1095
|
const status = subagent && subagentStatus === "interrupted" ? "failed" : activity ? subagentStatus === "completed" || interaction ? "completed" : "running" : params.phase === "start" ? "running" : itemStatus(item);
|
|
@@ -1644,7 +1278,7 @@ function stringifyResult(value, status) {
|
|
|
1644
1278
|
}
|
|
1645
1279
|
function completedWithoutFinalAssistantMessage() {
|
|
1646
1280
|
return {
|
|
1647
|
-
text: "
|
|
1281
|
+
text: "Subagent completed without a final assistant message.",
|
|
1648
1282
|
kind: "no_final_assistant_message"
|
|
1649
1283
|
};
|
|
1650
1284
|
}
|
|
@@ -1675,18 +1309,6 @@ function normalizeStatusKey(value) {
|
|
|
1675
1309
|
return value.replace(/[^a-z0-9]/giu, "").toLowerCase();
|
|
1676
1310
|
}
|
|
1677
1311
|
//#endregion
|
|
1678
|
-
//#region extensions/codex/src/app-server/native-subagent-task-ids.ts
|
|
1679
|
-
/**
|
|
1680
|
-
* Shared identifiers for representing Codex native subagents as OpenClaw task
|
|
1681
|
-
* runtime rows.
|
|
1682
|
-
*/
|
|
1683
|
-
/** Task runtime namespace for Codex native subagent task rows. */
|
|
1684
|
-
const CODEX_NATIVE_SUBAGENT_RUNTIME = "subagent";
|
|
1685
|
-
/** Task kind used to distinguish native Codex subagents from other subagent runtimes. */
|
|
1686
|
-
const CODEX_NATIVE_SUBAGENT_TASK_KIND = "codex-native";
|
|
1687
|
-
/** Run id prefix for task rows keyed by Codex child thread ids. */
|
|
1688
|
-
const CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX = "codex-thread:";
|
|
1689
|
-
//#endregion
|
|
1690
1312
|
//#region extensions/codex/src/app-server/native-subagent-task-mirror.ts
|
|
1691
1313
|
/** Projects Codex thread and collab-agent notifications into task lifecycle updates. */
|
|
1692
1314
|
var CodexNativeSubagentTaskMirror = class {
|
|
@@ -1734,15 +1356,15 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1734
1356
|
const spawn = readSubagentThreadSpawnSource(thread.source, this.params.parentThreadId);
|
|
1735
1357
|
if (!spawn) return;
|
|
1736
1358
|
const threadId = thread.id.trim();
|
|
1737
|
-
const label = normalizeOptionalString(spawn.agent_nickname) ?? normalizeOptionalString(thread.agentNickname) ?? normalizeOptionalString(spawn.agent_role) ?? normalizeOptionalString(thread.agentRole) ?? "
|
|
1738
|
-
const task = normalizeOptionalString(thread.preview) ?? `
|
|
1359
|
+
const label = normalizeOptionalString(spawn.agent_nickname) ?? normalizeOptionalString(thread.agentNickname) ?? normalizeOptionalString(spawn.agent_role) ?? normalizeOptionalString(thread.agentRole) ?? "Subagent";
|
|
1360
|
+
const task = normalizeOptionalString(thread.preview) ?? `Subagent${label === "Subagent" ? "" : ` ${label}`}`;
|
|
1739
1361
|
const createdAt = secondsToMillis(thread.createdAt) ?? this.now();
|
|
1740
1362
|
if (!this.createRunningTask({
|
|
1741
1363
|
threadId,
|
|
1742
1364
|
label,
|
|
1743
1365
|
task,
|
|
1744
1366
|
startedAt: createdAt,
|
|
1745
|
-
progressSummary: "
|
|
1367
|
+
progressSummary: "Subagent started."
|
|
1746
1368
|
})) return;
|
|
1747
1369
|
this.applyStatus(threadId, thread.status);
|
|
1748
1370
|
}
|
|
@@ -1763,7 +1385,7 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1763
1385
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1764
1386
|
runId,
|
|
1765
1387
|
lastEventAt: eventAt,
|
|
1766
|
-
progressSummary: "
|
|
1388
|
+
progressSummary: "Subagent is active."
|
|
1767
1389
|
});
|
|
1768
1390
|
return;
|
|
1769
1391
|
}
|
|
@@ -1771,7 +1393,7 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1771
1393
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1772
1394
|
runId,
|
|
1773
1395
|
lastEventAt: eventAt,
|
|
1774
|
-
progressSummary: "
|
|
1396
|
+
progressSummary: "Subagent is idle."
|
|
1775
1397
|
});
|
|
1776
1398
|
return;
|
|
1777
1399
|
}
|
|
@@ -1781,7 +1403,7 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1781
1403
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1782
1404
|
runId,
|
|
1783
1405
|
lastEventAt: eventAt,
|
|
1784
|
-
progressSummary: "
|
|
1406
|
+
progressSummary: "Subagent hit a system error; awaiting recovery."
|
|
1785
1407
|
});
|
|
1786
1408
|
return;
|
|
1787
1409
|
}
|
|
@@ -1791,16 +1413,16 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1791
1413
|
status: "failed",
|
|
1792
1414
|
endedAt: eventAt,
|
|
1793
1415
|
lastEventAt: eventAt,
|
|
1794
|
-
error: "
|
|
1795
|
-
progressSummary: "
|
|
1796
|
-
terminalSummary: "
|
|
1416
|
+
error: "Subagent encountered a system error.",
|
|
1417
|
+
progressSummary: "Subagent hit a system error.",
|
|
1418
|
+
terminalSummary: "Subagent failed."
|
|
1797
1419
|
});
|
|
1798
1420
|
return;
|
|
1799
1421
|
}
|
|
1800
1422
|
if (statusType === "notLoaded") this.runtime.recordTaskRunProgressByRunId({
|
|
1801
1423
|
runId,
|
|
1802
1424
|
lastEventAt: eventAt,
|
|
1803
|
-
progressSummary: "
|
|
1425
|
+
progressSummary: "Subagent is not loaded."
|
|
1804
1426
|
});
|
|
1805
1427
|
}
|
|
1806
1428
|
handleCollabAgentItem(params) {
|
|
@@ -1842,17 +1464,17 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1842
1464
|
return;
|
|
1843
1465
|
}
|
|
1844
1466
|
if (this.mirrorStateByThreadId.get(threadId) !== "mirrored") return;
|
|
1845
|
-
const message = kind === "interacted" ? "
|
|
1467
|
+
const message = kind === "interacted" ? "Subagent received more input." : "Subagent was interrupted.";
|
|
1846
1468
|
this.applyCollabAgentStatus(threadId, kind === "interacted" ? "running" : "interrupted", message);
|
|
1847
1469
|
}
|
|
1848
1470
|
createTaskFromSubagentActivity(threadId, agentPath) {
|
|
1849
1471
|
const eventAt = this.now();
|
|
1850
1472
|
this.createRunningTask({
|
|
1851
1473
|
threadId,
|
|
1852
|
-
label: "
|
|
1853
|
-
task: agentPath ? `
|
|
1474
|
+
label: "Subagent",
|
|
1475
|
+
task: agentPath ? `Subagent ${agentPath}` : "Subagent",
|
|
1854
1476
|
startedAt: eventAt,
|
|
1855
|
-
progressSummary: "
|
|
1477
|
+
progressSummary: "Subagent started."
|
|
1856
1478
|
});
|
|
1857
1479
|
}
|
|
1858
1480
|
createTaskFromCollabSpawnItem(threadId, item) {
|
|
@@ -1860,10 +1482,10 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1860
1482
|
const createdAt = this.now();
|
|
1861
1483
|
this.createRunningTask({
|
|
1862
1484
|
threadId,
|
|
1863
|
-
label: "
|
|
1864
|
-
task: prompt ?? "
|
|
1485
|
+
label: "Subagent",
|
|
1486
|
+
task: prompt ?? "Subagent",
|
|
1865
1487
|
startedAt: createdAt,
|
|
1866
|
-
progressSummary: "
|
|
1488
|
+
progressSummary: "Subagent spawned."
|
|
1867
1489
|
});
|
|
1868
1490
|
}
|
|
1869
1491
|
createRunningTask(params) {
|
|
@@ -1871,6 +1493,8 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1871
1493
|
if (!threadId || this.mirrorStateByThreadId.get(threadId) === "mirrored") return false;
|
|
1872
1494
|
this.mirrorStateByThreadId.set(threadId, "mirrored");
|
|
1873
1495
|
const runId = codexNativeSubagentRunId(threadId);
|
|
1496
|
+
const historyOwner = this.params.historyOwner;
|
|
1497
|
+
const stampHistoryOwner = historyOwner && !this.runtime.listTaskRecords().some((task) => task.runId === runId);
|
|
1874
1498
|
if (!this.runtime.tryCreateRunningTaskRun({
|
|
1875
1499
|
sourceId: runId,
|
|
1876
1500
|
agentId: this.params.agentId,
|
|
@@ -1882,7 +1506,8 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1882
1506
|
preferMetadata: true,
|
|
1883
1507
|
startedAt: params.startedAt,
|
|
1884
1508
|
lastEventAt: this.now(),
|
|
1885
|
-
progressSummary: params.progressSummary
|
|
1509
|
+
progressSummary: params.progressSummary,
|
|
1510
|
+
...stampHistoryOwner ? { detail: { nativeHistory: { ...historyOwner } } } : {}
|
|
1886
1511
|
})) {
|
|
1887
1512
|
this.mirrorStateByThreadId.set(threadId, "failed");
|
|
1888
1513
|
return false;
|
|
@@ -1903,13 +1528,13 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1903
1528
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1904
1529
|
runId,
|
|
1905
1530
|
lastEventAt: eventAt,
|
|
1906
|
-
progressSummary: normalizeOptionalString(message) ?? (normalizedStatus === "pendingInit" ? "
|
|
1531
|
+
progressSummary: normalizeOptionalString(message) ?? (normalizedStatus === "pendingInit" ? "Subagent is initializing." : normalizedStatus === "interrupted" ? "Subagent was interrupted." : "Subagent is running.")
|
|
1907
1532
|
});
|
|
1908
1533
|
return;
|
|
1909
1534
|
}
|
|
1910
1535
|
if (normalizedStatus === "completed") {
|
|
1911
1536
|
this.terminalRunIds.add(runId);
|
|
1912
|
-
const summary = normalizeOptionalString(message) ?? "
|
|
1537
|
+
const summary = normalizeOptionalString(message) ?? "Subagent completed.";
|
|
1913
1538
|
if (this.expectedAuthoritativeRunIds.has(runId)) this.runtime.recordTaskRunProgressByRunId({
|
|
1914
1539
|
runId,
|
|
1915
1540
|
lastEventAt: eventAt,
|
|
@@ -1932,8 +1557,8 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1932
1557
|
status: "succeeded",
|
|
1933
1558
|
endedAt: eventAt,
|
|
1934
1559
|
lastEventAt: eventAt,
|
|
1935
|
-
progressSummary: normalizeOptionalString(message) ?? "
|
|
1936
|
-
terminalSummary: normalizeOptionalString(message) ?? "
|
|
1560
|
+
progressSummary: normalizeOptionalString(message) ?? "Subagent blocked.",
|
|
1561
|
+
terminalSummary: normalizeOptionalString(message) ?? "Subagent blocked.",
|
|
1937
1562
|
terminalOutcome: "blocked"
|
|
1938
1563
|
});
|
|
1939
1564
|
return;
|
|
@@ -1944,9 +1569,9 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1944
1569
|
status: normalizedStatus === "shutdown" ? "cancelled" : "failed",
|
|
1945
1570
|
endedAt: eventAt,
|
|
1946
1571
|
lastEventAt: eventAt,
|
|
1947
|
-
error: normalizeOptionalString(message) ?? `
|
|
1948
|
-
progressSummary: normalizeOptionalString(message) ?? `
|
|
1949
|
-
terminalSummary: normalizeOptionalString(message) ?? "
|
|
1572
|
+
error: normalizeOptionalString(message) ?? `Subagent status: ${normalizedStatus}`,
|
|
1573
|
+
progressSummary: normalizeOptionalString(message) ?? `Subagent ${normalizedStatus}.`,
|
|
1574
|
+
terminalSummary: normalizeOptionalString(message) ?? "Subagent did not complete."
|
|
1950
1575
|
});
|
|
1951
1576
|
}
|
|
1952
1577
|
};
|
|
@@ -2129,6 +1754,7 @@ function registerMonitor(params) {
|
|
|
2129
1754
|
parentThreadId: params.parentThreadId,
|
|
2130
1755
|
requesterSessionKey: params.requesterSessionKey,
|
|
2131
1756
|
taskRuntimeScope: params.taskRuntimeScope,
|
|
1757
|
+
historyOwner: params.historyOwner,
|
|
2132
1758
|
agentId: params.agentId,
|
|
2133
1759
|
claimDirectChild: params.claimDirectChild,
|
|
2134
1760
|
rejectPendingDirectChild: params.rejectPendingDirectChild,
|
|
@@ -2207,6 +1833,7 @@ var Monitor = class {
|
|
|
2207
1833
|
}
|
|
2208
1834
|
state.requesterSessionKey ??= params.requesterSessionKey;
|
|
2209
1835
|
state.taskRuntimeScope ??= params.taskRuntimeScope;
|
|
1836
|
+
state.historyOwner ??= params.historyOwner;
|
|
2210
1837
|
state.agentId ??= params.agentId;
|
|
2211
1838
|
const owner = Symbol("codex-native-subagent-owner");
|
|
2212
1839
|
state.owners.set(owner, {
|
|
@@ -2261,7 +1888,7 @@ var Monitor = class {
|
|
|
2261
1888
|
this.retiredParentStates.add(state);
|
|
2262
1889
|
state.owners.clear();
|
|
2263
1890
|
this.clearPendingDirectSpawnEvidenceForParent(parentThreadId);
|
|
2264
|
-
for (const childState of Array.from(this.childStates.values())) if (childState.parentThreadId === parentThreadId) this.retireChild(state, childState, "
|
|
1891
|
+
for (const childState of Array.from(this.childStates.values())) if (childState.parentThreadId === parentThreadId) this.retireChild(state, childState, "Subagent parent session ended.");
|
|
2265
1892
|
if (this.parentStates.get(parentThreadId) === state) this.parentStates.delete(parentThreadId);
|
|
2266
1893
|
}
|
|
2267
1894
|
prepareParentTaskRuntime(state) {
|
|
@@ -2275,6 +1902,7 @@ var Monitor = class {
|
|
|
2275
1902
|
state.mirror ??= new CodexNativeSubagentTaskMirror({
|
|
2276
1903
|
parentThreadId: state.parentThreadId,
|
|
2277
1904
|
requesterSessionKey: state.requesterSessionKey,
|
|
1905
|
+
historyOwner: state.historyOwner,
|
|
2278
1906
|
agentId: state.agentId
|
|
2279
1907
|
}, state.taskRuntime);
|
|
2280
1908
|
}
|
|
@@ -2539,7 +2167,7 @@ var Monitor = class {
|
|
|
2539
2167
|
for (const childThreadId of childThreadIds) {
|
|
2540
2168
|
const childState = this.childStates.get(childThreadId);
|
|
2541
2169
|
if (childState && childState.parentThreadId !== state.parentThreadId) continue;
|
|
2542
|
-
if (childState) this.retireChild(state, childState, "
|
|
2170
|
+
if (childState) this.retireChild(state, childState, "Subagent was closed.");
|
|
2543
2171
|
else this.updateChildThreadOwnership("release", childThreadId, this.releaseChildThread);
|
|
2544
2172
|
}
|
|
2545
2173
|
}
|
|
@@ -2745,8 +2373,8 @@ var Monitor = class {
|
|
|
2745
2373
|
childSessionKey: codexNativeSubagentRunId(completion.childThreadId),
|
|
2746
2374
|
childSessionId: completion.childThreadId,
|
|
2747
2375
|
announceId: `codex-native:${state.parentThreadId}:${completion.childThreadId}:${completion.status}`,
|
|
2748
|
-
announceType: "
|
|
2749
|
-
taskLabel: "
|
|
2376
|
+
announceType: "Subagent",
|
|
2377
|
+
taskLabel: "Subagent",
|
|
2750
2378
|
status: completion.status,
|
|
2751
2379
|
statusLabel: completion.statusLabel,
|
|
2752
2380
|
result: completion.result,
|
|
@@ -3088,7 +2716,7 @@ var Monitor = class {
|
|
|
3088
2716
|
const candidates = /* @__PURE__ */ new Map();
|
|
3089
2717
|
for (const task of state.taskRuntime.listTaskRecords()) {
|
|
3090
2718
|
if (task.requesterSessionKey !== state.requesterSessionKey || !this.shouldReconcileCodexNativeTask(task)) continue;
|
|
3091
|
-
const childThreadId = task.runId.slice(
|
|
2719
|
+
const childThreadId = task.runId.slice(CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX.length).trim();
|
|
3092
2720
|
candidates.set(childThreadId, {
|
|
3093
2721
|
parentState: state,
|
|
3094
2722
|
nativeCompletionReceipts: state.nativeCompletionReceipts,
|
|
@@ -3249,14 +2877,14 @@ function toChildTurnCompletion(childState, turn) {
|
|
|
3249
2877
|
childThreadId: childState.childThreadId,
|
|
3250
2878
|
status: "succeeded",
|
|
3251
2879
|
statusLabel: result ? "turn_completed" : "completed_without_final_message",
|
|
3252
|
-
result: result ?? "
|
|
2880
|
+
result: result ?? "Subagent completed without a final assistant message."
|
|
3253
2881
|
};
|
|
3254
2882
|
}
|
|
3255
2883
|
if (status === "failed") return {
|
|
3256
2884
|
childThreadId: childState.childThreadId,
|
|
3257
2885
|
status: "failed",
|
|
3258
2886
|
statusLabel: "turn_failed",
|
|
3259
|
-
result: readTurnErrorMessage(turn) ?? "
|
|
2887
|
+
result: readTurnErrorMessage(turn) ?? "Subagent failed."
|
|
3260
2888
|
};
|
|
3261
2889
|
}
|
|
3262
2890
|
function lastChildAssistantMessage(childState, turnId) {
|
|
@@ -3276,7 +2904,7 @@ function systemErrorFallbackCompletion(childThreadId) {
|
|
|
3276
2904
|
childThreadId,
|
|
3277
2905
|
status: "failed",
|
|
3278
2906
|
statusLabel: "system_error",
|
|
3279
|
-
result: "
|
|
2907
|
+
result: "Subagent runtime reported a system error."
|
|
3280
2908
|
};
|
|
3281
2909
|
}
|
|
3282
2910
|
function readTurnCompletion(turn, childThreadId) {
|
|
@@ -3289,7 +2917,7 @@ function readTurnCompletion(turn, childThreadId) {
|
|
|
3289
2917
|
childThreadId,
|
|
3290
2918
|
status: "succeeded",
|
|
3291
2919
|
statusLabel: result ? "task_complete" : "completed_without_final_message",
|
|
3292
|
-
result: result ?? "
|
|
2920
|
+
result: result ?? "Subagent completed without a final assistant message.",
|
|
3293
2921
|
completedAt
|
|
3294
2922
|
};
|
|
3295
2923
|
if (status === "interrupted") return;
|
|
@@ -3297,7 +2925,7 @@ function readTurnCompletion(turn, childThreadId) {
|
|
|
3297
2925
|
childThreadId,
|
|
3298
2926
|
status: "failed",
|
|
3299
2927
|
statusLabel: "task_failed",
|
|
3300
|
-
result: readTurnErrorMessage(turn) ?? result ?? "
|
|
2928
|
+
result: readTurnErrorMessage(turn) ?? result ?? "Subagent failed.",
|
|
3301
2929
|
completedAt
|
|
3302
2930
|
};
|
|
3303
2931
|
}
|
|
@@ -3347,4 +2975,4 @@ function unrefTimer(timer) {
|
|
|
3347
2975
|
if (typeof timer === "object" && timer && "unref" in timer) timer.unref();
|
|
3348
2976
|
}
|
|
3349
2977
|
//#endregion
|
|
3350
|
-
export { CodexToolProgressProjection as a,
|
|
2978
|
+
export { CodexToolProgressProjection as a, CodexToolTranscriptProjection as i, CodexEventProjection as n, shouldEmitTranscriptToolProgress as o, emitCodexAgentEvent as r, codexNativeSubagentMonitorRuntime as t };
|