refactor: expose model catalog aliases in plugin lookup

This commit is contained in:
Shakker
2026-04-27 16:24:28 +01:00
parent 03c4c319e3
commit 6e893eaee4
4 changed files with 29 additions and 1 deletions

View File

@@ -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"]);

View File

@@ -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);
}

View File

@@ -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":

View File

@@ -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(