mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:30:44 +00:00
fix(codex): refresh live discovery config
This commit is contained in:
@@ -91,6 +91,52 @@ describe("codex provider", () => {
|
||||
expectStaticFallbackCatalog(result);
|
||||
});
|
||||
|
||||
it("uses live plugin config to re-enable discovery after startup disable", async () => {
|
||||
const listModels = vi.fn(async () => ({
|
||||
models: [
|
||||
{
|
||||
id: "gpt-5.4",
|
||||
model: "gpt-5.4",
|
||||
displayName: "gpt-5.4",
|
||||
hidden: false,
|
||||
inputModalities: ["text", "image"],
|
||||
supportedReasoningEfforts: ["low", "medium", "high", "xhigh"],
|
||||
},
|
||||
],
|
||||
}));
|
||||
const provider = buildCodexProvider({
|
||||
pluginConfig: { discovery: { enabled: false } },
|
||||
listModels,
|
||||
});
|
||||
|
||||
const result = await provider.catalog?.run({
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
codex: {
|
||||
config: {
|
||||
discovery: {
|
||||
enabled: true,
|
||||
timeoutMs: 4321,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
} as never);
|
||||
|
||||
expect(listModels).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ limit: 100, timeoutMs: 4321, sharedClient: false }),
|
||||
);
|
||||
expect(result).toMatchObject({
|
||||
provider: {
|
||||
models: [{ id: "gpt-5.4" }],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps a static fallback catalog when live discovery is explicitly disabled by env", async () => {
|
||||
const listModels = vi.fn();
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { resolvePluginConfigObject } from "openclaw/plugin-sdk/config-runtime";
|
||||
import type { ProviderRuntimeModel } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import {
|
||||
normalizeModelCompat,
|
||||
@@ -52,12 +53,15 @@ export function buildCodexProvider(options: BuildCodexProviderOptions = {}): Pro
|
||||
auth: [],
|
||||
catalog: {
|
||||
order: "late",
|
||||
run: async (ctx) =>
|
||||
buildCodexProviderCatalog({
|
||||
run: async (ctx) => {
|
||||
const runtimePluginConfig = resolvePluginConfigObject(ctx.config, CODEX_PROVIDER_ID);
|
||||
const pluginConfig = runtimePluginConfig ?? (ctx.config ? undefined : options.pluginConfig);
|
||||
return await buildCodexProviderCatalog({
|
||||
env: ctx.env,
|
||||
pluginConfig: options.pluginConfig,
|
||||
pluginConfig,
|
||||
listModels: options.listModels,
|
||||
}),
|
||||
});
|
||||
},
|
||||
},
|
||||
staticCatalog: {
|
||||
order: "late",
|
||||
|
||||
Reference in New Issue
Block a user