Skip to content

Conversation

@wnkz
Copy link
Contributor

@wnkz wnkz commented Dec 29, 2025

Summary

Adds configuration file support for Amazon Bedrock provider with profile, region, and endpoint options. Documents authentication precedence to clarify that bearer tokens take priority over AWS credential chain methods.

Changes

Provider Configuration (provider.ts)

  • Added support for profile, region, and endpoint options in opencode.json
  • Implemented precedence logic: config file options override environment variables
  • Profile option now passed to fromNodeProviderChain() for proper credential resolution

Tests (amazon-bedrock.test.ts)

  • Added 4 tests covering config precedence scenarios
  • Tests verify profile precedence, endpoint configuration, and combined options

Documentation (config.mdx, providers.mdx)

  • Added "Provider-Specific Options" section to config docs
  • Added "Authentication Precedence" section to providers docs
  • Documents that bearer tokens (AWS_BEARER_TOKEN_BEDROCK or /connect) take precedence over credential chain

CLI (auth.ts)

  • Updated /connect amazon-bedrock help message to show clear credential priority order

Configuration Example

{
  "provider": {
    "amazon-bedrock": {
      "options": {
        "region": "us-east-1",
        "profile": "my-aws-profile",
        "endpoint": "https://bedrock-runtime.us-east-1.vpce-xxxxx.amazonaws.com"
      }
    }
  }
}

Authentication Precedence

  1. Bearer token (AWS_BEARER_TOKEN_BEDROCK or /connect)
  2. AWS credential chain (profile, access keys, IAM roles)

Notes:

  • Follows existing patterns for provider configuration
  • Maintains backward compatibility with environment variable configuration
  • Configuration file options take precedence over environment variables (except bearer tokens)

@wnkz
Copy link
Contributor Author

wnkz commented Dec 29, 2025

I don't think the typecheck issue comes from here, happy to rebase when fixed upstream

@rekram1-node
Copy link
Collaborator

ill fix

@wnkz wnkz force-pushed the ft-improve-bedrock-configuration branch from 0e540c4 to d9f2600 Compare December 29, 2025 19:32
@wnkz wnkz marked this pull request as draft December 29, 2025 19:33
@wnkz wnkz force-pushed the ft-improve-bedrock-configuration branch from d9f2600 to 947ed98 Compare December 29, 2025 19:35
@wnkz wnkz marked this pull request as ready for review December 29, 2025 19:37
@rekram1-node
Copy link
Collaborator

/review

const defaultRegion = awsRegion ?? "us-east-1"
if (!profile && !awsAccessKeyId && !awsBearerToken) return { autoload: false }

const { fromNodeProviderChain } = await import(await BunProc.install("@aws-sdk/credential-providers"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style guide violation: AVOID using any type. Consider typing providerOptions with a proper interface or at least Record<string, unknown>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants