@plumbus/core 0.7.8 → 0.7.9

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 (88) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +6 -6
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/ai/ai/model-pricing.d.ts +5 -2
  5. package/dist/ai/ai/provider.d.ts +28 -1
  6. package/dist/ai/ai-service.d.ts +6 -1
  7. package/dist/ai/ai-service.d.ts.map +1 -1
  8. package/dist/ai/ai-service.js +21 -14
  9. package/dist/ai/ai-service.js.map +1 -1
  10. package/dist/ai/index.d.ts +1 -1
  11. package/dist/ai/index.d.ts.map +1 -1
  12. package/dist/ai/index.js.map +1 -1
  13. package/dist/ai/model-pricing.d.ts +5 -2
  14. package/dist/ai/model-pricing.d.ts.map +1 -1
  15. package/dist/ai/model-pricing.js +68 -12
  16. package/dist/ai/model-pricing.js.map +1 -1
  17. package/dist/ai/provider.d.ts +28 -1
  18. package/dist/ai/provider.d.ts.map +1 -1
  19. package/dist/ai/provider.js +186 -29
  20. package/dist/ai/provider.js.map +1 -1
  21. package/dist/ai/tool-loop.d.ts +3 -1
  22. package/dist/ai/tool-loop.d.ts.map +1 -1
  23. package/dist/ai/tool-loop.js +2 -0
  24. package/dist/ai/tool-loop.js.map +1 -1
  25. package/dist/ai/types/config.d.ts +11 -0
  26. package/dist/ai/validation.d.ts +7 -3
  27. package/dist/ai/validation.d.ts.map +1 -1
  28. package/dist/ai/validation.js +13 -10
  29. package/dist/ai/validation.js.map +1 -1
  30. package/dist/api/route-generator.d.ts +2 -12
  31. package/dist/api/route-generator.d.ts.map +1 -1
  32. package/dist/api/route-generator.js +14 -18
  33. package/dist/api/route-generator.js.map +1 -1
  34. package/dist/cli/commands/e2e.d.ts +12 -0
  35. package/dist/cli/commands/e2e.d.ts.map +1 -1
  36. package/dist/cli/commands/e2e.js +11 -0
  37. package/dist/cli/commands/e2e.js.map +1 -1
  38. package/dist/cli/commands/init.d.ts +1 -1
  39. package/dist/cli/commands/init.d.ts.map +1 -1
  40. package/dist/cli/commands/init.js +3 -3
  41. package/dist/cli/commands/init.js.map +1 -1
  42. package/dist/config/loader.d.ts.map +1 -1
  43. package/dist/config/loader.js +25 -0
  44. package/dist/config/loader.js.map +1 -1
  45. package/dist/execution/capability-error-hook.d.ts +24 -0
  46. package/dist/execution/capability-error-hook.d.ts.map +1 -0
  47. package/dist/execution/capability-error-hook.js +17 -0
  48. package/dist/execution/capability-error-hook.js.map +1 -0
  49. package/dist/execution/index.d.ts +1 -0
  50. package/dist/execution/index.d.ts.map +1 -1
  51. package/dist/execution/index.js.map +1 -1
  52. package/dist/flows/step-executor.d.ts +8 -0
  53. package/dist/flows/step-executor.d.ts.map +1 -1
  54. package/dist/flows/step-executor.js.map +1 -1
  55. package/dist/index.d.ts +2 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/runtime/bootstrap.d.ts.map +1 -1
  59. package/dist/runtime/bootstrap.js +7 -1
  60. package/dist/runtime/bootstrap.js.map +1 -1
  61. package/dist/runtime/register-consumers.d.ts +3 -0
  62. package/dist/runtime/register-consumers.d.ts.map +1 -1
  63. package/dist/runtime/register-consumers.js +27 -6
  64. package/dist/runtime/register-consumers.js.map +1 -1
  65. package/dist/runtime/start-worker-pool.d.ts.map +1 -1
  66. package/dist/runtime/start-worker-pool.js +1 -0
  67. package/dist/runtime/start-worker-pool.js.map +1 -1
  68. package/dist/server/bootstrap.d.ts +5 -12
  69. package/dist/server/bootstrap.d.ts.map +1 -1
  70. package/dist/server/bootstrap.js +2 -0
  71. package/dist/server/bootstrap.js.map +1 -1
  72. package/dist/types/config.d.ts +11 -0
  73. package/dist/types/config.d.ts.map +1 -1
  74. package/dist/types/context.d.ts +17 -2
  75. package/dist/types/context.d.ts.map +1 -1
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/index.js.map +1 -1
  79. package/dist/worker/bootstrap.d.ts +9 -0
  80. package/dist/worker/bootstrap.d.ts.map +1 -1
  81. package/dist/worker/bootstrap.js +33 -1
  82. package/dist/worker/bootstrap.js.map +1 -1
  83. package/instructions/README.md +3 -1
  84. package/instructions/ai-classification.md +22 -5
  85. package/instructions/ai.md +34 -11
  86. package/instructions/framework.md +5 -3
  87. package/instructions/peer-dependencies.md +1 -1
  88. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @plumbus/core changelog
