@arnilo/prism 0.0.96 → 0.1.0

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 (203) hide show
  1. package/CHANGELOG.md +285 -2
  2. package/README.md +17 -3
  3. package/dist/agent-definitions.js +2 -3
  4. package/dist/agent-event-source.d.ts +11 -0
  5. package/dist/agent-event-source.js +512 -0
  6. package/dist/agent-loops.d.ts +5 -0
  7. package/dist/agent-loops.js +99 -14
  8. package/dist/agent-run-lifecycle.d.ts +5 -2
  9. package/dist/agent-run-lifecycle.js +18 -2
  10. package/dist/agent-run-state.d.ts +27 -1
  11. package/dist/agent-run-state.js +113 -7
  12. package/dist/agents.d.ts +3 -1
  13. package/dist/agents.js +1255 -129
  14. package/dist/artifacts.d.ts +132 -0
  15. package/dist/artifacts.js +44 -0
  16. package/dist/cache-helpers.js +18 -9
  17. package/dist/checkpoints.d.ts +4 -0
  18. package/dist/checkpoints.js +17 -9
  19. package/dist/cli-init.js +3 -7
  20. package/dist/cli-runner.d.ts +2 -6
  21. package/dist/cli-runner.js +71 -33
  22. package/dist/compaction.js +5 -4
  23. package/dist/config.js +7 -4
  24. package/dist/content.js +26 -24
  25. package/dist/context-budget.d.ts +67 -0
  26. package/dist/context-budget.js +288 -0
  27. package/dist/contracts.d.ts +590 -8
  28. package/dist/contracts.js +142 -1
  29. package/dist/contribution-parsing.js +6 -2
  30. package/dist/contributions.d.ts +2 -0
  31. package/dist/contributions.js +3 -0
  32. package/dist/conversations.d.ts +50 -0
  33. package/dist/conversations.js +98 -0
  34. package/dist/credentials.d.ts +22 -2
  35. package/dist/credentials.js +18 -3
  36. package/dist/devices.d.ts +94 -0
  37. package/dist/devices.js +138 -0
  38. package/dist/event-multiplexer.js +18 -4
  39. package/dist/extensions.d.ts +18 -1
  40. package/dist/extensions.js +79 -6
  41. package/dist/feedback.js +12 -10
  42. package/dist/guardrails.d.ts +1 -1
  43. package/dist/guardrails.js +26 -17
  44. package/dist/identity.d.ts +92 -0
  45. package/dist/identity.js +265 -0
  46. package/dist/index.d.ts +94 -72
  47. package/dist/index.js +48 -36
  48. package/dist/input.d.ts +10 -1
  49. package/dist/input.js +152 -52
  50. package/dist/instruction-injection.d.ts +1 -1
  51. package/dist/middleware.js +9 -1
  52. package/dist/models.d.ts +2 -0
  53. package/dist/models.js +3 -0
  54. package/dist/node/agent-definitions.js +16 -8
  55. package/dist/node/contribution-discovery.d.ts +1 -2
  56. package/dist/node/contribution-discovery.js +3 -3
  57. package/dist/node/session-store-jsonl.js +13 -7
  58. package/dist/node/settings.d.ts +1 -1
  59. package/dist/node/settings.js +1 -1
  60. package/dist/node/system-project-prompts.js +2 -4
  61. package/dist/node/trust.js +1 -1
  62. package/dist/persistence-lifecycle.d.ts +103 -0
  63. package/dist/persistence-lifecycle.js +202 -0
  64. package/dist/provider-events.d.ts +1 -0
  65. package/dist/provider-events.js +6 -1
  66. package/dist/provider-request-policy.js +3 -4
  67. package/dist/providers/media.d.ts +1 -1
  68. package/dist/providers/openai-compatible.d.ts +46 -1
  69. package/dist/providers/openai-compatible.js +123 -53
  70. package/dist/providers/openai-primitives.js +10 -7
  71. package/dist/providers/transport.d.ts +6 -0
  72. package/dist/providers/transport.js +21 -0
  73. package/dist/providers.d.ts +2 -0
  74. package/dist/providers.js +3 -0
  75. package/dist/redaction.d.ts +1 -0
  76. package/dist/redaction.js +26 -9
  77. package/dist/resources.d.ts +2 -2
  78. package/dist/resources.js +2 -2
  79. package/dist/retry.d.ts +5 -0
  80. package/dist/retry.js +8 -1
  81. package/dist/rpc.js +55 -11
  82. package/dist/run-ledger.d.ts +6 -0
  83. package/dist/run-ledger.js +16 -13
  84. package/dist/run-limits.js +49 -10
  85. package/dist/secure-agent.js +8 -2
  86. package/dist/security.js +7 -2
  87. package/dist/session-stores.d.ts +7 -2
  88. package/dist/session-stores.js +195 -21
  89. package/dist/skill-disclosure.d.ts +35 -0
  90. package/dist/skill-disclosure.js +101 -0
  91. package/dist/skill-load.d.ts +25 -0
  92. package/dist/skill-load.js +112 -0
  93. package/dist/structured-output.d.ts +5 -1
  94. package/dist/structured-output.js +20 -2
  95. package/dist/system-prompts.js +7 -2
  96. package/dist/testing/agent-event-source-conformance.d.ts +4 -0
  97. package/dist/testing/agent-event-source-conformance.js +54 -0
  98. package/dist/testing/compaction-conformance.js +5 -1
  99. package/dist/testing/extension-conformance.js +15 -3
  100. package/dist/testing/feedback.d.ts +1 -3
  101. package/dist/testing/feedback.js +1 -1
  102. package/dist/testing/persistence-schema.d.ts +2 -2
  103. package/dist/testing/persistence-schema.js +280 -35
  104. package/dist/testing/provider-conformance.js +3 -3
  105. package/dist/testing/run-ledger-conformance.js +1 -1
  106. package/dist/testing/session-store-conformance.d.ts +6 -0
  107. package/dist/testing/session-store-conformance.js +37 -2
  108. package/dist/testing/tool-conformance.js +30 -5
  109. package/dist/testing/tool-effect-store-conformance.d.ts +9 -0
  110. package/dist/testing/tool-effect-store-conformance.js +85 -0
  111. package/dist/thinking.js +4 -1
  112. package/dist/tool-effects.d.ts +15 -0
  113. package/dist/tool-effects.js +352 -0
  114. package/dist/tool-result-fold.d.ts +40 -0
  115. package/dist/tool-result-fold.js +176 -0
  116. package/dist/tools.d.ts +8 -3
  117. package/dist/tools.js +248 -13
  118. package/docs/0.1.0-readiness.md +202 -0
  119. package/docs/a2a.md +33 -2
  120. package/docs/acp.md +126 -0
  121. package/docs/ag-ui-adoption.md +77 -0
  122. package/docs/ag-ui.md +225 -0
  123. package/docs/agent-events.md +34 -3
  124. package/docs/agent-identity.md +144 -0
  125. package/docs/agent-loops.md +17 -2
  126. package/docs/agent-session-runtime.md +21 -4
  127. package/docs/browser-automation.md +5 -0
  128. package/docs/caveman.md +129 -0
  129. package/docs/cli-rpc.md +3 -6
  130. package/docs/coding-agent-tools.md +229 -25
  131. package/docs/coding-security.md +77 -11
  132. package/docs/compaction-and-retry.md +5 -2
  133. package/docs/compaction-llm.md +20 -1
  134. package/docs/compaction-observational-memory.md +52 -8
  135. package/docs/context-and-skills.md +94 -7
  136. package/docs/contribution-registries.md +1 -0
  137. package/docs/conversations.md +135 -0
  138. package/docs/credential-storage.md +34 -1
  139. package/docs/credentials-and-redaction.md +11 -1
  140. package/docs/database-persistence.md +27 -7
  141. package/docs/device-adapters.md +97 -0
  142. package/docs/enterprise-postgres-state.md +178 -0
  143. package/docs/evaluations.md +14 -1
  144. package/docs/extensions.md +4 -1
  145. package/docs/forge-integration.md +113 -0
  146. package/docs/guardrails.md +16 -2
  147. package/docs/host-security.md +35 -4
  148. package/docs/index.md +69 -37
  149. package/docs/input-and-prompt-assembly.md +8 -7
  150. package/docs/language-intelligence.md +162 -0
  151. package/docs/mcp-tools.md +62 -5
  152. package/docs/middleware-hooks.md +2 -2
  153. package/docs/migration.md +423 -2
  154. package/docs/model-routing.md +111 -0
  155. package/docs/multimodal-content.md +8 -5
  156. package/docs/node-jsonl-session-store.md +1 -1
  157. package/docs/observability.md +2 -0
  158. package/docs/openapi-tools.md +56 -0
  159. package/docs/performance.md +282 -0
  160. package/docs/policy-and-audit.md +171 -0
  161. package/docs/ponytail.md +127 -0
  162. package/docs/postgres-persistence.md +8 -4
  163. package/docs/process-sessions.md +147 -0
  164. package/docs/provider-caching.md +13 -1
  165. package/docs/provider-conformance.md +29 -5
  166. package/docs/provider-packages.md +43 -2
  167. package/docs/provider-request-policies.md +2 -0
  168. package/docs/providers/ai-sdk.md +24 -7
  169. package/docs/providers/alibaba.md +179 -0
  170. package/docs/providers/anthropic.md +93 -0
  171. package/docs/providers/azure.md +74 -0
  172. package/docs/providers/bedrock.md +72 -0
  173. package/docs/providers/google.md +89 -0
  174. package/docs/providers/ollama.md +166 -0
  175. package/docs/providers/openai-compatible.md +31 -2
  176. package/docs/providers/openai.md +24 -5
  177. package/docs/providers/openrouter.md +2 -0
  178. package/docs/providers/vertex.md +71 -0
  179. package/docs/public-contracts.md +61 -4
  180. package/docs/rag.md +41 -12
  181. package/docs/release-and-install.md +323 -206
  182. package/docs/resource-loading.md +3 -0
  183. package/docs/runs-and-usage.md +3 -0
  184. package/docs/server.md +44 -6
  185. package/docs/session-store-conformance.md +2 -0
  186. package/docs/session-stores.md +41 -2
  187. package/docs/sqlite-persistence.md +11 -3
  188. package/docs/structured-output.md +7 -1
  189. package/docs/supervisors.md +8 -0
  190. package/docs/tool-effects.md +95 -0
  191. package/docs/tools.md +5 -0
  192. package/docs/work-artifacts-and-review.md +102 -0
  193. package/docs/work-connectors.md +32 -0
  194. package/docs/work-tools.md +137 -0
  195. package/docs/workflows.md +6 -0
  196. package/docs/working-and-semantic-memory.md +40 -7
  197. package/package.json +30 -8
  198. package/templates/init/providers.json +22 -0
  199. package/docs/review-coverage-2026-07-14.md +0 -260
  200. package/docs/review-coverage-2026-07-15.md +0 -193
  201. package/docs/review-coverage-2026-07-17-provider-validation.md +0 -192
  202. package/docs/review-coverage-2026-07-19-phase-3.md +0 -174
  203. package/docs/review-coverage-2026-07-20-phase-4.md +0 -175
