@openclaw/codex 2026.9.3 → 2026.9.5
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/assets/activity.svg +30 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/account-usage-runtime-C2MOIvfq.mjs +75 -0
- package/dist/{apply-B6el6hdO.js → .setup/apply-CJ0ZfmBG.mjs} +12 -13
- package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
- package/dist/{attempt-client-cleanup-D6cR54TV.js → .setup/attempt-client-cleanup-BpYKdTA0.mjs} +30 -211
- package/dist/{attempt-context-AO4DSjE0.js → .setup/attempt-context-VXVwTCfS.mjs} +6 -6
- package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
- package/dist/{auth-binding-Co2Vfcf_.js → .setup/auth-binding-DhLWa_7K.mjs} +2 -2
- package/dist/{auth-cache-key-Kq6oerr6.js → .setup/auth-cache-key-QirmgiCo.mjs} +3 -3
- package/dist/{auth-profile-CwzO4_RG.js → .setup/auth-profile-WqZtZfXN.mjs} +1 -1
- package/dist/.setup/binding-connection-Bm38niE8.mjs +50 -0
- package/dist/.setup/binding-connection.runtime-CnRMC0ta.mjs +48 -0
- package/dist/{bounded-turn-lRpmZHFv.js → .setup/bounded-turn-BtlZcivC.mjs} +19 -14
- package/dist/{build-state-6RL6qohz.js → .setup/build-state-Xx9ybZqa.mjs} +1 -1
- package/dist/{capabilities-BeqLPbtM.js → .setup/capabilities-_vXcZGSx.mjs} +1 -1
- package/dist/{client-BEKu4yDx.js → .setup/client-vXs2929Q.mjs} +355 -164
- package/dist/{command-dispatch-CisT9Jqq.js → .setup/command-dispatch-naHIZwwF.mjs} +3 -3
- package/dist/{command-formatters-DeTfrapr.js → .setup/command-formatters-CGEkdawF.mjs} +4 -3
- package/dist/{command-handlers-BfIsJEuA.js → .setup/command-handlers-BtAJEW1X.mjs} +812 -152
- package/dist/{command-rpc-BMqRQOFX.js → .setup/command-rpc-DHFpn4le.mjs} +37 -21
- package/dist/{compact-CGJZ2rlb.js → .setup/compact-C3i3qlzj.mjs} +28 -43
- package/dist/{config-JDfTI4VI.js → .setup/config-CedDWjM-.mjs} +5 -4
- package/dist/{config-options-jnIFvwxD.js → .setup/config-options-BsanJ8QG.mjs} +9 -421
- package/dist/{protocol-CAAcVIKF.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
- package/dist/{config-runtime-BWf6JLWG.js → .setup/config-runtime-CeAhl_h4.mjs} +2 -2
- package/dist/.setup/config-security-BRQ2mgW9.mjs +465 -0
- package/dist/{config-utils-C57JiJrU.js → .setup/config-utils-DujwEnhg.mjs} +2 -4
- package/dist/{conversation-binding-CxOlHiix.js → .setup/conversation-binding-DhzrpTM6.mjs} +60 -47
- package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
- package/dist/{conversation-control-CUCrSIQI.js → .setup/conversation-control-DN53ns41.mjs} +17 -13
- package/dist/.setup/cyber-failover-DYwbmf1o.mjs +123 -0
- package/dist/.setup/cyber-failover-notice-e9G3J9-e.mjs +17 -0
- package/dist/{dynamic-tools-D-JBoaLt.js → .setup/dynamic-tools-D16lOp67.mjs} +168 -61
- package/dist/{effective-mcp-catalog-J_5Ep5Um.js → .setup/effective-mcp-catalog-K6kLCN8X.mjs} +3 -3
- package/dist/{ephemeral-turn-DSwzP8YY.js → .setup/ephemeral-turn-R1gA8Sn6.mjs} +4 -5
- package/dist/{event-projector-assistant-message-BmBM4qBV.js → .setup/event-projector-assistant-message-DNUR1s0A.mjs} +6 -3
- package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +200 -0
- package/dist/{attempt-notifications--H8zXR5-.js → .setup/event-projector-usage-C7Ntzs-f.mjs} +102 -9
- package/dist/{harness-FR6eQgyO.js → .setup/harness-rxaaoN-o.mjs} +90 -19
- package/dist/.setup/inference-context-fulhZuz8.mjs +94 -0
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +311 -0
- package/dist/{isolated-completion-DHBefrzg.js → .setup/isolated-completion-B6srt48J.mjs} +7 -7
- package/dist/{launch-args-RXQwn8zV.js → .setup/launch-args-DnMak49W.mjs} +22 -1
- package/dist/{managed-binary-DrjjRRUD.js → .setup/managed-binary-DP6Rib3P.mjs} +11 -2
- package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
- package/dist/{model-catalog-B_6M04Wo.js → .setup/model-catalog-DkvUuBey.mjs} +35 -10
- package/dist/{models-P9k2qAof.js → .setup/models-BDFgm_G-.mjs} +3 -3
- package/dist/.setup/native-auth-BLZGqFjw.mjs +57 -0
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +135 -0
- package/dist/.setup/native-subagent-monitor-B1hxzIOy.mjs +5031 -0
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +411 -0
- package/dist/{node-cli-sessions-rj0ysJwM.js → .setup/node-cli-sessions-Cl8b2ZF3.mjs} +1 -1
- package/dist/{node-exec-server.runtime-BY_ctYnT.js → .setup/node-exec-server.runtime-BaViBKNz.mjs} +5 -5
- package/dist/{plan-BMJdMOEF.js → .setup/plan-xD7WKYTM.mjs} +331 -79
- package/dist/{plugin-activation-BQK-f5sV.js → .setup/plugin-activation-r8nq5Jzp.mjs} +24 -19
- package/dist/{plugin-app-cache-key-CdSQzWyX.js → .setup/plugin-app-cache-key-BOxKP7db.mjs} +29 -25
- package/dist/{plugin-approval-roundtrip-DeW95wB5.js → .setup/plugin-approval-roundtrip-CjfzafAZ.mjs} +1 -1
- package/dist/{plugin-inventory-CoRCzWW4.js → .setup/plugin-inventory-DUle8DLz.mjs} +12 -8
- package/dist/{plugin-marketplace-discovery-3akBizzF.js → .setup/plugin-marketplace-discovery-P-Vndfqq.mjs} +18 -15
- package/dist/{plugin-metadata-cache-DgNfRAGA.js → .setup/plugin-metadata-cache-DsS5buNa.mjs} +33 -14
- package/dist/{provider-capabilities-W4tfK5Y5.js → .setup/provider-capabilities-B8J4Dy-O.mjs} +2 -2
- package/dist/.setup/provider-fFh_-VR3.mjs +50 -0
- package/dist/{rate-limits-Bqnx1N4z.js → .setup/rate-limits-DOEGYRNs.mjs} +90 -46
- package/dist/.setup/request-BioXJLYa.mjs +292 -0
- package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
- package/dist/{run-attempt-DwKds3DN.js → .setup/run-attempt-rlA07pUv.mjs} +644 -491
- package/dist/{runtime-artifact-T-NwqeSH.js → .setup/runtime-artifact-Dy38Z5iU.mjs} +2 -2
- package/dist/{sandbox-guard-BcT66fWy.js → .setup/sandbox-guard-BBP-RbTf.mjs} +4 -3
- package/dist/{session-binding-CKSepwIC.js → .setup/session-binding-_0W_fHRr.mjs} +45 -63
- package/dist/{session-binding-record-CaZjYwNS.js → .setup/session-binding-record-TH3xA0zj.mjs} +181 -3
- package/dist/.setup/session-binding-sidecars-CKYEcfNn.mjs +543 -0
- package/dist/{session-catalog-adoption-BKLtSrwi.js → .setup/session-catalog-adoption-CR_whkEW.mjs} +6 -6
- package/dist/{session-catalog-archive-D0i2pGj2.js → .setup/session-catalog-archive-CwZaPacf.mjs} +6 -6
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +250 -0
- package/dist/.setup/session-catalog-fUdWDx-U.mjs +2464 -0
- package/dist/.setup/session-catalog-index-B141u15s.mjs +1070 -0
- package/dist/.setup/session-catalog-index-order-Cc5BzlQr.mjs +48 -0
- package/dist/.setup/session-catalog-index-state-BAuDztHN.mjs +180 -0
- package/dist/{session-catalog-parsing-CdD3JhdM.js → .setup/session-catalog-native-projection-ChV3cCtm.mjs} +213 -21
- package/dist/{session-catalog-node-adoption-BUuDYY8R.js → .setup/session-catalog-node-adoption-BVRsYOSh.mjs} +3 -3
- package/dist/{session-catalog-node-continue-CBtc4wkI.js → .setup/session-catalog-node-continue-Dowv8osw.mjs} +7 -7
- package/dist/.setup/session-catalog-projection-C1Bj9Jl-.mjs +414 -0
- package/dist/{session-cli-CbgaHh0f.js → .setup/session-cli-DIj-IE-E.mjs} +4 -4
- package/dist/{session-history-Cz-tOOYj.js → .setup/session-history-C--SrLI8.mjs} +10 -5
- package/dist/{session-history-import-DFN7sWRU.js → .setup/session-history-import-JHXT5Xfi.mjs} +4 -4
- package/dist/{session-history-read-cxPUxyVV.js → .setup/session-history-read-B3ZfSUbF.mjs} +2 -2
- package/dist/{session-history.worker-CNEvGaU5.js → .setup/session-history.worker-CpNj7H_P.mjs} +192 -89
- package/dist/{session-initialization-Jo86C60I.js → .setup/session-initialization-DH1z6fXn.mjs} +2 -2
- package/dist/{session-permission-policy-B22InTp_.js → .setup/session-permission-policy-DhurXY0l.mjs} +2 -2
- package/dist/{session-retirement-BSNG_mhf.js → .setup/session-retirement-CU87AOg9.mjs} +6 -6
- package/dist/{settled-turn-context-Du6gdUDd.js → .setup/settled-turn-context-fmwouT5I.mjs} +2 -2
- package/dist/{settled-turn-finalizer-BuLUrZl2.js → .setup/settled-turn-finalizer-CiY2bLFK.mjs} +10 -10
- package/dist/{shared-client-CVhez2Uo.js → .setup/shared-client-BpTtuLQ5.mjs} +495 -156
- package/dist/{side-question-DLbr2vUU.js → .setup/side-question-DSCZyoBD.mjs} +64 -47
- package/dist/{source-Da-h6f7e.js → .setup/source-Bjp4UQij.mjs} +15 -14
- package/dist/{thread-archive-guard-D1bP04Tf.js → .setup/thread-archive-guard-jmecf6OJ.mjs} +1 -1
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +83 -0
- package/dist/{thread-lifecycle-D1pzRwHB.js → .setup/thread-lifecycle-Cik28qWn.mjs} +330 -150
- package/dist/{thread-ownership-D6oASVRu.js → .setup/thread-ownership-skomxnIt.mjs} +4 -4
- package/dist/{thread-policy-D8kI7yAO.js → .setup/thread-policy-Cjs4B8xf.mjs} +3 -3
- package/dist/{thread-resume-T5cveyxA.js → .setup/thread-resume-BkNpj9Pz.mjs} +8 -5
- package/dist/.setup/timeout-DZF05XrR.mjs +63 -0
- package/dist/{session-catalog-home-id-D7-aLiNt.js → .setup/transcript-history-projection-DHNBDhCU.mjs} +73 -20
- package/dist/{transcript-mirror-t5TOccct.js → .setup/transcript-mirror-D4qp_leP.mjs} +15 -6
- package/dist/{transcript-mirror-attestation-DibE0krH.js → .setup/transcript-mirror-attestation-CzM-94NC.mjs} +4 -1
- package/dist/{transport-stdio-BGjHoYLr.js → .setup/transport-stdio-Cmx94Oiy.mjs} +149 -44
- package/dist/{upstream-session-fork-De-sLJ2r.js → .setup/upstream-session-fork-D3UKxgVD.mjs} +27 -26
- package/dist/{usage-CPPTmBvZ.js → .setup/usage-BOgBEKso.mjs} +4 -4
- package/dist/.setup/usage-limit-error-C0ow7DOc.mjs +166 -0
- package/dist/{version-omm6IPI3.js → .setup/version-CoqzXPgK.mjs} +1 -1
- package/dist/{web-search-provider.runtime-CSVgQL0w.js → .setup/web-search-provider.runtime-CTGuJt6i.mjs} +3 -3
- package/dist/api.js +28 -20
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +8 -528
- package/dist/harness.js +1 -1
- package/dist/index.js +130 -135
- package/dist/media-understanding-provider.js +3 -3
- package/dist/migration-provider-api.js +2 -0
- package/dist/native-tool-policy.js +12 -0
- package/dist/provider-discovery.js +18 -0
- package/dist/session-history-worker-runtime.js +23 -5
- package/dist/session-history.worker.js +2 -2
- package/dist/web-search-contract-api.js +1 -1
- package/openclaw.plugin.json +354 -68
- package/package.json +11 -8
- package/dist/binding-connection-QqgcPCgk.js +0 -60
- package/dist/event-projector-usage-CIyrYYid.js +0 -102
- package/dist/native-subagent-monitor-BbCUKRwC.js +0 -3350
- package/dist/request-CGvGOpeR.js +0 -198
- package/dist/session-catalog-HaDcp7Sv.js +0 -1533
- package/dist/session-catalog-provenance-DkJHo735.js +0 -124
- package/dist/timeout-BVw8aaM1.js +0 -33
- package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
- package/dist/{context-compaction-activity-CMla5FPJ.js → .setup/context-compaction-activity-CMla5FPJ.mjs} +0 -0
- package/dist/{elicitation-input-DPoK8F7w.js → .setup/elicitation-input-DPoK8F7w.mjs} +0 -0
- package/dist/{history-rejection-B4nOXNXF.js → .setup/history-rejection-B4nOXNXF.mjs} +0 -0
- package/dist/{image-payload-sanitizer-tupAr-2o.js → .setup/image-payload-sanitizer-tupAr-2o.mjs} +0 -0
- package/dist/{incognito-session-uhrBF6wJ.js → .setup/incognito-session-uhrBF6wJ.mjs} +0 -0
- package/dist/{local-runtime-attribution-B_2mnqhb.js → .setup/local-runtime-attribution-B_2mnqhb.mjs} +0 -0
- package/dist/{native-execution-policy-umd0tgh4.js → .setup/native-execution-policy-YBMHSzC4.mjs} +1 -1
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
- /package/dist/{session-upstream-marker-D15C9NHp.js → .setup/session-upstream-marker-D15C9NHp.mjs} +0 -0
- /package/dist/{upstream-prompt-provenance-LphB8slG.js → .setup/upstream-prompt-provenance-LphB8slG.mjs} +0 -0
- /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { n as defineCodexBuildState } from "./build-state-Xx9ybZqa.mjs";
|
|
2
|
+
import { g as resolveCodexAppServerLocalHomeDir, m as isJsonObject, r as inferCodexAppServerConnectionClass } from "./config-security-BRQ2mgW9.mjs";
|
|
3
|
+
import { o as codexCatalogSourceForClient, r as projectCodexCatalogNativeThread, v as MAX_CWD_LENGTH, x as boundedCatalogString } from "./session-catalog-native-projection-ChV3cCtm.mjs";
|
|
4
|
+
import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-BOxKP7db.mjs";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-registration";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import fs$1 from "node:fs/promises";
|
|
10
|
+
import { createZstdDecompress } from "node:zlib";
|
|
11
|
+
import { root } from "openclaw/plugin-sdk/file-access-runtime";
|
|
12
|
+
//#region extensions/codex/src/session-catalog-provenance.ts
|
|
13
|
+
const MAX_SESSION_META_BYTES = 1048576;
|
|
14
|
+
const SESSION_META_READ_CHUNK_BYTES = 65536;
|
|
15
|
+
const MAX_PROVENANCE_CACHE_ENTRIES = 2e4;
|
|
16
|
+
const provenanceByPath = /* @__PURE__ */ new Map();
|
|
17
|
+
function cacheProvenance(key, value) {
|
|
18
|
+
provenanceByPath.delete(key);
|
|
19
|
+
provenanceByPath.set(key, value);
|
|
20
|
+
while (provenanceByPath.size > MAX_PROVENANCE_CACHE_ENTRIES) {
|
|
21
|
+
const oldest = provenanceByPath.keys().next().value;
|
|
22
|
+
if (oldest === void 0) break;
|
|
23
|
+
provenanceByPath.delete(oldest);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Undefined means the metadata line is not durable enough to cache yet. */
|
|
27
|
+
async function readCodexSessionMeta(sessionsRoot, rolloutPath, threadId) {
|
|
28
|
+
let safeRoot;
|
|
29
|
+
try {
|
|
30
|
+
safeRoot = await root(sessionsRoot, {
|
|
31
|
+
hardlinks: "reject",
|
|
32
|
+
maxBytes: Number.MAX_SAFE_INTEGER,
|
|
33
|
+
symlinks: "reject"
|
|
34
|
+
});
|
|
35
|
+
} catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const candidates = rolloutPath.endsWith(".zst") ? [rolloutPath, rolloutPath.slice(0, -4)] : [rolloutPath, `${rolloutPath}.zst`];
|
|
39
|
+
for (const candidate of candidates) {
|
|
40
|
+
let opened;
|
|
41
|
+
try {
|
|
42
|
+
opened = await safeRoot.open(path.relative(sessionsRoot, candidate));
|
|
43
|
+
} catch {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const input = opened.handle.createReadStream({
|
|
47
|
+
autoClose: false,
|
|
48
|
+
highWaterMark: SESSION_META_READ_CHUNK_BYTES
|
|
49
|
+
});
|
|
50
|
+
const reader = candidate.endsWith(".zst") ? input.pipe(createZstdDecompress()) : input;
|
|
51
|
+
try {
|
|
52
|
+
const chunks = [];
|
|
53
|
+
let bytesReadTotal = 0;
|
|
54
|
+
let line;
|
|
55
|
+
for await (const value of reader) {
|
|
56
|
+
const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
57
|
+
const remaining = MAX_SESSION_META_BYTES - bytesReadTotal;
|
|
58
|
+
if (remaining <= 0) break;
|
|
59
|
+
const bounded = chunk.subarray(0, remaining);
|
|
60
|
+
bytesReadTotal += bounded.length;
|
|
61
|
+
const newline = bounded.indexOf(10);
|
|
62
|
+
chunks.push(newline >= 0 ? bounded.subarray(0, newline) : bounded);
|
|
63
|
+
if (newline >= 0) {
|
|
64
|
+
line = Buffer.concat(chunks).toString("utf8");
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!line) continue;
|
|
69
|
+
let parsed;
|
|
70
|
+
try {
|
|
71
|
+
parsed = JSON.parse(line);
|
|
72
|
+
} catch {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!isJsonObject(parsed) || parsed.type !== "session_meta" || !isJsonObject(parsed.payload)) return null;
|
|
76
|
+
const payload = parsed.payload;
|
|
77
|
+
return payload.id === threadId ? payload : null;
|
|
78
|
+
} catch {
|
|
79
|
+
continue;
|
|
80
|
+
} finally {
|
|
81
|
+
reader.destroy();
|
|
82
|
+
input.destroy();
|
|
83
|
+
await opened.handle.close().catch(() => void 0);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Passive local listing uses native creation provenance, with rollout fallback for older records. */
|
|
88
|
+
async function isOpenClawManagedCodexThread(thread, localSessionsRoot, diagnostics) {
|
|
89
|
+
const started = diagnostics ? performance.now() : 0;
|
|
90
|
+
if (diagnostics) diagnostics.fields.provenanceChecks++;
|
|
91
|
+
try {
|
|
92
|
+
const rolloutPath = typeof thread.path === "string" ? thread.path.trim() : "";
|
|
93
|
+
if (!localSessionsRoot || !rolloutPath) return false;
|
|
94
|
+
if (typeof thread.originator === "string" && thread.originator.length > 0) return thread.originator === "openclaw";
|
|
95
|
+
const cacheKey = `${localSessionsRoot}\0${rolloutPath}`;
|
|
96
|
+
const cached = provenanceByPath.get(cacheKey);
|
|
97
|
+
if (cached !== void 0) {
|
|
98
|
+
if (diagnostics) diagnostics.fields.provenanceCacheHits++;
|
|
99
|
+
return cached;
|
|
100
|
+
}
|
|
101
|
+
if (diagnostics) diagnostics.fields.provenanceReadCalls++;
|
|
102
|
+
const metadata = await readCodexSessionMeta(localSessionsRoot, rolloutPath, thread.id);
|
|
103
|
+
const managed = metadata === void 0 ? void 0 : metadata?.originator === "openclaw";
|
|
104
|
+
if (managed !== void 0) cacheProvenance(cacheKey, managed);
|
|
105
|
+
return managed ?? false;
|
|
106
|
+
} finally {
|
|
107
|
+
if (diagnostics) diagnostics.fields.provenanceMs = (diagnostics.fields.provenanceMs ?? 0) + performance.now() - started;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region extensions/codex/src/session-catalog-home-id.ts
|
|
112
|
+
function canonicalCodexCatalogHome(value) {
|
|
113
|
+
const resolved = path.resolve(value);
|
|
114
|
+
try {
|
|
115
|
+
return fs.realpathSync.native(resolved);
|
|
116
|
+
} catch {
|
|
117
|
+
return resolved;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** One canonical identity for catalog discovery and durable ownership rows. */
|
|
121
|
+
function codexCatalogHomeId(codexHome) {
|
|
122
|
+
return codexCatalogHomeIdFromCanonicalPath(canonicalCodexCatalogHome(codexHome));
|
|
123
|
+
}
|
|
124
|
+
/** Hashes lifecycle-prepared paths without repeating filesystem discovery. */
|
|
125
|
+
function codexCatalogHomeIdFromCanonicalPath(codexHome) {
|
|
126
|
+
return createHash("sha256").update("openclaw:codex-session-catalog-home:v1\0").update(codexHome).digest("hex");
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region extensions/codex/src/session-catalog-events.ts
|
|
130
|
+
const getCatalogEvents = defineCodexBuildState("openclaw.codexCatalogEvents", () => ({
|
|
131
|
+
listeners: /* @__PURE__ */ new Map(),
|
|
132
|
+
clients: /* @__PURE__ */ new WeakMap()
|
|
133
|
+
}));
|
|
134
|
+
const CATALOG_NOTIFICATION_METHODS = /* @__PURE__ */ new Set([
|
|
135
|
+
"thread/started",
|
|
136
|
+
"turn/started",
|
|
137
|
+
"turn/completed",
|
|
138
|
+
"thread/archived",
|
|
139
|
+
"thread/deleted",
|
|
140
|
+
"thread/unarchived",
|
|
141
|
+
"thread/reverted",
|
|
142
|
+
"thread/name/updated",
|
|
143
|
+
"thread/status/changed",
|
|
144
|
+
"thread/settings/updated"
|
|
145
|
+
]);
|
|
146
|
+
/** Uses prepared local identity or resolves it once during client/index startup. */
|
|
147
|
+
async function codexCatalogResidentHomeKey(params) {
|
|
148
|
+
if (inferCodexAppServerConnectionClass(params.startOptions) === "remote") {
|
|
149
|
+
const fingerprint = buildCodexAppServerConnectionFingerprint({
|
|
150
|
+
start: params.startOptions,
|
|
151
|
+
connectionClass: "remote"
|
|
152
|
+
}, params.agentDir);
|
|
153
|
+
return `remote:${createHash("sha256").update(fingerprint).digest("hex")}`;
|
|
154
|
+
}
|
|
155
|
+
if (params.sourceHomeId) return params.sourceHomeId;
|
|
156
|
+
const home = path.resolve(params.runtimeIdentity?.codexHome ?? resolveCodexAppServerLocalHomeDir(params.startOptions, params.agentDir));
|
|
157
|
+
return codexCatalogHomeIdFromCanonicalPath(await fs$1.realpath(home).catch(() => home));
|
|
158
|
+
}
|
|
159
|
+
function subscribeCodexCatalogEvents(homeKey, listener, callbacks = {}) {
|
|
160
|
+
const { listeners } = getCatalogEvents();
|
|
161
|
+
let homeListeners = listeners.get(homeKey);
|
|
162
|
+
if (!homeListeners) {
|
|
163
|
+
homeListeners = /* @__PURE__ */ new Set();
|
|
164
|
+
listeners.set(homeKey, homeListeners);
|
|
165
|
+
}
|
|
166
|
+
const subscription = {
|
|
167
|
+
notify: listener,
|
|
168
|
+
...callbacks
|
|
169
|
+
};
|
|
170
|
+
homeListeners.add(subscription);
|
|
171
|
+
return () => {
|
|
172
|
+
homeListeners.delete(subscription);
|
|
173
|
+
if (homeListeners.size === 0 && listeners.get(homeKey) === homeListeners) listeners.delete(homeKey);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** Observes physical clients without extending their lease or native thread lifetime. */
|
|
177
|
+
function observeCodexCatalogClient(client, params) {
|
|
178
|
+
const state = getCatalogEvents();
|
|
179
|
+
const existing = state.clients.get(client);
|
|
180
|
+
if (existing) return existing.then(() => void 0);
|
|
181
|
+
const observing = (async () => {
|
|
182
|
+
const homeKey = await codexCatalogResidentHomeKey({
|
|
183
|
+
...params,
|
|
184
|
+
runtimeIdentity: client.getRuntimeIdentity()
|
|
185
|
+
});
|
|
186
|
+
if (client.getCloseError()) return;
|
|
187
|
+
const source = codexCatalogSourceForClient(client);
|
|
188
|
+
const notifyLifecycle = (callback) => {
|
|
189
|
+
for (const listener of state.listeners.get(homeKey) ?? []) try {
|
|
190
|
+
listener[callback]?.(source);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
embeddedAgentLog.warn("Codex catalog lifecycle observer failed", {
|
|
193
|
+
callback,
|
|
194
|
+
error
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const readThread = async (threadId) => (await client.request("thread/read", {
|
|
199
|
+
threadId,
|
|
200
|
+
includeTurns: false
|
|
201
|
+
}, { timeoutMs: 6e4 })).thread;
|
|
202
|
+
const stopNotifications = client.addNotificationHandler((event) => {
|
|
203
|
+
if (!CATALOG_NOTIFICATION_METHODS.has(event.method)) return;
|
|
204
|
+
for (const listener of state.listeners.get(homeKey) ?? []) listener.notify(event, readThread, source);
|
|
205
|
+
});
|
|
206
|
+
const stopClose = client.addCloseHandler(() => {
|
|
207
|
+
stopNotifications();
|
|
208
|
+
stopClose();
|
|
209
|
+
notifyLifecycle("onClose");
|
|
210
|
+
});
|
|
211
|
+
if (inferCodexAppServerConnectionClass(params.startOptions) === "remote") notifyLifecycle("onRemoteReady");
|
|
212
|
+
return {
|
|
213
|
+
homeKey,
|
|
214
|
+
source
|
|
215
|
+
};
|
|
216
|
+
})();
|
|
217
|
+
state.clients.set(client, observing);
|
|
218
|
+
return observing.then(() => void 0);
|
|
219
|
+
}
|
|
220
|
+
/** Acknowledged resume settings may differ from the response thread's persisted metadata. */
|
|
221
|
+
function publishCodexCatalogResume(client, response, sanitize) {
|
|
222
|
+
try {
|
|
223
|
+
return publishPreparedResume(client, {
|
|
224
|
+
thread: projectCodexCatalogNativeThread(response.thread, sanitize),
|
|
225
|
+
cwd: boundedCatalogString(response.cwd, MAX_CWD_LENGTH),
|
|
226
|
+
modelProvider: boundedCatalogString(response.modelProvider, 500, "truncate")
|
|
227
|
+
});
|
|
228
|
+
} catch (error) {
|
|
229
|
+
embeddedAgentLog.warn("Codex catalog resume publication failed", { error });
|
|
230
|
+
return Promise.resolve();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async function publishPreparedResume(client, response) {
|
|
234
|
+
try {
|
|
235
|
+
const state = getCatalogEvents();
|
|
236
|
+
const binding = await state.clients.get(client);
|
|
237
|
+
if (!binding || binding.source.closed) return;
|
|
238
|
+
await Promise.all(Array.from(state.listeners.get(binding.homeKey) ?? [], async (listener) => {
|
|
239
|
+
try {
|
|
240
|
+
await listener.onResume?.(response, binding.source);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
embeddedAgentLog.warn("Codex catalog resume observer failed", { error });
|
|
243
|
+
}
|
|
244
|
+
}));
|
|
245
|
+
} catch (error) {
|
|
246
|
+
embeddedAgentLog.warn("Codex catalog resume publication failed", { error });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
export { codexCatalogHomeId as a, readCodexSessionMeta as c, subscribeCodexCatalogEvents as i, observeCodexCatalogClient as n, codexCatalogHomeIdFromCanonicalPath as o, publishCodexCatalogResume as r, isOpenClawManagedCodexThread as s, codexCatalogResidentHomeKey as t };
|