refactor: harden kilocode auth ordering and dedupe provider wiring

This commit is contained in:
Peter Steinberger
2026-02-23 23:37:07 +00:00
parent f52a0228ca
commit e6484cb65f
8 changed files with 131 additions and 79 deletions

View File

@@ -1,5 +1,6 @@
import type { AuthProfileStore } from "../agents/auth-profiles.js";
import { AUTH_CHOICE_LEGACY_ALIASES_FOR_CLI } from "./auth-choice-legacy.js";
import { ONBOARD_PROVIDER_AUTH_FLAGS } from "./onboard-provider-auth-flags.js";
import type { AuthChoice, AuthChoiceGroupId } from "./onboard-types.js";
export type { AuthChoiceGroupId };
@@ -186,6 +187,31 @@ const AUTH_CHOICE_GROUP_DEFS: {
},
];
const PROVIDER_AUTH_CHOICE_OPTION_HINTS: Partial<Record<AuthChoice, string>> = {
"litellm-api-key": "Unified gateway for 100+ LLM providers",
"cloudflare-ai-gateway-api-key": "Account ID + Gateway ID + API key",
"venice-api-key": "Privacy-focused inference (uncensored models)",
"together-api-key": "Access to Llama, DeepSeek, Qwen, and more open models",
"huggingface-api-key": "Inference Providers — OpenAI-compatible chat",
};
const PROVIDER_AUTH_CHOICE_OPTION_LABELS: Partial<Record<AuthChoice, string>> = {
"moonshot-api-key": "Kimi API key (.ai)",
"moonshot-api-key-cn": "Kimi API key (.cn)",
"kimi-code-api-key": "Kimi Code API key (subscription)",
"cloudflare-ai-gateway-api-key": "Cloudflare AI Gateway",
};
function buildProviderAuthChoiceOptions(): AuthChoiceOption[] {
return ONBOARD_PROVIDER_AUTH_FLAGS.map((flag) => ({
value: flag.authChoice,
label: PROVIDER_AUTH_CHOICE_OPTION_LABELS[flag.authChoice] ?? flag.description,
...(PROVIDER_AUTH_CHOICE_OPTION_HINTS[flag.authChoice]
? { hint: PROVIDER_AUTH_CHOICE_OPTION_HINTS[flag.authChoice] }
: {}),
}));
}
const BASE_AUTH_CHOICE_OPTIONS: ReadonlyArray<AuthChoiceOption> = [
{
value: "token",
@@ -202,59 +228,11 @@ const BASE_AUTH_CHOICE_OPTIONS: ReadonlyArray<AuthChoiceOption> = [
label: "vLLM (custom URL + model)",
hint: "Local/self-hosted OpenAI-compatible server",
},
{ value: "openai-api-key", label: "OpenAI API key" },
{ value: "mistral-api-key", label: "Mistral API key" },
{ value: "xai-api-key", label: "xAI (Grok) API key" },
{ value: "volcengine-api-key", label: "Volcano Engine API key" },
{ value: "byteplus-api-key", label: "BytePlus API key" },
{
value: "qianfan-api-key",
label: "Qianfan API key",
},
{ value: "openrouter-api-key", label: "OpenRouter API key" },
{ value: "kilocode-api-key", label: "Kilo Gateway API key" },
{
value: "litellm-api-key",
label: "LiteLLM API key",
hint: "Unified gateway for 100+ LLM providers",
},
{
value: "ai-gateway-api-key",
label: "Vercel AI Gateway API key",
},
{
value: "cloudflare-ai-gateway-api-key",
label: "Cloudflare AI Gateway",
hint: "Account ID + Gateway ID + API key",
},
{
value: "moonshot-api-key",
label: "Kimi API key (.ai)",
},
...buildProviderAuthChoiceOptions(),
{
value: "moonshot-api-key-cn",
label: "Kimi API key (.cn)",
},
{
value: "kimi-code-api-key",
label: "Kimi Code API key (subscription)",
},
{ value: "synthetic-api-key", label: "Synthetic API key" },
{
value: "venice-api-key",
label: "Venice AI API key",
hint: "Privacy-focused inference (uncensored models)",
},
{
value: "together-api-key",
label: "Together AI API key",
hint: "Access to Llama, DeepSeek, Qwen, and more open models",
},
{
value: "huggingface-api-key",
label: "Hugging Face API key (HF token)",
hint: "Inference Providers — OpenAI-compatible chat",
},
{
value: "github-copilot",
label: "GitHub Copilot (GitHub device login)",