fix(opencode): honor Bedrock Mantle config (#31001)

This commit is contained in:
Aiden Cline
2026-06-05 13:14:55 -05:00
committed by GitHub
parent 3bbf8c8989
commit ca9bf7abf9
2 changed files with 27 additions and 10 deletions
+13 -2
View File
@@ -295,6 +295,7 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
const profile = configProfile ?? envProfile
const awsAccessKeyId = env["AWS_ACCESS_KEY_ID"]
const configApiKey = providerConfig?.options?.apiKey
// TODO: Using process.env directly because Env.set only updates a process.env shallow copy,
// until the scope of the Env API is clarified (test only or runtime?)
@@ -314,7 +315,14 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI || process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI,
)
if (!profile && !awsAccessKeyId && !awsBearerToken && !awsWebIdentityTokenFile && !containerCreds)
if (
!profile &&
!awsAccessKeyId &&
!awsBearerToken &&
!configApiKey &&
!awsWebIdentityTokenFile &&
!containerCreds
)
return { autoload: false }
const { fromNodeProviderChain } = yield* Effect.promise(() => import("@aws-sdk/credential-providers"))
@@ -325,7 +333,7 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
// Only use credential chain if no bearer token exists
// Bearer token takes precedence over credential chain (profiles, access keys, IAM roles, web identity tokens)
if (!awsBearerToken) {
if (!awsBearerToken && !configApiKey) {
// Build credential provider options (only pass profile if specified)
const credentialProviderOptions = profile ? { profile } : {}
@@ -341,6 +349,9 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
return {
autoload: true,
options: providerOptions,
vars(options: Record<string, any>) {
return { AWS_REGION: options.region ?? defaultRegion }
},
async getModel(sdk: any, modelID: string, options?: Record<string, any>, model?: Model) {
if (model?.api.npm === "@ai-sdk/amazon-bedrock/mantle") return selectBedrockMantleLanguageModel(sdk, modelID)