@plumbus/core 0.6.14 → 0.6.16

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 (48) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/ai/ai/provider.d.ts +20 -3
  4. package/dist/ai/ai-service.d.ts.map +1 -1
  5. package/dist/ai/ai-service.js +31 -10
  6. package/dist/ai/ai-service.js.map +1 -1
  7. package/dist/ai/model-pricing.d.ts.map +1 -1
  8. package/dist/ai/model-pricing.js +16 -3
  9. package/dist/ai/model-pricing.js.map +1 -1
  10. package/dist/ai/provider.d.ts +20 -3
  11. package/dist/ai/provider.d.ts.map +1 -1
  12. package/dist/ai/provider.js +79 -18
  13. package/dist/ai/provider.js.map +1 -1
  14. package/dist/ai/types/config.d.ts +27 -0
  15. package/dist/ai/validation.d.ts +6 -0
  16. package/dist/ai/validation.d.ts.map +1 -1
  17. package/dist/ai/validation.js +12 -1
  18. package/dist/ai/validation.js.map +1 -1
  19. package/dist/cli/commands/init.d.ts +1 -1
  20. package/dist/cli/commands/init.d.ts.map +1 -1
  21. package/dist/cli/commands/init.js +19 -2
  22. package/dist/cli/commands/init.js.map +1 -1
  23. package/dist/cli/commands/migrate.d.ts.map +1 -1
  24. package/dist/cli/commands/migrate.js +8 -7
  25. package/dist/cli/commands/migrate.js.map +1 -1
  26. package/dist/config/loader.d.ts +1 -1
  27. package/dist/config/loader.d.ts.map +1 -1
  28. package/dist/config/loader.js +37 -4
  29. package/dist/config/loader.js.map +1 -1
  30. package/dist/data/index.d.ts +1 -1
  31. package/dist/data/index.d.ts.map +1 -1
  32. package/dist/data/index.js.map +1 -1
  33. package/dist/data/migration.d.ts +16 -7
  34. package/dist/data/migration.d.ts.map +1 -1
  35. package/dist/data/migration.js +38 -21
  36. package/dist/data/migration.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/types/config.d.ts +27 -0
  41. package/dist/types/config.d.ts.map +1 -1
  42. package/dist/types/index.d.ts +1 -1
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/index.js.map +1 -1
  45. package/instructions/README.md +2 -0
  46. package/instructions/ai.md +31 -2
  47. package/instructions/peer-dependencies.md +5 -1
  48. package/package.json +9 -4
@@ -26,6 +26,8 @@ For conceptual reference, see `docs/` in the Plumbus monorepo. These files are *
26
26
  | [peer-dependencies.md](./peer-dependencies.md) | **Before editing add-on `peerDependencies`** — copy literals exactly. |
27
27
  | [upgrading-0.5-capabilities.md](./upgrading-0.5-capabilities.md) | Canonical capability names, invoke policy, flow auth snapshot. |
28
28
 
29
+ Optional AI provider: after `pnpm add @plumbus/ai-bedrock`, read `node_modules/@plumbus/ai-bedrock/instructions/README.md` (framework + pricing pull).
30
+
29
31
  Package quickstart: [../README.md](../README.md).
30
32
 
31
33
  ## Critical rules
@@ -186,7 +186,9 @@ All AI responses are validated against the prompt's output Zod schema. On failur
186
186
 
187
187
  Every AI invocation records: model used, input/output token counts, latency, and prompt name. Token counts come directly from provider responses.
188
188
 
189
- **Per-request cost** is computed automatically from a built-in pricing table (`calculateModelCost`) covering major OpenAI and Anthropic models. Unknown models (Ollama, custom endpoints) return cost `$0`. Cached-token and long-context adjustments are applied when providers return cache metadata.
189
+ **Per-request cost** for OpenAI/Anthropic is computed from a built-in pricing table (`calculateModelCost`). Unknown models (Ollama, custom endpoints) return cost `$0`. Cached-token and long-context adjustments are applied when providers return cache metadata.
190
+
191
+ **Provider-supplied cost:** when an adapter sets `cost` on `ProviderResponse` / stream `done` (Amazon Bedrock via `@plumbus/ai-bedrock`), `createAIService` **prefers that value** over `MODEL_PRICING`. Bedrock never returns USD — the add-on multiplies usage × AWS Price List rates (auto-download or `AI_BEDROCK_PRICING_FILE`). Do not alias Bedrock rates to Anthropic catalog rows.
190
192
 
191
193
  `generateWithUsage()` and `streamGenerate()` expose `cost` on each call. Budget limits (`BudgetConfig`) can gate requests by tokens or dollar amounts.
192
194
 
@@ -219,7 +221,7 @@ AI_MODEL=gpt-4o-mini
219
221
 
