diff --git a/src/agents/auth-profiles/profiles.ts b/src/agents/auth-profiles/profiles.ts index 6afb10853e9..edd51fdb534 100644 --- a/src/agents/auth-profiles/profiles.ts +++ b/src/agents/auth-profiles/profiles.ts @@ -1,5 +1,5 @@ import { normalizeSecretInput } from "../../utils/normalize-secret-input.js"; -import { normalizeProviderId } from "../model-selection.js"; +import { normalizeProviderId, normalizeProviderIdForAuth } from "../model-selection.js"; import { ensureAuthProfileStore, saveAuthProfileStore, @@ -79,9 +79,9 @@ export async function upsertAuthProfileWithLock(params: { } export function listProfilesForProvider(store: AuthProfileStore, provider: string): string[] { - const providerKey = normalizeProviderId(provider); + const providerKey = normalizeProviderIdForAuth(provider); return Object.entries(store.profiles) - .filter(([, cred]) => normalizeProviderId(cred.provider) === providerKey) + .filter(([, cred]) => normalizeProviderIdForAuth(cred.provider) === providerKey) .map(([id]) => id); } diff --git a/src/agents/model-selection.test.ts b/src/agents/model-selection.test.ts index c28954bd9fb..49937912310 100644 --- a/src/agents/model-selection.test.ts +++ b/src/agents/model-selection.test.ts @@ -8,6 +8,7 @@ import { buildModelAliasIndex, normalizeModelSelection, normalizeProviderId, + normalizeProviderIdForAuth, modelKey, resolveAllowedModelRef, resolveConfiguredModelRef, @@ -64,6 +65,14 @@ describe("model-selection", () => { }); }); + describe("normalizeProviderIdForAuth", () => { + it("maps coding-plan variants to base provider for auth lookup", () => { + expect(normalizeProviderIdForAuth("volcengine-plan")).toBe("volcengine"); + expect(normalizeProviderIdForAuth("byteplus-plan")).toBe("byteplus"); + expect(normalizeProviderIdForAuth("openai")).toBe("openai"); + }); + }); + describe("parseModelRef", () => { it("should parse full model refs", () => { expect(parseModelRef("anthropic/claude-3-5-sonnet", "openai")).toEqual({ diff --git a/src/agents/model-selection.ts b/src/agents/model-selection.ts index cfb53fc1371..1489c9ee962 100644 --- a/src/agents/model-selection.ts +++ b/src/agents/model-selection.ts @@ -61,6 +61,18 @@ export function normalizeProviderId(provider: string): string { return normalized; } +/** Normalize provider ID for auth lookup. Coding-plan variants share auth with base. */ +export function normalizeProviderIdForAuth(provider: string): string { + const normalized = normalizeProviderId(provider); + if (normalized === "volcengine-plan") { + return "volcengine"; + } + if (normalized === "byteplus-plan") { + return "byteplus"; + } + return normalized; +} + export function findNormalizedProviderValue( entries: Record | undefined, provider: string,