refactor: expose model catalog aliases in plugin lookup · openclaw/openclaw@6e893ea
shakkernerd
·
2026-04-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -125,6 +125,11 @@ describe("loadPluginLookUpTable", () => {
|
125 | 125 | origin: "bundled", |
126 | 126 | providers: ["openai", "openai-codex"], |
127 | 127 | modelCatalog: { |
| 128 | +aliases: { |
| 129 | +"azure-openai-responses": { |
| 130 | +provider: "openai", |
| 131 | +}, |
| 132 | +}, |
128 | 133 | providers: { |
129 | 134 | openai: { |
130 | 135 | models: [{ id: "gpt-test" }], |
@@ -180,6 +185,7 @@ describe("loadPluginLookUpTable", () => {
|
180 | 185 | expect(table.owners.channelConfigs.get("telegram")).toEqual(["telegram"]); |
181 | 186 | expect(table.owners.providers.get("openai")).toEqual(["openai"]); |
182 | 187 | expect(table.owners.modelCatalogProviders.get("openai")).toEqual(["openai"]); |
| 188 | +expect(table.owners.modelCatalogProviders.get("azure-openai-responses")).toEqual(["openai"]); |
183 | 189 | expect(table.owners.cliBackends.get("codex-cli")).toEqual(["openai"]); |
184 | 190 | expect(table.owners.setupProviders.get("openai")).toEqual(["openai"]); |
185 | 191 | expect(table.owners.commandAliases.get("telegram-send")).toEqual(["telegram"]); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -120,6 +120,9 @@ export function buildPluginMetadataOwnerMaps(
|
120 | 120 | for (const providerId of Object.keys(plugin.modelCatalog?.providers ?? {})) { |
121 | 121 | appendOwner(modelCatalogProviders, providerId, plugin.id); |
122 | 122 | } |
| 123 | +for (const providerId of Object.keys(plugin.modelCatalog?.aliases ?? {})) { |
| 124 | +appendOwner(modelCatalogProviders, providerId, plugin.id); |
| 125 | +} |
123 | 126 | for (const cliBackendId of plugin.cliBackends) { |
124 | 127 | appendOwner(cliBackends, cliBackendId, plugin.id); |
125 | 128 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -173,7 +173,10 @@ function listManifestContributionIds(
|
173 | 173 | case "cliBackends": |
174 | 174 | return [...plugin.cliBackends, ...(plugin.setup?.cliBackends ?? [])]; |
175 | 175 | case "modelCatalogProviders": |
176 | | -return collectObjectKeys(plugin.modelCatalog?.providers); |
| 176 | +return [ |
| 177 | + ...collectObjectKeys(plugin.modelCatalog?.providers), |
| 178 | + ...collectObjectKeys(plugin.modelCatalog?.aliases), |
| 179 | +]; |
177 | 180 | case "commandAliases": |
178 | 181 | return plugin.commandAliases?.map((alias) => alias.name) ?? []; |
179 | 182 | case "contracts": |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -80,6 +80,11 @@ function createCandidate(rootDir: string): PluginCandidate {
|
80 | 80 | }, |
81 | 81 | }, |
82 | 82 | modelCatalog: { |
| 83 | +aliases: { |
| 84 | +"demo-alias": { |
| 85 | +provider: "demo", |
| 86 | +}, |
| 87 | +}, |
83 | 88 | providers: { |
84 | 89 | demo: { |
85 | 90 | models: [{ id: "demo-model" }], |
@@ -157,7 +162,18 @@ describe("plugin registry facade", () => {
|
157 | 162 | }); |
158 | 163 | expect(isPluginEnabled({ index, pluginId: "demo" })).toBe(true); |
159 | 164 | expect(listPluginContributionIds({ index, contribution: "providers" })).toEqual(["demo"]); |
| 165 | +expect(listPluginContributionIds({ index, contribution: "modelCatalogProviders" })).toEqual([ |
| 166 | +"demo", |
| 167 | +"demo-alias", |
| 168 | +]); |
160 | 169 | expect(resolveProviderOwners({ index, providerId: "demo" })).toEqual(["demo"]); |
| 170 | +expect( |
| 171 | +resolvePluginContributionOwners({ |
| 172 | + index, |
| 173 | +contribution: "modelCatalogProviders", |
| 174 | +matches: "demo-alias", |
| 175 | +}), |
| 176 | +).toEqual(["demo"]); |
161 | 177 | expect(resolveChannelOwners({ index, channelId: "demo-chat" })).toEqual(["demo"]); |
162 | 178 | expect(resolveCliBackendOwners({ index, cliBackendId: "demo-cli" })).toEqual(["demo"]); |
163 | 179 | expect( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。