@cat-factory/provider-bedrock 0.7.143 → 0.7.144
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.
- package/README.md +90 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @cat-factory/provider-bedrock
|
|
2
|
+
|
|
3
|
+
Opt-in **AWS Bedrock** model resolver for cat-factory's AI provisioning facade — lets a
|
|
4
|
+
deployment serve LLMs through Amazon Bedrock alongside (or instead of) the built-in direct
|
|
5
|
+
vendors.
|
|
6
|
+
|
|
7
|
+
## Why this is its own package
|
|
8
|
+
|
|
9
|
+
Bedrock support pulls in the AWS Bedrock SDK (`@ai-sdk/amazon-bedrock` + `ai`), which is heavy
|
|
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 —
|
|
12
|
+
only a facade that actually wires Bedrock pays for it. It contributes a single provider
|
|
13
|
+
(`bedrock`) to a `CompositeModelProvider` through the neutral `ModelResolver` / `ProviderRegistry`
|
|
14
|
+
seam from `@cat-factory/agents`; no model-resolution logic is duplicated.
|
|
15
|
+
|
|
16
|
+
## Enabling it
|
|
17
|
+
|
|
18
|
+
The package exports two helpers:
|
|
19
|
+
|
|
20
|
+
- `bedrockResolver(opts)` → a `ModelResolver` for the `bedrock` provider.
|
|
21
|
+
- `bedrockRegistry(opts)` → a `ProviderRegistry` (`{ bedrock: resolver }`) ready to mix in.
|
|
22
|
+
|
|
23
|
+
### Node / local facade — via env
|
|
24
|
+
|
|
25
|
+
The Node facade wires Bedrock automatically **when `BEDROCK_REGION` is set** (see
|
|
26
|
+
`createNodeModelProviderResolver` in `backend/runtimes/node/src/modelProvider.ts`); it appends
|
|
27
|
+
`bedrockRegistry(...)` to the composite's extra registries:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
if (env.BEDROCK_REGION) {
|
|
31
|
+
extraRegistries.push(
|
|
32
|
+
bedrockRegistry({
|
|
33
|
+
region: env.BEDROCK_REGION,
|
|
34
|
+
accessKeyId: env.AWS_ACCESS_KEY_ID,
|
|
35
|
+
secretAccessKey: env.AWS_SECRET_ACCESS_KEY,
|
|
36
|
+
sessionToken: env.AWS_SESSION_TOKEN,
|
|
37
|
+
// BEDROCK_MODELS="anthropic.claude-…,meta.llama3-…" → the allow-list below
|
|
38
|
+
supportedModels: env.BEDROCK_MODELS?.split(',').map((m) => m.trim()).filter(Boolean),
|
|
39
|
+
}),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
So a Node/local deployment opts in purely with env: `BEDROCK_REGION` (required to enable),
|
|
45
|
+
optional `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN` (omit to use the
|
|
46
|
+
ambient AWS credential chain — instance role, `~/.aws`, etc.), and optional `BEDROCK_MODELS`
|
|
47
|
+
(comma-separated allow-list).
|
|
48
|
+
|
|
49
|
+
### Cloudflare Worker facade — via `registerModelRegistry`
|
|
50
|
+
|
|
51
|
+
The Worker's base registry ships without the SDK; a deployment mixes Bedrock in at startup
|
|
52
|
+
through the installation-level model-provider extension point (see
|
|
53
|
+
`backend/runtimes/cloudflare/src/infrastructure/ai/registries.ts`):
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { registerModelRegistry } from '@cat-factory/worker'
|
|
57
|
+
import { bedrockRegistry } from '@cat-factory/provider-bedrock'
|
|
58
|
+
|
|
59
|
+
registerModelRegistry((env) => bedrockRegistry({ region: env.BEDROCK_REGION }))
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Registration is process-wide and read by every `buildContainer(env)` call, so the provider
|
|
63
|
+
reaches all paths — HTTP requests, the durable Workflow driver, and the cron sweeper — not just
|
|
64
|
+
one entry point. The factory receives the runtime `env`, so credentials/region come from the
|
|
65
|
+
deployment's configuration.
|
|
66
|
+
|
|
67
|
+
## How it resolves a model
|
|
68
|
+
|
|
69
|
+
The resolver forwards `ref.model` to the Bedrock provider (`createAmazonBedrock(...)`). A model is
|
|
70
|
+
addressed by its Bedrock model id (e.g. `anthropic.claude-3-5-sonnet-20240620-v1:0`). When
|
|
71
|
+
`supportedModels` is set, resolving anything outside the allow-list throws
|
|
72
|
+
`Unsupported Bedrock model: <id>` **up front**, so a misconfigured model fails fast with a clear
|
|
73
|
+
message instead of a deep AWS SDK error. Omit `supportedModels` to forward any model id.
|
|
74
|
+
|
|
75
|
+
## Config (`BedrockResolverOptions`)
|
|
76
|
+
|
|
77
|
+
| Option | Purpose |
|
|
78
|
+
| ----------------- | ------------------------------------------------------------------------------------ |
|
|
79
|
+
| `region` | AWS region, e.g. `us-east-1`. |
|
|
80
|
+
| `accessKeyId` | Explicit AWS access key; omit to use the default AWS credential chain. |
|
|
81
|
+
| `secretAccessKey` | Explicit AWS secret key. |
|
|
82
|
+
| `sessionToken` | Explicit AWS session token (temporary credentials). |
|
|
83
|
+
| `baseURL` | Override the Bedrock base URL (e.g. a VPC endpoint). |
|
|
84
|
+
| `supportedModels` | Allow-list of Bedrock model ids; resolving anything outside it throws. Omit to allow any. |
|
|
85
|
+
|
|
86
|
+
## Related
|
|
87
|
+
|
|
88
|
+
Part of cat-factory's opt-in **AWS stack** alongside [`@cat-factory/provider-s3`](../provider-s3)
|
|
89
|
+
(blob storage) and [`@cat-factory/eks`](../eks) (runner + environment backends). Each is
|
|
90
|
+
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.
|
|
3
|
+
"version": "0.7.144",
|
|
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": "^4.0.124",
|
|
28
28
|
"ai": "^6.0.214",
|
|
29
|
-
"@cat-factory/agents": "0.37.
|
|
30
|
-
"@cat-factory/kernel": "0.
|
|
29
|
+
"@cat-factory/agents": "0.37.1",
|
|
30
|
+
"@cat-factory/kernel": "0.89.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"typescript": "7.0.1-rc"
|