@openclaw/codex 2026.5.10-beta.2 → 2026.5.10-beta.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/dist/{client-CTzy3Y6M.js → client-CpksBQ9l.js} +1 -1
- package/dist/{client-factory-BJL_efz4.js → client-factory-D2P0KD6r.js} +1 -1
- package/dist/{request-DC1Dz3iZ.js → command-formatters-Ttwc_kgX.js} +192 -57
- package/dist/{command-handlers-BLZCm3fD.js → command-handlers-iLF1EI-b.js} +306 -15
- package/dist/{compact-4FVe6NwI.js → compact-BJ1UYEyA.js} +3 -3
- package/dist/{rate-limit-cache-DbZvmrAD.js → computer-use-CVLaKaW3.js} +3 -26
- package/dist/{config-CT01BBDc.js → config-C7xdbzrp.js} +1 -1
- package/dist/{conversation-binding-FqeYliIk.js → conversation-binding-D4XZ-tvV.js} +5 -4
- package/dist/harness.js +8 -4
- package/dist/index.js +11 -6
- package/dist/media-understanding-provider.js +142 -41
- package/dist/{models-H-PTi3W0.js → models-Bg-Qf5s-.js} +2 -2
- package/dist/{plugin-activation-CweAZa7r.js → plugin-activation-C0soz2YD.js} +1 -1
- package/dist/{protocol-validators-CeCyJaWj.js → protocol-validators-CSY0BFBo.js} +4 -1
- package/dist/provider.js +2 -2
- package/dist/rate-limit-cache-dvhq-4pi.js +24 -0
- package/dist/request-BCAfJvSg.js +41 -0
- package/dist/{run-attempt-CefRS5_d.js → run-attempt-DZvighJE.js} +548 -1053
- package/dist/{session-binding-B44KIZM2.js → session-binding-UFKjHkKJ.js} +13 -4
- package/dist/{shared-client-p-TvEiNL.js → shared-client-K13b0L1X.js} +78 -13
- package/dist/side-question-Dh_g53P9.js +548 -0
- package/dist/test-api.js +2 -2
- package/dist/{thread-lifecycle-CGc-O_5d.js → thread-lifecycle-i42nWiSS.js} +18 -11
- package/dist/vision-tools-Bo0P6gwM.js +1008 -0
- package/package.json +7 -6
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS } from "./provider-catalog.js";
|
|
2
|
-
import { s as resolveCodexAppServerRuntimeOptions } from "./config-
|
|
3
|
-
import {
|
|
4
|
-
import { i as readModelListResult } from "./models-
|
|
2
|
+
import { s as resolveCodexAppServerRuntimeOptions } from "./config-C7xdbzrp.js";
|
|
3
|
+
import { i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, o as readCodexErrorNotification, r as assertCodexThreadStartResponse } from "./protocol-validators-CSY0BFBo.js";
|
|
4
|
+
import { i as readModelListResult } from "./models-Bg-Qf5s-.js";
|
|
5
5
|
import { t as isJsonObject } from "./protocol-C9UWI98H.js";
|
|
6
|
+
import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
|
|
6
7
|
//#region extensions/codex/media-understanding-provider.ts
|
|
7
8
|
const DEFAULT_CODEX_IMAGE_MODEL = FALLBACK_CODEX_MODELS.find((model) => model.inputModalities.includes("image"))?.id ?? FALLBACK_CODEX_MODELS[0]?.id;
|
|
8
9
|
const DEFAULT_CODEX_IMAGE_PROMPT = "Describe the image.";
|
|
@@ -28,38 +29,63 @@ function buildCodexMediaUnderstandingProvider(options = {}) {
|
|
|
28
29
|
agentDir: req.agentDir,
|
|
29
30
|
cfg: req.cfg
|
|
30
31
|
}, options),
|
|
31
|
-
describeImages: async (req) => describeCodexImages(req, options)
|
|
32
|
+
describeImages: async (req) => describeCodexImages(req, options),
|
|
33
|
+
extractStructured: async (req) => extractCodexStructured(req, options)
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
36
|
async function describeCodexImages(req, options) {
|
|
35
37
|
const model = req.model.trim();
|
|
36
38
|
if (!model) throw new Error("Codex image understanding requires model id.");
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
return {
|
|
40
|
+
text: await runBoundedCodexVisionTurn({
|
|
41
|
+
model,
|
|
42
|
+
profile: req.profile,
|
|
43
|
+
timeoutMs: req.timeoutMs,
|
|
44
|
+
agentDir: req.agentDir,
|
|
45
|
+
options,
|
|
46
|
+
taskLabel: "image understanding",
|
|
47
|
+
developerInstructions: "You are OpenClaw's bounded image-understanding worker. Describe only the provided image content. Do not call tools, edit files, or ask follow-up questions.",
|
|
48
|
+
input: [{
|
|
49
|
+
type: "text",
|
|
50
|
+
text: buildCodexImagePrompt(req),
|
|
51
|
+
text_elements: []
|
|
52
|
+
}, ...req.images.map((image) => ({
|
|
53
|
+
type: "image",
|
|
54
|
+
url: `data:${image.mime ?? "image/png"};base64,${image.buffer.toString("base64")}`
|
|
55
|
+
}))],
|
|
56
|
+
requiredModalities: ["text", "image"]
|
|
57
|
+
}),
|
|
58
|
+
model
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function runBoundedCodexVisionTurn(params) {
|
|
62
|
+
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.options.pluginConfig });
|
|
63
|
+
const timeoutMs = Math.max(100, params.timeoutMs);
|
|
64
|
+
const ownsClient = !params.options.clientFactory;
|
|
65
|
+
const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-K13b0L1X.js").then((n) => n.i).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
|
|
41
66
|
startOptions: appServer.start,
|
|
42
67
|
timeoutMs,
|
|
43
|
-
authProfileId:
|
|
68
|
+
authProfileId: params.profile
|
|
44
69
|
}));
|
|
45
70
|
const abortController = new AbortController();
|
|
46
71
|
const timeout = setTimeout(() => abortController.abort("timeout"), timeoutMs);
|
|
47
72
|
timeout.unref?.();
|
|
48
73
|
try {
|
|
49
|
-
await
|
|
74
|
+
await assertCodexModelSupportsInput({
|
|
50
75
|
client,
|
|
51
|
-
model,
|
|
76
|
+
model: params.model,
|
|
77
|
+
requiredModalities: params.requiredModalities,
|
|
52
78
|
timeoutMs,
|
|
53
79
|
signal: abortController.signal
|
|
54
80
|
});
|
|
55
81
|
const thread = assertCodexThreadStartResponse(await client.request("thread/start", {
|
|
56
|
-
model,
|
|
82
|
+
model: params.model,
|
|
57
83
|
modelProvider: "openai",
|
|
58
|
-
cwd:
|
|
84
|
+
cwd: params.agentDir || process.cwd(),
|
|
59
85
|
approvalPolicy: "on-request",
|
|
60
86
|
sandbox: "read-only",
|
|
61
87
|
serviceName: "OpenClaw",
|
|
62
|
-
developerInstructions:
|
|
88
|
+
developerInstructions: params.developerInstructions,
|
|
63
89
|
dynamicTools: [],
|
|
64
90
|
experimentalRawEvents: true,
|
|
65
91
|
persistExtendedHistory: false,
|
|
@@ -68,35 +94,25 @@ async function describeCodexImages(req, options) {
|
|
|
68
94
|
timeoutMs,
|
|
69
95
|
signal: abortController.signal
|
|
70
96
|
}));
|
|
71
|
-
const collector =
|
|
97
|
+
const collector = createCodexTurnCollector(thread.thread.id, params.taskLabel);
|
|
72
98
|
const cleanup = client.addNotificationHandler(collector.handleNotification);
|
|
73
99
|
const requestCleanup = client.addRequestHandler(denyCodexImageApprovalRequest);
|
|
74
100
|
try {
|
|
75
101
|
const turn = assertCodexTurnStartResponse(await client.request("turn/start", {
|
|
76
102
|
threadId: thread.thread.id,
|
|
77
|
-
input:
|
|
78
|
-
|
|
79
|
-
text: buildCodexImagePrompt(req),
|
|
80
|
-
text_elements: []
|
|
81
|
-
}, ...req.images.map((image) => ({
|
|
82
|
-
type: "image",
|
|
83
|
-
url: `data:${image.mime ?? "image/png"};base64,${image.buffer.toString("base64")}`
|
|
84
|
-
}))],
|
|
85
|
-
cwd: req.agentDir || process.cwd(),
|
|
103
|
+
input: params.input,
|
|
104
|
+
cwd: params.agentDir || process.cwd(),
|
|
86
105
|
approvalPolicy: "on-request",
|
|
87
|
-
model,
|
|
106
|
+
model: params.model,
|
|
88
107
|
effort: "low"
|
|
89
108
|
}, {
|
|
90
109
|
timeoutMs,
|
|
91
110
|
signal: abortController.signal
|
|
92
111
|
}));
|
|
93
|
-
return {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}),
|
|
98
|
-
model
|
|
99
|
-
};
|
|
112
|
+
return await collector.collect(turn.turn, {
|
|
113
|
+
timeoutMs,
|
|
114
|
+
signal: abortController.signal
|
|
115
|
+
});
|
|
100
116
|
} finally {
|
|
101
117
|
requestCleanup();
|
|
102
118
|
cleanup();
|
|
@@ -106,6 +122,29 @@ async function describeCodexImages(req, options) {
|
|
|
106
122
|
if (ownsClient) client.close();
|
|
107
123
|
}
|
|
108
124
|
}
|
|
125
|
+
async function extractCodexStructured(req, options) {
|
|
126
|
+
const model = req.model.trim();
|
|
127
|
+
if (!model) throw new Error("Codex structured extraction requires model id.");
|
|
128
|
+
if (!req.instructions.trim()) throw new Error("Codex structured extraction requires instructions.");
|
|
129
|
+
if (req.input.length === 0) throw new Error("Codex structured extraction requires at least one input.");
|
|
130
|
+
if (!req.input.some((entry) => entry.type === "image")) throw new Error("Codex structured extraction requires at least one image input.");
|
|
131
|
+
return normalizeStructuredExtractionResult({
|
|
132
|
+
text: await runBoundedCodexVisionTurn({
|
|
133
|
+
model,
|
|
134
|
+
profile: req.profile,
|
|
135
|
+
timeoutMs: req.timeoutMs,
|
|
136
|
+
agentDir: req.agentDir,
|
|
137
|
+
options,
|
|
138
|
+
taskLabel: "structured extraction",
|
|
139
|
+
developerInstructions: "You are OpenClaw's bounded structured-extraction worker. Return only the requested extraction. Do not call tools, edit files, ask follow-up questions, or include secrets.",
|
|
140
|
+
input: buildCodexStructuredInput(req),
|
|
141
|
+
requiredModalities: requiredStructuredModalities()
|
|
142
|
+
}),
|
|
143
|
+
model,
|
|
144
|
+
provider: req.provider,
|
|
145
|
+
req
|
|
146
|
+
});
|
|
147
|
+
}
|
|
109
148
|
function denyCodexImageApprovalRequest(request) {
|
|
110
149
|
if (request.method === "item/commandExecution/requestApproval" || request.method === "item/fileChange/requestApproval") return {
|
|
111
150
|
decision: "decline",
|
|
@@ -121,7 +160,7 @@ function denyCodexImageApprovalRequest(request) {
|
|
|
121
160
|
};
|
|
122
161
|
if (request.method === "mcpServer/elicitation/request") return { action: "decline" };
|
|
123
162
|
}
|
|
124
|
-
async function
|
|
163
|
+
async function assertCodexModelSupportsInput(params) {
|
|
125
164
|
const match = readModelListResult(await params.client.request("model/list", {
|
|
126
165
|
limit: 100,
|
|
127
166
|
cursor: null,
|
|
@@ -131,14 +170,75 @@ async function assertCodexModelSupportsImage(params) {
|
|
|
131
170
|
signal: params.signal
|
|
132
171
|
})).models.find((entry) => entry.model === params.model || entry.id === params.model);
|
|
133
172
|
if (!match) throw new Error(`Codex app-server model not found: ${params.model}`);
|
|
134
|
-
if (!match.inputModalities.includes("image")) throw new Error(`Codex app-server model does not support images: ${params.model}`);
|
|
173
|
+
if (params.requiredModalities.includes("image") && !match.inputModalities.includes("image")) throw new Error(`Codex app-server model does not support images: ${params.model}`);
|
|
174
|
+
if (params.requiredModalities.includes("text") && !match.inputModalities.includes("text")) throw new Error(`Codex app-server model does not support text: ${params.model}`);
|
|
135
175
|
}
|
|
136
176
|
function buildCodexImagePrompt(req) {
|
|
137
177
|
const prompt = req.prompt?.trim() || DEFAULT_CODEX_IMAGE_PROMPT;
|
|
138
178
|
if (req.images.length <= 1) return prompt;
|
|
139
179
|
return `${prompt}\n\nAnalyze all ${req.images.length} images together.`;
|
|
140
180
|
}
|
|
141
|
-
function
|
|
181
|
+
function requiredStructuredModalities() {
|
|
182
|
+
return ["text", "image"];
|
|
183
|
+
}
|
|
184
|
+
function buildCodexStructuredInput(req) {
|
|
185
|
+
return [{
|
|
186
|
+
type: "text",
|
|
187
|
+
text: buildStructuredExtractionPrompt(req),
|
|
188
|
+
text_elements: []
|
|
189
|
+
}, ...req.input.map((entry) => {
|
|
190
|
+
if (entry.type === "text") return {
|
|
191
|
+
type: "text",
|
|
192
|
+
text: entry.text,
|
|
193
|
+
text_elements: []
|
|
194
|
+
};
|
|
195
|
+
return {
|
|
196
|
+
type: "image",
|
|
197
|
+
url: `data:${entry.mime ?? "image/png"};base64,${entry.buffer.toString("base64")}`
|
|
198
|
+
};
|
|
199
|
+
})];
|
|
200
|
+
}
|
|
201
|
+
function buildStructuredExtractionPrompt(req) {
|
|
202
|
+
return [
|
|
203
|
+
req.instructions.trim(),
|
|
204
|
+
req.schemaName ? `Schema name: ${req.schemaName}` : void 0,
|
|
205
|
+
req.jsonSchema ? `JSON schema:\n${JSON.stringify(req.jsonSchema)}` : void 0,
|
|
206
|
+
req.jsonMode === false ? "Return the extraction as concise text." : "Return valid JSON only. Do not wrap the JSON in Markdown fences."
|
|
207
|
+
].filter((part) => Boolean(part)).join("\n\n");
|
|
208
|
+
}
|
|
209
|
+
function isJsonSchemaObject(value) {
|
|
210
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
211
|
+
}
|
|
212
|
+
function normalizeStructuredExtractionResult(params) {
|
|
213
|
+
const result = {
|
|
214
|
+
text: params.text,
|
|
215
|
+
model: params.model,
|
|
216
|
+
provider: params.provider,
|
|
217
|
+
contentType: params.req.jsonMode === false ? "text" : "json"
|
|
218
|
+
};
|
|
219
|
+
if (params.req.jsonMode !== false) {
|
|
220
|
+
try {
|
|
221
|
+
result.parsed = JSON.parse(params.text);
|
|
222
|
+
} catch {
|
|
223
|
+
throw new Error("Codex structured extraction returned invalid JSON.");
|
|
224
|
+
}
|
|
225
|
+
if (isJsonSchemaObject(params.req.jsonSchema)) {
|
|
226
|
+
const validation = validateJsonSchemaValue({
|
|
227
|
+
schema: params.req.jsonSchema,
|
|
228
|
+
cacheKey: "codex.media-understanding.extractStructured",
|
|
229
|
+
value: result.parsed,
|
|
230
|
+
cache: false
|
|
231
|
+
});
|
|
232
|
+
if (!validation.ok) {
|
|
233
|
+
const message = validation.errors.map((error) => error.text).join("; ") || "invalid";
|
|
234
|
+
throw new Error(`Codex structured extraction JSON did not match schema: ${message}`);
|
|
235
|
+
}
|
|
236
|
+
result.parsed = validation.value;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
function createCodexTurnCollector(threadId, taskLabel) {
|
|
142
242
|
let turnId;
|
|
143
243
|
let completedTurn;
|
|
144
244
|
let promptError;
|
|
@@ -174,7 +274,7 @@ function createCodexImageTurnCollector(threadId) {
|
|
|
174
274
|
return;
|
|
175
275
|
}
|
|
176
276
|
if (notification.method === "error") {
|
|
177
|
-
promptError = readCodexErrorNotification(notification.params)?.error.message ??
|
|
277
|
+
promptError = readCodexErrorNotification(notification.params)?.error.message ?? `codex app-server ${taskLabel} turn failed`;
|
|
178
278
|
resolveCompletion?.();
|
|
179
279
|
}
|
|
180
280
|
};
|
|
@@ -187,14 +287,15 @@ function createCodexImageTurnCollector(threadId) {
|
|
|
187
287
|
if (!completedTurn && !promptError) await waitForTurnCompletion({
|
|
188
288
|
completion,
|
|
189
289
|
timeoutMs: options.timeoutMs,
|
|
190
|
-
signal: options.signal
|
|
290
|
+
signal: options.signal,
|
|
291
|
+
taskLabel
|
|
191
292
|
});
|
|
192
293
|
if (promptError) throw new Error(promptError);
|
|
193
|
-
if (completedTurn?.status === "failed") throw new Error(completedTurn.error?.message ??
|
|
294
|
+
if (completedTurn?.status === "failed") throw new Error(completedTurn.error?.message ?? `codex app-server ${taskLabel} turn failed`);
|
|
194
295
|
const itemText = collectAssistantTextFromItems(completedTurn?.items);
|
|
195
296
|
const deltaText = assistantItemOrder.map((itemId) => assistantTextByItem.get(itemId)?.trim()).filter((text) => Boolean(text)).join("\n\n").trim();
|
|
196
297
|
const text = (itemText || deltaText).trim();
|
|
197
|
-
if (!text) throw new Error(
|
|
298
|
+
if (!text) throw new Error(`Codex app-server ${taskLabel} turn returned no text.`);
|
|
198
299
|
return text;
|
|
199
300
|
}
|
|
200
301
|
};
|
|
@@ -204,9 +305,9 @@ async function waitForTurnCompletion(params) {
|
|
|
204
305
|
let cleanupAbort;
|
|
205
306
|
try {
|
|
206
307
|
await Promise.race([params.completion, new Promise((_, reject) => {
|
|
207
|
-
timeout = setTimeout(() => reject(/* @__PURE__ */ new Error(
|
|
308
|
+
timeout = setTimeout(() => reject(/* @__PURE__ */ new Error(`codex app-server ${params.taskLabel} turn timed out`)), params.timeoutMs);
|
|
208
309
|
timeout.unref?.();
|
|
209
|
-
const abortListener = () => reject(/* @__PURE__ */ new Error(
|
|
310
|
+
const abortListener = () => reject(/* @__PURE__ */ new Error(`codex app-server ${params.taskLabel} turn aborted`));
|
|
210
311
|
params.signal.addEventListener("abort", abortListener, { once: true });
|
|
211
312
|
cleanupAbort = () => params.signal.removeEventListener("abort", abortListener);
|
|
212
313
|
})]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
|
|
2
|
-
import {
|
|
2
|
+
import { s as readCodexModelListResponse } from "./protocol-validators-CSY0BFBo.js";
|
|
3
3
|
//#region extensions/codex/src/app-server/models.ts
|
|
4
4
|
var models_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
listAllCodexAppServerModels: () => listAllCodexAppServerModels,
|
|
@@ -39,7 +39,7 @@ async function listAllCodexAppServerModels(options = {}) {
|
|
|
39
39
|
async function withCodexAppServerModelClient(options, run) {
|
|
40
40
|
const timeoutMs = options.timeoutMs ?? 2500;
|
|
41
41
|
const useSharedClient = options.sharedClient !== false;
|
|
42
|
-
const { createIsolatedCodexAppServerClient, getSharedCodexAppServerClient } = await import("./shared-client-
|
|
42
|
+
const { createIsolatedCodexAppServerClient, getSharedCodexAppServerClient } = await import("./shared-client-K13b0L1X.js").then((n) => n.i);
|
|
43
43
|
const client = useSharedClient ? await getSharedCodexAppServerClient({
|
|
44
44
|
startOptions: options.startOptions,
|
|
45
45
|
timeoutMs,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as resolveCodexPluginsPolicy, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-
|
|
1
|
+
import { l as resolveCodexPluginsPolicy, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-C7xdbzrp.js";
|
|
2
2
|
import "node:fs/promises";
|
|
3
3
|
import "node:path";
|
|
4
4
|
var CodexAppInventoryCache = class {
|
|
@@ -5900,6 +5900,9 @@ const validateTurnStartResponse = ajv.compile(TurnStartResponse_default);
|
|
|
5900
5900
|
function assertCodexThreadStartResponse(value) {
|
|
5901
5901
|
return assertCodexShape(validateThreadStartResponse, normalizeThreadResponse(value), "thread/start response");
|
|
5902
5902
|
}
|
|
5903
|
+
function assertCodexThreadForkResponse(value) {
|
|
5904
|
+
return assertCodexShape(validateThreadStartResponse, normalizeThreadResponse(value), "thread/fork response");
|
|
5905
|
+
}
|
|
5903
5906
|
function assertCodexThreadResumeResponse(value) {
|
|
5904
5907
|
return assertCodexShape(validateThreadResumeResponse, normalizeThreadResponse(value), "thread/resume response");
|
|
5905
5908
|
}
|
|
@@ -6010,4 +6013,4 @@ function formatAjvErrors(validate) {
|
|
|
6010
6013
|
return ajv.errorsText(errors, { separator: "; " });
|
|
6011
6014
|
}
|
|
6012
6015
|
//#endregion
|
|
6013
|
-
export {
|
|
6016
|
+
export { readCodexDynamicToolCallParams as a, readCodexTurn as c, assertCodexTurnStartResponse as i, readCodexTurnCompletedNotification as l, assertCodexThreadResumeResponse as n, readCodexErrorNotification as o, assertCodexThreadStartResponse as r, readCodexModelListResponse as s, assertCodexThreadForkResponse as t };
|
package/dist/provider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CODEX_APP_SERVER_AUTH_MARKER, CODEX_BASE_URL, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexModelDefinition, buildCodexProviderConfig } from "./provider-catalog.js";
|
|
2
|
-
import { o as readCodexPluginConfig, s as resolveCodexAppServerRuntimeOptions } from "./config-
|
|
2
|
+
import { o as readCodexPluginConfig, s as resolveCodexAppServerRuntimeOptions } from "./config-C7xdbzrp.js";
|
|
3
3
|
import { resolveCodexSystemPromptContribution } from "./prompt-overlay.js";
|
|
4
4
|
import { resolvePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
5
5
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/core";
|
|
@@ -123,7 +123,7 @@ async function listModelsBestEffort(params) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
async function listCodexAppServerModelsLazy(options) {
|
|
126
|
-
const { listCodexAppServerModels } = await import("./models-
|
|
126
|
+
const { listCodexAppServerModels } = await import("./models-Bg-Qf5s-.js").then((n) => n.r);
|
|
127
127
|
return listCodexAppServerModels(options);
|
|
128
128
|
}
|
|
129
129
|
function normalizeTimeoutMs(value) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region extensions/codex/src/app-server/rate-limit-cache.ts
|
|
2
|
+
const DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS = 10 * 6e4;
|
|
3
|
+
const CODEX_RATE_LIMIT_CACHE_STATE = Symbol.for("openclaw.codexRateLimitCacheState");
|
|
4
|
+
function getCodexRateLimitCacheState() {
|
|
5
|
+
const globalState = globalThis;
|
|
6
|
+
globalState[CODEX_RATE_LIMIT_CACHE_STATE] ??= {};
|
|
7
|
+
return globalState[CODEX_RATE_LIMIT_CACHE_STATE];
|
|
8
|
+
}
|
|
9
|
+
function rememberCodexRateLimits(value, nowMs = Date.now()) {
|
|
10
|
+
if (value === void 0) return;
|
|
11
|
+
const state = getCodexRateLimitCacheState();
|
|
12
|
+
state.value = value;
|
|
13
|
+
state.updatedAtMs = nowMs;
|
|
14
|
+
}
|
|
15
|
+
function readRecentCodexRateLimits(options) {
|
|
16
|
+
const state = getCodexRateLimitCacheState();
|
|
17
|
+
if (state.value === void 0 || state.updatedAtMs === void 0) return;
|
|
18
|
+
const nowMs = options?.nowMs ?? Date.now();
|
|
19
|
+
const maxAgeMs = options?.maxAgeMs ?? DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS;
|
|
20
|
+
if (maxAgeMs >= 0 && nowMs - state.updatedAtMs > maxAgeMs) return;
|
|
21
|
+
return state.value;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { rememberCodexRateLimits as n, readRecentCodexRateLimits as t };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as CodexAppServerRpcError } from "./client-CpksBQ9l.js";
|
|
2
|
+
import { a as withTimeout, n as createIsolatedCodexAppServerClient, r as getSharedCodexAppServerClient } from "./shared-client-K13b0L1X.js";
|
|
3
|
+
//#region extensions/codex/src/app-server/capabilities.ts
|
|
4
|
+
const CODEX_CONTROL_METHODS = {
|
|
5
|
+
account: "account/read",
|
|
6
|
+
compact: "thread/compact/start",
|
|
7
|
+
feedback: "feedback/upload",
|
|
8
|
+
listMcpServers: "mcpServerStatus/list",
|
|
9
|
+
listSkills: "skills/list",
|
|
10
|
+
listThreads: "thread/list",
|
|
11
|
+
rateLimits: "account/rateLimits/read",
|
|
12
|
+
resumeThread: "thread/resume",
|
|
13
|
+
review: "review/start"
|
|
14
|
+
};
|
|
15
|
+
function describeControlFailure(error) {
|
|
16
|
+
if (isUnsupportedControlError(error)) return "unsupported by this Codex app-server";
|
|
17
|
+
return error instanceof Error ? error.message : String(error);
|
|
18
|
+
}
|
|
19
|
+
function isUnsupportedControlError(error) {
|
|
20
|
+
return error instanceof CodexAppServerRpcError && error.code === -32601;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region extensions/codex/src/app-server/request.ts
|
|
24
|
+
async function requestCodexAppServerJson(params) {
|
|
25
|
+
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
26
|
+
return await withTimeout((async () => {
|
|
27
|
+
const client = await (params.isolated ? createIsolatedCodexAppServerClient : getSharedCodexAppServerClient)({
|
|
28
|
+
startOptions: params.startOptions,
|
|
29
|
+
timeoutMs,
|
|
30
|
+
authProfileId: params.authProfileId,
|
|
31
|
+
config: params.config
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
return await client.request(params.method, params.requestParams, { timeoutMs });
|
|
35
|
+
} finally {
|
|
36
|
+
if (params.isolated) client.close();
|
|
37
|
+
}
|
|
38
|
+
})(), timeoutMs, `codex app-server ${params.method} timed out`);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { CODEX_CONTROL_METHODS as n, describeControlFailure as r, requestCodexAppServerJson as t };
|