mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:30:42 +00:00
refactor: expose model catalog aliases in plugin lookup
This commit is contained in:
@@ -125,6 +125,11 @@ describe("loadPluginLookUpTable", () => {
|
||||
origin: "bundled",
|
||||
providers: ["openai", "openai-codex"],
|
||||
modelCatalog: {
|
||||
aliases: {
|
||||
"azure-openai-responses": {
|
||||
provider: "openai",
|
||||
},
|
||||
},
|
||||
providers: {
|
||||
openai: {
|
||||
models: [{ id: "gpt-test" }],
|
||||
@@ -180,6 +185,7 @@ describe("loadPluginLookUpTable", () => {
|
||||
expect(table.owners.channelConfigs.get("telegram")).toEqual(["telegram"]);
|
||||
expect(table.owners.providers.get("openai")).toEqual(["openai"]);
|
||||
expect(table.owners.modelCatalogProviders.get("openai")).toEqual(["openai"]);
|
||||
expect(table.owners.modelCatalogProviders.get("azure-openai-responses")).toEqual(["openai"]);
|
||||
expect(table.owners.cliBackends.get("codex-cli")).toEqual(["openai"]);
|
||||
expect(table.owners.setupProviders.get("openai")).toEqual(["openai"]);
|
||||
expect(table.owners.commandAliases.get("telegram-send")).toEqual(["telegram"]);
|
||||
|
||||
@@ -120,6 +120,9 @@ export function buildPluginMetadataOwnerMaps(
|
||||
for (const providerId of Object.keys(plugin.modelCatalog?.providers ?? {})) {
|
||||
appendOwner(modelCatalogProviders, providerId, plugin.id);
|
||||
}
|
||||
for (const providerId of Object.keys(plugin.modelCatalog?.aliases ?? {})) {
|
||||
appendOwner(modelCatalogProviders, providerId, plugin.id);
|
||||
}
|
||||
for (const cliBackendId of plugin.cliBackends) {
|
||||
appendOwner(cliBackends, cliBackendId, plugin.id);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,10 @@ function listManifestContributionIds(
|
||||
case "cliBackends":
|
||||
return [...plugin.cliBackends, ...(plugin.setup?.cliBackends ?? [])];
|
||||
case "modelCatalogProviders":
|
||||
return collectObjectKeys(plugin.modelCatalog?.providers);
|
||||
return [
|
||||
...collectObjectKeys(plugin.modelCatalog?.providers),
|
||||
...collectObjectKeys(plugin.modelCatalog?.aliases),
|
||||
];
|
||||
case "commandAliases":
|
||||
return plugin.commandAliases?.map((alias) => alias.name) ?? [];
|
||||
case "contracts":
|
||||
|
||||
@@ -80,6 +80,11 @@ function createCandidate(rootDir: string): PluginCandidate {
|
||||
},
|
||||
},
|
||||
modelCatalog: {
|
||||
aliases: {
|
||||
"demo-alias": {
|
||||
provider: "demo",
|
||||
},
|
||||
},
|
||||
providers: {
|
||||
demo: {
|
||||
models: [{ id: "demo-model" }],
|
||||
@@ -157,7 +162,18 @@ describe("plugin registry facade", () => {
|
||||
});
|
||||
expect(isPluginEnabled({ index, pluginId: "demo" })).toBe(true);
|
||||
expect(listPluginContributionIds({ index, contribution: "providers" })).toEqual(["demo"]);
|
||||
expect(listPluginContributionIds({ index, contribution: "modelCatalogProviders" })).toEqual([
|
||||
"demo",
|
||||
"demo-alias",
|
||||
]);
|
||||
expect(resolveProviderOwners({ index, providerId: "demo" })).toEqual(["demo"]);
|
||||
expect(
|
||||
resolvePluginContributionOwners({
|
||||
index,
|
||||
contribution: "modelCatalogProviders",
|
||||
matches: "demo-alias",
|
||||
}),
|
||||
).toEqual(["demo"]);
|
||||
expect(resolveChannelOwners({ index, channelId: "demo-chat" })).toEqual(["demo"]);
|
||||
expect(resolveCliBackendOwners({ index, cliBackendId: "demo-cli" })).toEqual(["demo"]);
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user