@@ -0,0 +1,89 @@
1
+ # Google provider package
2
+
3
+ ## What it does
4
+
5
+ `@arnilo/prism-provider-google` is the first-party Gemini `generateContent` / `streamGenerateContent` provider for Prism (`POST /v1beta/models/{model}:streamGenerateContent?alt=sse`). Setup is side-effect-free: no network, env scan, or keychain lookup during import/setup. Uses native `fetch` + SSE — no `@google/genai` runtime dependency.
6
+
7
+ ## When to use it
8
+
9
+ Use for first-party Gemini Developer API coding-host semantics (function calling, multimodal `inlineData`, thinking, usage, abort). Prefer this over the AI SDK escape hatch when Gemini is a primary host.
10
+
11
+ Do **not** use for Vertex enterprise identity (deferred to 0.0.13+), as a substitute for Anthropic Messages, or Gemini CLI OAuth/credential-file/token import. This package is API-key-only.
12
+
13
+ ## Inputs / request
14
+
15
+ ```ts
16
+ import {
17
+ createGoogleProviderPackage,
18
+ createGoogleGenerateContentProvider,
19
+ listGoogleModels,
20
+ defineGoogleModel,
21
+ } from "@arnilo/prism-provider-google";
22
+
23
+ createGoogleProviderPackage(options?: GoogleProviderPackageOptions): ProviderPackage
24
+ createGoogleGenerateContentProvider(options?): AIProvider
25
+ listGoogleModels(options?: ListGoogleModelsOptions): Promise<ModelConfig[]>
26
+ ```
27
+
28
+ | Field | Type | Purpose |
29
+ | --- | --- | --- |
30
+ | `apiKey` | `CredentialValueSource` | Host-owned Google/Gemini API key (late-bound). |
31
+ | `fetch` | `typeof fetch` | Optional fetch for tests/hosts. |
32
+ | `baseUrl` | `string` | Override default Gemini REST base. |
33
+ | `id` | `string` | Provider id (default `google`). |
34
+ | `userAgent` | `string` | Optional User-Agent. |
35
+ | `models` | `readonly ModelConfig[]` | Override featured offline models. |
36
+
37
+ Featured offline aliases include `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-2.5-flash-lite`, and `gemini-3.5-flash` (see package README for the live curated list). Caller-gated discovery: `listGoogleModels()` — never during setup. Model ids may arrive prefixed with `models/`; Prism strips the prefix.
38
+
39
+ ## Outputs / response / events
40
+
41
+ | Surface | Behavior |
42
+ | --- | --- |
43
+ | Stream | Prism text, thinking when present, **complete** `tool_call` events (Gemini does not stream argument deltas), usage, `done`, redacted `error`. |
44
+ | Cache | No Anthropic-style `cache_control`; Gemini implicit caching is not exposed as Prism breakpoints in 0.0.11. |
45
+ | Multimodal | `inlineData` parts with MIME + base64; capability checks fail closed for unsupported modalities. |
46
+ | Auth | `api_key`; provider-owned `content-type` + `x-goog-api-key` win over caller headers. No OAuth descriptor or Gemini CLI subscription adapter is registered. |
47
+
48
+ ## Request/response example
49
+
50
+ ```json
51
+ {
52
+ "contents": [{ "role": "user", "parts": [{ "text": "Hello" }] }],
53
+ "tools": [{ "functionDeclarations": [{ "name": "lookup", "parameters": { "type": "object" } }] }]
54
+ }
55
+ ```
56
+
57
+ ## Implementation example
58
+
59
+ ```ts
60
+ import { createGoogleProviderPackage, listGoogleModels } from "@arnilo/prism-provider-google";
61
+
62
+ api.registerProviderPackage(createGoogleProviderPackage({ apiKey: hostKey }));
63
+
64
+ const models = await listGoogleModels({ apiKey: hostKey });
65
+ api.registerProviderPackage(createGoogleProviderPackage({ apiKey: hostKey, models }));
66
+ ```
67
+
68
+ ## Extension and configuration notes
69
+
70
+ - Register via `defineProviderPackage` / host registries; no package auto-discovery.
71
+ - AI SDK remains an escape hatch, not the primary Google path.
72
+ - Live smoke: `PRISM_LIVE_PROVIDER_TESTS=1` + `GOOGLE_API_KEY` or `GEMINI_API_KEY`.
73
+ - Vertex / enterprise identity stays out of 0.0.11.
74
+ - Gemini CLI says third-party software accessing its backend through Gemini CLI OAuth violates applicable terms, and its FAQ directs third-party coding agents to Vertex AI or Google AI Studio API keys ([terms](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/tos-privacy.md), [FAQ](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/faq.md)). Prism therefore has no Gemini CLI OAuth API or token-import shortcut.
75
+
76
+ ## Security and performance notes
77
+
78
+ - No network during import/setup/default tests; credentials host-owned and late-bound.
79
+ - Provider-owned auth headers cannot be overridden by caller headers.
80
+ - Media bounds reuse shared provider media helpers; tool args arrive complete per chunk (no partial JSON reconstruction required).
81
+ - Offline conformance: `@arnilo/prism/testing/provider-conformance`.
82
+
83
+ ## Related APIs
84
+
85
+ - [Google Vertex AI](vertex.md): enterprise ADC/workload-identity package (separate from this consumer API-key package).
86
+ - [Provider packages](../provider-packages.md): package setup + discovery contract.
87
+ - [Thinking and reasoning](../thinking-and-reasoning.md): portable thinking helpers.
88
+ - [Provider conformance](../provider-conformance.md): network-free assertions.
89
+ - Package README: [`packages/provider-google/README.md`](../../packages/provider-google/README.md)
@@ -0,0 +1,166 @@
1
+ # Ollama Cloud provider package
2
+
3
+ ## What it does
4
+
5
+ `@arnilo/prism-provider-ollama` is a side-effect-free adapter for Ollama — both
6
+ **Ollama Cloud** (`https://ollama.com`) and a **local** `ollama serve`
7
+ (`http://localhost:11434`) — over the OpenAI-compatible
8
+ `POST {base}/chat/completions` endpoint.
9
+
10
+ - **Dynamic model discovery** — `listOllamaModels()` calls the OpenAI-compatible
11
+ `GET {base}/models`. No model catalog is hard-coded: available models vary by cloud
12
+ account or local pull, so discovery is the source of truth. Package setup never
13
+ fetches. (The native `GET {base}/api/tags` endpoint is an alternate catalog source;
14
+ Prism uses the OpenAI-compatible route for a uniform shape.)
15
+ - **Implicit cache only** — Ollama reuses its KV/prompt cache automatically. There is
16
+ no request knob and no cached-token count in usage, so `Usage.cacheReadTokens` is
17
+ intentionally left undefined (documented ceiling below).
18
+ - **Reasoning** — `reasoning_effort` passthrough (e.g. gpt-oss models).
19
+
20
+ Cloud auth is an ollama.com API key sent as `Authorization: Bearer`; local instances
21
+ are typically unauthenticated (omit the key).
22
+
23
+ ## When to use it
24
+
25
+ Use it when a host app wants Ollama Cloud or local Ollama models through Prism's
26
+ `AgentSession` runtime with OpenAI-compatible serialization and dynamic model
27
+ discovery.
28
+
29
+ Do not use it for automatic credential discovery, setup-time catalog fetches, explicit
30
+ cache control (Ollama has none), or real-network tests (live tests stay opt-in).
31
+
32
+ ## Inputs / request
33
+
34
+ ```ts
35
+ import {
36
+ createOllamaProviderPackage,
37
+ createOllamaProvider,
38
+ listOllamaModels,
39
+ defineOllamaModel,
40
+ ollamaBaseUrl,
41
+ } from "@arnilo/prism-provider-ollama";
42
+
43
+ createOllamaProviderPackage(options: OllamaProviderPackageOptions): ProviderPackage
44
+ createOllamaProvider(options?: OllamaProviderOptions): AIProvider
45
+ listOllamaModels(options?: ListOllamaModelsOptions): Promise<ModelConfig[]>
46
+ defineOllamaModel(config: OllamaModelConfig): ModelConfig
47
+ ollamaBaseUrl(options?: { baseUrl?: string; preset?: OllamaBasePreset }): string
48
+ ```
49
+
50
+ | Field | Type | Purpose |
51
+ | --- | --- | --- |
52
+ | `apiKey` | `CredentialValueSource` | Ollama Cloud API key; omit for unauthenticated local. |
53
+ | `baseUrl` | `string` | Explicit OpenAI-compatible base URL (wins over `preset`). |
54
+ | `preset` | `OllamaBasePreset` | `"cloud"` (default) / `"local"`. |
55
+ | `fetch` | `typeof fetch` | Optional fetch implementation for tests/hosts. |
56
+ | `id` | `string` | Provider id (default `ollama`). |
57
+ | `models` | `readonly ModelConfig[]` | Host-supplied models (from `listOllamaModels`) to register. |
58
+
59
+ Base URLs resolved by preset (each includes the `/v1` segment):
60
+
61
+ | Preset | Base URL |
62
+ | --- | --- |
63
+ | `cloud` | `https://ollama.com/v1` |
64
+ | `local` | `http://localhost:11434/v1` |
65
+
66
+ ## Outputs / response / events
67
+
68
+ | Surface | Behavior |
69
+ | --- | --- |
70
+ | Stream | Prism text deltas, `delta.reasoning_content` → thinking deltas, tool-call delta/final, `usage`, `done`, redacted `error`. |
71
+ | Usage | `prompt_tokens` → `inputTokens`, `completion_tokens` → `outputTokens` (native `prompt_eval_count`/`eval_count` are the equivalent). `cacheReadTokens` stays undefined. |
72
+ | Discovery | `listOllamaModels()` maps `GET {base}/models` entries → `ModelConfig` (reasoning/vision inferred from id). |
73
+ | Auth methods | `api_key` for `ollama`. |
74
+
75
+ The stream parser emits `done` only on completion evidence (`[DONE]` plus a terminal
76
+ `finish_reason` with no dangling tool calls). Truncated streams terminate with an
77
+ `error` event instead. Unsupported block placements or unclaimed images fail before
78
+ fetch.
79
+
80
+ ## Request/response example
81
+
82
+ ```bash
83
+ curl 'https://ollama.com/v1/chat/completions' \
84
+ -H "Authorization: Bearer $OLLAMA_API_KEY" \
85
+ -H 'Content-Type: application/json' \
86
+ -d '{
87
+ "model": "gpt-oss:20b",
88
+ "messages": [{ "role": "user", "content": "Hello" }],
89
+ "stream": true,
90
+ "stream_options": { "include_usage": true }
91
+ }'
92
+
93
+ curl 'https://ollama.com/v1/models' -H "Authorization: Bearer $OLLAMA_API_KEY"
94
+ ```
95
+
96
+ Usage in the final streamed chunk:
97
+
98
+ ```json
99
+ { "usage": { "prompt_tokens": 100, "completion_tokens": 5, "total_tokens": 105 } }
100
+ ```
101
+
102
+ ## Implementation example
103
+
104
+ ```ts
105
+ import { createExtensionKernel } from "@arnilo/prism";
106
+ import {
107
+ createOllamaProviderPackage,
108
+ listOllamaModels,
109
+ } from "@arnilo/prism-provider-ollama";
110
+
111
+ const kernel = createExtensionKernel();
112
+
113
+ // Caller-gated discovery — never runs during setup.
114
+ const models = await listOllamaModels({ apiKey: process.env.OLLAMA_API_KEY });
115
+
116
+ await kernel.load([
117
+ createOllamaProviderPackage({
118
+ apiKey: process.env.OLLAMA_API_KEY, // omit for local
119
+ preset: "cloud", // or "local"
120
+ models,
121
+ }),
122
+ ]);
123
+ ```
124
+
125
+ ## Extension and configuration notes
126
+
127
+ - Hosts choose base URL/preset, provider id, model list, credential source, and
128
+ `fetch` impl. Nothing is hard-coded; register discovered models via `models:`.
129
+ - Reasoning: `compat.reasoning_effort` (request wins over model default) maps to the
130
+ top-level `reasoning_effort` wire field; omitted unless explicitly a string.
131
+ - Provider-owned compat keys (`route`, `reasoning_effort`, `ollama`) are stripped
132
+ before the opaque `compat` spread so they never leak into wire bodies.
133
+
134
+ ### Cache behavior
135
+
136
+ - **Implicit only.** Ollama reuses its KV/prompt cache automatically; there is no
137
+ request knob and no wire marker. Prism never emits `cache_control` for Ollama.
138
+ - **Documented ceiling:** Ollama exposes no cached-token count, so
139
+ `Usage.cacheReadTokens` is intentionally left `undefined` (not `0`). If a future
140
+ Ollama release reports cached tokens, map them in `mapOllamaModel`/usage handling.
141
+
142
+ ## Security and performance notes
143
+
144
+ - SSE streams and HTTP error bodies use bounded `@arnilo/prism/providers/transport`
145
+ helpers (`readSseData`, `readBoundedResponseText`).
146
+ - No network calls during import, setup, build, or default tests.
147
+ - No automatic environment, file, keychain, or shell credential lookup.
148
+ - The cloud API key is resolved per request via `resolveCredentialValue` and sent only
149
+ as `Authorization: Bearer`; keys are redacted from all thrown errors (including
150
+ discovery failures). Local presets send no auth header when no key is configured.
151
+ No local filesystem paths enter request payloads.
152
+ - Caller-supplied `ProviderRequest.options.headers` can add non-owned headers, but
153
+ provider-owned headers (`content-type`, `authorization`) are applied last and
154
+ cannot be overridden.
155
+ - Model discovery is caller-gated and never invoked in the provider hot path.
156
+ - Live tests stay opt-in; default tests are network-free.
157
+
158
+ ## Related APIs
159
+
160
+ - [Provider packages](../provider-packages.md): `defineProviderPackage`,
161
+ caller-gated discovery, OpenAI-compatible routes.
162
+ - [Provider caching](../provider-caching.md): explicit/implicit matrix (Ollama =
163
+ implicit only).
164
+ - [Credentials and redaction](../credentials-and-redaction.md):
165
+ `resolveCredentialValue`, `redactSecrets`.
166
+ - [Provider conformance](../provider-conformance.md): network-free adapter tests.
@@ -27,9 +27,27 @@ Options:
27
27
  | Field | Type | Purpose |
