Add native Kimi Code OAuth support, allowing users to authenticate with
their Kimi subscription instead of requiring a static API key.
Changes:
- New kimi-code-oauth.ts: token refresh via auth.kimi.com/api/oauth/token
- Auth dispatch: route kimi-code provider to custom refresh (same pattern
as qwen-portal and chutes)
- New 'kimi-code-oauth' onboarding auth choice: imports OAuth credentials
from Kimi CLI (~/.kimi/credentials/kimi-code.json)
- Handles expires_at conversion (Kimi uses seconds, Moltbot uses ms)
Usage:
moltbot onboard --auth-choice kimi-code-oauth
Requires Kimi CLI to be logged in first (kimi login).
🤖 AI-assisted (Claude Opus 4.5 + Kimi K2.5 sub-agent)
Testing: endpoint + refresh verified via curl; compiles clean; lint clean; not yet tested e2e through Moltbot
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import type { AuthChoice } from "./onboard-types.js";
|
|
|
|
const PREFERRED_PROVIDER_BY_AUTH_CHOICE: Partial<Record<AuthChoice, string>> = {
|
|
oauth: "anthropic",
|
|
"setup-token": "anthropic",
|
|
"claude-cli": "anthropic",
|
|
token: "anthropic",
|
|
apiKey: "anthropic",
|
|
"openai-codex": "openai-codex",
|
|
"codex-cli": "openai-codex",
|
|
chutes: "chutes",
|
|
"openai-api-key": "openai",
|
|
"openrouter-api-key": "openrouter",
|
|
"ai-gateway-api-key": "vercel-ai-gateway",
|
|
"moonshot-api-key": "moonshot",
|
|
"kimi-code-api-key": "kimi-code",
|
|
"kimi-code-oauth": "kimi-code",
|
|
"gemini-api-key": "google",
|
|
"google-antigravity": "google-antigravity",
|
|
"google-gemini-cli": "google-gemini-cli",
|
|
"zai-api-key": "zai",
|
|
"synthetic-api-key": "synthetic",
|
|
"venice-api-key": "venice",
|
|
"github-copilot": "github-copilot",
|
|
"copilot-proxy": "copilot-proxy",
|
|
"minimax-cloud": "minimax",
|
|
"minimax-api": "minimax",
|
|
"minimax-api-lightning": "minimax",
|
|
minimax: "lmstudio",
|
|
"opencode-zen": "opencode",
|
|
"qwen-portal": "qwen-portal",
|
|
};
|
|
|
|
export function resolvePreferredProviderForAuthChoice(choice: AuthChoice): string | undefined {
|
|
return PREFERRED_PROVIDER_BY_AUTH_CHOICE[choice];
|
|
}
|