mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:00:42 +00:00
feat: use indexed manifests for static model catalog rows
This commit is contained in:
@@ -115,7 +115,7 @@ export async function modelsListCommand(
|
||||
const rows: ModelRow[] = [];
|
||||
|
||||
if (opts.all) {
|
||||
let rowContext = buildRowContext(useProviderCatalogFastPath);
|
||||
let rowContext = buildRowContext(useManifestCatalogFastPath || useProviderCatalogFastPath);
|
||||
const initialAppend = await appendAllModelRowSources({
|
||||
rows,
|
||||
context: rowContext,
|
||||
|
||||
@@ -1,17 +1,33 @@
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import { planManifestModelCatalogRows } from "../../model-catalog/index.js";
|
||||
import {
|
||||
normalizeModelCatalogProviderId,
|
||||
planManifestModelCatalogRows,
|
||||
} from "../../model-catalog/index.js";
|
||||
import type { NormalizedModelCatalogRow } from "../../model-catalog/index.js";
|
||||
import { loadPluginManifestRegistry } from "../../plugins/manifest-registry.js";
|
||||
import { loadPluginManifestRegistryForInstalledIndex } from "../../plugins/manifest-registry-installed.js";
|
||||
import {
|
||||
getPluginRecord,
|
||||
isPluginEnabled,
|
||||
loadPluginRegistrySnapshot,
|
||||
resolvePluginContributionOwners,
|
||||
type PluginRegistrySnapshot,
|
||||
} from "../../plugins/plugin-registry.js";
|
||||
|
||||
export function loadStaticManifestCatalogRowsForList(params: {
|
||||
function loadStaticManifestCatalogRowsForPluginIds(params: {
|
||||
cfg: OpenClawConfig;
|
||||
providerFilter: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
index: PluginRegistrySnapshot;
|
||||
pluginIds: readonly string[];
|
||||
providerFilter: string;
|
||||
}): readonly NormalizedModelCatalogRow[] {
|
||||
const registry = loadPluginManifestRegistry({
|
||||
if (params.pluginIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const registry = loadPluginManifestRegistryForInstalledIndex({
|
||||
index: params.index,
|
||||
config: params.cfg,
|
||||
env: params.env,
|
||||
cache: true,
|
||||
pluginIds: params.pluginIds,
|
||||
});
|
||||
const plan = planManifestModelCatalogRows({
|
||||
registry,
|
||||
@@ -25,3 +41,78 @@ export function loadStaticManifestCatalogRowsForList(params: {
|
||||
}
|
||||
return plan.rows.filter((row) => staticProviders.has(row.provider));
|
||||
}
|
||||
|
||||
function resolveConventionModelCatalogPluginIds(params: {
|
||||
cfg: OpenClawConfig;
|
||||
index: PluginRegistrySnapshot;
|
||||
providerFilter: string;
|
||||
}): readonly string[] {
|
||||
const record = getPluginRecord({
|
||||
index: params.index,
|
||||
pluginId: params.providerFilter,
|
||||
});
|
||||
if (
|
||||
!record ||
|
||||
!isPluginEnabled({
|
||||
index: params.index,
|
||||
pluginId: record.pluginId,
|
||||
config: params.cfg,
|
||||
})
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
return [record.pluginId];
|
||||
}
|
||||
|
||||
function resolveDeclaredModelCatalogPluginIds(params: {
|
||||
cfg: OpenClawConfig;
|
||||
index: PluginRegistrySnapshot;
|
||||
providerFilter: string;
|
||||
}): readonly string[] {
|
||||
return resolvePluginContributionOwners({
|
||||
index: params.index,
|
||||
config: params.cfg,
|
||||
contribution: "modelCatalogProviders",
|
||||
matches: params.providerFilter,
|
||||
});
|
||||
}
|
||||
|
||||
export function loadStaticManifestCatalogRowsForList(params: {
|
||||
cfg: OpenClawConfig;
|
||||
providerFilter: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): readonly NormalizedModelCatalogRow[] {
|
||||
const providerFilter = normalizeModelCatalogProviderId(params.providerFilter);
|
||||
if (!providerFilter) {
|
||||
return [];
|
||||
}
|
||||
const index = loadPluginRegistrySnapshot({
|
||||
config: params.cfg,
|
||||
env: params.env,
|
||||
});
|
||||
const conventionRows = loadStaticManifestCatalogRowsForPluginIds({
|
||||
cfg: params.cfg,
|
||||
env: params.env,
|
||||
index,
|
||||
pluginIds: resolveConventionModelCatalogPluginIds({
|
||||
cfg: params.cfg,
|
||||
index,
|
||||
providerFilter,
|
||||
}),
|
||||
providerFilter,
|
||||
});
|
||||
if (conventionRows.length > 0) {
|
||||
return conventionRows;
|
||||
}
|
||||
return loadStaticManifestCatalogRowsForPluginIds({
|
||||
cfg: params.cfg,
|
||||
env: params.env,
|
||||
index,
|
||||
pluginIds: resolveDeclaredModelCatalogPluginIds({
|
||||
cfg: params.cfg,
|
||||
index,
|
||||
providerFilter,
|
||||
}),
|
||||
providerFilter,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user