28
28
  | --- | --- | --- |
29
29
  | `id` | `string` | Optional provider id. Defaults to `openai-compatible`. |
30
- | `baseUrl` | `string` | Base API URL; `/chat/completions` is appended. |
30
+ | `baseUrl` | `string` | Base API URL; `/chat/completions` is appended unless `chatCompletionsUrl` is set. |
31
31
  | `apiKey` | `CredentialValueSource` | Optional direct/callback/resolver credential source. |
32
32
  | `fetch` | `typeof fetch` | Optional fetch implementation for tests or custom hosts. |
33
+ | `chatCompletionsUrl` | `string \| ((request) => string)` | Optional full chat-completions URL override (Azure deployment paths). |
34
+ | `authStyle` | `"bearer" \| "api-key" \| "none"` | Auth header style. Default `bearer`. |
35
+ | `buildBodyExtra` | `(request) => JsonObject \| undefined` | Optional provider-specific body fields (thinking/reasoning/cache); merged over the base body. |
36
+ | `mapMessages` | `(request) => readonly Message[]` | Optional message transform before serialization (e.g. cache-control markers). Defaults to `request.messages`. |
37
+ | `mapUsage` | `(usage: unknown) => Usage \| undefined` | Optional usage mapping override (e.g. OpenRouter cost fields). Defaults to `mapOpenAIChatUsage`. |
38
+ | `serializeMessage` | `(message, request) => JsonObject` | Optional custom message serializer (e.g. Z.AI `reasoning_content` replay). Defaults to assert + `serializeOpenAIChatMessage`. |
39
+ | `doneUsage` | `boolean` | Emit the final stream usage on the `done` event (without strict completion checks). |
40
+ | `mapHttpError` | `(response, bodyText, secrets) => Error` | Custom HTTP error mapping (e.g. NeuralWatt retry classification). Receives the response and redacted body text. |
41
+ | `onComment` | `(text) => ProviderEvent \| undefined` | Handle SSE comment lines (text after `:`), e.g. NeuralWatt `: energy` / `: cost` telemetry. Returned events are yielded in stream order. |
42
+ | `extraHeaders` | `(request) => Record<string, string>` | Optional extra request headers; provider auth and `content-type` still win. |
43
+ | `transformBody` | `(body, request) => JsonObject` | Optional final body transform, applied last (token limits, compat stripping); wins over everything. |
44
+ | `strictCompletion` | `boolean` | Require `[DONE]` and a `finish_reason`; truncated streams yield an `error` and `done` carries the final usage. |
45
+ | `requestFailedPrefix` | `string` | Prefix for HTTP error messages. Default `OpenAI-compatible request failed`. |
46
+
47
+ The subpath also exports the building blocks for provider packages that keep public body/stream helpers:
48
+
49
+ - `openAIChatEvents(body, { signal, strictCompletion, doneUsage, mapUsage, onComment })`: the shared SSE stream loop as an `AsyncIterable<ProviderEvent>`.
50
+ - `buildOpenAIChatBody(request, { mapMessages, serializeMessage, buildBodyExtra, transformBody })`: the base Chat Completions request body builder.
33
51
 
