@plumbus/core 0.8.0-beta.0 → 0.8.0-beta.10

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 (275) hide show
  1. package/CHANGELOG.md +197 -0
  2. package/README.md +8 -1
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/ai/ai/cost-tracker.d.ts +22 -2
  5. package/dist/ai/ai/model-pricing.d.ts +8 -2
  6. package/dist/ai/ai/openai-strict-schema.d.ts +84 -0
  7. package/dist/ai/ai/provider.d.ts +90 -6
  8. package/dist/ai/ai-service.d.ts +53 -1
  9. package/dist/ai/ai-service.d.ts.map +1 -1
  10. package/dist/ai/ai-service.js +550 -119
  11. package/dist/ai/ai-service.js.map +1 -1
  12. package/dist/ai/cost-tracker.d.ts +22 -2
  13. package/dist/ai/cost-tracker.d.ts.map +1 -1
  14. package/dist/ai/cost-tracker.js +59 -20
  15. package/dist/ai/cost-tracker.js.map +1 -1
  16. package/dist/ai/explainability.d.ts +2 -1
  17. package/dist/ai/explainability.d.ts.map +1 -1
  18. package/dist/ai/explainability.js +1 -0
  19. package/dist/ai/explainability.js.map +1 -1
  20. package/dist/ai/index.d.ts +2 -2
  21. package/dist/ai/index.d.ts.map +1 -1
  22. package/dist/ai/index.js +1 -1
  23. package/dist/ai/index.js.map +1 -1
  24. package/dist/ai/model-pricing.d.ts +8 -2
  25. package/dist/ai/model-pricing.d.ts.map +1 -1
  26. package/dist/ai/model-pricing.js +113 -15
  27. package/dist/ai/model-pricing.js.map +1 -1
  28. package/dist/ai/openai-strict-schema.d.ts +85 -0
  29. package/dist/ai/openai-strict-schema.d.ts.map +1 -0
  30. package/dist/ai/openai-strict-schema.js +730 -0
  31. package/dist/ai/openai-strict-schema.js.map +1 -0
  32. package/dist/ai/prompt-overrides.d.ts +19 -0
  33. package/dist/ai/prompt-overrides.d.ts.map +1 -0
  34. package/dist/ai/prompt-overrides.js +60 -0
  35. package/dist/ai/prompt-overrides.js.map +1 -0
  36. package/dist/ai/provider-failure.d.ts +9 -0
  37. package/dist/ai/provider-failure.d.ts.map +1 -0
  38. package/dist/ai/provider-failure.js +112 -0
  39. package/dist/ai/provider-failure.js.map +1 -0
  40. package/dist/ai/provider.d.ts +90 -6
  41. package/dist/ai/provider.d.ts.map +1 -1
  42. package/dist/ai/provider.js +546 -97
  43. package/dist/ai/provider.js.map +1 -1
  44. package/dist/ai/rag/pipeline.d.ts +21 -1
  45. package/dist/ai/rag/pipeline.d.ts.map +1 -1
  46. package/dist/ai/rag/pipeline.js +17 -1
  47. package/dist/ai/rag/pipeline.js.map +1 -1
  48. package/dist/ai/tool-loop.d.ts +8 -1
  49. package/dist/ai/tool-loop.d.ts.map +1 -1
  50. package/dist/ai/tool-loop.js +7 -0
  51. package/dist/ai/tool-loop.js.map +1 -1
  52. package/dist/ai/types/config.d.ts +13 -0
  53. package/dist/ai/types/fields.d.ts +6 -0
  54. package/dist/ai/types/prompt.d.ts +9 -0
  55. package/dist/ai/usage-validation.d.ts.map +1 -1
  56. package/dist/ai/usage-validation.js +6 -1
  57. package/dist/ai/usage-validation.js.map +1 -1
  58. package/dist/ai/validation.d.ts +7 -3
  59. package/dist/ai/validation.d.ts.map +1 -1
  60. package/dist/ai/validation.js +38 -25
  61. package/dist/ai/validation.js.map +1 -1
  62. package/dist/ai/zod-to-provider-schema.d.ts.map +1 -1
  63. package/dist/ai/zod-to-provider-schema.js +246 -16
  64. package/dist/ai/zod-to-provider-schema.js.map +1 -1
  65. package/dist/api/route-generator.d.ts +2 -12
  66. package/dist/api/route-generator.d.ts.map +1 -1
  67. package/dist/api/route-generator.js +33 -41
  68. package/dist/api/route-generator.js.map +1 -1
  69. package/dist/approvals/index.d.ts +1 -1
  70. package/dist/approvals/index.d.ts.map +1 -1
  71. package/dist/approvals/index.js.map +1 -1
  72. package/dist/approvals/memory-store.d.ts.map +1 -1
  73. package/dist/approvals/memory-store.js +22 -0
  74. package/dist/approvals/memory-store.js.map +1 -1
  75. package/dist/approvals/schema.d.ts +34 -0
  76. package/dist/approvals/schema.d.ts.map +1 -1
  77. package/dist/approvals/schema.js +2 -0
  78. package/dist/approvals/schema.js.map +1 -1
  79. package/dist/approvals/service.d.ts.map +1 -1
  80. package/dist/approvals/service.js +36 -0
  81. package/dist/approvals/service.js.map +1 -1
  82. package/dist/approvals/sql-store.d.ts.map +1 -1
  83. package/dist/approvals/sql-store.js +42 -1
  84. package/dist/approvals/sql-store.js.map +1 -1
  85. package/dist/approvals/types.d.ts +11 -0
  86. package/dist/approvals/types.d.ts.map +1 -1
  87. package/dist/approvals/types.js +1 -0
  88. package/dist/approvals/types.js.map +1 -1
  89. package/dist/audit/service.d.ts.map +1 -1
  90. package/dist/audit/service.js +22 -2
  91. package/dist/audit/service.js.map +1 -1
  92. package/dist/cli/cli.d.ts.map +1 -1
  93. package/dist/cli/cli.js +2 -1
  94. package/dist/cli/cli.js.map +1 -1
  95. package/dist/cli/commands/browser-extension.d.ts +16 -0
  96. package/dist/cli/commands/browser-extension.d.ts.map +1 -1
  97. package/dist/cli/commands/browser-extension.js +16 -5
  98. package/dist/cli/commands/browser-extension.js.map +1 -1
  99. package/dist/cli/commands/dev.d.ts.map +1 -1
  100. package/dist/cli/commands/dev.js +7 -1
  101. package/dist/cli/commands/dev.js.map +1 -1
  102. package/dist/cli/commands/e2e.d.ts +12 -0
  103. package/dist/cli/commands/e2e.d.ts.map +1 -1
  104. package/dist/cli/commands/e2e.js +11 -0
  105. package/dist/cli/commands/e2e.js.map +1 -1
  106. package/dist/cli/commands/generate-openapi-from-zod.d.ts.map +1 -1
  107. package/dist/cli/commands/generate-openapi-from-zod.js +9 -1
  108. package/dist/cli/commands/generate-openapi-from-zod.js.map +1 -1
  109. package/dist/cli/commands/index.d.ts +1 -0
  110. package/dist/cli/commands/index.d.ts.map +1 -1
  111. package/dist/cli/commands/index.js +1 -0
  112. package/dist/cli/commands/index.js.map +1 -1
  113. package/dist/cli/commands/init.d.ts +1 -1
  114. package/dist/cli/commands/init.d.ts.map +1 -1
  115. package/dist/cli/commands/init.js +63 -3
  116. package/dist/cli/commands/init.js.map +1 -1
  117. package/dist/cli/commands/migrate.d.ts.map +1 -1
  118. package/dist/cli/commands/migrate.js +8 -14
  119. package/dist/cli/commands/migrate.js.map +1 -1
  120. package/dist/cli/commands/payments.d.ts +56 -0
  121. package/dist/cli/commands/payments.d.ts.map +1 -0
  122. package/dist/cli/commands/payments.js +184 -0
  123. package/dist/cli/commands/payments.js.map +1 -0
  124. package/dist/cli/commands/run.d.ts.map +1 -1
  125. package/dist/cli/commands/run.js +2 -7
  126. package/dist/cli/commands/run.js.map +1 -1
  127. package/dist/cli/commands/seed.d.ts.map +1 -1
  128. package/dist/cli/commands/seed.js +2 -7
  129. package/dist/cli/commands/seed.js.map +1 -1
  130. package/dist/cli/commands/start.d.ts.map +1 -1
  131. package/dist/cli/commands/start.js +9 -1
  132. package/dist/cli/commands/start.js.map +1 -1
  133. package/dist/cli/commands/worker.js +1 -1
  134. package/dist/cli/commands/worker.js.map +1 -1
  135. package/dist/cli/discover.d.ts +2 -0
  136. package/dist/cli/discover.d.ts.map +1 -1
  137. package/dist/cli/discover.js +39 -5
  138. package/dist/cli/discover.js.map +1 -1
  139. package/dist/config/loader.d.ts +4 -1
  140. package/dist/config/loader.d.ts.map +1 -1
  141. package/dist/config/loader.js +112 -24
  142. package/dist/config/loader.js.map +1 -1
  143. package/dist/data/connection.d.ts +23 -0
  144. package/dist/data/connection.d.ts.map +1 -1
  145. package/dist/data/connection.js +23 -6
  146. package/dist/data/connection.js.map +1 -1
  147. package/dist/data/schema-generator.d.ts.map +1 -1
  148. package/dist/data/schema-generator.js +2 -2
  149. package/dist/data/schema-generator.js.map +1 -1
  150. package/dist/define/definePrompt.d.ts.map +1 -1
  151. package/dist/define/definePrompt.js +6 -0
  152. package/dist/define/definePrompt.js.map +1 -1
  153. package/dist/durable/index.d.ts +2 -2
  154. package/dist/durable/index.d.ts.map +1 -1
  155. package/dist/durable/index.js +2 -2
  156. package/dist/durable/index.js.map +1 -1
  157. package/dist/durable/postgres-persist.d.ts +47 -2
  158. package/dist/durable/postgres-persist.d.ts.map +1 -1
  159. package/dist/durable/postgres-persist.js +152 -6
  160. package/dist/durable/postgres-persist.js.map +1 -1
  161. package/dist/durable/spine-claim.d.ts +22 -1
  162. package/dist/durable/spine-claim.d.ts.map +1 -1
  163. package/dist/durable/spine-claim.js +54 -3
  164. package/dist/durable/spine-claim.js.map +1 -1
  165. package/dist/errors/http.d.ts.map +1 -1
  166. package/dist/errors/http.js +9 -1
  167. package/dist/errors/http.js.map +1 -1
  168. package/dist/events/dispatcher.d.ts +20 -0
  169. package/dist/events/dispatcher.d.ts.map +1 -1
  170. package/dist/events/dispatcher.js +61 -26
  171. package/dist/events/dispatcher.js.map +1 -1
  172. package/dist/events/pipeline-audit.d.ts +14 -0
  173. package/dist/events/pipeline-audit.d.ts.map +1 -0
  174. package/dist/events/pipeline-audit.js +29 -0
  175. package/dist/events/pipeline-audit.js.map +1 -0
  176. package/dist/events/worker.d.ts +3 -0
  177. package/dist/events/worker.d.ts.map +1 -1
  178. package/dist/events/worker.js +14 -14
  179. package/dist/events/worker.js.map +1 -1
  180. package/dist/execution/capability-error-hook.d.ts +24 -0
  181. package/dist/execution/capability-error-hook.d.ts.map +1 -0
  182. package/dist/execution/capability-error-hook.js +17 -0
  183. package/dist/execution/capability-error-hook.js.map +1 -0
  184. package/dist/execution/capability-executor.d.ts +2 -2
  185. package/dist/execution/capability-executor.d.ts.map +1 -1
  186. package/dist/execution/capability-executor.js +45 -7
  187. package/dist/execution/capability-executor.js.map +1 -1
  188. package/dist/execution/context-factory.d.ts.map +1 -1
  189. package/dist/execution/context-factory.js +9 -1
  190. package/dist/execution/context-factory.js.map +1 -1
  191. package/dist/execution/deferred-flow-service.d.ts.map +1 -1
  192. package/dist/execution/deferred-flow-service.js +7 -0
  193. package/dist/execution/deferred-flow-service.js.map +1 -1
  194. package/dist/execution/index.d.ts +1 -0
  195. package/dist/execution/index.d.ts.map +1 -1
  196. package/dist/execution/index.js.map +1 -1
  197. package/dist/fields/index.d.ts +7 -0
  198. package/dist/fields/index.d.ts.map +1 -1
  199. package/dist/fields/index.js +10 -1
  200. package/dist/fields/index.js.map +1 -1
  201. package/dist/flows/dead-letter.d.ts +18 -1
  202. package/dist/flows/dead-letter.d.ts.map +1 -1
  203. package/dist/flows/dead-letter.js +17 -1
  204. package/dist/flows/dead-letter.js.map +1 -1
  205. package/dist/flows/engine.d.ts +16 -1
  206. package/dist/flows/engine.d.ts.map +1 -1
  207. package/dist/flows/engine.js +218 -29
  208. package/dist/flows/engine.js.map +1 -1
  209. package/dist/flows/flow-service.d.ts.map +1 -1
  210. package/dist/flows/flow-service.js +3 -0
  211. package/dist/flows/flow-service.js.map +1 -1
  212. package/dist/flows/step-executor.d.ts +8 -0
  213. package/dist/flows/step-executor.d.ts.map +1 -1
  214. package/dist/flows/step-executor.js.map +1 -1
  215. package/dist/index.d.ts +4 -4
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js +1 -1
  218. package/dist/index.js.map +1 -1
  219. package/dist/runtime/bootstrap.d.ts +18 -1
  220. package/dist/runtime/bootstrap.d.ts.map +1 -1
  221. package/dist/runtime/bootstrap.js +36 -5
  222. package/dist/runtime/bootstrap.js.map +1 -1
  223. package/dist/runtime/load-extensions.d.ts +2 -1
  224. package/dist/runtime/load-extensions.d.ts.map +1 -1
  225. package/dist/runtime/load-extensions.js +49 -1
  226. package/dist/runtime/load-extensions.js.map +1 -1
  227. package/dist/runtime/register-consumers.d.ts +3 -0
  228. package/dist/runtime/register-consumers.d.ts.map +1 -1
  229. package/dist/runtime/register-consumers.js +27 -6
  230. package/dist/runtime/register-consumers.js.map +1 -1
  231. package/dist/runtime/start-worker-pool.d.ts.map +1 -1
  232. package/dist/runtime/start-worker-pool.js +36 -15
  233. package/dist/runtime/start-worker-pool.js.map +1 -1
  234. package/dist/server/bootstrap.d.ts +42 -16
  235. package/dist/server/bootstrap.d.ts.map +1 -1
  236. package/dist/server/bootstrap.js +91 -21
  237. package/dist/server/bootstrap.js.map +1 -1
  238. package/dist/testing/context.d.ts +2 -0
  239. package/dist/testing/context.d.ts.map +1 -1
  240. package/dist/testing/context.js +8 -3
  241. package/dist/testing/context.js.map +1 -1
  242. package/dist/testing/field-validation.d.ts.map +1 -1
  243. package/dist/testing/field-validation.js +3 -0
  244. package/dist/testing/field-validation.js.map +1 -1
  245. package/dist/types/config.d.ts +13 -0
  246. package/dist/types/config.d.ts.map +1 -1
  247. package/dist/types/context.d.ts +70 -4
  248. package/dist/types/context.d.ts.map +1 -1
  249. package/dist/types/fields.d.ts +6 -0
  250. package/dist/types/fields.d.ts.map +1 -1
  251. package/dist/types/index.d.ts +1 -1
  252. package/dist/types/index.d.ts.map +1 -1
  253. package/dist/types/index.js.map +1 -1
  254. package/dist/types/prompt.d.ts +9 -0
  255. package/dist/types/prompt.d.ts.map +1 -1
  256. package/dist/worker/bootstrap.d.ts +19 -0
  257. package/dist/worker/bootstrap.d.ts.map +1 -1
  258. package/dist/worker/bootstrap.js +156 -84
  259. package/dist/worker/bootstrap.js.map +1 -1
  260. package/instructions/README.md +4 -1
  261. package/instructions/ai-classification.md +132 -0
  262. package/instructions/ai.md +94 -15
  263. package/instructions/cli.md +19 -1
  264. package/instructions/entities.md +3 -1
  265. package/instructions/flows.md +6 -0
  266. package/instructions/framework.md +13 -3
  267. package/instructions/peer-dependencies.md +2 -1
  268. package/instructions/prompts.md +2 -1
  269. package/migrations/durable-tenant/0002_approval_cancellation.sql +3 -0
  270. package/migrations/durable-tenant/meta/_journal.json +7 -0
  271. package/package.json +5 -4
  272. package/dist/ai/__typecheck-fixtures__/legacy-cost-api.d.ts +0 -5
  273. package/dist/ai/__typecheck-fixtures__/legacy-cost-api.d.ts.map +0 -1
  274. package/dist/ai/__typecheck-fixtures__/legacy-cost-api.js +0 -15
  275. package/dist/ai/__typecheck-fixtures__/legacy-cost-api.js.map +0 -1
