@openclaw/codex 2026.9.5 → 2026.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
- package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
- package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
- package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
- package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
- package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
- package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
- package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
- package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
- package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
- package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
- package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
- package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
- package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
- package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
- package/dist/.setup/compact-C2WamavS.mjs +776 -0
- package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
- package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
- package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
- package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
- package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
- package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
- package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
- package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
- package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
- package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
- package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
- package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
- package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
- package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
- package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
- package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
- package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
- package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
- package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
- package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
- package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
- package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
- package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
- package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
- package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
- package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
- package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
- package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
- package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
- package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
- package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
- package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
- package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
- package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
- package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
- package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
- package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
- package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
- package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
- package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
- package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
- package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
- package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
- package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
- package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
- package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
- package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
- package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
- package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
- package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
- package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
- package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
- package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
- package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
- package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
- package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
- package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
- package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
- package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
- package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
- package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
- package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
- package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
- package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
- package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
- package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
- package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
- package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
- package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
- package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
- package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
- package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
- package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
- package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
- package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
- package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
- package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
- package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
- package/dist/.setup/thread-lifecycle-DPflntEJ.mjs +2362 -0
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
- package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
- package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
- package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
- package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
- package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
- package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
- package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
- package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
- package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
- package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
- package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
- package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
- package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
- package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
- package/dist/api.js +25 -16
- package/dist/catalog-page-worker-entrypoint.js +12 -0
- package/dist/catalog-page.worker.js +9 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +50 -8
- package/dist/harness.js +344 -1
- package/dist/index.js +345 -346
- package/dist/media-understanding-provider.js +9 -22
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +16 -33
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +14 -2
- package/package.json +11 -7
- package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
- package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
- package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
- package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
- package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
- package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
- package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
- package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
- package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
- package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
- package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
- package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
- package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
- package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
- package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
- package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
- package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
- package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
- package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
- package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
- package/dist/.setup/version-CoqzXPgK.mjs +0 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as CODEX_CATALOG_MAX_ROWS } from "./session-catalog-limits-DDxOsQeC.mjs";
|
|
2
2
|
//#region extensions/codex/src/session-catalog-index-order.ts
|
|
3
3
|
function codexCatalogRowRecency(row) {
|
|
4
4
|
return row.recencyAt ?? row.updatedAt ?? 0;
|
|
@@ -21,7 +21,7 @@ var CodexCatalogOrdering = class {
|
|
|
21
21
|
this.nextEventOrder = -1;
|
|
22
22
|
}
|
|
23
23
|
read(rows) {
|
|
24
|
-
return this.ordered ??= [...rows.values()].toSorted(compareCodexCatalogRows);
|
|
24
|
+
return this.ordered ??= [...rows.values()].filter((row) => !row.archived && row.page.sessions.length > 0).toSorted(compareCodexCatalogRows);
|
|
25
25
|
}
|
|
26
26
|
invalidate() {
|
|
27
27
|
this.ordered = void 0;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { v as parseCatalogPage } from "./session-catalog-parsing-CPGaPYr-.mjs";
|
|
2
|
+
import { n as detachCodexCatalogString } from "./session-catalog-limits-DDxOsQeC.mjs";
|
|
3
|
+
import { i as retainCodexCatalogRow } from "./session-catalog-index-order-BcQpHks3.mjs";
|
|
3
4
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
6
|
import { setImmediate } from "node:timers/promises";
|
|
@@ -109,6 +110,9 @@ var CodexCatalogPersistence = class {
|
|
|
109
110
|
this.failed = false;
|
|
110
111
|
this.retired = false;
|
|
111
112
|
}
|
|
113
|
+
hasActiveWork() {
|
|
114
|
+
return this.writing !== void 0 || this.pending.size > 0;
|
|
115
|
+
}
|
|
112
116
|
async readSnapshot() {
|
|
113
117
|
await this.drain();
|
|
114
118
|
return await readCodexCatalogSnapshot(this.state);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
|
|
2
|
+
//#region extensions/codex/src/session-catalog-limits.ts
|
|
3
|
+
var session_catalog_limits_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
CODEX_CATALOG_MAX_ROWS: () => CODEX_CATALOG_MAX_ROWS,
|
|
5
|
+
CODEX_CATALOG_MAX_STATE_KEY_BYTES: () => 512,
|
|
6
|
+
detachCodexCatalogString: () => detachCodexCatalogString
|
|
7
|
+
});
|
|
8
|
+
const CODEX_CATALOG_MAX_ROWS = 2e4;
|
|
9
|
+
/** Preserve UTF-16 code units without retaining an oversized source string. */
|
|
10
|
+
function detachCodexCatalogString(value) {
|
|
11
|
+
return Buffer.from(value, "utf16le").toString("utf16le");
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { detachCodexCatalogString as n, session_catalog_limits_exports as r, CODEX_CATALOG_MAX_ROWS as t };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { o as CatalogParamsError } from "./session-catalog-parsing-CPGaPYr-.mjs";
|
|
2
|
+
import { r as compareCodexCatalogRows } from "./session-catalog-index-order-BcQpHks3.mjs";
|
|
3
|
+
import { i as withTimeout } from "./timeout-CXOfNoaX.mjs";
|
|
4
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
6
|
+
//#region extensions/codex/src/session-catalog-availability.ts
|
|
7
|
+
var CodexCatalogLoadingError = class extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("Codex session catalog is still loading. Retry shortly.");
|
|
10
|
+
this.code = "APP_SERVER_UNAVAILABLE";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
/** One generation promise wakes cold callers; native pages remain owned by the index. */
|
|
14
|
+
var CodexCatalogAvailability = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.complete = false;
|
|
17
|
+
this.changed = createDeferred();
|
|
18
|
+
}
|
|
19
|
+
begin() {
|
|
20
|
+
this.failure = void 0;
|
|
21
|
+
}
|
|
22
|
+
publish(frontier, complete = false) {
|
|
23
|
+
if (this.complete) return;
|
|
24
|
+
if (frontier && (!this.frontier || compareCodexCatalogRows(frontier, this.frontier) > 0)) {
|
|
25
|
+
const { threadId, updatedAt, recencyAt, sourceOrder } = frontier;
|
|
26
|
+
this.frontier = {
|
|
27
|
+
threadId,
|
|
28
|
+
updatedAt,
|
|
29
|
+
recencyAt,
|
|
30
|
+
sourceOrder
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
this.complete = complete;
|
|
34
|
+
this.notify();
|
|
35
|
+
}
|
|
36
|
+
fail(error) {
|
|
37
|
+
this.failure = { error };
|
|
38
|
+
this.notify();
|
|
39
|
+
}
|
|
40
|
+
notify() {
|
|
41
|
+
const previous = this.changed;
|
|
42
|
+
this.changed = createDeferred();
|
|
43
|
+
previous.resolve();
|
|
44
|
+
}
|
|
45
|
+
async until(promise, deadline) {
|
|
46
|
+
const remaining = deadline - performance.now();
|
|
47
|
+
if (remaining <= 0) throw new CodexCatalogLoadingError();
|
|
48
|
+
return await withTimeout(promise, remaining, "Codex session catalog is still loading", () => new CodexCatalogLoadingError());
|
|
49
|
+
}
|
|
50
|
+
async next(deadline) {
|
|
51
|
+
if (this.failure) throw this.failure.error;
|
|
52
|
+
await this.until(this.changed.promise, deadline);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region extensions/codex/src/session-catalog-list-request.ts
|
|
57
|
+
const listRequest = new AsyncLocalStorage();
|
|
58
|
+
function currentCodexCatalogListRequest() {
|
|
59
|
+
return listRequest.getStore();
|
|
60
|
+
}
|
|
61
|
+
/** One foreground request owns its native read budget and source-health outcome. */
|
|
62
|
+
var CodexCatalogListRequest = class {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.pages = 0;
|
|
65
|
+
this.closed = false;
|
|
66
|
+
this.attempts = /* @__PURE__ */ new Map();
|
|
67
|
+
}
|
|
68
|
+
get hasPages() {
|
|
69
|
+
return this.pages < 20;
|
|
70
|
+
}
|
|
71
|
+
deadline(timeoutMs) {
|
|
72
|
+
this.assertActive();
|
|
73
|
+
return this.deadlineAt ??= performance.now() + timeoutMs;
|
|
74
|
+
}
|
|
75
|
+
constrainDeadline(absolute) {
|
|
76
|
+
this.assertActive();
|
|
77
|
+
this.deadlineAt = Math.min(this.deadlineAt ?? absolute, absolute);
|
|
78
|
+
return this.deadlineAt;
|
|
79
|
+
}
|
|
80
|
+
remaining(timeoutMs) {
|
|
81
|
+
const remaining = Math.min(timeoutMs, this.deadline(timeoutMs) - performance.now());
|
|
82
|
+
if (remaining <= 0) throw new CodexCatalogLoadingError();
|
|
83
|
+
return remaining;
|
|
84
|
+
}
|
|
85
|
+
assertActive() {
|
|
86
|
+
if (this.closed) throw new DOMException("Codex session catalog request is closed", "AbortError");
|
|
87
|
+
if (this.deadlineAt !== void 0 && this.deadlineAt <= performance.now()) throw new CodexCatalogLoadingError();
|
|
88
|
+
}
|
|
89
|
+
async run(run) {
|
|
90
|
+
this.assertActive();
|
|
91
|
+
const pending = listRequest.run(this, run);
|
|
92
|
+
const remaining = this.deadlineAt === void 0 ? void 0 : this.deadlineAt - performance.now();
|
|
93
|
+
if (remaining !== void 0 && remaining <= 0) {
|
|
94
|
+
pending.catch(() => {});
|
|
95
|
+
throw new CodexCatalogLoadingError();
|
|
96
|
+
}
|
|
97
|
+
const result = remaining === void 0 ? await pending : await withTimeout(pending, remaining, "Codex session catalog is still loading", () => new CodexCatalogLoadingError());
|
|
98
|
+
this.assertActive();
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
async read(timeoutMs, read) {
|
|
102
|
+
const remaining = this.remaining(timeoutMs);
|
|
103
|
+
if (!this.hasPages) throw new CatalogParamsError("Codex catalog native page budget is exhausted");
|
|
104
|
+
this.pages++;
|
|
105
|
+
try {
|
|
106
|
+
const result = await withTimeout(read(remaining), remaining, "Codex session catalog is still loading", () => new CodexCatalogLoadingError());
|
|
107
|
+
this.assertActive();
|
|
108
|
+
return result;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (!this.closed) this.failure ??= { error };
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
attempt(owner, key, start) {
|
|
115
|
+
this.assertActive();
|
|
116
|
+
let attempts = this.attempts.get(owner);
|
|
117
|
+
const existing = attempts?.get(key);
|
|
118
|
+
if (existing) return existing;
|
|
119
|
+
const attempt = start();
|
|
120
|
+
if (!attempts) {
|
|
121
|
+
attempts = /* @__PURE__ */ new Map();
|
|
122
|
+
this.attempts.set(owner, attempts);
|
|
123
|
+
}
|
|
124
|
+
attempts.set(key, attempt);
|
|
125
|
+
return attempt;
|
|
126
|
+
}
|
|
127
|
+
resolved() {
|
|
128
|
+
if (this.failure) {
|
|
129
|
+
this.rejected(this.failure.error);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.settle((attempt) => attempt.resolved());
|
|
133
|
+
}
|
|
134
|
+
rejected(error) {
|
|
135
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
136
|
+
this.close();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const reason = this.failure?.error ?? error;
|
|
140
|
+
this.settle((attempt) => attempt.rejected(reason));
|
|
141
|
+
}
|
|
142
|
+
close() {
|
|
143
|
+
this.settle((attempt) => attempt.abandoned());
|
|
144
|
+
}
|
|
145
|
+
settle(settle) {
|
|
146
|
+
if (this.closed) return;
|
|
147
|
+
this.closed = true;
|
|
148
|
+
for (const attempts of this.attempts.values()) for (const attempt of attempts.values()) if (attempt.allowed) settle(attempt);
|
|
149
|
+
this.attempts.clear();
|
|
150
|
+
this.failure = void 0;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
async function withCodexCatalogListRequest(run) {
|
|
154
|
+
const current = currentCodexCatalogListRequest();
|
|
155
|
+
if (current) {
|
|
156
|
+
current.assertActive();
|
|
157
|
+
return await run(current);
|
|
158
|
+
}
|
|
159
|
+
const scope = new CodexCatalogListRequest();
|
|
160
|
+
try {
|
|
161
|
+
const result = await scope.run(() => run(scope));
|
|
162
|
+
scope.resolved();
|
|
163
|
+
return result;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
scope.rejected(error);
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { CodexCatalogLoadingError as a, CodexCatalogAvailability as i, currentCodexCatalogListRequest as n, withCodexCatalogListRequest as r, CodexCatalogListRequest as t };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { D as selectCodexCatalogPreviewInput, c as MAX_CWD_LENGTH, d as boundedCatalogString, k as truncateCodexCatalogPreview } from "./session-catalog-parsing-CPGaPYr-.mjs";
|
|
2
|
+
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
3
|
+
import { n as defineCodexBuildState } from "./build-state-Da1_z0kd.mjs";
|
|
4
|
+
import { n as detachCodexCatalogString } from "./session-catalog-limits-DDxOsQeC.mjs";
|
|
5
|
+
import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
|
|
6
|
+
//#region extensions/codex/src/session-catalog-source.ts
|
|
7
|
+
function hasLiveCodexCatalogSource(sources) {
|
|
8
|
+
for (const source of sources) if (!source.closed) return true;
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const getSources = defineCodexBuildState("openclaw.codexCatalogSources", () => ({
|
|
12
|
+
clients: /* @__PURE__ */ new WeakMap(),
|
|
13
|
+
values: /* @__PURE__ */ new WeakMap()
|
|
14
|
+
}));
|
|
15
|
+
const getEphemeralObservers = defineCodexBuildState("openclaw.codexCatalogEphemeralObservers", () => /* @__PURE__ */ new WeakMap());
|
|
16
|
+
/** A passive lifetime fact; the token never retains its client or a lease. */
|
|
17
|
+
function codexCatalogSourceForClient(client) {
|
|
18
|
+
const { clients } = getSources();
|
|
19
|
+
let source = clients.get(client);
|
|
20
|
+
if (!source) {
|
|
21
|
+
source = { closed: false };
|
|
22
|
+
clients.set(client, source);
|
|
23
|
+
}
|
|
24
|
+
return source;
|
|
25
|
+
}
|
|
26
|
+
function closeCodexCatalogClientSource(client) {
|
|
27
|
+
const { clients } = getSources();
|
|
28
|
+
const source = clients.get(client);
|
|
29
|
+
if (source) {
|
|
30
|
+
source.closed = true;
|
|
31
|
+
getEphemeralObservers().delete(source);
|
|
32
|
+
} else clients.set(client, { closed: true });
|
|
33
|
+
}
|
|
34
|
+
/** The catalog observer is bound once per physical source and released on closure. */
|
|
35
|
+
function observeCodexCatalogEphemeralThreads(source, observer) {
|
|
36
|
+
getEphemeralObservers().set(source, observer);
|
|
37
|
+
}
|
|
38
|
+
function getCodexCatalogSource(value) {
|
|
39
|
+
return value !== null && typeof value === "object" ? getSources().values.get(value) : void 0;
|
|
40
|
+
}
|
|
41
|
+
function setCodexCatalogSource(value, source) {
|
|
42
|
+
if (source) getSources().values.set(value, source);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
/** Source attribution survives projection without becoming serialized row data. */
|
|
46
|
+
function copyCodexCatalogSource(from, to) {
|
|
47
|
+
return setCodexCatalogSource(to, getCodexCatalogSource(from));
|
|
48
|
+
}
|
|
49
|
+
/** Stamp the final decoded objects, including any bounded catalog DTO replacement. */
|
|
50
|
+
function recordCodexCatalogResponseSource(method, result, source) {
|
|
51
|
+
if (result === null || typeof result !== "object") return;
|
|
52
|
+
if (method === "thread/list" && "data" in result && Array.isArray(result.data)) {
|
|
53
|
+
setCodexCatalogSource(result, source);
|
|
54
|
+
for (const thread of result.data) if (thread !== null && typeof thread === "object") setCodexCatalogSource(thread, source);
|
|
55
|
+
} else if ((method === "thread/read" || method === "thread/start" || method === "thread/fork" || method === "thread/resume") && "thread" in result && result.thread !== null && typeof result.thread === "object") {
|
|
56
|
+
setCodexCatalogSource(result, source);
|
|
57
|
+
setCodexCatalogSource(result.thread, source);
|
|
58
|
+
if ("ephemeral" in result.thread && result.thread.ephemeral === true && "id" in result.thread && typeof result.thread.id === "string") getEphemeralObservers().get(source)?.(result.thread.id);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region extensions/codex/src/session-catalog-native-projection.ts
|
|
63
|
+
var session_catalog_native_projection_exports = /* @__PURE__ */ __exportAll({
|
|
64
|
+
CODEX_CATALOG_NATIVE_PAGE_LIMIT: () => 64,
|
|
65
|
+
projectCodexCatalogNativeResponse: () => projectCodexCatalogNativeResponse,
|
|
66
|
+
projectCodexCatalogNativeThread: () => projectCodexCatalogNativeThread,
|
|
67
|
+
reuseCodexCatalogPreview: () => reuseCodexCatalogPreview
|
|
68
|
+
});
|
|
69
|
+
const CODEX_CATALOG_NATIVE_PAGE_LIMIT = 64;
|
|
70
|
+
const STRING_FIELDS = [
|
|
71
|
+
[
|
|
72
|
+
"name",
|
|
73
|
+
500,
|
|
74
|
+
"truncate"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"cwd",
|
|
78
|
+
MAX_CWD_LENGTH,
|
|
79
|
+
"omit"
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
"modelProvider",
|
|
83
|
+
500,
|
|
84
|
+
"truncate"
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
"cliVersion",
|
|
88
|
+
500,
|
|
89
|
+
"truncate"
|
|
90
|
+
]
|
|
91
|
+
];
|
|
92
|
+
/** Drop unused native fields before catalog-owned asynchronous work can retain them. */
|
|
93
|
+
function projectCodexCatalogNativeThread(thread, sanitize, cachedPreview) {
|
|
94
|
+
if (!isJsonObject(thread)) throw new Error("Codex catalog response contains an invalid thread");
|
|
95
|
+
const id = boundedCatalogString(thread.id, 256);
|
|
96
|
+
if (!id) throw new Error("Codex catalog response contains an invalid thread id");
|
|
97
|
+
const row = {
|
|
98
|
+
id,
|
|
99
|
+
projectId: boundedCatalogString(thread.projectId, 256, "omit") ?? null
|
|
100
|
+
};
|
|
101
|
+
const sessionId = boundedCatalogString(thread.sessionId, 256, "omit");
|
|
102
|
+
if (sessionId) row.sessionId = sessionId;
|
|
103
|
+
if (thread.ephemeral === true) return copyCodexCatalogSource(thread, {
|
|
104
|
+
...row,
|
|
105
|
+
ephemeral: true
|
|
106
|
+
});
|
|
107
|
+
for (const [field, limit, overflow] of STRING_FIELDS) {
|
|
108
|
+
const value = thread[field];
|
|
109
|
+
const bounded = boundedCatalogString(value, limit, overflow);
|
|
110
|
+
if (value === null || bounded !== void 0) row[field] = bounded ?? null;
|
|
111
|
+
}
|
|
112
|
+
if (typeof thread.path === "string") {
|
|
113
|
+
if (thread.path.length > 4096) throw new Error("Codex catalog rollout path exceeds its length limit");
|
|
114
|
+
row.path = detachCodexCatalogString(thread.path);
|
|
115
|
+
} else if (thread.path === null) row.path = null;
|
|
116
|
+
if (typeof thread.originator === "string") row.originator = detachCodexCatalogString(thread.originator.slice(0, 500));
|
|
117
|
+
for (const field of [
|
|
118
|
+
"createdAt",
|
|
119
|
+
"updatedAt",
|
|
120
|
+
"recencyAt"
|
|
121
|
+
]) {
|
|
122
|
+
const value = thread[field];
|
|
123
|
+
if (value === null || typeof value === "number" && Number.isFinite(value)) row[field] = value;
|
|
124
|
+
}
|
|
125
|
+
const rawPreview = thread.preview;
|
|
126
|
+
const preview = reuseCodexCatalogPreview(row, typeof rawPreview === "string" ? Boolean(rawPreview) : void 0, cachedPreview);
|
|
127
|
+
if (preview !== void 0) row.preview = preview;
|
|
128
|
+
else if (typeof rawPreview === "string") row.preview = rawPreview ? truncateCodexCatalogPreview(selectCodexCatalogPreviewInput(rawPreview), sanitize) : "";
|
|
129
|
+
else if (rawPreview === null) row.preview = null;
|
|
130
|
+
const source = typeof thread.source === "string" ? detachCodexCatalogString(thread.source.slice(0, 500)) : void 0;
|
|
131
|
+
if (source === "cli" || source === "vscode" || source === "exec" || source === "appServer" || source === "unknown") row.source = source;
|
|
132
|
+
else if (isJsonObject(thread.source) && typeof thread.source.custom === "string" && thread.source.custom.length <= 500) row.source = { custom: detachCodexCatalogString(thread.source.custom) };
|
|
133
|
+
if (isJsonObject(thread.gitInfo)) {
|
|
134
|
+
const branch = boundedCatalogString(thread.gitInfo.branch, 500, "truncate");
|
|
135
|
+
if (branch !== void 0) row.gitInfo = { branch };
|
|
136
|
+
}
|
|
137
|
+
if (isJsonObject(thread.status)) {
|
|
138
|
+
const type = boundedCatalogString(thread.status.type, 64);
|
|
139
|
+
if (type === "active" || type === "idle" || type === "notLoaded" || type === "systemError") {
|
|
140
|
+
const activeFlags = type === "active" && Array.isArray(thread.status.activeFlags) ? thread.status.activeFlags.slice(0, 16).flatMap((flag) => {
|
|
141
|
+
const bounded = boundedCatalogString(flag, 128, "omit");
|
|
142
|
+
return bounded ? [bounded] : [];
|
|
143
|
+
}) : void 0;
|
|
144
|
+
row.status = type === "active" ? {
|
|
145
|
+
type,
|
|
146
|
+
...activeFlags ? { activeFlags } : {}
|
|
147
|
+
} : { type };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return copyCodexCatalogSource(thread, row);
|
|
151
|
+
}
|
|
152
|
+
/** Keep only the admitted prefix before an RPC promise retains its response. */
|
|
153
|
+
function projectCodexCatalogNativeResponse(response, sanitize, cachedPreview, remainingRows = 64) {
|
|
154
|
+
if (!Array.isArray(response.data) || response.data.length > 64) throw new Error("Codex catalog response exceeds its native page limit");
|
|
155
|
+
const limit = Number.isFinite(remainingRows) ? Math.max(0, Math.min(64, Math.floor(remainingRows))) : 0;
|
|
156
|
+
const page = { data: response.data.slice(0, limit).map((thread) => projectCodexCatalogNativeThread(thread, sanitize, cachedPreview)) };
|
|
157
|
+
for (const field of ["nextCursor", "backwardsCursor"]) {
|
|
158
|
+
const value = response[field];
|
|
159
|
+
if (value === null) page[field] = null;
|
|
160
|
+
else if (value !== void 0) {
|
|
161
|
+
if (typeof value !== "string" || value.length > 4096) throw new Error("Codex catalog response contains an invalid cursor");
|
|
162
|
+
page[field] = detachCodexCatalogString(value);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return page;
|
|
166
|
+
}
|
|
167
|
+
/** Reuse resident text without transferring a cache or an unbounded native preview. */
|
|
168
|
+
function reuseCodexCatalogPreview(thread, rawPreviewNonempty, cachedPreview) {
|
|
169
|
+
const preview = cachedPreview?.({
|
|
170
|
+
id: thread.id,
|
|
171
|
+
path: typeof thread.path === "string" ? thread.path : null,
|
|
172
|
+
updatedAt: typeof thread.updatedAt === "number" ? thread.updatedAt : null,
|
|
173
|
+
recencyAt: typeof thread.recencyAt === "number" ? thread.recencyAt : null
|
|
174
|
+
});
|
|
175
|
+
return preview !== void 0 && preview.length <= 500 && (rawPreviewNonempty === void 0 || rawPreviewNonempty === Boolean(preview)) ? preview : void 0;
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { session_catalog_native_projection_exports as a, copyCodexCatalogSource as c, observeCodexCatalogEphemeralThreads as d, recordCodexCatalogResponseSource as f, reuseCodexCatalogPreview as i, getCodexCatalogSource as l, projectCodexCatalogNativeResponse as n, closeCodexCatalogClientSource as o, setCodexCatalogSource as p, projectCodexCatalogNativeThread as r, codexCatalogSourceForClient as s, CODEX_CATALOG_NATIVE_PAGE_LIMIT as t, hasLiveCodexCatalogSource as u };
|
|
@@ -1,37 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as CatalogParamsError } from "./session-catalog-parsing-CPGaPYr-.mjs";
|
|
2
2
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
3
4
|
import { parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
|
|
4
|
-
import { listSessionCatalogEntries, sessionCatalogAdoptedSessionKey, sessionCatalogAdoptedSourceKey } from "openclaw/plugin-sdk/session-catalog";
|
|
5
5
|
import { resolveStorePath } from "openclaw/plugin-sdk/session-store-paths";
|
|
6
|
+
import { listSessionCatalogEntries, sessionCatalogAdoptedSessionKey, sessionCatalogAdoptedSourceKey } from "openclaw/plugin-sdk/session-catalog";
|
|
6
7
|
//#region extensions/codex/src/session-catalog-node-adoption.ts
|
|
7
8
|
const CODEX_NODE_SESSION_KEY_PREFIX = "harness:codex:node-session:";
|
|
8
|
-
const
|
|
9
|
-
const sessionActionTails = /* @__PURE__ */ new Map();
|
|
10
|
-
async function runSessionActionExclusive(threadId, run) {
|
|
11
|
-
const operation = (sessionActionTails.get(threadId) ?? Promise.resolve()).then(run);
|
|
12
|
-
const tail = operation.then(() => void 0, () => void 0);
|
|
13
|
-
sessionActionTails.set(threadId, tail);
|
|
14
|
-
try {
|
|
15
|
-
return await operation;
|
|
16
|
-
} finally {
|
|
17
|
-
if (sessionActionTails.get(threadId) === tail) sessionActionTails.delete(threadId);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
9
|
+
const catalogSessionActions = new KeyedAsyncQueue();
|
|
20
10
|
function adoptionSessionKeyRest(sessionKey) {
|
|
21
11
|
const trimmed = sessionKey.trim();
|
|
22
12
|
return parseAgentSessionKey(trimmed)?.rest ?? trimmed;
|
|
23
13
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
14
|
+
function nodeAdoptedSourceKey(hostId, threadId, sourceHomeId) {
|
|
15
|
+
return sessionCatalogAdoptedSourceKey(JSON.stringify([hostId, sourceHomeId]), threadId);
|
|
16
|
+
}
|
|
17
|
+
function nodeAdoptionSessionKey(hostId, threadId, sourceHomeId) {
|
|
18
|
+
const source = JSON.stringify([
|
|
19
|
+
hostId,
|
|
20
|
+
sourceHomeId,
|
|
21
|
+
threadId
|
|
22
|
+
]);
|
|
26
23
|
return sessionCatalogAdoptedSessionKey(CODEX_NODE_SESSION_KEY_PREFIX, source);
|
|
27
24
|
}
|
|
28
25
|
function readNodeSessionMarker(entry) {
|
|
29
26
|
const codex = isRecord(entry.pluginExtensions?.codex) ? entry.pluginExtensions.codex : void 0;
|
|
30
27
|
const marker = codex && isRecord(codex.sessionCatalog) ? codex.sessionCatalog : void 0;
|
|
31
|
-
if (!marker || typeof marker.sourceHostId !== "string" || !marker.sourceHostId.startsWith("node:") || typeof marker.sourceThreadId !== "string" || !marker.sourceThreadId.trim() || typeof marker.nodeId !== "string" || !marker.nodeId.trim()) return;
|
|
28
|
+
if (!marker || typeof marker.sourceHostId !== "string" || !marker.sourceHostId.startsWith("node:") || typeof marker.sourceThreadId !== "string" || !marker.sourceThreadId.trim() || typeof marker.nodeId !== "string" || !marker.nodeId.trim() || marker.sourceHomeId !== void 0 && (typeof marker.sourceHomeId !== "string" || !marker.sourceHomeId.trim() || marker.sourceHomeId.length > 256)) return;
|
|
32
29
|
return {
|
|
33
30
|
sourceHostId: marker.sourceHostId,
|
|
34
31
|
sourceThreadId: marker.sourceThreadId,
|
|
32
|
+
...typeof marker.sourceHomeId === "string" ? { sourceHomeId: marker.sourceHomeId } : {},
|
|
35
33
|
nodeId: marker.nodeId,
|
|
36
34
|
...marker.initializing === true ? { initializing: true } : {}
|
|
37
35
|
};
|
|
@@ -46,8 +44,8 @@ function listNodeAdoptedSessionEntries(params) {
|
|
|
46
44
|
})) {
|
|
47
45
|
const marker = readNodeSessionMarker(entry);
|
|
48
46
|
const sessionId = entry.sessionId?.trim();
|
|
49
|
-
if (!marker || marker.initializing === true && params.includeInitializing !== true || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true || !sessionId || adoptionSessionKeyRest(sessionKey) !== nodeAdoptionSessionKey(marker.sourceHostId, marker.sourceThreadId) || marker.sourceHostId !== `node:${marker.nodeId}`) continue;
|
|
50
|
-
const sourceKey =
|
|
47
|
+
if (!marker || !marker.sourceHomeId || marker.initializing === true && params.includeInitializing !== true || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true || !sessionId || adoptionSessionKeyRest(sessionKey) !== nodeAdoptionSessionKey(marker.sourceHostId, marker.sourceThreadId, marker.sourceHomeId) || marker.sourceHostId !== `node:${marker.nodeId}`) continue;
|
|
48
|
+
const sourceKey = nodeAdoptedSourceKey(marker.sourceHostId, marker.sourceThreadId, marker.sourceHomeId);
|
|
51
49
|
if (adopted.has(sourceKey)) throw new Error(`multiple OpenClaw sessions adopt Codex thread ${marker.sourceThreadId} on ${marker.sourceHostId}`);
|
|
52
50
|
adopted.set(sourceKey, {
|
|
53
51
|
key: sessionKey,
|
|
@@ -59,12 +57,13 @@ function listNodeAdoptedSessionEntries(params) {
|
|
|
59
57
|
return adopted;
|
|
60
58
|
}
|
|
61
59
|
function findNodeAdoptedSessionEntry(params) {
|
|
62
|
-
return listNodeAdoptedSessionEntries(params).get(
|
|
60
|
+
return listNodeAdoptedSessionEntries(params).get(nodeAdoptedSourceKey(params.hostId, params.threadId, params.sourceHomeId));
|
|
63
61
|
}
|
|
64
62
|
function nodeSessionMarker(params) {
|
|
65
63
|
return {
|
|
66
64
|
sourceHostId: params.hostId,
|
|
67
65
|
sourceThreadId: params.threadId,
|
|
66
|
+
sourceHomeId: params.sourceHomeId,
|
|
68
67
|
nodeId: params.nodeId,
|
|
69
68
|
...params.initializing === true ? { initializing: true } : {}
|
|
70
69
|
};
|
|
@@ -79,7 +78,7 @@ async function finalizeNodeAdoptedSession(params) {
|
|
|
79
78
|
preserveActivity: true,
|
|
80
79
|
update: (entry) => {
|
|
81
80
|
const current = readNodeSessionMarker(entry);
|
|
82
|
-
if (entry.sessionId?.trim() !== params.adopted.sessionId || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true || !current || current.sourceHostId !== params.marker.sourceHostId || current.sourceThreadId !== params.marker.sourceThreadId || current.nodeId !== params.marker.nodeId) throw changedError();
|
|
81
|
+
if (entry.sessionId?.trim() !== params.adopted.sessionId || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true || !current || current.sourceHostId !== params.marker.sourceHostId || current.sourceThreadId !== params.marker.sourceThreadId || current.sourceHomeId !== params.marker.sourceHomeId || current.nodeId !== params.marker.nodeId) throw changedError();
|
|
83
82
|
if (current.initializing !== true) return {
|
|
84
83
|
archivedAt: void 0,
|
|
85
84
|
archivedBy: void 0,
|
|
@@ -106,25 +105,28 @@ async function finalizeNodeAdoptedSession(params) {
|
|
|
106
105
|
readConsistency: "latest"
|
|
107
106
|
});
|
|
108
107
|
const current = currentEntry ? readNodeSessionMarker(currentEntry) : void 0;
|
|
109
|
-
if (currentEntry?.sessionId?.trim() === params.adopted.sessionId && current?.initializing !== true && current?.sourceHostId === params.marker.sourceHostId && current.sourceThreadId === params.marker.sourceThreadId && current.nodeId === params.marker.nodeId) return;
|
|
108
|
+
if (currentEntry?.sessionId?.trim() === params.adopted.sessionId && current?.initializing !== true && current?.sourceHostId === params.marker.sourceHostId && current.sourceThreadId === params.marker.sourceThreadId && current.sourceHomeId === params.marker.sourceHomeId && current.nodeId === params.marker.nodeId) return;
|
|
110
109
|
throw error;
|
|
111
110
|
}
|
|
112
111
|
if (!finalized) throw changedError();
|
|
113
112
|
}
|
|
114
113
|
async function createOrReuseNodeAdoptedSession(params) {
|
|
115
|
-
const
|
|
114
|
+
const lookup = {
|
|
116
115
|
agentId: params.agentId,
|
|
117
116
|
config: params.config,
|
|
118
117
|
runtime: params.api.runtime,
|
|
119
118
|
hostId: params.hostId,
|
|
120
119
|
threadId: params.record.threadId,
|
|
120
|
+
sourceHomeId: params.sourceHomeId,
|
|
121
121
|
includeInitializing: true
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
|
+
const existing = findNodeAdoptedSessionEntry(lookup);
|
|
123
124
|
if (existing) return existing;
|
|
124
125
|
const initializingMarker = {
|
|
125
126
|
...nodeSessionMarker({
|
|
126
127
|
hostId: params.hostId,
|
|
127
128
|
threadId: params.record.threadId,
|
|
129
|
+
sourceHomeId: params.sourceHomeId,
|
|
128
130
|
nodeId: params.nodeId
|
|
129
131
|
}),
|
|
130
132
|
initializing: true
|
|
@@ -132,7 +134,7 @@ async function createOrReuseNodeAdoptedSession(params) {
|
|
|
132
134
|
try {
|
|
133
135
|
const created = await params.api.runtime.agent.session.createSessionEntry({
|
|
134
136
|
cfg: params.config,
|
|
135
|
-
key: nodeAdoptionSessionKey(params.hostId, params.record.threadId),
|
|
137
|
+
key: nodeAdoptionSessionKey(params.hostId, params.record.threadId, params.sourceHomeId),
|
|
136
138
|
agentId: params.agentId,
|
|
137
139
|
recoverMatchingInitialEntry: true,
|
|
138
140
|
displayName: params.record.name ?? void 0,
|
|
@@ -144,7 +146,7 @@ async function createOrReuseNodeAdoptedSession(params) {
|
|
|
144
146
|
},
|
|
145
147
|
afterCreate: async (entry) => {
|
|
146
148
|
const storePath = resolveStorePath(params.config.session?.store, { agentId: entry.agentId });
|
|
147
|
-
const { importCodexThreadHistoryToTranscript } = await import("./transcript-mirror-
|
|
149
|
+
const { importCodexThreadHistoryToTranscript } = await import("./transcript-mirror-kxmCYsuF.mjs").then((n) => n.a);
|
|
148
150
|
await importCodexThreadHistoryToTranscript({
|
|
149
151
|
thread: params.history.thread,
|
|
150
152
|
throughTurnId: params.history.throughTurnId,
|
|
@@ -166,17 +168,10 @@ async function createOrReuseNodeAdoptedSession(params) {
|
|
|
166
168
|
initializing: true
|
|
167
169
|
};
|
|
168
170
|
} catch (error) {
|
|
169
|
-
const raced = findNodeAdoptedSessionEntry(
|
|
170
|
-
agentId: params.agentId,
|
|
171
|
-
config: params.config,
|
|
172
|
-
runtime: params.api.runtime,
|
|
173
|
-
hostId: params.hostId,
|
|
174
|
-
threadId: params.record.threadId,
|
|
175
|
-
includeInitializing: true
|
|
176
|
-
});
|
|
171
|
+
const raced = findNodeAdoptedSessionEntry(lookup);
|
|
177
172
|
if (raced) return raced;
|
|
178
173
|
throw error;
|
|
179
174
|
}
|
|
180
175
|
}
|
|
181
176
|
//#endregion
|
|
182
|
-
export { adoptionSessionKeyRest,
|
|
177
|
+
export { CODEX_NODE_SESSION_KEY_PREFIX, adoptionSessionKeyRest, catalogSessionActions, createOrReuseNodeAdoptedSession, finalizeNodeAdoptedSession, findNodeAdoptedSessionEntry, listNodeAdoptedSessionEntries, nodeAdoptedSourceKey, nodeSessionMarker, readNodeSessionMarker };
|