@@ -1302,6 +1302,8 @@ export interface ExtensionAPI {
|
||||
|
||||
/** Configuration for registering a provider via pi.registerProvider(). */
|
||||
export interface ProviderConfig {
|
||||
/** Display name for the provider in UI. */
|
||||
name?: string;
|
||||
/** Base URL for the API endpoint. Required when defining models. */
|
||||
baseUrl?: string;
|
||||
/** API key or environment variable name. Required when defining models (unless oauth provided). */
|
||||
|
||||
@@ -26,6 +26,7 @@ import { Compile } from "typebox/compile";
|
||||
import type { TLocalizedValidationError } from "typebox/error";
|
||||
import { getAgentDir } from "../config.js";
|
||||
import type { AuthStatus, AuthStorage } from "./auth-storage.js";
|
||||
import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "./provider-display-names.js";
|
||||
import {
|
||||
clearConfigValueCache,
|
||||
resolveConfigValueOrThrow,
|
||||
@@ -177,6 +178,7 @@ const ModelOverrideSchema = Type.Object({
|
||||
type ModelOverride = Static<typeof ModelOverrideSchema>;
|
||||
|
||||
const ProviderConfigSchema = Type.Object({
|
||||
name: Type.Optional(Type.String({ minLength: 1 })),
|
||||
baseUrl: Type.Optional(Type.String({ minLength: 1 })),
|
||||
apiKey: Type.Optional(Type.String({ minLength: 1 })),
|
||||
api: Type.Optional(Type.String({ minLength: 1 })),
|
||||
@@ -727,6 +729,22 @@ export class ModelRegistry {
|
||||
return { configured: true, source: "models_json_key" };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get display name for a provider.
|
||||
*/
|
||||
getProviderDisplayName(provider: string): string {
|
||||
const registeredProvider = this.registeredProviders.get(provider);
|
||||
const oauthProvider = this.authStorage.getOAuthProviders().find((p) => p.id === provider);
|
||||
|
||||
return (
|
||||
registeredProvider?.name ??
|
||||
registeredProvider?.oauth?.name ??
|
||||
oauthProvider?.name ??
|
||||
BUILT_IN_PROVIDER_DISPLAY_NAMES[provider] ??
|
||||
provider
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get API key for a provider.
|
||||
*/
|
||||
@@ -893,6 +911,7 @@ export class ModelRegistry {
|
||||
* Input type for registerProvider API.
|
||||
*/
|
||||
export interface ProviderConfigInput {
|
||||
name?: string;
|
||||
baseUrl?: string;
|
||||
apiKey?: string;
|
||||
api?: Api;
|
||||
|
||||
24
packages/coding-agent/src/core/provider-display-names.ts
Normal file
24
packages/coding-agent/src/core/provider-display-names.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export const BUILT_IN_PROVIDER_DISPLAY_NAMES: Record<string, string> = {
|
||||
anthropic: "Anthropic",
|
||||
"amazon-bedrock": "Amazon Bedrock",
|
||||
"azure-openai-responses": "Azure OpenAI Responses",
|
||||
cerebras: "Cerebras",
|
||||
"cloudflare-workers-ai": "Cloudflare Workers AI",
|
||||
deepseek: "DeepSeek",
|
||||
fireworks: "Fireworks",
|
||||
google: "Google Gemini",
|
||||
"google-vertex": "Google Vertex AI",
|
||||
groq: "Groq",
|
||||
huggingface: "Hugging Face",
|
||||
"kimi-coding": "Kimi For Coding",
|
||||
mistral: "Mistral",
|
||||
minimax: "MiniMax",
|
||||
"minimax-cn": "MiniMax (China)",
|
||||
opencode: "OpenCode Zen",
|
||||
"opencode-go": "OpenCode Go",
|
||||
openai: "OpenAI",
|
||||
openrouter: "OpenRouter",
|
||||
"vercel-ai-gateway": "Vercel AI Gateway",
|
||||
xai: "xAI",
|
||||
zai: "ZAI",
|
||||
};
|
||||
Reference in New Issue
Block a user