fix: normalize provider catalog template lookup

This commit is contained in:
Tak Hoffman
2026-03-27 21:01:13 -05:00
parent 269f461b2e
commit fe295b15a5
2 changed files with 15 additions and 1 deletions

View File

@@ -49,6 +49,19 @@ describe("buildSingleProviderApiKeyCatalog", () => {
expect(result).toEqual({ provider: "Demo Provider", id: "demo-model" });
});
it("matches provider templates across canonical provider aliases", () => {
const result = findCatalogTemplate({
entries: [
{ provider: "z.ai", id: "glm-4.7" },
{ provider: "other", id: "fallback" },
],
providerId: "z-ai",
templateIds: ["GLM-4.7"],
});
expect(result).toEqual({ provider: "z.ai", id: "glm-4.7" });
});
it("returns null when api key is missing", async () => {
const result = await buildSingleProviderApiKeyCatalog({
ctx: createCatalogContext({}),

View File

@@ -1,3 +1,4 @@
import { normalizeProviderId } from "../agents/provider-id.js";
import type { ModelProviderConfig } from "../config/types.js";
import type { ProviderCatalogContext, ProviderCatalogResult } from "./types.js";
@@ -10,7 +11,7 @@ export function findCatalogTemplate(params: {
.map((templateId) =>
params.entries.find(
(entry) =>
entry.provider.toLowerCase() === params.providerId.toLowerCase() &&
normalizeProviderId(entry.provider) === normalizeProviderId(params.providerId) &&
entry.id.toLowerCase() === templateId.toLowerCase(),
),
)