@openclaw/codex 2026.9.6 → 2026.9.8
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-Eem_WGqY.mjs → account-usage-runtime-G348lY1q.mjs} +5 -5
- package/dist/.setup/{apply-DDOi8uNx.mjs → apply-Cqb-YoCS.mjs} +22 -36
- package/dist/.setup/{attempt-client-cleanup-CEv1cKwF.mjs → attempt-client-cleanup-B-S7ngS_.mjs} +128 -37
- package/dist/.setup/attempt-workspace-context-BJ5Z_olH.mjs +164 -0
- package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
- package/dist/.setup/{auth-cache-key-B2mpaI9D.mjs → auth-cache-key-Dnps4W4_.mjs} +36 -34
- package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
- package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
- package/dist/.setup/{binding-connection-ThoatDcb.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-yoHrABt-.mjs → binding-connection.runtime-6TpgD1M6.mjs} +4 -4
- package/dist/.setup/{bounded-turn-B2HScEgT.mjs → bounded-turn-BNunZPtz.mjs} +15 -18
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-C7EnDVgr.mjs → build-state-DIQ5O_-S.mjs} +1 -1
- package/dist/.setup/{capabilities-CDXOOFdZ.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-catalog-response-BMgt_4q4.mjs → client-catalog-response-DRvx_wCC.mjs} +1 -1
- package/dist/.setup/{client-Cs08OXVQ.mjs → client-qyUBJlGZ.mjs} +138 -399
- package/dist/.setup/{command-dispatch-B4JuOsOk.mjs → command-dispatch-Btrs1D6f.mjs} +5 -8
- package/dist/.setup/{command-formatters-Bmqvr9tO.mjs → command-formatters-R3ckE3Co.mjs} +29 -61
- package/dist/.setup/{command-handlers-DW7Lx9oH.mjs → command-handlers-DvlCHJch.mjs} +222 -343
- package/dist/.setup/{command-rpc-DixIj3HW.mjs → command-rpc-skzRq4wD.mjs} +15 -18
- package/dist/.setup/compact-8ttks5U5.mjs +776 -0
- package/dist/.setup/{config-BoTP_mrL.mjs → config-DKhXquav.mjs} +26 -28
- package/dist/.setup/{config-options-BvaRs51b.mjs → config-options-CzyWLTJt.mjs} +24 -37
- package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
- package/dist/.setup/{config-runtime-C8Rw1m1m.mjs → config-runtime-C0NbLms1.mjs} +2 -2
- package/dist/.setup/{config-security-BEReZ6go.mjs → config-security-CE-FcGw9.mjs} +32 -111
- 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-DP-gMrBP.mjs → conversation-binding-74LaGGH-.mjs} +67 -90
- package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
- package/dist/.setup/{conversation-control-uK9Jomlc.mjs → conversation-control-OrN6zuaY.mjs} +8 -8
- 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-BDXl-8Cw.mjs → dynamic-tools-Db2sY5cZ.mjs} +2305 -2606
- package/dist/.setup/{effective-mcp-catalog-CvnvnGIe.mjs → effective-mcp-catalog-Bi6-SQ7i.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-poidXgek.mjs → ephemeral-turn-DiCS1ijR.mjs} +3 -3
- package/dist/.setup/event-projector-assistant-message-MV_1dj-3.mjs +69 -0
- package/dist/.setup/{event-projector-usage-CnBS8Wa3.mjs → event-projector-usage-03R0I2dM.mjs} +3 -25
- package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
- package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
- package/dist/.setup/{inference-context-D96l9-ew.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-b-aJMSxm.mjs → inference-proxy-DhcXOgUE.mjs} +174 -214
- package/dist/.setup/{isolated-completion-BIZFhTNG.mjs → isolated-completion-D80IXfQF.mjs} +9 -12
- package/dist/.setup/{managed-binary-BnshlFag.mjs → managed-binary-kiWRhNRE.mjs} +8 -12
- package/dist/.setup/{model-catalog-CfXJf9Ay.mjs → model-catalog-DiC0Tkha.mjs} +11 -10
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-KnqBv0hE.mjs → models-DfLmPV0k.mjs} +9 -18
- package/dist/.setup/{native-auth-rWbGbMn3.mjs → native-auth-CuG53tu4.mjs} +4 -4
- package/dist/.setup/{native-execution-policy-umd0tgh4.mjs → native-execution-policy-BxZJy5mP.mjs} +5 -30
- package/dist/.setup/{native-subagent-monitor-D3filLY2.mjs → native-subagent-monitor-BwkQXf9e.mjs} +4395 -3609
- 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-r3avj02l.mjs → node-cli-sessions-HC4W6FLI.mjs} +19 -49
- package/dist/.setup/{node-exec-server.runtime-BDwWXVpK.mjs → node-exec-server.runtime-BgBfWQqo.mjs} +3 -6
- package/dist/.setup/{plan-CN3VwfNU.mjs → plan-DPdMk1Oy.mjs} +49 -92
- package/dist/.setup/{plugin-activation-DT3MNtqj.mjs → plugin-activation-cNHRfaxU.mjs} +8 -36
- package/dist/.setup/{plugin-app-cache-key-B2CsSdnV.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +6 -23
- package/dist/.setup/{plugin-inventory-BoRei8Z4.mjs → plugin-inventory-Cky2XJUw.mjs} +21 -21
- package/dist/.setup/{plugin-marketplace-discovery-CDOi8IFs.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +18 -24
- package/dist/.setup/{plugin-metadata-cache-Ctmo83k_.mjs → plugin-metadata-cache-BRwtRct9.mjs} +116 -176
- package/dist/.setup/{provider-BOsxQHOM.mjs → provider-D6F_7p1I.mjs} +11 -14
- package/dist/.setup/{provider-capabilities-BfE88FZ5.mjs → provider-capabilities-DG5qbsUZ.mjs} +13 -18
- package/dist/.setup/{rate-limits-CMU3DUD0.mjs → rate-limits-B7-X2TgG.mjs} +9 -31
- package/dist/.setup/{request-D2L0zMrq.mjs → request-BZOfsSXW.mjs} +7 -6
- package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
- package/dist/.setup/{run-attempt-BHu11r7h.mjs → run-attempt-dYJhjZrp.mjs} +1035 -1023
- package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
- package/dist/.setup/{runtime-artifact-CLZ8udh-.mjs → runtime-artifact-DDQ-HGXf.mjs} +16 -4
- 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-BGoz8wOK.mjs → session-binding-record-Oe9L-CNY.mjs} +52 -130
- package/dist/.setup/{session-binding-sidecars-BlB5EvIS.mjs → session-binding-sidecars-jo6H8dFr.mjs} +196 -17
- package/dist/.setup/{session-catalog-Pno1xGcl.mjs → session-catalog-BFafIiF6.mjs} +185 -350
- package/dist/.setup/{session-catalog-adoption-BI6UTDZT.mjs → session-catalog-adoption-BU_pHWG7.mjs} +7 -6
- package/dist/.setup/{session-catalog-archive-lHBqzhaO.mjs → session-catalog-archive-spHfihri.mjs} +6 -6
- package/dist/.setup/session-catalog-events-BMCFMZw-.mjs +139 -0
- package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
- package/dist/.setup/{session-catalog-index-B9_VQIUz.mjs → session-catalog-index-DwJjnF5k.mjs} +126 -122
- package/dist/.setup/{session-catalog-index-order-hcdz07yN.mjs → session-catalog-index-order-BcQpHks3.mjs} +1 -1
- package/dist/.setup/{session-catalog-index-state-Dgh8ORJm.mjs → session-catalog-index-state-TeO7EyO-.mjs} +3 -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-CuaFZuQE.mjs +178 -0
- package/dist/.setup/{session-catalog-node-adoption-ITddWx_X.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +10 -27
- package/dist/.setup/{session-catalog-node-continue-6g6qi4A9.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +8 -10
- package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
- package/dist/.setup/{session-catalog-native-projection-DowriLid.mjs → session-catalog-parsing-CPGaPYr-.mjs} +11 -194
- package/dist/.setup/{session-catalog-projection-zK_PUsiE.mjs → session-catalog-projection-CGfzfP93.mjs} +6 -4
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-irrD-uo7.mjs → session-cli-DlmBHYIe.mjs} +9 -22
- package/dist/.setup/{session-history-BrqhSCf9.mjs → session-history-D83lJWHG.mjs} +4 -6
- package/dist/.setup/{session-history-import-D-3wAgOP.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-CaCh0xF_.mjs → session-history.worker-MnPKncqP.mjs} +9 -5
- package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
- package/dist/.setup/{session-permission-policy-BI1QK_98.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
- package/dist/.setup/{session-retirement-BH-S6qkJ.mjs → session-retirement-LlYWBKTJ.mjs} +17 -17
- package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
- package/dist/.setup/{settled-turn-finalizer-DiAi6Kx6.mjs → settled-turn-finalizer-DW9W3gza.mjs} +14 -10
- package/dist/.setup/{shared-client-DA4VR4Eb.mjs → shared-client-CJCTeFpQ.mjs} +783 -412
- package/dist/.setup/shared-client-lifecycle-7xgtlo15.mjs +153 -0
- package/dist/.setup/{side-question-BJ1wSDcB.mjs → side-question-BLeGj7TQ.mjs} +79 -143
- package/dist/.setup/{source-CUzJq5WN.mjs → source-CJis_1EF.mjs} +80 -137
- package/dist/.setup/{thread-lifecycle-B3mfz1TG.mjs → thread-lifecycle-_bAbjedG.mjs} +294 -737
- package/dist/.setup/{thread-ownership-DcTtAcXj.mjs → thread-ownership-B6pPt21M.mjs} +45 -10
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-policy-DGuQsuFC.mjs → thread-policy-gNPzzpVp.mjs} +46 -7
- package/dist/.setup/{thread-requests-BLvGkP2R.mjs → thread-requests-OWGOiDaV.mjs} +199 -302
- package/dist/.setup/{thread-resume-DIBXwOpE.mjs → thread-resume-GOry0AYh.mjs} +6 -6
- package/dist/.setup/{timeout-C910MdAB.mjs → timeout-CXOfNoaX.mjs} +1 -35
- package/dist/.setup/{transcript-history-projection-ZZpkFkJ_.mjs → transcript-history-projection-DRSifI-1.mjs} +17 -89
- package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
- package/dist/.setup/{transcript-mirror-BtHDBp1G.mjs → transcript-mirror-kxmCYsuF.mjs} +7 -9
- package/dist/.setup/{transport-stdio-h2VHOskC.mjs → transport-stdio-Bdegpn2V.mjs} +5 -22
- 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-BUr4OUbC.mjs → upstream-session-fork-gkdRj2yH.mjs} +23 -23
- package/dist/.setup/{usage-BML0r-ua.mjs → usage-CApUvLOV.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-DUMbefVY.mjs → usage-limit-error-wSMQkbpV.mjs} +4 -19
- package/dist/.setup/{web-search-provider.runtime-CDKlN-Rv.mjs → web-search-provider.runtime-UKgeiBUG.mjs} +8 -19
- package/dist/api.js +9 -11
- package/dist/catalog-page.worker.js +1 -1
- 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 +193 -245
- 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 +3 -3
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +14 -2
- package/package.json +7 -6
- package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +0 -331
- package/dist/.setup/compact-Du5UvtxA.mjs +0 -680
- package/dist/.setup/event-projector-assistant-message-BsruvNrH.mjs +0 -103
- package/dist/.setup/event-projector-items-C6L_5ZiT.mjs +0 -234
- package/dist/.setup/harness-a_MsE4-_.mjs +0 -355
- package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
- package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
- package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
- package/dist/.setup/native-subagent-history-0nYYgo0k.mjs +0 -148
- package/dist/.setup/native-subagent-task-ids-wb8CKZGN.mjs +0 -441
- package/dist/.setup/plugin-approval-roundtrip-C0MZzCuP.mjs +0 -122
- package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/.setup/sandbox-guard-C2sRMOEY.mjs +0 -166
- package/dist/.setup/session-binding-Cm0apEbd.mjs +0 -692
- package/dist/.setup/session-catalog-events-Bj6j94E_.mjs +0 -347
- package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
- package/dist/.setup/session-initialization-rcgbZiid.mjs +0 -75
- package/dist/.setup/thread-history-page-DoVpnHim.mjs +0 -83
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as CodexAppServerScopedRequestRejectedError } from "./request-
|
|
4
|
-
import {
|
|
5
|
-
import { b as assertCodexThreadResumeResponse, l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-
|
|
6
|
-
import { i as assertCodexThreadResumeSubscription, p as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-
|
|
1
|
+
import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
|
|
2
|
+
import { r as publishCodexCatalogResume } from "./session-catalog-events-BMCFMZw-.mjs";
|
|
3
|
+
import { t as CodexAppServerScopedRequestRejectedError } from "./request-BZOfsSXW.mjs";
|
|
4
|
+
import { L as forgetCodexWorkspaceReferences, ft as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CJCTeFpQ.mjs";
|
|
5
|
+
import { b as assertCodexThreadResumeResponse, l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-qyUBJlGZ.mjs";
|
|
6
|
+
import { i as assertCodexThreadResumeSubscription, p as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-B-S7ngS_.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,42 +1,8 @@
|
|
|
1
|
-
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
2
1
|
import { withTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
3
|
-
//#region extensions/codex/src/app-server/rpc-error.ts
|
|
4
|
-
const CODEX_APP_SERVER_OVERLOADED_ERROR_CODE = -32001;
|
|
5
|
-
/** RPC error wrapper that preserves app-server error code and data. */
|
|
6
|
-
var CodexAppServerRpcError = class extends Error {
|
|
7
|
-
constructor(error, method) {
|
|
8
|
-
super(formatCodexAppServerRpcErrorMessage(error, method));
|
|
9
|
-
this.name = "CodexAppServerRpcError";
|
|
10
|
-
this.code = error.code;
|
|
11
|
-
this.data = error.data;
|
|
12
|
-
this.method = method;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function isCodexThreadReadMissingError(error, threadId) {
|
|
16
|
-
return error instanceof CodexAppServerRpcError && error.method === "thread/read" && error.code === -32600 && error.message === `thread not loaded: ${threadId}`;
|
|
17
|
-
}
|
|
18
|
-
function formatCodexAppServerRpcErrorMessage(error, method) {
|
|
19
|
-
const message = error.message || `${method} failed`;
|
|
20
|
-
const detail = readCodexAppServerRpcReloginDetail(error.data);
|
|
21
|
-
return detail && !message.includes(detail) ? `${message}: ${detail}` : message;
|
|
22
|
-
}
|
|
23
|
-
function readCodexAppServerRpcReloginDetail(data) {
|
|
24
|
-
const record = isJsonObject(data) ? data : void 0;
|
|
25
|
-
const nested = isJsonObject(record?.error) ? record.error : record;
|
|
26
|
-
if (!nested) return;
|
|
27
|
-
const isRelogin = nested.action === "relogin" || nested.reason === "cloudRequirements" && nested.errorCode === "Auth";
|
|
28
|
-
const detail = typeof nested.detail === "string" ? nested.detail.trim() : "";
|
|
29
|
-
return isRelogin && detail ? detail : void 0;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
2
|
//#region extensions/codex/src/app-server/timeout.ts
|
|
33
|
-
/**
|
|
34
|
-
* Thin Codex app-server timeout adapter around OpenClaw's shared timeout helper.
|
|
35
|
-
*/
|
|
36
3
|
function resolveAbortError(signal) {
|
|
37
4
|
return signal.reason instanceof Error ? signal.reason : new Error("Codex app-server operation aborted", { cause: signal.reason });
|
|
38
5
|
}
|
|
39
|
-
/** Awaits a promise with a Codex-specific timeout error message. */
|
|
40
6
|
async function withTimeout$1(promise, timeoutMs, timeoutMessage, createError) {
|
|
41
7
|
return await withTimeout(promise, timeoutMs, {
|
|
42
8
|
message: timeoutMessage,
|
|
@@ -77,4 +43,4 @@ function abortReason(signal) {
|
|
|
77
43
|
return signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "codex app-server thread route aborted"));
|
|
78
44
|
}
|
|
79
45
|
//#endregion
|
|
80
|
-
export {
|
|
46
|
+
export { withTimeout$1 as i, waitForPromiseOrAbort as n, withAbortableTimeout as r, abortReason as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-
|
|
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
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
6
6
|
import { Buffer } from "node:buffer";
|
|
@@ -9,9 +9,7 @@ const CODEX_HISTORY_IMPORT_MAX_MESSAGES = 200;
|
|
|
9
9
|
const CODEX_HISTORY_IMPORT_MAX_BYTES = 524288;
|
|
10
10
|
const CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES = 65536;
|
|
11
11
|
const CODEX_HISTORY_TRUNCATION_SUFFIX = "\n\n[Message truncated during Codex history import.]";
|
|
12
|
-
const CODEX_HISTORY_ASSISTANT_API = "openai-chatgpt-responses";
|
|
13
12
|
const CODEX_HISTORY_ASSISTANT_PROVIDER = "openai";
|
|
14
|
-
const CODEX_HISTORY_ASSISTANT_MODEL = "native-history";
|
|
15
13
|
const CODEX_HISTORY_ZERO_USAGE = {
|
|
16
14
|
input: 0,
|
|
17
15
|
output: 0,
|
|
@@ -26,6 +24,14 @@ const CODEX_HISTORY_ZERO_USAGE = {
|
|
|
26
24
|
total: 0
|
|
27
25
|
}
|
|
28
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
|
+
}
|
|
29
35
|
function projectCodexHistoryMessage(message, text) {
|
|
30
36
|
const phase = message.role === "assistant" && "phase" in message && (message.phase === "commentary" || message.phase === "final_answer") ? message.phase : void 0;
|
|
31
37
|
return {
|
|
@@ -85,6 +91,7 @@ function selectTurnsThroughBoundary(thread, throughTurnId) {
|
|
|
85
91
|
}
|
|
86
92
|
function projectCodexThreadHistory(params) {
|
|
87
93
|
const projected = [];
|
|
94
|
+
const assistantFields = historyAssistantFields(normalizeOptionalString(params.modelProvider) ?? normalizeOptionalString(params.thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER);
|
|
88
95
|
const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
|
|
89
96
|
let itemOffset = 0;
|
|
90
97
|
for (const turn of params.turns) {
|
|
@@ -94,8 +101,7 @@ function projectCodexThreadHistory(params) {
|
|
|
94
101
|
nativeTurnId: turn.id
|
|
95
102
|
}) : void 0;
|
|
96
103
|
let hasAssistantMessage = false;
|
|
97
|
-
for (const
|
|
98
|
-
const item = value;
|
|
104
|
+
for (const item of turn.items) {
|
|
99
105
|
const itemId = normalizeOptionalString(item.id);
|
|
100
106
|
const identity = `${turn.id}:${itemId ?? itemOffset}`;
|
|
101
107
|
const timestampSeconds = item.type === "agentMessage" ? turn.completedAt ?? turn.startedAt : turn.startedAt ?? turn.completedAt;
|
|
@@ -115,17 +121,10 @@ function projectCodexThreadHistory(params) {
|
|
|
115
121
|
type: "text",
|
|
116
122
|
text
|
|
117
123
|
}],
|
|
118
|
-
|
|
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,
|
|
124
|
+
...assistantFields,
|
|
122
125
|
stopReason: turn.status === "interrupted" ? "aborted" : turn.status === "failed" ? "error" : "stop",
|
|
123
126
|
...turn.status === "failed" && turn.error?.message ? { errorMessage: turn.error.message } : {},
|
|
124
|
-
...
|
|
125
|
-
type: "provider_refusal",
|
|
126
|
-
timestamp,
|
|
127
|
-
details: codexProviderRefusalDetails(refusal)
|
|
128
|
-
}] } : {},
|
|
127
|
+
...codexProviderRefusalDiagnostics(terminalAssistant ? refusal : void 0, timestamp),
|
|
129
128
|
...phase ? { phase } : {},
|
|
130
129
|
...asyncDelivery && itemId ? { openclawAsyncDelivery: {
|
|
131
130
|
itemId,
|
|
@@ -145,17 +144,10 @@ function projectCodexThreadHistory(params) {
|
|
|
145
144
|
const message = attachCodexMirrorIdentity({
|
|
146
145
|
role: "assistant",
|
|
147
146
|
content: [],
|
|
148
|
-
|
|
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,
|
|
147
|
+
...assistantFields,
|
|
152
148
|
stopReason: "error",
|
|
153
149
|
errorMessage: text,
|
|
154
|
-
...refusal
|
|
155
|
-
type: "provider_refusal",
|
|
156
|
-
timestamp,
|
|
157
|
-
details: codexProviderRefusalDetails(refusal)
|
|
158
|
-
}] } : {},
|
|
150
|
+
...codexProviderRefusalDiagnostics(refusal, timestamp),
|
|
159
151
|
timestamp
|
|
160
152
|
}, `${turn.id}:assistant`);
|
|
161
153
|
projected.push(projectCodexHistoryMessage(message, ""));
|
|
@@ -205,69 +197,5 @@ function projectBoundedCodexVisibleSessionHistory(entries) {
|
|
|
205
197
|
}
|
|
206
198
|
return selectBoundedCodexHistoryTail(projected).map(({ responseItem }) => responseItem);
|
|
207
199
|
}
|
|
208
|
-
/** Displays native items through the shared transcript roles, including an unfinished turn. */
|
|
209
|
-
function projectCodexThreadHistoryItem(thread, entry, toolItems) {
|
|
210
|
-
const { item } = entry;
|
|
211
|
-
const timestamp = (entry.turn?.startedAt ?? thread.createdAt ?? 0) * 1e3;
|
|
212
|
-
if (item.type === "userMessage" || item.type === "agentMessage") return projectCodexThreadHistory({
|
|
213
|
-
thread,
|
|
214
|
-
turns: [{
|
|
215
|
-
...entry.turn,
|
|
216
|
-
id: entry.turnId,
|
|
217
|
-
items: [item]
|
|
218
|
-
}],
|
|
219
|
-
importedAt: timestamp
|
|
220
|
-
}).map(({ message }) => message);
|
|
221
|
-
const identity = `${entry.turnId}:${item.id}`;
|
|
222
|
-
const assistant = (content, toolUse = false) => attachCodexMirrorIdentity({
|
|
223
|
-
role: "assistant",
|
|
224
|
-
content,
|
|
225
|
-
api: CODEX_HISTORY_ASSISTANT_API,
|
|
226
|
-
provider: normalizeOptionalString(thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
|
|
227
|
-
model: CODEX_HISTORY_ASSISTANT_MODEL,
|
|
228
|
-
usage: CODEX_HISTORY_ZERO_USAGE,
|
|
229
|
-
stopReason: toolUse ? "toolUse" : "stop",
|
|
230
|
-
timestamp
|
|
231
|
-
}, identity);
|
|
232
|
-
if (item.type === "reasoning") {
|
|
233
|
-
const parts = Array.isArray(item.summary) && item.summary.length > 0 ? item.summary : item.content;
|
|
234
|
-
const thinking = normalizeImportedHistoryText(Array.isArray(parts) ? parts.filter((part) => typeof part === "string").join("\n") : item.text);
|
|
235
|
-
return thinking ? [assistant([{
|
|
236
|
-
type: "thinking",
|
|
237
|
-
thinking
|
|
238
|
-
}])] : [];
|
|
239
|
-
}
|
|
240
|
-
if (item.type === "contextCompaction") return [assistant([{
|
|
241
|
-
type: "text",
|
|
242
|
-
text: "Context compacted."
|
|
243
|
-
}])];
|
|
244
|
-
const toolName = itemName(item) ?? auditNativeToolName(item);
|
|
245
|
-
if (!toolName) {
|
|
246
|
-
const text = normalizeImportedHistoryText(item.text ?? item.title);
|
|
247
|
-
return text ? [assistant([{
|
|
248
|
-
type: "text",
|
|
249
|
-
text
|
|
250
|
-
}])] : [];
|
|
251
|
-
}
|
|
252
|
-
const messages = [assistant([{
|
|
253
|
-
type: "toolCall",
|
|
254
|
-
id: item.id,
|
|
255
|
-
name: toolName,
|
|
256
|
-
arguments: toolItems.itemToolArgs(item) ?? {}
|
|
257
|
-
}], true)];
|
|
258
|
-
const status = itemStatus(item);
|
|
259
|
-
if (status !== "running") messages.push(attachCodexMirrorIdentity({
|
|
260
|
-
role: "toolResult",
|
|
261
|
-
toolCallId: item.id,
|
|
262
|
-
toolName,
|
|
263
|
-
content: [{
|
|
264
|
-
type: "text",
|
|
265
|
-
text: toolItems.itemTranscriptResultText(item) ?? status
|
|
266
|
-
}],
|
|
267
|
-
isError: status === "failed" || status === "blocked",
|
|
268
|
-
timestamp
|
|
269
|
-
}, `${identity}:result`));
|
|
270
|
-
return messages;
|
|
271
|
-
}
|
|
272
200
|
//#endregion
|
|
273
|
-
export {
|
|
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) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
1
|
import { t as readCodexAsyncQuestions } from "./async-questions-DdhOCwGi.mjs";
|
|
3
|
-
import { i as readUpstreamUserText, n as attachUpstreamUserText, r as readMirrorIdentity, t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-
|
|
4
|
-
import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-
|
|
5
|
-
import { a as fingerprintCodexMirrorSourceMessage, c as readCodexMirrorSourceFingerprint, i as buildCodexMirrorDedupeIdentity, n as attachCodexMirrorAttestation, r as attachCodexMirrorRunId, s as isMirroredAgentMessage, t as applyCodexTranscriptTaint } from "./transcript-mirror-attestation-
|
|
2
|
+
import { i as readUpstreamUserText, n as attachUpstreamUserText, r as readMirrorIdentity, t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-fXkKbPVC.mjs";
|
|
3
|
+
import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-DRSifI-1.mjs";
|
|
4
|
+
import { a as fingerprintCodexMirrorSourceMessage, c as readCodexMirrorSourceFingerprint, i as buildCodexMirrorDedupeIdentity, n as attachCodexMirrorAttestation, r as attachCodexMirrorRunId, s as isMirroredAgentMessage, t as applyCodexTranscriptTaint } from "./transcript-mirror-attestation-YSegaktH.mjs";
|
|
5
|
+
import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
|
|
6
6
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { deliverAgentHarnessUserInputPrompt, embeddedAgentLog, formatErrorMessage, projectAgentHarnessTranscriptMessageForDisplay, restorePreparedUserTurnOperationalMetaForRuntime, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
8
8
|
import { withCodexSessionTranscriptMirrorWriteLock } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
|
|
@@ -229,12 +229,10 @@ function buildFromPrepared(params, preparedUserMessage) {
|
|
|
229
229
|
function buildCodexUserPromptMessage(params) {
|
|
230
230
|
return buildFromPrepared(params, params.userTurnTranscriptRecorder?.message);
|
|
231
231
|
}
|
|
232
|
-
function buildCodexUpstreamPromptMessage(params, identity, upstreamUserText) {
|
|
233
|
-
const message = attachCodexMirrorIdentity(buildCodexUserPromptMessage(params), identity);
|
|
234
|
-
return upstreamUserText ? attachUpstreamUserText(message, upstreamUserText) : message;
|
|
235
|
-
}
|
|
236
232
|
function promptSnapshot(params, turnId, upstreamUserText) {
|
|
237
|
-
|
|
233
|
+
if (params.suppressNextUserMessagePersistence) return [];
|
|
234
|
+
const message = attachCodexMirrorIdentity(buildCodexUserPromptMessage(params), `${turnId}:prompt`);
|
|
235
|
+
return [upstreamUserText ? attachUpstreamUserText(message, upstreamUserText) : message];
|
|
238
236
|
}
|
|
239
237
|
async function buildResolvedCodexUserPromptMessage(params) {
|
|
240
238
|
return buildFromPrepared(params, await params.userTurnTranscriptRecorder?.resolveMessage() ?? params.userTurnTranscriptRecorder?.message);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as normalizeCodexAppServerArgs } from "./launch-args-DbFCehO7.mjs";
|
|
2
|
-
import { i as resolveManagedCodexNativeCommand } from "./managed-binary-
|
|
2
|
+
import { i as resolveManagedCodexNativeCommand } from "./managed-binary-kiWRhNRE.mjs";
|
|
3
3
|
import { i as recordCodexAppServerSpawnFailure, r as getCodexAppServerSpawnFailure } from "./spawn-error-CL3n6MAa.mjs";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -716,12 +716,7 @@ function beginCodexAppServerTransportClose(child, options) {
|
|
|
716
716
|
finishCodexAppServerTransportClose(child, options, forceKill);
|
|
717
717
|
return "uncertain";
|
|
718
718
|
}
|
|
719
|
-
|
|
720
|
-
try {
|
|
721
|
-
contained = await terminateCodexAppServerDescendants(child);
|
|
722
|
-
} catch {
|
|
723
|
-
contained = void 0;
|
|
724
|
-
}
|
|
719
|
+
const contained = await terminateCodexAppServerDescendants(child).catch(() => void 0);
|
|
725
720
|
if (contained === "exited") return "natural";
|
|
726
721
|
try {
|
|
727
722
|
finishCodexAppServerTransportClose(child, options, forceKill, contained?.resume);
|
|
@@ -782,7 +777,7 @@ async function closeCodexAppServerTransportAndWait(child, options = {}) {
|
|
|
782
777
|
};
|
|
783
778
|
}
|
|
784
779
|
function hasCodexAppServerTransportExited(child) {
|
|
785
|
-
return child.exitCode
|
|
780
|
+
return child.exitCode != null || child.signalCode != null;
|
|
786
781
|
}
|
|
787
782
|
async function waitForCodexAppServerTransportExit(child, timeoutMs, drained) {
|
|
788
783
|
return await new Promise((resolve) => {
|
|
@@ -857,7 +852,7 @@ function resolveCodexAppServerSpawnEnv(options, baseEnv = process.env, platform
|
|
|
857
852
|
const env = Object.create(null);
|
|
858
853
|
copySafeEnvironmentEntries(env, baseEnv);
|
|
859
854
|
copySafeEnvironmentEntries(env, options.env ?? {});
|
|
860
|
-
const keysToClear =
|
|
855
|
+
const keysToClear = (options.clearEnv ?? []).map((key) => key.trim()).filter(Boolean);
|
|
861
856
|
if (platform === "win32") {
|
|
862
857
|
const lowerCaseKeysToClear = new Set(keysToClear.map((key) => key.toLowerCase()));
|
|
863
858
|
for (const candidate of Object.keys(env)) if (lowerCaseKeysToClear.has(candidate.toLowerCase())) delete env[candidate];
|
|
@@ -869,18 +864,6 @@ function isCodexRuntimeInjectionEnvironmentKey(rawKey) {
|
|
|
869
864
|
const key = rawKey.toUpperCase();
|
|
870
865
|
return RUNTIME_INJECTION_ENVIRONMENT_KEYS.has(key) || key.startsWith("DYLD_");
|
|
871
866
|
}
|
|
872
|
-
/** Keeps QA-owned app-server processes inside the gateway process-group cleanup boundary. */
|
|
873
|
-
function resolveCodexAppServerDetachedMode(env, platform = process.platform) {
|
|
874
|
-
return platform !== "win32" && !env[QA_PARENT_PID_ENV]?.trim();
|
|
875
|
-
}
|
|
876
|
-
function normalizedEnvironmentKeys(rawKeys) {
|
|
877
|
-
const keys = [];
|
|
878
|
-
for (const rawKey of rawKeys) {
|
|
879
|
-
const key = rawKey.trim();
|
|
880
|
-
if (key.length > 0) keys.push(key);
|
|
881
|
-
}
|
|
882
|
-
return keys;
|
|
883
|
-
}
|
|
884
867
|
function copySafeEnvironmentEntries(target, source) {
|
|
885
868
|
for (const [key, value] of Object.entries(source)) {
|
|
886
869
|
if (UNSAFE_ENVIRONMENT_KEYS.has(key)) continue;
|
|
@@ -915,7 +898,7 @@ async function createStdioTransport(options, baseEnv = process.env, assertCurren
|
|
|
915
898
|
child = spawn(invocation.command, invocation.argv, {
|
|
916
899
|
...options.cwd !== void 0 ? { cwd: options.cwd } : {},
|
|
917
900
|
env,
|
|
918
|
-
detached:
|
|
901
|
+
detached: process.platform !== "win32" && !env[QA_PARENT_PID_ENV]?.trim(),
|
|
919
902
|
shell: invocation.shell,
|
|
920
903
|
stdio: [
|
|
921
904
|
"pipe",
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { r as resolveCodexAppServerUserHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
|
|
2
|
+
import "./config-DKhXquav.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { EventEmitter } from "node:events";
|
|
5
|
+
import net from "node:net";
|
|
6
|
+
import { PassThrough, Writable } from "node:stream";
|
|
7
|
+
import { StringDecoder } from "node:string_decoder";
|
|
8
|
+
import { WebSocket } from "openclaw/plugin-sdk/websocket-runtime";
|
|
9
|
+
//#region extensions/codex/src/app-server/transport-websocket.ts
|
|
10
|
+
/**
|
|
11
|
+
* Adapts a remote Codex app-server WebSocket endpoint to the shared stdio-like
|
|
12
|
+
* transport interface.
|
|
13
|
+
*/
|
|
14
|
+
const WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
15
|
+
const WEBSOCKET_PING_INTERVAL_MS = 2e4;
|
|
16
|
+
const WEBSOCKET_PONG_TIMEOUT_MS = 2e4;
|
|
17
|
+
const MAX_CONSECUTIVE_MISSED_WEBSOCKET_PONGS = 5;
|
|
18
|
+
/** Only the transport can prove that its buffered initialize never reached a peer. */
|
|
19
|
+
function isCodexWebSocketOpenFailure(error) {
|
|
20
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21
|
+
let current = error;
|
|
22
|
+
while (current instanceof Error && !seen.has(current)) {
|
|
23
|
+
seen.add(current);
|
|
24
|
+
if ("code" in current && current.code === "CODEX_APP_SERVER_WEBSOCKET_OPEN_FAILED") return true;
|
|
25
|
+
current = current.cause;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
/** Opens a WebSocket app-server transport and maps newline-delimited frames to stdout/stdin. */
|
|
30
|
+
function createWebSocketTransport(options) {
|
|
31
|
+
if (!options.url) throw new Error("codex app-server websocket transport requires plugins.entries.codex.config.appServer.url");
|
|
32
|
+
const events = new EventEmitter();
|
|
33
|
+
const stdout = new PassThrough();
|
|
34
|
+
const stderr = new PassThrough();
|
|
35
|
+
const websocketOptions = {
|
|
36
|
+
headers: {
|
|
37
|
+
...options.headers,
|
|
38
|
+
...options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {}
|
|
39
|
+
},
|
|
40
|
+
perMessageDeflate: false,
|
|
41
|
+
...options.transport === "websocket" ? { handshakeTimeout: WEBSOCKET_HANDSHAKE_TIMEOUT_MS } : {}
|
|
42
|
+
};
|
|
43
|
+
const unixSocketPath = resolveCodexAppServerUnixSocketPath(options);
|
|
44
|
+
const socket = unixSocketPath ? new WebSocket("ws://localhost/", {
|
|
45
|
+
...websocketOptions,
|
|
46
|
+
createConnection: () => connectCodexAppServerUnixSocket(unixSocketPath)
|
|
47
|
+
}) : new WebSocket(options.url, websocketOptions);
|
|
48
|
+
const pendingFrames = [];
|
|
49
|
+
const stdinDecoder = new StringDecoder("utf8");
|
|
50
|
+
let pendingLine = "";
|
|
51
|
+
let opened = false;
|
|
52
|
+
let killed = false;
|
|
53
|
+
let exitCode = null;
|
|
54
|
+
let pingTimeout;
|
|
55
|
+
let pongTimeout;
|
|
56
|
+
let expectedPong;
|
|
57
|
+
let consecutiveMissedPongs = 0;
|
|
58
|
+
let heartbeatSequence = 0;
|
|
59
|
+
const clearConnectionHealthTimers = () => {
|
|
60
|
+
if (pingTimeout) {
|
|
61
|
+
clearTimeout(pingTimeout);
|
|
62
|
+
pingTimeout = void 0;
|
|
63
|
+
}
|
|
64
|
+
if (pongTimeout) {
|
|
65
|
+
clearTimeout(pongTimeout);
|
|
66
|
+
pongTimeout = void 0;
|
|
67
|
+
}
|
|
68
|
+
expectedPong = void 0;
|
|
69
|
+
};
|
|
70
|
+
const sendHeartbeatPing = () => {
|
|
71
|
+
if (socket.readyState !== WebSocket.OPEN || pongTimeout) return;
|
|
72
|
+
const payload = Buffer.from(`openclaw-codex-${++heartbeatSequence}`);
|
|
73
|
+
expectedPong = payload;
|
|
74
|
+
pongTimeout = setTimeout(() => {
|
|
75
|
+
pongTimeout = void 0;
|
|
76
|
+
expectedPong = void 0;
|
|
77
|
+
consecutiveMissedPongs += 1;
|
|
78
|
+
if (consecutiveMissedPongs >= MAX_CONSECUTIVE_MISSED_WEBSOCKET_PONGS) {
|
|
79
|
+
socket.terminate();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
sendHeartbeatPing();
|
|
83
|
+
}, WEBSOCKET_PONG_TIMEOUT_MS);
|
|
84
|
+
pongTimeout.unref();
|
|
85
|
+
socket.ping(payload, void 0, (error) => {
|
|
86
|
+
if (error) socket.terminate();
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const scheduleHeartbeatPing = () => {
|
|
90
|
+
if (options.transport !== "websocket" || socket.readyState !== WebSocket.OPEN || pingTimeout || pongTimeout) return;
|
|
91
|
+
pingTimeout = setTimeout(() => {
|
|
92
|
+
pingTimeout = void 0;
|
|
93
|
+
sendHeartbeatPing();
|
|
94
|
+
}, WEBSOCKET_PING_INTERVAL_MS);
|
|
95
|
+
pingTimeout.unref();
|
|
96
|
+
};
|
|
97
|
+
const recordConnectionActivity = () => {
|
|
98
|
+
consecutiveMissedPongs = 0;
|
|
99
|
+
if (pongTimeout) {
|
|
100
|
+
clearTimeout(pongTimeout);
|
|
101
|
+
pongTimeout = void 0;
|
|
102
|
+
}
|
|
103
|
+
expectedPong = void 0;
|
|
104
|
+
scheduleHeartbeatPing();
|
|
105
|
+
};
|
|
106
|
+
const sendFrame = (frame) => {
|
|
107
|
+
const trimmed = frame.trim();
|
|
108
|
+
if (!trimmed) return;
|
|
109
|
+
if (socket.readyState === WebSocket.OPEN) {
|
|
110
|
+
socket.send(trimmed);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
pendingFrames.push(trimmed);
|
|
114
|
+
};
|
|
115
|
+
socket.once("open", () => {
|
|
116
|
+
opened = true;
|
|
117
|
+
for (const frame of pendingFrames.splice(0)) socket.send(frame);
|
|
118
|
+
scheduleHeartbeatPing();
|
|
119
|
+
});
|
|
120
|
+
socket.on("pong", (payload) => {
|
|
121
|
+
if (expectedPong?.equals(payload)) recordConnectionActivity();
|
|
122
|
+
});
|
|
123
|
+
socket.once("error", (error) => {
|
|
124
|
+
clearConnectionHealthTimers();
|
|
125
|
+
const code = "code" in error ? error.code : void 0;
|
|
126
|
+
if (options.transport === "websocket" && !opened && (code === "ECONNREFUSED" || code === "ECONNRESET" || code === "ETIMEDOUT" || error.message === "Opening handshake has timed out")) {
|
|
127
|
+
events.emit("error", Object.assign(new Error(error.message, { cause: error }), { code: "CODEX_APP_SERVER_WEBSOCKET_OPEN_FAILED" }));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
events.emit("error", error);
|
|
131
|
+
});
|
|
132
|
+
socket.once("close", (code, reason) => {
|
|
133
|
+
clearConnectionHealthTimers();
|
|
134
|
+
killed = true;
|
|
135
|
+
exitCode = code;
|
|
136
|
+
events.emit("exit", code, reason.toString("utf8"));
|
|
137
|
+
});
|
|
138
|
+
socket.on("message", (data) => {
|
|
139
|
+
if (options.transport === "websocket") recordConnectionActivity();
|
|
140
|
+
const frame = websocketFrameToBuffer(data);
|
|
141
|
+
const writable = stdout.write(frame);
|
|
142
|
+
const delimited = frame.at(-1) === 10 || stdout.write(Buffer.from("\n"));
|
|
143
|
+
if (!writable || !delimited) socket.pause();
|
|
144
|
+
});
|
|
145
|
+
stdout.on("drain", () => {
|
|
146
|
+
if (socket.readyState === WebSocket.OPEN) socket.resume();
|
|
147
|
+
});
|
|
148
|
+
const stdin = new Writable({
|
|
149
|
+
write(chunk, _encoding, callback) {
|
|
150
|
+
pendingLine += stdinDecoder.write(chunk);
|
|
151
|
+
const lines = pendingLine.split("\n");
|
|
152
|
+
pendingLine = lines.pop() ?? "";
|
|
153
|
+
for (const frame of lines) sendFrame(frame);
|
|
154
|
+
callback();
|
|
155
|
+
},
|
|
156
|
+
final(callback) {
|
|
157
|
+
pendingLine += stdinDecoder.end();
|
|
158
|
+
if (pendingLine) sendFrame(pendingLine);
|
|
159
|
+
pendingLine = "";
|
|
160
|
+
callback();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
const closeSocket = () => {
|
|
164
|
+
if (socket.readyState === WebSocket.CLOSED || socket.readyState === WebSocket.CLOSING) return;
|
|
165
|
+
socket.close();
|
|
166
|
+
};
|
|
167
|
+
stdin.once("finish", closeSocket);
|
|
168
|
+
stdin.once("close", closeSocket);
|
|
169
|
+
return {
|
|
170
|
+
maxFrameBytes: 16777216,
|
|
171
|
+
stdin,
|
|
172
|
+
stdout,
|
|
173
|
+
stderr,
|
|
174
|
+
get killed() {
|
|
175
|
+
return killed;
|
|
176
|
+
},
|
|
177
|
+
get exitCode() {
|
|
178
|
+
return exitCode;
|
|
179
|
+
},
|
|
180
|
+
kill: (signal) => {
|
|
181
|
+
killed = true;
|
|
182
|
+
clearConnectionHealthTimers();
|
|
183
|
+
if (signal === "SIGKILL") socket.terminate();
|
|
184
|
+
else socket.close();
|
|
185
|
+
},
|
|
186
|
+
once: (event, listener) => events.once(event, listener),
|
|
187
|
+
off: (event, listener) => events.off(event, listener)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** Named local-only socket boundary for the egress classifier. */
|
|
191
|
+
function connectCodexAppServerUnixSocket(socketPath) {
|
|
192
|
+
return net.createConnection(socketPath);
|
|
193
|
+
}
|
|
194
|
+
/** Resolves the canonical or explicitly configured Codex control socket. */
|
|
195
|
+
function resolveCodexAppServerUnixSocketPath(options) {
|
|
196
|
+
if (options.transport !== "unix") {
|
|
197
|
+
if (options.url?.startsWith("unix://")) throw new Error("codex app-server unix URL requires unix transport");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const url = options.url ?? "unix://";
|
|
201
|
+
if (!url.startsWith("unix://")) throw new Error("codex app-server unix transport requires a unix:// URL");
|
|
202
|
+
return url.slice(7) || path.join(resolveCodexAppServerUserHomeDir(options.env ?? process.env), "app-server-control", "app-server-control.sock");
|
|
203
|
+
}
|
|
204
|
+
function websocketFrameToBuffer(data) {
|
|
205
|
+
if (typeof data === "string") return Buffer.from(data);
|
|
206
|
+
if (Buffer.isBuffer(data)) return data;
|
|
207
|
+
if (Array.isArray(data)) return Buffer.concat(data);
|
|
208
|
+
return Buffer.from(data);
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
export { isCodexWebSocketOpenFailure as n, resolveCodexAppServerUnixSocketPath as r, createWebSocketTransport as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
1
|
+
import { asOptionalRecord, readNonEmptyStringPreservingWhitespace } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
//#region extensions/codex/src/app-server/upstream-prompt-provenance.ts
|
|
3
3
|
const UPSTREAM_USER_TEXT_META_KEY = "upstreamUserText";
|
|
4
4
|
const MIRROR_IDENTITY_META_KEY = "mirrorIdentity";
|
|
@@ -16,10 +16,7 @@ function attachCodexMirrorIdentity(message, identity) {
|
|
|
16
16
|
}
|
|
17
17
|
function readMirrorIdentity(message) {
|
|
18
18
|
const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
19
|
-
|
|
20
|
-
if (!record) return;
|
|
21
|
-
const id = record[MIRROR_IDENTITY_META_KEY];
|
|
22
|
-
return typeof id === "string" && id ? id : void 0;
|
|
19
|
+
return readNonEmptyStringPreservingWhitespace(asOptionalRecord(meta)?.[MIRROR_IDENTITY_META_KEY]);
|
|
23
20
|
}
|
|
24
21
|
function attachUpstreamUserText(message, text) {
|
|
25
22
|
const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
@@ -34,10 +31,7 @@ function attachUpstreamUserText(message, text) {
|
|
|
34
31
|
}
|
|
35
32
|
function readUpstreamUserText(message) {
|
|
36
33
|
const meta = message && CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
|
|
37
|
-
|
|
38
|
-
if (!record) return;
|
|
39
|
-
const text = record[UPSTREAM_USER_TEXT_META_KEY];
|
|
40
|
-
return typeof text === "string" && text ? text : void 0;
|
|
34
|
+
return readNonEmptyStringPreservingWhitespace(asOptionalRecord(meta)?.[UPSTREAM_USER_TEXT_META_KEY]);
|
|
41
35
|
}
|
|
42
36
|
//#endregion
|
|
43
37
|
export { readUpstreamUserText as i, attachUpstreamUserText as n, readMirrorIdentity as r, attachCodexMirrorIdentity as t };
|
package/dist/.setup/{upstream-session-fork-BUr4OUbC.mjs → upstream-session-fork-gkdRj2yH.mjs}
RENAMED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { m as sessionBindingIdentity } from "./session-binding-record-BGoz8wOK.mjs";
|
|
2
|
-
import { d as readCodexPluginConfig } from "./config-parsing-CcB9iPoq.mjs";
|
|
3
1
|
import { i as isJsonObject, r as flattenCodexDynamicToolFunctions } from "./protocol-CANUwXJ3.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { i as
|
|
2
|
+
import { v as sessionBindingIdentity } from "./session-binding-record-Oe9L-CNY.mjs";
|
|
3
|
+
import { d as readCodexPluginConfig } from "./config-parsing-b088LyhT.mjs";
|
|
4
|
+
import { s as assertCodexModelBackedReviewerEffectiveConfig } from "./config-options-CzyWLTJt.mjs";
|
|
5
|
+
import { t as withCodexAppServerThreadMutation } from "./thread-ownership-queue-Dp24d7-F.mjs";
|
|
6
|
+
import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-fXkKbPVC.mjs";
|
|
7
|
+
import { r as projectCodexUserItemText } from "./transcript-history-projection-DRSifI-1.mjs";
|
|
9
8
|
import { n as codexUpstreamBaseline, t as codexLastTerminalTurnId } from "./session-upstream-marker-D15C9NHp.mjs";
|
|
10
|
-
import { r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { r as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import "./
|
|
19
|
-
import
|
|
20
|
-
import "./thread-
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { n as
|
|
25
|
-
import {
|
|
9
|
+
import { r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BL9B5H0L.mjs";
|
|
10
|
+
import { n as readCodexSessionMeta } from "./session-catalog-provenance-DoAvktcj.mjs";
|
|
11
|
+
import { t as CodexAppServerScopedRequestRejectedError } from "./request-BZOfsSXW.mjs";
|
|
12
|
+
import { r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-DKhXquav.mjs";
|
|
13
|
+
import { r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
|
|
14
|
+
import { a as fingerprintCodexMirrorSourceMessage, c as readCodexMirrorSourceFingerprint } from "./transcript-mirror-attestation-YSegaktH.mjs";
|
|
15
|
+
import { P as claimCodexAppServerLiveThread, R as hasCodexAppServerLiveThread, f as readCodexAppServerClientDesktopGenerationFingerprint } from "./shared-client-CJCTeFpQ.mjs";
|
|
16
|
+
import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, v as assertCodexThreadAcceptsDirectInput, y as assertCodexThreadForkResponse } from "./client-qyUBJlGZ.mjs";
|
|
17
|
+
import { D as buildCodexNativeHookRelayConfig, E as assertCodexNativeHookRelayAllowed, H as applyCodexNativeSkillIsolation, I as checkCodexThreadAppAvailability, K as codexDynamicToolsFingerprint, M as resolveCodexNativeHookRelayEvents, St as mergeCodexThreadConfigs, U as resolveCodexNativeSkillIsolation, V as parseCodexNativeToolCatalog, X as fingerprintJsonObject, Z as fingerprintUserMcpServersConfigPatch, a as buildCodexThreadConfiguration, h as buildDeveloperInstructions, ht as buildCodexPluginThreadConfig, k as buildCodexNativeHookRelayId, p as resolveCodexWebSearchPlan, wt as shouldBuildCodexPluginThreadConfig } from "./thread-requests-OWGOiDaV.mjs";
|
|
18
|
+
import "./session-binding-DGCYAfvD.mjs";
|
|
19
|
+
import { a as refreshCodexThreadPolicy, n as CodexThreadPolicyHandoffError } from "./thread-policy-gNPzzpVp.mjs";
|
|
20
|
+
import "./thread-ownership-B6pPt21M.mjs";
|
|
21
|
+
import { n as resolveCodexNativeExecutionPolicy } from "./native-execution-policy-BxZJy5mP.mjs";
|
|
22
|
+
import { l as prepareCodexWorkspaceDeveloperInstructions } from "./attempt-workspace-context-BJ5Z_olH.mjs";
|
|
23
|
+
import { d as isCodexDynamicToolExcluded, n as resolveCodexProviderWebSearchSupportForClient } from "./provider-capabilities-DG5qbsUZ.mjs";
|
|
24
|
+
import { n as prepareCodexSessionInitialization } from "./session-initialization-6aveB9qb.mjs";
|
|
25
|
+
import { createImportedCodexSession } from "./session-history-import-WhX-X33a.mjs";
|
|
26
26
|
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
27
27
|
import { randomUUID } from "node:crypto";
|
|
28
28
|
import { isDeepStrictEqual } from "node:util";
|