@openclaw/codex 2026.9.2 → 2026.9.4
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/dist/api.js +29 -26
- package/dist/apply-CvT8tW5i.js +356 -0
- package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-DKHzbwt5.js} +38 -214
- package/dist/{attempt-context-CSazkWns.js → attempt-context-D44yeDII.js} +9 -7
- package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications-C9XufG6l.js} +3 -106
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-CWlKVccJ.js} +2 -2
- package/dist/auth-cache-key-7orQae_j.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/binding-connection-D3udKbIE.js +60 -0
- package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-C_Hneydj.js} +28 -125
- package/dist/build-state-BCmg9-5p.js +19 -0
- package/dist/{capabilities-B1mgvpP8.js → capabilities-8vx68WLH.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-B57KWPQx.js +4005 -0
- package/dist/command-dispatch-BpduNGVf.js +21 -0
- package/dist/{command-formatters-DSbGMXA0.js → command-formatters-lxlkNZgU.js} +4 -3
- package/dist/{command-handlers-DOJvGv6-.js → command-handlers-tiL9iWj7.js} +788 -135
- package/dist/command-rpc-CR5EOEZX.js +233 -0
- package/dist/{compact-Y_xBqrHN.js → compact-B_H3AOd7.js} +19 -14
- package/dist/config-oIORaQ5T.js +106 -0
- package/dist/{config-CyapYSji.js → config-options-CXMq1T-C.js} +205 -593
- package/dist/config-runtime-D0zGNIHu.js +11 -0
- package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
- package/dist/conversation-binding-DsB4-O7U.js +900 -0
- package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CtUu1b3m.js} +11 -143
- package/dist/doctor-contract-api.js +5 -5
- package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-CmN5RAip.js} +133 -76
- package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-D78_VmzO.js +101 -0
- package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
- package/dist/event-projector-items-5VhsECCO.js +200 -0
- package/dist/event-projector-usage-BfXmpOec.js +102 -0
- package/dist/{harness-Czh2Sdoc.js → harness-C7rRa7bm.js} +48 -24
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +406 -2915
- package/dist/inference-context-Dr_mzvk4.js +94 -0
- package/dist/inference-proxy-HGXKUIre.js +311 -0
- package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DWVb5U2J.js} +7 -4
- package/dist/launch-args-RXQwn8zV.js +90 -0
- package/dist/{managed-binary-DcpnJF9x.js → managed-binary-D22rNEcR.js} +13 -103
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/migration-provider-api.js +2 -0
- package/dist/{model-catalog-DT5vo6qo.js → model-catalog-Dq2n8f_p.js} +6 -5
- package/dist/{models-CcrgSMQR.js → models-PCKOim-h.js} +3 -3
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/native-subagent-history-DjtPloaU.js +140 -0
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
- package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-fQ7eIXEf.js} +115 -460
- package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
- package/dist/node-cli-sessions-DKaOmVUh.js +527 -0
- package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-Cl2vapEi.js} +55 -24
- package/dist/plan-7uG-Fp36.js +947 -0
- package/dist/plugin-activation-BYQculil.js +138 -0
- package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-d0eKxy7b.js} +4 -52
- package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
- package/dist/plugin-inventory-oL4Na1ZG.js +328 -0
- package/dist/plugin-marketplace-discovery-P-Vndfqq.js +137 -0
- package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-ClPJpRio.js} +17 -9
- package/dist/protocol-5bh1G-H7.js +275 -0
- package/dist/provider-MQ8PVkuE.js +50 -0
- package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-BvCUL69A.js} +2 -2
- package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-CBMmWBr9.js} +1 -1
- package/dist/request-B7hEkBGq.js +212 -0
- package/dist/rpc-error-ttN_QjEm.js +30 -0
- package/dist/{run-attempt-BzthFQSM.js → run-attempt-CvsAAGa0.js} +664 -377
- package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-BJ0rXBZ_.js} +27 -27
- package/dist/sandbox-guard-BxgyoM8M.js +166 -0
- package/dist/{session-binding-4Ki04sW-.js → session-binding-CI8UuilT.js} +30 -48
- package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-Bcvslnhf.js} +12 -26
- package/dist/session-catalog-adoption-tcZi1IfX.js +251 -0
- package/dist/session-catalog-archive-CwKg8Xz2.js +56 -0
- package/dist/session-catalog-ct-AH01I.js +1477 -0
- package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
- package/dist/session-catalog-node-adoption-B1tgDW-m.js +182 -0
- package/dist/session-catalog-node-continue-Ci-DXyJP.js +238 -0
- package/dist/session-catalog-provenance-D-dIfRAH.js +96 -0
- package/dist/{session-cli-BjLhpmS1.js → session-cli-DNN_jhGc.js} +3 -2
- package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
- package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DwyijFI6.js} +5 -50
- package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
- package/dist/session-history-worker-runtime.js +18 -6
- package/dist/session-history.worker-BeK1YOyT.js +378 -0
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Ct0_Hzmg.js} +2 -2
- package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-BBmXA8Eg.js} +4 -7
- package/dist/{session-retirement-DNdmYdFc.js → session-retirement-B2YfbAAT.js} +6 -5
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
- package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-Dn91stmc.js} +8 -7
- package/dist/shared-client-CscigXXL.js +3109 -0
- package/dist/{side-question-B6DWAw1A.js → side-question-BGMJQf4U.js} +65 -170
- package/dist/source-CElXU0Oy.js +518 -0
- package/dist/thread-archive-guard-DfpBr-Sz.js +53 -0
- package/dist/thread-history-page-D0JIp48V.js +361 -0
- package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-DXl1-I6b.js} +187 -639
- package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-BsDRTsyp.js} +13 -15
- package/dist/thread-policy-BuEQfE0g.js +54 -0
- package/dist/thread-resume-DsDOZpFg.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-history-projection-v17wXgdK.js +238 -0
- package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-C5CKgNy6.js} +50 -260
- package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
- package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
- package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-BZerMte_.js} +27 -19
- package/dist/{usage-i9fv5-4m.js → usage-tCk-mg_x.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
- package/openclaw.plugin.json +23 -1
- package/package.json +4 -4
- package/dist/request-C8H22rPi.js +0 -475
- package/dist/session-catalog-B47uwekb.js +0 -3272
- package/dist/session-history.worker-zZVcx0ME.js +0 -267
- package/dist/shared-client-CKhX2kFt.js +0 -7505
- package/dist/thread-policy-CTalhWFy.js +0 -105
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { l as sessionBindingIdentity } from "./session-binding-record-Bcvslnhf.js";
|
|
2
|
+
import { c as CatalogParamsError, f as boundedCatalogString, w as requireBoundThread } from "./thread-history-page-D0JIp48V.js";
|
|
3
|
+
import { n as codexUpstreamBaseline, t as codexLastTerminalTurnId } from "./session-upstream-marker-D15C9NHp.js";
|
|
4
|
+
import { i as reclaimCurrentCodexSessionGeneration } from "./session-binding-CI8UuilT.js";
|
|
5
|
+
import { adoptionSessionKeyRest, continueOperations, runSessionActionExclusive } from "./session-catalog-node-adoption-B1tgDW-m.js";
|
|
6
|
+
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { listSessionCatalogEntries, sessionCatalogAdoptedSessionKey, sessionCatalogAdoptedSourceKey } from "openclaw/plugin-sdk/session-catalog";
|
|
8
|
+
//#region extensions/codex/src/session-catalog-adoption.ts
|
|
9
|
+
const CODEX_SUPERVISION_SESSION_KEY_PREFIX = "harness:codex:supervision:";
|
|
10
|
+
const boundCatalogSessionId = (value) => boundedCatalogString(value, 256);
|
|
11
|
+
function requireIdleThread(thread, action) {
|
|
12
|
+
if (thread.status?.type === "idle" || action === "archive" && thread.status?.type === "notLoaded") return;
|
|
13
|
+
if (thread.status?.type === "active") throw new CatalogParamsError(`Codex session is active in this App Server; wait for it to finish before ${action === "continue" ? "starting a branch" : "archiving"}`);
|
|
14
|
+
throw new CatalogParamsError(action === "archive" ? "Codex session cannot be archived in its current state" : "Codex session cannot start a branch in its current state");
|
|
15
|
+
}
|
|
16
|
+
function adoptionSessionKey(threadId, sourceHomeId) {
|
|
17
|
+
const source = sourceHomeId ? JSON.stringify([sourceHomeId, threadId]) : threadId;
|
|
18
|
+
return sessionCatalogAdoptedSessionKey(CODEX_SUPERVISION_SESSION_KEY_PREFIX, source);
|
|
19
|
+
}
|
|
20
|
+
function isAdoptionSessionKeyForThread(sessionKey, threadId, sourceHomeId) {
|
|
21
|
+
return adoptionSessionKeyRest(sessionKey) === adoptionSessionKey(threadId, sourceHomeId);
|
|
22
|
+
}
|
|
23
|
+
function readCodexSupervisionMarker(entry) {
|
|
24
|
+
const codex = isRecord(entry.pluginExtensions?.codex) ? entry.pluginExtensions.codex : void 0;
|
|
25
|
+
const marker = codex && isRecord(codex.supervision) ? codex.supervision : void 0;
|
|
26
|
+
const sourceThreadId = marker?.sourceThreadId;
|
|
27
|
+
const sourceHomeId = marker?.sourceHomeId;
|
|
28
|
+
if (typeof sourceThreadId !== "string" || !sourceThreadId.trim() || sourceHomeId !== void 0 && (typeof sourceHomeId !== "string" || !sourceHomeId.trim())) return;
|
|
29
|
+
return {
|
|
30
|
+
sourceThreadId: sourceThreadId.trim(),
|
|
31
|
+
...typeof sourceHomeId === "string" ? { sourceHomeId: sourceHomeId.trim() } : {}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async function listAdoptedSessionEntries(params) {
|
|
35
|
+
const adopted = /* @__PURE__ */ new Map();
|
|
36
|
+
for (const { agentId, entry, sessionKey } of listSessionCatalogEntries({
|
|
37
|
+
...params.agentId ? { agentId: params.agentId } : {},
|
|
38
|
+
config: params.config ?? {},
|
|
39
|
+
runtime: params.runtime,
|
|
40
|
+
sessionEntries: params.sessionEntries
|
|
41
|
+
})) {
|
|
42
|
+
const sessionKeyRest = adoptionSessionKeyRest(sessionKey);
|
|
43
|
+
const marker = readCodexSupervisionMarker(entry);
|
|
44
|
+
if (!sessionKeyRest.startsWith(CODEX_SUPERVISION_SESSION_KEY_PREFIX) || !marker || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true) continue;
|
|
45
|
+
const sessionId = entry.sessionId?.trim();
|
|
46
|
+
if (!sessionId) continue;
|
|
47
|
+
const binding = params.bindingStore.read(sessionBindingIdentity({
|
|
48
|
+
sessionId,
|
|
49
|
+
sessionKey,
|
|
50
|
+
config: params.config
|
|
51
|
+
}));
|
|
52
|
+
const sourceThreadId = binding?.supervisionSourceThreadId?.trim();
|
|
53
|
+
const boundThreadId = binding?.threadId.trim();
|
|
54
|
+
if (binding?.connectionScope !== "supervision" || !sourceThreadId || !boundThreadId || sessionKeyRest !== adoptionSessionKey(sourceThreadId, marker.sourceHomeId)) continue;
|
|
55
|
+
const sourceKey = sessionCatalogAdoptedSourceKey(marker.sourceHomeId ?? "gateway:local", sourceThreadId);
|
|
56
|
+
if (adopted.has(sourceKey)) throw new Error(`multiple OpenClaw sessions adopt Codex thread ${sourceThreadId} from the same home`);
|
|
57
|
+
adopted.set(sourceKey, {
|
|
58
|
+
key: sessionKey,
|
|
59
|
+
sessionId,
|
|
60
|
+
agentId,
|
|
61
|
+
boundThreadId
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return adopted;
|
|
65
|
+
}
|
|
66
|
+
async function findAdoptedSessionEntry(params) {
|
|
67
|
+
const adopted = await listAdoptedSessionEntries(params);
|
|
68
|
+
return adopted.get(sessionCatalogAdoptedSourceKey(params.sourceHomeId ?? "gateway:local", params.threadId)) ?? (params.sourceHomeId && params.allowLegacy === true ? adopted.get(sessionCatalogAdoptedSourceKey("gateway:local", params.threadId)) : void 0);
|
|
69
|
+
}
|
|
70
|
+
function matchesPendingAdoptionBinding(binding, expected) {
|
|
71
|
+
const historyCoveredThrough = binding?.historyCoveredThrough;
|
|
72
|
+
return binding?.threadId === expected.sourceThreadId && binding.connectionScope === "supervision" && binding.supervisionSourceThreadId === expected.sourceThreadId && binding.cwd === expected.cwd && binding.conversationSourceTransferComplete === true && binding.preserveNativeModel === true && binding.pendingSupervisionBranch?.sourceThreadId === expected.sourceThreadId && binding.pendingSupervisionBranch.connectionFingerprint === expected.connectionFingerprint && binding.pendingSupervisionBranch.lastTurnId === expected.lastTurnId && (binding.pendingSupervisionBranch.cleanupThreadIds?.length ?? 0) === 0 && typeof historyCoveredThrough === "string" && Number.isFinite(Date.parse(historyCoveredThrough));
|
|
73
|
+
}
|
|
74
|
+
async function ensurePendingAdoptionBinding(params) {
|
|
75
|
+
const pending = {
|
|
76
|
+
sourceThreadId: params.sourceThreadId,
|
|
77
|
+
connectionFingerprint: params.connectionFingerprint,
|
|
78
|
+
...params.lastTurnId ? { lastTurnId: params.lastTurnId } : {}
|
|
79
|
+
};
|
|
80
|
+
const ownsGeneration = await reclaimCurrentCodexSessionGeneration({
|
|
81
|
+
assertCurrent: params.initialization.assertCurrent,
|
|
82
|
+
bindingStore: params.bindingStore,
|
|
83
|
+
identity: params.identity,
|
|
84
|
+
config: params.config
|
|
85
|
+
});
|
|
86
|
+
params.initialization.assertCurrent();
|
|
87
|
+
if (!ownsGeneration) throw new Error(`failed to claim the OpenClaw session generation for ${params.sourceThreadId}`);
|
|
88
|
+
const existing = params.bindingStore.read(params.identity);
|
|
89
|
+
params.initialization.assertCurrent();
|
|
90
|
+
if (existing) {
|
|
91
|
+
if (matchesPendingAdoptionBinding(existing, params)) return;
|
|
92
|
+
throw new Error(`OpenClaw session is already bound to Codex thread ${existing.threadId}`);
|
|
93
|
+
}
|
|
94
|
+
const binding = {
|
|
95
|
+
threadId: params.sourceThreadId,
|
|
96
|
+
connectionScope: "supervision",
|
|
97
|
+
supervisionSourceThreadId: params.sourceThreadId,
|
|
98
|
+
cwd: params.cwd,
|
|
99
|
+
historyCoveredThrough: (/* @__PURE__ */ new Date()).toISOString(),
|
|
100
|
+
conversationSourceTransferComplete: true,
|
|
101
|
+
preserveNativeModel: true,
|
|
102
|
+
pendingSupervisionBranch: pending
|
|
103
|
+
};
|
|
104
|
+
await params.initialization.bind(binding);
|
|
105
|
+
}
|
|
106
|
+
async function createOrReuseAdoptedSession(params) {
|
|
107
|
+
const runtime = params.api.runtime;
|
|
108
|
+
const lookup = {
|
|
109
|
+
...params,
|
|
110
|
+
runtime,
|
|
111
|
+
threadId: params.sourceThread.id
|
|
112
|
+
};
|
|
113
|
+
const existing = await findAdoptedSessionEntry(lookup);
|
|
114
|
+
if (existing) return existing;
|
|
115
|
+
try {
|
|
116
|
+
const spawnedCwd = params.sourceThread.cwd?.trim() || void 0;
|
|
117
|
+
const pendingLastTurnId = codexLastTerminalTurnId(params.sourceThread, boundCatalogSessionId);
|
|
118
|
+
const marker = {
|
|
119
|
+
sourceThreadId: params.sourceThread.id,
|
|
120
|
+
...params.sourceHomeId ? { sourceHomeId: params.sourceHomeId } : {}
|
|
121
|
+
};
|
|
122
|
+
const { createImportedCodexSession } = await import("./session-history-import-DwyijFI6.js");
|
|
123
|
+
const created = await createImportedCodexSession({
|
|
124
|
+
runtime: params.api.runtime,
|
|
125
|
+
bindingStore: params.bindingStore,
|
|
126
|
+
config: params.config,
|
|
127
|
+
key: adoptionSessionKey(params.sourceThread.id, params.sourceHomeId),
|
|
128
|
+
agentId: params.agentId,
|
|
129
|
+
displayName: params.sourceThread.name ?? void 0,
|
|
130
|
+
thread: params.sourceThread,
|
|
131
|
+
throughTurnId: pendingLastTurnId ?? null,
|
|
132
|
+
recoverMatchingInitialEntry: true,
|
|
133
|
+
initialEntry: {
|
|
134
|
+
agentHarnessId: "codex",
|
|
135
|
+
modelSelectionLocked: true,
|
|
136
|
+
pluginExtensions: { codex: { supervision: {
|
|
137
|
+
...marker,
|
|
138
|
+
initializing: true,
|
|
139
|
+
modelLocked: true
|
|
140
|
+
} } }
|
|
141
|
+
},
|
|
142
|
+
afterImport: async (entry, initialization) => {
|
|
143
|
+
const identity = sessionBindingIdentity({
|
|
144
|
+
sessionId: entry.sessionId,
|
|
145
|
+
sessionKey: entry.key,
|
|
146
|
+
config: params.config
|
|
147
|
+
});
|
|
148
|
+
await ensurePendingAdoptionBinding({
|
|
149
|
+
bindingStore: params.bindingStore,
|
|
150
|
+
config: params.config,
|
|
151
|
+
identity,
|
|
152
|
+
initialization,
|
|
153
|
+
sourceThreadId: params.sourceThread.id,
|
|
154
|
+
connectionFingerprint: params.connectionFingerprint,
|
|
155
|
+
cwd: spawnedCwd ?? "",
|
|
156
|
+
...pendingLastTurnId ? { lastTurnId: pendingLastTurnId } : {}
|
|
157
|
+
});
|
|
158
|
+
return { pluginExtensions: { codex: { supervision: {
|
|
159
|
+
...marker,
|
|
160
|
+
modelLocked: true
|
|
161
|
+
} } } };
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
key: created.key,
|
|
166
|
+
sessionId: created.sessionId,
|
|
167
|
+
agentId: created.agentId,
|
|
168
|
+
boundThreadId: params.sourceThread.id
|
|
169
|
+
};
|
|
170
|
+
} catch (error) {
|
|
171
|
+
const raced = await findAdoptedSessionEntry(lookup);
|
|
172
|
+
if (raced) return raced;
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function continueLocalCodexSessionInner(params) {
|
|
177
|
+
await params.control.requireEligibleThread(params.threadId);
|
|
178
|
+
const existing = await findAdoptedSessionEntry({
|
|
179
|
+
...params,
|
|
180
|
+
runtime: params.api.runtime
|
|
181
|
+
});
|
|
182
|
+
if (existing) {
|
|
183
|
+
const boundThreadId = requireBoundThread(existing);
|
|
184
|
+
const boundThread = await params.control.readThread(boundThreadId, true);
|
|
185
|
+
if (boundThread.id !== boundThreadId) throw new Error("Codex app-server returned a different thread than requested");
|
|
186
|
+
const changedError = () => new CatalogParamsError("Codex OpenClaw session changed before it could be opened. Retry.");
|
|
187
|
+
if (!await params.api.runtime.agent.session.patchSessionEntry({
|
|
188
|
+
sessionKey: existing.key,
|
|
189
|
+
readConsistency: "latest",
|
|
190
|
+
preserveActivity: true,
|
|
191
|
+
update: (entry) => {
|
|
192
|
+
if (entry.sessionId?.trim() !== existing.sessionId || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true) throw changedError();
|
|
193
|
+
return {
|
|
194
|
+
archivedAt: void 0,
|
|
195
|
+
archivedBy: void 0,
|
|
196
|
+
archiveReason: void 0
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
})) throw changedError();
|
|
200
|
+
const connectionFingerprint = params.control.connectionFingerprint;
|
|
201
|
+
if (connectionFingerprint) params.onContinued?.({
|
|
202
|
+
connectionFingerprint,
|
|
203
|
+
...codexUpstreamBaseline(boundThread, boundCatalogSessionId)
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
sessionKey: existing.key,
|
|
207
|
+
disposition: "existing"
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const sourceThread = await params.control.readThread(params.threadId, true);
|
|
211
|
+
if (sourceThread.id !== params.threadId) throw new Error("Codex app-server returned a different thread than requested");
|
|
212
|
+
if (sourceThread.status?.type !== "notLoaded") requireIdleThread(sourceThread, "continue");
|
|
213
|
+
const connectionFingerprint = params.control.connectionFingerprint;
|
|
214
|
+
if (!connectionFingerprint) throw new Error("Codex Continue requires a pinned app-server connection");
|
|
215
|
+
const adopted = await createOrReuseAdoptedSession({
|
|
216
|
+
...params,
|
|
217
|
+
sourceThread,
|
|
218
|
+
connectionFingerprint
|
|
219
|
+
});
|
|
220
|
+
const boundThreadId = requireBoundThread(adopted);
|
|
221
|
+
const baselineThread = boundThreadId === sourceThread.id ? sourceThread : await params.control.readThread(boundThreadId, true);
|
|
222
|
+
if (baselineThread.id !== boundThreadId) throw new Error("Codex app-server returned a different thread than requested");
|
|
223
|
+
params.onContinued?.({
|
|
224
|
+
connectionFingerprint,
|
|
225
|
+
...codexUpstreamBaseline(baselineThread, boundCatalogSessionId)
|
|
226
|
+
});
|
|
227
|
+
return {
|
|
228
|
+
sessionKey: adopted.key,
|
|
229
|
+
disposition: "forked"
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** Creates one locked OpenClaw branch whose first harness run forks the Codex source. */
|
|
233
|
+
async function continueLocalCodexSession(params) {
|
|
234
|
+
const sourceKey = sessionCatalogAdoptedSourceKey(params.hostId ?? "gateway:local", params.threadId);
|
|
235
|
+
const operationKey = sessionCatalogAdoptedSourceKey(params.agentId, sourceKey);
|
|
236
|
+
const current = continueOperations.get(operationKey);
|
|
237
|
+
if (current) return await current;
|
|
238
|
+
const run = async (control) => await continueLocalCodexSessionInner({
|
|
239
|
+
...params,
|
|
240
|
+
control
|
|
241
|
+
});
|
|
242
|
+
const operation = runSessionActionExclusive(sourceKey, async () => params.control.withPinnedConnection(run));
|
|
243
|
+
continueOperations.set(operationKey, operation);
|
|
244
|
+
try {
|
|
245
|
+
return await operation;
|
|
246
|
+
} finally {
|
|
247
|
+
if (continueOperations.get(operationKey) === operation) continueOperations.delete(operationKey);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { continueLocalCodexSession, isAdoptionSessionKeyForThread, listAdoptedSessionEntries, requireIdleThread };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { l as sessionBindingIdentity } from "./session-binding-record-Bcvslnhf.js";
|
|
2
|
+
import { t as assertCodexArchiveDescendantsUnowned } from "./thread-archive-guard-DfpBr-Sz.js";
|
|
3
|
+
import { c as CatalogParamsError } from "./thread-history-page-D0JIp48V.js";
|
|
4
|
+
import "./session-binding-CI8UuilT.js";
|
|
5
|
+
import { runSessionActionExclusive } from "./session-catalog-node-adoption-B1tgDW-m.js";
|
|
6
|
+
import { isAdoptionSessionKeyForThread, requireIdleThread } from "./session-catalog-adoption-tcZi1IfX.js";
|
|
7
|
+
import { listAgentIds } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
8
|
+
import { sessionCatalogAdoptedSourceKey } from "openclaw/plugin-sdk/session-catalog";
|
|
9
|
+
//#region extensions/codex/src/session-catalog-archive.ts
|
|
10
|
+
function assertNoPendingSupervisionBranch(params) {
|
|
11
|
+
const adoptedEntries = [params.agentId, ...listAgentIds(params.config).filter((agentId) => agentId !== params.agentId)].flatMap((agentId) => params.runtime.agent.session.listSessionEntries({
|
|
12
|
+
agentId,
|
|
13
|
+
readOnly: true
|
|
14
|
+
})).filter((candidate) => isAdoptionSessionKeyForThread(candidate.sessionKey, params.threadId, params.sourceHomeId) || params.sourceHomeId !== void 0 && params.allowLegacy === true && isAdoptionSessionKeyForThread(candidate.sessionKey, params.threadId));
|
|
15
|
+
for (const adopted of adoptedEntries) {
|
|
16
|
+
if (adopted.entry.initializationPending === true) throw new CatalogParamsError("Codex session cannot be archived while its OpenClaw branch is initializing");
|
|
17
|
+
const sessionId = adopted.entry.sessionId?.trim();
|
|
18
|
+
if (!sessionId) continue;
|
|
19
|
+
const binding = params.bindingStore.read(sessionBindingIdentity({
|
|
20
|
+
sessionId,
|
|
21
|
+
sessionKey: adopted.sessionKey,
|
|
22
|
+
config: params.config
|
|
23
|
+
}));
|
|
24
|
+
if (binding?.connectionScope === "supervision" && binding.supervisionSourceThreadId === params.threadId && binding.pendingSupervisionBranch?.sourceThreadId === params.threadId) throw new CatalogParamsError("Codex session cannot be archived until its OpenClaw branch starts");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Archives one inactive Gateway-local Codex thread after a fresh status read. */
|
|
28
|
+
async function archiveLocalCodexSession(params) {
|
|
29
|
+
return await runSessionActionExclusive(sessionCatalogAdoptedSourceKey(params.hostId ?? "gateway:local", params.threadId), async () => {
|
|
30
|
+
return await params.bindingStore.withThreadArchiveFence(async () => {
|
|
31
|
+
const run = async (control) => {
|
|
32
|
+
assertNoPendingSupervisionBranch(params);
|
|
33
|
+
await control.requireEligibleThread(params.threadId);
|
|
34
|
+
const thread = await control.readThread(params.threadId, false);
|
|
35
|
+
if (thread.id !== params.threadId) throw new Error("Codex app-server returned a different thread than requested");
|
|
36
|
+
requireIdleThread(thread, "archive");
|
|
37
|
+
if (await params.bindingStore.hasOtherThreadOwner(params.threadId)) throw new CatalogParamsError("Codex session cannot be archived while it is attached to an OpenClaw session");
|
|
38
|
+
await assertCodexArchiveDescendantsUnowned({
|
|
39
|
+
bindingStore: params.bindingStore,
|
|
40
|
+
threadId: params.threadId,
|
|
41
|
+
listPage: (request) => control.listDescendantPage(request),
|
|
42
|
+
assertDescendantIdle: async (descendantThreadId) => {
|
|
43
|
+
const descendant = await control.readThread(descendantThreadId, false);
|
|
44
|
+
if (descendant.id !== descendantThreadId) throw new Error("Codex app-server returned a different descendant than requested");
|
|
45
|
+
requireIdleThread(descendant, "archive");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
await control.archiveThread(params.threadId);
|
|
49
|
+
return { archived: true };
|
|
50
|
+
};
|
|
51
|
+
return await params.control.withPinnedConnection(run);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { archiveLocalCodexSession };
|