@@ -6,7 +6,8 @@ export interface AICostRecord {
6
6
  model: string;
7
7
  provider: string;
8
8
  promptName?: string;
9
- operation: 'generate' | 'extract' | 'classify' | 'embed' | 'transcribe' | 'synthesize' | 'transport';
9
+ decisionName?: string;
10
+ operation: 'generate' | 'extract' | 'classify' | 'decide' | 'embed' | 'transcribe' | 'synthesize' | 'transport';
10
11
  /**
11
12
  * True when the call originally streamed but fell back to a non-streaming
12
13
  * retry after the streamed text failed JSON/schema validation. Both the
@@ -29,12 +30,21 @@ export interface AICostRecord {
29
30
  };
30
31
  /** Provider-reported or catalog-estimated USD cost; null when unknown. */
31
32
  cost: number | null;
33
+ /**
34
+ * What dollar budgets charge while `cost` is null: the call's known spend plus, for each
35
+ * attempt whose usage never came back (e.g. the connection dropped after the request was
36
+ * sent), its input estimate and output cap at the model's price. An attempt on a model
37
+ * with no price adds nothing. Not a billed amount, so `cost` stays null.
38
+ */
39
+ estimatedCost?: number;
32
40
  latencyMs: number;
33
41
  tenantId?: string;
34
42
  actor?: string;
35
43
  /**
36
44
  * Whether the underlying provider call completed successfully. Failed rows
37
- * still represent real provider-side spend and count toward budget caps.
45
+ * still represent real provider-side spend and count toward budget caps;
46
+ * a call that never reached the provider, or that it turned away, is
47
+ * recorded at zero cost.
38
48
  * Defaults to 'success' inside `createCostTracker` when the caller does
39
49
  * not set it, preserving pre-0.3.0 behavior for existing consumers.
40
50
  */
@@ -56,6 +66,9 @@ export interface BudgetConfig {
56
66
  * `status` to `'success'` internally.
57
67
  */
58
68
  export type AICostRecordInput = Omit<AICostRecord, 'id' | 'timestamp' | 'status' | 'cost'> & {
69
+ /** Framework-generated identity shared with the persistence hook. */
70
+ id?: string;
71
+ timestamp?: Date;
59
72
  status?: AICostRecord['status'];
60
73
  cost?: number | null;
61
74
  };
@@ -69,6 +82,13 @@ export interface CostTracker {
69
82
  * layers can compute this ahead of time and pre-check shared daily caps.
70
83
  */
71
84
  estimatedCostUsd?: number;
85
+ /**
86
+ * Provider and model the call will use. Unpriced spend (a row with neither a cost nor an
87
+ * estimate) then refuses only calls to that provider and model; a check without them is
88
+ * refused by unpriced spend on any model.
89
+ */
90
+ provider?: string;
91
+ model?: string;
72
92
  }): BudgetCheckResult;
73
93
  getDailyUsage(tenantId?: string): DailyUsage;
74
94
  getRecords(): AICostRecord[];
@@ -18,6 +18,8 @@ export interface ModelRate {
18
18
  cachedInputPerMTok?: number;
19
19
  /** Above this inclusive input-token boundary, charge 2× input/cache and 1.5× output. */
20
20
  longContextThreshold?: number;
21
+ /** Published rates above `longContextThreshold`, replacing the 2× / 1.5× rule. */
22
+ longContextRates?: Pick<ModelRate, 'inputPerMTok' | 'outputPerMTok' | 'cachedInputPerMTok'>;
21
23
  /**
22
24
  * Capability classification. Optional on the type for backward compat —
23
25
  * existing consumers that destructure only the rate fields keep working —
@@ -48,9 +50,13 @@ export declare function calculateModelCost(inputTokens: number, outputTokens: nu
48
50
  *
49
51
  * Pricing adjustments applied:
50
52
  * - **Cached input tokens**: published per-model rate, defaulting to 0.1× input.
51
- * - **Cache write tokens**: charged at 1.25× the base input rate (Anthropic 5-min cache).
53
+ * - **Cache write tokens**: 1.25× the base input rate for Claude and for OpenAI GPT-5.6 and
54
+ * later, the base input rate for earlier OpenAI models (`cacheWriteMultiplier`). Both providers
55
+ * count cache writes inside the input tokens, so they are priced once.
52
56
  * - **Long context premium**: for Claude Sonnet 4 / 4.5, when total input exceeds
53
- * 200K tokens, or GPT-5.6 Sol over 272K, charge 2× input/cache and 1.5× output.
57
+ * 200K tokens, or OpenAI models with a `longContextThreshold` (GPT-5.4 to GPT-6)
58
+ * over 272K, charge 2× input/cache and 1.5× output. Claude Haiku 5.5 over 100K uses
59
+ * its published `longContextRates`.
54
60
  *
55
61
  * Returns undefined for unknown/unsupported models; explicitly free adapters may report zero.
56
62
  */
@@ -0,0 +1,84 @@
1
+ /**
2
+ * One schema that requires what `left` and `right` both require. Keywords only one side has are
3
+ * kept; keywords both have are combined where JSON Schema allows it (`type` and `enum`
4
+ * intersected, `properties` and `required` joined, `minItems` the larger, `items` and union
5
+ * branches merged in turn); where it does not (two different patterns or formats), the first is
6
+ * kept and the other is named in the description. Annotations (`title`, `default`) keep the
7
+ * first; descriptions are joined. Also used by `zodToProviderJsonSchema` to fold a union's only
8
+ * reachable branch into the node that holds it.
9
+ */
10
+ export declare function mergeTwoSchemas(left: Record<string, unknown>, right: Record<string, unknown>): Record<string, unknown>;
11
+ /**
12
+ * The schema as strict mode is sent it, at this node: `allOf` merged, union siblings distributed.
13
+ * `zodToProviderJsonSchema` merges an intersection of objects with it too, for every provider.
14
+ */
15
+ export declare function structuralSchema(node: Record<string, unknown>): Record<string, unknown>;
16
+ /**
17
+ * Project a provider-neutral structured-output schema (from `zodToProviderJsonSchema`) onto
18
+ * OpenAI's strict subset: every object lists all of its properties in `required`, and each
19
+ * property that was optional also accepts `null` (unless it already did). A string `format`
20
+ * outside `OPENAI_STRICT_STRING_FORMATS` (such as `uri`) is removed and named in the
21
+ * description, and so is a `default` (`dropDefault`). Every `allOf` is merged into one schema
22
+ * (`mergeAllOf`), since strict mode has no `allOf`. Nested objects, array items and every `anyOf`
23
+ * branch are projected too.
24
+ * The input is not mutated — `createAIService` caches it and shares it across providers.
25
+ */
26
+ export declare function toOpenAIStrictJsonSchema(schema: Record<string, unknown>): Record<string, unknown>;
27
+ /** The property a structured output whose root is not an object is sent and answered under. */
28
+ export declare const OPENAI_STRICT_OUTPUT_ENVELOPE_KEY = "value";
29
+ export interface OpenAIStrictOutputSchema {
30
+ /** The schema the request sends: `toOpenAIStrictJsonSchema(schema)`, in the envelope if needed. */
31
+ schema: Record<string, unknown>;
32
+ /** True when the answer comes back as `{"value": <answer>}` and has to be unwrapped. */
33
+ enveloped: boolean;
34
+ }
35
+ /**
36
+ * The schema an OpenAI strict structured output sends for `schema`. An object root goes as
37
+ * `toOpenAIStrictJsonSchema(schema)`. Any other root (`z.array(...)` — `classify()`, an
38
+ * `extract()` or prompt output that is an array, a union, an enum, a number, a nullable object)
39
+ * goes as the single required property `value` of an object, because OpenAI refuses a schema
40
+ * whose root is not an object; the adapter unwraps the answer, so callers never see the envelope.
41
+ */
42
+ export declare function toOpenAIStrictOutputSchema(schema: Record<string, unknown>): OpenAIStrictOutputSchema;
43
+ /**
44
+ * The answer inside an enveloped strict output (`{"value": [...]}` → `[...]`), as JSON text. An
45
+ * answer cut off inside the envelope's value (`max_tokens`) comes back as the part of the value
46
+ * it holds (`{"value":[{"a":"x"` → `[{"a":"x"`), as a stream of it would, so an
47
+ * `AIIncompleteOutputError`'s `partialText` does not show the envelope. Any other text (not the
48
+ * envelope, not JSON, or a complete value with something after it) comes back unchanged, for
49
+ * validation to report.
50
+ */
51
+ export declare function unwrapOpenAIStrictOutput(content: string): string;
52
+ export interface OpenAIStrictOutputStreamUnwrapper {
53
+ /** The part of a streamed text delta that belongs to the answer (may be empty). */
54
+ push(delta: string): string;
55
+ /**
56
+ * Once the stream has ended: text held back because it looked like the envelope's opening, or
57
+ * nothing if the whole opening `{"value":` had arrived (then it was the envelope, cut off
58
+ * before its value).
59
+ */
60
+ end(): string;
61
+ }
62
+ /**
63
+ * `unwrapOpenAIStrictOutput` for a streamed answer: the opening `{"value":` is held back until it
64
+ * is complete, the value is passed on as it arrives, and what follows it (the closing `}`) is
65
+ * dropped. A stream that does not open with the envelope is passed on unchanged, so validation
66
+ * sees exactly what the model wrote.
67
+ */
68
+ export declare function createOpenAIStrictOutputStreamUnwrapper(): OpenAIStrictOutputStreamUnwrapper;
69
+ /**
70
+ * Undo `toOpenAIStrictJsonSchema` on a parsed answer: drop a property whose value is `null` when
71
+ * `schema` (the provider-neutral schema the request carried) marks it optional and its own schema
72
+ * does not admit `null`. A property that admits `null` (`.nullable()`, `.nullish()`) keeps it.
73
+ *
74
+ * Union branches are chosen deterministically: the first branch the answer already satisfies
75
+ * keeps it unchanged; otherwise the first branch it satisfies once that branch's optional nulls
76
+ * are dropped. An answer that already satisfies `schema` comes back unchanged, so providers that
77
+ * honour the optional properties as they are (Anthropic, Bedrock) are unaffected. An answer that
78
+ * fits no branch is left for the Zod output schema to report.
79
+ *
80
+ * An `allOf` is read as the one schema strict mode was sent (merged, with an object's properties
81
+ * moved into the branches of a union it is intersected with), so an intersection's optionals are
82
+ * found whichever member declares them.
83
+ */
84
+ export declare function restoreOmittedOptionalProperties(value: unknown, rawSchema: unknown): unknown;
@@ -71,6 +71,26 @@ export type ChatMessage = {
71
71
  toolCallId: string;
72
72
  name: string;
73
73
  };
74
+ /**
75
+ * Per-section prompt-cache controls for providers that require explicit cache
76
+ * marks (Anthropic `cache_control`, Bedrock Converse `cachePoint`).
77
+ *
78
+ * Omitted fields are treated as `false`. Prefer `cache: true` for the common
79
+ * case (system + tools).
80
+ */
81
+ export interface AICacheConfig {
82
+ /** Cache the system prompt / instructions. */
83
+ system?: boolean;
84
+ /** Cache tool definitions (mark on the last tool). */
85
+ tools?: boolean;
86
+ /** Cache conversation history (mark on the last message). */
87
+ messages?: boolean;
88
+ }
89
+ /**
90
+ * Prompt-caching option. `true` enables system + tools (not messages).
91
+ * OpenAI ignores this — it caches long prompts automatically.
92
+ */
93
+ export type AIPromptCacheOption = boolean | AICacheConfig;
74
94
  export interface ProviderRequest {
75
95
  /** System prompt / instructions */
76
96
  system?: string;
@@ -105,15 +125,23 @@ export interface ProviderRequest {
105
125
  responseSchema?: Record<string, unknown>;
106
126
  /** Transport used for provider-side structured outputs. Defaults to response_format. */
107
127
  structuredOutputTransport?: 'response_format' | 'tool';
108
- /** Request timeout in milliseconds (default: 120_000) */
128
+ /**
129
+ * How long one HTTP attempt of this request may take, in milliseconds, from sending it to the
130
+ * last byte of the answer (streamed answers included); the adapter's `requestTimeout`
131
+ * (default 120_000) when unset. A whole number from 1 to 2_147_483_647. Each retry of a
132
+ * 408/429/5xx answer gets its own. A request this timeout ends fails with a non-retryable
133
+ * `ProviderAPIError` carrying `timeoutMs`.
134
+ */
109
135
  timeout?: number;
110
136
  /**
111
137
  * External AbortSignal (e.g. `ctx.signal`). When fired, the in-flight
112
138
  * fetch(es) for this request abort immediately. Combined with the internal
113
139
  * timeout signal via `AbortSignal.any([...])`, so whichever triggers first
114
- * wins.
140
+ * wins: a caller's abort is rethrown as it was raised.
115
141
  */
116
142
  signal?: AbortSignal;
143
+ /** Trusted host-supplied propagation headers. Provider adapters never accept credential overrides. */
144
+ transportHeaders?: Readonly<Record<string, string>>;
117
145
  /**
118
146
  * Deterministic sampling seed. OpenAI-compatible providers (including xAI
119
147
  * Grok) honor this parameter: identical `{seed, temperature, model, prompt}`
@@ -128,9 +156,14 @@ export interface ProviderRequest {
128
156
  toolChoice?: AIToolChoice;
129
157
  /** Tool-execution options (e.g. disable parallel tool calls). */
130
158
  toolExecution?: AIToolExecutionOptions;
159
+ /**
160
+ * Explicit prompt caching for Anthropic / Bedrock. OpenAI ignores this
161
+ * (automatic caching). `true` caches system + tools; pass an object for
162
+ * per-section control. Shorter prompts may not meet provider minima — the
163
+ * request still succeeds without a cache write.
164
+ */
165
+ cache?: AIPromptCacheOption;
131
166
  }
132
- /** Compose a request's optional user signal with a timeout, returning a single AbortSignal. */
133
- export declare function combineRequestSignals(userSignal: AbortSignal | undefined, timeoutMs: number): AbortSignal;
134
167
  export interface ProviderResponse {
135
168
  content: string;
136
169
  model: string;
@@ -153,8 +186,18 @@ export interface TokenUsage {
153
186
  totalTokens: number;
154
187
  /** Tokens served from provider cache (charged at reduced rate). */
155
188
  cachedInputTokens?: number;
156
- /** Tokens written to provider cache (charged at elevated rate — Anthropic only). */
157
- cacheWriteTokens?: number /** Tokens the model spent reasoning, when the provider reports the split (OpenAI o-series / gpt-5). */;
189
+ /**
190
+ * Tokens written to the provider's prompt cache, counted inside `inputTokens` (Anthropic
191
+ * `cache_creation_input_tokens`; OpenAI `cache_write_tokens` on Chat Completions and the
192
+ * Responses API). Priced at 1.25× input for Claude and OpenAI GPT-5.6 and later, at the input
193
+ * rate for earlier OpenAI models, which bill no extra for them.
194
+ */
195
+ cacheWriteTokens?: number;
196
+ /**
197
+ * Tokens the model spent reasoning, when the provider reports the split (OpenAI reasoning
198
+ * models, on Chat Completions and the Responses API). Counted inside `outputTokens`, which is
199
+ * what is priced, so never added to a cost again.
200
+ */
158
201
  reasoningTokens?: number;
159
202
  }
160
203
  export interface ProviderStreamEvent {
@@ -169,6 +212,13 @@ export interface ProviderStreamEvent {
169
212
  toolCalls?: AIToolCall[];
170
213
  /** Error message (for error events) */
171
214
  error?: string;
215
+ /**
216
+ * The error an adapter caught and reported as an `error` event (e.g. the fetch that never
217
+ * connected, or a 4xx answer). The AI service reads it to tell a request the provider never
218
+ * took, which costs nothing, from one that may have been billed; it is not passed on to
219
+ * `streamGenerate` callers.
220
+ */
221
+ cause?: unknown;
172
222
  /**
173
223
  * Optional USD cost on `done` (and optionally `usage`) events. When set,
174
224
  * `createAIService` prefers this over `calculateModelCost`.
@@ -178,6 +228,17 @@ export interface ProviderStreamEvent {
178
228
  export interface EmbeddingRequest {
179
229
  texts: string[];
180
230
  model?: string;
231
+ /**
232
+ * How long one HTTP attempt of this request may take, in milliseconds; the adapter's
233
+ * `requestTimeout` (default 120_000) when unset. Same rules as `ProviderRequest.timeout`.
234
+ */
235
+ timeout?: number;
236
+ /**
237
+ * External AbortSignal (e.g. `ctx.signal`, passed on by `ctx.ai.retrieve` and the RAG
238
+ * pipeline). When it fires the in-flight embedding request(s) abort; as with
239
+ * `ProviderRequest.signal`, the caller's abort is rethrown as raised.
240
+ */
241
+ signal?: AbortSignal;
181
242
  }
182
243
  export interface EmbeddingResponse {
183
244
  embeddings: number[][];
@@ -277,15 +338,38 @@ export declare class ProviderAPIError extends Error {
277
338
  readonly statusCode?: number;
278
339
  readonly retryable: boolean;
279
340
  readonly attempts: number;
341
+ /**
342
+ * Set when the request's own timeout ended it (`ProviderRequest.timeout`, a prompt's
343
+ * `model.timeoutMs`, or the adapter's `requestTimeout`): the limit that was reached, in
344
+ * milliseconds. Such a failure is not retryable — the provider may have billed the work, and
345
+ * asking again with the same limit usually ends the same way.
346
+ */
347
+ readonly timeoutMs?: number;
280
348
  constructor(args: {
281
349
  providerName: string;
282
350
  message: string;
283
351
  retryable: boolean;
284
352
  attempts: number;
285
353
  statusCode?: number;
354
+ timeoutMs?: number;
355
+ cause?: unknown;
286
356
  });
287
357
  }
358
+ /**
359
+ * True for a provider HTTP failure from any adapter: a `ProviderAPIError` instance, or an error
360
+ * of the same shape built by an adapter package with its own copy of core (`@plumbus/ai-bedrock`).
361
+ */
288
362
  export declare function isProviderAPIError(value: unknown): value is ProviderAPIError;
363
+ /**
364
+ * True when the request's own timeout ended it (`timeoutMs` on the call, a prompt override, the
365
+ * prompt's `model.timeoutMs`, or the adapter's `requestTimeout`): a `ProviderAPIError` carrying
366
+ * the limit reached as `timeoutMs`. Not retryable; raise the timeout rather than asking again.
367
+ */
368
+ export declare function isProviderTimeoutError(value: unknown): value is ProviderAPIError & {
369
+ readonly timeoutMs: number;
370
+ };
371
+ /** Throws `AIInvalidRequestError` (before any I/O) unless `timeoutMs` is a usable request timeout. */
372
+ export declare function assertRequestTimeout(timeoutMs: number): void;
289
373
  /** Normalize a provider-specific finish/stop reason into the framework's vocabulary. */
290
374
  export declare function normalizeFinishReason(raw: string | undefined): 'stop' | 'length' | 'refusal' | 'tool_calls' | 'other';
291
375
  export interface OpenAIAdapterConfig {
@@ -1,9 +1,11 @@
1
+ import type { DecisionRuntimeConfig } from '@plumbus/ai-decision/types';
1
2
  import type { AICostContext, AIService } from '../types/context.js';
2
3
  import type { AIReasoningConfig, PromptDefinition, ReasoningEffort } from '../types/prompt.js';
3
4
  import type { AICostRecord, CostTracker } from './cost-tracker.js';
4
5
  import type { AIExplainabilityTracker } from './explainability.js';
6
+ import { type PromptOverrideMap } from './prompt-overrides.js';
5
7
  import type { PromptRegistry } from './prompt-registry.js';
6
- import { type AIProviderAdapter } from './provider.js';
8
+ import { type AIPromptCacheOption, type AIProviderAdapter } from './provider.js';
7
9
  import type { RAGPipeline } from './rag/pipeline.js';
8
10
  import type { AISecurityConfig } from './security.js';
9
11
  import { type ValidationRetryConfig } from './validation.js';
@@ -15,11 +17,39 @@ export type { AICostContext };
15
17
  * to their own ledger (e.g. an app-owned per-project cost ledger).
16
18
  */
17
19
  export type OnAICostRecorded = (record: AICostRecord, costContext?: AICostContext) => Promise<void> | void;
20
+ export type AIProviderOperation = 'generate' | 'stream' | 'extract' | 'classify';
21
+ /** Privacy-sensitive call context visible only to trusted server extension hooks. */
22
+ export interface AIProviderCallContext {
23
+ readonly provider: string;
24
+ readonly operation: AIProviderOperation;
25
+ readonly tenantId?: string;
26
+ readonly actor?: string;
27
+ readonly correlationId?: string;
28
+ readonly costContext?: AICostContext;
29
+ }
30
+ export interface AIProviderSpan extends AIProviderCallContext {
31
+ readonly startedAt: string;
32
+ readonly durationMs: number;
33
+ readonly status: 'ok' | 'error';
34
+ readonly traceparent?: string;
35
+ readonly errorType?: string;
36
+ }
37
+ export interface AIProviderConcurrencyConfig {
38
+ /** Immediate per-scope ceiling. Saturation refuses; it never queues or hangs. */
39
+ readonly maxConcurrentCalls: number;
40
+ /** Defaults to provider + tenant + costContext.serviceArea (the package/service boundary). */
41
+ readonly resolveScope?: (context: AIProviderCallContext) => string;
42
+ }
43
+ interface AIProviderConcurrencyState {
44
+ readonly active: Map<string, number>;
45
+ }
18
46
  export interface AIServiceConfig {
19
47
  /** Multiple provider adapters keyed by name (e.g. "openai", "anthropic") */
20
48
  providers: Record<string, AIProviderAdapter>;
21
49
  /** Which provider to use when a prompt doesn't specify one */
22
50
  defaultProvider: string;
51
+ /** Explicit decision providers and named definitions; independent of text providers. */
52
+ decisions?: DecisionRuntimeConfig;
23
53
  promptRegistry?: PromptRegistry;
24
54
  /**
25
55
  * Prompt definitions to register for this service. Convenience for hosts
@@ -37,6 +67,11 @@ export interface AIServiceConfig {
37
67
  defaultModel?: string /** Per-prompt model/provider overrides from config/env */;
38
68
  /** Enable provider-side constrained decoding for JSON-output prompt schemas. */
39
69
  enableStrictStructuredOutputs?: boolean;
70
+ /**
71
+ * Default prompt-caching preference for Anthropic / Bedrock. Per-call
72
+ * `cache` on generate / streamGenerate overrides this. OpenAI ignores it.
73
+ */
74
+ cache?: AIPromptCacheOption;
40
75
  promptOverrides?: Record<string, {
41
76
  provider?: string;
42
77
  model?: string;
@@ -45,10 +80,13 @@ export interface AIServiceConfig {
45
80
  reasoning?: AIReasoningConfig;
46
81
  /** @deprecated Use `reasoning`. */
47
82
  reasoningEffort?: ReasoningEffort;
83
+ /** Provider request timeout in ms; see `ModelConfig.timeoutMs`. */
84
+ timeoutMs?: number;
48
85
  }> /** Budget enforcement settings */;
49
86
  budget?: {
50
87
  tenantId?: string;
51
88
  actor?: string;
89
+ correlationId?: string;
52
90
  };
53
91
  /**
54
92
  * Optional framework hook fired after every AI call completes and the
@@ -57,6 +95,20 @@ export interface AIServiceConfig {
57
95
  * in the hook are caught and logged to stderr but never propagate.
58
96
  */
59
97
  onAICostRecorded?: OnAICostRecorded;
98
+ /** Per-tenant/provider/package admission applied around each real provider attempt. */
99
+ providerConcurrency?: AIProviderConcurrencyConfig;
100
+ /** Trusted propagation headers, resolved once per provider attempt. */
101
+ resolveProviderHeaders?: (context: AIProviderCallContext) => Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
102
+ /** Best-effort provider client span export hook. Hook failures never fail the model call. */
103
+ onProviderSpan?: (span: AIProviderSpan) => void | Promise<void>;
104
+ /** @internal Shared by services rebound with `withContext`. */
105
+ _providerConcurrencyState?: AIProviderConcurrencyState;
106
+ /**
107
+ * @internal Per-prompt overrides from `resolveAiOverrides`, replaced before each call by
108
+ * `wrapAIServiceWithDynamicOverrides`. Merged over `promptOverrides` field by field
109
+ * (see `resolvePromptOverride`).
110
+ */
111
+ _dynamicPromptOverrides?: PromptOverrideMap;
60
112
  }
61
113
  /** Convenience: create config from a single provider (backward compat) */
62
114
  export declare function singleProviderConfig(provider: AIProviderAdapter, rest?: Omit<AIServiceConfig, 'providers' | 'defaultProvider'>): AIServiceConfig;
@@ -1 +1 @@
1
-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