2
2
 
3
+ ## 0.7.9 — 2026-10-08
4
+
5
+ - Fix `plumbus e2e` freezing the frontend dev server partway through a long run. The server's stdout was piped but never read, and `next dev` writes a line there for every request with stdout in blocking mode, so after about 80 KB (roughly 1,000 page loads) the server blocked in that write for good. The test in flight timed out at its 30 s limit and every later test would too, which looked like one random late test failing. The runner now reads and discards that stream; stderr is still relayed as `[frontend]` lines.
6
+ - Add prompt caching for Anthropic and Bedrock (#63). Pass `cache: true` (system prompt + tools) or `{ system?, tools?, messages? }` on `ctx.ai.generate`, `generateWithUsage`, `streamGenerate`, or `runToolLoop`, which forwards it to every round. Anthropic requests get `cache_control` on the system prompt, the last tool, and (when asked) the last message; `@plumbus/ai-bedrock` 0.2.2 adds Converse `cachePoint`. OpenAI ignores the option. Without `cache` or the default below, requests are unchanged. Cache reads and writes are reported in `usage.cachedInputTokens` / `usage.cacheWriteTokens` and priced as before.
7
+ - Add a prompt-cache default for every call: `AI_PROMPT_CACHE=true` (or sections such as `system,messages`) loads into `aiProviders.cache` (`ai.cache` in single-provider mode), and the API server, workers, and `plumbus mcp serve` pass it to `createAIService({ cache })`. A per-call `cache` overrides it. Other values log a warning and leave caching off.
8
+ - Fix multi-turn history in the Anthropic adapter's `stream()`: it now converts `messages` with the same mapping as `complete()`. It used to copy each message as `{ role, content }`, so a `tool` message went out with a role the Messages API does not accept, assistant tool calls were dropped, and thinking blocks kept in `providerState` were not sent back. `stream()` still sends no tools.
9
+ - Support the new optional OpenAI Decisions API provider, `@plumbus/ai-decision-openai` 0.2.0 (#72). Register it under `decisions.providers` with a key such as `openai-decisions` (distinct from the `openai` text provider) and select it from `ctx.ai.classify()` / `ctx.ai.decide()`; the classification recipe (`instructions/ai-classification.md`) and `instructions/ai.md` show how. Core now depends on `@plumbus/ai-decision` `~0.2.3` (was `~0.2.2`), the shared version the adapter needs: it adds the transport endpoint path, adapter-declared rounding (two decimals for OpenAI), and `DecisionProviderError.refusedQuestions`. TypeSafe and Laya results are validated exactly as before, and core's decision code is unchanged.
10
+ - Bump agent wiring to v19. Every agent format (Copilot, Cursor, AGENTS.md, CLAUDE.md; inline and reference, flat and monorepo) adds a link to `node_modules/@plumbus/ai-decision-openai/instructions/README.md` next to the TypeSafe/Jev and Laya indexes, and the Cursor capability rule names OpenAI Decisions in its classification line. Nothing else changes from v18. Refresh apps with `plumbus init --patch --agent all`; `plumbus doctor` reports older wiring as stale.
11
+ - `onCapabilityError` also fires when a capability fails in the worker: flow steps, jobs, and event handlers (#71). It used to run only for HTTP routes, so background failures never reached the hook. Apps that export `onCapabilityError` from `app/server.ts` start receiving these failures without a code change, because the worker started by `plumbus dev`, `plumbus start`, and `plumbus worker` now wires it. A new optional `source` field (`'http' | 'flow' | 'job' | 'event'`) tells them apart. In the worker, `sourceIp` and `userAgent` are undefined and `userId` can be a service identity (`event-worker` for event handlers), so a hook that assumes an HTTP caller should check `source`.
12
+ - The hook stays fire-and-forget: errors it throws are logged, and event retries and dead-lettering, job status, and flow step retries and `onFlowError` are unchanged. Each failed attempt fires once, so an event handler that fails on all N delivery attempts fires N times.
13
+ - Apps with their own bootstrap pass the hook as `createWorkerPool({ onCapabilityError })`. Flow steps are reported when `stepDeps` comes from `buildStepDeps()`, which now names the capability on failures it ran (an optional `capability` field on the step result). Jobs and event handlers are reported when `createWorkerPool()` registers their consumers; apps that call `registerCapabilityConsumers()` themselves pass it the new `onCapabilityError` option. The payload type is exported as `CapabilityErrorInfo` and replaces the inline types on `ServerConfig` and `RouteGeneratorConfig`; hooks typed against the old shape still compile.
14
+ - Add standard pricing for `gpt-6.1-sol` ($2 input / $0.10 cached input / $2.50 cache writes / $10 output per MTok, doubling input and cache and 1.5× output above 272K input tokens), `claude-sonnet-5-5` ($2 / $0.10 / $2.50 five-minute cache writes / $10, flat across the 1M window), and `claude-haiku-5-5` ($0.10 / $0.01 / $0.125 / $0.50 for prompts up to 100,000 tokens; $0.50 / $0.05 / $0.625 / $2.50 above). `gpt-6-astra` now applies its published long-context premium above 272K input tokens ($20 / $2 cached / $25 cache writes / $75), which it lacked; its $1 cached-input rate is now listed explicitly (unchanged). Pricing checked against OpenAI's and Anthropic's pricing pages on 2026-10-08; the other GPT-6 and current Anthropic rows match.
15
+ - Add optional `ModelRate.longContextRates`: published rates used above `longContextThreshold` in place of the 2× input/cache and 1.5× output rule, for Haiku 5.5's 5× step at 100,000 tokens. Entries without it are priced as before.
16
+ - Price validation retries per attempt: `generateWithValidation` adds up each attempt's adapter cost, else the catalog price of that attempt's own usage, into `ValidatedResponse.cost` and the new `AIValidationError.cost`, and `generate`, `extract`, `classify`, and the streaming validation fallback record that sum. Pricing the summed usage once could cross a long-context threshold no single request crossed, such as two 60K-token Claude Haiku 5.5 attempts billed at its over-100K rates.
17
+ - OpenAI usage now carries `cacheWriteTokens` from `cache_write_tokens` for GPT-5.6 and GPT-6 models (Chat Completions, streaming, and Responses), so their cache writes cost the 1.25× input rate OpenAI bills; they were priced as ordinary input. Earlier OpenAI models have no cache-write charge and are unchanged.
18
+ - GPT-6 reasoning settings the API rejects now fail with `AIInvalidRequestError` before any I/O instead of an HTTP 400: effort `minimal` on every GPT-6 model, and `{ mode: 'disabled' }` on `gpt-6-astra` and `gpt-6.1-sol`, which have no `none` effort.
19
+ - `gpt-5.6-terra`, `gpt-5.6-luna`, `gpt-5.5`, `gpt-5.5-pro`, `gpt-5.4`, and `gpt-5.4-pro` now apply the long-context prices OpenAI's pricing page lists above 272K input tokens: 2× input, cache reads, and cache writes and 1.5× output for the whole request (`gpt-5.6-terra`: $4 input / $0.40 cached / $18 output instead of $2 / $0.20 / $12). They were priced at the short-context rates at any length.
20
+ - Anthropic adapter: Claude Fable 5.1, Mythos 5.1, Fable 5, Mythos 5, Mythos Preview, Opus 5.5, Opus 5, Opus 4.8, Opus 4.7, Sonnet 5.5, Sonnet 5, and Haiku 5.5 return HTTP 400 for any temperature other than 1, thinking on or off, so requests to them failed whenever the adapter's `temperature: 0.7` default was sent (no explicit temperature and no effort or budget reasoning). No temperature is sent to these models any more, neither the default nor one set on a call or a prompt (such as `@plumbus/chat`'s scope check at `0` or the CLI prompt template's `0.7`), as the OpenAI adapter already does for `gpt-5.5` and later. For them, `{ mode: 'disabled' }` is sent as `thinking: { type: 'between_tools' }` on Sonnet 5.5 and fails with `reasoning_disabled_unsupported` on Opus 5.5, Fable 5.1, Mythos 5.1, Fable 5, Mythos 5, and Mythos Preview, which cannot turn thinking off; `{ mode: 'budget' }` fails with `reasoning_budget_unsupported` on all of them except Mythos Preview. Requests to other Claude models, such as `claude-sonnet-4-5`, `claude-haiku-4-5`, and `claude-opus-4-6`, are sent byte for byte as before.
21
+
3
22
  ## 0.7.8 — 2026-09-27
4
23
 
5
24
  - `plumbus dev` and `plumbus start` load an `authenticationRuntime` export from `app/server.ts` (named or on the default export) and pass it to `createServer`, so apps that do not own their bootstrap can use `@plumbus/auth` browser sign-in. Without the export nothing changes. With it, capability routes authenticate through the runtime's composite authenticator (bearer first, then the session cookie) and `routeConfig.authAdapter` is the deny-all adapter, so custom routes in `onRoutesRegistered` should call `routeConfig.requestAuthenticator`.
package/README.md CHANGED
@@ -152,7 +152,7 @@ node_modules/@plumbus/core/instructions/
152
152
  ├── flows.md # Workflow steps and retry logic
153
153
  ├── prompts.md # Prompt content, system/description, model config
154
154
  ├── ai.md # ctx.ai operations, RAG, cost tracking
155
- ├── ai-classification.md # Provider/model selection, TypeSafe/Jev, Laya
155
+ ├── ai-classification.md # Provider/model selection, TypeSafe/Jev, Laya, OpenAI Decisions
156
156
  ├── translations.md # i18n catalogs and ctx.translations
157
157
  ├── security.md # Access policies and tenant isolation
158
158
  ├── governance.md # Advisory rules and compliance
@@ -166,11 +166,11 @@ node_modules/@plumbus/core/instructions/
166
166
  └── upgrading-0.5-capabilities.md # 0.5.x capability invocation migration
167
167
  ```
168
168
 
169
- Wire them up with `plumbus init --agent all`. After upgrading to core 0.7.7+, run
170
- `plumbus init --patch --agent all` for wiring v18 (v17 added the classification recipe;
171
- v18 adds the payments packages and Cognito server-attested sign-in). For classification,
172
- provider/model selection, or TypeSafe/Jev and Laya, start with
173
- [the classification recipe](instructions/ai-classification.md).
169
+ Wire them up with `plumbus init --agent all`. After upgrading to core 0.7.9+, run
170
+ `plumbus init --patch --agent all` for wiring v19 (v17 added the classification recipe;
171
+ v18 adds the payments packages and Cognito server-attested sign-in; v19 adds the OpenAI
172
+ Decisions provider). For classification, provider/model selection, or TypeSafe/Jev, Laya,
173
+ or OpenAI Decisions, start with [the classification recipe](instructions/ai-classification.md).
174
174
 
175
175
  ## Documentation
176
176