@openclaw/codex 2026.9.6 → 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-Eem_WGqY.mjs → account-usage-runtime-DFhbh1zz.mjs} +5 -5
- package/dist/.setup/{apply-DDOi8uNx.mjs → apply-D3GcSoSa.mjs} +22 -36
- package/dist/.setup/{attempt-client-cleanup-CEv1cKwF.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +128 -37
- 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-B2mpaI9D.mjs → auth-cache-key-Dbvq-QgB.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-CbjoN2OW.mjs} +15 -18
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-C7EnDVgr.mjs → build-state-Da1_z0kd.mjs} +1 -1
- package/dist/.setup/{capabilities-CDXOOFdZ.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-Cs08OXVQ.mjs → client-N0JpgSzF.mjs} +138 -399
- package/dist/.setup/{client-catalog-response-BMgt_4q4.mjs → client-catalog-response-5HHLdcde.mjs} +1 -1
- package/dist/.setup/{command-dispatch-B4JuOsOk.mjs → command-dispatch-BeAoaovI.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-ylTMS00z.mjs} +222 -343
- package/dist/.setup/{command-rpc-DixIj3HW.mjs → command-rpc-CGJGUQ6Y.mjs} +15 -18
- package/dist/.setup/compact-C2WamavS.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-3Min8qvP.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-CEP8X5JC.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-DzlsLUuS.mjs} +2305 -2606
- package/dist/.setup/{effective-mcp-catalog-CvnvnGIe.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-poidXgek.mjs → ephemeral-turn-CDsPJOa2.mjs} +3 -3
- package/dist/.setup/event-projector-assistant-message-CigreO4K.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-Dm3PzxJk.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-PAuZgJC6.mjs} +11 -10
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-KnqBv0hE.mjs → models-DHXZtVVk.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-Dpsmf2wz.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-Y-QIvrKB.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-DsjsL1dr.mjs} +115 -175
- package/dist/.setup/{provider-BOsxQHOM.mjs → provider-DH8NSzGt.mjs} +11 -14
- package/dist/.setup/{provider-capabilities-BfE88FZ5.mjs → provider-capabilities-CAxoF-X1.mjs} +13 -18
- package/dist/.setup/{rate-limits-CMU3DUD0.mjs → rate-limits-B7-X2TgG.mjs} +9 -31
- package/dist/.setup/{request-D2L0zMrq.mjs → request-BHZ1nz8d.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-D8RZUOzY.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-4sCdv5qx.mjs} +170 -324
- 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-DePDzzjc.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-CZvDzC6z.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-DjhwGL6x.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-Cr5qP5Dj.mjs} +6 -4
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-irrD-uo7.mjs → session-cli-Cn_nCqfq.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-qMTxkNx2.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-BsvEabkw.mjs} +14 -10
- package/dist/.setup/{shared-client-DA4VR4Eb.mjs → shared-client-DqyTMYug.mjs} +783 -412
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
- package/dist/.setup/{side-question-BJ1wSDcB.mjs → side-question-C4kCmQy1.mjs} +79 -143
- package/dist/.setup/{source-CUzJq5WN.mjs → source-CS_7GFJZ.mjs} +80 -137
- package/dist/.setup/{thread-lifecycle-B3mfz1TG.mjs → thread-lifecycle-DPflntEJ.mjs} +294 -737
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-ownership-DcTtAcXj.mjs → thread-ownership-roNP0l1c.mjs} +45 -10
- package/dist/.setup/{thread-policy-DGuQsuFC.mjs → thread-policy-DTd-DtkX.mjs} +46 -7
- package/dist/.setup/{thread-requests-BLvGkP2R.mjs → thread-requests-B_bRnMGN.mjs} +199 -302
- package/dist/.setup/{thread-resume-DIBXwOpE.mjs → thread-resume-CdDaoc7T.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-CBeVjBpT.mjs} +23 -23
- package/dist/.setup/{usage-BML0r-ua.mjs → usage-BMzNxeR_.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-DUMbefVY.mjs → usage-limit-error-QXerDo3i.mjs} +4 -19
- package/dist/.setup/{web-search-provider.runtime-CDKlN-Rv.mjs → web-search-provider.runtime-P77OUeoo.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
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
2
|
+
import { asOptionalRecord, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region extensions/codex/src/app-server/native-subagent-history-owner.ts
|
|
7
|
+
const nonBlankString = z.string().refine((value) => Boolean(value.trim()));
|
|
8
|
+
const codexNativeSubagentHistoryOwnerSchema = z.object({
|
|
9
|
+
parentThreadId: nonBlankString,
|
|
10
|
+
sessionId: nonBlankString,
|
|
11
|
+
lifecycleRevision: nonBlankString.optional(),
|
|
12
|
+
connectionFingerprint: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
13
|
+
});
|
|
14
|
+
/** Automatic recovery may follow native rotation only within the same host lifecycle and connection. */
|
|
15
|
+
function matchesCodexNativeSubagentHistoryOwner(stored, current) {
|
|
16
|
+
return stored.connectionFingerprint === current.connectionFingerprint && stored.lifecycleRevision === current.lifecycleRevision && (stored.lifecycleRevision !== void 0 || stored.sessionId === current.sessionId);
|
|
17
|
+
}
|
|
18
|
+
function codexNativeSubagentHistoryConnectionFingerprint(binding) {
|
|
19
|
+
if (!binding.appServerRuntimeFingerprint) return;
|
|
20
|
+
return createHash("sha256").update(JSON.stringify([
|
|
21
|
+
binding.appServerRuntimeFingerprint,
|
|
22
|
+
binding.connectionScope ?? null,
|
|
23
|
+
binding.authProfileId ?? null
|
|
24
|
+
])).digest("hex");
|
|
25
|
+
}
|
|
26
|
+
function createCodexNativeSubagentHistoryOwner(params) {
|
|
27
|
+
const connectionFingerprint = codexNativeSubagentHistoryConnectionFingerprint(params.binding);
|
|
28
|
+
return connectionFingerprint ? {
|
|
29
|
+
parentThreadId: params.parentThreadId,
|
|
30
|
+
sessionId: params.sessionId,
|
|
31
|
+
...params.lifecycleRevision ? { lifecycleRevision: params.lifecycleRevision } : {},
|
|
32
|
+
connectionFingerprint
|
|
33
|
+
} : void 0;
|
|
34
|
+
}
|
|
35
|
+
function readCodexNativeSubagentHistoryOwner(detail) {
|
|
36
|
+
const value = asOptionalRecord(detail)?.nativeHistory;
|
|
37
|
+
if (value === void 0) return;
|
|
38
|
+
const owner = codexNativeSubagentHistoryOwnerSchema.safeParse(value);
|
|
39
|
+
if (!owner.success) throw new Error("Subagent history owner is invalid.");
|
|
40
|
+
const { lifecycleRevision, ...required } = owner.data;
|
|
41
|
+
return lifecycleRevision === void 0 ? required : {
|
|
42
|
+
...required,
|
|
43
|
+
lifecycleRevision
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function assertHistoryOwnerMatchesRegistration(saved, current, parentThreadId, requireSaved = false) {
|
|
47
|
+
if (requireSaved && !saved) throw new Error("Subagent completion history owner is missing.");
|
|
48
|
+
if (saved && (!current || saved.parentThreadId !== parentThreadId || saved.connectionFingerprint !== current.connectionFingerprint || saved.sessionId !== current.sessionId || saved.lifecycleRevision !== current.lifecycleRevision)) throw new Error("Subagent completion history owner is contradictory.");
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region extensions/codex/src/app-server/native-subagent-assignment.ts
|
|
52
|
+
/**
|
|
53
|
+
* Shared identifiers for Codex native subagent execution and completion receipts.
|
|
54
|
+
*/
|
|
55
|
+
/** Run ID prefix for native child thread assignments. */
|
|
56
|
+
const CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX = "codex-thread:";
|
|
57
|
+
/** Initial assignments use the thread locator; follow-ups belong to a native turn. */
|
|
58
|
+
function codexNativeSubagentRunId(threadId, turnId) {
|
|
59
|
+
return `${CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX}${threadId.trim()}${turnId ? `:turn:${turnId}` : ""}`;
|
|
60
|
+
}
|
|
61
|
+
function readCodexNativeSubagentRunId(runId) {
|
|
62
|
+
if (!runId?.startsWith(CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX)) return;
|
|
63
|
+
const [threadId, turnId] = runId.slice(13).split(":turn:");
|
|
64
|
+
return threadId?.trim() ? {
|
|
65
|
+
threadId,
|
|
66
|
+
...turnId ? { turnId } : {}
|
|
67
|
+
} : void 0;
|
|
68
|
+
}
|
|
69
|
+
function readNativeSubagentThreadIds(value) {
|
|
70
|
+
if (!Array.isArray(value)) return [];
|
|
71
|
+
return value.filter((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
72
|
+
}
|
|
73
|
+
function readThreadParentThreadId(thread) {
|
|
74
|
+
return readStringField(thread, "parentThreadId")?.trim() ?? readStringField(readThreadSpawnSource(thread), "parent_thread_id")?.trim();
|
|
75
|
+
}
|
|
76
|
+
function readThreadSpawnSource(thread) {
|
|
77
|
+
const source = isJsonObject(thread?.source) ? thread.source : void 0;
|
|
78
|
+
const subAgent = isJsonObject(source?.subAgent) ? source.subAgent : void 0;
|
|
79
|
+
return isJsonObject(subAgent?.thread_spawn) ? subAgent.thread_spawn : void 0;
|
|
80
|
+
}
|
|
81
|
+
function normalizeIdentifier(value) {
|
|
82
|
+
return value?.replace(/[^a-z0-9]/giu, "").toLowerCase();
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region extensions/codex/src/app-server/native-subagent-submission.ts
|
|
86
|
+
const identifier$1 = z.string().refine((value) => Boolean(value.trim()));
|
|
87
|
+
const submissionSchema = z.object({
|
|
88
|
+
parentTurnId: identifier$1,
|
|
89
|
+
callId: identifier$1,
|
|
90
|
+
childThreadId: identifier$1,
|
|
91
|
+
submissionId: identifier$1,
|
|
92
|
+
predecessorRunId: identifier$1,
|
|
93
|
+
predecessorNativeTurnId: identifier$1
|
|
94
|
+
}).strict();
|
|
95
|
+
const submissionsSchema = z.object({
|
|
96
|
+
version: z.literal(1),
|
|
97
|
+
owner: codexNativeSubagentHistoryOwnerSchema,
|
|
98
|
+
receipts: z.array(submissionSchema)
|
|
99
|
+
}).strict().refine(({ receipts }) => new Set(receipts.map(({ parentTurnId, callId }) => JSON.stringify([parentTurnId, callId]))).size === receipts.length);
|
|
100
|
+
function matchesCodexNativeSubagentSubmissionOwner(stored, current) {
|
|
101
|
+
return stored.parentThreadId === current.parentThreadId && matchesCodexNativeSubagentHistoryOwner(stored, current);
|
|
102
|
+
}
|
|
103
|
+
function readCodexNativeSubagentSubmissions(value) {
|
|
104
|
+
if (value === void 0) return;
|
|
105
|
+
const parsed = submissionsSchema.safeParse(value);
|
|
106
|
+
if (!parsed.success) throw new Error("Invalid Codex native subagent submission metadata.");
|
|
107
|
+
return parsed.data;
|
|
108
|
+
}
|
|
109
|
+
function mutateCodexNativeSubagentSubmissions(params) {
|
|
110
|
+
const current = readCodexNativeSubagentSubmissions(params.current);
|
|
111
|
+
const owner = codexNativeSubagentHistoryOwnerSchema.parse(params.owner);
|
|
112
|
+
const receipt = submissionSchema.parse(params.receipt);
|
|
113
|
+
if (current && !matchesCodexNativeSubagentSubmissionOwner(current.owner, owner)) return { applied: false };
|
|
114
|
+
const receipts = current?.receipts ?? [];
|
|
115
|
+
const existing = receipts.find((entry) => entry.parentTurnId === receipt.parentTurnId && entry.callId === receipt.callId);
|
|
116
|
+
if (existing && !isDeepStrictEqual(existing, receipt)) return { applied: false };
|
|
117
|
+
if (params.consume) {
|
|
118
|
+
if (!current) return { applied: false };
|
|
119
|
+
const remaining = receipts.filter((entry) => entry !== existing);
|
|
120
|
+
return {
|
|
121
|
+
applied: true,
|
|
122
|
+
...remaining.length ? { next: {
|
|
123
|
+
version: 1,
|
|
124
|
+
owner: current.owner,
|
|
125
|
+
receipts: remaining
|
|
126
|
+
} } : {}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
applied: true,
|
|
131
|
+
next: {
|
|
132
|
+
version: 1,
|
|
133
|
+
owner: current?.owner ?? owner,
|
|
134
|
+
receipts: existing ? receipts : [...receipts, receipt]
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Physical adoption cannot establish continuity for an unstamped receipt. */
|
|
139
|
+
function adoptCodexNativeSubagentSubmissions(value) {
|
|
140
|
+
if (value === void 0) return;
|
|
141
|
+
const parsed = submissionsSchema.safeParse(value);
|
|
142
|
+
return !parsed.success || parsed.data.owner.lifecycleRevision ? value : void 0;
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region extensions/codex/src/app-server/native-subagent-pending-assignments.ts
|
|
146
|
+
const identifier = z.string().trim().min(1);
|
|
147
|
+
const assignmentSchema = z.object({
|
|
148
|
+
runId: identifier,
|
|
149
|
+
childThreadId: identifier,
|
|
150
|
+
nativeTurnId: identifier.optional(),
|
|
151
|
+
nativeParentThreadId: identifier,
|
|
152
|
+
owner: codexNativeSubagentHistoryOwnerSchema,
|
|
153
|
+
submission: submissionSchema.optional(),
|
|
154
|
+
recordedCompletion: z.object({
|
|
155
|
+
childThreadId: identifier,
|
|
156
|
+
status: z.enum([
|
|
157
|
+
"succeeded",
|
|
158
|
+
"failed",
|
|
159
|
+
"cancelled"
|
|
160
|
+
]),
|
|
161
|
+
statusLabel: z.literal("recorded_task_result"),
|
|
162
|
+
result: z.string().min(1),
|
|
163
|
+
completedAt: z.number().finite().optional()
|
|
164
|
+
}).strict().optional()
|
|
165
|
+
}).strict().refine((entry) => !entry.recordedCompletion || entry.recordedCompletion.childThreadId === entry.childThreadId).refine((entry) => !entry.submission || entry.submission.childThreadId === entry.childThreadId && entry.nativeTurnId === entry.submission.submissionId && entry.runId === codexNativeSubagentRunId(entry.childThreadId, entry.submission.submissionId)).refine((entry) => entry.runId === codexNativeSubagentRunId(entry.childThreadId) || entry.nativeTurnId !== void 0 && readCodexNativeSubagentRunId(entry.runId)?.threadId === entry.childThreadId);
|
|
166
|
+
const inventorySchema = z.object({
|
|
167
|
+
version: z.literal(1),
|
|
168
|
+
assignments: z.array(assignmentSchema)
|
|
169
|
+
}).strict().refine(({ assignments }) => new Set(assignments.map((entry) => entry.runId)).size === assignments.length);
|
|
170
|
+
/** Native parent rotation is not physical requester or connection adoption. */
|
|
171
|
+
function matchesNativeAssignmentLifecycle(saved, current) {
|
|
172
|
+
return saved.sessionId === current.sessionId && saved.lifecycleRevision === current.lifecycleRevision && saved.connectionFingerprint === current.connectionFingerprint;
|
|
173
|
+
}
|
|
174
|
+
function readNativePendingAssignments(value) {
|
|
175
|
+
if (value === void 0) return;
|
|
176
|
+
const parsed = inventorySchema.safeParse(value);
|
|
177
|
+
if (!parsed.success) throw new Error("Invalid Codex native pending assignment metadata.");
|
|
178
|
+
return parsed.data;
|
|
179
|
+
}
|
|
180
|
+
function mutateNativePendingAssignments(params) {
|
|
181
|
+
const current = readNativePendingAssignments(params.current);
|
|
182
|
+
const assignment = assignmentSchema.parse(params.assignment);
|
|
183
|
+
const owner = codexNativeSubagentHistoryOwnerSchema.parse(params.owner);
|
|
184
|
+
if (!matchesNativeAssignmentLifecycle(assignment.owner, owner)) return { applied: false };
|
|
185
|
+
const assignments = current?.assignments ?? [];
|
|
186
|
+
const existing = assignments.find((entry) => entry.runId === assignment.runId);
|
|
187
|
+
if (existing && (!isDeepStrictEqual(existing.owner, assignment.owner) || existing.nativeParentThreadId !== assignment.nativeParentThreadId || existing.childThreadId !== assignment.childThreadId)) return { applied: false };
|
|
188
|
+
if (params.consume && (!existing || existing.nativeTurnId !== assignment.nativeTurnId)) return { applied: false };
|
|
189
|
+
const remaining = assignments.filter((entry) => entry !== existing);
|
|
190
|
+
if (!params.consume) remaining.push(existing?.recordedCompletion && !assignment.recordedCompletion ? {
|
|
191
|
+
...assignment,
|
|
192
|
+
recordedCompletion: existing.recordedCompletion
|
|
193
|
+
} : assignment);
|
|
194
|
+
return {
|
|
195
|
+
applied: true,
|
|
196
|
+
next: remaining.length ? {
|
|
197
|
+
version: 1,
|
|
198
|
+
assignments: remaining
|
|
199
|
+
} : void 0
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
export { readCodexNativeSubagentHistoryOwner as _, matchesCodexNativeSubagentSubmissionOwner as a, codexNativeSubagentRunId as c, readNativeSubagentThreadIds as d, readThreadParentThreadId as f, createCodexNativeSubagentHistoryOwner as g, codexNativeSubagentHistoryConnectionFingerprint as h, adoptCodexNativeSubagentSubmissions as i, normalizeIdentifier as l, assertHistoryOwnerMatchesRegistration as m, mutateNativePendingAssignments as n, mutateCodexNativeSubagentSubmissions as o, readThreadSpawnSource as p, readNativePendingAssignments as r, readCodexNativeSubagentSubmissions as s, matchesNativeAssignmentLifecycle as t, readCodexNativeSubagentRunId as u };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { _ as readCodexNativeSubagentHistoryOwner, h as codexNativeSubagentHistoryConnectionFingerprint, r as readNativePendingAssignments, u as readCodexNativeSubagentRunId } from "./native-subagent-pending-assignments-DwkCzLvD.mjs";
|
|
2
|
+
import { _ as readStoredCodexAppServerBinding, r as bindingStoreKey } from "./session-binding-record-Oe9L-CNY.mjs";
|
|
3
|
+
import { n as CODEX_APP_SERVER_BINDING_NAMESPACE, t as CODEX_APP_SERVER_BINDING_MAX_ENTRIES } from "./session-binding-meta-B7aEMU7g.mjs";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import { extractErrorCode } from "openclaw/plugin-sdk/error-runtime";
|
|
9
|
+
import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
10
|
+
import { executeSqliteQuerySync, getNodeSqliteKysely, openNodeSqliteDatabase, prepareSqliteReadOnlyLocation, tableExists } from "openclaw/plugin-sdk/sqlite-runtime";
|
|
11
|
+
//#region extensions/codex/src/migration/native-task-assignments.ts
|
|
12
|
+
const importSchema = z.object({
|
|
13
|
+
version: z.literal(1),
|
|
14
|
+
taskIds: z.array(z.string().min(1))
|
|
15
|
+
}).strict();
|
|
16
|
+
const detailSchema = z.object({ nativeTurnId: z.string().trim().min(1).optional() });
|
|
17
|
+
function databasePath(params) {
|
|
18
|
+
return path.join(params.stateDir, "state", "openclaw.sqlite");
|
|
19
|
+
}
|
|
20
|
+
const missingOwnerMessage = "missing original requester session, lifecycle and connection facts (nativeHistory); inspect the original child in its native Codex account, or restore the pre-upgrade backup with its matching OpenClaw version to finish delivery";
|
|
21
|
+
function taskIdentity(task) {
|
|
22
|
+
try {
|
|
23
|
+
const owner = readCodexNativeSubagentHistoryOwner(task.detail_json ? JSON.parse(task.detail_json) : {});
|
|
24
|
+
return task.agent_id && task.requester_session_key && owner ? {
|
|
25
|
+
kind: "session",
|
|
26
|
+
agentId: task.agent_id,
|
|
27
|
+
sessionKey: task.requester_session_key,
|
|
28
|
+
sessionId: owner.sessionId
|
|
29
|
+
} : void 0;
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function inspect(params) {
|
|
35
|
+
const source = databasePath(params);
|
|
36
|
+
try {
|
|
37
|
+
await fs.access(source);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (extractErrorCode(error) === "ENOENT") return [];
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
const snapshot = await prepareSqliteReadOnlyLocation(source, { preserveSourceArtifacts: true });
|
|
43
|
+
try {
|
|
44
|
+
const db = openNodeSqliteDatabase(snapshot.location, { readOnly: true });
|
|
45
|
+
try {
|
|
46
|
+
if (!tableExists(db, "task_runs") || !tableExists(db, "plugin_state_entries")) return [];
|
|
47
|
+
const sql = getNodeSqliteKysely(db);
|
|
48
|
+
return executeSqliteQuerySync(db, sql.selectFrom("task_runs").select([
|
|
49
|
+
"task_id",
|
|
50
|
+
"runtime",
|
|
51
|
+
"task_kind",
|
|
52
|
+
"run_id",
|
|
53
|
+
"agent_id",
|
|
54
|
+
"requester_session_key",
|
|
55
|
+
"owner_key",
|
|
56
|
+
"scope_kind",
|
|
57
|
+
"status",
|
|
58
|
+
"delivery_status",
|
|
59
|
+
"ended_at",
|
|
60
|
+
"terminal_summary",
|
|
61
|
+
"detail_json"
|
|
62
|
+
]).select((eb) => eb.selectFrom("task_runs as all_runs").select((count) => count.fn.countAll().as("count")).whereRef("all_runs.run_id", "=", "task_runs.run_id").where("all_runs.runtime", "=", "subagent").where("all_runs.task_kind", "=", "codex-native").as("run_count")).where("runtime", "=", "subagent").where("task_kind", "=", "codex-native").where("delivery_status", "!=", "delivered").where((eb) => eb.or([
|
|
63
|
+
eb("status", "in", ["queued", "running"]),
|
|
64
|
+
eb("delivery_status", "=", "pending"),
|
|
65
|
+
eb.and([eb("delivery_status", "=", "not_applicable"), eb("ended_at", ">=", Date.now() - 6e4)])
|
|
66
|
+
]))).rows.filter((row) => {
|
|
67
|
+
const identity = taskIdentity(row);
|
|
68
|
+
if (!identity) return true;
|
|
69
|
+
const binding = executeSqliteQuerySync(db, sql.selectFrom("plugin_state_entries").select("value_json").where("plugin_id", "=", "codex").where("namespace", "=", CODEX_APP_SERVER_BINDING_NAMESPACE).where("entry_key", "=", bindingStoreKey(identity)).where((eb) => eb.or([eb("expires_at", "is", null), eb("expires_at", ">", Date.now())]))).rows[0];
|
|
70
|
+
try {
|
|
71
|
+
const stored = binding && readStoredCodexAppServerBinding(JSON.parse(binding.value_json));
|
|
72
|
+
const imported = importSchema.safeParse(stored?.nativeSubagentTaskImport);
|
|
73
|
+
return !imported.success || !imported.data.taskIds.includes(row.task_id);
|
|
74
|
+
} catch {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} finally {
|
|
79
|
+
db.close();
|
|
80
|
+
}
|
|
81
|
+
} finally {
|
|
82
|
+
await snapshot.cleanupAsync();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function prepareAssignment(task, stored, params) {
|
|
86
|
+
const identity = taskIdentity(task);
|
|
87
|
+
const native = readCodexNativeSubagentRunId(task.run_id ?? void 0);
|
|
88
|
+
const detail = task.detail_json ? JSON.parse(task.detail_json) : {};
|
|
89
|
+
const owner = readCodexNativeSubagentHistoryOwner(detail);
|
|
90
|
+
if (!owner) throw new Error(missingOwnerMessage);
|
|
91
|
+
if (!identity || !native || !task.run_id || stored.state !== "active" || stored.binding.pendingSupervisionBranch) throw new Error("current requester binding is unavailable; reconnect the original requester and run openclaw doctor --fix");
|
|
92
|
+
const session = getSessionEntry({
|
|
93
|
+
agentId: identity.agentId,
|
|
94
|
+
sessionKey: identity.sessionKey,
|
|
95
|
+
env: params.env,
|
|
96
|
+
storePath: resolveStorePath(params.config.session?.store, {
|
|
97
|
+
agentId: identity.agentId,
|
|
98
|
+
env: params.env
|
|
99
|
+
}),
|
|
100
|
+
readConsistency: "latest"
|
|
101
|
+
});
|
|
102
|
+
if (!session || session.sessionId !== owner.sessionId || stored.sessionId !== owner.sessionId || session.lifecycleRevision !== owner.lifecycleRevision || session.agentHarnessId !== void 0 && session.agentHarnessId !== "codex" || codexNativeSubagentHistoryConnectionFingerprint(stored.binding) !== owner.connectionFingerprint) throw new Error("requester session, lifecycle, or connection ownership no longer matches; inspect the original child in its native Codex account");
|
|
103
|
+
if (task.scope_kind !== "session" || task.owner_key !== identity.sessionKey) throw new Error("Task requester ownership does not match its session; inspect the original child in its native Codex account");
|
|
104
|
+
const nativeTurnId = detailSchema.parse(detail).nativeTurnId ?? native.turnId;
|
|
105
|
+
return {
|
|
106
|
+
runId: task.run_id,
|
|
107
|
+
childThreadId: native.threadId,
|
|
108
|
+
...nativeTurnId ? { nativeTurnId } : {},
|
|
109
|
+
nativeParentThreadId: owner.parentThreadId,
|
|
110
|
+
owner,
|
|
111
|
+
...(task.status === "succeeded" || task.status === "failed" || task.status === "cancelled") && task.terminal_summary ? { recordedCompletion: {
|
|
112
|
+
childThreadId: native.threadId,
|
|
113
|
+
status: task.status,
|
|
114
|
+
statusLabel: "recorded_task_result",
|
|
115
|
+
result: task.terminal_summary,
|
|
116
|
+
...task.ended_at !== null ? { completedAt: task.ended_at } : {}
|
|
117
|
+
} } : {}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const codexNativeTaskAssignmentMigration = {
|
|
121
|
+
id: "codex-native-task-assignments",
|
|
122
|
+
label: "Codex native pending assignments",
|
|
123
|
+
collectBackupResources: (params) => [{
|
|
124
|
+
path: databasePath(params),
|
|
125
|
+
kind: "sqlite"
|
|
126
|
+
}],
|
|
127
|
+
async detectLegacyState(params) {
|
|
128
|
+
return (await inspect(params)).length > 0 ? { preview: ["- Preserve native Codex child recovery before retiring Tasks"] } : null;
|
|
129
|
+
},
|
|
130
|
+
async migrateLegacyState(params) {
|
|
131
|
+
const rows = await inspect(params);
|
|
132
|
+
const warnings = [];
|
|
133
|
+
if (rows.length === 0) return {
|
|
134
|
+
changes: [],
|
|
135
|
+
warnings
|
|
136
|
+
};
|
|
137
|
+
let imported = 0;
|
|
138
|
+
const store = params.context.openPluginStateKeyedStore({
|
|
139
|
+
namespace: CODEX_APP_SERVER_BINDING_NAMESPACE,
|
|
140
|
+
maxEntries: CODEX_APP_SERVER_BINDING_MAX_ENTRIES,
|
|
141
|
+
overflowPolicy: "reject-new",
|
|
142
|
+
env: params.env
|
|
143
|
+
});
|
|
144
|
+
for (const task of rows) try {
|
|
145
|
+
const identity = taskIdentity(task);
|
|
146
|
+
if (!identity) throw new Error(missingOwnerMessage);
|
|
147
|
+
if (!store.observe || !store.compareAndApply || !store.withCurrent) throw new Error("current requester identity or atomic binding storage is unavailable; run openclaw doctor --fix with the current version");
|
|
148
|
+
if (task.run_count !== 1) throw new Error("duplicate native assignment identity; inspect the retained Task records before repairing them");
|
|
149
|
+
const key = bindingStoreKey(identity);
|
|
150
|
+
const observed = await store.observe(key);
|
|
151
|
+
const stored = readStoredCodexAppServerBinding(observed.value);
|
|
152
|
+
if (!stored) throw new Error("original requester binding is unavailable; inspect the child in its native Codex account");
|
|
153
|
+
const marker = stored.nativeSubagentTaskImport === void 0 ? {
|
|
154
|
+
version: 1,
|
|
155
|
+
taskIds: []
|
|
156
|
+
} : importSchema.parse(stored.nativeSubagentTaskImport);
|
|
157
|
+
if (marker.taskIds.includes(task.task_id)) continue;
|
|
158
|
+
const assignment = prepareAssignment(task, stored, params);
|
|
159
|
+
if (stored.state !== "active" || observed.value?.state !== "active") continue;
|
|
160
|
+
const assignments = readNativePendingAssignments(stored.nativeSubagentAssignments)?.assignments ?? [];
|
|
161
|
+
const existing = assignments.find((value) => value.runId === assignment.runId);
|
|
162
|
+
if (existing && !isDeepStrictEqual(existing, assignment)) throw new Error("a newer binding assignment already owns this result; preserve both records for inspection");
|
|
163
|
+
const next = {
|
|
164
|
+
...stored,
|
|
165
|
+
...observed.value,
|
|
166
|
+
nativeSubagentAssignments: {
|
|
167
|
+
version: 1,
|
|
168
|
+
assignments: existing ? assignments : [...assignments, assignment]
|
|
169
|
+
},
|
|
170
|
+
nativeSubagentTaskImport: {
|
|
171
|
+
version: 1,
|
|
172
|
+
taskIds: [...marker.taskIds, task.task_id]
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
if ((await store.withCurrent({ assertCurrent: () => {
|
|
176
|
+
prepareAssignment(task, stored, params);
|
|
177
|
+
} }).compareAndApply(key, observed.comparison, {
|
|
178
|
+
operation: "update",
|
|
179
|
+
action: "set",
|
|
180
|
+
value: next
|
|
181
|
+
})).status === "conflict") throw new Error("binding changed during import; run openclaw doctor --fix again");
|
|
182
|
+
imported += 1;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
warnings.push(`Native Codex task ${task.task_id} (${task.run_id ?? "unknown child"}) was preserved without migration: ${String(error)}`);
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
changes: imported ? [`Preserved ${imported} native Codex assignment(s) in their existing parent bindings`] : [],
|
|
188
|
+
warnings,
|
|
189
|
+
...warnings.length ? { warningDisposition: "recoverable" } : {}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
//#endregion
|
|
194
|
+
export { codexNativeTaskAssignmentMigration };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { A as unwrapNodeInvokePayload, x as readBoundedOptionalString } from "./session-catalog-parsing-CPGaPYr-.mjs";
|
|
2
|
+
import { r as resolveCodexAppServerUserHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
|
|
3
|
+
import { o as formatCodexDisplayText } from "./command-formatters-R3ckE3Co.mjs";
|
|
4
|
+
import { t as codexCatalogHomeId } from "./session-catalog-home-id-vlih0B_g.mjs";
|
|
5
5
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
-
import { timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
|
|
7
6
|
import { runCommandBuffered, withCommandProcessScope } from "openclaw/plugin-sdk/process-runtime";
|
|
7
|
+
import { timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
|
|
8
8
|
import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import fs from "node:fs/promises";
|
|
@@ -187,7 +187,7 @@ async function resumeCodexCliSessionOnNode(params) {
|
|
|
187
187
|
let catalogAgentId;
|
|
188
188
|
let catalogHomeId;
|
|
189
189
|
if (params.sessionKey) {
|
|
190
|
-
const { adoptionSessionKeyRest, CODEX_NODE_SESSION_KEY_PREFIX, readNodeSessionMarker } = await import("./session-catalog-node-adoption-
|
|
190
|
+
const { adoptionSessionKeyRest, CODEX_NODE_SESSION_KEY_PREFIX, readNodeSessionMarker } = await import("./session-catalog-node-adoption-DgXvSGu0.mjs");
|
|
191
191
|
const entry = params.runtime.agent.session.getSessionEntry({
|
|
192
192
|
sessionKey: params.sessionKey,
|
|
193
193
|
readConsistency: "latest"
|
|
@@ -201,7 +201,7 @@ async function resumeCodexCliSessionOnNode(params) {
|
|
|
201
201
|
catalogHomeId = marker.sourceHomeId;
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
const
|
|
204
|
+
const raw = await params.runtime.nodes.invoke({
|
|
205
205
|
nodeId: params.nodeId,
|
|
206
206
|
command: CODEX_CLI_SESSION_RESUME_COMMAND,
|
|
207
207
|
params: {
|
|
@@ -214,7 +214,8 @@ async function resumeCodexCliSessionOnNode(params) {
|
|
|
214
214
|
},
|
|
215
215
|
timeoutMs: (params.timeoutMs ?? DEFAULT_RESUME_TIMEOUT_MS) + 5e3,
|
|
216
216
|
scopes: ["operator.write"]
|
|
217
|
-
})
|
|
217
|
+
});
|
|
218
|
+
const payload = unwrapNodeInvokePayload(raw, "Codex CLI node command returned malformed payloadJSON.");
|
|
218
219
|
if (!isRecord(payload) || payload.ok !== true || typeof payload.text !== "string") throw new Error("Codex CLI resume returned an invalid payload.");
|
|
219
220
|
return {
|
|
220
221
|
ok: true,
|
|
@@ -230,7 +231,7 @@ function formatCodexCliSessions(params) {
|
|
|
230
231
|
})].join("\n");
|
|
231
232
|
}
|
|
232
233
|
async function listLocalCodexCliSessions(paramsJSON) {
|
|
233
|
-
const params =
|
|
234
|
+
const params = parseJsonRecord(paramsJSON);
|
|
234
235
|
const limit = normalizeLimit(params.limit);
|
|
235
236
|
const filter = typeof params.filter === "string" ? params.filter.trim().toLowerCase() : "";
|
|
236
237
|
const codexHome = resolveCodexAppServerUserHomeDir();
|
|
@@ -243,7 +244,7 @@ async function listLocalCodexCliSessions(paramsJSON) {
|
|
|
243
244
|
session.cwd,
|
|
244
245
|
session.lastMessage
|
|
245
246
|
].some((value) => value?.toLowerCase().includes(filter));
|
|
246
|
-
}).toSorted((a, b) =>
|
|
247
|
+
}).toSorted((a, b) => (b.updatedAt ?? "").localeCompare(a.updatedAt ?? "")).slice(0, limit);
|
|
247
248
|
return JSON.stringify({
|
|
248
249
|
sessions,
|
|
249
250
|
codexHome
|
|
@@ -251,7 +252,7 @@ async function listLocalCodexCliSessions(paramsJSON) {
|
|
|
251
252
|
}
|
|
252
253
|
async function resumeLocalCodexCliSession(paramsJSON, resolveCatalogSource, context) {
|
|
253
254
|
context?.signal?.throwIfAborted();
|
|
254
|
-
const params =
|
|
255
|
+
const params = parseJsonRecord(paramsJSON);
|
|
255
256
|
const sessionId = typeof params.sessionId === "string" ? params.sessionId.trim() : "";
|
|
256
257
|
const prompt = typeof params.prompt === "string" ? params.prompt.trim() : "";
|
|
257
258
|
const expectedHomeId = readBoundedOptionalString(params, "sourceHomeId", 256);
|
|
@@ -346,15 +347,8 @@ async function runCodexExecResume(params) {
|
|
|
346
347
|
async function readHistorySessions(codexHome) {
|
|
347
348
|
const summaries = /* @__PURE__ */ new Map();
|
|
348
349
|
if (!(await visitJsonlLines(path.join(codexHome, "history.jsonl"), (line) => {
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
351
|
-
let parsed;
|
|
352
|
-
try {
|
|
353
|
-
parsed = JSON.parse(trimmed);
|
|
354
|
-
} catch {
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
if (!isRecord(parsed) || typeof parsed.session_id !== "string") return;
|
|
350
|
+
const parsed = parseJsonRecord(line.trim());
|
|
351
|
+
if (typeof parsed.session_id !== "string") return;
|
|
358
352
|
const sessionId = parsed.session_id.trim();
|
|
359
353
|
if (!sessionId) return;
|
|
360
354
|
const entry = summaries.get(sessionId) ?? {
|
|
@@ -392,15 +386,7 @@ async function readSessionFileSummary(file) {
|
|
|
392
386
|
let lastMessage;
|
|
393
387
|
let messageCount = 0;
|
|
394
388
|
const result = await visitJsonlLines(file, (line) => {
|
|
395
|
-
const
|
|
396
|
-
if (!trimmed) return;
|
|
397
|
-
let parsed;
|
|
398
|
-
try {
|
|
399
|
-
parsed = JSON.parse(trimmed);
|
|
400
|
-
} catch {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
if (!isRecord(parsed)) return;
|
|
389
|
+
const parsed = parseJsonRecord(line.trim());
|
|
404
390
|
if (typeof parsed.timestamp === "string" && parsed.timestamp.trim()) updatedAt = parsed.timestamp.trim();
|
|
405
391
|
if (parsed.type === "session_meta" && isRecord(parsed.payload)) {
|
|
406
392
|
if (typeof parsed.payload.id === "string" && parsed.payload.id.trim()) sessionId = parsed.payload.id.trim();
|
|
@@ -413,8 +399,7 @@ async function readSessionFileSummary(file) {
|
|
|
413
399
|
lastMessage = truncateText(messageText, 140);
|
|
414
400
|
}
|
|
415
401
|
});
|
|
416
|
-
if (!result.ok) return null;
|
|
417
|
-
if (result.lineCount === 0) return null;
|
|
402
|
+
if (!result.ok || result.lineCount === 0) return null;
|
|
418
403
|
if (!sessionId) sessionId = readSessionIdFromFilename(file) ?? "";
|
|
419
404
|
if (!sessionId) return null;
|
|
420
405
|
return {
|
|
@@ -443,9 +428,7 @@ async function findSessionFiles(dir, maxDepth) {
|
|
|
443
428
|
return files;
|
|
444
429
|
}
|
|
445
430
|
function readResponseItemMessageText(parsed) {
|
|
446
|
-
if (parsed.type !== "response_item" || !isRecord(parsed.payload)) return;
|
|
447
|
-
if (parsed.payload.type !== "message") return;
|
|
448
|
-
if ((typeof parsed.payload.role === "string" ? parsed.payload.role : "") !== "user") return;
|
|
431
|
+
if (parsed.type !== "response_item" || !isRecord(parsed.payload) || parsed.payload.type !== "message" || parsed.payload.role !== "user") return;
|
|
449
432
|
const parts = (Array.isArray(parsed.payload.content) ? parsed.payload.content : []).flatMap((entry) => {
|
|
450
433
|
if (!isRecord(entry)) return [];
|
|
451
434
|
const text = typeof entry.text === "string" ? entry.text : typeof entry.input_text === "string" ? entry.input_text : void 0;
|
|
@@ -474,7 +457,7 @@ async function resolveCodexCliNode(params) {
|
|
|
474
457
|
return expectDefined(usable[0], "single usable Codex CLI node");
|
|
475
458
|
}
|
|
476
459
|
function parseCodexCliSessionsListResult(raw) {
|
|
477
|
-
const payload = unwrapNodeInvokePayload(raw);
|
|
460
|
+
const payload = unwrapNodeInvokePayload(raw, "Codex CLI node command returned malformed payloadJSON.");
|
|
478
461
|
if (!isRecord(payload) || !Array.isArray(payload.sessions)) throw new Error("Codex CLI session list returned an invalid payload.");
|
|
479
462
|
return {
|
|
480
463
|
codexHome: typeof payload.codexHome === "string" ? payload.codexHome : "",
|
|
@@ -491,17 +474,7 @@ function parseCodexCliSessionsListResult(raw) {
|
|
|
491
474
|
})
|
|
492
475
|
};
|
|
493
476
|
}
|
|
494
|
-
function
|
|
495
|
-
const record = isRecord(raw) ? raw : {};
|
|
496
|
-
if (typeof record.payloadJSON === "string" && record.payloadJSON.trim()) try {
|
|
497
|
-
return JSON.parse(record.payloadJSON);
|
|
498
|
-
} catch (error) {
|
|
499
|
-
throw new Error("Codex CLI node command returned malformed payloadJSON.", { cause: error });
|
|
500
|
-
}
|
|
501
|
-
if ("payload" in record) return record.payload;
|
|
502
|
-
return raw;
|
|
503
|
-
}
|
|
504
|
-
function readRecordParam(paramsJSON) {
|
|
477
|
+
function parseJsonRecord(paramsJSON) {
|
|
505
478
|
if (!paramsJSON?.trim()) return {};
|
|
506
479
|
try {
|
|
507
480
|
const parsed = JSON.parse(paramsJSON);
|
|
@@ -527,9 +500,6 @@ function truncateText(value, max) {
|
|
|
527
500
|
if (value.length <= max) return value;
|
|
528
501
|
return `${truncateUtf16Safe(value, Math.max(0, max - 3))}...`;
|
|
529
502
|
}
|
|
530
|
-
function compareOptionalStringsDesc(a, b) {
|
|
531
|
-
return (b ?? "").localeCompare(a ?? "");
|
|
532
|
-
}
|
|
533
503
|
function readNodeId(node) {
|
|
534
504
|
if (!node.nodeId) throw new Error("Codex CLI node did not include a node id.");
|
|
535
505
|
return node.nodeId;
|
package/dist/.setup/{node-exec-server.runtime-BDwWXVpK.mjs → node-exec-server.runtime-BgBfWQqo.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as resolveManagedCodexNativeCommand, r as resolveManagedCodexAppServerStartOptions, t as isManagedCodexDesktopCommand } from "./managed-binary-
|
|
2
|
-
import { a as closeCodexAppServerTransportAndWait, t as createStdioTransport } from "./transport-stdio-
|
|
1
|
+
import { i as resolveManagedCodexNativeCommand, r as resolveManagedCodexAppServerStartOptions, t as isManagedCodexDesktopCommand } from "./managed-binary-kiWRhNRE.mjs";
|
|
2
|
+
import { a as closeCodexAppServerTransportAndWait, t as createStdioTransport } from "./transport-stdio-Bdegpn2V.mjs";
|
|
3
3
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { stripVTControlCharacters } from "node:util";
|
|
5
5
|
import { killProcessTree } from "openclaw/plugin-sdk/process-runtime";
|
|
@@ -113,10 +113,7 @@ async function runCodexNodeExecServer(params) {
|
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
let close = releaseResources;
|
|
116
|
-
|
|
117
|
-
const disconnected = new Promise((_resolve, reject) => {
|
|
118
|
-
rejectDisconnected = reject;
|
|
119
|
-
});
|
|
116
|
+
const { promise: disconnected, reject: rejectDisconnected } = createDeferred();
|
|
120
117
|
disconnected.catch(() => {});
|
|
121
118
|
const onAbort = () => {
|
|
122
119
|
const error = nodeExecServerAbortError(io.signal);
|