Skip to content

Commit f332589

Browse files
committed
PR feedback
1 parent daf9a91 commit f332589

File tree

1 file changed

+83
-28
lines changed

1 file changed

+83
-28
lines changed

packages/types/src/provider-settings.ts

Lines changed: 83 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import {
2727
internationalZAiModels,
2828
} from "./providers/index.js"
2929

30+
/**
31+
* constants
32+
*/
33+
34+
export const DEFAULT_CONSECUTIVE_MISTAKE_LIMIT = 3
35+
3036
/**
3137
* ProviderName
3238
*/
@@ -74,6 +80,67 @@ export const providerNamesSchema = z.enum(providerNames)
7480

7581
export type ProviderName = z.infer<typeof providerNamesSchema>
7682

83+
/**
84+
* DynamicProvider
85+
*
86+
* Dynamic provider requires external API calls in order to get the model list.
87+
*/
88+
89+
export const dynamicProviders = [
90+
"glama",
91+
"huggingface",
92+
"litellm",
93+
"openrouter",
94+
"requesty",
95+
"unbound",
96+
"deepinfra",
97+
"vercel-ai-gateway",
98+
] as const satisfies readonly ProviderName[]
99+
100+
export type DynamicProvider = (typeof dynamicProviders)[number]
101+
102+
export const isDynamicProvider = (key: string): key is DynamicProvider =>
103+
dynamicProviders.includes(key as DynamicProvider)
104+
105+
/**
106+
* FauxProvider
107+
*
108+
* Faux providers do not make external inference calls and therefore do not have
109+
* model lists.
110+
*/
111+
112+
export const fauxProviders = ["fake-ai", "human-relay"] as const satisfies readonly ProviderName[]
113+
114+
export type FauxProvider = (typeof fauxProviders)[number]
115+
116+
export const isFauxProvider = (key: string): key is FauxProvider => fauxProviders.includes(key as FauxProvider)
117+
118+
/**
119+
* CustomProvider
120+
*
121+
* Custom providers are completely configurable within Roo Code settings.
122+
*/
123+
124+
export const customProviders = ["openai-native"] as const satisfies readonly ProviderName[]
125+
126+
export type CustomProvider = (typeof customProviders)[number]
127+
128+
export const isCustomProvider = (key: string): key is CustomProvider => customProviders.includes(key as CustomProvider)
129+
130+
/**
131+
* InternalProvider
132+
*
133+
* Internal providers require internal VSCode API calls in order to get the
134+
* model list.
135+
*/
136+
137+
export const internalProviders = ["vscode-lm"] as const satisfies readonly ProviderName[]
138+
139+
export type InternalProvider = (typeof internalProviders)[number]
140+
141+
export const isInternalProvider = (key: string): key is InternalProvider =>
142+
internalProviders.includes(key as InternalProvider)
143+
77144
/**
78145
* ProviderSettingsEntry
79146
*/
@@ -91,11 +158,6 @@ export type ProviderSettingsEntry = z.infer<typeof providerSettingsEntrySchema>
91158
* ProviderSettings
92159
*/
93160

