@cat-factory/provider-bedrock

中文文档
0.7.579发布于 2026/11/06TypeScriptES Module构建来源已验证近 30 天下载 6568

Opt-in AWS Bedrock model registry for the Agent Architecture Board's AI provisioning facade. Mix into a CompositeModelProvider to add the bedrock provider.

原始使用文档
文档目录7 节
  1. Why this is its own package
  2. Enabling it
  3. Node / local facade: via env
  4. Cloudflare Worker facade: via registerModelRegistry
  5. How it resolves a model
  6. Config ( BedrockResolverOptions )
  7. Related

@cat-factory/provider-bedrock

Opt-in AWS Bedrock model resolver for cat-factory's AI provisioning facade: lets a deployment serve LLMs through Amazon Bedrock alongside (or instead of) the built-in direct vendors.

Why this is its own package

Bedrock support pulls in the AWS Bedrock SDK (@ai-sdk/amazon-bedrock + ai), which is heavy and irrelevant to any deployment that doesn't use Bedrock. Keeping it in a separate opt-in package means the core packages and the Cloudflare Worker base registry stay free of the SDK: only a facade that actually wires Bedrock pays for it. It contributes a single provider (bedrock) to a CompositeModelProvider through the neutral ModelResolver / ProviderRegistry seam from @cat-factory/agents; no model-resolution logic is duplicated.

Enabling it

The package exports two helpers:

  • bedrockResolver(opts) → a ModelResolver for the bedrock provider.
  • bedrockRegistry(opts) → a ProviderRegistry ({ bedrock: resolver }) ready to mix in.

Node / local facade: via env

The Node facade wires Bedrock automatically when BEDROCK_REGION is set (see createNodeModelProviderResolver in backend/runtimes/node/src/modelProvider.ts); it appends bedrockRegistry(...) to the composite's extra registries:

// ONE pair of readers, shared with the model catalog's `bedrock` capability: see below.
const bedrockRegion = bedrockRegionFromEnv(env)
if (bedrockRegion) {
  const supportedModels = bedrockAllowListFromEnv(env)
  extraRegistries.push(
    bedrockRegistry({
      region: bedrockRegion,
      accessKeyId: env.AWS_ACCESS_KEY_ID,
      secretAccessKey: env.AWS_SECRET_ACCESS_KEY,
      sessionToken: env.AWS_SESSION_TOKEN,
      ...(supportedModels ? { supportedModels: [...supportedModels] } : {}),
    }),
  )
}

So a Node/local deployment opts in purely with env: BEDROCK_REGION (required to enable), optional AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN (omit to use the ambient AWS credential chain; instance role, ~/.aws, etc.), and optional BEDROCK_MODELS (comma-separated allow-list).

BEDROCK_MODELS does double duty, which is why it is parsed by bedrockAllowListFromEnv (@cat-factory/server) rather than inline: the same value becomes this resolver's allow-list AND ProviderCapabilities.bedrockModels, which decides whether a catalog model's bedrock flavour is selectable in the picker. Parsed separately, the picker could offer an id this resolver throws on. Details: model-support.md §8.

Cloudflare Worker facade: via registerModelRegistry

The Worker's base registry ships without the SDK; a deployment mixes Bedrock in at startup through the installation-level model-provider extension point (see backend/runtimes/cloudflare/src/infrastructure/ai/registries.ts):

import { registerModelRegistry } from '@cat-factory/worker'
import { bedrockRegistry } from '@cat-factory/provider-bedrock'

registerModelRegistry((env) => bedrockRegistry({ region: env.BEDROCK_REGION }))

Registration is process-wide and read by every buildContainer(env) call, so the provider reaches all paths (HTTP requests, the durable Workflow driver, and the cron sweeper) not just one entry point. The factory receives the runtime env, so credentials/region come from the deployment's configuration.

The registration is also what unlocks the picker flavour on this facade. The Worker reads BEDROCK_REGION / BEDROCK_MODELS for the per-model enablement, but grants the capability only when a registered registry can actually serve bedrock (bedrockModelsCapability in ai/registries.ts): the env vars alone don't prove this package was mixed in, and offering the flavour on them would put rows in the picker whose dispatch fails. Set-but-unregistered logs a warning naming the missing registerModelRegistry call.

How it resolves a model

The resolver forwards ref.model to the Bedrock provider (createAmazonBedrock(...)). A model is addressed by its Bedrock model id (e.g. anthropic.claude-3-5-sonnet-20240620-v1:0). When supportedModels is set, resolving anything outside the allow-list throws Unsupported Bedrock model: <id> up front, so a misconfigured model fails fast with a clear message instead of a deep AWS SDK error. Omit supportedModels to forward any model id.

Config (BedrockResolverOptions)

OptionPurpose
regionAWS region, e.g. us-east-1.
accessKeyIdExplicit AWS access key; omit to use the default AWS credential chain.
secretAccessKeyExplicit AWS secret key.
sessionTokenExplicit AWS session token (temporary credentials).
baseURLOverride the Bedrock base URL (e.g. a VPC endpoint).
supportedModelsAllow-list of Bedrock model ids; resolving anything outside it throws. Omit to allow any.

Part of cat-factory's opt-in AWS stack alongside @cat-factory/provider-s3 (blob storage) and @cat-factory/eks (runner + environment backends). Each is independent and registers into its own seam: mix in only what you use.

版本与发布记录

@cat-factory/provider-bedrock 共发布 554 个版本,首次发布于 2026/06/24;过去 12 个月发布了 554 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.579latest2026/11/062 天前
0.7.5782026/11/045 天前
0.7.5772026/11/045 天前
0.7.5762026/11/045 天前
0.7.5752026/11/045 天前
0.7.5742026/11/045 天前

关于 @cat-factory/provider-bedrock 的常见问题

@cat-factory/provider-bedrock 是什么?

Opt-in AWS Bedrock model registry for the Agent Architecture Board's AI provisioning facade. Mix into a CompositeModelProvider to add the bedrock provider.

如何安装 @cat-factory/provider-bedrock?

在项目目录运行 npm install @cat-factory/provider-bedrock,或使用 pnpm add / yarn add / bun add。

@cat-factory/provider-bedrock 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cat-factory/provider-bedrock 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cat-factory/provider-bedrock 可以商用吗?

@cat-factory/provider-bedrock 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@cat-factory/provider-bedrock 的下载量有多少?

根据 npm 官方下载统计,@cat-factory/provider-bedrock 在 2026/10/09 – 2026/11/07 这 30 天内被下载 6,568 次,日均约 219 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cat-factory/provider-bedrock 还在维护吗?

最新版本 0.7.579 发布于 2026/11/06(2 天前);至今共发布 554 个版本,其中过去 12 个月发布了 554 个;首次发布于 2026/06/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。