@openclaw/codex 2026.7.1-beta.6 → 2026.7.2-beta.1
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 +27 -3
- package/dist/app-server-policy-DVcxdse_.js +49 -0
- package/dist/{attempt-notifications-BGsEIIDI.js → attempt-notifications-DEv9h7iC.js} +1 -1
- package/dist/auth-binding-C1czuHPA.js +62 -0
- package/dist/capabilities-42Dfn2TV.js +33 -0
- package/dist/cli-metadata.js +20 -0
- package/dist/{app-server-policy-C968Kgin.js → command-formatters-D6ZlGNmb.js} +8 -51
- package/dist/{command-handlers-Dv-pzAmg.js → command-handlers-Cpl9fUWv.js} +163 -60
- package/dist/{compact-4mVBriKT.js → compact-FnJmiPNA.js} +40 -10
- package/dist/computer-use-DVzr8OP1.js +685 -0
- package/dist/{config-CYEDnLJ2.js → config-c48K5HP9.js} +200 -29
- package/dist/conversation-control-DtQ-E7mr.js +288 -0
- package/dist/doctor-contract-api.js +120 -81
- package/dist/{provider-capabilities-CDnHbmUZ.js → dynamic-tools-BMLoaTeG.js} +5246 -5140
- package/dist/harness.js +55 -15
- package/dist/index.js +1435 -265
- package/dist/{media-understanding-provider-BHOu9-Gg.js → media-understanding-provider-D580L0P8.js} +28 -10
- package/dist/media-understanding-provider.js +1 -1
- package/dist/{models-DDmO1zwd.js → models-DuKzZA6G.js} +1 -1
- package/dist/notification-correlation-DfaCm0mx.js +67 -0
- package/dist/plugin-app-cache-key-BKNjHMEs.js +315 -0
- package/dist/{protocol-2POPqAY4.js → protocol-BMifTfdW.js} +3 -1
- package/dist/provider-catalog.js +66 -27
- package/dist/provider.js +306 -1
- package/dist/{provider-zjPfx5Fs.js → rate-limits-Dhp04Rqo.js} +4 -261
- package/dist/request-DborTWgw.js +111 -0
- package/dist/{run-attempt-FUyOjGCV.js → run-attempt-VPVJoYDP.js} +7897 -7136
- package/dist/runtime-artifact-C2ITXdhM.js +488 -0
- package/dist/{sandbox-guard-DA2TQfZW.js → sandbox-guard-D1Wky__S.js} +10 -1
- package/dist/{session-binding-C1ZXdP-x.js → session-binding-BMfX1OX-.js} +247 -88
- package/dist/session-catalog-7H112Tr_.js +2396 -0
- package/dist/session-cli-B28RhCyp.js +175 -0
- package/dist/{shared-client-4ICy3U6d.js → shared-client-D4mFI9al.js} +1997 -1297
- package/dist/{side-question-N4OaDer2.js → side-question-CgJBz52s.js} +135 -67
- package/dist/{thread-lifecycle-qWE88Dn2.js → thread-lifecycle-BgLXzjvV.js} +747 -317
- package/dist/transcript-mirror-DhLwFIL4.js +485 -0
- package/dist/transport-stdio-DXgGZ7Ib.js +88 -0
- package/dist/{web-search-provider.runtime-BSlriav6.js → web-search-provider.runtime-Bs-eTn5U.js} +3 -3
- package/npm-shrinkwrap.json +56 -30
- package/openclaw.plugin.json +168 -10
- package/package.json +8 -6
- package/dist/command-rpc-eLM_mtC7.js +0 -784
- package/dist/computer-use-Bmaz333N.js +0 -377
- package/dist/notification-correlation-Bo7KB3ks.js +0 -35
- package/dist/plugin-app-cache-key-BrhVdeEf.js +0 -98
- package/dist/request-BcJyl8KL.js +0 -36
package/dist/provider.js
CHANGED
|
@@ -1,2 +1,307 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CODEX_APP_SERVER_AUTH_MARKER, CODEX_BASE_URL, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexModelDefinition, buildCodexProviderConfig } from "./provider-catalog.js";
|
|
2
|
+
import { d as readCodexPluginConfig, f as resolveCodexAppServerRuntimeOptions } from "./config-c48K5HP9.js";
|
|
3
|
+
import { resolveCodexSystemPromptContribution } from "./prompt-overlay.js";
|
|
4
|
+
import { t as buildCodexAppServerUsageSnapshot } from "./rate-limits-Dhp04Rqo.js";
|
|
5
|
+
import { resolvePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
6
|
+
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
7
|
+
import { normalizeModelCompat } from "openclaw/plugin-sdk/provider-model-shared";
|
|
8
|
+
import { createSubsystemLogger } from "openclaw/plugin-sdk/core";
|
|
9
|
+
//#region extensions/codex/provider.ts
|
|
10
|
+
/**
|
|
11
|
+
* Codex provider plugin and live app-server model catalog discovery.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_DISCOVERY_TIMEOUT_MS = 2500;
|
|
14
|
+
const LIVE_DISCOVERY_ENV = "OPENCLAW_CODEX_DISCOVERY_LIVE";
|
|
15
|
+
const MODEL_DISCOVERY_PAGE_LIMIT = 100;
|
|
16
|
+
const CODEX_APP_SERVER_SETUP_METHOD_ID = "app-server";
|
|
17
|
+
const CODEX_DEFAULT_MODEL_REF = `${CODEX_PROVIDER_ID}/${expectDefined(FALLBACK_CODEX_MODELS[0], "Codex fallback model catalog must not be empty").id}`;
|
|
18
|
+
const codexCatalogLog = createSubsystemLogger("codex/catalog");
|
|
19
|
+
const CODEX_REASONING_EFFORTS = [
|
|
20
|
+
"minimal",
|
|
21
|
+
"low",
|
|
22
|
+
"medium",
|
|
23
|
+
"high",
|
|
24
|
+
"xhigh",
|
|
25
|
+
"max",
|
|
26
|
+
"ultra"
|
|
27
|
+
];
|
|
28
|
+
const GPT_56_MAX_REASONING_EFFORTS = [
|
|
29
|
+
"low",
|
|
30
|
+
"medium",
|
|
31
|
+
"high",
|
|
32
|
+
"xhigh",
|
|
33
|
+
"max"
|
|
34
|
+
];
|
|
35
|
+
const GPT_56_ULTRA_REASONING_EFFORTS = [...GPT_56_MAX_REASONING_EFFORTS, "ultra"];
|
|
36
|
+
const GPT_56_ULTRA_MODEL_IDS = /* @__PURE__ */ new Set(["gpt-5.6-sol", "gpt-5.6-terra"]);
|
|
37
|
+
const GPT_56_MAX_MODEL_IDS = /* @__PURE__ */ new Set([...GPT_56_ULTRA_MODEL_IDS, "gpt-5.6-luna"]);
|
|
38
|
+
const GPT_56_DEFAULT_REASONING_EFFORTS = /* @__PURE__ */ new Map([
|
|
39
|
+
["gpt-5.6-sol", "low"],
|
|
40
|
+
["gpt-5.6-terra", "medium"],
|
|
41
|
+
["gpt-5.6-luna", "medium"]
|
|
42
|
+
]);
|
|
43
|
+
const GPT_5_PRO_REASONING_EFFORTS = [
|
|
44
|
+
"medium",
|
|
45
|
+
"high",
|
|
46
|
+
"xhigh"
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Builds the Codex provider plugin, including setup metadata, catalog discovery,
|
|
50
|
+
* dynamic model resolution, and prompt/thinking hooks.
|
|
51
|
+
*/
|
|
52
|
+
function buildCodexProvider(options = {}) {
|
|
53
|
+
return {
|
|
54
|
+
id: CODEX_PROVIDER_ID,
|
|
55
|
+
label: "Codex",
|
|
56
|
+
docsPath: "/providers/models",
|
|
57
|
+
auth: [{
|
|
58
|
+
id: CODEX_APP_SERVER_SETUP_METHOD_ID,
|
|
59
|
+
label: "Codex app-server",
|
|
60
|
+
hint: "Use the Codex app-server runtime and managed model catalog.",
|
|
61
|
+
kind: "custom",
|
|
62
|
+
wizard: {
|
|
63
|
+
choiceId: CODEX_PROVIDER_ID,
|
|
64
|
+
choiceLabel: "Codex app-server",
|
|
65
|
+
choiceHint: "Use the Codex app-server runtime and managed model catalog.",
|
|
66
|
+
assistantPriority: -40,
|
|
67
|
+
groupId: CODEX_PROVIDER_ID,
|
|
68
|
+
groupLabel: "Codex",
|
|
69
|
+
groupHint: "Codex app-server model provider",
|
|
70
|
+
onboardingScopes: ["text-inference"]
|
|
71
|
+
},
|
|
72
|
+
run: async () => ({
|
|
73
|
+
profiles: [],
|
|
74
|
+
defaultModel: CODEX_DEFAULT_MODEL_REF
|
|
75
|
+
})
|
|
76
|
+
}],
|
|
77
|
+
catalog: {
|
|
78
|
+
order: "late",
|
|
79
|
+
run: async (ctx) => {
|
|
80
|
+
const pluginConfig = resolvePluginConfigObject(ctx.config, "codex") ?? (ctx.config ? void 0 : options.pluginConfig);
|
|
81
|
+
return await buildCodexProviderCatalog({
|
|
82
|
+
env: ctx.env,
|
|
83
|
+
pluginConfig,
|
|
84
|
+
listModels: options.listModels
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
staticCatalog: {
|
|
89
|
+
order: "late",
|
|
90
|
+
run: async () => ({ provider: buildCodexProviderConfig(FALLBACK_CODEX_MODELS) })
|
|
91
|
+
},
|
|
92
|
+
resolveDynamicModel: (ctx) => resolveCodexDynamicModel(ctx.modelId),
|
|
93
|
+
resolveSyntheticAuth: () => ({
|
|
94
|
+
apiKey: CODEX_APP_SERVER_AUTH_MARKER,
|
|
95
|
+
source: "codex-app-server",
|
|
96
|
+
mode: "token"
|
|
97
|
+
}),
|
|
98
|
+
fetchUsageSnapshot: async (ctx) => {
|
|
99
|
+
if (ctx.token !== "codex-app-server") return null;
|
|
100
|
+
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: resolvePluginConfigObject(ctx.config, "codex") ?? (ctx.config ? void 0 : options.pluginConfig) });
|
|
101
|
+
const usage = await (options.readUsage ?? requestCodexAppServerUsageLazy)({
|
|
102
|
+
timeoutMs: ctx.timeoutMs,
|
|
103
|
+
agentDir: ctx.agentDir,
|
|
104
|
+
...ctx.authProfileId ? { authProfileId: ctx.authProfileId } : {},
|
|
105
|
+
config: ctx.config,
|
|
106
|
+
startOptions: appServer.start
|
|
107
|
+
});
|
|
108
|
+
const snapshot = buildCodexAppServerUsageSnapshot(usage.rateLimits);
|
|
109
|
+
const accountEmail = ctx.email ?? usage.accountEmail;
|
|
110
|
+
return accountEmail && !snapshot.error ? {
|
|
111
|
+
...snapshot,
|
|
112
|
+
accountEmail
|
|
113
|
+
} : snapshot;
|
|
114
|
+
},
|
|
115
|
+
resolveThinkingProfile: ({ modelId, compat }) => {
|
|
116
|
+
const efforts = resolveCodexThinkingEfforts({
|
|
117
|
+
modelId,
|
|
118
|
+
supportedReasoningEfforts: readCodexSupportedReasoningEfforts(compat)
|
|
119
|
+
});
|
|
120
|
+
const defaultLevel = GPT_56_DEFAULT_REASONING_EFFORTS.get(modelId.trim().toLowerCase());
|
|
121
|
+
return {
|
|
122
|
+
levels: [{ id: "off" }, ...efforts.map((id) => ({ id }))],
|
|
123
|
+
...defaultLevel && efforts.includes(defaultLevel) ? { defaultLevel } : {}
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
resolveSystemPromptContribution: ({ config, modelId }) => resolveCodexSystemPromptContribution({
|
|
127
|
+
config,
|
|
128
|
+
modelId
|
|
129
|
+
}),
|
|
130
|
+
isModernModelRef: ({ modelId }) => isModernCodexModel(modelId)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Builds the Codex model catalog from live app-server discovery, falling back
|
|
135
|
+
* to built-in model records when discovery is disabled or unavailable.
|
|
136
|
+
*/
|
|
137
|
+
async function buildCodexProviderCatalog(options = {}) {
|
|
138
|
+
const config = readCodexPluginConfig(options.pluginConfig);
|
|
139
|
+
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: options.pluginConfig });
|
|
140
|
+
const timeoutMs = normalizeTimeoutMs(config.discovery?.timeoutMs);
|
|
141
|
+
let discovered = [];
|
|
142
|
+
if (config.discovery?.enabled !== false && !shouldSkipLiveDiscovery(options.env)) discovered = await listModelsBestEffort({
|
|
143
|
+
listModels: options.listModels ?? listCodexAppServerModelsLazy,
|
|
144
|
+
timeoutMs,
|
|
145
|
+
startOptions: appServer.start,
|
|
146
|
+
onDiscoveryFailure: options.onDiscoveryFailure
|
|
147
|
+
});
|
|
148
|
+
return { provider: buildCodexProviderConfig(discovered.length > 0 ? discovered : FALLBACK_CODEX_MODELS) };
|
|
149
|
+
}
|
|
150
|
+
function resolveCodexDynamicModel(modelId) {
|
|
151
|
+
const id = modelId.trim();
|
|
152
|
+
if (!id) return;
|
|
153
|
+
const fallbackModel = FALLBACK_CODEX_MODELS.find((model) => model.id === id);
|
|
154
|
+
return normalizeModelCompat({
|
|
155
|
+
...buildCodexModelDefinition({
|
|
156
|
+
id,
|
|
157
|
+
model: id,
|
|
158
|
+
inputModalities: fallbackModel?.inputModalities ?? ["text"],
|
|
159
|
+
supportedReasoningEfforts: fallbackModel?.supportedReasoningEfforts
|
|
160
|
+
}),
|
|
161
|
+
provider: CODEX_PROVIDER_ID,
|
|
162
|
+
baseUrl: CODEX_BASE_URL
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async function listModelsBestEffort(params) {
|
|
166
|
+
try {
|
|
167
|
+
const models = [];
|
|
168
|
+
let cursor;
|
|
169
|
+
do {
|
|
170
|
+
const result = await params.listModels({
|
|
171
|
+
timeoutMs: params.timeoutMs,
|
|
172
|
+
limit: MODEL_DISCOVERY_PAGE_LIMIT,
|
|
173
|
+
cursor,
|
|
174
|
+
startOptions: params.startOptions,
|
|
175
|
+
sharedClient: false
|
|
176
|
+
});
|
|
177
|
+
models.push(...result.models.filter((model) => !model.hidden));
|
|
178
|
+
cursor = result.nextCursor;
|
|
179
|
+
} while (cursor);
|
|
180
|
+
return models;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
params.onDiscoveryFailure?.(error);
|
|
183
|
+
codexCatalogLog.debug("codex model discovery failed; using fallback catalog", { error: error instanceof Error ? error.message : String(error) });
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async function listCodexAppServerModelsLazy(options) {
|
|
188
|
+
const { listCodexAppServerModels } = await import("./models-DuKzZA6G.js").then((n) => n.r);
|
|
189
|
+
return listCodexAppServerModels(options);
|
|
190
|
+
}
|
|
191
|
+
function extractCodexAccountEmail(value) {
|
|
192
|
+
if (!value || typeof value !== "object") return;
|
|
193
|
+
const record = value;
|
|
194
|
+
const account = record.account && typeof record.account === "object" ? record.account : record;
|
|
195
|
+
const email = account.email ?? account.accountEmail;
|
|
196
|
+
return typeof email === "string" && email.trim() ? email.trim() : void 0;
|
|
197
|
+
}
|
|
198
|
+
async function requestCodexAppServerUsageLazy(options) {
|
|
199
|
+
const { withCodexAppServerJsonClient } = await import("./request-DborTWgw.js").then((n) => n.r);
|
|
200
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
201
|
+
return await withCodexAppServerJsonClient({
|
|
202
|
+
timeoutMs: options.timeoutMs,
|
|
203
|
+
timeoutMessage: "codex app-server usage read timed out",
|
|
204
|
+
agentDir: options.agentDir,
|
|
205
|
+
...options.authProfileId ? { authProfileId: options.authProfileId } : {},
|
|
206
|
+
config: options.config,
|
|
207
|
+
startOptions: options.startOptions,
|
|
208
|
+
isolated: true,
|
|
209
|
+
isolatedShutdown: CODEX_USAGE_ISOLATED_SHUTDOWN
|
|
210
|
+
}, async (request) => {
|
|
211
|
+
const rateLimits = await request({ method: "account/rateLimits/read" });
|
|
212
|
+
const accountEmail = await readCodexAccountEmailBestEffort(request, deadline);
|
|
213
|
+
return {
|
|
214
|
+
rateLimits,
|
|
215
|
+
...accountEmail ? { accountEmail } : {}
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const CODEX_USAGE_ISOLATED_SHUTDOWN = {
|
|
220
|
+
forceKillDelayMs: 200,
|
|
221
|
+
exitTimeoutMs: 300
|
|
222
|
+
};
|
|
223
|
+
const CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS = 4e3;
|
|
224
|
+
const CODEX_USAGE_DEADLINE_RESERVE_MS = CODEX_USAGE_ISOLATED_SHUTDOWN.forceKillDelayMs + CODEX_USAGE_ISOLATED_SHUTDOWN.exitTimeoutMs + 250;
|
|
225
|
+
async function readCodexAccountEmailBestEffort(request, deadline) {
|
|
226
|
+
const boundMs = Math.min(CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS, deadline - Date.now() - CODEX_USAGE_DEADLINE_RESERVE_MS);
|
|
227
|
+
if (boundMs <= 0) return;
|
|
228
|
+
const read = request({
|
|
229
|
+
method: "account/read",
|
|
230
|
+
requestParams: {}
|
|
231
|
+
}).then((account) => extractCodexAccountEmail(account), () => void 0);
|
|
232
|
+
let timer;
|
|
233
|
+
const timeout = new Promise((resolve) => {
|
|
234
|
+
timer = setTimeout(() => resolve(void 0), boundMs);
|
|
235
|
+
timer.unref?.();
|
|
236
|
+
});
|
|
237
|
+
try {
|
|
238
|
+
return await Promise.race([read, timeout]);
|
|
239
|
+
} finally {
|
|
240
|
+
if (timer) clearTimeout(timer);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function normalizeTimeoutMs(value) {
|
|
244
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : DEFAULT_DISCOVERY_TIMEOUT_MS;
|
|
245
|
+
}
|
|
246
|
+
function shouldSkipLiveDiscovery(env = process.env) {
|
|
247
|
+
const override = env[LIVE_DISCOVERY_ENV]?.trim().toLowerCase();
|
|
248
|
+
if (override === "0" || override === "false") return true;
|
|
249
|
+
return Boolean(env.VITEST) && override !== "1";
|
|
250
|
+
}
|
|
251
|
+
function isKnownXHighCodexModel(modelId) {
|
|
252
|
+
const lower = modelId.trim().toLowerCase();
|
|
253
|
+
return lower.startsWith("gpt-5") || lower.startsWith("o3") || lower.startsWith("o4") || lower.includes("codex");
|
|
254
|
+
}
|
|
255
|
+
function normalizeCodexReasoningEfforts(efforts) {
|
|
256
|
+
if (!efforts) return [];
|
|
257
|
+
const supported = new Set(efforts.map((effort) => effort.trim().toLowerCase()));
|
|
258
|
+
return CODEX_REASONING_EFFORTS.filter((effort) => supported.has(effort));
|
|
259
|
+
}
|
|
260
|
+
/** Read app-server reasoning metadata from a runtime model compat union. */
|
|
261
|
+
function readCodexSupportedReasoningEfforts(compat) {
|
|
262
|
+
if (!compat || typeof compat !== "object" || Array.isArray(compat)) return;
|
|
263
|
+
const efforts = compat.supportedReasoningEfforts;
|
|
264
|
+
if (!Array.isArray(efforts)) return;
|
|
265
|
+
const strings = efforts.filter((effort) => typeof effort === "string");
|
|
266
|
+
return strings.some((effort) => effort.trim().toLowerCase() === "none") ? void 0 : strings;
|
|
267
|
+
}
|
|
268
|
+
function resolveCodexThinkingEfforts(params) {
|
|
269
|
+
if (params.supportedReasoningEfforts) return normalizeCodexReasoningEfforts(params.supportedReasoningEfforts);
|
|
270
|
+
const fallbackEfforts = resolveCodexFallbackReasoningEfforts(params.modelId);
|
|
271
|
+
if (fallbackEfforts) return [...fallbackEfforts];
|
|
272
|
+
return [
|
|
273
|
+
"minimal",
|
|
274
|
+
"low",
|
|
275
|
+
"medium",
|
|
276
|
+
"high",
|
|
277
|
+
...isKnownXHighCodexModel(params.modelId) ? ["xhigh"] : [],
|
|
278
|
+
...isMaxReasoningCodexModel(params.modelId) ? ["max"] : []
|
|
279
|
+
];
|
|
280
|
+
}
|
|
281
|
+
/** Map a requested effort onto the authoritative app-server model contract. */
|
|
282
|
+
function resolveCodexSupportedReasoningEffort(params) {
|
|
283
|
+
const supported = normalizeCodexReasoningEfforts(params.supportedReasoningEfforts);
|
|
284
|
+
if (supported.includes(params.requested)) return params.requested;
|
|
285
|
+
const fallbackEfforts = params.requested === "ultra" ? supported : supported.filter((effort) => effort !== "ultra");
|
|
286
|
+
const requestedRank = CODEX_REASONING_EFFORTS.indexOf(params.requested);
|
|
287
|
+
return fallbackEfforts.find((effort) => CODEX_REASONING_EFFORTS.indexOf(effort) >= requestedRank) ?? fallbackEfforts.at(-1);
|
|
288
|
+
}
|
|
289
|
+
/** Return the known effort contract when app-server model metadata is unavailable. */
|
|
290
|
+
function resolveCodexFallbackReasoningEfforts(modelId) {
|
|
291
|
+
const normalized = modelId.trim().toLowerCase();
|
|
292
|
+
if (GPT_56_ULTRA_MODEL_IDS.has(normalized)) return GPT_56_ULTRA_REASONING_EFFORTS;
|
|
293
|
+
if (normalized === "gpt-5.6-luna") return GPT_56_MAX_REASONING_EFFORTS;
|
|
294
|
+
if (normalized === "gpt-5.5-pro" || normalized === "gpt-5.4-pro") return GPT_5_PRO_REASONING_EFFORTS;
|
|
295
|
+
}
|
|
296
|
+
/** Return whether the model uses the modern Codex reasoning profile. */
|
|
297
|
+
function isModernCodexModel(modelId) {
|
|
298
|
+
const lower = modelId.trim().toLowerCase();
|
|
299
|
+
return GPT_56_MAX_MODEL_IDS.has(lower) || lower === "gpt-5.5" || lower === "gpt-5.5-pro" || lower === "gpt-5.4" || lower === "gpt-5.4-pro" || lower === "gpt-5.4-mini" || lower === "gpt-5.3-codex-spark";
|
|
300
|
+
}
|
|
301
|
+
/** Return whether Codex accepts the preview GPT-5.6 `max` reasoning effort. */
|
|
302
|
+
function isMaxReasoningCodexModel(modelId) {
|
|
303
|
+
const lower = modelId.trim().toLowerCase();
|
|
304
|
+
return GPT_56_MAX_MODEL_IDS.has(lower);
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
2
307
|
export { buildCodexProvider, buildCodexProviderCatalog, isMaxReasoningCodexModel, isModernCodexModel, readCodexSupportedReasoningEfforts, resolveCodexFallbackReasoningEfforts, resolveCodexSupportedReasoningEffort };
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as isJsonObject } from "./protocol-2POPqAY4.js";
|
|
3
|
-
import { d as resolveCodexAppServerRuntimeOptions, u as readCodexPluginConfig } from "./config-CYEDnLJ2.js";
|
|
4
|
-
import { resolveCodexSystemPromptContribution } from "./prompt-overlay.js";
|
|
5
|
-
import { resolvePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
1
|
+
import { i as isJsonObject } from "./protocol-BMifTfdW.js";
|
|
6
2
|
import { MAX_DATE_TIMESTAMP_MS, resolveExpiresAtMsFromEpochSeconds } from "openclaw/plugin-sdk/number-runtime";
|
|
7
3
|
import { asFiniteNumber, parseStrictFiniteNumber } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
-
import {
|
|
9
|
-
import { createSubsystemLogger } from "openclaw/plugin-sdk/core";
|
|
4
|
+
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
10
5
|
import { PROVIDER_LABELS, clampPercent } from "openclaw/plugin-sdk/provider-usage";
|
|
11
6
|
//#region extensions/codex/src/app-server/rate-limits.ts
|
|
12
7
|
/**
|
|
@@ -78,7 +73,7 @@ function resolveCodexUsageLimitResetAtMs(value, nowMs = Date.now()) {
|
|
|
78
73
|
function summarizeCodexAccountUsage(value, nowMs = Date.now()) {
|
|
79
74
|
const snapshots = collectCodexRateLimitSnapshots(value).filter(snapshotHasDisplayableData);
|
|
80
75
|
if (snapshots.length === 0) return;
|
|
81
|
-
const usageSnapshot = snapshots.find(isCodexLimitSnapshot) ?? snapshots[0];
|
|
76
|
+
const usageSnapshot = snapshots.find(isCodexLimitSnapshot) ?? expectDefined(snapshots[0], "displayable Codex rate-limit snapshot");
|
|
82
77
|
const blockedSnapshots = snapshots.filter(snapshotHasLimitBlock);
|
|
83
78
|
const blockingSnapshot = blockedSnapshots.find(isCodexLimitSnapshot) ?? blockedSnapshots[0] ?? void 0;
|
|
84
79
|
const blockingEntries = blockingSnapshot ? readWindowEntries(blockingSnapshot) : [];
|
|
@@ -400,256 +395,4 @@ function normalizeText(value) {
|
|
|
400
395
|
return text ? text : void 0;
|
|
401
396
|
}
|
|
402
397
|
//#endregion
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Codex provider plugin and live app-server model catalog discovery.
|
|
406
|
-
*/
|
|
407
|
-
const DEFAULT_DISCOVERY_TIMEOUT_MS = 2500;
|
|
408
|
-
const LIVE_DISCOVERY_ENV = "OPENCLAW_CODEX_DISCOVERY_LIVE";
|
|
409
|
-
const MODEL_DISCOVERY_PAGE_LIMIT = 100;
|
|
410
|
-
const CODEX_APP_SERVER_SETUP_METHOD_ID = "app-server";
|
|
411
|
-
const CODEX_DEFAULT_MODEL_REF = `${CODEX_PROVIDER_ID}/${FALLBACK_CODEX_MODELS[0].id}`;
|
|
412
|
-
const codexCatalogLog = createSubsystemLogger("codex/catalog");
|
|
413
|
-
const CODEX_REASONING_EFFORTS = [
|
|
414
|
-
"minimal",
|
|
415
|
-
"low",
|
|
416
|
-
"medium",
|
|
417
|
-
"high",
|
|
418
|
-
"xhigh",
|
|
419
|
-
"max",
|
|
420
|
-
"ultra"
|
|
421
|
-
];
|
|
422
|
-
const GPT_56_MAX_REASONING_EFFORTS = [
|
|
423
|
-
"low",
|
|
424
|
-
"medium",
|
|
425
|
-
"high",
|
|
426
|
-
"xhigh",
|
|
427
|
-
"max"
|
|
428
|
-
];
|
|
429
|
-
const GPT_56_ULTRA_REASONING_EFFORTS = [...GPT_56_MAX_REASONING_EFFORTS, "ultra"];
|
|
430
|
-
const GPT_56_ULTRA_MODEL_IDS = /* @__PURE__ */ new Set(["gpt-5.6-sol", "gpt-5.6-terra"]);
|
|
431
|
-
const GPT_56_MAX_MODEL_IDS = /* @__PURE__ */ new Set([...GPT_56_ULTRA_MODEL_IDS, "gpt-5.6-luna"]);
|
|
432
|
-
const GPT_56_DEFAULT_REASONING_EFFORTS = /* @__PURE__ */ new Map([
|
|
433
|
-
["gpt-5.6-sol", "low"],
|
|
434
|
-
["gpt-5.6-terra", "medium"],
|
|
435
|
-
["gpt-5.6-luna", "medium"]
|
|
436
|
-
]);
|
|
437
|
-
const GPT_5_PRO_REASONING_EFFORTS = [
|
|
438
|
-
"medium",
|
|
439
|
-
"high",
|
|
440
|
-
"xhigh"
|
|
441
|
-
];
|
|
442
|
-
/**
|
|
443
|
-
* Builds the Codex provider plugin, including setup metadata, catalog discovery,
|
|
444
|
-
* dynamic model resolution, and prompt/thinking hooks.
|
|
445
|
-
*/
|
|
446
|
-
function buildCodexProvider(options = {}) {
|
|
447
|
-
return {
|
|
448
|
-
id: CODEX_PROVIDER_ID,
|
|
449
|
-
label: "Codex",
|
|
450
|
-
docsPath: "/providers/models",
|
|
451
|
-
auth: [{
|
|
452
|
-
id: CODEX_APP_SERVER_SETUP_METHOD_ID,
|
|
453
|
-
label: "Codex app-server",
|
|
454
|
-
hint: "Use the Codex app-server runtime and managed model catalog.",
|
|
455
|
-
kind: "custom",
|
|
456
|
-
wizard: {
|
|
457
|
-
choiceId: CODEX_PROVIDER_ID,
|
|
458
|
-
choiceLabel: "Codex app-server",
|
|
459
|
-
choiceHint: "Use the Codex app-server runtime and managed model catalog.",
|
|
460
|
-
assistantPriority: -40,
|
|
461
|
-
groupId: CODEX_PROVIDER_ID,
|
|
462
|
-
groupLabel: "Codex",
|
|
463
|
-
groupHint: "Codex app-server model provider",
|
|
464
|
-
onboardingScopes: ["text-inference"]
|
|
465
|
-
},
|
|
466
|
-
run: async () => ({
|
|
467
|
-
profiles: [],
|
|
468
|
-
defaultModel: CODEX_DEFAULT_MODEL_REF
|
|
469
|
-
})
|
|
470
|
-
}],
|
|
471
|
-
catalog: {
|
|
472
|
-
order: "late",
|
|
473
|
-
run: async (ctx) => {
|
|
474
|
-
const pluginConfig = resolvePluginConfigObject(ctx.config, "codex") ?? (ctx.config ? void 0 : options.pluginConfig);
|
|
475
|
-
return await buildCodexProviderCatalog({
|
|
476
|
-
env: ctx.env,
|
|
477
|
-
pluginConfig,
|
|
478
|
-
listModels: options.listModels
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
staticCatalog: {
|
|
483
|
-
order: "late",
|
|
484
|
-
run: async () => ({ provider: buildCodexProviderConfig(FALLBACK_CODEX_MODELS) })
|
|
485
|
-
},
|
|
486
|
-
resolveDynamicModel: (ctx) => resolveCodexDynamicModel(ctx.modelId),
|
|
487
|
-
resolveSyntheticAuth: () => ({
|
|
488
|
-
apiKey: CODEX_APP_SERVER_AUTH_MARKER,
|
|
489
|
-
source: "codex-app-server",
|
|
490
|
-
mode: "token"
|
|
491
|
-
}),
|
|
492
|
-
fetchUsageSnapshot: async (ctx) => {
|
|
493
|
-
if (ctx.token !== "codex-app-server") return null;
|
|
494
|
-
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: resolvePluginConfigObject(ctx.config, "codex") ?? (ctx.config ? void 0 : options.pluginConfig) });
|
|
495
|
-
return buildCodexAppServerUsageSnapshot(await (options.readRateLimits ?? requestCodexAppServerRateLimitsLazy)({
|
|
496
|
-
timeoutMs: ctx.timeoutMs,
|
|
497
|
-
agentDir: ctx.agentDir,
|
|
498
|
-
...ctx.authProfileId ? { authProfileId: ctx.authProfileId } : {},
|
|
499
|
-
config: ctx.config,
|
|
500
|
-
startOptions: appServer.start
|
|
501
|
-
}));
|
|
502
|
-
},
|
|
503
|
-
resolveThinkingProfile: ({ modelId, compat }) => {
|
|
504
|
-
const efforts = resolveCodexThinkingEfforts({
|
|
505
|
-
modelId,
|
|
506
|
-
supportedReasoningEfforts: readCodexSupportedReasoningEfforts(compat)
|
|
507
|
-
});
|
|
508
|
-
const defaultLevel = GPT_56_DEFAULT_REASONING_EFFORTS.get(modelId.trim().toLowerCase());
|
|
509
|
-
return {
|
|
510
|
-
levels: [{ id: "off" }, ...efforts.map((id) => ({ id }))],
|
|
511
|
-
...defaultLevel && efforts.includes(defaultLevel) ? { defaultLevel } : {}
|
|
512
|
-
};
|
|
513
|
-
},
|
|
514
|
-
resolveSystemPromptContribution: ({ config, modelId }) => resolveCodexSystemPromptContribution({
|
|
515
|
-
config,
|
|
516
|
-
modelId
|
|
517
|
-
}),
|
|
518
|
-
isModernModelRef: ({ modelId }) => isModernCodexModel(modelId)
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Builds the Codex model catalog from live app-server discovery, falling back
|
|
523
|
-
* to built-in model records when discovery is disabled or unavailable.
|
|
524
|
-
*/
|
|
525
|
-
async function buildCodexProviderCatalog(options = {}) {
|
|
526
|
-
const config = readCodexPluginConfig(options.pluginConfig);
|
|
527
|
-
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: options.pluginConfig });
|
|
528
|
-
const timeoutMs = normalizeTimeoutMs(config.discovery?.timeoutMs);
|
|
529
|
-
let discovered = [];
|
|
530
|
-
if (config.discovery?.enabled !== false && !shouldSkipLiveDiscovery(options.env)) discovered = await listModelsBestEffort({
|
|
531
|
-
listModels: options.listModels ?? listCodexAppServerModelsLazy,
|
|
532
|
-
timeoutMs,
|
|
533
|
-
startOptions: appServer.start,
|
|
534
|
-
onDiscoveryFailure: options.onDiscoveryFailure
|
|
535
|
-
});
|
|
536
|
-
return { provider: buildCodexProviderConfig(discovered.length > 0 ? discovered : FALLBACK_CODEX_MODELS) };
|
|
537
|
-
}
|
|
538
|
-
function resolveCodexDynamicModel(modelId) {
|
|
539
|
-
const id = modelId.trim();
|
|
540
|
-
if (!id) return;
|
|
541
|
-
const fallbackModel = FALLBACK_CODEX_MODELS.find((model) => model.id === id);
|
|
542
|
-
return normalizeModelCompat({
|
|
543
|
-
...buildCodexModelDefinition({
|
|
544
|
-
id,
|
|
545
|
-
model: id,
|
|
546
|
-
inputModalities: fallbackModel?.inputModalities ?? ["text"],
|
|
547
|
-
supportedReasoningEfforts: fallbackModel?.supportedReasoningEfforts
|
|
548
|
-
}),
|
|
549
|
-
provider: CODEX_PROVIDER_ID,
|
|
550
|
-
baseUrl: CODEX_BASE_URL
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
async function listModelsBestEffort(params) {
|
|
554
|
-
try {
|
|
555
|
-
const models = [];
|
|
556
|
-
let cursor;
|
|
557
|
-
do {
|
|
558
|
-
const result = await params.listModels({
|
|
559
|
-
timeoutMs: params.timeoutMs,
|
|
560
|
-
limit: MODEL_DISCOVERY_PAGE_LIMIT,
|
|
561
|
-
cursor,
|
|
562
|
-
startOptions: params.startOptions,
|
|
563
|
-
sharedClient: false
|
|
564
|
-
});
|
|
565
|
-
models.push(...result.models.filter((model) => !model.hidden));
|
|
566
|
-
cursor = result.nextCursor;
|
|
567
|
-
} while (cursor);
|
|
568
|
-
return models;
|
|
569
|
-
} catch (error) {
|
|
570
|
-
params.onDiscoveryFailure?.(error);
|
|
571
|
-
codexCatalogLog.debug("codex model discovery failed; using fallback catalog", { error: error instanceof Error ? error.message : String(error) });
|
|
572
|
-
return [];
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
async function listCodexAppServerModelsLazy(options) {
|
|
576
|
-
const { listCodexAppServerModels } = await import("./models-DDmO1zwd.js").then((n) => n.r);
|
|
577
|
-
return listCodexAppServerModels(options);
|
|
578
|
-
}
|
|
579
|
-
async function requestCodexAppServerRateLimitsLazy(options) {
|
|
580
|
-
const { requestCodexAppServerJson } = await import("./request-BcJyl8KL.js").then((n) => n.n);
|
|
581
|
-
return await requestCodexAppServerJson({
|
|
582
|
-
method: "account/rateLimits/read",
|
|
583
|
-
timeoutMs: options.timeoutMs,
|
|
584
|
-
agentDir: options.agentDir,
|
|
585
|
-
...options.authProfileId ? { authProfileId: options.authProfileId } : {},
|
|
586
|
-
config: options.config,
|
|
587
|
-
startOptions: options.startOptions,
|
|
588
|
-
isolated: true
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
function normalizeTimeoutMs(value) {
|
|
592
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : DEFAULT_DISCOVERY_TIMEOUT_MS;
|
|
593
|
-
}
|
|
594
|
-
function shouldSkipLiveDiscovery(env = process.env) {
|
|
595
|
-
const override = env[LIVE_DISCOVERY_ENV]?.trim().toLowerCase();
|
|
596
|
-
if (override === "0" || override === "false") return true;
|
|
597
|
-
return Boolean(env.VITEST) && override !== "1";
|
|
598
|
-
}
|
|
599
|
-
function isKnownXHighCodexModel(modelId) {
|
|
600
|
-
const lower = modelId.trim().toLowerCase();
|
|
601
|
-
return lower.startsWith("gpt-5") || lower.startsWith("o3") || lower.startsWith("o4") || lower.includes("codex");
|
|
602
|
-
}
|
|
603
|
-
function normalizeCodexReasoningEfforts(efforts) {
|
|
604
|
-
if (!efforts) return [];
|
|
605
|
-
const supported = new Set(efforts.map((effort) => effort.trim().toLowerCase()));
|
|
606
|
-
return CODEX_REASONING_EFFORTS.filter((effort) => supported.has(effort));
|
|
607
|
-
}
|
|
608
|
-
/** Read app-server reasoning metadata from a runtime model compat union. */
|
|
609
|
-
function readCodexSupportedReasoningEfforts(compat) {
|
|
610
|
-
if (!compat || typeof compat !== "object" || Array.isArray(compat)) return;
|
|
611
|
-
const efforts = compat.supportedReasoningEfforts;
|
|
612
|
-
if (!Array.isArray(efforts)) return;
|
|
613
|
-
const strings = efforts.filter((effort) => typeof effort === "string");
|
|
614
|
-
return strings.some((effort) => effort.trim().toLowerCase() === "none") ? void 0 : strings;
|
|
615
|
-
}
|
|
616
|
-
function resolveCodexThinkingEfforts(params) {
|
|
617
|
-
if (params.supportedReasoningEfforts) return normalizeCodexReasoningEfforts(params.supportedReasoningEfforts);
|
|
618
|
-
const fallbackEfforts = resolveCodexFallbackReasoningEfforts(params.modelId);
|
|
619
|
-
if (fallbackEfforts) return [...fallbackEfforts];
|
|
620
|
-
return [
|
|
621
|
-
"minimal",
|
|
622
|
-
"low",
|
|
623
|
-
"medium",
|
|
624
|
-
"high",
|
|
625
|
-
...isKnownXHighCodexModel(params.modelId) ? ["xhigh"] : [],
|
|
626
|
-
...isMaxReasoningCodexModel(params.modelId) ? ["max"] : []
|
|
627
|
-
];
|
|
628
|
-
}
|
|
629
|
-
/** Map a requested effort onto the authoritative app-server model contract. */
|
|
630
|
-
function resolveCodexSupportedReasoningEffort(params) {
|
|
631
|
-
const supported = normalizeCodexReasoningEfforts(params.supportedReasoningEfforts);
|
|
632
|
-
if (supported.includes(params.requested)) return params.requested;
|
|
633
|
-
const fallbackEfforts = params.requested === "ultra" ? supported : supported.filter((effort) => effort !== "ultra");
|
|
634
|
-
const requestedRank = CODEX_REASONING_EFFORTS.indexOf(params.requested);
|
|
635
|
-
return fallbackEfforts.find((effort) => CODEX_REASONING_EFFORTS.indexOf(effort) >= requestedRank) ?? fallbackEfforts.at(-1);
|
|
636
|
-
}
|
|
637
|
-
/** Return the known effort contract when app-server model metadata is unavailable. */
|
|
638
|
-
function resolveCodexFallbackReasoningEfforts(modelId) {
|
|
639
|
-
const normalized = modelId.trim().toLowerCase();
|
|
640
|
-
if (GPT_56_ULTRA_MODEL_IDS.has(normalized)) return GPT_56_ULTRA_REASONING_EFFORTS;
|
|
641
|
-
if (normalized === "gpt-5.6-luna") return GPT_56_MAX_REASONING_EFFORTS;
|
|
642
|
-
if (normalized === "gpt-5.5-pro" || normalized === "gpt-5.4-pro") return GPT_5_PRO_REASONING_EFFORTS;
|
|
643
|
-
}
|
|
644
|
-
/** Return whether the model uses the modern Codex reasoning profile. */
|
|
645
|
-
function isModernCodexModel(modelId) {
|
|
646
|
-
const lower = modelId.trim().toLowerCase();
|
|
647
|
-
return GPT_56_MAX_MODEL_IDS.has(lower) || lower === "gpt-5.5" || lower === "gpt-5.5-pro" || lower === "gpt-5.4" || lower === "gpt-5.4-pro" || lower === "gpt-5.4-mini" || lower === "gpt-5.3-codex-spark";
|
|
648
|
-
}
|
|
649
|
-
/** Return whether Codex accepts the preview GPT-5.6 `max` reasoning effort. */
|
|
650
|
-
function isMaxReasoningCodexModel(modelId) {
|
|
651
|
-
const lower = modelId.trim().toLowerCase();
|
|
652
|
-
return GPT_56_MAX_MODEL_IDS.has(lower);
|
|
653
|
-
}
|
|
654
|
-
//#endregion
|
|
655
|
-
export { readCodexSupportedReasoningEfforts as a, formatCodexUsageLimitErrorMessage as c, shouldRefreshCodexRateLimitsForUsageLimitMessage as d, summarizeCodexAccountRateLimits as f, isModernCodexModel as i, hasCodexRateLimitSnapshots as l, summarizeCodexRateLimits as m, buildCodexProviderCatalog as n, resolveCodexFallbackReasoningEfforts as o, summarizeCodexAccountUsage as p, isMaxReasoningCodexModel as r, resolveCodexSupportedReasoningEffort as s, buildCodexProvider as t, resolveCodexUsageLimitResetAtMs as u };
|
|
398
|
+
export { shouldRefreshCodexRateLimitsForUsageLimitMessage as a, summarizeCodexRateLimits as c, resolveCodexUsageLimitResetAtMs as i, formatCodexUsageLimitErrorMessage as n, summarizeCodexAccountRateLimits as o, hasCodexRateLimitSnapshots as r, summarizeCodexAccountUsage as s, buildCodexAppServerUsageSnapshot as t };
|