220
222
  ### Multi-Provider
221
223
 
222
- Set `AI_DEFAULT_PROVIDER` to enable multi-provider mode. Env-based discovery supports **only** `AI_OPENAI_*` and `AI_ANTHROPIC_*` slots — other `AI_{NAME}_API_KEY` values are ignored with a warning. Wire additional providers programmatically via `createProviderAdapter` / `createAIService`.
224
+ Set `AI_DEFAULT_PROVIDER` to enable multi-provider mode. Env-based discovery supports **`AI_OPENAI_*`**, **`AI_ANTHROPIC_*`**, and **`AI_BEDROCK_*`** (region-based; no API key). Other `AI_{NAME}_API_KEY` values are ignored with a warning. Wire additional providers programmatically via `createProviderAdapter` / `createAIService`.
223
225
 
224
226
  ```bash
225
227
  AI_DEFAULT_PROVIDER=openai
@@ -233,6 +235,33 @@ AI_ANTHROPIC_BASE_URL=https://custom-anthropic.com # optional
233
235
  AI_ANTHROPIC_MODEL=claude-sonnet-4-20250514
234
236
  ```
235
237
 
238
+ ### Amazon Bedrock
239
+
240
+ Requires `@plumbus/core` **≥ 0.6.16** (provider slot, env discovery, adapter `cost`, wiring v13).
241
+
242
+ ```bash
243
+ pnpm add @plumbus/ai-bedrock
244
+ ```
245
+
246
+ ```bash
247
+ AI_DEFAULT_PROVIDER=bedrock
248
+ AI_BEDROCK_REGION=us-east-1
249
+ AI_BEDROCK_MODEL=anthropic.claude-sonnet-4-5-20250929-v1:0
250
+ # containers (recommended) — mount normalized rates; no Price List CDN egress:
251
+ # AI_BEDROCK_PRICING_FILE=/config/bedrock-pricing.json
252
+ ```
253
+
254
+ Auth is IAM / IRSA / default credential chain (SDK may honor `AWS_BEARER_TOKEN_BEDROCK`). Price List URLs, curl, normalize script, ConfigMap:
255
+
256
+ - `node_modules/@plumbus/ai-bedrock/instructions/framework.md`
257
+ - `node_modules/@plumbus/ai-bedrock/instructions/pricing.md`
258
+
259
+ Example rates URL (public, no IAM):
260
+
261
+ ```text
262
+ https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrockFoundationModels/current/us-east-1/index.json
263
+ ```
264
+
236
265
  Each prompt's `model.provider` routes to the named provider; prompts without a provider field use `defaultProvider`.
237
266
 
238
267
  ### Default Model
@@ -16,6 +16,7 @@ Read this file **before** editing `peerDependencies` in any `packages/*/package.
16
16
  | Most add-ons (chat, chat-ui, knowledge-base, mcp, api, browser-extension) | `"0.5.x \|\| 0.6.x"` | `packages/mcp/package.json` |
17
17
  | Voice only (requires core 0.6+ media/cost APIs) | `"0.6.x"` | `packages/voice/package.json` |
18
18
  | Auth only (requires core 0.6.8+ HttpAuthenticationRuntime) | `"0.6.x"` | `packages/auth/package.json` |
19
+ | AI Bedrock (requires provider `cost` preference + optional peer load; **runtime ≥ 0.6.16**) | `"0.6.x"` | `packages/ai-bedrock/package.json` |
19
20
 
20
21
  When adding a **new** publishable add-on under `packages/`, use `"0.5.x || 0.6.x"` unless the package genuinely requires core 0.6+ only (then use the voice pattern).
21
22
 
@@ -26,6 +27,7 @@ When adding a **new** publishable add-on under `packages/`, use `"0.5.x || 0.6.x
26
27
  | `@plumbus/chat` **0.1.11+** | `0.5.x \|\| 0.6.x` | `@plumbus/core` **≥ 0.6.11** (tool protocol + `updateWhere`) |
27
28
  | `@plumbus/chat-ui` **0.1.7+** | `0.5.x \|\| 0.6.x` (+ `@plumbus/chat` `0.1.x`) | `@plumbus/chat` **≥ 0.1.11** (and thus core **≥ 0.6.11**) |
28
29
  | `@plumbus/auth` | `0.6.x` | `@plumbus/core` **≥ 0.6.8** (`HttpAuthenticationRuntime`) |
30
+ | `@plumbus/api` **0.1.4+** | `0.5.x \|\| 0.6.x` | `@plumbus/core` **≥ 0.6.9** (`buildAuthenticationRequest` for partner session auth) |
29
31
 
30
32
  ## Other publishable peer strings
31
33
 
