@openclaw/codex 2026.9.4 → 2026.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/activity.svg +30 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/account-usage-runtime-Eem_WGqY.mjs +75 -0
- package/dist/{apply-CvT8tW5i.js → .setup/apply-DDOi8uNx.mjs} +24 -30
- package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
- package/dist/{attempt-client-cleanup-DKHzbwt5.js → .setup/attempt-client-cleanup-CEv1cKwF.mjs} +79 -49
- package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
- package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +331 -0
- package/dist/{auth-binding-CWlKVccJ.js → .setup/auth-binding-DhLWa_7K.mjs} +1 -1
- package/dist/{auth-cache-key-7orQae_j.js → .setup/auth-cache-key-B2mpaI9D.mjs} +9 -81
- package/dist/{auth-profile-CwzO4_RG.js → .setup/auth-profile-WqZtZfXN.mjs} +1 -1
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/binding-connection-ThoatDcb.mjs +50 -0
- package/dist/.setup/binding-connection.runtime-yoHrABt-.mjs +48 -0
- package/dist/{bounded-turn-C_Hneydj.js → .setup/bounded-turn-B2HScEgT.mjs} +143 -32
- package/dist/{build-state-BCmg9-5p.js → .setup/build-state-C7EnDVgr.mjs} +1 -1
- package/dist/{capabilities-8vx68WLH.js → .setup/capabilities-CDXOOFdZ.mjs} +1 -1
- package/dist/{client-B57KWPQx.js → .setup/client-Cs08OXVQ.mjs} +705 -512
- package/dist/.setup/client-catalog-response-BMgt_4q4.mjs +285 -0
- package/dist/{command-dispatch-BpduNGVf.js → .setup/command-dispatch-B4JuOsOk.mjs} +8 -4
- package/dist/{command-formatters-lxlkNZgU.js → .setup/command-formatters-Bmqvr9tO.mjs} +8 -4
- package/dist/{command-handlers-tiL9iWj7.js → .setup/command-handlers-DW7Lx9oH.mjs} +137 -186
- package/dist/{command-rpc-CR5EOEZX.js → .setup/command-rpc-DixIj3HW.mjs} +47 -23
- package/dist/{compact-B_H3AOd7.js → .setup/compact-Du5UvtxA.mjs} +29 -51
- package/dist/{config-oIORaQ5T.js → .setup/config-BoTP_mrL.mjs} +5 -4
- package/dist/{config-options-CXMq1T-C.js → .setup/config-options-BvaRs51b.mjs} +50 -446
- package/dist/{protocol-5bh1G-H7.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
- package/dist/{config-runtime-D0zGNIHu.js → .setup/config-runtime-C8Rw1m1m.mjs} +2 -2
- package/dist/.setup/config-security-BEReZ6go.mjs +380 -0
- package/dist/{conversation-binding-DsB4-O7U.js → .setup/conversation-binding-DP-gMrBP.mjs} +29 -38
- package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
- package/dist/{conversation-control-CtUu1b3m.js → .setup/conversation-control-uK9Jomlc.mjs} +32 -67
- package/dist/.setup/cyber-failover-DYwbmf1o.mjs +123 -0
- package/dist/.setup/cyber-failover-notice-e9G3J9-e.mjs +17 -0
- package/dist/{dynamic-tools-CmN5RAip.js → .setup/dynamic-tools-BDXl-8Cw.mjs} +936 -620
- package/dist/{effective-mcp-catalog-Bd73bqA8.js → .setup/effective-mcp-catalog-CvnvnGIe.mjs} +3 -3
- package/dist/{ephemeral-turn-D78_VmzO.js → .setup/ephemeral-turn-poidXgek.mjs} +9 -7
- package/dist/{event-projector-assistant-message-BmBM4qBV.js → .setup/event-projector-assistant-message-BsruvNrH.mjs} +8 -7
- package/dist/{event-projector-items-5VhsECCO.js → .setup/event-projector-items-C6L_5ZiT.mjs} +42 -8
- package/dist/{attempt-notifications-C9XufG6l.js → .setup/event-projector-usage-CnBS8Wa3.mjs} +102 -9
- package/dist/{harness-C7rRa7bm.js → .setup/harness-a_MsE4-_.mjs} +81 -21
- package/dist/{inference-context-Dr_mzvk4.js → .setup/inference-context-D96l9-ew.mjs} +1 -1
- package/dist/.setup/inference-proxy-b-aJMSxm.mjs +601 -0
- package/dist/{isolated-completion-DWVb5U2J.js → .setup/isolated-completion-BIZFhTNG.mjs} +18 -11
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/{managed-binary-D22rNEcR.js → .setup/managed-binary-BnshlFag.mjs} +14 -3
- package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
- package/dist/{model-catalog-Dq2n8f_p.js → .setup/model-catalog-CfXJf9Ay.mjs} +36 -12
- package/dist/{models-PCKOim-h.js → .setup/models-KnqBv0hE.mjs} +3 -3
- package/dist/.setup/native-auth-rWbGbMn3.mjs +57 -0
- package/dist/{native-subagent-history-DjtPloaU.js → .setup/native-subagent-history-0nYYgo0k.mjs} +43 -35
- package/dist/.setup/native-subagent-monitor-D3filLY2.mjs +4859 -0
- package/dist/{native-subagent-task-ids-BzTdT0Uw.js → .setup/native-subagent-task-ids-wb8CKZGN.mjs} +98 -44
- package/dist/{node-cli-sessions-DKaOmVUh.js → .setup/node-cli-sessions-r3avj02l.mjs} +86 -68
- package/dist/.setup/node-exec-server.runtime-BDwWXVpK.mjs +247 -0
- package/dist/{plan-7uG-Fp36.js → .setup/plan-CN3VwfNU.mjs} +133 -119
- package/dist/{plugin-activation-BYQculil.js → .setup/plugin-activation-DT3MNtqj.mjs} +7 -16
- package/dist/{plugin-app-cache-key-d0eKxy7b.js → .setup/plugin-app-cache-key-B2CsSdnV.mjs} +32 -44
- package/dist/{plugin-approval-roundtrip-Bz3FT8W5.js → .setup/plugin-approval-roundtrip-C0MZzCuP.mjs} +1 -1
- package/dist/{plugin-inventory-oL4Na1ZG.js → .setup/plugin-inventory-BoRei8Z4.mjs} +21 -11
- package/dist/{plugin-marketplace-discovery-P-Vndfqq.js → .setup/plugin-marketplace-discovery-CDOi8IFs.mjs} +4 -1
- package/dist/{plugin-metadata-cache-ClPJpRio.js → .setup/plugin-metadata-cache-Ctmo83k_.mjs} +226 -141
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/{provider-MQ8PVkuE.js → .setup/provider-BOsxQHOM.mjs} +9 -5
- package/dist/{provider-capabilities-BvCUL69A.js → .setup/provider-capabilities-BfE88FZ5.mjs} +31 -3
- package/dist/{rate-limits-CBMmWBr9.js → .setup/rate-limits-CMU3DUD0.mjs} +174 -151
- package/dist/{request-B7hEkBGq.js → .setup/request-D2L0zMrq.mjs} +130 -42
- package/dist/{run-attempt-CvsAAGa0.js → .setup/run-attempt-BHu11r7h.mjs} +1628 -966
- package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
- package/dist/{runtime-artifact-BJ0rXBZ_.js → .setup/runtime-artifact-CLZ8udh-.mjs} +29 -45
- package/dist/{sandbox-guard-BxgyoM8M.js → .setup/sandbox-guard-C2sRMOEY.mjs} +3 -3
- package/dist/{session-binding-CI8UuilT.js → .setup/session-binding-Cm0apEbd.mjs} +36 -83
- package/dist/{session-binding-record-Bcvslnhf.js → .setup/session-binding-record-BGoz8wOK.mjs} +202 -5
- package/dist/.setup/session-binding-sidecars-BlB5EvIS.mjs +546 -0
- package/dist/.setup/session-catalog-Pno1xGcl.mjs +2764 -0
- package/dist/{session-catalog-adoption-tcZi1IfX.js → .setup/session-catalog-adoption-BI6UTDZT.mjs} +58 -26
- package/dist/{session-catalog-archive-CwKg8Xz2.js → .setup/session-catalog-archive-lHBqzhaO.mjs} +6 -6
- package/dist/.setup/session-catalog-events-Bj6j94E_.mjs +347 -0
- package/dist/.setup/session-catalog-index-B9_VQIUz.mjs +1170 -0
- package/dist/.setup/session-catalog-index-order-hcdz07yN.mjs +48 -0
- package/dist/.setup/session-catalog-index-state-Dgh8ORJm.mjs +183 -0
- package/dist/{thread-history-page-D0JIp48V.js → .setup/session-catalog-native-projection-DowriLid.mjs} +223 -95
- package/dist/{session-catalog-node-adoption-B1tgDW-m.js → .setup/session-catalog-node-adoption-ITddWx_X.mjs} +25 -13
- package/dist/{session-catalog-node-continue-Ci-DXyJP.js → .setup/session-catalog-node-continue-6g6qi4A9.mjs} +24 -15
- package/dist/.setup/session-catalog-projection-zK_PUsiE.mjs +422 -0
- package/dist/{session-cli-DNN_jhGc.js → .setup/session-cli-irrD-uo7.mjs} +3 -3
- package/dist/{session-history-Cz-tOOYj.js → .setup/session-history-BrqhSCf9.mjs} +19 -19
- package/dist/{session-history-import-DwyijFI6.js → .setup/session-history-import-D-3wAgOP.mjs} +4 -4
- package/dist/{session-history-read-cxPUxyVV.js → .setup/session-history-read-B3ZfSUbF.mjs} +2 -2
- package/dist/{session-history.worker-BeK1YOyT.js → .setup/session-history.worker-CaCh0xF_.mjs} +10 -24
- package/dist/{session-initialization-Ct0_Hzmg.js → .setup/session-initialization-rcgbZiid.mjs} +2 -2
- package/dist/{session-permission-policy-BBmXA8Eg.js → .setup/session-permission-policy-BI1QK_98.mjs} +2 -2
- package/dist/{session-retirement-B2YfbAAT.js → .setup/session-retirement-BH-S6qkJ.mjs} +26 -7
- package/dist/{settled-turn-context-Du6gdUDd.js → .setup/settled-turn-context-fmwouT5I.mjs} +2 -2
- package/dist/{settled-turn-finalizer-Dn91stmc.js → .setup/settled-turn-finalizer-DiAi6Kx6.mjs} +12 -12
- package/dist/{shared-client-CscigXXL.js → .setup/shared-client-DA4VR4Eb.mjs} +332 -221
- package/dist/{side-question-BGMJQf4U.js → .setup/side-question-BJ1wSDcB.mjs} +183 -230
- package/dist/{source-CElXU0Oy.js → .setup/source-CUzJq5WN.mjs} +11 -10
- package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
- package/dist/{thread-archive-guard-DfpBr-Sz.js → .setup/thread-archive-guard-C9frICzX.mjs} +10 -3
- package/dist/.setup/thread-history-page-DoVpnHim.mjs +83 -0
- package/dist/{thread-lifecycle-DXl1-I6b.js → .setup/thread-lifecycle-B3mfz1TG.mjs} +347 -2318
- package/dist/{thread-ownership-BsDRTsyp.js → .setup/thread-ownership-DcTtAcXj.mjs} +6 -4
- package/dist/{thread-policy-BuEQfE0g.js → .setup/thread-policy-DGuQsuFC.mjs} +19 -3
- package/dist/.setup/thread-requests-BLvGkP2R.mjs +2205 -0
- package/dist/{thread-resume-DsDOZpFg.js → .setup/thread-resume-DIBXwOpE.mjs} +8 -5
- package/dist/.setup/timeout-C910MdAB.mjs +80 -0
- package/dist/{transcript-history-projection-v17wXgdK.js → .setup/transcript-history-projection-ZZpkFkJ_.mjs} +96 -61
- package/dist/{transcript-mirror-C5CKgNy6.js → .setup/transcript-mirror-BtHDBp1G.mjs} +224 -195
- package/dist/{transcript-mirror-attestation-DibE0krH.js → .setup/transcript-mirror-attestation-CzM-94NC.mjs} +4 -1
- package/dist/{transport-stdio-BGjHoYLr.js → .setup/transport-stdio-h2VHOskC.mjs} +274 -89
- package/dist/{upstream-session-fork-BZerMte_.js → .setup/upstream-session-fork-BUr4OUbC.mjs} +51 -42
- package/dist/{usage-tCk-mg_x.js → .setup/usage-BML0r-ua.mjs} +5 -4
- package/dist/.setup/usage-limit-error-DUMbefVY.mjs +166 -0
- package/dist/{web-search-provider.runtime-B7bGbGWq.js → .setup/web-search-provider.runtime-CDKlN-Rv.mjs} +4 -3
- package/dist/api.js +23 -12
- package/dist/catalog-page-worker-entrypoint.js +12 -0
- package/dist/catalog-page.worker.js +9 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +8 -528
- package/dist/harness.js +1 -1
- package/dist/index.js +306 -215
- package/dist/media-understanding-provider.js +3 -3
- package/dist/migration-provider-api.js +1 -1
- package/dist/native-tool-policy.js +12 -0
- package/dist/provider-discovery.js +18 -0
- package/dist/session-history-worker-runtime.js +36 -35
- package/dist/session-history.worker.js +2 -2
- package/dist/web-search-contract-api.js +1 -1
- package/openclaw.plugin.json +354 -69
- package/package.json +14 -8
- package/dist/attempt-context-D44yeDII.js +0 -636
- package/dist/binding-connection-D3udKbIE.js +0 -60
- package/dist/event-projector-usage-BfXmpOec.js +0 -102
- package/dist/inference-proxy-HGXKUIre.js +0 -311
- package/dist/launch-args-RXQwn8zV.js +0 -90
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +0 -34
- package/dist/native-subagent-monitor-fQ7eIXEf.js +0 -2978
- package/dist/node-exec-server.runtime-Cl2vapEi.js +0 -226
- package/dist/rpc-error-ttN_QjEm.js +0 -30
- package/dist/session-catalog-ct-AH01I.js +0 -1477
- package/dist/session-catalog-home-id-CwhLdC03.js +0 -18
- package/dist/session-catalog-provenance-D-dIfRAH.js +0 -96
- package/dist/timeout-BVw8aaM1.js +0 -33
- package/dist/version-omm6IPI3.js +0 -12
- /package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
- /package/dist/{config-utils-DujwEnhg.js → .setup/config-utils-DujwEnhg.mjs} +0 -0
- /package/dist/{context-compaction-activity-CMla5FPJ.js → .setup/context-compaction-activity-CMla5FPJ.mjs} +0 -0
- /package/dist/{elicitation-input-DPoK8F7w.js → .setup/elicitation-input-DPoK8F7w.mjs} +0 -0
- /package/dist/{history-rejection-B4nOXNXF.js → .setup/history-rejection-B4nOXNXF.mjs} +0 -0
- /package/dist/{image-payload-sanitizer-tupAr-2o.js → .setup/image-payload-sanitizer-tupAr-2o.mjs} +0 -0
- /package/dist/{incognito-session-uhrBF6wJ.js → .setup/incognito-session-uhrBF6wJ.mjs} +0 -0
- /package/dist/{local-runtime-attribution-B_2mnqhb.js → .setup/local-runtime-attribution-B_2mnqhb.mjs} +0 -0
- /package/dist/{native-execution-policy-umd0tgh4.js → .setup/native-execution-policy-umd0tgh4.mjs} +0 -0
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
- /package/dist/{session-upstream-marker-D15C9NHp.js → .setup/session-upstream-marker-D15C9NHp.mjs} +0 -0
- /package/dist/{upstream-prompt-provenance-LphB8slG.js → .setup/upstream-prompt-provenance-LphB8slG.mjs} +0 -0
- /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
package/dist/{native-subagent-task-ids-BzTdT0Uw.js → .setup/native-subagent-task-ids-wb8CKZGN.mjs}
RENAMED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { asNonArrayRecord, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
1
|
+
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
2
|
+
import { T as readNonEmptyStringArray, c as itemName, h as unknownItemStatus, l as itemStatus, m as shouldSynthesizeToolProgressForItem, t as auditNativeToolName, v as normalizeOptionalString$1, w as readNonEmptyString } from "./event-projector-items-C6L_5ZiT.mjs";
|
|
3
|
+
import { asNonArrayRecord, normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
5
|
-
import { formatToolAggregate, formatToolProgressOutput, inferToolMetaFromArgs } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
6
|
-
import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
5
|
+
import { formatToolAggregate, formatToolProgressOutput, inferToolMetaFromArgs, projectAgentToolActivity, sanitizeToolArgs } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
7
6
|
//#region extensions/codex/src/app-server/event-projector-tool-output.ts
|
|
8
7
|
const TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS = 1e4;
|
|
9
8
|
const TOOL_PROGRESS_ECHO_PREFIX_MIN_CHARS = 1024;
|
|
@@ -16,6 +15,9 @@ var ToolOutputAccumulator = class {
|
|
|
16
15
|
this.truncatedItemIds = /* @__PURE__ */ new Set();
|
|
17
16
|
this.textByItem = /* @__PURE__ */ new Map();
|
|
18
17
|
}
|
|
18
|
+
isTruncated(itemId) {
|
|
19
|
+
return this.truncatedItemIds.has(itemId);
|
|
20
|
+
}
|
|
19
21
|
append(itemId, delta) {
|
|
20
22
|
const originalLength = (this.originalLengthByItem.get(itemId) ?? this.textByItem.get(itemId)?.length ?? 0) + delta.length;
|
|
21
23
|
this.originalLengthByItem.set(itemId, originalLength);
|
|
@@ -74,6 +76,17 @@ function collectDynamicToolContentText(contentItems) {
|
|
|
74
76
|
return text ? [text] : [];
|
|
75
77
|
}).join("\n");
|
|
76
78
|
}
|
|
79
|
+
function readCodexResponseOutput(item) {
|
|
80
|
+
if (typeof item.output === "string") return item.output;
|
|
81
|
+
if (!Array.isArray(item.output)) return;
|
|
82
|
+
return JSON.stringify(item.output.map((part) => isJsonObject(part) && part.type === "input_text" && typeof part.text === "string" ? {
|
|
83
|
+
type: part.type,
|
|
84
|
+
text: part.text
|
|
85
|
+
} : {
|
|
86
|
+
type: isJsonObject(part) ? part.type : "unknown",
|
|
87
|
+
omitted: true
|
|
88
|
+
}), null, 2);
|
|
89
|
+
}
|
|
77
90
|
function appendBoundedToolTranscriptText(currentPrefix, delta, originalLength) {
|
|
78
91
|
if (originalLength <= 1e4) {
|
|
79
92
|
const rawPrefix = currentPrefix + delta;
|
|
@@ -146,26 +159,9 @@ function isCodexCommandBearingToolCall(name, args) {
|
|
|
146
159
|
const normalizedName = name?.trim().toLowerCase();
|
|
147
160
|
return normalizedName === "exec" || normalizedName === "bash" || normalizedName === "shell" || typeof args?.command === "string" && args.command.trim().length > 0;
|
|
148
161
|
}
|
|
149
|
-
/** Recursively redacts sensitive strings and handles circular values in event payloads. */
|
|
150
|
-
function sanitizeCodexAgentEventValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
151
|
-
if (typeof value === "string") return redactToolPayloadText(value);
|
|
152
|
-
if (Array.isArray(value)) {
|
|
153
|
-
if (seen.has(value)) return "[Circular]";
|
|
154
|
-
seen.add(value);
|
|
155
|
-
return value.map((entry) => sanitizeCodexAgentEventValue(entry, seen));
|
|
156
|
-
}
|
|
157
|
-
if (value && typeof value === "object") {
|
|
158
|
-
if (seen.has(value)) return "[Circular]";
|
|
159
|
-
seen.add(value);
|
|
160
|
-
const out = {};
|
|
161
|
-
for (const [key, child] of Object.entries(value)) out[key] = typeof child === "string" ? redactSensitiveFieldValue(key, child) : sanitizeCodexAgentEventValue(child, seen);
|
|
162
|
-
return out;
|
|
163
|
-
}
|
|
164
|
-
return value;
|
|
165
|
-
}
|
|
166
162
|
/** Sanitizes a record-shaped Codex agent event payload. */
|
|
167
163
|
function sanitizeCodexAgentEventRecord(value) {
|
|
168
|
-
return
|
|
164
|
+
return sanitizeToolArgs(value);
|
|
169
165
|
}
|
|
170
166
|
/** Sanitizes dynamic-tool arguments before diagnostic/event emission. */
|
|
171
167
|
function sanitizeCodexToolArguments(value) {
|
|
@@ -182,6 +178,46 @@ function inferCodexDynamicToolMeta(call, detailMode) {
|
|
|
182
178
|
}
|
|
183
179
|
//#endregion
|
|
184
180
|
//#region extensions/codex/src/app-server/event-projector-tool-items.ts
|
|
181
|
+
const CODE_MODE_NATIVE_PATCH_SOURCE_RE = /^\s*(?:\/\/[^\r\n]*\r?\n\s*)?(?:const|let)\s+([A-Za-z_$][\w$]*)\s*=\s*await\s+tools\.apply_patch\(\s*("(?:\\[\s\S]|[^"\\])*")\s*\)\s*;?\s*text\(\s*\1\s*\)\s*;?\s*$/u;
|
|
182
|
+
function readCodeModeNativePatchInput(source) {
|
|
183
|
+
if (typeof source !== "string") return;
|
|
184
|
+
const match = CODE_MODE_NATIVE_PATCH_SOURCE_RE.exec(source);
|
|
185
|
+
if (!match?.[2]) return;
|
|
186
|
+
try {
|
|
187
|
+
const patch = JSON.parse(match[2]);
|
|
188
|
+
return typeof patch === "string" && /^\*\*\* Begin Patch\r?\n[\s\S]*\r?\n\*\*\* End Patch(?:\r?\n)?$/u.test(patch) ? patch : void 0;
|
|
189
|
+
} catch {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function readInterceptedNativePatchInput(command) {
|
|
194
|
+
if (typeof command !== "string") return;
|
|
195
|
+
const lines = command.replace(/\r\n?/gu, "\n").split("\n");
|
|
196
|
+
const patchStart = lines.indexOf("*** Begin Patch");
|
|
197
|
+
const invocation = /^[\t ]*(?:cd[\t ]+(?:'([^'\n]+)'|([A-Za-z0-9_./-]+))[\t ]+&&[\t ]+)?apply_patch[\t ]*<<-?[\t ]*'([^'\n]+)'[\t ]*$/u.exec(lines[0] ?? "");
|
|
198
|
+
if (!invocation || patchStart !== 1) return;
|
|
199
|
+
const patchEnd = lines.indexOf("*** End Patch", patchStart + 1);
|
|
200
|
+
const cwd = invocation[1] ?? invocation[2];
|
|
201
|
+
const delimiter = invocation[3];
|
|
202
|
+
if (patchEnd < 0 || lines[patchEnd + 1] !== delimiter || lines.slice(patchEnd + 2).some((line) => line.trim().length > 0)) return;
|
|
203
|
+
return {
|
|
204
|
+
input: `${lines.slice(patchStart, patchEnd + 1).join("\n")}\n`,
|
|
205
|
+
...cwd ? { cwd } : {}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function projectCodexToolActivity(item, phase, meta) {
|
|
209
|
+
const name = itemName(item) ?? auditNativeToolName(item);
|
|
210
|
+
return name ? projectAgentToolActivity({
|
|
211
|
+
toolCallId: item.id,
|
|
212
|
+
name,
|
|
213
|
+
phase,
|
|
214
|
+
args: item.type === "dynamicToolCall" ? void 0 : itemToolArgs(item),
|
|
215
|
+
meta,
|
|
216
|
+
status: item.type === "collabAgentToolCall" && item.status === "interrupted" ? "failed" : unknownItemStatus(item) ? "unknown" : itemStatus(item),
|
|
217
|
+
result: { details: itemToolResult(item).result },
|
|
218
|
+
...item.type === "collabAgentToolCall" && item.tool === "wait" ? { nativeOperation: "wait" } : {}
|
|
219
|
+
}) : void 0;
|
|
220
|
+
}
|
|
185
221
|
function isNativePostToolUseRelayItem(item) {
|
|
186
222
|
switch (item.type) {
|
|
187
223
|
case "commandExecution":
|
|
@@ -344,25 +380,19 @@ function itemMeta(item, detailMode = "explain") {
|
|
|
344
380
|
if ((item.type === "dynamicToolCall" || item.type === "mcpToolCall") && toolName) return inferToolMetaFromArgs(toolName, item.arguments, { detailMode });
|
|
345
381
|
}
|
|
346
382
|
function itemOutputText(item, outputTextByItem) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
if (item.type === "
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
if (item.type === "mcpToolCall") {
|
|
356
|
-
const output = item.error ? stringifyJsonValue(item.error) : item.result ? stringifyJsonValue(item.result) : void 0;
|
|
357
|
-
return output ? truncateToolTranscriptText(output) : void 0;
|
|
358
|
-
}
|
|
383
|
+
const output = itemObservedOutputText(item, outputTextByItem)?.trim();
|
|
384
|
+
return output ? truncateToolTranscriptText(output) : void 0;
|
|
385
|
+
}
|
|
386
|
+
function itemObservedOutputText(item, outputTextByItem) {
|
|
387
|
+
if (item.type === "commandExecution") return item.aggregatedOutput ?? outputTextByItem?.get(item.id);
|
|
388
|
+
if (item.type === "dynamicToolCall") return collectDynamicToolContentText(item.contentItems);
|
|
389
|
+
if (item.type === "mcpToolCall") return item.error ? stringifyJsonValue(item.error) : item.result ? stringifyJsonValue(item.result) : void 0;
|
|
359
390
|
}
|
|
360
391
|
function itemTranscriptResultText(item, outputTextByItem) {
|
|
361
|
-
const output =
|
|
362
|
-
if (output) return output;
|
|
392
|
+
const output = itemObservedOutputText(item, outputTextByItem);
|
|
393
|
+
if (output !== void 0) return output;
|
|
363
394
|
const result = itemToolResult(item).result;
|
|
364
|
-
|
|
365
|
-
return resultText ? truncateToolTranscriptText(resultText) : itemStatus(item);
|
|
395
|
+
return (result ? stringifyJsonValue(result) : void 0) ?? itemStatus(item);
|
|
366
396
|
}
|
|
367
397
|
function stringifyJsonValue(value) {
|
|
368
398
|
try {
|
|
@@ -373,15 +403,39 @@ function stringifyJsonValue(value) {
|
|
|
373
403
|
}
|
|
374
404
|
//#endregion
|
|
375
405
|
//#region extensions/codex/src/app-server/native-subagent-task-ids.ts
|
|
376
|
-
/**
|
|
377
|
-
* Shared identifiers for representing Codex native subagents as OpenClaw task
|
|
378
|
-
* runtime rows.
|
|
379
|
-
*/
|
|
380
406
|
/** Task runtime namespace for Codex native subagent task rows. */
|
|
381
407
|
const CODEX_NATIVE_SUBAGENT_RUNTIME = "subagent";
|
|
382
408
|
/** Task kind used to distinguish native Codex subagents from other subagent runtimes. */
|
|
383
409
|
const CODEX_NATIVE_SUBAGENT_TASK_KIND = "codex-native";
|
|
384
410
|
/** Run id prefix for task rows keyed by Codex child thread ids. */
|
|
385
411
|
const CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX = "codex-thread:";
|
|
412
|
+
/** Initial tasks keep their shipped locator; later assignments belong to a native turn. */
|
|
413
|
+
function codexNativeSubagentRunId(threadId, turnId) {
|
|
414
|
+
return `${CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX}${threadId.trim()}${turnId ? `:turn:${turnId}` : ""}`;
|
|
415
|
+
}
|
|
416
|
+
function readCodexNativeSubagentRunId(runId) {
|
|
417
|
+
if (!runId?.startsWith("codex-thread:")) return;
|
|
418
|
+
const [threadId, turnId] = runId.slice(13).split(":turn:");
|
|
419
|
+
return threadId?.trim() ? {
|
|
420
|
+
threadId,
|
|
421
|
+
...turnId ? { turnId } : {}
|
|
422
|
+
} : void 0;
|
|
423
|
+
}
|
|
424
|
+
function readNativeTaskAssignment(task) {
|
|
425
|
+
const runId = task.runId;
|
|
426
|
+
const identity = readCodexNativeSubagentRunId(runId);
|
|
427
|
+
if (!runId || !identity) return;
|
|
428
|
+
const storedTurnId = isJsonObject(task.detail) ? normalizeOptionalString(readStringField(task.detail, "nativeTurnId")) : void 0;
|
|
429
|
+
return {
|
|
430
|
+
runId,
|
|
431
|
+
childThreadId: identity.threadId,
|
|
432
|
+
nativeTurnId: storedTurnId ?? identity.turnId,
|
|
433
|
+
initialTurnId: identity.turnId
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function readNativeSubagentThreadIds(value) {
|
|
437
|
+
if (!Array.isArray(value)) return [];
|
|
438
|
+
return value.filter((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
439
|
+
}
|
|
386
440
|
//#endregion
|
|
387
|
-
export { formatToolSummary as C,
|
|
441
|
+
export { formatToolSummary as A, sanitizeCodexToolArguments as C, ToolOutputAccumulator as D, TOOL_TRANSCRIPT_OUTPUT_MAX_CHARS as E, readCodexResponseOutput as M, toolOutputRawEchoSignature as N, collectDynamicToolContentText as O, truncateToolTranscriptText as P, resolveCodexToolProgressDetailMode as S, TOOL_PROGRESS_ECHO_PREFIX_MIN_CHARS as T, readCodeModeNativePatchInput as _, readCodexNativeSubagentRunId as a, inferCodexDynamicToolMeta as b, isCommandBearingToolItem as c, itemOutputText as d, itemToolArgs as f, projectCodexToolActivity as g, itemTranscriptResultText as h, codexNativeSubagentRunId as i, normalizeToolTranscriptArguments as j, formatToolOutput as k, isNativePostToolUseRelayItem as l, itemToolResult as m, CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX as n, readNativeSubagentThreadIds as o, itemToolError as p, CODEX_NATIVE_SUBAGENT_TASK_KIND as r, readNativeTaskAssignment as s, CODEX_NATIVE_SUBAGENT_RUNTIME as t, itemMeta as u, readInterceptedNativePatchInput as v, sanitizeCodexToolResponse as w, isCodexCommandBearingToolCall as x, shouldSuppressChannelProgressForItem as y };
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as resolveCodexAppServerUserHomeDir } from "./config-security-BEReZ6go.mjs";
|
|
2
|
+
import { N as readBoundedOptionalString } from "./session-catalog-native-projection-DowriLid.mjs";
|
|
3
|
+
import { s as codexCatalogHomeId } from "./session-catalog-events-Bj6j94E_.mjs";
|
|
4
|
+
import { o as formatCodexDisplayText } from "./command-formatters-Bmqvr9tO.mjs";
|
|
2
5
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
6
|
import { timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
|
|
4
|
-
import { runCommandBuffered } from "openclaw/plugin-sdk/process-runtime";
|
|
7
|
+
import { runCommandBuffered, withCommandProcessScope } from "openclaw/plugin-sdk/process-runtime";
|
|
5
8
|
import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
|
|
6
9
|
import path from "node:path";
|
|
7
|
-
import os from "node:os";
|
|
8
10
|
import fs from "node:fs/promises";
|
|
9
11
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
10
12
|
import process from "node:process";
|
|
13
|
+
import { parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
|
|
11
14
|
import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
|
|
12
15
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
13
16
|
//#region extensions/codex/src/jsonl-lines.ts
|
|
14
17
|
const JSONL_STREAM_THRESHOLD_BYTES = 4194304;
|
|
15
18
|
const JSONL_READ_CHUNK_BYTES = 1048576;
|
|
16
|
-
async function visitJsonlLines(file, visitor
|
|
19
|
+
async function visitJsonlLines(file, visitor) {
|
|
17
20
|
let size;
|
|
18
21
|
try {
|
|
19
22
|
size = (await fs.stat(file)).size;
|
|
@@ -40,7 +43,7 @@ async function visitJsonlLines(file, visitor, chunkBytes = JSONL_READ_CHUNK_BYTE
|
|
|
40
43
|
let lineCount = 0;
|
|
41
44
|
for (const line of content.split(/\r?\n/u)) {
|
|
42
45
|
lineCount += 1;
|
|
43
|
-
|
|
46
|
+
visitor(line);
|
|
44
47
|
}
|
|
45
48
|
return {
|
|
46
49
|
ok: true,
|
|
@@ -56,7 +59,7 @@ async function visitJsonlLines(file, visitor, chunkBytes = JSONL_READ_CHUNK_BYTE
|
|
|
56
59
|
lineCount: 0
|
|
57
60
|
};
|
|
58
61
|
}
|
|
59
|
-
const buffer = Buffer.allocUnsafe(
|
|
62
|
+
const buffer = Buffer.allocUnsafe(JSONL_READ_CHUNK_BYTES);
|
|
60
63
|
const decoder = new TextDecoder();
|
|
61
64
|
let pendingFragments = [];
|
|
62
65
|
let lineCount = 0;
|
|
@@ -77,10 +80,7 @@ async function visitJsonlLines(file, visitor, chunkBytes = JSONL_READ_CHUNK_BYTE
|
|
|
77
80
|
}
|
|
78
81
|
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
79
82
|
lineCount += 1;
|
|
80
|
-
|
|
81
|
-
ok: true,
|
|
82
|
-
lineCount
|
|
83
|
-
};
|
|
83
|
+
visitor(line);
|
|
84
84
|
lineStart = newline + 1;
|
|
85
85
|
}
|
|
86
86
|
if (lineStart < content.length) pendingFragments.push(content.slice(lineStart));
|
|
@@ -110,21 +110,25 @@ async function visitJsonlLines(file, visitor, chunkBytes = JSONL_READ_CHUNK_BYTE
|
|
|
110
110
|
//#region extensions/codex/src/node-cli-sessions.ts
|
|
111
111
|
const CODEX_CLI_SESSIONS_LIST_COMMAND = "codex.cli.sessions.list";
|
|
112
112
|
const CODEX_CLI_SESSION_RESUME_COMMAND = "codex.cli.session.resume";
|
|
113
|
+
const CODEX_CLI_SESSION_SOURCE_CAPABILITY = "codex-cli-session-source";
|
|
114
|
+
const CODEX_CLI_SESSION_SOURCE_UPGRADE_MESSAGE = "Update the node and approve its refreshed capabilities before continuing this Codex catalog session.";
|
|
113
115
|
const DEFAULT_SESSION_LIMIT = 10;
|
|
114
116
|
const MAX_SESSION_LIMIT = 50;
|
|
115
117
|
const DEFAULT_RESUME_TIMEOUT_MS = 12e5;
|
|
116
118
|
const SESSION_ID_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
117
119
|
const activeResumeSessions = /* @__PURE__ */ new Set();
|
|
118
|
-
function createCodexCliSessionNodeHostCommands() {
|
|
120
|
+
function createCodexCliSessionNodeHostCommands(resolveCatalogSource) {
|
|
119
121
|
return [{
|
|
120
122
|
command: CODEX_CLI_SESSIONS_LIST_COMMAND,
|
|
121
123
|
cap: "codex-cli-sessions",
|
|
124
|
+
hasActiveWork: () => false,
|
|
122
125
|
handle: listLocalCodexCliSessions
|
|
123
126
|
}, {
|
|
124
127
|
command: CODEX_CLI_SESSION_RESUME_COMMAND,
|
|
125
|
-
cap:
|
|
128
|
+
cap: CODEX_CLI_SESSION_SOURCE_CAPABILITY,
|
|
126
129
|
dangerous: true,
|
|
127
|
-
|
|
130
|
+
hasActiveWork: () => activeResumeSessions.size > 0,
|
|
131
|
+
handle: (paramsJSON, _io, context) => resumeLocalCodexCliSession(paramsJSON, resolveCatalogSource, context)
|
|
128
132
|
}];
|
|
129
133
|
}
|
|
130
134
|
function createCodexCliSessionNodeInvokePolicies() {
|
|
@@ -139,7 +143,11 @@ function createCodexCliSessionNodeInvokePolicies() {
|
|
|
139
143
|
}, {
|
|
140
144
|
commands: [CODEX_CLI_SESSION_RESUME_COMMAND],
|
|
141
145
|
dangerous: true,
|
|
142
|
-
handle: (ctx) => ctx.
|
|
146
|
+
handle: (ctx) => isRecord(ctx.params) && (ctx.params.agentId !== void 0 || ctx.params.sourceHomeId !== void 0) && !ctx.node?.caps?.includes("codex-cli-session-source") ? {
|
|
147
|
+
ok: false,
|
|
148
|
+
code: "CODEX_NODE_SOURCE_UNAVAILABLE",
|
|
149
|
+
message: CODEX_CLI_SESSION_SOURCE_UPGRADE_MESSAGE
|
|
150
|
+
} : ctx.invokeNode()
|
|
143
151
|
}];
|
|
144
152
|
}
|
|
145
153
|
async function listCodexCliSessionsOnNode(params) {
|
|
@@ -176,11 +184,30 @@ async function resolveCodexCliSessionForBindingOnNode(params) {
|
|
|
176
184
|
};
|
|
177
185
|
}
|
|
178
186
|
async function resumeCodexCliSessionOnNode(params) {
|
|
187
|
+
let catalogAgentId;
|
|
188
|
+
let catalogHomeId;
|
|
189
|
+
if (params.sessionKey) {
|
|
190
|
+
const { adoptionSessionKeyRest, CODEX_NODE_SESSION_KEY_PREFIX, readNodeSessionMarker } = await import("./session-catalog-node-adoption-ITddWx_X.mjs");
|
|
191
|
+
const entry = params.runtime.agent.session.getSessionEntry({
|
|
192
|
+
sessionKey: params.sessionKey,
|
|
193
|
+
readConsistency: "latest"
|
|
194
|
+
});
|
|
195
|
+
const codex = entry?.pluginExtensions?.codex;
|
|
196
|
+
if (adoptionSessionKeyRest(params.sessionKey).startsWith(CODEX_NODE_SESSION_KEY_PREFIX) || isRecord(codex) && codex.sessionCatalog !== void 0) {
|
|
197
|
+
const marker = entry ? readNodeSessionMarker(entry) : void 0;
|
|
198
|
+
catalogAgentId = params.agentId?.trim();
|
|
199
|
+
if (!catalogAgentId || parseAgentSessionKey(params.sessionKey)?.agentId !== catalogAgentId || !marker || marker.initializing === true || marker.nodeId !== params.nodeId || marker.sourceHostId !== `node:${params.nodeId}` || marker.sourceThreadId !== params.sessionId || entry?.initializationPending === true || entry?.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true) throw new Error("Codex catalog session changed before its node turn could run.");
|
|
200
|
+
if (!marker.sourceHomeId) throw new Error("This Codex catalog session has no saved source home. Reopen it from the catalog to continue in a new chat.");
|
|
201
|
+
catalogHomeId = marker.sourceHomeId;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
179
204
|
const payload = unwrapNodeInvokePayload(await params.runtime.nodes.invoke({
|
|
180
205
|
nodeId: params.nodeId,
|
|
181
206
|
command: CODEX_CLI_SESSION_RESUME_COMMAND,
|
|
182
207
|
params: {
|
|
183
208
|
sessionId: params.sessionId,
|
|
209
|
+
...catalogAgentId ? { agentId: catalogAgentId } : {},
|
|
210
|
+
...catalogHomeId ? { sourceHomeId: catalogHomeId } : {},
|
|
184
211
|
prompt: params.prompt,
|
|
185
212
|
cwd: params.cwd,
|
|
186
213
|
timeoutMs: params.timeoutMs
|
|
@@ -206,9 +233,8 @@ async function listLocalCodexCliSessions(paramsJSON) {
|
|
|
206
233
|
const params = readRecordParam(paramsJSON);
|
|
207
234
|
const limit = normalizeLimit(params.limit);
|
|
208
235
|
const filter = typeof params.filter === "string" ? params.filter.trim().toLowerCase() : "";
|
|
209
|
-
const codexHome =
|
|
236
|
+
const codexHome = resolveCodexAppServerUserHomeDir();
|
|
210
237
|
const summaries = await readHistorySessions(codexHome);
|
|
211
|
-
await hydrateSessionFiles(codexHome, summaries);
|
|
212
238
|
await hydrateSessionsFromSessionFiles(codexHome, summaries);
|
|
213
239
|
const sessions = [...summaries.values()].filter((session) => {
|
|
214
240
|
if (!filter) return true;
|
|
@@ -223,20 +249,39 @@ async function listLocalCodexCliSessions(paramsJSON) {
|
|
|
223
249
|
codexHome
|
|
224
250
|
});
|
|
225
251
|
}
|
|
226
|
-
async function resumeLocalCodexCliSession(paramsJSON) {
|
|
252
|
+
async function resumeLocalCodexCliSession(paramsJSON, resolveCatalogSource, context) {
|
|
253
|
+
context?.signal?.throwIfAborted();
|
|
227
254
|
const params = readRecordParam(paramsJSON);
|
|
228
255
|
const sessionId = typeof params.sessionId === "string" ? params.sessionId.trim() : "";
|
|
229
256
|
const prompt = typeof params.prompt === "string" ? params.prompt.trim() : "";
|
|
257
|
+
const expectedHomeId = readBoundedOptionalString(params, "sourceHomeId", 256);
|
|
230
258
|
if (!sessionId || !SESSION_ID_PATTERN.test(sessionId)) throw new Error("Missing or invalid Codex CLI session id.");
|
|
231
259
|
if (!prompt) throw new Error("Missing Codex CLI prompt.");
|
|
232
|
-
|
|
233
|
-
|
|
260
|
+
let codexHome = resolveCodexAppServerUserHomeDir();
|
|
261
|
+
let sourceHomeId;
|
|
262
|
+
let assertCurrent;
|
|
263
|
+
if (params.agentId !== void 0) {
|
|
264
|
+
if (typeof params.agentId !== "string" || !params.agentId.trim()) throw new Error("Codex catalog agent id must be a nonempty string.");
|
|
265
|
+
const source = await resolveCatalogSource(params.agentId.trim());
|
|
266
|
+
if (source.transport !== "stdio") throw new Error("Codex CLI continuation requires a local Codex catalog source.");
|
|
267
|
+
codexHome = source.codexHome;
|
|
268
|
+
sourceHomeId = source.sourceHomeId;
|
|
269
|
+
assertCurrent = () => source.assertCurrent();
|
|
270
|
+
} else sourceHomeId = codexCatalogHomeId(codexHome);
|
|
271
|
+
if (expectedHomeId && expectedHomeId !== sourceHomeId) throw new Error("Codex catalog source home changed. Reopen the session from the catalog.");
|
|
272
|
+
context?.signal?.throwIfAborted();
|
|
273
|
+
const resumeKey = `${sourceHomeId}\0${sessionId}`;
|
|
274
|
+
if (activeResumeSessions.has(resumeKey)) throw new Error(`Codex CLI session ${sessionId} already has an active resume turn.`);
|
|
275
|
+
activeResumeSessions.add(resumeKey);
|
|
234
276
|
try {
|
|
235
277
|
const text = await runCodexExecResume({
|
|
236
278
|
sessionId,
|
|
237
279
|
prompt,
|
|
238
280
|
cwd: typeof params.cwd === "string" && params.cwd.trim() ? params.cwd.trim() : void 0,
|
|
239
|
-
timeoutMs: normalizeTimeoutMs(params.timeoutMs)
|
|
281
|
+
timeoutMs: normalizeTimeoutMs(params.timeoutMs),
|
|
282
|
+
codexHome,
|
|
283
|
+
assertCurrent,
|
|
284
|
+
signal: context?.signal
|
|
240
285
|
});
|
|
241
286
|
return JSON.stringify({
|
|
242
287
|
ok: true,
|
|
@@ -244,7 +289,7 @@ async function resumeLocalCodexCliSession(paramsJSON) {
|
|
|
244
289
|
text: text.trim() || "Codex completed without a text reply."
|
|
245
290
|
});
|
|
246
291
|
} finally {
|
|
247
|
-
activeResumeSessions.delete(
|
|
292
|
+
activeResumeSessions.delete(resumeKey);
|
|
248
293
|
}
|
|
249
294
|
}
|
|
250
295
|
async function runCodexExecResume(params) {
|
|
@@ -266,22 +311,31 @@ async function runCodexExecResume(params) {
|
|
|
266
311
|
execPath: process.execPath,
|
|
267
312
|
packageName: "@openai/codex"
|
|
268
313
|
}), args);
|
|
269
|
-
const result = await
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
314
|
+
const result = await withCommandProcessScope(() => {
|
|
315
|
+
params.assertCurrent?.();
|
|
316
|
+
return runCommandBuffered([invocation.command, ...invocation.argv], {
|
|
317
|
+
cwd: params.cwd || process.cwd(),
|
|
318
|
+
input: params.prompt,
|
|
319
|
+
env: {
|
|
320
|
+
...process.env,
|
|
321
|
+
CODEX_HOME: params.codexHome
|
|
322
|
+
},
|
|
323
|
+
killGraceMs: 2e3,
|
|
324
|
+
signal: params.signal,
|
|
325
|
+
terminateOnOutputError: true,
|
|
326
|
+
timeoutMs: params.timeoutMs
|
|
327
|
+
});
|
|
328
|
+
}, params.signal);
|
|
329
|
+
params.signal?.throwIfAborted();
|
|
278
330
|
if (result.termination === "timeout") throw new Error(`codex exec resume timed out after ${String(params.timeoutMs)}ms`);
|
|
279
331
|
if (result.termination === "error" && result.error) throw result.error;
|
|
280
332
|
if (result.code !== 0) {
|
|
281
333
|
const message = result.stderr.toString("utf8").trim() || result.stdout.toString("utf8").trim() || `codex exec resume exited with code ${String(result.code)}`;
|
|
282
334
|
throw new Error(message);
|
|
283
335
|
}
|
|
284
|
-
|
|
336
|
+
const text = await fs.readFile(outputPath, "utf8");
|
|
337
|
+
params.signal?.throwIfAborted();
|
|
338
|
+
return text;
|
|
285
339
|
} finally {
|
|
286
340
|
await fs.rm(path.dirname(outputPath), {
|
|
287
341
|
recursive: true,
|
|
@@ -314,23 +368,6 @@ async function readHistorySessions(codexHome) {
|
|
|
314
368
|
})).ok) return /* @__PURE__ */ new Map();
|
|
315
369
|
return summaries;
|
|
316
370
|
}
|
|
317
|
-
async function hydrateSessionFiles(codexHome, summaries) {
|
|
318
|
-
if (summaries.size === 0) return;
|
|
319
|
-
const files = await findSessionFiles(path.join(codexHome, "sessions"), 4);
|
|
320
|
-
const pending = new Set(summaries.keys());
|
|
321
|
-
for (const file of files) {
|
|
322
|
-
const basename = path.basename(file);
|
|
323
|
-
const sessionId = [...pending].find((id) => basename.includes(id));
|
|
324
|
-
if (!sessionId) continue;
|
|
325
|
-
const entry = summaries.get(sessionId);
|
|
326
|
-
if (!entry) continue;
|
|
327
|
-
entry.sessionFile = file;
|
|
328
|
-
const cwd = readSessionMetaCwd(await readFirstLine(file) ?? "");
|
|
329
|
-
if (cwd) entry.cwd = cwd;
|
|
330
|
-
pending.delete(sessionId);
|
|
331
|
-
if (pending.size === 0) return;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
371
|
async function hydrateSessionsFromSessionFiles(codexHome, summaries) {
|
|
335
372
|
const files = await findSessionFiles(path.join(codexHome, "sessions"), 4);
|
|
336
373
|
for (const file of files) {
|
|
@@ -405,15 +442,6 @@ async function findSessionFiles(dir, maxDepth) {
|
|
|
405
442
|
}
|
|
406
443
|
return files;
|
|
407
444
|
}
|
|
408
|
-
function readSessionMetaCwd(line) {
|
|
409
|
-
try {
|
|
410
|
-
const parsed = JSON.parse(line);
|
|
411
|
-
if (!isRecord(parsed) || parsed.type !== "session_meta" || !isRecord(parsed.payload)) return;
|
|
412
|
-
return typeof parsed.payload.cwd === "string" && parsed.payload.cwd.trim() ? parsed.payload.cwd.trim() : void 0;
|
|
413
|
-
} catch {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
445
|
function readResponseItemMessageText(parsed) {
|
|
418
446
|
if (parsed.type !== "response_item" || !isRecord(parsed.payload)) return;
|
|
419
447
|
if (parsed.payload.type !== "message") return;
|
|
@@ -482,16 +510,6 @@ function readRecordParam(paramsJSON) {
|
|
|
482
510
|
return {};
|
|
483
511
|
}
|
|
484
512
|
}
|
|
485
|
-
function resolveCodexHome() {
|
|
486
|
-
return process.env.CODEX_HOME?.trim() || path.join(os.homedir(), ".codex");
|
|
487
|
-
}
|
|
488
|
-
async function readFirstLine(file) {
|
|
489
|
-
let firstLine;
|
|
490
|
-
return (await visitJsonlLines(file, (line) => {
|
|
491
|
-
firstLine = line;
|
|
492
|
-
return false;
|
|
493
|
-
}, 65536)).ok ? firstLine : void 0;
|
|
494
|
-
}
|
|
495
513
|
async function readFileMtimeIso(file) {
|
|
496
514
|
try {
|
|
497
515
|
return (await fs.stat(file)).mtime.toISOString();
|
|
@@ -524,4 +542,4 @@ function formatNodeLabel(node) {
|
|
|
524
542
|
].filter(Boolean).join(" / ") || "node";
|
|
525
543
|
}
|
|
526
544
|
//#endregion
|
|
527
|
-
export {
|
|
545
|
+
export { createCodexCliSessionNodeInvokePolicies as a, resolveCodexCliSessionForBindingOnNode as c, createCodexCliSessionNodeHostCommands as i, resumeCodexCliSessionOnNode as l, CODEX_CLI_SESSION_SOURCE_CAPABILITY as n, formatCodexCliSessions as o, CODEX_CLI_SESSION_SOURCE_UPGRADE_MESSAGE as r, listCodexCliSessionsOnNode as s, CODEX_CLI_SESSION_RESUME_COMMAND as t };
|