feat: support xiaomi/mimo-v2-flash

This commit is contained in:
Vibe Kanban
2026-01-29 00:30:17 +08:00
committed by Peter Steinberger
parent cb4b3f74b5
commit 50d44d0bd9
19 changed files with 334 additions and 1 deletions

View File

@@ -96,6 +96,33 @@ function resolveMinimaxApiKey(): string | undefined {
return undefined;
}
function resolveXiaomiApiKey(): string | undefined {
const envDirect = process.env.XIAOMI_API_KEY?.trim();
if (envDirect) return envDirect;
const envResolved = resolveEnvApiKey("xiaomi");
if (envResolved?.apiKey) return envResolved.apiKey;
const cfg = loadConfig();
const key = getCustomProviderApiKey(cfg, "xiaomi");
if (key) return key;
const store = ensureAuthProfileStore();
const apiProfile = listProfilesForProvider(store, "xiaomi").find((id) => {
const cred = store.profiles[id];
return cred?.type === "api_key" || cred?.type === "token";
});
if (!apiProfile) return undefined;
const cred = store.profiles[apiProfile];
if (cred?.type === "api_key" && cred.key?.trim()) {
return cred.key.trim();
}
if (cred?.type === "token" && cred.token?.trim()) {
return cred.token.trim();
}
return undefined;
}
async function resolveOAuthToken(params: {
provider: UsageProviderId;
agentDir?: string;
@@ -199,6 +226,11 @@ export async function resolveProviderAuths(params: {
if (apiKey) auths.push({ provider, token: apiKey });
continue;
}
if (provider === "xiaomi") {
const apiKey = resolveXiaomiApiKey();
if (apiKey) auths.push({ provider, token: apiKey });
continue;
}
if (!oauthProviders.includes(provider)) continue;
const auth = await resolveOAuthToken({