@@ -33,6 +35,8 @@ When adding a **new** publishable add-on under `packages/`, use `"0.5.x || 0.6.x
33
35
  |---|---|---|---|---|
34
36
  | `@plumbus/core` | `@plumbus/mcp` | `"0.5.x \|\| 0.6.x"` | optional | `packages/plumbus-core/package.json` |
35
37
  | `@plumbus/core` | `@plumbus/api` | `"0.1.x"` | optional | `packages/plumbus-core/package.json` |
38
+ | `@plumbus/core` | `@plumbus/ai-bedrock` | `"0.1.x"` | optional | `packages/plumbus-core/package.json` |
39
+ | `@plumbus/ai-bedrock` | `@plumbus/core` | `"0.6.x"` | required | `packages/ai-bedrock/package.json` |
36
40
  | `@plumbus/chat` | `@plumbus/knowledge-base` | `"^0.1.0"` | optional | `packages/chat/package.json` |
37
41
  | `@plumbus/chat-ui` | `@plumbus/chat` | `"0.1.x"` | required | `packages/chat-ui/package.json` |
38
42
  | `@plumbus/chat-ui` | `@plumbus/core` | `"0.5.x \|\| 0.6.x"` | required | `packages/chat-ui/package.json` |
@@ -46,7 +50,7 @@ When adding a **new** publishable add-on under `packages/`, use `"0.5.x || 0.6.x
46
50
  | `@plumbus/voice` | `@plumbus/voice-minimax` | `"0.1.x"` | optional | `packages/voice/package.json` |
47
51
  | `@plumbus/voice` | `@plumbus/voice-livekit` | `"0.1.x"` | optional | `packages/voice/package.json` |
48
52
 
49
- **Peering direction:** add-ons declare `@plumbus/core` as a peer — consumer apps install both. `@plumbus/core` optionally peers `@plumbus/mcp` and `@plumbus/api` when those packages are present. `@plumbus/chat` optionally peers `@plumbus/knowledge-base` for registry-backed context sources — **not** the reverse. `@plumbus/knowledge-base` only peers `@plumbus/core`. `@plumbus/auth-cognito` peers `@plumbus/auth` only — not `@plumbus/core` directly. Voice provider packages peer `@plumbus/voice` `0.4.x` (and `@plumbus/core` `0.6.x`); `@plumbus/voice` does **not** peer the add-ons — apps install add-ons and pass `*_REGISTRATION` into `createProviderRegistry()` — **copy these literals; do not derive**.
53
+ **Peering direction:** add-ons declare `@plumbus/core` as a peer — consumer apps install both. `@plumbus/core` optionally peers `@plumbus/mcp`, `@plumbus/api`, and `@plumbus/ai-bedrock` when those packages are present. `@plumbus/chat` optionally peers `@plumbus/knowledge-base` for registry-backed context sources — **not** the reverse. `@plumbus/knowledge-base` only peers `@plumbus/core`. `@plumbus/auth-cognito` peers `@plumbus/auth` only — not `@plumbus/core` directly. Voice provider packages peer `@plumbus/voice` `0.4.x` (and `@plumbus/core` `0.6.x`); `@plumbus/voice` does **not** peer the add-ons — apps install add-ons and pass `*_REGISTRATION` into `createProviderRegistry()` — **copy these literals; do not derive**.
50
54
 
51
55
  ## Forbidden patterns
52
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumbus/core",
3
- "version": "0.6.14",
3
+ "version": "0.6.16",
4
4
  "description": "Plumbus framework core — types, SDK, runtime, CLI, test utilities",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -75,6 +75,7 @@
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@plumbus/api": "0.1.x",
78
+ "@plumbus/ai-bedrock": "0.1.x",
78
79
  "@plumbus/mcp": "0.5.x || 0.6.x",
79
80
  "cron-parser": "^4.9.0",
80
81
  "redis": "^4.7.0"
@@ -83,6 +84,9 @@
83
84
  "@plumbus/api": {
84
85
  "optional": true
85
86
  },
87
+ "@plumbus/ai-bedrock": {
88
+ "optional": true
89
+ },
86
90
  "@plumbus/mcp": {
87
91
  "optional": true
88
92
  },
@@ -99,9 +103,10 @@
99
103
  "@vitest/browser": "^3.0.0",
100
104
  "esbuild": "^0.25.12",
101
105
  "typescript": "^5.7.0",
102
- "@plumbus/api": "0.1.3",
103
- "@plumbus/mcp": "0.5.1",
104
- "@plumbus/voice": "0.4.3"
106
+ "@plumbus/api": "0.1.4",
107
+ "@plumbus/ai-bedrock": "0.1.0",
108
+ "@plumbus/voice": "0.4.3",
109
+ "@plumbus/mcp": "0.5.1"
105
110
  },
106
111
  "scripts": {
107
112
  "build": "tsc -b",