94-
/**
95-
* Default value for consecutive mistake limit
96-
*/
97-
export const DEFAULT_CONSECUTIVE_MISTAKE_LIMIT = 3
98-
99161
const baseProviderSettingsSchema = z.object({
100162
includeMaxTokens: z.boolean().optional(),
101163
diffEnabled: z.boolean().optional(),
@@ -124,7 +186,7 @@ const anthropicSchema = apiModelIdProviderModelSchema.extend({
124186
apiKey: z.string().optional(),
125187
anthropicBaseUrl: z.string().optional(),
126188
anthropicUseAuthToken: z.boolean().optional(),
127-
anthropicBeta1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window
189+
anthropicBeta1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window.
128190
})
129191

130192
const claudeCodeSchema = apiModelIdProviderModelSchema.extend({
@@ -160,7 +222,7 @@ const bedrockSchema = apiModelIdProviderModelSchema.extend({
160222
awsModelContextWindow: z.number().optional(),
161223
awsBedrockEndpointEnabled: z.boolean().optional(),
162224
awsBedrockEndpoint: z.string().optional(),
163-
awsBedrock1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window
225+
awsBedrock1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window.
164226
})
165227

166228
const vertexSchema = apiModelIdProviderModelSchema.extend({
@@ -335,7 +397,7 @@ const qwenCodeSchema = apiModelIdProviderModelSchema.extend({
335397
})
336398

337399
const rooSchema = apiModelIdProviderModelSchema.extend({
338-
// No additional fields needed - uses cloud authentication
400+
// No additional fields needed - uses cloud authentication.
339401
})
340402

341403
const vercelAiGatewaySchema = baseProviderSettingsSchema.extend({
@@ -440,6 +502,10 @@ export type ProviderSettingsWithId = z.infer<typeof providerSettingsWithIdSchema
440502

441503
export const PROVIDER_SETTINGS_KEYS = providerSettingsSchema.keyof().options
442504

505+
/**
506+
* ModelIdKey
507+
*/
508+
443509
export const modelIdKeys = [
444510
"apiModelId",
445511
"glamaModelId",
@@ -464,7 +530,7 @@ export const getModelId = (settings: ProviderSettings): string | undefined => {
464530
return modelIdKey ? settings[modelIdKey] : undefined
465531
}
466532

467-
export const modelIdKeysByProvider: Record<ProviderName, ModelIdKey> = {
533+
export const modelIdKeysByProvider: Record<Exclude<ProviderName, FauxProvider | CustomProvider>, ModelIdKey> = {
468534
anthropic: "apiModelId",
469535
"claude-code": "apiModelId",
470536
glama: "glamaModelId",
@@ -477,7 +543,6 @@ export const modelIdKeysByProvider: Record<ProviderName, ModelIdKey> = {
477543
lmstudio: "lmStudioModelId",
478544
gemini: "apiModelId",
479545
"gemini-cli": "apiModelId",
480-
"openai-native": "openAiModelId",
481546
mistral: "apiModelId",
482547
moonshot: "apiModelId",
483548
deepseek: "apiModelId",
@@ -486,8 +551,6 @@ export const modelIdKeysByProvider: Record<ProviderName, ModelIdKey> = {
486551
"qwen-code": "apiModelId",
487552
unbound: "unboundModelId",
488553
requesty: "requestyModelId",
489-
"human-relay": "apiModelId",
490-
"fake-ai": "apiModelId",
491554
xai: "apiModelId",
492555
groq: "apiModelId",
493556
chutes: "apiModelId",
@@ -503,6 +566,10 @@ export const modelIdKeysByProvider: Record<ProviderName, ModelIdKey> = {
503566
"vercel-ai-gateway": "vercelAiGatewayModelId",
504567
}
505568

569+
/**
570+
* ANTHROPIC_STYLE_PROVIDERS
571+
*/
572+
506573
// Providers that use Anthropic-style API protocol.
507574
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = ["anthropic", "claude-code", "bedrock"]
508575

@@ -523,6 +590,10 @@ export const getApiProtocol = (provider: ProviderName | undefined, modelId?: str
523590
return "openai"
524591
}
525592

593+
/**
594+
* MODELS_BY_PROVIDER
595+
*/
596+
526597
export const MODELS_BY_PROVIDER: Record<
527598
Exclude<ProviderName, "fake-ai" | "human-relay" | "gemini-cli" | "lmstudio" | "openai" | "ollama">,
528599
{ id: ProviderName; label: string; models: string[] }
@@ -620,19 +691,3 @@ export const MODELS_BY_PROVIDER: Record<
620691
deepinfra: { id: "deepinfra", label: "DeepInfra", models: [] },
621692
"vercel-ai-gateway": { id: "vercel-ai-gateway", label: "Vercel AI Gateway", models: [] },
622693
}
623-
624-
export const dynamicProviders = [
625-
"glama",
626-
"huggingface",
627-
"litellm",
628-
"openrouter",
629-
"requesty",
630-
"unbound",
631-
"deepinfra",
632-
"vercel-ai-gateway",
633-
] as const satisfies readonly ProviderName[]
634-
635-
export type DynamicProvider = (typeof dynamicProviders)[number]
636-
637-
export const isDynamicProvider = (key: string): key is DynamicProvider =>
638-
dynamicProviders.includes(key as DynamicProvider)

0 commit comments

Comments
 (0)