feat(usage): add minimax usage snapshot

This commit is contained in:
Peter Steinberger
2026-01-14 09:57:32 +00:00
parent 40fb59e5f7
commit 18b4575e4d
8 changed files with 316 additions and 1 deletions

View File

@@ -74,6 +74,35 @@ function resolveZaiApiKey(): string | undefined {
}
}
function resolveMinimaxApiKey(): string | undefined {
const envDirect =
process.env.MINIMAX_CODE_PLAN_KEY?.trim() ||
process.env.MINIMAX_API_KEY?.trim();
if (envDirect) return envDirect;
const envResolved = resolveEnvApiKey("minimax");
if (envResolved?.apiKey) return envResolved.apiKey;
const cfg = loadConfig();
const key = getCustomProviderApiKey(cfg, "minimax");
if (key) return key;
const store = ensureAuthProfileStore();
const apiProfile = listProfilesForProvider(store, "minimax").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;
@@ -182,6 +211,11 @@ export async function resolveProviderAuths(params: {
if (apiKey) auths.push({ provider, token: apiKey });
continue;
}
if (provider === "minimax") {
const apiKey = resolveMinimaxApiKey();
if (apiKey) auths.push({ provider, token: apiKey });
continue;
}
if (!oauthProviders.includes(provider)) continue;
const auth = await resolveOAuthToken({