fix(usage): restore provider auth fallback

This commit is contained in:
Peter Steinberger
2026-04-04 12:08:49 +01:00
parent 6bbccb087a
commit 91bac7cb83
3 changed files with 31 additions and 2 deletions

View File

@@ -68,7 +68,7 @@ describe("session MCP runtime", () => {
{ toolName: "alpha?", description: "question" },
{ toolName: "alpha!", description: "bang" },
];
const catalogB = [...catalogA].reverse();
const catalogB = catalogA.toReversed();
const materializedA = await materializeBundleMcpToolsForRun({
runtime: makeRuntime(catalogA),

View File

@@ -200,6 +200,7 @@ describe("resolveProviderAuths key normalization", () => {
Z_AI_API_KEY: undefined,
MINIMAX_API_KEY: undefined,
MINIMAX_CODE_PLAN_KEY: undefined,
MINIMAX_CODING_API_KEY: undefined,
XIAOMI_API_KEY: undefined,
} satisfies Record<string, string | undefined>;
@@ -416,6 +417,16 @@ describe("resolveProviderAuths key normalization", () => {
});
});
it("accepts MINIMAX_CODING_API_KEY as a coding-plan alias", async () => {
await expectResolvedAuthsFromSuiteHome({
providers: ["minimax"],
env: {
MINIMAX_CODING_API_KEY: "coding-api-key",
},
expected: [{ provider: "minimax", token: "coding-api-key" }],
});
});
it("strips embedded CR/LF from stored auth profiles (token + api_key)", async () => {
await expectResolvedAuthsFromSuiteHome({
providers: ["minimax", "xiaomi"],

View File

@@ -170,7 +170,25 @@ async function resolveProviderUsageAuthFallback(params: {
state: UsageAuthState;
provider: UsageProviderId;
}): Promise<ProviderAuth | null> {
void params;
const oauthToken = await resolveOAuthToken({
state: params.state,
provider: params.provider,
});
if (oauthToken) {
return oauthToken;
}
const apiKey = resolveProviderApiKeyFromConfigAndStore({
state: params.state,
providerIds: [params.provider],
});
if (apiKey) {
return {
provider: params.provider,
token: apiKey,
};
}
return null;
}