@openclaw/codex 2026.9.5 → 2026.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-Eem_WGqY.mjs} +5 -5
- package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-DDOi8uNx.mjs} +22 -28
- package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-CEv1cKwF.mjs} +58 -43
- package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +331 -0
- package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-B2mpaI9D.mjs} +9 -81
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-ThoatDcb.mjs} +1 -1
- package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-yoHrABt-.mjs} +4 -4
- package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-B2HScEgT.mjs} +138 -32
- package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-C7EnDVgr.mjs} +1 -1
- package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-CDXOOFdZ.mjs} +1 -1
- package/dist/.setup/{client-vXs2929Q.mjs → client-Cs08OXVQ.mjs} +583 -559
- package/dist/.setup/client-catalog-response-BMgt_4q4.mjs +285 -0
- package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-B4JuOsOk.mjs} +8 -4
- package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-Bmqvr9tO.mjs} +8 -4
- package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-DW7Lx9oH.mjs} +106 -172
- package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-DixIj3HW.mjs} +36 -21
- package/dist/.setup/{compact-C3i3qlzj.mjs → compact-Du5UvtxA.mjs} +14 -21
- package/dist/.setup/{config-CedDWjM-.mjs → config-BoTP_mrL.mjs} +3 -3
- package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-BvaRs51b.mjs} +46 -30
- package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C8Rw1m1m.mjs} +1 -1
- package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-BEReZ6go.mjs} +35 -120
- package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-DP-gMrBP.mjs} +21 -32
- package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-uK9Jomlc.mjs} +28 -67
- package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-BDXl-8Cw.mjs} +848 -578
- package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CvnvnGIe.mjs} +3 -3
- package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-poidXgek.mjs} +9 -6
- package/dist/.setup/{event-projector-assistant-message-DNUR1s0A.mjs → event-projector-assistant-message-BsruvNrH.mjs} +2 -4
- package/dist/.setup/{event-projector-items-DyTQ_XqL.mjs → event-projector-items-C6L_5ZiT.mjs} +42 -8
- package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-CnBS8Wa3.mjs} +1 -1
- package/dist/.setup/{harness-rxaaoN-o.mjs → harness-a_MsE4-_.mjs} +23 -17
- package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D96l9-ew.mjs} +1 -1
- package/dist/.setup/inference-proxy-b-aJMSxm.mjs +601 -0
- package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-BIZFhTNG.mjs} +17 -10
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-BnshlFag.mjs} +13 -2
- package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-CfXJf9Ay.mjs} +9 -10
- package/dist/.setup/{models-BDFgm_G-.mjs → models-KnqBv0hE.mjs} +3 -3
- package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-rWbGbMn3.mjs} +4 -4
- package/dist/.setup/{native-subagent-history-YXaL6dMd.mjs → native-subagent-history-0nYYgo0k.mjs} +26 -13
- package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-D3filLY2.mjs} +145 -317
- package/dist/.setup/{native-subagent-task-ids-DsuOonKv.mjs → native-subagent-task-ids-wb8CKZGN.mjs} +69 -39
- package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-r3avj02l.mjs} +86 -68
- package/dist/.setup/node-exec-server.runtime-BDwWXVpK.mjs +247 -0
- package/dist/.setup/{plan-xD7WKYTM.mjs → plan-CN3VwfNU.mjs} +74 -76
- package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-DT3MNtqj.mjs} +7 -16
- package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-B2CsSdnV.mjs} +4 -20
- package/dist/.setup/{plugin-approval-roundtrip-CjfzafAZ.mjs → plugin-approval-roundtrip-C0MZzCuP.mjs} +1 -1
- package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-BoRei8Z4.mjs} +16 -7
- package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-CDOi8IFs.mjs} +4 -1
- package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-Ctmo83k_.mjs} +224 -154
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/.setup/{provider-fFh_-VR3.mjs → provider-BOsxQHOM.mjs} +9 -5
- package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-BfE88FZ5.mjs} +31 -3
- package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-CMU3DUD0.mjs} +116 -137
- package/dist/.setup/{request-BioXJLYa.mjs → request-D2L0zMrq.mjs} +23 -15
- package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-BHu11r7h.mjs} +1197 -617
- package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-CLZ8udh-.mjs} +29 -45
- package/dist/.setup/{sandbox-guard-BBP-RbTf.mjs → sandbox-guard-C2sRMOEY.mjs} +1 -1
- package/dist/.setup/{session-binding-_0W_fHRr.mjs → session-binding-Cm0apEbd.mjs} +3 -32
- package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-BGoz8wOK.mjs} +22 -3
- package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-BlB5EvIS.mjs} +48 -45
- package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-Pno1xGcl.mjs} +482 -182
- package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BI6UTDZT.mjs} +57 -25
- package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-lHBqzhaO.mjs} +6 -6
- package/dist/.setup/{session-catalog-events-jMcYfQyd.mjs → session-catalog-events-Bj6j94E_.mjs} +122 -25
- package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-B9_VQIUz.mjs} +178 -78
- package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-hcdz07yN.mjs} +2 -2
- package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-Dgh8ORJm.mjs} +5 -2
- package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-native-projection-DowriLid.mjs} +30 -13
- package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-ITddWx_X.mjs} +24 -12
- package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-6g6qi4A9.mjs} +22 -13
- package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-zK_PUsiE.mjs} +13 -5
- package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-irrD-uo7.mjs} +4 -4
- package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-BrqhSCf9.mjs} +17 -22
- package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-D-3wAgOP.mjs} +4 -4
- package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-CaCh0xF_.mjs} +5 -18
- package/dist/.setup/{session-initialization-DH1z6fXn.mjs → session-initialization-rcgbZiid.mjs} +2 -2
- package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-BI1QK_98.mjs} +2 -2
- package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-BH-S6qkJ.mjs} +25 -6
- package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-DiAi6Kx6.mjs} +8 -8
- package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DA4VR4Eb.mjs} +59 -89
- package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-BJ1wSDcB.mjs} +147 -211
- package/dist/.setup/{source-Bjp4UQij.mjs → source-CUzJq5WN.mjs} +9 -9
- package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
- package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
- package/dist/.setup/{thread-history-page-BTx-4xsg.mjs → thread-history-page-DoVpnHim.mjs} +1 -1
- package/dist/.setup/{thread-lifecycle-Cik28qWn.mjs → thread-lifecycle-B3mfz1TG.mjs} +172 -2271
- package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-DcTtAcXj.mjs} +4 -2
- package/dist/.setup/{thread-policy-Cjs4B8xf.mjs → thread-policy-DGuQsuFC.mjs} +19 -3
- package/dist/.setup/thread-requests-BLvGkP2R.mjs +2205 -0
- package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-DIBXwOpE.mjs} +6 -6
- package/dist/.setup/{timeout-DZF05XrR.mjs → timeout-C910MdAB.mjs} +19 -2
- package/dist/.setup/{transcript-history-projection-DHNBDhCU.mjs → transcript-history-projection-ZZpkFkJ_.mjs} +94 -64
- package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-BtHDBp1G.mjs} +218 -198
- package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-h2VHOskC.mjs} +135 -55
- package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-BUr4OUbC.mjs} +44 -36
- package/dist/.setup/{usage-BOgBEKso.mjs → usage-BML0r-ua.mjs} +5 -4
- package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-DUMbefVY.mjs} +4 -4
- package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-CDKlN-Rv.mjs} +4 -3
- package/dist/api.js +23 -12
- package/dist/catalog-page-worker-entrypoint.js +12 -0
- package/dist/catalog-page.worker.js +9 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +2 -2
- package/dist/harness.js +1 -1
- package/dist/index.js +221 -170
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +15 -32
- package/dist/session-history.worker.js +1 -1
- package/package.json +9 -6
- package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
- package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
- package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
- package/dist/.setup/version-CoqzXPgK.mjs +0 -12
- package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-umd0tgh4.mjs} +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { r as publishCodexCatalogResume } from "./session-catalog-events-Bj6j94E_.mjs";
|
|
2
|
+
import { o as CodexAppServerRpcError } from "./timeout-C910MdAB.mjs";
|
|
3
|
+
import { t as CodexAppServerScopedRequestRejectedError } from "./request-D2L0zMrq.mjs";
|
|
4
|
+
import { F as forgetCodexWorkspaceReferences, rt as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-DA4VR4Eb.mjs";
|
|
5
|
+
import { b as assertCodexThreadResumeResponse, l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-Cs08OXVQ.mjs";
|
|
6
|
+
import { i as assertCodexThreadResumeSubscription, p as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-CEv1cKwF.mjs";
|
|
7
7
|
import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
|
|
8
8
|
//#region extensions/codex/src/app-server/thread-resume.ts
|
|
9
9
|
/** Owns Codex thread/resume subscription safety. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
2
2
|
import { withTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
3
3
|
//#region extensions/codex/src/app-server/rpc-error.ts
|
|
4
4
|
const CODEX_APP_SERVER_OVERLOADED_ERROR_CODE = -32001;
|
|
@@ -59,5 +59,22 @@ async function withAbortableTimeout(params) {
|
|
|
59
59
|
removeAbortListener?.();
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
async function waitForPromiseOrAbort(promise, signal) {
|
|
63
|
+
if (signal.aborted) return false;
|
|
64
|
+
let removeAbort;
|
|
65
|
+
try {
|
|
66
|
+
return await Promise.race([promise.then(() => true), new Promise((resolve) => {
|
|
67
|
+
const onAbort = () => resolve(false);
|
|
68
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
69
|
+
removeAbort = () => signal.removeEventListener("abort", onAbort);
|
|
70
|
+
if (signal.aborted) onAbort();
|
|
71
|
+
})]);
|
|
72
|
+
} finally {
|
|
73
|
+
removeAbort?.();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function abortReason(signal) {
|
|
77
|
+
return signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "codex app-server thread route aborted"));
|
|
78
|
+
}
|
|
62
79
|
//#endregion
|
|
63
|
-
export {
|
|
80
|
+
export { CODEX_APP_SERVER_OVERLOADED_ERROR_CODE as a, withTimeout$1 as i, waitForPromiseOrAbort as n, CodexAppServerRpcError as o, withAbortableTimeout as r, isCodexThreadReadMissingError as s, abortReason as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
2
|
-
import { c as itemName, l as itemStatus, t as auditNativeToolName } from "./event-projector-items-
|
|
2
|
+
import { b as readCodexProviderRefusal, c as itemName, g as codexProviderRefusalDetails, l as itemStatus, t as auditNativeToolName } from "./event-projector-items-C6L_5ZiT.mjs";
|
|
3
3
|
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.mjs";
|
|
4
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -26,6 +26,22 @@ const CODEX_HISTORY_ZERO_USAGE = {
|
|
|
26
26
|
total: 0
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
function projectCodexHistoryMessage(message, text) {
|
|
30
|
+
const phase = message.role === "assistant" && "phase" in message && (message.phase === "commentary" || message.phase === "final_answer") ? message.phase : void 0;
|
|
31
|
+
return {
|
|
32
|
+
message,
|
|
33
|
+
responseItem: {
|
|
34
|
+
type: "message",
|
|
35
|
+
role: message.role,
|
|
36
|
+
content: [{
|
|
37
|
+
type: message.role === "assistant" ? "output_text" : "input_text",
|
|
38
|
+
text
|
|
39
|
+
}],
|
|
40
|
+
...phase ? { phase } : {}
|
|
41
|
+
},
|
|
42
|
+
messageBytes: Buffer.byteLength(text, "utf8") + (message.role === "assistant" ? Buffer.byteLength(message.errorMessage ?? "", "utf8") + (message.diagnostics ? Buffer.byteLength(JSON.stringify(message.diagnostics), "utf8") : 0) : 0)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
29
45
|
function normalizeImportedHistoryText(value) {
|
|
30
46
|
if (typeof value !== "string") return;
|
|
31
47
|
const text = value.trim();
|
|
@@ -71,55 +87,79 @@ function projectCodexThreadHistory(params) {
|
|
|
71
87
|
const projected = [];
|
|
72
88
|
const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
|
|
73
89
|
let itemOffset = 0;
|
|
74
|
-
for (const turn of params.turns)
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
role
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
stopReason: turn.status === "interrupted" ? "aborted" : turn.status === "failed" ? "error" : "stop",
|
|
98
|
-
...turn.status === "failed" && turn.error?.message ? { errorMessage: turn.error.message } : {},
|
|
99
|
-
...phase ? { phase } : {},
|
|
100
|
-
...asyncDelivery && itemId ? { openclawAsyncDelivery: {
|
|
101
|
-
itemId,
|
|
102
|
-
...questions ? { questions } : {}
|
|
103
|
-
} } : {},
|
|
104
|
-
timestamp
|
|
105
|
-
}, identity) : attachCodexMirrorIdentity({
|
|
106
|
-
role,
|
|
107
|
-
content: text,
|
|
108
|
-
timestamp
|
|
109
|
-
}, identity);
|
|
110
|
-
projected.push({
|
|
111
|
-
message,
|
|
112
|
-
responseItem: {
|
|
113
|
-
type: "message",
|
|
90
|
+
for (const turn of params.turns) {
|
|
91
|
+
const refusal = turn.status === "failed" ? readCodexProviderRefusal(turn.error?.message, turn.error?.codexErrorInfo, {
|
|
92
|
+
misalignment: turn.error?.misalignment,
|
|
93
|
+
nativeThreadId: params.thread.id,
|
|
94
|
+
nativeTurnId: turn.id
|
|
95
|
+
}) : void 0;
|
|
96
|
+
let hasAssistantMessage = false;
|
|
97
|
+
for (const value of turn.items) {
|
|
98
|
+
const item = value;
|
|
99
|
+
const itemId = normalizeOptionalString(item.id);
|
|
100
|
+
const identity = `${turn.id}:${itemId ?? itemOffset}`;
|
|
101
|
+
const timestampSeconds = item.type === "agentMessage" ? turn.completedAt ?? turn.startedAt : turn.startedAt ?? turn.completedAt;
|
|
102
|
+
const timestamp = typeof timestampSeconds === "number" && Number.isFinite(timestampSeconds) ? timestampSeconds * 1e3 + itemOffset : threadTimestamp + itemOffset;
|
|
103
|
+
const text = item.type === "userMessage" ? projectCodexUserItemText(item) : item.type === "agentMessage" ? normalizeImportedHistoryText(item.text) : void 0;
|
|
104
|
+
const role = item.type === "userMessage" ? "user" : item.type === "agentMessage" ? "assistant" : void 0;
|
|
105
|
+
itemOffset += 1;
|
|
106
|
+
if (!text || !role) continue;
|
|
107
|
+
const phase = item.phase === "commentary" || item.phase === "final_answer" ? item.phase : void 0;
|
|
108
|
+
const asyncDelivery = item.delivery === "async";
|
|
109
|
+
const terminalAssistant = role === "assistant" && phase !== "commentary" && !asyncDelivery;
|
|
110
|
+
hasAssistantMessage ||= terminalAssistant;
|
|
111
|
+
const questions = asyncDelivery ? readCodexAsyncQuestions(item.questions) : void 0;
|
|
112
|
+
const message = role === "assistant" ? attachCodexMirrorIdentity({
|
|
114
113
|
role,
|
|
115
114
|
content: [{
|
|
116
|
-
type:
|
|
115
|
+
type: "text",
|
|
117
116
|
text
|
|
118
117
|
}],
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
api: CODEX_HISTORY_ASSISTANT_API,
|
|
119
|
+
provider: normalizeOptionalString(params.modelProvider) ?? normalizeOptionalString(params.thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
|
|
120
|
+
model: CODEX_HISTORY_ASSISTANT_MODEL,
|
|
121
|
+
usage: CODEX_HISTORY_ZERO_USAGE,
|
|
122
|
+
stopReason: turn.status === "interrupted" ? "aborted" : turn.status === "failed" ? "error" : "stop",
|
|
123
|
+
...turn.status === "failed" && turn.error?.message ? { errorMessage: turn.error.message } : {},
|
|
124
|
+
...refusal && terminalAssistant ? { diagnostics: [{
|
|
125
|
+
type: "provider_refusal",
|
|
126
|
+
timestamp,
|
|
127
|
+
details: codexProviderRefusalDetails(refusal)
|
|
128
|
+
}] } : {},
|
|
129
|
+
...phase ? { phase } : {},
|
|
130
|
+
...asyncDelivery && itemId ? { openclawAsyncDelivery: {
|
|
131
|
+
itemId,
|
|
132
|
+
...questions ? { questions } : {}
|
|
133
|
+
} } : {},
|
|
134
|
+
timestamp
|
|
135
|
+
}, identity) : attachCodexMirrorIdentity({
|
|
136
|
+
role,
|
|
137
|
+
content: text,
|
|
138
|
+
timestamp
|
|
139
|
+
}, identity);
|
|
140
|
+
projected.push(projectCodexHistoryMessage(message, text));
|
|
141
|
+
}
|
|
142
|
+
if (params.includeErrorOnlyTurns && !hasAssistantMessage && turn.status === "failed" && turn.error?.message) {
|
|
143
|
+
const timestamp = (turn.completedAt ?? turn.startedAt ?? threadTimestamp / 1e3) * 1e3;
|
|
144
|
+
const text = normalizeImportedHistoryText(turn.error.message) ?? "Codex turn failed.";
|
|
145
|
+
const message = attachCodexMirrorIdentity({
|
|
146
|
+
role: "assistant",
|
|
147
|
+
content: [],
|
|
148
|
+
api: CODEX_HISTORY_ASSISTANT_API,
|
|
149
|
+
provider: normalizeOptionalString(params.modelProvider) ?? normalizeOptionalString(params.thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
|
|
150
|
+
model: CODEX_HISTORY_ASSISTANT_MODEL,
|
|
151
|
+
usage: CODEX_HISTORY_ZERO_USAGE,
|
|
152
|
+
stopReason: "error",
|
|
153
|
+
errorMessage: text,
|
|
154
|
+
...refusal ? { diagnostics: [{
|
|
155
|
+
type: "provider_refusal",
|
|
156
|
+
timestamp,
|
|
157
|
+
details: codexProviderRefusalDetails(refusal)
|
|
158
|
+
}] } : {},
|
|
159
|
+
timestamp
|
|
160
|
+
}, `${turn.id}:assistant`);
|
|
161
|
+
projected.push(projectCodexHistoryMessage(message, ""));
|
|
162
|
+
}
|
|
123
163
|
}
|
|
124
164
|
return projected;
|
|
125
165
|
}
|
|
@@ -129,9 +169,9 @@ function selectBoundedCodexHistoryTail(projected) {
|
|
|
129
169
|
for (let index = projected.length - 1; index >= 0; index -= 1) {
|
|
130
170
|
const candidate = projected[index];
|
|
131
171
|
if (!candidate) continue;
|
|
132
|
-
if (selected.length >= CODEX_HISTORY_IMPORT_MAX_MESSAGES || selectedBytes + candidate.
|
|
172
|
+
if (selected.length >= CODEX_HISTORY_IMPORT_MAX_MESSAGES || selectedBytes + candidate.messageBytes > CODEX_HISTORY_IMPORT_MAX_BYTES) break;
|
|
133
173
|
selected.push(candidate);
|
|
134
|
-
selectedBytes += candidate.
|
|
174
|
+
selectedBytes += candidate.messageBytes;
|
|
135
175
|
}
|
|
136
176
|
return selected.toReversed();
|
|
137
177
|
}
|
|
@@ -141,6 +181,7 @@ function projectBoundedCodexThreadHistory(params) {
|
|
|
141
181
|
thread: params.thread,
|
|
142
182
|
turns: selectTurnsThroughBoundary(params.thread, params.throughTurnId),
|
|
143
183
|
importedAt: params.importedAt,
|
|
184
|
+
includeErrorOnlyTurns: true,
|
|
144
185
|
...params.modelProvider ? { modelProvider: params.modelProvider } : {}
|
|
145
186
|
});
|
|
146
187
|
const selected = selectBoundedCodexHistoryTail(projected);
|
|
@@ -154,24 +195,13 @@ function projectBoundedCodexThreadHistory(params) {
|
|
|
154
195
|
/** Projects only visible local user/assistant messages through the same bounded history policy. */
|
|
155
196
|
function projectBoundedCodexVisibleSessionHistory(entries) {
|
|
156
197
|
const projected = [];
|
|
157
|
-
for (const
|
|
158
|
-
if (
|
|
159
|
-
if (
|
|
160
|
-
const content =
|
|
198
|
+
for (const { message } of entries) {
|
|
199
|
+
if (message.role !== "user" && message.role !== "assistant" || !("content" in message)) continue;
|
|
200
|
+
if (message.role === "assistant" && (message.stopReason === "aborted" || message.stopReason === "error" || "openclawAsyncDelivery" in message)) continue;
|
|
201
|
+
const content = message.content;
|
|
161
202
|
const text = normalizeImportedHistoryText(typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => part && typeof part === "object" && "text" in part && typeof part.text === "string" ? [part.text] : []).join("\n") : void 0);
|
|
162
203
|
if (!text) continue;
|
|
163
|
-
projected.push(
|
|
164
|
-
message: entry.message,
|
|
165
|
-
responseItem: {
|
|
166
|
-
type: "message",
|
|
167
|
-
role: entry.role,
|
|
168
|
-
content: [{
|
|
169
|
-
type: entry.role === "assistant" ? "output_text" : "input_text",
|
|
170
|
-
text
|
|
171
|
-
}]
|
|
172
|
-
},
|
|
173
|
-
textBytes: Buffer.byteLength(text, "utf8")
|
|
174
|
-
});
|
|
204
|
+
projected.push(projectCodexHistoryMessage(message, text));
|
|
175
205
|
}
|
|
176
206
|
return selectBoundedCodexHistoryTail(projected).map(({ responseItem }) => responseItem);
|
|
177
207
|
}
|