@openclaw/codex 2026.9.2 → 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/README.md +2 -0
- package/dist/api.js +29 -26
- package/dist/apply-CvT8tW5i.js +356 -0
- package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-DKHzbwt5.js} +38 -214
- package/dist/{attempt-context-CSazkWns.js → attempt-context-D44yeDII.js} +9 -7
- package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications-C9XufG6l.js} +3 -106
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-CWlKVccJ.js} +2 -2
- package/dist/auth-cache-key-7orQae_j.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/binding-connection-D3udKbIE.js +60 -0
- package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-C_Hneydj.js} +28 -125
- package/dist/build-state-BCmg9-5p.js +19 -0
- package/dist/{capabilities-B1mgvpP8.js → capabilities-8vx68WLH.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-B57KWPQx.js +4005 -0
- package/dist/command-dispatch-BpduNGVf.js +21 -0
- package/dist/{command-formatters-DSbGMXA0.js → command-formatters-lxlkNZgU.js} +4 -3
- package/dist/{command-handlers-DOJvGv6-.js → command-handlers-tiL9iWj7.js} +788 -135
- package/dist/command-rpc-CR5EOEZX.js +233 -0
- package/dist/{compact-Y_xBqrHN.js → compact-B_H3AOd7.js} +19 -14
- package/dist/config-oIORaQ5T.js +106 -0
- package/dist/{config-CyapYSji.js → config-options-CXMq1T-C.js} +205 -593
- package/dist/config-runtime-D0zGNIHu.js +11 -0
- package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
- package/dist/conversation-binding-DsB4-O7U.js +900 -0
- package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CtUu1b3m.js} +11 -143
- package/dist/doctor-contract-api.js +5 -5
- package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-CmN5RAip.js} +133 -76
- package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-D78_VmzO.js +101 -0
- package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
- package/dist/event-projector-items-5VhsECCO.js +200 -0
- package/dist/event-projector-usage-BfXmpOec.js +102 -0
- package/dist/{harness-Czh2Sdoc.js → harness-C7rRa7bm.js} +48 -24
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +406 -2915
- package/dist/inference-context-Dr_mzvk4.js +94 -0
- package/dist/inference-proxy-HGXKUIre.js +311 -0
- package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DWVb5U2J.js} +7 -4
- package/dist/launch-args-RXQwn8zV.js +90 -0
- package/dist/{managed-binary-DcpnJF9x.js → managed-binary-D22rNEcR.js} +13 -103
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/migration-provider-api.js +2 -0
- package/dist/{model-catalog-DT5vo6qo.js → model-catalog-Dq2n8f_p.js} +6 -5
- package/dist/{models-CcrgSMQR.js → models-PCKOim-h.js} +3 -3
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/native-subagent-history-DjtPloaU.js +140 -0
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
- package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-fQ7eIXEf.js} +115 -460
- package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
- package/dist/node-cli-sessions-DKaOmVUh.js +527 -0
- package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-Cl2vapEi.js} +55 -24
- package/dist/plan-7uG-Fp36.js +947 -0
- package/dist/plugin-activation-BYQculil.js +138 -0
- package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-d0eKxy7b.js} +4 -52
- package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
- package/dist/plugin-inventory-oL4Na1ZG.js +328 -0
- package/dist/plugin-marketplace-discovery-P-Vndfqq.js +137 -0
- package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-ClPJpRio.js} +17 -9
- package/dist/protocol-5bh1G-H7.js +275 -0
- package/dist/provider-MQ8PVkuE.js +50 -0
- package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-BvCUL69A.js} +2 -2
- package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-CBMmWBr9.js} +1 -1
- package/dist/request-B7hEkBGq.js +212 -0
- package/dist/rpc-error-ttN_QjEm.js +30 -0
- package/dist/{run-attempt-BzthFQSM.js → run-attempt-CvsAAGa0.js} +664 -377
- package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-BJ0rXBZ_.js} +27 -27
- package/dist/sandbox-guard-BxgyoM8M.js +166 -0
- package/dist/{session-binding-4Ki04sW-.js → session-binding-CI8UuilT.js} +30 -48
- package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-Bcvslnhf.js} +12 -26
- package/dist/session-catalog-adoption-tcZi1IfX.js +251 -0
- package/dist/session-catalog-archive-CwKg8Xz2.js +56 -0
- package/dist/session-catalog-ct-AH01I.js +1477 -0
- package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
- package/dist/session-catalog-node-adoption-B1tgDW-m.js +182 -0
- package/dist/session-catalog-node-continue-Ci-DXyJP.js +238 -0
- package/dist/session-catalog-provenance-D-dIfRAH.js +96 -0
- package/dist/{session-cli-BjLhpmS1.js → session-cli-DNN_jhGc.js} +3 -2
- package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
- package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DwyijFI6.js} +5 -50
- package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
- package/dist/session-history-worker-runtime.js +18 -6
- package/dist/session-history.worker-BeK1YOyT.js +378 -0
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Ct0_Hzmg.js} +2 -2
- package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-BBmXA8Eg.js} +4 -7
- package/dist/{session-retirement-DNdmYdFc.js → session-retirement-B2YfbAAT.js} +6 -5
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
- package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-Dn91stmc.js} +8 -7
- package/dist/shared-client-CscigXXL.js +3109 -0
- package/dist/{side-question-B6DWAw1A.js → side-question-BGMJQf4U.js} +65 -170
- package/dist/source-CElXU0Oy.js +518 -0
- package/dist/thread-archive-guard-DfpBr-Sz.js +53 -0
- package/dist/thread-history-page-D0JIp48V.js +361 -0
- package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-DXl1-I6b.js} +187 -639
- package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-BsDRTsyp.js} +13 -15
- package/dist/thread-policy-BuEQfE0g.js +54 -0
- package/dist/thread-resume-DsDOZpFg.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-history-projection-v17wXgdK.js +238 -0
- package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-C5CKgNy6.js} +50 -260
- package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
- package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
- package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-BZerMte_.js} +27 -19
- package/dist/{usage-i9fv5-4m.js → usage-tCk-mg_x.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
- package/openclaw.plugin.json +23 -1
- package/package.json +4 -4
- package/dist/request-C8H22rPi.js +0 -475
- package/dist/session-catalog-B47uwekb.js +0 -3272
- package/dist/session-history.worker-zZVcx0ME.js +0 -267
- package/dist/shared-client-CKhX2kFt.js +0 -7505
- package/dist/thread-policy-CTalhWFy.js +0 -105
|
@@ -1,398 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
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, 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-Bp1ZOnk2.js";
|
|
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";
|
|
4
3
|
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
|
|
5
|
-
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-
|
|
4
|
+
import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-Cz-tOOYj.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
|
-
import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage, formatToolAggregate, formatToolProgressOutput, inferToolMetaFromArgs, runAgentHarnessAfterToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
12
|
-
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
13
|
-
import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
14
12
|
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
13
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
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.normalizedLengthByItem = /* @__PURE__ */ new Map();
|
|
24
|
-
this.trimStateByItem = /* @__PURE__ */ new Map();
|
|
25
|
-
this.truncatedItemIds = /* @__PURE__ */ new Set();
|
|
26
|
-
this.textByItem = /* @__PURE__ */ new Map();
|
|
27
|
-
}
|
|
28
|
-
append(itemId, delta) {
|
|
29
|
-
const originalLength = (this.originalLengthByItem.get(itemId) ?? this.textByItem.get(itemId)?.length ?? 0) + delta.length;
|
|
30
|
-
this.originalLengthByItem.set(itemId, originalLength);
|
|
31
|
-
const normalizedLength = updateToolOutputTrimState(this.trimStateByItem, itemId, delta);
|
|
32
|
-
this.normalizedLengthByItem.set(itemId, normalizedLength);
|
|
33
|
-
if (this.truncatedItemIds.has(itemId)) {
|
|
34
|
-
const next = appendBoundedToolTranscriptText(this.prefixByItem.get(itemId) ?? this.textByItem.get(itemId) ?? "", "", originalLength);
|
|
35
|
-
this.prefixByItem.set(itemId, next.rawPrefix);
|
|
36
|
-
this.textByItem.set(itemId, next.text);
|
|
37
|
-
return {
|
|
38
|
-
text: next.text,
|
|
39
|
-
originalLength,
|
|
40
|
-
normalizedLength,
|
|
41
|
-
rawPrefix: next.rawPrefix
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const next = appendBoundedToolTranscriptText(this.prefixByItem.get(itemId) ?? this.textByItem.get(itemId) ?? "", delta, originalLength);
|
|
45
|
-
this.prefixByItem.set(itemId, next.rawPrefix);
|
|
46
|
-
this.textByItem.set(itemId, next.text);
|
|
47
|
-
if (originalLength > 1e4) this.truncatedItemIds.add(itemId);
|
|
48
|
-
return {
|
|
49
|
-
text: next.text,
|
|
50
|
-
originalLength,
|
|
51
|
-
normalizedLength,
|
|
52
|
-
rawPrefix: next.rawPrefix
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
function updateToolOutputTrimState(trimStateByItem, itemId, delta) {
|
|
57
|
-
const state = trimStateByItem.get(itemId) ?? {
|
|
58
|
-
totalLength: 0,
|
|
59
|
-
leadingWhitespaceLength: 0,
|
|
60
|
-
trailingWhitespaceLength: 0,
|
|
61
|
-
sawNonWhitespace: false
|
|
62
|
-
};
|
|
63
|
-
state.totalLength += delta.length;
|
|
64
|
-
const firstNonWhitespace = delta.search(/\S/u);
|
|
65
|
-
if (firstNonWhitespace === -1) {
|
|
66
|
-
if (!state.sawNonWhitespace) state.leadingWhitespaceLength += delta.length;
|
|
67
|
-
state.trailingWhitespaceLength += delta.length;
|
|
68
|
-
trimStateByItem.set(itemId, state);
|
|
69
|
-
return state.sawNonWhitespace ? state.totalLength - state.leadingWhitespaceLength - state.trailingWhitespaceLength : 0;
|
|
70
|
-
}
|
|
71
|
-
if (!state.sawNonWhitespace) {
|
|
72
|
-
state.leadingWhitespaceLength += firstNonWhitespace;
|
|
73
|
-
state.sawNonWhitespace = true;
|
|
74
|
-
}
|
|
75
|
-
state.trailingWhitespaceLength = delta.match(/\s*$/u)?.[0].length ?? 0;
|
|
76
|
-
trimStateByItem.set(itemId, state);
|
|
77
|
-
return state.totalLength - state.leadingWhitespaceLength - state.trailingWhitespaceLength;
|
|
78
|
-
}
|
|
79
|
-
function toolOutputRawEchoSignature(text) {
|
|
80
|
-
const trimmed = text.trim();
|
|
81
|
-
if (!trimmed) return;
|
|
82
|
-
return {
|
|
83
|
-
rawLength: trimmed.length,
|
|
84
|
-
rawPrefix: trimmed.slice(0, TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS)
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function normalizeToolTranscriptArguments(value) {
|
|
88
|
-
return asNonArrayRecord(value);
|
|
89
|
-
}
|
|
90
|
-
function collectDynamicToolContentText(contentItems) {
|
|
91
|
-
if (!Array.isArray(contentItems)) return "";
|
|
92
|
-
return contentItems.flatMap((entry) => {
|
|
93
|
-
if (!isJsonObject(entry)) return [];
|
|
94
|
-
const text = readStringField(entry, "text");
|
|
95
|
-
return text ? [text] : [];
|
|
96
|
-
}).join("\n");
|
|
97
|
-
}
|
|
98
|
-
function appendBoundedToolTranscriptText(currentPrefix, delta, originalLength) {
|
|
99
|
-
if (originalLength <= 1e4) {
|
|
100
|
-
const rawPrefix = currentPrefix + delta;
|
|
101
|
-
return {
|
|
102
|
-
text: rawPrefix,
|
|
103
|
-
rawPrefix
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const notice = toolTranscriptTruncationNotice(originalLength);
|
|
107
|
-
if (notice.length >= 1e4) return {
|
|
108
|
-
text: notice.slice(0, TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS),
|
|
109
|
-
rawPrefix: ""
|
|
110
|
-
};
|
|
111
|
-
const textBudget = TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS - notice.length;
|
|
112
|
-
const remaining = Math.max(0, textBudget - currentPrefix.length);
|
|
113
|
-
const prefix = remaining > 0 ? `${currentPrefix}${truncateUtf16Safe(delta, remaining)}` : currentPrefix;
|
|
114
|
-
const rawPrefix = truncateUtf16Safe(prefix, textBudget);
|
|
115
|
-
return {
|
|
116
|
-
text: `${rawPrefix}${notice}`,
|
|
117
|
-
rawPrefix
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
function toolTranscriptTruncationNotice(originalLength) {
|
|
121
|
-
return `\n${`${TOOL_OUTPUT_TRUNCATION_NOTICE_PREFIX}: original ${originalLength} chars, showing ${TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS}; rerun with narrower args.)`}`;
|
|
122
|
-
}
|
|
123
|
-
function truncateToolTranscriptText(text, originalLength = text.length) {
|
|
124
|
-
if (originalLength <= 1e4 && text.length <= 1e4) return text;
|
|
125
|
-
const notice = toolTranscriptTruncationNotice(originalLength);
|
|
126
|
-
if (notice.length >= 1e4) return notice.slice(1, 10001);
|
|
127
|
-
const textBudget = TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS - notice.length;
|
|
128
|
-
return `${truncateUtf16Safe(text, textBudget)}${notice}`;
|
|
129
|
-
}
|
|
130
|
-
function formatToolSummary(toolName, meta) {
|
|
131
|
-
const trimmedMeta = meta?.trim();
|
|
132
|
-
return formatToolAggregate(toolName, trimmedMeta ? [trimmedMeta] : void 0, { markdown: true });
|
|
133
|
-
}
|
|
134
|
-
function formatToolOutput(toolName, meta, output) {
|
|
135
|
-
const formattedOutput = formatToolProgressOutput(output);
|
|
136
|
-
if (!formattedOutput) return formatToolSummary(toolName, meta);
|
|
137
|
-
const fence = markdownFenceForText(formattedOutput);
|
|
138
|
-
return `${formatToolSummary(toolName, meta)}\n${fence}txt\n${formattedOutput}\n${fence}`;
|
|
139
|
-
}
|
|
140
|
-
function markdownFenceForText(text) {
|
|
141
|
-
return "`".repeat(Math.max(3, longestBacktickRun(text) + 1));
|
|
142
|
-
}
|
|
143
|
-
function longestBacktickRun(value) {
|
|
144
|
-
let longest = 0;
|
|
145
|
-
let current = 0;
|
|
146
|
-
for (const char of value) {
|
|
147
|
-
if (char === "`") {
|
|
148
|
-
current += 1;
|
|
149
|
-
longest = Math.max(longest, current);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
current = 0;
|
|
153
|
-
}
|
|
154
|
-
return longest;
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region extensions/codex/src/app-server/tool-progress-normalization.ts
|
|
158
|
-
/**
|
|
159
|
-
* Normalizes and sanitizes Codex dynamic-tool progress payloads before they are
|
|
160
|
-
* emitted into OpenClaw events or logs.
|
|
161
|
-
*/
|
|
162
|
-
/** Maps OpenClaw tool-progress config to the mode used by Codex progress metadata. */
|
|
163
|
-
function resolveCodexToolProgressDetailMode(value) {
|
|
164
|
-
return value === "raw" ? "raw" : "explain";
|
|
165
|
-
}
|
|
166
|
-
function isCodexCommandBearingToolCall(name, args) {
|
|
167
|
-
const normalizedName = name?.trim().toLowerCase();
|
|
168
|
-
return normalizedName === "exec" || normalizedName === "bash" || normalizedName === "shell" || typeof args?.command === "string" && args.command.trim().length > 0;
|
|
169
|
-
}
|
|
170
|
-
/** Recursively redacts sensitive strings and handles circular values in event payloads. */
|
|
171
|
-
function sanitizeCodexAgentEventValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
172
|
-
if (typeof value === "string") return redactToolPayloadText(value);
|
|
173
|
-
if (Array.isArray(value)) {
|
|
174
|
-
if (seen.has(value)) return "[Circular]";
|
|
175
|
-
seen.add(value);
|
|
176
|
-
return value.map((entry) => sanitizeCodexAgentEventValue(entry, seen));
|
|
177
|
-
}
|
|
178
|
-
if (value && typeof value === "object") {
|
|
179
|
-
if (seen.has(value)) return "[Circular]";
|
|
180
|
-
seen.add(value);
|
|
181
|
-
const out = {};
|
|
182
|
-
for (const [key, child] of Object.entries(value)) out[key] = typeof child === "string" ? redactSensitiveFieldValue(key, child) : sanitizeCodexAgentEventValue(child, seen);
|
|
183
|
-
return out;
|
|
184
|
-
}
|
|
185
|
-
return value;
|
|
186
|
-
}
|
|
187
|
-
/** Sanitizes a record-shaped Codex agent event payload. */
|
|
188
|
-
function sanitizeCodexAgentEventRecord(value) {
|
|
189
|
-
return sanitizeCodexAgentEventValue(value);
|
|
190
|
-
}
|
|
191
|
-
/** Sanitizes dynamic-tool arguments before diagnostic/event emission. */
|
|
192
|
-
function sanitizeCodexToolArguments(value) {
|
|
193
|
-
if (!isJsonObject(value)) return;
|
|
194
|
-
return sanitizeCodexAgentEventRecord(value);
|
|
195
|
-
}
|
|
196
|
-
/** Sanitizes a Codex dynamic-tool response before diagnostic/event emission. */
|
|
197
|
-
function sanitizeCodexToolResponse(response) {
|
|
198
|
-
return sanitizeCodexAgentEventRecord({ ...response });
|
|
199
|
-
}
|
|
200
|
-
/** Infers compact human-readable tool metadata from Codex dynamic-tool arguments. */
|
|
201
|
-
function inferCodexDynamicToolMeta(call, detailMode) {
|
|
202
|
-
return inferToolMetaFromArgs(call.tool, call.arguments, { detailMode });
|
|
203
|
-
}
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region extensions/codex/src/app-server/event-projector-tool-items.ts
|
|
206
|
-
function isNativePostToolUseRelayItem(item) {
|
|
207
|
-
switch (item.type) {
|
|
208
|
-
case "commandExecution":
|
|
209
|
-
case "fileChange":
|
|
210
|
-
case "mcpToolCall": return true;
|
|
211
|
-
default: return false;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function shouldSuppressChannelProgressForItem(item) {
|
|
215
|
-
if (shouldSynthesizeToolProgressForItem(item)) return true;
|
|
216
|
-
return item.type === "dynamicToolCall";
|
|
217
|
-
}
|
|
218
|
-
function itemToolArgs(item) {
|
|
219
|
-
if (item.type === "commandExecution") return sanitizeCodexAgentEventRecord({
|
|
220
|
-
command: item.command,
|
|
221
|
-
...typeof item.cwd === "string" ? { cwd: item.cwd } : {}
|
|
222
|
-
});
|
|
223
|
-
if (item.type === "fileChange") return sanitizeCodexAgentEventRecord({ changes: itemFileChangesForTranscript(item) });
|
|
224
|
-
if (item.type === "webSearch") return webSearchToolArgs(item);
|
|
225
|
-
if (item.type === "dynamicToolCall" || item.type === "mcpToolCall") return sanitizeCodexToolArguments(item.arguments);
|
|
226
|
-
}
|
|
227
|
-
function isCommandBearingToolItem(item, args) {
|
|
228
|
-
if (item.type === "commandExecution") return true;
|
|
229
|
-
return typeof args?.command === "string" && args.command.trim().length > 0;
|
|
230
|
-
}
|
|
231
|
-
function webSearchToolArgs(item) {
|
|
232
|
-
const action = isJsonObject(item.action) ? item.action : void 0;
|
|
233
|
-
const actionType = action ? readNonEmptyString(action, "type") : void 0;
|
|
234
|
-
const queries = action && actionType === "search" ? readNonEmptyStringArray(action, "queries") : [];
|
|
235
|
-
const query = normalizeOptionalString$1(item.query) ?? (action && actionType === "search" ? readNonEmptyString(action, "query") : void 0) ?? queries[0];
|
|
236
|
-
const url = action ? readNonEmptyString(action, "url") : void 0;
|
|
237
|
-
const pattern = action ? readNonEmptyString(action, "pattern") : void 0;
|
|
238
|
-
const args = {};
|
|
239
|
-
if (query) args.query = query;
|
|
240
|
-
if (queries.length > 0) args.queries = queries;
|
|
241
|
-
if (actionType && actionType !== "search") args.action = actionType;
|
|
242
|
-
if (url) args.url = url;
|
|
243
|
-
if (pattern) args.pattern = pattern;
|
|
244
|
-
if (!query && !url && !pattern) args.queryUnavailable = true;
|
|
245
|
-
return sanitizeCodexAgentEventRecord(args);
|
|
246
|
-
}
|
|
247
|
-
function itemToolResult(item) {
|
|
248
|
-
if (item.type === "commandExecution") return { result: sanitizeCodexAgentEventRecord({
|
|
249
|
-
status: item.status,
|
|
250
|
-
exitCode: item.exitCode,
|
|
251
|
-
durationMs: item.durationMs
|
|
252
|
-
}) };
|
|
253
|
-
if (item.type === "fileChange") return { result: sanitizeCodexAgentEventRecord({
|
|
254
|
-
status: item.status,
|
|
255
|
-
changes: itemFileChanges(item)
|
|
256
|
-
}) };
|
|
257
|
-
if (item.type === "mcpToolCall") return { result: sanitizeCodexAgentEventRecord({
|
|
258
|
-
status: item.status,
|
|
259
|
-
durationMs: item.durationMs,
|
|
260
|
-
...item.error ? { error: item.error } : {},
|
|
261
|
-
...item.result ? { result: item.result } : {}
|
|
262
|
-
}) };
|
|
263
|
-
if (item.type === "webSearch") return { result: webSearchToolResult(item) };
|
|
264
|
-
return {};
|
|
265
|
-
}
|
|
266
|
-
function webSearchToolResult(item) {
|
|
267
|
-
return sanitizeCodexAgentEventRecord({
|
|
268
|
-
status: itemStatus(item),
|
|
269
|
-
...typeof item.durationMs === "number" ? { durationMs: item.durationMs } : {},
|
|
270
|
-
...webSearchToolArgs(item)
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
function itemFileChangeRecords(item) {
|
|
274
|
-
const changes = item.changes;
|
|
275
|
-
return Array.isArray(changes) ? changes.filter(isJsonObject) : [];
|
|
276
|
-
}
|
|
277
|
-
function itemFileChanges(item) {
|
|
278
|
-
return itemFileChangeRecords(item).flatMap((change) => {
|
|
279
|
-
const path = normalizeOptionalString$1(change.path);
|
|
280
|
-
if (!path || change.kind === void 0) return [];
|
|
281
|
-
return [{
|
|
282
|
-
path,
|
|
283
|
-
kind: change.kind
|
|
284
|
-
}];
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
function fileChangeKindType(kind) {
|
|
288
|
-
if (typeof kind === "string") return kind;
|
|
289
|
-
return isJsonObject(kind) ? normalizeOptionalString$1(kind.type) : void 0;
|
|
290
|
-
}
|
|
291
|
-
function countFileContentLines(content) {
|
|
292
|
-
if (!content) return 0;
|
|
293
|
-
const lines = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
294
|
-
if (lines.length > 1 && lines.at(-1) === "") lines.pop();
|
|
295
|
-
return lines.length;
|
|
296
|
-
}
|
|
297
|
-
function fileChangeDiffStat(diff, kind) {
|
|
298
|
-
const kindType = fileChangeKindType(kind);
|
|
299
|
-
if (kindType === "add") return {
|
|
300
|
-
added: countFileContentLines(diff),
|
|
301
|
-
removed: 0
|
|
302
|
-
};
|
|
303
|
-
if (kindType === "delete") return {
|
|
304
|
-
added: 0,
|
|
305
|
-
removed: countFileContentLines(diff)
|
|
306
|
-
};
|
|
307
|
-
let added = 0;
|
|
308
|
-
let removed = 0;
|
|
309
|
-
let inHunk = false;
|
|
310
|
-
for (const line of diff.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n")) {
|
|
311
|
-
if (line.startsWith("@@")) {
|
|
312
|
-
inHunk = true;
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
if (!inHunk) continue;
|
|
316
|
-
if (line.startsWith("+")) added += 1;
|
|
317
|
-
else if (line.startsWith("-")) removed += 1;
|
|
318
|
-
}
|
|
319
|
-
return {
|
|
320
|
-
added,
|
|
321
|
-
removed
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
function truncateFileChangeDiffAtLineBoundary(diff, maxChars) {
|
|
325
|
-
if (diff.length <= maxChars) return { diff };
|
|
326
|
-
if (maxChars <= 0) return { diffTruncated: true };
|
|
327
|
-
const boundary = diff.lastIndexOf("\n", maxChars - 1);
|
|
328
|
-
return boundary >= 0 ? {
|
|
329
|
-
diff: diff.slice(0, boundary + 1),
|
|
330
|
-
diffTruncated: true
|
|
331
|
-
} : { diffTruncated: true };
|
|
332
|
-
}
|
|
333
|
-
function itemFileChangesForTranscript(item) {
|
|
334
|
-
let remainingDiffChars = 1e4;
|
|
335
|
-
return itemFileChangeRecords(item).flatMap((change) => {
|
|
336
|
-
const path = normalizeOptionalString$1(change.path);
|
|
337
|
-
if (!path || change.kind === void 0) return [];
|
|
338
|
-
const result = {
|
|
339
|
-
path,
|
|
340
|
-
kind: change.kind
|
|
341
|
-
};
|
|
342
|
-
if (typeof change.diff !== "string") return [result];
|
|
343
|
-
result.stat = fileChangeDiffStat(change.diff, change.kind);
|
|
344
|
-
const bounded = truncateFileChangeDiffAtLineBoundary(change.diff, remainingDiffChars);
|
|
345
|
-
if (bounded.diff !== void 0) {
|
|
346
|
-
result.diff = bounded.diff;
|
|
347
|
-
remainingDiffChars -= bounded.diff.length;
|
|
348
|
-
}
|
|
349
|
-
if (bounded.diffTruncated) result.diffTruncated = true;
|
|
350
|
-
return [result];
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
function itemToolError(item, status, outputTextByItem) {
|
|
354
|
-
if (status === "blocked") return "codex native tool blocked";
|
|
355
|
-
if (status !== "failed") return;
|
|
356
|
-
return itemOutputText(item, outputTextByItem) ?? "codex native tool failed";
|
|
357
|
-
}
|
|
358
|
-
function itemMeta(item, detailMode = "explain") {
|
|
359
|
-
if (item.type === "commandExecution" && typeof item.command === "string") return inferToolMetaFromArgs("exec", {
|
|
360
|
-
command: item.command,
|
|
361
|
-
cwd: typeof item.cwd === "string" ? item.cwd : void 0
|
|
362
|
-
}, { detailMode });
|
|
363
|
-
if (item.type === "webSearch") return inferToolMetaFromArgs("web_search", webSearchToolArgs(item), { detailMode });
|
|
364
|
-
const toolName = itemName(item);
|
|
365
|
-
if ((item.type === "dynamicToolCall" || item.type === "mcpToolCall") && toolName) return inferToolMetaFromArgs(toolName, item.arguments, { detailMode });
|
|
366
|
-
}
|
|
367
|
-
function itemOutputText(item, outputTextByItem) {
|
|
368
|
-
if (item.type === "commandExecution") {
|
|
369
|
-
const output = item.aggregatedOutput?.trim() || outputTextByItem?.get(item.id)?.trim();
|
|
370
|
-
return output ? truncateToolTranscriptText(output) : void 0;
|
|
371
|
-
}
|
|
372
|
-
if (item.type === "dynamicToolCall") {
|
|
373
|
-
const output = collectDynamicToolContentText(item.contentItems).trim();
|
|
374
|
-
return output ? truncateToolTranscriptText(output) : void 0;
|
|
375
|
-
}
|
|
376
|
-
if (item.type === "mcpToolCall") {
|
|
377
|
-
const output = item.error ? stringifyJsonValue(item.error) : item.result ? stringifyJsonValue(item.result) : void 0;
|
|
378
|
-
return output ? truncateToolTranscriptText(output) : void 0;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
function itemTranscriptResultText(item, outputTextByItem) {
|
|
382
|
-
const output = itemOutputText(item, outputTextByItem);
|
|
383
|
-
if (output) return output;
|
|
384
|
-
const result = itemToolResult(item).result;
|
|
385
|
-
const resultText = result ? stringifyJsonValue(result) : void 0;
|
|
386
|
-
return resultText ? truncateToolTranscriptText(resultText) : itemStatus(item);
|
|
387
|
-
}
|
|
388
|
-
function stringifyJsonValue(value) {
|
|
389
|
-
try {
|
|
390
|
-
return JSON.stringify(value, null, 2);
|
|
391
|
-
} catch {
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
//#endregion
|
|
396
16
|
//#region extensions/codex/src/app-server/event-projector-tool-progress.ts
|
|
397
17
|
const TRANSCRIPT_PROGRESS_SUPPRESSED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
398
18
|
"message",
|
|
@@ -562,7 +182,8 @@ var CodexToolProgressProjection = class {
|
|
|
562
182
|
else if (this.lastNativeToolError?.mutatingAction !== true) this.lastNativeToolError = void 0;
|
|
563
183
|
}
|
|
564
184
|
emitToolResultSummary(item) {
|
|
565
|
-
if (!item ||
|
|
185
|
+
if (!item || item.type === "dynamicToolCall") return;
|
|
186
|
+
if (!this.params.onToolResult || !this.shouldEmitToolResult()) return;
|
|
566
187
|
if (this.resultSummaryItemIds.has(item.id)) return;
|
|
567
188
|
const toolName = itemName(item);
|
|
568
189
|
const args = itemToolArgs(item);
|
|
@@ -575,7 +196,8 @@ var CodexToolProgressProjection = class {
|
|
|
575
196
|
});
|
|
576
197
|
}
|
|
577
198
|
emitToolResultOutput(item) {
|
|
578
|
-
if (!item ||
|
|
199
|
+
if (!item || item.type === "dynamicToolCall") return;
|
|
200
|
+
if (!this.params.onToolResult || !this.shouldEmitToolOutput()) return;
|
|
579
201
|
if (this.resultOutputItemIds.has(item.id) || this.resultOutputStreamedItemIds.has(item.id)) return;
|
|
580
202
|
const toolName = itemName(item);
|
|
581
203
|
const output = itemOutputText(item, this.output.textByItem);
|
|
@@ -658,7 +280,7 @@ var CodexToolProgressProjection = class {
|
|
|
658
280
|
return !commandBearing || !channel && this.shouldEmitToolOutput();
|
|
659
281
|
}
|
|
660
282
|
emitTranscriptToolCallProgress(params) {
|
|
661
|
-
if (!shouldEmitTranscriptToolProgress(params.name, params.arguments)) return;
|
|
283
|
+
if (params.name === "progress_card" || !shouldEmitTranscriptToolProgress(params.name, params.arguments)) return;
|
|
662
284
|
this.transcriptProgressCallIds.add(params.id);
|
|
663
285
|
const args = normalizeToolTranscriptArguments(params.arguments);
|
|
664
286
|
const meta = this.shouldIncludeFormattedMeta(isCodexCommandBearingToolCall(params.name, args)) ? inferToolMetaFromArgs(params.name, args, { detailMode: this.toolProgressDetailMode() }) : void 0;
|
|
@@ -670,7 +292,12 @@ var CodexToolProgressProjection = class {
|
|
|
670
292
|
});
|
|
671
293
|
}
|
|
672
294
|
emitTranscriptToolResultProgress(params) {
|
|
673
|
-
if (this.transcriptProgressSuppressedIds.has(params.id) || !shouldEmitTranscriptToolProgress(params.name, this.transcriptArgumentsById.get(params.id))) return;
|
|
295
|
+
if (params.name === "progress_card" && !params.isError || this.transcriptProgressSuppressedIds.has(params.id) || !shouldEmitTranscriptToolProgress(params.name, this.transcriptArgumentsById.get(params.id))) return;
|
|
296
|
+
if (params.name === "progress_card" && this.shouldEmitToolResult()) this.emitToolResultMessage({
|
|
297
|
+
itemId: params.id,
|
|
298
|
+
text: formatToolSummary(params.name),
|
|
299
|
+
isError: true
|
|
300
|
+
});
|
|
674
301
|
if (!this.transcriptProgressCallIds.has(params.id)) this.emitTranscriptToolCallProgress({
|
|
675
302
|
id: params.id,
|
|
676
303
|
name: params.name,
|
|
@@ -1389,6 +1016,16 @@ var CodexEventProjection = class {
|
|
|
1389
1016
|
}
|
|
1390
1017
|
});
|
|
1391
1018
|
}
|
|
1019
|
+
handleRetry(params) {
|
|
1020
|
+
const rateLimited = isJsonObject(params.error) && params.error.codexErrorInfo === "rateLimitExceeded";
|
|
1021
|
+
this.emitAgentEvent({
|
|
1022
|
+
stream: "run_status",
|
|
1023
|
+
data: {
|
|
1024
|
+
phase: "retrying",
|
|
1025
|
+
message: rateLimited ? "Rate limited. The provider is retrying." : "Connection interrupted. The provider is retrying."
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1392
1029
|
flushPendingGuardianWarning() {
|
|
1393
1030
|
const pending = this.pendingGuardianWarning;
|
|
1394
1031
|
if (!pending) return;
|
|
@@ -1445,20 +1082,27 @@ var CodexEventProjection = class {
|
|
|
1445
1082
|
emitStandardItemEvent(params) {
|
|
1446
1083
|
const { item } = params;
|
|
1447
1084
|
if (!item) return;
|
|
1448
|
-
const
|
|
1085
|
+
const activity = item.type === "subAgentActivity";
|
|
1086
|
+
if (activity && params.phase === "start") return;
|
|
1087
|
+
const subagent = activity || item.type === "collabAgentToolCall";
|
|
1088
|
+
const kind = subagent ? "tool" : itemKind(item);
|
|
1449
1089
|
if (!kind) return;
|
|
1450
|
-
const name = itemName(item);
|
|
1451
|
-
const
|
|
1452
|
-
const
|
|
1090
|
+
const name = subagent ? "subagents" : itemName(item);
|
|
1091
|
+
const args = itemToolArgs(item);
|
|
1092
|
+
const commandBearing = isCommandBearingToolItem(item, args);
|
|
1093
|
+
const subagentStatus = readStringField(item, activity ? "kind" : "status");
|
|
1094
|
+
const interaction = activity && subagentStatus === "interacted";
|
|
1095
|
+
const status = subagent && subagentStatus === "interrupted" ? "failed" : activity ? subagentStatus === "completed" || interaction ? "completed" : "running" : params.phase === "start" ? "running" : itemStatus(item);
|
|
1096
|
+
const meta = subagent ? [interaction ? "message sent" : activity ? subagentStatus : status, readStringField(item, activity ? "agentPath" : "tool")].filter(Boolean).join(": ") : itemMeta(item, this.toolProgress.toolProgressDetailMode());
|
|
1453
1097
|
const suppressChannelProgress = shouldSuppressChannelProgressForItem(item);
|
|
1454
1098
|
this.emitAgentEvent({
|
|
1455
1099
|
stream: "item",
|
|
1456
1100
|
data: {
|
|
1457
|
-
itemId: item.id,
|
|
1101
|
+
itemId: activity && !interaction ? `subagent:${readStringField(item, "agentThreadId") ?? item.id}` : item.id,
|
|
1458
1102
|
phase: params.phase,
|
|
1459
1103
|
kind,
|
|
1460
1104
|
title: itemTitle(item),
|
|
1461
|
-
status
|
|
1105
|
+
status,
|
|
1462
1106
|
...name ? { name } : {},
|
|
1463
1107
|
...meta ? { meta } : {},
|
|
1464
1108
|
...commandBearing ? { commandBearing: true } : {},
|
|
@@ -1466,6 +1110,31 @@ var CodexEventProjection = class {
|
|
|
1466
1110
|
}
|
|
1467
1111
|
});
|
|
1468
1112
|
}
|
|
1113
|
+
async emitSnapshotOnlyNativeToolProgress(params) {
|
|
1114
|
+
const { item, activeItemIds, completedItemIds, isActive } = params;
|
|
1115
|
+
if (!shouldSynthesizeToolProgressForItem(item) || !matchesCodexSnapshotTurn(item, this.turnId) || completedItemIds.has(item.id) || itemStatus(item) === "running") return;
|
|
1116
|
+
if (!activeItemIds.has(item.id)) {
|
|
1117
|
+
this.emitStandardItemEvent({
|
|
1118
|
+
phase: "start",
|
|
1119
|
+
item
|
|
1120
|
+
});
|
|
1121
|
+
await this.emitNormalizedToolItemEvent({
|
|
1122
|
+
phase: "start",
|
|
1123
|
+
item
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
if (!isActive()) return;
|
|
1127
|
+
activeItemIds.delete(item.id);
|
|
1128
|
+
this.emitStandardItemEvent({
|
|
1129
|
+
phase: "end",
|
|
1130
|
+
item
|
|
1131
|
+
});
|
|
1132
|
+
await this.emitNormalizedToolItemEvent({
|
|
1133
|
+
phase: "result",
|
|
1134
|
+
item
|
|
1135
|
+
});
|
|
1136
|
+
completedItemIds.add(item.id);
|
|
1137
|
+
}
|
|
1469
1138
|
async emitNormalizedToolItemEvent(params) {
|
|
1470
1139
|
const projection = projectNormalizedToolItem({
|
|
1471
1140
|
...params,
|
|
@@ -1517,10 +1186,10 @@ function extractCodexNativeSubagentCompletions(notification) {
|
|
|
1517
1186
|
if (!params) return [];
|
|
1518
1187
|
const item = isJsonObject(params.item) ? params.item : void 0;
|
|
1519
1188
|
if (!item) return [];
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
return extractCodexNativeSubagentCompletionsFromText(text).filter((completion) => completion.agentPath === author);
|
|
1189
|
+
const communication = readTrustedInterAgentCommunication(item);
|
|
1190
|
+
const text = communication?.content;
|
|
1191
|
+
if (typeof text !== "string" || !text) return [];
|
|
1192
|
+
return extractCodexNativeSubagentCompletionsFromText(text).filter((completion) => completion.agentPath === communication?.author);
|
|
1524
1193
|
}
|
|
1525
1194
|
/** Parses one or more tagged subagent completion payloads from commentary text. */
|
|
1526
1195
|
function extractCodexNativeSubagentCompletionsFromText(text) {
|
|
@@ -1609,18 +1278,10 @@ function stringifyResult(value, status) {
|
|
|
1609
1278
|
}
|
|
1610
1279
|
function completedWithoutFinalAssistantMessage() {
|
|
1611
1280
|
return {
|
|
1612
|
-
text: "
|
|
1281
|
+
text: "Subagent completed without a final assistant message.",
|
|
1613
1282
|
kind: "no_final_assistant_message"
|
|
1614
1283
|
};
|
|
1615
1284
|
}
|
|
1616
|
-
function readTrustedInterAgentCommunicationContent(item) {
|
|
1617
|
-
const communication = readTrustedInterAgentCommunication(item);
|
|
1618
|
-
return typeof communication?.content === "string" ? communication.content : void 0;
|
|
1619
|
-
}
|
|
1620
|
-
function readTrustedInterAgentCommunicationAuthor(item) {
|
|
1621
|
-
const communication = readTrustedInterAgentCommunication(item);
|
|
1622
|
-
return typeof communication?.author === "string" ? communication.author : void 0;
|
|
1623
|
-
}
|
|
1624
1285
|
function readTrustedInterAgentCommunication(item) {
|
|
1625
1286
|
if (readStringField(item, "type") !== "message" || readStringField(item, "role") !== "assistant" || readStringField(item, "phase") !== "commentary") return;
|
|
1626
1287
|
const text = extractSingleTextPart(item);
|
|
@@ -1648,18 +1309,6 @@ function normalizeStatusKey(value) {
|
|
|
1648
1309
|
return value.replace(/[^a-z0-9]/giu, "").toLowerCase();
|
|
1649
1310
|
}
|
|
1650
1311
|
//#endregion
|
|
1651
|
-
//#region extensions/codex/src/app-server/native-subagent-task-ids.ts
|
|
1652
|
-
/**
|
|
1653
|
-
* Shared identifiers for representing Codex native subagents as OpenClaw task
|
|
1654
|
-
* runtime rows.
|
|
1655
|
-
*/
|
|
1656
|
-
/** Task runtime namespace for Codex native subagent task rows. */
|
|
1657
|
-
const CODEX_NATIVE_SUBAGENT_RUNTIME = "subagent";
|
|
1658
|
-
/** Task kind used to distinguish native Codex subagents from other subagent runtimes. */
|
|
1659
|
-
const CODEX_NATIVE_SUBAGENT_TASK_KIND = "codex-native";
|
|
1660
|
-
/** Run id prefix for task rows keyed by Codex child thread ids. */
|
|
1661
|
-
const CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX = "codex-thread:";
|
|
1662
|
-
//#endregion
|
|
1663
1312
|
//#region extensions/codex/src/app-server/native-subagent-task-mirror.ts
|
|
1664
1313
|
/** Projects Codex thread and collab-agent notifications into task lifecycle updates. */
|
|
1665
1314
|
var CodexNativeSubagentTaskMirror = class {
|
|
@@ -1707,15 +1356,15 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1707
1356
|
const spawn = readSubagentThreadSpawnSource(thread.source, this.params.parentThreadId);
|
|
1708
1357
|
if (!spawn) return;
|
|
1709
1358
|
const threadId = thread.id.trim();
|
|
1710
|
-
const label = normalizeOptionalString(spawn.agent_nickname) ?? normalizeOptionalString(thread.agentNickname) ?? normalizeOptionalString(spawn.agent_role) ?? normalizeOptionalString(thread.agentRole) ?? "
|
|
1711
|
-
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}`}`;
|
|
1712
1361
|
const createdAt = secondsToMillis(thread.createdAt) ?? this.now();
|
|
1713
1362
|
if (!this.createRunningTask({
|
|
1714
1363
|
threadId,
|
|
1715
1364
|
label,
|
|
1716
1365
|
task,
|
|
1717
1366
|
startedAt: createdAt,
|
|
1718
|
-
progressSummary: "
|
|
1367
|
+
progressSummary: "Subagent started."
|
|
1719
1368
|
})) return;
|
|
1720
1369
|
this.applyStatus(threadId, thread.status);
|
|
1721
1370
|
}
|
|
@@ -1736,7 +1385,7 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1736
1385
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1737
1386
|
runId,
|
|
1738
1387
|
lastEventAt: eventAt,
|
|
1739
|
-
progressSummary: "
|
|
1388
|
+
progressSummary: "Subagent is active."
|
|
1740
1389
|
});
|
|
1741
1390
|
return;
|
|
1742
1391
|
}
|
|
@@ -1744,7 +1393,7 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1744
1393
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1745
1394
|
runId,
|
|
1746
1395
|
lastEventAt: eventAt,
|
|
1747
|
-
progressSummary: "
|
|
1396
|
+
progressSummary: "Subagent is idle."
|
|
1748
1397
|
});
|
|
1749
1398
|
return;
|
|
1750
1399
|
}
|
|
@@ -1754,7 +1403,7 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1754
1403
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1755
1404
|
runId,
|
|
1756
1405
|
lastEventAt: eventAt,
|
|
1757
|
-
progressSummary: "
|
|
1406
|
+
progressSummary: "Subagent hit a system error; awaiting recovery."
|
|
1758
1407
|
});
|
|
1759
1408
|
return;
|
|
1760
1409
|
}
|
|
@@ -1764,16 +1413,16 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1764
1413
|
status: "failed",
|
|
1765
1414
|
endedAt: eventAt,
|
|
1766
1415
|
lastEventAt: eventAt,
|
|
1767
|
-
error: "
|
|
1768
|
-
progressSummary: "
|
|
1769
|
-
terminalSummary: "
|
|
1416
|
+
error: "Subagent encountered a system error.",
|
|
1417
|
+
progressSummary: "Subagent hit a system error.",
|
|
1418
|
+
terminalSummary: "Subagent failed."
|
|
1770
1419
|
});
|
|
1771
1420
|
return;
|
|
1772
1421
|
}
|
|
1773
1422
|
if (statusType === "notLoaded") this.runtime.recordTaskRunProgressByRunId({
|
|
1774
1423
|
runId,
|
|
1775
1424
|
lastEventAt: eventAt,
|
|
1776
|
-
progressSummary: "
|
|
1425
|
+
progressSummary: "Subagent is not loaded."
|
|
1777
1426
|
});
|
|
1778
1427
|
}
|
|
1779
1428
|
handleCollabAgentItem(params) {
|
|
@@ -1815,17 +1464,17 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1815
1464
|
return;
|
|
1816
1465
|
}
|
|
1817
1466
|
if (this.mirrorStateByThreadId.get(threadId) !== "mirrored") return;
|
|
1818
|
-
const message = kind === "interacted" ? "
|
|
1467
|
+
const message = kind === "interacted" ? "Subagent received more input." : "Subagent was interrupted.";
|
|
1819
1468
|
this.applyCollabAgentStatus(threadId, kind === "interacted" ? "running" : "interrupted", message);
|
|
1820
1469
|
}
|
|
1821
1470
|
createTaskFromSubagentActivity(threadId, agentPath) {
|
|
1822
1471
|
const eventAt = this.now();
|
|
1823
1472
|
this.createRunningTask({
|
|
1824
1473
|
threadId,
|
|
1825
|
-
label: "
|
|
1826
|
-
task: agentPath ? `
|
|
1474
|
+
label: "Subagent",
|
|
1475
|
+
task: agentPath ? `Subagent ${agentPath}` : "Subagent",
|
|
1827
1476
|
startedAt: eventAt,
|
|
1828
|
-
progressSummary: "
|
|
1477
|
+
progressSummary: "Subagent started."
|
|
1829
1478
|
});
|
|
1830
1479
|
}
|
|
1831
1480
|
createTaskFromCollabSpawnItem(threadId, item) {
|
|
@@ -1833,10 +1482,10 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1833
1482
|
const createdAt = this.now();
|
|
1834
1483
|
this.createRunningTask({
|
|
1835
1484
|
threadId,
|
|
1836
|
-
label: "
|
|
1837
|
-
task: prompt ?? "
|
|
1485
|
+
label: "Subagent",
|
|
1486
|
+
task: prompt ?? "Subagent",
|
|
1838
1487
|
startedAt: createdAt,
|
|
1839
|
-
progressSummary: "
|
|
1488
|
+
progressSummary: "Subagent spawned."
|
|
1840
1489
|
});
|
|
1841
1490
|
}
|
|
1842
1491
|
createRunningTask(params) {
|
|
@@ -1844,6 +1493,8 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1844
1493
|
if (!threadId || this.mirrorStateByThreadId.get(threadId) === "mirrored") return false;
|
|
1845
1494
|
this.mirrorStateByThreadId.set(threadId, "mirrored");
|
|
1846
1495
|
const runId = codexNativeSubagentRunId(threadId);
|
|
1496
|
+
const historyOwner = this.params.historyOwner;
|
|
1497
|
+
const stampHistoryOwner = historyOwner && !this.runtime.listTaskRecords().some((task) => task.runId === runId);
|
|
1847
1498
|
if (!this.runtime.tryCreateRunningTaskRun({
|
|
1848
1499
|
sourceId: runId,
|
|
1849
1500
|
agentId: this.params.agentId,
|
|
@@ -1855,7 +1506,8 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1855
1506
|
preferMetadata: true,
|
|
1856
1507
|
startedAt: params.startedAt,
|
|
1857
1508
|
lastEventAt: this.now(),
|
|
1858
|
-
progressSummary: params.progressSummary
|
|
1509
|
+
progressSummary: params.progressSummary,
|
|
1510
|
+
...stampHistoryOwner ? { detail: { nativeHistory: { ...historyOwner } } } : {}
|
|
1859
1511
|
})) {
|
|
1860
1512
|
this.mirrorStateByThreadId.set(threadId, "failed");
|
|
1861
1513
|
return false;
|
|
@@ -1876,13 +1528,13 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1876
1528
|
this.runtime.recordTaskRunProgressByRunId({
|
|
1877
1529
|
runId,
|
|
1878
1530
|
lastEventAt: eventAt,
|
|
1879
|
-
progressSummary: normalizeOptionalString(message) ?? (normalizedStatus === "pendingInit" ? "
|
|
1531
|
+
progressSummary: normalizeOptionalString(message) ?? (normalizedStatus === "pendingInit" ? "Subagent is initializing." : normalizedStatus === "interrupted" ? "Subagent was interrupted." : "Subagent is running.")
|
|
1880
1532
|
});
|
|
1881
1533
|
return;
|
|
1882
1534
|
}
|
|
1883
1535
|
if (normalizedStatus === "completed") {
|
|
1884
1536
|
this.terminalRunIds.add(runId);
|
|
1885
|
-
const summary = normalizeOptionalString(message) ?? "
|
|
1537
|
+
const summary = normalizeOptionalString(message) ?? "Subagent completed.";
|
|
1886
1538
|
if (this.expectedAuthoritativeRunIds.has(runId)) this.runtime.recordTaskRunProgressByRunId({
|
|
1887
1539
|
runId,
|
|
1888
1540
|
lastEventAt: eventAt,
|
|
@@ -1905,8 +1557,8 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1905
1557
|
status: "succeeded",
|
|
1906
1558
|
endedAt: eventAt,
|
|
1907
1559
|
lastEventAt: eventAt,
|
|
1908
|
-
progressSummary: normalizeOptionalString(message) ?? "
|
|
1909
|
-
terminalSummary: normalizeOptionalString(message) ?? "
|
|
1560
|
+
progressSummary: normalizeOptionalString(message) ?? "Subagent blocked.",
|
|
1561
|
+
terminalSummary: normalizeOptionalString(message) ?? "Subagent blocked.",
|
|
1910
1562
|
terminalOutcome: "blocked"
|
|
1911
1563
|
});
|
|
1912
1564
|
return;
|
|
@@ -1917,9 +1569,9 @@ var CodexNativeSubagentTaskMirror = class {
|
|
|
1917
1569
|
status: normalizedStatus === "shutdown" ? "cancelled" : "failed",
|
|
1918
1570
|
endedAt: eventAt,
|
|
1919
1571
|
lastEventAt: eventAt,
|
|
1920
|
-
error: normalizeOptionalString(message) ?? `
|
|
1921
|
-
progressSummary: normalizeOptionalString(message) ?? `
|
|
1922
|
-
terminalSummary: normalizeOptionalString(message) ?? "
|
|
1572
|
+
error: normalizeOptionalString(message) ?? `Subagent status: ${normalizedStatus}`,
|
|
1573
|
+
progressSummary: normalizeOptionalString(message) ?? `Subagent ${normalizedStatus}.`,
|
|
1574
|
+
terminalSummary: normalizeOptionalString(message) ?? "Subagent did not complete."
|
|
1923
1575
|
});
|
|
1924
1576
|
}
|
|
1925
1577
|
};
|
|
@@ -2102,6 +1754,7 @@ function registerMonitor(params) {
|
|
|
2102
1754
|
parentThreadId: params.parentThreadId,
|
|
2103
1755
|
requesterSessionKey: params.requesterSessionKey,
|
|
2104
1756
|
taskRuntimeScope: params.taskRuntimeScope,
|
|
1757
|
+
historyOwner: params.historyOwner,
|
|
2105
1758
|
agentId: params.agentId,
|
|
2106
1759
|
claimDirectChild: params.claimDirectChild,
|
|
2107
1760
|
rejectPendingDirectChild: params.rejectPendingDirectChild,
|
|
@@ -2180,6 +1833,7 @@ var Monitor = class {
|
|
|
2180
1833
|
}
|
|
2181
1834
|
state.requesterSessionKey ??= params.requesterSessionKey;
|
|
2182
1835
|
state.taskRuntimeScope ??= params.taskRuntimeScope;
|
|
1836
|
+
state.historyOwner ??= params.historyOwner;
|
|
2183
1837
|
state.agentId ??= params.agentId;
|
|
2184
1838
|
const owner = Symbol("codex-native-subagent-owner");
|
|
2185
1839
|
state.owners.set(owner, {
|
|
@@ -2234,7 +1888,7 @@ var Monitor = class {
|
|
|
2234
1888
|
this.retiredParentStates.add(state);
|
|
2235
1889
|
state.owners.clear();
|
|
2236
1890
|
this.clearPendingDirectSpawnEvidenceForParent(parentThreadId);
|
|
2237
|
-
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.");
|
|
2238
1892
|
if (this.parentStates.get(parentThreadId) === state) this.parentStates.delete(parentThreadId);
|
|
2239
1893
|
}
|
|
2240
1894
|
prepareParentTaskRuntime(state) {
|
|
@@ -2248,6 +1902,7 @@ var Monitor = class {
|
|
|
2248
1902
|
state.mirror ??= new CodexNativeSubagentTaskMirror({
|
|
2249
1903
|
parentThreadId: state.parentThreadId,
|
|
2250
1904
|
requesterSessionKey: state.requesterSessionKey,
|
|
1905
|
+
historyOwner: state.historyOwner,
|
|
2251
1906
|
agentId: state.agentId
|
|
2252
1907
|
}, state.taskRuntime);
|
|
2253
1908
|
}
|
|
@@ -2512,7 +2167,7 @@ var Monitor = class {
|
|
|
2512
2167
|
for (const childThreadId of childThreadIds) {
|
|
2513
2168
|
const childState = this.childStates.get(childThreadId);
|
|
2514
2169
|
if (childState && childState.parentThreadId !== state.parentThreadId) continue;
|
|
2515
|
-
if (childState) this.retireChild(state, childState, "
|
|
2170
|
+
if (childState) this.retireChild(state, childState, "Subagent was closed.");
|
|
2516
2171
|
else this.updateChildThreadOwnership("release", childThreadId, this.releaseChildThread);
|
|
2517
2172
|
}
|
|
2518
2173
|
}
|
|
@@ -2718,8 +2373,8 @@ var Monitor = class {
|
|
|
2718
2373
|
childSessionKey: codexNativeSubagentRunId(completion.childThreadId),
|
|
2719
2374
|
childSessionId: completion.childThreadId,
|
|
2720
2375
|
announceId: `codex-native:${state.parentThreadId}:${completion.childThreadId}:${completion.status}`,
|
|
2721
|
-
announceType: "
|
|
2722
|
-
taskLabel: "
|
|
2376
|
+
announceType: "Subagent",
|
|
2377
|
+
taskLabel: "Subagent",
|
|
2723
2378
|
status: completion.status,
|
|
2724
2379
|
statusLabel: completion.statusLabel,
|
|
2725
2380
|
result: completion.result,
|
|
@@ -3061,7 +2716,7 @@ var Monitor = class {
|
|
|
3061
2716
|
const candidates = /* @__PURE__ */ new Map();
|
|
3062
2717
|
for (const task of state.taskRuntime.listTaskRecords()) {
|
|
3063
2718
|
if (task.requesterSessionKey !== state.requesterSessionKey || !this.shouldReconcileCodexNativeTask(task)) continue;
|
|
3064
|
-
const childThreadId = task.runId.slice(
|
|
2719
|
+
const childThreadId = task.runId.slice(CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX.length).trim();
|
|
3065
2720
|
candidates.set(childThreadId, {
|
|
3066
2721
|
parentState: state,
|
|
3067
2722
|
nativeCompletionReceipts: state.nativeCompletionReceipts,
|
|
@@ -3222,14 +2877,14 @@ function toChildTurnCompletion(childState, turn) {
|
|
|
3222
2877
|
childThreadId: childState.childThreadId,
|
|
3223
2878
|
status: "succeeded",
|
|
3224
2879
|
statusLabel: result ? "turn_completed" : "completed_without_final_message",
|
|
3225
|
-
result: result ?? "
|
|
2880
|
+
result: result ?? "Subagent completed without a final assistant message."
|
|
3226
2881
|
};
|
|
3227
2882
|
}
|
|
3228
2883
|
if (status === "failed") return {
|
|
3229
2884
|
childThreadId: childState.childThreadId,
|
|
3230
2885
|
status: "failed",
|
|
3231
2886
|
statusLabel: "turn_failed",
|
|
3232
|
-
result: readTurnErrorMessage(turn) ?? "
|
|
2887
|
+
result: readTurnErrorMessage(turn) ?? "Subagent failed."
|
|
3233
2888
|
};
|
|
3234
2889
|
}
|
|
3235
2890
|
function lastChildAssistantMessage(childState, turnId) {
|
|
@@ -3249,7 +2904,7 @@ function systemErrorFallbackCompletion(childThreadId) {
|
|
|
3249
2904
|
childThreadId,
|
|
3250
2905
|
status: "failed",
|
|
3251
2906
|
statusLabel: "system_error",
|
|
3252
|
-
result: "
|
|
2907
|
+
result: "Subagent runtime reported a system error."
|
|
3253
2908
|
};
|
|
3254
2909
|
}
|
|
3255
2910
|
function readTurnCompletion(turn, childThreadId) {
|
|
@@ -3262,7 +2917,7 @@ function readTurnCompletion(turn, childThreadId) {
|
|
|
3262
2917
|
childThreadId,
|
|
3263
2918
|
status: "succeeded",
|
|
3264
2919
|
statusLabel: result ? "task_complete" : "completed_without_final_message",
|
|
3265
|
-
result: result ?? "
|
|
2920
|
+
result: result ?? "Subagent completed without a final assistant message.",
|
|
3266
2921
|
completedAt
|
|
3267
2922
|
};
|
|
3268
2923
|
if (status === "interrupted") return;
|
|
@@ -3270,7 +2925,7 @@ function readTurnCompletion(turn, childThreadId) {
|
|
|
3270
2925
|
childThreadId,
|
|
3271
2926
|
status: "failed",
|
|
3272
2927
|
statusLabel: "task_failed",
|
|
3273
|
-
result: readTurnErrorMessage(turn) ?? result ?? "
|
|
2928
|
+
result: readTurnErrorMessage(turn) ?? result ?? "Subagent failed.",
|
|
3274
2929
|
completedAt
|
|
3275
2930
|
};
|
|
3276
2931
|
}
|
|
@@ -3320,4 +2975,4 @@ function unrefTimer(timer) {
|
|
|
3320
2975
|
if (typeof timer === "object" && timer && "unref" in timer) timer.unref();
|
|
3321
2976
|
}
|
|
3322
2977
|
//#endregion
|
|
3323
|
-
export { CodexToolProgressProjection as a,
|
|
2978
|
+
export { CodexToolProgressProjection as a, CodexToolTranscriptProjection as i, CodexEventProjection as n, shouldEmitTranscriptToolProgress as o, emitCodexAgentEvent as r, codexNativeSubagentMonitorRuntime as t };
|