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
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:5-22-bookworm",
"features": {
"ghcr.io/devcontainers-extra/features/bun:1": {"version": "1.3.4"}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "curl https://qlty.sh | bash && bun install"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
66 changes: 30 additions & 36 deletions packages/core/src/plugin/provider/amazon-bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,39 @@ type MantleSDK = {
// Bedrock cross-region inference profiles require regional prefixes only for
// specific model/region combinations. Keep the mapping narrow and avoid
// double-prefixing model IDs that models.dev already marks as global/us/eu/etc.
function resolveModelID(modelID: string, region: string | undefined) {
const crossRegionPrefixes = ["global.", "us.", "eu.", "jp.", "apac.", "au."]
if (crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))) return modelID
const CROSS_REGION_PREFIXES = ["global.", "us.", "eu.", "jp.", "apac.", "au."]
const US_MODELS = ["nova-micro", "nova-lite", "nova-pro", "nova-premier", "nova-2", "claude", "deepseek"]
const EU_REGIONS = ["eu-west-1", "eu-west-2", "eu-west-3", "eu-north-1", "eu-central-1", "eu-south-1", "eu-south-2"]
const EU_MODELS = ["claude", "nova-lite", "nova-micro", "llama3", "pixtral"]
const AU_REGIONS = ["ap-southeast-2", "ap-southeast-4"]
const AU_MODELS = ["anthropic.claude-sonnet-4-5", "anthropic.claude-haiku"]
const APAC_MODELS = ["claude", "nova-lite", "nova-micro", "nova-pro"]

const resolvedRegion = region ?? "us-east-1"
const regionPrefix = resolvedRegion.split("-")[0]
if (regionPrefix === "us") {
const requiresPrefix = ["nova-micro", "nova-lite", "nova-pro", "nova-premier", "nova-2", "claude", "deepseek"].some(
(item) => modelID.includes(item),
)
if (requiresPrefix && !resolvedRegion.startsWith("us-gov")) return `${regionPrefix}.${modelID}`
return modelID
}
if (regionPrefix === "eu") {
const regionRequiresPrefix = [
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-north-1",
"eu-central-1",
"eu-south-1",
"eu-south-2",
].some((item) => resolvedRegion.includes(item))
const modelRequiresPrefix = ["claude", "nova-lite", "nova-micro", "llama3", "pixtral"].some((item) =>
modelID.includes(item),
)
return regionRequiresPrefix && modelRequiresPrefix ? `${regionPrefix}.${modelID}` : modelID
}
if (regionPrefix !== "ap") return modelID
const matchesAny = (value: string, patterns: string[]) => patterns.some((pattern) => value.includes(pattern))

type PrefixResolver = (modelID: string, region: string) => string | undefined

const usPrefix: PrefixResolver = (modelID, region) =>
!region.startsWith("us-gov") && matchesAny(modelID, US_MODELS) ? "us" : undefined

const australia = ["ap-southeast-2", "ap-southeast-4"].includes(resolvedRegion)
if (australia && ["anthropic.claude-sonnet-4-5", "anthropic.claude-haiku"].some((item) => modelID.includes(item))) {
return `au.${modelID}`
}
const euPrefix: PrefixResolver = (modelID, region) =>
matchesAny(region, EU_REGIONS) && matchesAny(modelID, EU_MODELS) ? "eu" : undefined

const prefix = resolvedRegion === "ap-northeast-1" ? "jp" : "apac"
return ["claude", "nova-lite", "nova-micro", "nova-pro"].some((item) => modelID.includes(item))
? `${prefix}.${modelID}`
: modelID
const apPrefix: PrefixResolver = (modelID, region) => {
if (AU_REGIONS.includes(region) && matchesAny(modelID, AU_MODELS)) return "au"
const prefix = region === "ap-northeast-1" ? "jp" : "apac"
return matchesAny(modelID, APAC_MODELS) ? prefix : undefined
}

const PREFIX_RESOLVERS: Record<string, PrefixResolver> = { us: usPrefix, eu: euPrefix, ap: apPrefix }

function resolveModelID(modelID: string, region: string | undefined) {
if (CROSS_REGION_PREFIXES.some((prefix) => modelID.startsWith(prefix))) return modelID

const resolvedRegion = region ?? "us-east-1"
const resolver = PREFIX_RESOLVERS[resolvedRegion.split("-")[0]]
const prefix = resolver?.(modelID, resolvedRegion)
return prefix ? `${prefix}.${modelID}` : modelID
}

function selectMantleModel(sdk: MantleSDK, modelID: string) {
Expand Down
Loading