Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/types/src/providers/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

export type BedrockModelId = keyof typeof bedrockModels

export const BedrockModelsMessageType = {
requestBedrockModels: "requestBedrockModels",
cancelBedrockModels: "cancelBedrockModels",
bedrockModels: "bedrockModels",
} as const

export interface BedrockCatalogEntry {
arn: string
name: string
kind: "regional" | "geographic" | "global" | "application"
}

export const bedrockDefaultModelId: BedrockModelId = "anthropic.claude-sonnet-4-5-20250929-v1:0"

export const bedrockDefaultPromptRouterModelId: BedrockModelId = "anthropic.claude-3-sonnet-20240229-v1:0"
Expand Down Expand Up @@ -738,3 +750,24 @@
FLEX: 0.5, // 50% discount from standard
PRIORITY: 1.75, // 75% premium over standard
} as const

/** Resolve the bundled model selection without silently opting into a routing geography. */
export function getBedrockInferenceModelId(
modelId: string,
region?: string,
crossRegion?: boolean,
global?: boolean,
): string {
const existingPrefix = ["global.", ...AWS_INFERENCE_PROFILE_MAPPING.map(([, prefix]) => prefix)].find((prefix) =>
modelId.startsWith(prefix),

Check warning on line 762 in packages/types/src/providers/bedrock.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/bedrock.ts:762: 4 mutation test gaps; example: Survived StringLiteral mutant (replacement: ""). See the job summary for the complete list and resolution guidance.
)

Check warning on line 763 in packages/types/src/providers/bedrock.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/bedrock.ts:763: Survived MethodExpression mutant (replacement: modelId.endsWith(prefix)). See the job summary for the complete list and resolution guidance.
if (existingPrefix) modelId = modelId.slice(existingPrefix.length)
if (global && BEDROCK_GLOBAL_INFERENCE_MODEL_IDS.some((id) => id === modelId)) {

Check warning on line 765 in packages/types/src/providers/bedrock.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/bedrock.ts:765: 3 mutation test gaps; example: Survived ConditionalExpression mutant (replacement: true). See the job summary for the complete list and resolution guidance.
return `global.${modelId}`

Check warning on line 766 in packages/types/src/providers/bedrock.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/bedrock.ts:766: 8 mutation test gaps; example: Survived ConditionalExpression mutant (replacement: true). See the job summary for the complete list and resolution guidance.
}

Check warning on line 767 in packages/types/src/providers/bedrock.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/bedrock.ts:767: Survived StringLiteral mutant (replacement: ``). See the job summary for the complete list and resolution guidance.
const prefix =
crossRegion && region
? AWS_INFERENCE_PROFILE_MAPPING.find(([pattern]) => region.startsWith(pattern))?.[1]

Check warning on line 770 in packages/types/src/providers/bedrock.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/bedrock.ts:770: 3 mutation test gaps; example: Survived ConditionalExpression mutant (replacement: true). See the job summary for the complete list and resolution guidance.
: undefined

Check warning on line 771 in packages/types/src/providers/bedrock.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

packages/types/src/providers/bedrock.ts:771: 3 mutation test gaps; example: Survived OptionalChaining mutant (replacement: AWS_INFERENCE_PROFILE_MAPPING.find(([pattern]) => region.startsWith(pattern))[1]). See the job summary for the complete list and resolution guidance.
return prefix ? `${prefix}${modelId}` : modelId
}
5 changes: 5 additions & 0 deletions packages/types/src/vscode-extension-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { RouterModelsMessageType, type ModelRecord, type RouterModels } from "./
import { LmStudioModelsMessageType } from "./providers/lm-studio.js"
import { OllamaModelsMessageType } from "./providers/ollama.js"
import { OpenAiModelsMessageType } from "./providers/openai.js"
import { BedrockModelsMessageType, type BedrockCatalogEntry } from "./providers/bedrock.js"
import { VsCodeLmModelsMessageType } from "./providers/vscode-llm.js"
import type { OpenAiCodexRateLimitInfo } from "./providers/openai-codex-rate-limits.js"
import type { SkillMetadata } from "./skills.js"
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface ExtensionMessage {
| typeof RouterModelsMessageType.routerModels
| "zooGatewayCredentialsReady"
| typeof OpenAiModelsMessageType.openAiModels
| typeof BedrockModelsMessageType.bedrockModels
| typeof OllamaModelsMessageType.ollamaModels
| typeof LmStudioModelsMessageType.lmStudioModels
| typeof VsCodeLmModelsMessageType.vsCodeLmModels
Expand Down Expand Up @@ -141,6 +143,7 @@ export interface ExtensionMessage {
clineMessage?: ClineMessage
routerModels?: RouterModels
openAiModels?: string[]
bedrockModels?: BedrockCatalogEntry[]
ollamaModels?: ModelRecord
lmStudioModels?: ModelRecord
vsCodeLmModels?: { vendor?: string; family?: string; version?: string; id?: string }[]
Expand Down Expand Up @@ -490,6 +493,8 @@ export interface WebviewMessage {
| typeof RouterModelsMessageType.flushRouterModels
| typeof RouterModelsMessageType.requestRouterModels
| typeof OpenAiModelsMessageType.requestOpenAiModels
| typeof BedrockModelsMessageType.requestBedrockModels
| typeof BedrockModelsMessageType.cancelBedrockModels
| typeof OllamaModelsMessageType.requestOllamaModels
| typeof LmStudioModelsMessageType.requestLmStudioModels
| "requestRooModels"
Expand Down
Loading
Loading