Skip to content

Commit 241df17

Browse files
authored
Add MODELS_BY_PROVIDER for use in @roo-code/cloud (#7258)
1 parent 57ea625 commit 241df17

File tree

6 files changed

+151
-20
lines changed

6 files changed

+151
-20
lines changed

packages/types/npm/package.metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@roo-code/types",
3-
"version": "1.55.0",
3+
"version": "1.59.0",
44
"description": "TypeScript type definitions for Roo Code.",
55
"publishConfig": {
66
"access": "public",

packages/types/src/model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export const reasoningEffortsSchema = z.enum(reasoningEfforts)
1010

1111
export type ReasoningEffort = z.infer<typeof reasoningEffortsSchema>
1212

13+
/**
14+
* ReasoningEffortWithMinimal
15+
*/
16+
17+
export const reasoningEffortWithMinimalSchema = z.union([reasoningEffortsSchema, z.literal("minimal")])
18+
19+
export type ReasoningEffortWithMinimal = z.infer<typeof reasoningEffortWithMinimalSchema>
20+
1321
/**
1422
* Verbosity
1523
*/

packages/types/src/provider-settings.ts

Lines changed: 135 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
import { z } from "zod"
22

3-
import { reasoningEffortsSchema, verbosityLevelsSchema, modelInfoSchema } from "./model.js"
3+
import { modelInfoSchema, reasoningEffortWithMinimalSchema, verbosityLevelsSchema } from "./model.js"
44
import { codebaseIndexProviderSchema } from "./codebase-index.js"
5-
6-
// Bedrock Claude Sonnet 4 model ID that supports 1M context
7-
export const BEDROCK_CLAUDE_SONNET_4_MODEL_ID = "anthropic.claude-sonnet-4-20250514-v1:0"
8-
9-
// Extended schema that includes "minimal" for GPT-5 models
10-
export const extendedReasoningEffortsSchema = z.union([reasoningEffortsSchema, z.literal("minimal")])
11-
12-
export type ReasoningEffortWithMinimal = z.infer<typeof extendedReasoningEffortsSchema>
5+
import {
6+
anthropicModels,
7+
bedrockModels,
8+
cerebrasModels,
9+
chutesModels,
10+
claudeCodeModels,
11+
deepSeekModels,
12+
doubaoModels,
13+
featherlessModels,
14+
fireworksModels,
15+
geminiModels,
16+
groqModels,
17+
ioIntelligenceModels,
18+
mistralModels,
19+
moonshotModels,
20+
openAiNativeModels,
21+
rooModels,
22+
sambaNovaModels,
23+
vertexModels,
24+
vscodeLlmModels,
25+
xaiModels,
26+
internationalZAiModels,
27+
} from "./providers/index.js"
1328

1429
/**
1530
* ProviderName
@@ -87,7 +102,7 @@ const baseProviderSettingsSchema = z.object({
87102

88103
// Model reasoning.
89104
enableReasoningEffort: z.boolean().optional(),
90-
reasoningEffort: extendedReasoningEffortsSchema.optional(),
105+
reasoningEffort: reasoningEffortWithMinimalSchema.optional(),
91106
modelMaxTokens: z.number().optional(),
92107
modelMaxThinkingTokens: z.number().optional(),
93108

@@ -407,21 +422,126 @@ export const getModelId = (settings: ProviderSettings): string | undefined => {
407422
return modelIdKey ? (settings[modelIdKey] as string) : undefined
408423
}
409424

410-
// Providers that use Anthropic-style API protocol
425+
// Providers that use Anthropic-style API protocol.
411426
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = ["anthropic", "claude-code", "bedrock"]
412427

413-
// Helper function to determine API protocol for a provider and model
414428
export const getApiProtocol = (provider: ProviderName | undefined, modelId?: string): "anthropic" | "openai" => {
415-
// First check if the provider is an Anthropic-style provider
416429
if (provider && ANTHROPIC_STYLE_PROVIDERS.includes(provider)) {
417430
return "anthropic"
418431
}
419432

420-
// For vertex provider, check if the model ID contains "claude" (case-insensitive)
421433
if (provider && provider === "vertex" && modelId && modelId.toLowerCase().includes("claude")) {
422434
return "anthropic"
423435
}
424436

425-
// Default to OpenAI protocol
426437
return "openai"
427438
}
439+
440+
export const MODELS_BY_PROVIDER: Record<
441+
Exclude<ProviderName, "fake-ai" | "human-relay" | "gemini-cli" | "lmstudio" | "openai" | "ollama">,
442+
{ id: ProviderName; label: string; models: string[] }
443+
> = {
444+
anthropic: {
445+
id: "anthropic",
446+
label: "Anthropic",
447+
models: Object.keys(anthropicModels),
448+
},
449+
bedrock: {
450+
id: "bedrock",
451+
label: "Amazon Bedrock",
452+
models: Object.keys(bedrockModels),
453+
},
454+
cerebras: {
455+
id: "cerebras",
456+
label: "Cerebras",
457+
models: Object.keys(cerebrasModels),
458+
},
459+
chutes: {
460+
id: "chutes",
461+
label: "Chutes AI",
462+
models: Object.keys(chutesModels),
463+
},
464+
"claude-code": { id: "claude-code", label: "Claude Code", models: Object.keys(claudeCodeModels) },
465+
deepseek: {
466+
id: "deepseek",
467+
label: "DeepSeek",
468+
models: Object.keys(deepSeekModels),
469+
},
470+
doubao: { id: "doubao", label: "Doubao", models: Object.keys(doubaoModels) },
471+
featherless: {
472+
id: "featherless",
473+
label: "Featherless",
474+
models: Object.keys(featherlessModels),
475+
},
476+
fireworks: {
477+
id: "fireworks",
478+
label: "Fireworks",
479+
models: Object.keys(fireworksModels),
480+
},
481+
gemini: {
482+
id: "gemini",
483+
label: "Google Gemini",
484+
models: Object.keys(geminiModels),
485+
},
486+
groq: { id: "groq", label: "Groq", models: Object.keys(groqModels) },
487+
"io-intelligence": {
488+
id: "io-intelligence",
489+
label: "IO Intelligence",
490+
models: Object.keys(ioIntelligenceModels),
491+
},
492+
mistral: {
493+
id: "mistral",
494+
label: "Mistral",
495+
models: Object.keys(mistralModels),
496+
},
497+
moonshot: {
498+
id: "moonshot",
499+
label: "Moonshot",
500+
models: Object.keys(moonshotModels),
501+
},
502+
"openai-native": {
503+
id: "openai-native",
504+
label: "OpenAI",
505+
models: Object.keys(openAiNativeModels),
506+
},
507+
roo: { id: "roo", label: "Roo", models: Object.keys(rooModels) },
508+
sambanova: {
509+
id: "sambanova",
510+
label: "SambaNova",
511+
models: Object.keys(sambaNovaModels),
512+
},
513+
vertex: {
514+
id: "vertex",
515+
label: "GCP Vertex AI",
516+
models: Object.keys(vertexModels),
517+
},
518+
"vscode-lm": {
519+
id: "vscode-lm",
520+
label: "VS Code LM API",
521+
models: Object.keys(vscodeLlmModels),
522+
},
523+
xai: { id: "xai", label: "xAI (Grok)", models: Object.keys(xaiModels) },
524+
zai: { id: "zai", label: "Zai", models: Object.keys(internationalZAiModels) },
525+
526+
// Dynamic providers; models pulled from the respective APIs.
527+
glama: { id: "glama", label: "Glama", models: [] },
528+
huggingface: { id: "huggingface", label: "Hugging Face", models: [] },
529+
litellm: { id: "litellm", label: "LiteLLM", models: [] },
530+
openrouter: { id: "openrouter", label: "OpenRouter", models: [] },
531+
requesty: { id: "requesty", label: "Requesty", models: [] },
532+
unbound: { id: "unbound", label: "Unbound", models: [] },
533+
}
534+
535+
export const dynamicProviders = [
536+
"glama",
537+
"huggingface",
538+
"litellm",
539+
"openrouter",
540+
"requesty",
541+
"unbound",
542+
] as const satisfies readonly ProviderName[]
543+
544+
export type DynamicProvider = (typeof dynamicProviders)[number]
545+
546+
export const isDynamicProvider = (key: string): key is DynamicProvider =>
547+
dynamicProviders.includes(key as DynamicProvider)

packages/types/src/providers/bedrock.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,5 @@ export const BEDROCK_REGIONS = [
441441
{ value: "us-gov-east-1", label: "us-gov-east-1" },
442442
{ value: "us-gov-west-1", label: "us-gov-west-1" },
443443
].sort((a, b) => a.value.localeCompare(b.value))
444+
445+
export const BEDROCK_CLAUDE_SONNET_4_MODEL_ID = "anthropic.claude-sonnet-4-20250514-v1:0"

packages/types/src/providers/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export * from "./cerebras.js"
44
export * from "./chutes.js"
55
export * from "./claude-code.js"
66
export * from "./deepseek.js"
7+
export * from "./doubao.js"
8+
export * from "./featherless.js"
9+
export * from "./fireworks.js"
710
export * from "./gemini.js"
811
export * from "./glama.js"
912
export * from "./groq.js"
@@ -17,13 +20,10 @@ export * from "./ollama.js"
1720
export * from "./openai.js"
1821
export * from "./openrouter.js"
1922
export * from "./requesty.js"
23+
export * from "./roo.js"
2024
export * from "./sambanova.js"
2125
export * from "./unbound.js"
2226
export * from "./vertex.js"
2327
export * from "./vscode-llm.js"
2428
export * from "./xai.js"
25-
export * from "./doubao.js"
2629
export * from "./zai.js"
27-
export * from "./fireworks.js"
28-
export * from "./roo.js"
29-
export * from "./featherless.js"

packages/types/src/providers/vscode-llm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type VscodeLlmModelId = keyof typeof vscodeLlmModels
44

55
export const vscodeLlmDefaultModelId: VscodeLlmModelId = "claude-3.5-sonnet"
66

7+
// https://docs.cline.bot/provider-config/vscode-language-model-api
78
export const vscodeLlmModels = {
89
"gpt-3.5-turbo": {
910
contextWindow: 12114,

0 commit comments

Comments
 (0)