mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 04:00:44 +00:00
fix: use static provider catalogs for model listing
This commit is contained in:
@@ -15,6 +15,10 @@ function resolveProviderCatalogHook(provider: ProviderPlugin) {
|
||||
return provider.catalog ?? provider.discovery;
|
||||
}
|
||||
|
||||
function resolveProviderCatalogOrderHook(provider: ProviderPlugin) {
|
||||
return resolveProviderCatalogHook(provider) ?? provider.staticCatalog;
|
||||
}
|
||||
|
||||
export async function resolvePluginDiscoveryProviders(params: {
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
@@ -23,7 +27,7 @@ export async function resolvePluginDiscoveryProviders(params: {
|
||||
}): Promise<ProviderPlugin[]> {
|
||||
return (await loadProviderRuntime())
|
||||
.resolvePluginDiscoveryProvidersRuntime(params)
|
||||
.filter((provider) => resolveProviderCatalogHook(provider));
|
||||
.filter((provider) => resolveProviderCatalogOrderHook(provider));
|
||||
}
|
||||
|
||||
export function groupPluginDiscoveryProvidersByOrder(
|
||||
@@ -37,7 +41,7 @@ export function groupPluginDiscoveryProvidersByOrder(
|
||||
} as Record<ProviderDiscoveryOrder, ProviderPlugin[]>;
|
||||
|
||||
for (const provider of providers) {
|
||||
const order = resolveProviderCatalogHook(provider)?.order ?? "late";
|
||||
const order = resolveProviderCatalogOrderHook(provider)?.order ?? "late";
|
||||
grouped[order].push(provider);
|
||||
}
|
||||
|
||||
@@ -118,3 +122,26 @@ export function runProviderCatalog(params: {
|
||||
resolveProviderAuth: params.resolveProviderAuth,
|
||||
});
|
||||
}
|
||||
|
||||
export function runProviderStaticCatalog(params: {
|
||||
provider: ProviderPlugin;
|
||||
config: OpenClawConfig;
|
||||
agentDir?: string;
|
||||
workspaceDir?: string;
|
||||
env: NodeJS.ProcessEnv;
|
||||
}) {
|
||||
return params.provider.staticCatalog?.run({
|
||||
config: params.config,
|
||||
agentDir: params.agentDir,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
resolveProviderApiKey: () => ({
|
||||
apiKey: undefined,
|
||||
}),
|
||||
resolveProviderAuth: () => ({
|
||||
apiKey: undefined,
|
||||
mode: "none",
|
||||
source: "none",
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1083,6 +1083,14 @@ export type ProviderPlugin = {
|
||||
* Returns provider config/model definitions that merge into models.providers.
|
||||
*/
|
||||
catalog?: ProviderPluginCatalog;
|
||||
/**
|
||||
* Offline provider catalog for display-only surfaces.
|
||||
*
|
||||
* Unlike `catalog`, this hook must not perform network I/O or require real
|
||||
* credentials. Use it for bundled/static rows that can be shown before auth is
|
||||
* configured.
|
||||
*/
|
||||
staticCatalog?: ProviderPluginCatalog;
|
||||
/**
|
||||
* Legacy alias for catalog.
|
||||
* Kept for compatibility with existing provider plugins.
|
||||
|
||||
Reference in New Issue
Block a user