@openclaw/codex 2026.9.5 → 2026.9.7
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/assets/icon.png +0 -0
- package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
- package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
- package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
- package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
- package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
- package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
- package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
- package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
- package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
- package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
- package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
- package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
- package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
- package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
- package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
- package/dist/.setup/compact-C2WamavS.mjs +776 -0
- package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
- package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
- package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
- package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
- package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
- package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
- package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
- package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
- package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
- package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
- package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
- package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
- package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
- package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
- package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
- package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
- package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
- package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
- package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
- package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
- package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
- package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
- package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
- package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
- package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
- package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
- package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
- package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
- package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
- package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
- package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
- package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
- package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
- package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
- package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
- package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
- package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
- package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
- package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
- package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
- package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
- package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
- package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
- package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
- package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
- package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
- package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
- package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
- package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
- package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
- package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
- package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
- package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
- package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
- package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
- package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
- package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
- package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
- package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
- package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
- package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
- package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
- package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
- package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
- package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
- package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
- package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
- package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
- package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
- package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
- package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
- package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
- package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
- package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
- package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
- package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
- 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-lifecycle-DPflntEJ.mjs +2362 -0
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
- package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
- package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
- package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
- package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
- package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
- package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
- package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
- package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
- package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
- package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
- package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
- package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
- package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
- package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
- package/dist/api.js +25 -16
- 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 +50 -8
- package/dist/harness.js +344 -1
- package/dist/index.js +345 -346
- package/dist/media-understanding-provider.js +9 -22
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +16 -33
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +14 -2
- package/package.json +11 -7
- package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
- package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
- package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
- package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
- package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
- package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
- package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
- package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
- package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
- package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
- package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
- package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
- package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
- package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
- package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
- package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
- package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
- package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
- package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
- package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
- package/dist/.setup/version-CoqzXPgK.mjs +0 -12
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
|
|
2
|
+
import { r as publishCodexCatalogResume } from "./session-catalog-events-DePDzzjc.mjs";
|
|
3
|
+
import { t as CodexAppServerScopedRequestRejectedError } from "./request-BHZ1nz8d.mjs";
|
|
4
|
+
import { L as forgetCodexWorkspaceReferences, ft as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-DqyTMYug.mjs";
|
|
5
|
+
import { b as assertCodexThreadResumeResponse, l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-N0JpgSzF.mjs";
|
|
6
|
+
import { i as assertCodexThreadResumeSubscription, p as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DOP-cW5j.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. */
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { withTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
2
|
+
//#region extensions/codex/src/app-server/timeout.ts
|
|
3
|
+
function resolveAbortError(signal) {
|
|
4
|
+
return signal.reason instanceof Error ? signal.reason : new Error("Codex app-server operation aborted", { cause: signal.reason });
|
|
5
|
+
}
|
|
6
|
+
async function withTimeout$1(promise, timeoutMs, timeoutMessage, createError) {
|
|
7
|
+
return await withTimeout(promise, timeoutMs, {
|
|
8
|
+
message: timeoutMessage,
|
|
9
|
+
...createError ? { createError } : {}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** Bounds an operation by both its owner lifecycle and one total wall-clock budget. */
|
|
13
|
+
async function withAbortableTimeout(params) {
|
|
14
|
+
const signal = params.signal;
|
|
15
|
+
if (signal?.aborted) throw resolveAbortError(signal);
|
|
16
|
+
let removeAbortListener;
|
|
17
|
+
const operation = signal ? Promise.race([params.promise, new Promise((_, reject) => {
|
|
18
|
+
const onAbort = () => reject(resolveAbortError(signal));
|
|
19
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
20
|
+
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
21
|
+
})]) : params.promise;
|
|
22
|
+
try {
|
|
23
|
+
return await withTimeout$1(operation, params.timeoutMs, params.timeoutMessage, params.createTimeoutError);
|
|
24
|
+
} finally {
|
|
25
|
+
removeAbortListener?.();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function waitForPromiseOrAbort(promise, signal) {
|
|
29
|
+
if (signal.aborted) return false;
|
|
30
|
+
let removeAbort;
|
|
31
|
+
try {
|
|
32
|
+
return await Promise.race([promise.then(() => true), new Promise((resolve) => {
|
|
33
|
+
const onAbort = () => resolve(false);
|
|
34
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
35
|
+
removeAbort = () => signal.removeEventListener("abort", onAbort);
|
|
36
|
+
if (signal.aborted) onAbort();
|
|
37
|
+
})]);
|
|
38
|
+
} finally {
|
|
39
|
+
removeAbort?.();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function abortReason(signal) {
|
|
43
|
+
return signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "codex app-server thread route aborted"));
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { withTimeout$1 as i, waitForPromiseOrAbort as n, withAbortableTimeout as r, abortReason as t };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
2
|
+
import { a as readCodexProviderRefusal, t as codexProviderRefusalDiagnostics } from "./event-projector-values-DJSz8BTk.mjs";
|
|
3
|
+
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-fXkKbPVC.mjs";
|
|
4
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
+
import { truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
6
|
+
import { Buffer } from "node:buffer";
|
|
7
|
+
//#region extensions/codex/src/app-server/transcript-history-projection.ts
|
|
8
|
+
const CODEX_HISTORY_IMPORT_MAX_MESSAGES = 200;
|
|
9
|
+
const CODEX_HISTORY_IMPORT_MAX_BYTES = 524288;
|
|
10
|
+
const CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES = 65536;
|
|
11
|
+
const CODEX_HISTORY_TRUNCATION_SUFFIX = "\n\n[Message truncated during Codex history import.]";
|
|
12
|
+
const CODEX_HISTORY_ASSISTANT_PROVIDER = "openai";
|
|
13
|
+
const CODEX_HISTORY_ZERO_USAGE = {
|
|
14
|
+
input: 0,
|
|
15
|
+
output: 0,
|
|
16
|
+
cacheRead: 0,
|
|
17
|
+
cacheWrite: 0,
|
|
18
|
+
totalTokens: 0,
|
|
19
|
+
cost: {
|
|
20
|
+
input: 0,
|
|
21
|
+
output: 0,
|
|
22
|
+
cacheRead: 0,
|
|
23
|
+
cacheWrite: 0,
|
|
24
|
+
total: 0
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function historyAssistantFields(provider) {
|
|
28
|
+
return {
|
|
29
|
+
api: "openai-chatgpt-responses",
|
|
30
|
+
provider,
|
|
31
|
+
model: "native-history",
|
|
32
|
+
usage: CODEX_HISTORY_ZERO_USAGE
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function projectCodexHistoryMessage(message, text) {
|
|
36
|
+
const phase = message.role === "assistant" && "phase" in message && (message.phase === "commentary" || message.phase === "final_answer") ? message.phase : void 0;
|
|
37
|
+
return {
|
|
38
|
+
message,
|
|
39
|
+
responseItem: {
|
|
40
|
+
type: "message",
|
|
41
|
+
role: message.role,
|
|
42
|
+
content: [{
|
|
43
|
+
type: message.role === "assistant" ? "output_text" : "input_text",
|
|
44
|
+
text
|
|
45
|
+
}],
|
|
46
|
+
...phase ? { phase } : {}
|
|
47
|
+
},
|
|
48
|
+
messageBytes: Buffer.byteLength(text, "utf8") + (message.role === "assistant" ? Buffer.byteLength(message.errorMessage ?? "", "utf8") + (message.diagnostics ? Buffer.byteLength(JSON.stringify(message.diagnostics), "utf8") : 0) : 0)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function normalizeImportedHistoryText(value) {
|
|
52
|
+
if (typeof value !== "string") return;
|
|
53
|
+
const text = value.trim();
|
|
54
|
+
if (!text) return;
|
|
55
|
+
if (Buffer.byteLength(text, "utf8") <= CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES) return text;
|
|
56
|
+
const suffixBytes = Buffer.byteLength(CODEX_HISTORY_TRUNCATION_SUFFIX, "utf8");
|
|
57
|
+
const contentLimitBytes = Math.max(0, CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES - suffixBytes);
|
|
58
|
+
return `${truncateUtf8Prefix(text, contentLimitBytes)}${CODEX_HISTORY_TRUNCATION_SUFFIX}`;
|
|
59
|
+
}
|
|
60
|
+
function projectCodexUserItemText(item) {
|
|
61
|
+
if (!Array.isArray(item.content)) return;
|
|
62
|
+
const parts = [];
|
|
63
|
+
for (const value of item.content) {
|
|
64
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
65
|
+
const input = value;
|
|
66
|
+
if (input.type === "text") {
|
|
67
|
+
const text = normalizeImportedHistoryText(input.text);
|
|
68
|
+
if (text) parts.push(text);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (input.type === "image" || input.type === "localImage") {
|
|
72
|
+
parts.push("[Image attachment]");
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (input.type === "audio" || input.type === "localAudio" || input.type === "local_audio") parts.push("[Audio attachment]");
|
|
76
|
+
if (input.type === "skill" || input.type === "mention") {
|
|
77
|
+
const name = normalizeOptionalString(input.name);
|
|
78
|
+
if (name) parts.push(`${input.type === "skill" ? "$" : "@"}${name}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return normalizeImportedHistoryText(parts.join("\n"));
|
|
82
|
+
}
|
|
83
|
+
function selectTurnsThroughBoundary(thread, throughTurnId) {
|
|
84
|
+
if (throughTurnId === null) return [];
|
|
85
|
+
const turns = thread.turns ?? [];
|
|
86
|
+
const boundaryIndex = turns.findIndex((turn) => turn.id === throughTurnId);
|
|
87
|
+
if (boundaryIndex < 0) throw new Error(`Codex history boundary turn not found: ${throughTurnId}`);
|
|
88
|
+
const boundary = turns[boundaryIndex];
|
|
89
|
+
if (boundary?.status !== "completed" && boundary?.status !== "interrupted" && boundary?.status !== "failed") throw new Error(`Codex history boundary turn is not terminal: ${throughTurnId}`);
|
|
90
|
+
return turns.slice(0, boundaryIndex + 1);
|
|
91
|
+
}
|
|
92
|
+
function projectCodexThreadHistory(params) {
|
|
93
|
+
const projected = [];
|
|
94
|
+
const assistantFields = historyAssistantFields(normalizeOptionalString(params.modelProvider) ?? normalizeOptionalString(params.thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER);
|
|
95
|
+
const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
|
|
96
|
+
let itemOffset = 0;
|
|
97
|
+
for (const turn of params.turns) {
|
|
98
|
+
const refusal = turn.status === "failed" ? readCodexProviderRefusal(turn.error?.message, turn.error?.codexErrorInfo, {
|
|
99
|
+
misalignment: turn.error?.misalignment,
|
|
100
|
+
nativeThreadId: params.thread.id,
|
|
101
|
+
nativeTurnId: turn.id
|
|
102
|
+
}) : void 0;
|
|
103
|
+
let hasAssistantMessage = false;
|
|
104
|
+
for (const item of turn.items) {
|
|
105
|
+
const itemId = normalizeOptionalString(item.id);
|
|
106
|
+
const identity = `${turn.id}:${itemId ?? itemOffset}`;
|
|
107
|
+
const timestampSeconds = item.type === "agentMessage" ? turn.completedAt ?? turn.startedAt : turn.startedAt ?? turn.completedAt;
|
|
108
|
+
const timestamp = typeof timestampSeconds === "number" && Number.isFinite(timestampSeconds) ? timestampSeconds * 1e3 + itemOffset : threadTimestamp + itemOffset;
|
|
109
|
+
const text = item.type === "userMessage" ? projectCodexUserItemText(item) : item.type === "agentMessage" ? normalizeImportedHistoryText(item.text) : void 0;
|
|
110
|
+
const role = item.type === "userMessage" ? "user" : item.type === "agentMessage" ? "assistant" : void 0;
|
|
111
|
+
itemOffset += 1;
|
|
112
|
+
if (!text || !role) continue;
|
|
113
|
+
const phase = item.phase === "commentary" || item.phase === "final_answer" ? item.phase : void 0;
|
|
114
|
+
const asyncDelivery = item.delivery === "async";
|
|
115
|
+
const terminalAssistant = role === "assistant" && phase !== "commentary" && !asyncDelivery;
|
|
116
|
+
hasAssistantMessage ||= terminalAssistant;
|
|
117
|
+
const questions = asyncDelivery ? readCodexAsyncQuestions(item.questions) : void 0;
|
|
118
|
+
const message = role === "assistant" ? attachCodexMirrorIdentity({
|
|
119
|
+
role,
|
|
120
|
+
content: [{
|
|
121
|
+
type: "text",
|
|
122
|
+
text
|
|
123
|
+
}],
|
|
124
|
+
...assistantFields,
|
|
125
|
+
stopReason: turn.status === "interrupted" ? "aborted" : turn.status === "failed" ? "error" : "stop",
|
|
126
|
+
...turn.status === "failed" && turn.error?.message ? { errorMessage: turn.error.message } : {},
|
|
127
|
+
...codexProviderRefusalDiagnostics(terminalAssistant ? refusal : void 0, timestamp),
|
|
128
|
+
...phase ? { phase } : {},
|
|
129
|
+
...asyncDelivery && itemId ? { openclawAsyncDelivery: {
|
|
130
|
+
itemId,
|
|
131
|
+
...questions ? { questions } : {}
|
|
132
|
+
} } : {},
|
|
133
|
+
timestamp
|
|
134
|
+
}, identity) : attachCodexMirrorIdentity({
|
|
135
|
+
role,
|
|
136
|
+
content: text,
|
|
137
|
+
timestamp
|
|
138
|
+
}, identity);
|
|
139
|
+
projected.push(projectCodexHistoryMessage(message, text));
|
|
140
|
+
}
|
|
141
|
+
if (params.includeErrorOnlyTurns && !hasAssistantMessage && turn.status === "failed" && turn.error?.message) {
|
|
142
|
+
const timestamp = (turn.completedAt ?? turn.startedAt ?? threadTimestamp / 1e3) * 1e3;
|
|
143
|
+
const text = normalizeImportedHistoryText(turn.error.message) ?? "Codex turn failed.";
|
|
144
|
+
const message = attachCodexMirrorIdentity({
|
|
145
|
+
role: "assistant",
|
|
146
|
+
content: [],
|
|
147
|
+
...assistantFields,
|
|
148
|
+
stopReason: "error",
|
|
149
|
+
errorMessage: text,
|
|
150
|
+
...codexProviderRefusalDiagnostics(refusal, timestamp),
|
|
151
|
+
timestamp
|
|
152
|
+
}, `${turn.id}:assistant`);
|
|
153
|
+
projected.push(projectCodexHistoryMessage(message, ""));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return projected;
|
|
157
|
+
}
|
|
158
|
+
function selectBoundedCodexHistoryTail(projected) {
|
|
159
|
+
const selected = [];
|
|
160
|
+
let selectedBytes = 0;
|
|
161
|
+
for (let index = projected.length - 1; index >= 0; index -= 1) {
|
|
162
|
+
const candidate = projected[index];
|
|
163
|
+
if (!candidate) continue;
|
|
164
|
+
if (selected.length >= CODEX_HISTORY_IMPORT_MAX_MESSAGES || selectedBytes + candidate.messageBytes > CODEX_HISTORY_IMPORT_MAX_BYTES) break;
|
|
165
|
+
selected.push(candidate);
|
|
166
|
+
selectedBytes += candidate.messageBytes;
|
|
167
|
+
}
|
|
168
|
+
return selected.toReversed();
|
|
169
|
+
}
|
|
170
|
+
/** Projects one terminal Codex history prefix into transcript and Responses API items. */
|
|
171
|
+
function projectBoundedCodexThreadHistory(params) {
|
|
172
|
+
const projected = projectCodexThreadHistory({
|
|
173
|
+
thread: params.thread,
|
|
174
|
+
turns: selectTurnsThroughBoundary(params.thread, params.throughTurnId),
|
|
175
|
+
importedAt: params.importedAt,
|
|
176
|
+
includeErrorOnlyTurns: true,
|
|
177
|
+
...params.modelProvider ? { modelProvider: params.modelProvider } : {}
|
|
178
|
+
});
|
|
179
|
+
const selected = selectBoundedCodexHistoryTail(projected);
|
|
180
|
+
return {
|
|
181
|
+
importedMessages: selected.length,
|
|
182
|
+
omittedMessages: projected.length - selected.length,
|
|
183
|
+
responseItems: selected.filter(({ message }) => message.role !== "assistant" || message.stopReason !== "aborted" && message.stopReason !== "error" && !("openclawAsyncDelivery" in message)).map(({ responseItem }) => responseItem),
|
|
184
|
+
transcriptMessages: selected.map(({ message }) => message)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** Projects only visible local user/assistant messages through the same bounded history policy. */
|
|
188
|
+
function projectBoundedCodexVisibleSessionHistory(entries) {
|
|
189
|
+
const projected = [];
|
|
190
|
+
for (const { message } of entries) {
|
|
191
|
+
if (message.role !== "user" && message.role !== "assistant" || !("content" in message)) continue;
|
|
192
|
+
if (message.role === "assistant" && (message.stopReason === "aborted" || message.stopReason === "error" || "openclawAsyncDelivery" in message)) continue;
|
|
193
|
+
const content = message.content;
|
|
194
|
+
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);
|
|
195
|
+
if (!text) continue;
|
|
196
|
+
projected.push(projectCodexHistoryMessage(message, text));
|
|
197
|
+
}
|
|
198
|
+
return selectBoundedCodexHistoryTail(projected).map(({ responseItem }) => responseItem);
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
export { projectBoundedCodexVisibleSessionHistory as n, projectCodexUserItemText as r, projectBoundedCodexThreadHistory as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
2
|
-
import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-
|
|
2
|
+
import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-fXkKbPVC.mjs";
|
|
3
3
|
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
//#region extensions/codex/src/app-server/transcript-mirror-attestation.ts
|
|
@@ -37,7 +37,7 @@ function applyCodexTranscriptTaint(message, state) {
|
|
|
37
37
|
}
|
|
38
38
|
function attachCodexMirrorAttestation(message, sourceFingerprint) {
|
|
39
39
|
const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
40
|
-
const baseMeta =
|
|
40
|
+
const baseMeta = asOptionalRecord(existing) ?? {};
|
|
41
41
|
return {
|
|
42
42
|
...message,
|
|
43
43
|
[CODEX_META_KEY]: {
|
|
@@ -66,8 +66,7 @@ function hasCodexMirrorOrigin(message) {
|
|
|
66
66
|
}
|
|
67
67
|
function readCodexMirrorSourceFingerprint(message) {
|
|
68
68
|
const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
69
|
-
|
|
70
|
-
const value = meta[MIRROR_SOURCE_FINGERPRINT_META_KEY];
|
|
69
|
+
const value = asOptionalRecord(meta)?.[MIRROR_SOURCE_FINGERPRINT_META_KEY];
|
|
71
70
|
return typeof value === "string" && value ? value : void 0;
|
|
72
71
|
}
|
|
73
72
|
function serializeCodexMirrorSourceEvidence(message) {
|