34
52
  Provider requests use the standard `ProviderRequest` shape: `model`, `messages`, optional `tools`, `metadata`, and `signal`.
35
53
 
@@ -47,7 +65,7 @@ The returned provider emits normalized `ProviderEvent` values:
47
65
  | `[DONE]` or stream end | `done` event. |
48
66
  | HTTP/stream/parsing error | `error` event with redacted `ErrorInfo`. |
49
67
 
50
- The adapter passes `request.signal` to `fetch` for abort propagation.
68
+ The adapter passes `request.signal` to `fetch` for abort propagation; an already-aborted signal throws before fetch.
51
69
 
52
70
  ## Request/response example
53
71
 
@@ -108,6 +126,17 @@ const provider = createOpenAICompatibleProvider({
108
126
  - The adapter resolves `apiKey` per request through `resolveCredentialValue()`.
109
127
  - This adapter currently targets Chat Completions streaming only.
110
128
  - The serializer preserves text, thinking (downgraded to text), assistant `tool_call` blocks as `tool_calls`, `tool_result` blocks as role `tool` messages, and image blocks when the model declares `capabilities.input` includes `"image"`. Unsupported block placements or unclaimed images fail before fetch.
129
+ - Vendor-specific OpenAI-compatible endpoints (cache markers, thinking bodies, reasoning fields, custom usage) plug in through `buildBodyExtra`/`mapMessages`/`mapUsage`/`extraHeaders` instead of duplicating the stream loop:
130
+
131
+ ```ts
132
+ const provider = createOpenAICompatibleProvider({
133
+ baseUrl: "https://vendor.example/v1",
134
+ apiKey: () => process.env.VENDOR_API_KEY,
135
+ buildBodyExtra: (request) => ({ thinking: { type: "enabled" } }),
136
+ extraHeaders: () => ({ "x-vendor-app": "my-app" }),
137
+ });
138
+ ```
139
+
111
140
  - Cache behavior is intentionally minimal: this Chat Completions adapter sends no `prompt_cache_key`, `prompt_cache_retention`, or `cache_control` fields. Endpoints that cache implicitly do so automatically; hosts needing OpenAI `prompt_cache_key`/`prompt_cache_retention` should use the [`@arnilo/prism-provider-openai`](openai.md) Responses package. The adapter still normalizes cache usage from `prompt_tokens_details.cached_tokens` (and `prompt_cache_hit_tokens`) into `Usage.cacheReadTokens`.
112
141
 
113
142
  ## Security and performance notes
@@ -50,11 +50,13 @@ uses official Responses `reasoning: { effort, summary? }` via
50
50
 
51
51
  | Surface | Behavior |
52
52
  | --- | --- |
53
- | Provider stream | Prism text, thinking (downgraded to text), `tool_call` deltas/finals, `usage`, `done`, redacted `error` events. |
54
- | Block preservation | User/system text → `input_text`; assistant text → `output_text`; assistant `tool_call` → top-level `function_call` with `call_id`; `tool_result` → top-level `function_call_output`; images/files/audio when declared on the model. Bare thinking without an encrypted Responses reasoning item is omitted on replay. |
55
- | Auth methods | `api_key` for `openai`; `oauth` for `openai-codex`. |
53
+ | Provider stream | Prism text, thinking (downgraded to text), host `tool_call` deltas/finals, provider-hosted `tool_call` events (`authority: "provider-hosted"`), `continuation_required`, `usage`, `done`, and redacted `error` events. |
54
+ | Continuation | An incomplete Responses stream self-resumes at most eight HTTP hops using opaque `previous_response_id`; a cursor is at most 4 KiB, is never replayed, and is observable as `continuation_required`. |
55
+ | Realtime | `createOpenAIRealtimeSession()` exposes server-session creation, audio in/out, transcript deltas, provider-hosted calls, interrupt, and idempotent close through the neutral `RealtimeSession` seam. |
56
+ | Block preservation | User/system text → `input_text`; assistant text → `output_text`; assistant host `tool_call` → top-level `function_call` with `call_id`; provider-hosted calls are not replayed; `tool_result` → top-level `function_call_output`; images/files/audio when declared on the model. Bare thinking without an encrypted Responses reasoning item is omitted on replay. |
57
+ | Auth methods | `api_key` for `openai`; host-invoked subscription `oauth` for `openai-codex`. This is Prism's only first-party subscription OAuth flow in 0.0.12. |
56
58
 
57
- Unsupported block placements or unclaimed images fail before `fetch`.
59
+ Unsupported block placements or unclaimed images fail before `fetch`. Provider-hosted calls are telemetry only: Prism never dispatches them as host tools or sends a `tool_result`.
58
60
 
59
61
  ## Request/response example
60
62
 
@@ -76,6 +78,21 @@ Responses request body (Codex subscription shape, abbreviated):
76
78
  }
77
79
  ```
78
80
 
81
+ Realtime session (OpenAI session creation, abbreviated):
82
+
83
+ ```ts
84
+ import { createOpenAIRealtimeSession } from "@arnilo/prism-provider-openai";
85
+
86
+ const session = createOpenAIRealtimeSession({
87
+ model: { provider: "openai", model: "gpt-realtime-2.1" },
88
+ ownerId: "hashed-host-user-id",
89
+ apiKey,
90
+ });
91
+ for await (const event of session.events()) {
92
+ if (event.type === "audio_delta") play(event.audio);
93
+ }
94
+ ```
95
+
79
96
  OAuth authorize URL (PKCE, `S256`):
80
97
 
81
98
  ```
@@ -120,11 +137,12 @@ const challenge = computeS256Challenge(verifier);
120
137
  - Hosts/apps control model selection, credential resolution, and cache policy per
121
138
  run/model through `RunOptions` and `ModelConfig.compat`.
122
139
  - OAuth browser/device-code flows run only when the caller explicitly invokes the
123
- OAuth provider.
140
+ OAuth provider. Login UI and optional durable token storage remain host-owned; no ambient credential discovery or refresh timer is installed.
124
141
  - Device-code login polls the token endpoint with server-directed `interval` and
125
142
  `expires_in`, honors RFC 8628 `authorization_pending` / `slow_down`, and stops
126
143
  on terminal errors or expiry. Pass `signal` on `OAuthLoginCallbacks` to abort
127
144
  polling promptly.
145
+ - `createOpenAIRealtimeSession` requires a stable host `ownerId`; it sends that value as OpenAI's safety identifier and binds the stream to the server `session.created` id. An injected `webSocket(url, { headers })` factory supports Node 22 hosts whose global WebSocket does not expose header options.
128
146
 
129
147
  ### Cache behavior
130
148
 
@@ -189,6 +207,7 @@ Official: [Reasoning models](https://developers.openai.com/api/docs/guides/reaso
189
207
  access/refresh tokens echoed in token-endpoint failures.
190
208
  - The PKCE verifier is exchanged at the token endpoint, never sent on the authorize
191
209
  URL.
210
+ - Realtime uses the documented WebSocket `Authorization` header, never a credential query parameter. API keys are redacted from transcript/error events; audio/transcript input is untrusted, realtime queues are bounded, and disconnect, abort, malformed session identity, or audio/byte/wall-time cap breach closes the session.
192
211
  - Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus fake-safe
193
212
  provider-specific env names; default `npm test` is network-free.
194
213
 
@@ -188,9 +188,11 @@ cache-read pricing exists), and seeds `compat.reasoning.effort` from
188
188
  hidden app identity.
189
189
  - Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus fake-safe
190
190
  provider-specific env names; default tests are network-free.
191
+ - Enterprise hosts that must gate `compat.openRouterRouting` should wrap selection with `@arnilo/prism-model-router` (`allowOpenRouterRouting`); the OpenRouter adapter itself still passthroughs routing when present on the request.
191
192
 
192
193
  ## Related APIs
193
194
 
195
+ - [Model routing](../model-routing.md): optional allow-list/residency/budget/circuit facade and OpenRouter routing gate.
194
196
  - [Provider packages](../provider-packages.md): `defineProviderPackage`,
195
197
  `ModelConfig`/`compat`, cache policy, caller-gated discovery.
196
198
  - [Thinking and reasoning](../thinking-and-reasoning.md): `applyThinkingLevel`
@@ -0,0 +1,71 @@
1
+ # Google Vertex AI
2
+
3
+ ## What it does
4
+
5
+ `@arnilo/prism-provider-vertex` registers a Vertex AI OpenAPI-compatible Chat Completions provider authenticated with host ADC / workload identity tokens. It is intentionally separate from `@arnilo/prism-provider-google` (consumer Gemini API keys).
6
+
7
+ ## When to use it
8
+
9
+ Use it for GCP enterprise Vertex deployments with Application Default Credentials or workload identity federation. Do not use the consumer Google package for Vertex auth semantics.
10
+
11
+ ## Inputs / request
12
+
13
+ ```ts
14
+ import { createVertexProviderPackage } from "@arnilo/prism-provider-vertex";
15
+
16
+ createVertexProviderPackage({
17
+ projectId: "my-gcp-project",
18
+ location: "europe-west1",
19
+ credential: () => hostAdcAccessToken(),
20
+ models: [{ provider: "vertex", model: "google/gemini-2.0-flash-001" }],
21
+ });
22
+ ```
23
+
24
+ | Field | Meaning |
25
+ | --- | --- |
26
+ | `projectId` | GCP project |
27
+ | `location` | Vertex location / region |
28
+ | `endpoint` | Optional full https OpenAPI base (private/custom); otherwise location-scoped default |
29
+ | `credential` | Bearer access token source (ADC / WIF) |
30
+
31
+ Default base: `https://{location}-aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/endpoints/openapi`.
32
+
33
+ ## Outputs / response / events
34
+
35
+ OpenAI-compatible SSE → Prism provider events. Missing ADC token fails closed before `fetch`.
36
+
37
+ ## Request/response example
38
+
39
+ ```http
40
+ POST https://europe-west1-aiplatform.googleapis.com/v1/projects/my-gcp-project/locations/europe-west1/endpoints/openapi/chat/completions
41
+ Authorization: Bearer <adc-token>
42
+ ```
43
+
44
+ ## Implementation example
45
+
46
+ ```ts
47
+ const provider = createVertexProvider({
48
+ projectId: "my-gcp-project",
49
+ location: "us-central1",
50
+ credential: async () => (await GoogleAuth.getAccessToken()),
51
+ });
52
+ ```
53
+
54
+ ## Extension and configuration notes
55
+
56
+ `@arnilo/prism-provider-google` remains API-key Gemini (`generativelanguage.googleapis.com`) and must not register Vertex OAuth/ADC. Load this package explicitly for Vertex.
57
+
58
+ ## Security and performance notes
59
+
60
+ - No Google Cloud SDK dependency in the package.
61
+ - Custom/private endpoint hosts are preserved.
62
+ - Tokens redacted from errors; no import-time credential prefetch.
63
+ - Pair with model-router residency allow-lists on `location`.
64
+
65
+ ## Related APIs
66
+
67
+ - [Google Gemini (consumer)](google.md)
68
+ - [OpenAI-compatible provider](openai-compatible.md)
69
+ - [Provider packages](../provider-packages.md)
70
+ - [Model routing](../model-routing.md)
71
+ - Package README: [`@arnilo/prism-provider-vertex`](../../packages/provider-vertex/README.md)
@@ -15,7 +15,8 @@ Current contract groups:
15
15
  - Extensions/middleware: `ExtensionLifecycleEventName`, `ExtensionEvent`, `Extension`, `ExtensionAPI`, `MiddlewareHookName`, `Middleware`, `MiddlewareNext`, `MiddlewareRegistry`
16
16
  - Configuration/manifests: `ConfigProvider`, `ConfigLayer`, `ConfigLoadContext`, `PrismManifest`, `ManifestContributionDeclaration`, `ManifestResourceDeclaration`, `ManifestContributionKind`
17
17
  - Stores/resources/settings/credentials/compaction/retry/cache helpers: `SessionEntry`, `SessionStore`, `StoreFactory`, `Resource`, `ResourceLoader`, `ResourceLoadContext`, `SettingsProvider`, `CredentialRequest`, `Credential`, `CredentialResolver`, `CompactionStrategy`, `CompactionContext`, `CompactionResult`, `CompactionOptions`, `CompactionMiddlewarePayload`, `CompactionEntryData`, `DefaultCompactionStrategyOptions`, `RetryPolicy`, `RetryContext`, `RetryDecision`, `RetryOptions`, `RetryMiddlewarePayload`, `DefaultRetryPolicyOptions`, `CacheUsageReport`, `sanitizeCacheKey`, `mapCacheRetention`, `applyCacheControl`, `cacheHitRate`, `cacheSavings`, `cacheUsageReport`
18
- - Production persistence (adapter-facing): `ProductionPersistenceStore`, `CheckpointStore`, `CheckpointKey`, `CheckpointSaveInput`, `CheckpointRecord`, `CheckpointQuery`, `LeaseStore`, `LeaseKey`, `LeaseAcquireInput`, `LeaseClaimInput`, `LeaseRecord`, `PersistencePage`, `PersistenceQuery`, `OwnershipScope`, `SessionRecord`, `SessionQuery`, `BranchRecord`, `BranchQuery`, `SessionEntryQuery`, `RunRecord`, `RunQuery`, `RunFeedbackRecord`, `RunFeedbackStore`, `RunFeedbackQuery`, `AgentEventRecord`, `AgentEventQuery`, `ToolCallRecord`, `ToolCallQuery`, `UsageRecord`, `UsageQuery`, `AgentDefinitionRecord`, `AgentDefinitionQuery`, `RetentionPolicy`, `RetentionPolicyQuery`, `MigrationRecord`, `MigrationQuery`
18
+ - Production persistence (adapter-facing): `ProductionPersistenceStore` (optional `lifecycle`), `CheckpointStore`, `CheckpointKey`, `CheckpointSaveInput`, `CheckpointRecord`, `CheckpointQuery`, `LeaseStore`, `LeaseKey`, `LeaseAcquireInput`, `LeaseClaimInput`, `LeaseRecord`, `PersistencePage`, `PersistenceQuery`, `OwnershipScope`, `SessionRecord`, `SessionQuery`, `BranchRecord`, `BranchQuery`, `SessionEntryQuery`, `RunRecord`, `RunQuery`, `RunFeedbackRecord`, `RunFeedbackStore`, `RunFeedbackQuery`, `AgentEventRecord`, `AgentEventQuery`, `ToolCallRecord`, `ToolCallQuery`, `UsageRecord`, `UsageQuery`, `AgentDefinitionRecord`, `AgentDefinitionQuery`, `RetentionPolicy`, `RetentionPolicyQuery`, `MigrationRecord`, `MigrationQuery`, `PersistenceLifecycleStore`, `LegalHoldRecord`, `TenantQuota`
19
+ - Identity: `Principal`, `AgentIdentity`, `IdentityVerifier`, `assertIdentityActive`, `narrowIdentity`, `ownershipFromIdentity`, `assertIdentityMatchesOwnership`, `assertIdentityPropagation`, `identityTelemetryAttributes`, `resolveRunIdentity`, `IdentityError`, identity limit constants
19
20
 
20
21
  ## When to use it
21
22
 
@@ -121,7 +122,7 @@ Important request shapes:
121
122
  | `ToolRegistry` | Host active tool registry shape: `register()`, `get()`, `resolve()`, and `list()`. |
122
123
  | `ToolExecutionContext` | Host tool execution context: session/run ids, tool call id, optional abort signal, metadata, and progress callback. |
123
124
  | `ContextResolutionContext` | Context provider input: messages plus optional session/run ids, metadata, and signal. |
124
- | `InputAssemblyLayout` | Default input layout selector: `"legacy"` (default) or opt-in `"cache_aware"`. |
125
+ | `InputAssemblyLayout` | Default input layout selector: `"cache_aware"` (default) or opt-in `"legacy"`. |
125
126
  | `DefaultInputBuildContext` | Optional default input assembly context: input layout, instructions, history, summaries, attachments, explicit resources, tool results, middleware, ids, metadata, and signal. |
126
127
  | `ResolveContextOptions` | Ordered context resolution input: selected providers, messages, ids, metadata, signal, and optional middleware. |
127
128
  | `AssembleProviderInputOptions` | Provider input assembly input: model, input, optional builders, selected context providers/skills, active tools, metadata, and signal. |
@@ -132,6 +133,7 @@ Important request shapes:
132
133
  | `AgentSessionConfig` | Session creation input: optional id, agent, store, leaf id, and metadata. |
133
134
  | `RunOptions` | Per-run overrides: optional abort signal, model, input layout, max tool rounds, provider options/request policies, system prompt layers, compaction, retry, metadata, skill selection, validate, redactor, and loop. |
134
135
  | `SubscribeOptions` / `SubscriberOverflowPolicy` | Live `AgentEvent` subscriber queue limit and overflow policy: `maxQueuedEvents`, `overflow: "close" \| "drop_oldest" \| "drop_newest"`. |
136
+ | `resumeAgentRunStream` / `AgentRunResumeStreamOptions` | One durable-run event stream: existing checkpoint/resume options plus `signal` and bounded subscriber options. `AgentRunLifecycle.resumeStream()` adds host capability resolution; no protocol types enter core. |
135
137
  | `AgentConfig.loop` / `RunOptions.loop` | Replaceable per-run control loop: `singleShotLoop` default, `generate-validate-revise` options, or a custom `AgentLoopStrategy`. `RunOptions.loop` wins. See [Agent loops](agent-loops.md). |
136
138
  | `AgentLoopStrategy` | `{ name; run(ctx: LoopContext): Promise<Usage \| undefined> }` — orchestrates shared runtime primitives via `LoopContext`. |
137
139
  | `LoopContext` | Loop-facing surface: run ids, signal, live `history`, `input`/`inputMessages`/`maxToolRounds`, and bound `assemble`/`generate`/`dispatchToolCall`/`appendMessage`/`emit` primitives. |
@@ -143,7 +145,7 @@ Important request shapes:
143
145
  | `ConfigLayer` | Named JSON config layer consumed by `mergeConfigLayers()`. |
144
146
  | `PrismManifest` | Data-only package manifest with config defaults, contribution declarations, and resource declarations. |
145
147
  | `ProductionPersistenceStore` | Adapter-facing interface for durable, paginated, multi-tenant storage plus optional `checkpoints?: CheckpointStore`, `leases?: LeaseStore`, and `feedback?: RunFeedbackStore`. No SQL/ORM/host file storage/network dependency. |
146
- | `CheckpointStore` | Generic versioned checkpoint capability: save/load/bounded-list/delete by namespace and key, with ownership, exact-version CAS, and lease fencing. `createMemoryCheckpointStore()` is the reference implementation. |
148
+ | `CheckpointStore` | Generic versioned checkpoint capability: save/load/bounded-list/delete by namespace and key, with ownership, exact-version CAS, and lease fencing. `createMemoryCheckpointStore()` is the reference implementation; it is bounded — `maxRecords` (default 10,000, evicts least-recently-saved) and `maxValueBytes` (default 1 MiB per JSON value). |
147
149
  | `LeaseStore` | Atomic acquire/renew/release/get by namespace and key, with opaque claim tokens, expiry, ownership scope, and monotonically increasing takeover fences. `createMemoryLeaseStore()` is the reference implementation. |
148
150
  | `RunFeedbackStore` | Immutable append, bounded owned query, and owned deletion for ratings/comments/tags linked to existing run/trace/evaluation IDs. `createMemoryRunFeedbackStore()` is the reference implementation. |
149
151
  | `EventMultiplexer<T>` | Generic bounded fan-in from async sources. `createEventMultiplexer()` owns queue limits, overflow policy, abort, source teardown, and close behavior. |
@@ -151,6 +153,10 @@ Important request shapes:
151
153
  | `PersistenceQuery` | Common pagination controls: `cursor?`, `limit?`, `order?: "asc" \| "desc"`. |
152
154
  | `OwnershipScope` | Multi-tenant scope: `tenantId?`, `accountId?`, `userId?`. Included in records and queries. |
153
155
  | `SessionRecord` / `SessionQuery` | Stored session and query filters (parent, agent definition, retention policy, timestamps, ownership). |
156
+ | `SessionIndex` / `SessionSearchQuery` / `SessionSearchHit` | Bounded optional session search seam (`search` / `SessionStore.searchSessions?`). Filters: workspace (`metadata.workspaceRoot`), time, provider/model, label/summary, optional FTS `query`, ownership. Hits return `sessionId` + optional `leafId` for resume; never credentials. Caps via `resolveSessionSearchQuery` / `DEFAULT_*` / `HARD_MAX_*` session-search constants. |
157
+ | `contextBudget` / `getContextBudgetReport` / `ContextBudgetError` | Opt-in assembler budget on `AssembleProviderInputOptions`; deterministic eviction; omission report in `ProviderRequest.metadata` (kinds/ids/sizes only). |
158
+ | `AgentSession.steer` / `SteerOptions` / pending-steer caps | Mid-run enqueue into active run; optional `softInterrupt`; default 8 msgs / 64 KiB UTF-8. |
159
+ | `SessionSearchUnsupportedError` / `sessionSearchMode` | Memory opt-out + JSONL; typed throw (not empty success). |
154
160
  | `BranchRecord` / `BranchQuery` | Branch handle/leaf pointer and query filters (session, name, parent branch, leaf presence). |
155
161
  | `SessionEntryQuery` | Paginated entry filters: `sessionId`, `runId`, `parentId`, `leafId`, `kind`, timestamp range, ownership. |
156
162
  | `RunRecord` / `RunQuery` | Stored run and filters: session, branch, status, timestamps, ownership. |
@@ -160,6 +166,7 @@ Important request shapes:
160
166
  | `CacheUsageReport` | Numeric cache diagnostics from normalized `Usage`: read/write tokens, hit rate, estimated savings, and optional currency. |
161
167
  | `AgentDefinitionRecord` / `AgentDefinitionQuery` | Versioned agent-definition snapshot and filters. Does not store credentials or provider instances. |
162
168
  | `RetentionPolicy` / `RetentionPolicyQuery` | Retention policy and filters: age, entry count, byte limits, archive store, applied kinds. |
169
+ | `PersistenceLifecycleStore` / `LegalHoldRecord` / `TenantQuota` | Optional hold/retention apply/export/quota capability on `ProductionPersistenceStore.lifecycle`. |
163
170
  | `MigrationRecord` / `MigrationQuery` | Applied migration record and filters. |
164
171
 
165
172
  ## Outputs / response / events
@@ -422,6 +429,8 @@ void credentials;
422
429
  - `createAgent()` and `createAgentSession()` implement the session runtime. They use explicit providers only; no hidden provider registry is created. Store-backed sessions use explicit `SessionStore` values and branch methods on `AgentSession`. `AgentSession.compact()` and `AgentConfig`/`RunOptions.compaction` provide manual and opt-in auto-compaction. `AgentConfig`/`RunOptions.retry` provide bounded provider-turn retry before observable output.
423
430
  - `createMemorySessionStore()` is the built-in in-memory `SessionStore`. Node hosts can opt into file durability with `@arnilo/prism/node/session-store-jsonl`. `createSessionEntry()`, `getSessionBranchEntries()`, `listSessionBranches()`, and `rebuildSessionContext()` are pure helpers for branch-aware session entries. `rebuildSessionContext()` understands compaction entries produced by `createDefaultCompactionStrategy()`, reducing provider-context messages while keeping raw entries. They do not read files or call providers.
424
431
 
432
+ Phase 7 contracts: `AgentEventSource`, `ToolEffectDeclaration`/`ToolEffectStore`, and related error codes. Opt-in only; hosts without stores keep prior dispatch behavior.
433
+
425
434
  ## Security and performance notes
426
435
 
427
436
  - Type-only imports have no runtime side effects.
@@ -430,6 +439,53 @@ void credentials;
430
439
  - Use `unknown`/metadata fields for host data, but validate at trust boundaries before executing tools or loading resources.
431
440
  - App-specific tool categories and business domains do not belong in public contracts.
432
441
 
442
+ ## Frozen 0.1.x contract (plan 012 Task 7)
443
+
444
+ Release 0.1.0 freezes the public contract surface for the 0.1.x line. The
445
+ freeze is recorded in `scripts/phase12-freeze-manifest.json` and machine-checked
446
+ on every `npm test` by the release gates; this section states what is frozen.
447
+
448
+ **Declaration/exports surface.** Every publishable package's generated `.d.ts`
449
+ export surface is diffed against checked-in baselines in
450
+ `scripts/compat-baseline/` (one file per package, regenerated at 0.1.0). The
451
+ gate fails on any removed export or changed declaration and allows additive
452
+ exports only. **0.1.x patch promise:** additive-only declaration deltas vs the
453
+ 0.1.0 baselines, enforced by `node scripts/release.mjs gate`; a genuine break
454
+ requires `--allow-break` plus a `docs/migration.md` entry naming the version.
455
+
456
+ **Events.** The `AgentEvent` union (`agent_*`/`artifact_*`/`tool_*` variants),
457
+ the durable `AgentEventRecord`/`DurableAgentEventRecord` shapes
458
+ (`turn_started`, `turn_finished`, `tool_execution_started`, `message_finished`;
459
+ run-scoped strictly increasing sequences; `redacted: true` on appends), and
460
+ `AgentEventSource` page/cursor semantics (opaque ownership-bound cursors,
461
+ terminal pages, at-least-once delivery) are frozen as shipped in 0.1.0. See
462
+ [docs/agent-events.md](agent-events.md).
463
+
464
+ **Protocol payloads.** AG-UI/A2UI surface state and operation payloads, ACP
465
+ (`@arnilo/prism-ag-ui/acp`) capability advertisement and session payloads,
466
+ MCP tool/resource/prompt payloads and OAuth discovery exchanges, A2A messages,
467
+ and provider request/response envelopes are frozen at the 0.1.0 pins recorded
468
+ in the freeze-manifest `support.protocol` table (`@agentclientprotocol/sdk`,
469
+ `@modelcontextprotocol/sdk`, A2A 1.0, AG-UI 0.4.x, OpenAPI 3.1 subset).
470
+
471
+ **Migration checksums.** The PostgreSQL persistence contract
472
+ (`createPersistenceMigrationContract`, 7 steps `001_init` …
473
+ `007_agent_event_retention_index`, sha256-checksummed rows in
474
+ `prism_migrations`) is frozen; `assertAppliedPersistenceMigrations` fails
475
+ closed on unknown history, incomplete legacy checksums, name mismatch, or
476
+ checksum mismatch. Enterprise state DDL (`enterprise-postgres`) is covered by
477
+ its own checksum contract. See [docs/database-persistence.md](database-persistence.md)
478
+ and [docs/migration.md](migration.md).
479
+
480
+ **Compatibility promise.** 0.1.x patch releases: additive exports only, no
481
+ schema migration steps, no default-behavior changes, no new runtime
482
+ dependencies, store compatibility maintained with 0.1.0 (persisted data
483
+ remains readable; no upgrade step required). 0.1.0 itself is store-compatible
484
+ with 0.0.28 (no migration) and the `0.0.17 → 0.1.0` upgrade matrix in
485
+ [docs/migration.md](migration.md) documents every intermediate line
486
+ (compatible / tested migration / tested refusal). The 1.x line may break the
487
+ 0.1.x surface; any break ships with a migration-guide entry first.
488
+
433
489
  ## Related APIs
434
490
 
435
491
  - [Input and prompt assembly](input-and-prompt-assembly.md): prompt template expansion and default input builder for strings, messages, history, attachments, resources, summaries, and tool results.
@@ -443,6 +499,7 @@ void credentials;
443
499
  - [Agent/session runtime](agent-session-runtime.md): `createAgent()` / `createAgentSession()` runtime, `AgentSession.compact()`, and auto-compaction config built on these contracts.
444
500
  - [Agent loops](agent-loops.md): `singleShotLoop` default, `generateValidateReviseLoop`, `resolveLoop`, and the `Artifact*`/`AgentLoop*`/`LoopContext` contracts.
445
501
  - [Agent events](agent-events.md): the `AgentEvent` union including `artifact_*` variants and event ordering.
502
+ - [Frontend interoperability (AG-UI and ACP)](ag-ui.md): optional protocol package consuming `AgentEvent`, `AgentRunLifecycle`, `OwnershipScope`, and `AgentEventRecord`; AG-UI/ACP protocol types do not enter root contracts.
446
503
  - [Structured output](structured-output.md): the `ArtifactParser<T>`/`ArtifactValidator<T>`/`ArtifactRepairer<T>` seam — the only typed-output path from a loop.
447
504
  - [Session stores](session-stores.md): `SessionStore` contract, branch-aware `SessionEntry` helpers, context rebuild, and store responsibilities.
448
505
  - [Database persistence](database-persistence.md): production persistence contracts, paginated query shapes, reference schema, indexes, retention, migrations, and NoSQL mapping.
@@ -455,4 +512,4 @@ void credentials;
455
512
  - `@arnilo/prism/providers/transport`: bounded SSE/event parsing, bounded HTTP error-body reads, and JSON-object tool-argument parsing for provider packages.
456
513
  - `@arnilo/prism/providers/openai`: OpenAI Chat Completions message/tool serialization, usage mapping, and indexed message validation helpers.
457
514
 
458
- Phase 10 public helpers include `createStaticSettingsProvider`, `createChainedSettingsProvider`, `createMemoryCredentialStore`, `createChainedCredentialResolver`, `createStaticTrustPolicy`, `assertTrusted`, `createStaticPermissionPolicy`, `assertPermission`, and `createSecretRedactor`. Phase 11 auth/request/prompt helpers include `createExplicitCredentialResolver`, `createEnvCredentialResolver`, `refreshOAuthCredential`, `createProviderRequestPolicyChain`, `createSessionCachePolicy`, `mergeProviderRequestOptions`, `composeSystemPrompt`, and `mergeSystemPromptConfig`; they do not read env vars, persist OAuth tokens, create cache stores, discover prompt files, or load packages unless the host supplies that behavior. `@arnilo/prism/testing/provider-conformance` exports network-free provider assertion helpers. Node subpaths `@arnilo/prism/node/settings` and `@arnilo/prism/node/trust` are explicit filesystem/path helpers.
515
+ Phase 10 public helpers include `createStaticSettingsProvider`, `createChainedSettingsProvider`, `createMemoryCredentialStore`, `createChainedCredentialResolver`, `createStaticTrustPolicy`, `assertTrusted`, `createStaticPermissionPolicy`, `assertPermission`, and `createSecretRedactor`. Phase 11 auth/request/prompt helpers include `createExplicitCredentialResolver`, `createEnvCredentialResolver`, `refreshOAuthCredential`, `createProviderRequestPolicyChain`, `createSessionCachePolicy`, `mergeProviderRequestOptions`, `composeSystemPrompt`, and `mergeSystemPromptConfig`; 0.0.16 adds `resolveRedactor(redactor?, secrets?)`, which resolves the active redactor from an explicit redactor plus known secret values (the single survivor of the former per-package copies). They do not read env vars, persist OAuth tokens, create cache stores, discover prompt files, or load packages unless the host supplies that behavior. `@arnilo/prism/testing/provider-conformance` exports network-free provider assertion helpers. Node subpaths `@arnilo/prism/node/settings` and `@arnilo/prism/node/trust` are explicit filesystem/path helpers.