@cat-factory/provider-bedrock 0.7.353 → 0.7.355

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +27 -13
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @cat-factory/provider-bedrock
2
2
 
3
- Opt-in **AWS Bedrock** model resolver for cat-factory's AI provisioning facade lets a
3
+ Opt-in **AWS Bedrock** model resolver for cat-factory's AI provisioning facade: lets a
4
4
  deployment serve LLMs through Amazon Bedrock alongside (or instead of) the built-in direct
5
5
  vendors.
6
6
 
@@ -8,7 +8,7 @@ vendors.
8
8
 
9
9
  Bedrock support pulls in the AWS Bedrock SDK (`@ai-sdk/amazon-bedrock` + `ai`), which is heavy
10
10
  and irrelevant to any deployment that doesn't use Bedrock. Keeping it in a separate opt-in
11
- package means the core packages and the Cloudflare Worker base registry stay free of the SDK
11
+ package means the core packages and the Cloudflare Worker base registry stay free of the SDK:
12
12
  only a facade that actually wires Bedrock pays for it. It contributes a single provider
13
13
  (`bedrock`) to a `CompositeModelProvider` through the neutral `ModelResolver` / `ProviderRegistry`
14
14
  seam from `@cat-factory/agents`; no model-resolution logic is duplicated.
@@ -20,24 +20,24 @@ The package exports two helpers:
20
20
  - `bedrockResolver(opts)` → a `ModelResolver` for the `bedrock` provider.
21
21
  - `bedrockRegistry(opts)` → a `ProviderRegistry` (`{ bedrock: resolver }`) ready to mix in.
22
22
 
23
- ### Node / local facade via env
23
+ ### Node / local facade: via env
24
24
 
25
25
  The Node facade wires Bedrock automatically **when `BEDROCK_REGION` is set** (see
26
26
  `createNodeModelProviderResolver` in `backend/runtimes/node/src/modelProvider.ts`); it appends
27
27
  `bedrockRegistry(...)` to the composite's extra registries:
28
28
 
29
29
  ```ts
30
- if (env.BEDROCK_REGION) {
30
+ // ONE pair of readers, shared with the model catalog's `bedrock` capability: see below.
31
+ const bedrockRegion = bedrockRegionFromEnv(env)
32
+ if (bedrockRegion) {
33
+ const supportedModels = bedrockAllowListFromEnv(env)
31
34
  extraRegistries.push(
32
35
  bedrockRegistry({
33
- region: env.BEDROCK_REGION,
36
+ region: bedrockRegion,
34
37
  accessKeyId: env.AWS_ACCESS_KEY_ID,
35
38
  secretAccessKey: env.AWS_SECRET_ACCESS_KEY,
36
39
  sessionToken: env.AWS_SESSION_TOKEN,
37
- // BEDROCK_MODELS="anthropic.claude-…,meta.llama3-…" the allow-list below
38
- supportedModels: env.BEDROCK_MODELS?.split(',')
39
- .map((m) => m.trim())
40
- .filter(Boolean),
40
+ ...(supportedModels ? { supportedModels: [...supportedModels] } : {}),
41
41
  }),
42
42
  )
43
43
  }
@@ -45,10 +45,17 @@ if (env.BEDROCK_REGION) {
45
45
 
46
46
  So a Node/local deployment opts in purely with env: `BEDROCK_REGION` (required to enable),
47
47
  optional `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN` (omit to use the
48
- ambient AWS credential chain instance role, `~/.aws`, etc.), and optional `BEDROCK_MODELS`
48
+ ambient AWS credential chain; instance role, `~/.aws`, etc.), and optional `BEDROCK_MODELS`
49
49
  (comma-separated allow-list).
50
50
 
51
- ### Cloudflare Worker facade via `registerModelRegistry`
51
+ **`BEDROCK_MODELS` does double duty**, which is why it is parsed by
52
+ `bedrockAllowListFromEnv` (`@cat-factory/server`) rather than inline: the same value becomes
53
+ this resolver's allow-list AND `ProviderCapabilities.bedrockModels`, which decides whether a
54
+ catalog model's `bedrock` flavour is selectable in the picker. Parsed separately, the picker
55
+ could offer an id this resolver throws on. Details:
56
+ [`model-support.md` §8](../../docs/model-support.md).
57
+
58
+ ### Cloudflare Worker facade: via `registerModelRegistry`
52
59
 
53
60
  The Worker's base registry ships without the SDK; a deployment mixes Bedrock in at startup
54
61
  through the installation-level model-provider extension point (see
@@ -62,10 +69,17 @@ registerModelRegistry((env) => bedrockRegistry({ region: env.BEDROCK_REGION }))
62
69
  ```
63
70
 
64
71
  Registration is process-wide and read by every `buildContainer(env)` call, so the provider
65
- reaches all paths HTTP requests, the durable Workflow driver, and the cron sweeper not just
72
+ reaches all paths (HTTP requests, the durable Workflow driver, and the cron sweeper) not just
66
73
  one entry point. The factory receives the runtime `env`, so credentials/region come from the
67
74
  deployment's configuration.
68
75
 
76
+ **The registration is also what unlocks the picker flavour on this facade.** The Worker reads
77
+ `BEDROCK_REGION` / `BEDROCK_MODELS` for the per-model enablement, but grants the capability only
78
+ when a registered registry can actually serve `bedrock` (`bedrockModelsCapability` in
79
+ `ai/registries.ts`): the env vars alone don't prove this package was mixed in, and offering the
80
+ flavour on them would put rows in the picker whose dispatch fails. Set-but-unregistered logs a
81
+ warning naming the missing `registerModelRegistry` call.
82
+
69
83
  ## How it resolves a model
70
84
 
71
85
  The resolver forwards `ref.model` to the Bedrock provider (`createAmazonBedrock(...)`). A model is
@@ -89,4 +103,4 @@ message instead of a deep AWS SDK error. Omit `supportedModels` to forward any m
89
103
 
90
104
  Part of cat-factory's opt-in **AWS stack** alongside [`@cat-factory/provider-s3`](../provider-s3)
91
105
  (blob storage) and [`@cat-factory/eks`](../eks) (runner + environment backends). Each is
92
- independent and registers into its own seam mix in only what you use.
106
+ independent and registers into its own seam: mix in only what you use.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/provider-bedrock",
3
- "version": "0.7.353",
3
+ "version": "0.7.355",
4
4
  "description": "Opt-in AWS Bedrock model registry for the Agent Architecture Board's AI provisioning facade. Mix into a CompositeModelProvider to add the `bedrock` provider.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,8 +26,8 @@
26
26
  "dependencies": {
27
27
  "@ai-sdk/amazon-bedrock": "^5.0.40",
28
28
  "ai": "^7.0.47",
29
- "@cat-factory/agents": "0.106.1",
30
- "@cat-factory/kernel": "0.217.0"
29
+ "@cat-factory/agents": "0.106.3",
30
+ "@cat-factory/kernel": "0.219.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "typescript": "7.0.2",