@openclaw/codex 2026.5.14-beta.2 → 2026.5.16-beta.2
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/dist/{client-CoctX13d.js → client-CA7amCZ8.js} +1 -1
- package/dist/{client-factory-Be6RD28K.js → client-factory-DwzPofwS.js} +1 -1
- package/dist/{command-formatters-DRJaVHhN.js → command-formatters-BRW7_Nu7.js} +10 -2
- package/dist/{command-handlers-CXxykxjq.js → command-handlers-D6UDzndR.js} +7 -7
- package/dist/compact-96QPqIAu.js +329 -0
- package/dist/{computer-use-DsJxRRtm.js → computer-use-BX02ojP4.js} +2 -2
- package/dist/{config-0rd3LnKg.js → config-3ATInASk.js} +7 -1
- package/dist/harness.js +9 -6
- package/dist/index.js +7 -7
- package/dist/media-understanding-provider.js +3 -3
- package/dist/{models-GCYf5s8J.js → models-BHS-8DS_.js} +1 -1
- package/dist/{node-cli-sessions-CiexDHeV.js → node-cli-sessions-BLDFnUEF.js} +5 -5
- package/dist/{plugin-activation-aQOmRQwA.js → plugin-activation-BDU4e-NA.js} +1 -1
- package/dist/provider.js +2 -2
- package/dist/{request-CKYiRqsN.js → request-Czoa60Nt.js} +3 -3
- package/dist/{run-attempt-DG9NQab2.js → run-attempt-B6gN6CrO.js} +364 -77
- package/dist/{session-binding-CMTXuyoz.js → session-binding-DbdVqMzW.js} +14 -2
- package/dist/{shared-client-BwUqd3lh.js → shared-client-CnbrvEfV.js} +2 -2
- package/dist/{side-question-CVWPOkY-.js → side-question-CFcVH8fj.js} +7 -7
- package/dist/test-api.js +2 -2
- package/dist/{thread-lifecycle-DrbViNpf.js → thread-lifecycle-BMK4m_PL.js} +159 -34
- package/dist/{vision-tools-CzTdigBu.js → vision-tools-Cm_YicZb.js} +107 -7
- package/openclaw.plugin.json +1 -1
- package/package.json +4 -4
- package/dist/compact-DWa8cylR.js +0 -256
package/dist/compact-DWa8cylR.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { s as resolveCodexAppServerRuntimeOptions } from "./config-0rd3LnKg.js";
|
|
2
|
-
import { t as isJsonObject } from "./protocol-C9UWI98H.js";
|
|
3
|
-
import { i as readCodexAppServerBinding } from "./session-binding-CMTXuyoz.js";
|
|
4
|
-
import { t as defaultCodexAppServerClientFactory } from "./client-factory-Be6RD28K.js";
|
|
5
|
-
import { embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, runHarnessContextEngineMaintenance } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
6
|
-
//#region extensions/codex/src/app-server/compact.ts
|
|
7
|
-
const DEFAULT_CODEX_COMPACTION_WAIT_TIMEOUT_MS = 300 * 1e3;
|
|
8
|
-
async function maybeCompactCodexAppServerSession(params, options = {}) {
|
|
9
|
-
const activeContextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
|
|
10
|
-
if (activeContextEngine?.info.ownsCompaction) {
|
|
11
|
-
let primary;
|
|
12
|
-
let primaryError;
|
|
13
|
-
try {
|
|
14
|
-
primary = await activeContextEngine.compact({
|
|
15
|
-
sessionId: params.sessionId,
|
|
16
|
-
sessionKey: params.sessionKey,
|
|
17
|
-
sessionFile: params.sessionFile,
|
|
18
|
-
tokenBudget: params.contextTokenBudget,
|
|
19
|
-
currentTokenCount: params.currentTokenCount,
|
|
20
|
-
compactionTarget: params.trigger === "manual" ? "threshold" : "budget",
|
|
21
|
-
customInstructions: params.customInstructions,
|
|
22
|
-
force: params.trigger === "manual",
|
|
23
|
-
runtimeContext: params.contextEngineRuntimeContext
|
|
24
|
-
});
|
|
25
|
-
} catch (error) {
|
|
26
|
-
primaryError = formatErrorMessage(error);
|
|
27
|
-
embeddedAgentLog.warn("context engine compaction failed; attempting Codex native compaction", {
|
|
28
|
-
sessionId: params.sessionId,
|
|
29
|
-
engineId: activeContextEngine.info.id,
|
|
30
|
-
error: primaryError
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (primary?.ok && primary.compacted) try {
|
|
34
|
-
await runHarnessContextEngineMaintenance({
|
|
35
|
-
contextEngine: activeContextEngine,
|
|
36
|
-
sessionId: params.sessionId,
|
|
37
|
-
sessionKey: params.sessionKey,
|
|
38
|
-
sessionFile: params.sessionFile,
|
|
39
|
-
reason: "compaction",
|
|
40
|
-
runtimeContext: params.contextEngineRuntimeContext,
|
|
41
|
-
config: params.config
|
|
42
|
-
});
|
|
43
|
-
} catch (error) {
|
|
44
|
-
embeddedAgentLog.warn("context engine compaction maintenance failed; continuing Codex native compaction", {
|
|
45
|
-
sessionId: params.sessionId,
|
|
46
|
-
engineId: activeContextEngine.info.id,
|
|
47
|
-
error: formatErrorMessage(error)
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const nativeResult = await compactCodexNativeThread(params, options);
|
|
51
|
-
if (!primary) return buildContextEngineCompactionFailureResult({
|
|
52
|
-
primaryError,
|
|
53
|
-
nativeResult,
|
|
54
|
-
currentTokenCount: params.currentTokenCount
|
|
55
|
-
});
|
|
56
|
-
return {
|
|
57
|
-
ok: primary.ok,
|
|
58
|
-
compacted: primary.compacted,
|
|
59
|
-
reason: primary.reason,
|
|
60
|
-
result: buildContextEnginePrimaryResult(primary, nativeResult, params.currentTokenCount)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return await compactCodexNativeThread(params, options);
|
|
64
|
-
}
|
|
65
|
-
async function compactCodexNativeThread(params, options = {}) {
|
|
66
|
-
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: options.pluginConfig });
|
|
67
|
-
const binding = await readCodexAppServerBinding(params.sessionFile, { config: params.config });
|
|
68
|
-
if (!binding?.threadId) return {
|
|
69
|
-
ok: false,
|
|
70
|
-
compacted: false,
|
|
71
|
-
reason: "no codex app-server thread binding"
|
|
72
|
-
};
|
|
73
|
-
const requestedAuthProfileId = params.authProfileId?.trim() || void 0;
|
|
74
|
-
if (requestedAuthProfileId && binding.authProfileId && binding.authProfileId !== requestedAuthProfileId) return {
|
|
75
|
-
ok: false,
|
|
76
|
-
compacted: false,
|
|
77
|
-
reason: "auth profile mismatch for session binding"
|
|
78
|
-
};
|
|
79
|
-
const client = await (options.clientFactory ?? defaultCodexAppServerClientFactory)(appServer.start, requestedAuthProfileId ?? binding.authProfileId, params.agentDir, params.config);
|
|
80
|
-
const waiter = createCodexNativeCompactionWaiter(client, binding.threadId);
|
|
81
|
-
let completion;
|
|
82
|
-
try {
|
|
83
|
-
await client.request("thread/compact/start", { threadId: binding.threadId });
|
|
84
|
-
embeddedAgentLog.info("started codex app-server compaction", {
|
|
85
|
-
sessionId: params.sessionId,
|
|
86
|
-
threadId: binding.threadId
|
|
87
|
-
});
|
|
88
|
-
waiter.startTimeout();
|
|
89
|
-
completion = await waiter.promise;
|
|
90
|
-
} catch (error) {
|
|
91
|
-
waiter.cancel();
|
|
92
|
-
return {
|
|
93
|
-
ok: false,
|
|
94
|
-
compacted: false,
|
|
95
|
-
reason: formatCompactionError(error)
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
embeddedAgentLog.info("completed codex app-server compaction", {
|
|
99
|
-
sessionId: params.sessionId,
|
|
100
|
-
threadId: binding.threadId,
|
|
101
|
-
signal: completion.signal,
|
|
102
|
-
turnId: completion.turnId,
|
|
103
|
-
itemId: completion.itemId
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
ok: true,
|
|
107
|
-
compacted: true,
|
|
108
|
-
result: {
|
|
109
|
-
summary: "",
|
|
110
|
-
firstKeptEntryId: "",
|
|
111
|
-
tokensBefore: params.currentTokenCount ?? 0,
|
|
112
|
-
details: {
|
|
113
|
-
backend: "codex-app-server",
|
|
114
|
-
ownsCompaction: params.contextEngine?.info?.ownsCompaction === true,
|
|
115
|
-
threadId: binding.threadId,
|
|
116
|
-
signal: completion.signal,
|
|
117
|
-
turnId: completion.turnId,
|
|
118
|
-
itemId: completion.itemId
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function mergeCompactionDetails(primaryDetails, nativeResult, contextEngineCompaction) {
|
|
124
|
-
const codexNativeCompaction = nativeResult ? nativeResult.ok && nativeResult.compacted ? {
|
|
125
|
-
ok: true,
|
|
126
|
-
compacted: true,
|
|
127
|
-
details: nativeResult.result?.details
|
|
128
|
-
} : {
|
|
129
|
-
ok: false,
|
|
130
|
-
compacted: false,
|
|
131
|
-
reason: nativeResult.reason
|
|
132
|
-
} : void 0;
|
|
133
|
-
const extraDetails = {
|
|
134
|
-
...codexNativeCompaction ? { codexNativeCompaction } : {},
|
|
135
|
-
...contextEngineCompaction ? { contextEngineCompaction } : {}
|
|
136
|
-
};
|
|
137
|
-
if (primaryDetails && typeof primaryDetails === "object" && !Array.isArray(primaryDetails)) return {
|
|
138
|
-
...primaryDetails,
|
|
139
|
-
...extraDetails
|
|
140
|
-
};
|
|
141
|
-
return Object.keys(extraDetails).length > 0 ? extraDetails : primaryDetails;
|
|
142
|
-
}
|
|
143
|
-
function buildContextEnginePrimaryResult(primary, nativeResult, currentTokenCount) {
|
|
144
|
-
if (primary.result) return {
|
|
145
|
-
summary: primary.result.summary ?? "",
|
|
146
|
-
firstKeptEntryId: primary.result.firstKeptEntryId ?? "",
|
|
147
|
-
tokensBefore: primary.result.tokensBefore,
|
|
148
|
-
tokensAfter: primary.result.tokensAfter,
|
|
149
|
-
details: mergeCompactionDetails(primary.result.details, nativeResult)
|
|
150
|
-
};
|
|
151
|
-
const details = mergeCompactionDetails(void 0, nativeResult);
|
|
152
|
-
return details ? {
|
|
153
|
-
summary: "",
|
|
154
|
-
firstKeptEntryId: "",
|
|
155
|
-
tokensBefore: nativeResult?.result?.tokensBefore ?? currentTokenCount ?? 0,
|
|
156
|
-
details
|
|
157
|
-
} : void 0;
|
|
158
|
-
}
|
|
159
|
-
function buildContextEngineCompactionFailureResult(params) {
|
|
160
|
-
const reason = params.primaryError ? `context engine compaction failed: ${params.primaryError}` : "context engine compaction failed";
|
|
161
|
-
return {
|
|
162
|
-
ok: false,
|
|
163
|
-
compacted: params.nativeResult?.compacted ?? false,
|
|
164
|
-
reason,
|
|
165
|
-
result: {
|
|
166
|
-
summary: params.nativeResult?.result?.summary ?? "",
|
|
167
|
-
firstKeptEntryId: params.nativeResult?.result?.firstKeptEntryId ?? "",
|
|
168
|
-
tokensBefore: params.nativeResult?.result?.tokensBefore ?? params.currentTokenCount ?? 0,
|
|
169
|
-
tokensAfter: params.nativeResult?.result?.tokensAfter,
|
|
170
|
-
details: mergeCompactionDetails(params.nativeResult?.result?.details, params.nativeResult, {
|
|
171
|
-
ok: false,
|
|
172
|
-
reason
|
|
173
|
-
})
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function createCodexNativeCompactionWaiter(client, threadId) {
|
|
178
|
-
let settled = false;
|
|
179
|
-
let removeHandler = () => {};
|
|
180
|
-
let timeout;
|
|
181
|
-
let failWaiter = () => {};
|
|
182
|
-
return {
|
|
183
|
-
promise: new Promise((resolve, reject) => {
|
|
184
|
-
const cleanup = () => {
|
|
185
|
-
removeHandler();
|
|
186
|
-
if (timeout) clearTimeout(timeout);
|
|
187
|
-
};
|
|
188
|
-
const complete = (completion) => {
|
|
189
|
-
if (settled) return;
|
|
190
|
-
settled = true;
|
|
191
|
-
cleanup();
|
|
192
|
-
resolve(completion);
|
|
193
|
-
};
|
|
194
|
-
const fail = (error) => {
|
|
195
|
-
if (settled) return;
|
|
196
|
-
settled = true;
|
|
197
|
-
cleanup();
|
|
198
|
-
reject(error);
|
|
199
|
-
};
|
|
200
|
-
failWaiter = fail;
|
|
201
|
-
const handler = (notification) => {
|
|
202
|
-
const completion = readNativeCompactionCompletion(notification, threadId);
|
|
203
|
-
if (completion) complete(completion);
|
|
204
|
-
};
|
|
205
|
-
removeHandler = client.addNotificationHandler(handler);
|
|
206
|
-
}),
|
|
207
|
-
startTimeout() {
|
|
208
|
-
if (settled || timeout) return;
|
|
209
|
-
timeout = setTimeout(() => {
|
|
210
|
-
failWaiter(/* @__PURE__ */ new Error(`timed out waiting for codex app-server compaction for ${threadId}`));
|
|
211
|
-
}, resolveCompactionWaitTimeoutMs());
|
|
212
|
-
timeout.unref?.();
|
|
213
|
-
},
|
|
214
|
-
cancel() {
|
|
215
|
-
if (settled) return;
|
|
216
|
-
settled = true;
|
|
217
|
-
removeHandler();
|
|
218
|
-
if (timeout) clearTimeout(timeout);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function readNativeCompactionCompletion(notification, threadId) {
|
|
223
|
-
const params = notification.params;
|
|
224
|
-
if (!isJsonObject(params) || readString(params, "threadId", "thread_id") !== threadId) return;
|
|
225
|
-
if (notification.method === "thread/compacted") return {
|
|
226
|
-
signal: "thread/compacted",
|
|
227
|
-
turnId: readString(params, "turnId", "turn_id")
|
|
228
|
-
};
|
|
229
|
-
if (notification.method !== "item/completed") return;
|
|
230
|
-
const item = isJsonObject(params.item) ? params.item : void 0;
|
|
231
|
-
if (readString(item, "type") !== "contextCompaction") return;
|
|
232
|
-
return {
|
|
233
|
-
signal: "item/completed",
|
|
234
|
-
turnId: readString(params, "turnId", "turn_id"),
|
|
235
|
-
itemId: readString(item, "id") ?? readString(params, "itemId", "item_id", "id")
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
function resolveCompactionWaitTimeoutMs() {
|
|
239
|
-
const raw = process.env.OPENCLAW_CODEX_COMPACTION_WAIT_TIMEOUT_MS?.trim();
|
|
240
|
-
const parsed = raw ? Number.parseInt(raw, 10) : NaN;
|
|
241
|
-
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
242
|
-
return DEFAULT_CODEX_COMPACTION_WAIT_TIMEOUT_MS;
|
|
243
|
-
}
|
|
244
|
-
function readString(params, ...keys) {
|
|
245
|
-
if (!params) return;
|
|
246
|
-
for (const key of keys) {
|
|
247
|
-
const value = params[key];
|
|
248
|
-
if (typeof value === "string") return value;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function formatCompactionError(error) {
|
|
252
|
-
if (error instanceof Error) return error.message;
|
|
253
|
-
return String(error);
|
|
254
|
-
}
|
|
255
|
-
//#endregion
|
|
256
|
-
export { maybeCompactCodexAppServerSession };
|