@fgv/ts-extras 5.1.0-33 → 5.1.0-34

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 (77) hide show
  1. package/dist/packlets/ai-assist/apiClient.js +4 -4
  2. package/dist/packlets/ai-assist/apiClient.js.map +1 -1
  3. package/dist/packlets/ai-assist/chatRequestBuilders.js +86 -3
  4. package/dist/packlets/ai-assist/chatRequestBuilders.js.map +1 -1
  5. package/dist/packlets/ai-assist/converters.js +31 -1
  6. package/dist/packlets/ai-assist/converters.js.map +1 -1
  7. package/dist/packlets/ai-assist/index.js +3 -2
  8. package/dist/packlets/ai-assist/index.js.map +1 -1
  9. package/dist/packlets/ai-assist/model.js.map +1 -1
  10. package/dist/packlets/ai-assist/streamingAdapters/anthropic.js +176 -32
  11. package/dist/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -1
  12. package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +511 -0
  13. package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
  14. package/dist/packlets/ai-assist/streamingAdapters/common.js +95 -0
  15. package/dist/packlets/ai-assist/streamingAdapters/common.js.map +1 -1
  16. package/dist/packlets/ai-assist/streamingAdapters/gemini.js +34 -10
  17. package/dist/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -1
  18. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js +215 -15
  19. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -1
  20. package/dist/packlets/ai-assist/streamingClient.js +18 -0
  21. package/dist/packlets/ai-assist/streamingClient.js.map +1 -1
  22. package/dist/packlets/ai-assist/thinkingOptionsResolver.js +23 -0
  23. package/dist/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -1
  24. package/dist/packlets/ai-assist/toolFormats.js +106 -10
  25. package/dist/packlets/ai-assist/toolFormats.js.map +1 -1
  26. package/dist/ts-extras.d.ts +339 -3
  27. package/lib/packlets/ai-assist/apiClient.d.ts.map +1 -1
  28. package/lib/packlets/ai-assist/apiClient.js +3 -3
  29. package/lib/packlets/ai-assist/apiClient.js.map +1 -1
  30. package/lib/packlets/ai-assist/chatRequestBuilders.d.ts +29 -5
  31. package/lib/packlets/ai-assist/chatRequestBuilders.d.ts.map +1 -1
  32. package/lib/packlets/ai-assist/chatRequestBuilders.js +86 -3
  33. package/lib/packlets/ai-assist/chatRequestBuilders.js.map +1 -1
  34. package/lib/packlets/ai-assist/converters.d.ts +9 -1
  35. package/lib/packlets/ai-assist/converters.d.ts.map +1 -1
  36. package/lib/packlets/ai-assist/converters.js +31 -1
  37. package/lib/packlets/ai-assist/converters.js.map +1 -1
  38. package/lib/packlets/ai-assist/index.d.ts +4 -3
  39. package/lib/packlets/ai-assist/index.d.ts.map +1 -1
  40. package/lib/packlets/ai-assist/index.js +5 -1
  41. package/lib/packlets/ai-assist/index.js.map +1 -1
  42. package/lib/packlets/ai-assist/model.d.ts +183 -3
  43. package/lib/packlets/ai-assist/model.d.ts.map +1 -1
  44. package/lib/packlets/ai-assist/model.js.map +1 -1
  45. package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts +58 -5
  46. package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts.map +1 -1
  47. package/lib/packlets/ai-assist/streamingAdapters/anthropic.js +175 -31
  48. package/lib/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -1
  49. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts +158 -0
  50. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts.map +1 -0
  51. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +517 -0
  52. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
  53. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts +51 -0
  54. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts.map +1 -1
  55. package/lib/packlets/ai-assist/streamingAdapters/common.js +97 -0
  56. package/lib/packlets/ai-assist/streamingAdapters/common.js.map +1 -1
  57. package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts +16 -2
  58. package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts.map +1 -1
  59. package/lib/packlets/ai-assist/streamingAdapters/gemini.js +34 -10
  60. package/lib/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -1
  61. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts +15 -2
  62. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts.map +1 -1
  63. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js +214 -14
  64. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -1
  65. package/lib/packlets/ai-assist/streamingClient.d.ts +17 -0
  66. package/lib/packlets/ai-assist/streamingClient.d.ts.map +1 -1
  67. package/lib/packlets/ai-assist/streamingClient.js +20 -1
  68. package/lib/packlets/ai-assist/streamingClient.js.map +1 -1
  69. package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts +18 -2
  70. package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts.map +1 -1
  71. package/lib/packlets/ai-assist/thinkingOptionsResolver.js +24 -0
  72. package/lib/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -1
  73. package/lib/packlets/ai-assist/toolFormats.d.ts +40 -9
  74. package/lib/packlets/ai-assist/toolFormats.d.ts.map +1 -1
  75. package/lib/packlets/ai-assist/toolFormats.js +107 -10
  76. package/lib/packlets/ai-assist/toolFormats.js.map +1 -1
  77. package/package.json +7 -7
@@ -3,7 +3,7 @@
3
3
  * @packageDocumentation
4
4
  */
5
5
  import { type Result } from '@fgv/ts-utils';
6
- import { type JsonObject } from '@fgv/ts-json-base';
6
+ import { type JsonObject, type JsonSchema } from '@fgv/ts-json-base';
7
7
  /**
8
8
  * Universal image representation used for both image input (vision prompts)
9
9
  * and image output (generation responses).
@@ -123,6 +123,169 @@ export interface IAiToolEnablement {
123
123
  /** Optional tool-specific configuration. */
124
124
  readonly config?: AiServerToolConfig;
125
125
  }
126
+ /**
127
+ * Configuration for a client-defined (harness-supplied) tool.
128
+ *
129
+ * @remarks
130
+ * The `parametersSchema` is the single source of truth for both the wire-format
131
+ * JSON Schema sent to the provider (via `.toJson()`) and the runtime argument
132
+ * validation (via `.validate(rawArgs)`). Use `JsonSchema.object(...)` from
133
+ * `@fgv/ts-json-base` to author the schema as a const (e.g. `const mySchema = JsonSchema.object({...})`);
134
+ * the static type `TParams` is then derived via `JsonSchema.Static<typeof mySchema>` —
135
+ * no drift between wire schema and runtime validation.
136
+ *
137
+ * @public
138
+ */
139
+ export interface IAiClientToolConfig<TParams = unknown> {
140
+ /** Discriminator — always `'client_tool'`. */
141
+ readonly type: 'client_tool';
142
+ /** Tool name sent to the model (must be unique within a call). */
143
+ readonly name: string;
144
+ /** Human-readable description of what the tool does, shown to the model. */
145
+ readonly description: string;
146
+ /**
147
+ * JSON Schema validator for the tool's parameters. Emits wire format via
148
+ * `.toJson()` and validates model-returned args via `.validate(rawArgs)`.
149
+ */
150
+ readonly parametersSchema: JsonSchema.ISchemaValidator<TParams>;
151
+ }
152
+ /**
153
+ * A client-defined tool: configuration + execution callback pair.
154
+ *
155
+ * @remarks
156
+ * The `execute` callback receives typed `TParams` (already validated by
157
+ * `config.parametersSchema.validate()`) and returns a `Promise<Result<unknown>>`.
158
+ * Thrown errors are caught via `captureAsyncResult` in the round-trip helper.
159
+ *
160
+ * @public
161
+ */
162
+ export interface IAiClientTool<TParams = unknown> {
163
+ /** The tool's configuration (name, description, parameters schema). */
164
+ readonly config: IAiClientToolConfig<TParams>;
165
+ /**
166
+ * Execute the tool with validated parameters.
167
+ * @param args - Typed arguments, already validated against `config.parametersSchema`.
168
+ * @returns A `Promise<Result<unknown>>` — the result is stringified and sent back to the model.
169
+ */
170
+ readonly execute: (args: TParams) => Promise<Result<unknown>>;
171
+ }
172
+ /**
173
+ * Union of all tool configurations: server-side or client-defined.
174
+ * Discriminated on `type`.
175
+ * @public
176
+ */
177
+ export type AiToolConfig = AiServerToolConfig | IAiClientToolConfig;
178
+ /**
179
+ * Emitted when a client-defined tool call begins streaming. Carries the tool name
180
+ * and optional provider-assigned call ID (Anthropic / OpenAI Responses API; absent
181
+ * for Gemini which does not assign call IDs).
182
+ * @public
183
+ */
184
+ export interface IAiStreamToolUseStart {
185
+ readonly type: 'client-tool-call-start';
186
+ /** The name of the client tool being called. */
187
+ readonly toolName: string;
188
+ /**
189
+ * Provider-assigned call identifier (Anthropic: `toolu_*`; OpenAI: `call_*`).
190
+ * Absent for Gemini (correlation by name).
191
+ */
192
+ readonly callId?: string;
193
+ }
194
+ /**
195
+ * Emitted when a client-defined tool call is complete and its arguments are fully
196
+ * accumulated. The `args` object is the fully parsed JSON object — no further
197
+ * streaming deltas follow for this call.
198
+ * @public
199
+ */
200
+ export interface IAiStreamToolUseDelta {
201
+ readonly type: 'client-tool-call-done';
202
+ /** The name of the client tool being called. */
203
+ readonly toolName: string;
204
+ /**
205
+ * Provider-assigned call identifier. Absent for Gemini.
206
+ */
207
+ readonly callId?: string;
208
+ /** The fully accumulated and parsed tool arguments. */
209
+ readonly args: JsonObject;
210
+ }
211
+ /**
212
+ * Emitted after a client-defined tool has been executed and the result is ready
213
+ * to be fed back to the model in the round-trip continuation.
214
+ * @public
215
+ */
216
+ export interface IAiStreamToolUseComplete {
217
+ readonly type: 'client-tool-result';
218
+ /** The name of the client tool that was executed. */
219
+ readonly toolName: string;
220
+ /**
221
+ * Provider-assigned call identifier. Absent for Gemini.
222
+ */
223
+ readonly callId?: string;
224
+ /** The stringified result returned by the tool's execute callback. */
225
+ readonly result: string;
226
+ /** Whether the tool execution failed (schema validation failure, execute error, or unknown tool). */
227
+ readonly isError: boolean;
228
+ }
229
+ /**
230
+ * Summary of a single client tool call within a turn: the tool name, call ID,
231
+ * raw arguments, execution result, and whether the execution was an error.
232
+ * @public
233
+ */
234
+ export interface IAiClientToolCallSummary {
235
+ /** The name of the tool that was called. */
236
+ readonly toolName: string;
237
+ /** Provider-assigned call identifier (absent for Gemini). */
238
+ readonly callId?: string;
239
+ /** The fully accumulated raw arguments object as parsed JSON. */
240
+ readonly args: JsonObject;
241
+ /** The stringified result (success value or error message). */
242
+ readonly result: string;
243
+ /** Whether execution failed (schema validation failure, execute error, or unknown tool). */
244
+ readonly isError: boolean;
245
+ }
246
+ /**
247
+ * The provider-specific continuation data needed to build the follow-up request
248
+ * for the next round of the conversation.
249
+ *
250
+ * @remarks
251
+ * `messages` are provider-native request objects (Anthropic: content-block arrays,
252
+ * OpenAI Responses API: input items, Gemini: content parts). The continuation
253
+ * builder in `clientToolContinuationBuilder.ts` populates this.
254
+ *
255
+ * @public
256
+ */
257
+ export interface IAiClientToolContinuation {
258
+ /**
259
+ * Provider-native wire-format message objects to supply back on the next
260
+ * streaming call via `IExecuteClientToolTurnParams.continuationMessages`
261
+ * (which is forwarded as `rawTail` to the underlying call). The exact
262
+ * shape depends on the provider format and may contain provider-specific
263
+ * blocks (e.g. Anthropic thinking/redacted_thinking/tool_use). These are
264
+ * NOT `IChatMessage[]` and must not be prepended via `messagesBefore` —
265
+ * the normalized-message path would strip the provider-native fields
266
+ * (signatures, redacted thinking) that the server requires for
267
+ * continuation validation.
268
+ */
269
+ readonly messages: ReadonlyArray<JsonObject>;
270
+ /** Summary of each tool call that was executed in this turn. */
271
+ readonly toolCallsSummary: ReadonlyArray<IAiClientToolCallSummary>;
272
+ }
273
+ /**
274
+ * The result of a single client-tool turn: the optional continuation for the next
275
+ * call (absent when no tool calls occurred) and whether the stream was truncated.
276
+ * @public
277
+ */
278
+ export interface IAiClientToolTurnResult {
279
+ /**
280
+ * The continuation data for the next round-trip. `undefined` when the model
281
+ * completed without invoking any client tools.
282
+ */
283
+ readonly continuation: IAiClientToolContinuation | undefined;
284
+ /** Whether the stream was truncated (token limit or stop reason). */
285
+ readonly truncated: boolean;
286
+ /** The full concatenated text from all `text-delta` events in this turn. */
287
+ readonly fullText: string;
288
+ }
126
289
  /**
127
290
  * Known context keys for model specification maps.
128
291
  * @public
@@ -259,6 +422,15 @@ export interface IAiStreamDone {
259
422
  readonly truncated: boolean;
260
423
  /** The full concatenated text from all `text-delta` events. */
261
424
  readonly fullText: string;
425
+ /**
426
+ * Provider-reported reason a truncated response was cut short (e.g.
427
+ * `'max_output_tokens'`, `'content_filter'`), when the provider supplies one.
428
+ * Currently populated only by the OpenAI / xAI Responses adapter, from the
429
+ * completed payload's `incomplete_details.reason`. Meaningful only when
430
+ * `truncated === true`; `undefined` otherwise (and whenever the provider
431
+ * reports truncation without a reason).
432
+ */
433
+ readonly incompleteReason?: string;
262
434
  }
263
435
  /**
264
436
  * Terminal failure event for a streaming completion. After this event no
@@ -278,9 +450,15 @@ export interface IAiStreamError {
278
450
  }
279
451
  /**
280
452
  * Discriminated union of events emitted by a streaming completion.
453
+ *
454
+ * @remarks
455
+ * **Exhaustive-switch consumers must handle all variants.** The three
456
+ * `client-tool-*` variants were added when client-tool support shipped;
457
+ * update every exhaustive switch over this union in lockstep.
458
+ *
281
459
  * @public
282
460
  */
283
- export type IAiStreamEvent = IAiStreamTextDelta | IAiStreamToolEvent | IAiStreamDone | IAiStreamError;
461
+ export type IAiStreamEvent = IAiStreamTextDelta | IAiStreamToolEvent | IAiStreamToolUseStart | IAiStreamToolUseDelta | IAiStreamToolUseComplete | IAiStreamDone | IAiStreamError;
284
462
  /**
285
463
  * Thinking/reasoning mode support for a provider.
286
464
  * @public
@@ -738,7 +916,9 @@ export type XAiThinkingModelNames = 'grok-3-mini' | 'grok-4.3' | 'grok-4';
738
916
  */
739
917
  export interface IAnthropicThinkingConfig {
740
918
  /**
741
- * Anthropic effort level. Maps 1:1 to `output_config.effort` on the wire.
919
+ * Anthropic effort level. The emit-site converts to `thinking.budget_tokens`
920
+ * (the integer budget the Anthropic API requires). Mapping policy: low = 2048,
921
+ * medium = 8192, high = 24000, max = 32000.
742
922
  * - 'low' | 'medium' | 'high': all thinking-capable models
743
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O,IAAI,IAAI,EAAE,CAAC;QAC7C,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,sBAAsB;IACtB,IAAI,2BAAmB,IAAI,IAAI,EAAE,CAAC;QAChC,OAAO,YAAY,CAAC,IAAI,CAAC,2BAAmB,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,yCAAyC;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,6FAA6F;IAC7F,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAs2BD;;;GAGG;AACU,QAAA,iBAAiB,GAAsB;IAClD,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;CACxC,CAAC","sourcesContent":["// Copyright (c) 2026 Erik Fortune\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/**\n * Core types for AI assist: prompt class, provider descriptors, settings, and chat messages.\n * @packageDocumentation\n */\n\nimport { type Result } from '@fgv/ts-utils';\nimport { type JsonObject } from '@fgv/ts-json-base';\n\n// ============================================================================\n// Image Data\n// ============================================================================\n\n/**\n * Universal image representation used for both image input (vision prompts)\n * and image output (generation responses).\n *\n * @remarks\n * The base64 string is raw — no `data:` URL prefix. Use {@link AiAssist.toDataUrl} to\n * format it for browser-display contexts.\n *\n * @public\n */\nexport interface IAiImageData {\n /** MIME type, e.g. `'image/png'`, `'image/jpeg'`, `'image/webp'`. */\n readonly mimeType: string;\n /** Base64-encoded image bytes (no `data:` prefix). */\n readonly base64: string;\n}\n\n/**\n * Formats an {@link IAiImageData} as a `data:` URL suitable for browser display.\n * @param image - The image to format\n * @returns A `data:<mime>;base64,<data>` URL string\n * @public\n */\nexport function toDataUrl(image: IAiImageData): string {\n return `data:${image.mimeType};base64,${image.base64}`;\n}\n\n/**\n * Image attachment for a vision (image-input) prompt.\n *\n * @remarks\n * Extends {@link IAiImageData} with an OpenAI-specific `detail` hint that is\n * silently ignored by Anthropic, Gemini, and other providers.\n *\n * @public\n */\nexport interface IAiImageAttachment extends IAiImageData {\n /**\n * OpenAI vision detail hint:\n * - `'low'`: faster, cheaper, lower fidelity\n * - `'high'`: slower, more expensive, higher fidelity\n * - `'auto'` (default): provider chooses\n *\n * Ignored by providers other than OpenAI.\n */\n readonly detail?: 'low' | 'high' | 'auto';\n}\n\n// ============================================================================\n// AiPrompt\n// ============================================================================\n\n/**\n * A structured AI prompt with system/user split for direct API calls,\n * and a lazily-constructed combined version for copy/paste workflows.\n * @public\n */\nexport class AiPrompt {\n /** System instructions: schema documentation, format rules, general guidance. */\n public readonly system: string;\n /** User request: the specific entity generation request. */\n public readonly user: string;\n /**\n * Optional image attachments. When present, vision-capable providers will\n * include them in the user message; non-vision providers will reject the\n * call up front (see {@link AiAssist.IAiProviderDescriptor.acceptsImageInput}).\n */\n public readonly attachments: ReadonlyArray<IAiImageAttachment>;\n\n public constructor(user: string, system: string, attachments?: ReadonlyArray<IAiImageAttachment>) {\n this.system = system;\n this.user = user;\n this.attachments = attachments ?? [];\n }\n\n /**\n * Combined single-string version (user + system joined) for copy/paste.\n * When attachments are present, includes a sentinel noting they aren't\n * part of the copied text.\n */\n public get combined(): string {\n const sentinel =\n this.attachments.length > 0\n ? `\\n\\n[${this.attachments.length} image attachment(s) — not included in copied text]`\n : '';\n return `${this.user}${sentinel}\\n\\n${this.system}`;\n }\n}\n\n// ============================================================================\n// Chat Message\n// ============================================================================\n\n/**\n * A single chat message in OpenAI format.\n * @public\n */\nexport interface IChatMessage {\n /** Message role */\n readonly role: 'system' | 'user' | 'assistant';\n /** Message content */\n readonly content: string;\n}\n\n// ============================================================================\n// Server-Side Tools\n// ============================================================================\n\n/**\n * Built-in server-side tool types supported across providers.\n * @public\n */\nexport type AiServerToolType = 'web_search';\n\n/**\n * Configuration specific to web search tools.\n * @public\n */\nexport interface IAiWebSearchToolConfig {\n readonly type: 'web_search';\n /** Optional: restrict search to these domains. */\n readonly allowedDomains?: ReadonlyArray<string>;\n /** Optional: exclude these domains from search. */\n readonly blockedDomains?: ReadonlyArray<string>;\n /** Optional: max number of searches per request. */\n readonly maxUses?: number;\n /**\n * Optional: enable image understanding during web search.\n * When true, the model can view and analyze images found during search.\n * Currently supported by xAI only; ignored by other providers.\n */\n readonly enableImageUnderstanding?: boolean;\n}\n\n/**\n * Union of all server-side tool configurations. Discriminated on `type`.\n * @public\n */\nexport type AiServerToolConfig = IAiWebSearchToolConfig;\n\n/**\n * Declares a tool as enabled/disabled in provider settings.\n * Tools are disabled by default — consuming apps must opt in explicitly.\n * @public\n */\nexport interface IAiToolEnablement {\n /** Which tool type. */\n readonly type: AiServerToolType;\n /** Whether this tool is enabled by default for this provider. */\n readonly enabled: boolean;\n /** Optional tool-specific configuration. */\n readonly config?: AiServerToolConfig;\n}\n\n// ============================================================================\n// Model Specification\n// ============================================================================\n\n/**\n * Known context keys for model specification maps.\n * @public\n */\nexport type ModelSpecKey = 'base' | 'tools' | 'image' | 'thinking';\n\n/**\n * All valid {@link ModelSpecKey} values.\n * @public\n */\nexport const allModelSpecKeys: ReadonlyArray<ModelSpecKey> = ['base', 'tools', 'image', 'thinking'];\n\n/**\n * Default context key used as fallback when resolving a {@link ModelSpec}.\n * @public\n */\nexport const MODEL_SPEC_BASE_KEY: ModelSpecKey = 'base';\n\n/**\n * A model specification: either a simple model string or a record mapping\n * context keys to nested model specs.\n *\n * @remarks\n * A bare string is equivalent to `{ base: string }`. This keeps the simple\n * case simple while allowing context-aware model selection (e.g. different\n * models for tool-augmented vs. base completions).\n *\n * @example\n * ```typescript\n * // Simple — same model for all contexts:\n * const simple: ModelSpec = 'grok-4.3';\n *\n * // Context-aware — different model for tools and thinking:\n * const split: ModelSpec = { base: 'grok-4.3', tools: 'grok-4.3', thinking: 'grok-4.3' };\n *\n * // Future nested — per-tool model selection:\n * const nested: ModelSpec = { base: 'grok-fast', tools: { base: 'grok-r', image: 'grok-v' } };\n * ```\n * @public\n */\nexport interface IModelSpecMap {\n readonly [key: string]: ModelSpec;\n}\n\n/**\n * @public\n */\nexport type ModelSpec = string | IModelSpecMap;\n\n/**\n * Resolves a {@link ModelSpec} to a concrete model string given an optional context key.\n *\n * @remarks\n * Resolution rules:\n * 1. If the spec is a string, return it directly (context is irrelevant).\n * 2. If the spec is an object and the context key exists, recurse into that branch.\n * 3. Otherwise, fall back to the {@link MODEL_SPEC_BASE_KEY | 'base'} key.\n * 4. If neither context nor `'base'` exists, use the first available value.\n *\n * @param spec - The model specification to resolve\n * @param context - Optional context key (e.g. `'tools'`)\n * @returns The resolved model string\n * @public\n */\nexport function resolveModel(spec: ModelSpec, context?: string): string {\n if (typeof spec === 'string') {\n return spec;\n }\n\n // Try the requested context key first\n if (context !== undefined && context in spec) {\n return resolveModel(spec[context]);\n }\n\n // Fall back to 'base'\n if (MODEL_SPEC_BASE_KEY in spec) {\n return resolveModel(spec[MODEL_SPEC_BASE_KEY]);\n }\n\n // Last resort: first value in the record\n const first = Object.values(spec)[0];\n /* c8 ignore next 3 - defensive: only reachable with empty object (prevented by converter) */\n if (first === undefined) {\n return '';\n }\n return resolveModel(first);\n}\n\n// ============================================================================\n// Provider Descriptor\n// ============================================================================\n\n/**\n * All known AI provider identifiers.\n * @public\n */\nexport type AiProviderId =\n | 'copy-paste'\n | 'xai-grok'\n | 'openai'\n | 'openai-compat'\n | 'anthropic'\n | 'google-gemini'\n | 'groq'\n | 'mistral'\n | 'ollama';\n\n/**\n * API format categories for provider routing.\n * @public\n */\nexport type AiApiFormat = 'openai' | 'anthropic' | 'gemini';\n\n/**\n * API format categories for image-generation provider routing.\n *\n * @remarks\n * - `'openai-images'` — OpenAI Images API. Routes to `/images/generations`\n * (text-only) or `/images/edits` (when reference images are present).\n * - `'xai-images'` — xAI Images API. Text-only JSON generation request.\n * - `'xai-images-edits'` — xAI Images API for Grok Imagine models. Uses JSON\n * body with `{ type: \"image_url\" }` objects (not multipart).\n * - `'gemini-imagen'` — Google Imagen `:predict` endpoint. Text-only.\n * - `'gemini-image-out'` — Google Gemini chat-style `:generateContent`\n * endpoint that returns image parts (Gemini 2.5 Flash Image / \"Nano\n * Banana\"). Accepts reference images.\n *\n * @public\n */\nexport type AiImageApiFormat =\n | 'openai-images'\n | 'gemini-imagen'\n | 'xai-images'\n | 'xai-images-edits'\n | 'gemini-image-out';\n\n// ============================================================================\n// Completion Response\n// ============================================================================\n\n/**\n * Result of an AI provider completion call.\n * @public\n */\nexport interface IAiCompletionResponse {\n /** The generated text content */\n readonly content: string;\n /** Whether the response was truncated due to token limits */\n readonly truncated: boolean;\n}\n\n// ============================================================================\n// Streaming Events\n// ============================================================================\n\n/**\n * A text-content delta arriving during a streaming completion.\n * @public\n */\nexport interface IAiStreamTextDelta {\n readonly type: 'text-delta';\n /** The newly arrived text fragment. */\n readonly delta: string;\n}\n\n/**\n * A server-side tool progress event arriving during a streaming completion.\n * Surfaced for providers that emit explicit tool-progress markers (OpenAI\n * Responses API, Anthropic). Gemini's grounding doesn't emit these.\n * @public\n */\nexport interface IAiStreamToolEvent {\n readonly type: 'tool-event';\n /** Which server-side tool this event describes. */\n readonly toolType: AiServerToolType;\n /** Tool lifecycle phase. */\n readonly phase: 'started' | 'completed';\n /**\n * Optional provider-specific detail. For web_search this is typically the\n * search query when available; format varies by provider.\n */\n readonly detail?: string;\n}\n\n/**\n * Terminal success event for a streaming completion. Carries the aggregated\n * full text and truncation status for callers that want both the progressive\n * UI and the complete result.\n * @public\n */\nexport interface IAiStreamDone {\n readonly type: 'done';\n /** Whether the response was truncated due to token limits. */\n readonly truncated: boolean;\n /** The full concatenated text from all `text-delta` events. */\n readonly fullText: string;\n}\n\n/**\n * Terminal failure event for a streaming completion. After this event no\n * further events are emitted.\n *\n * @remarks\n * Connection-time failures (auth, network, pre-flight CORS rejection) are\n * surfaced via the outer `Result.fail` returned by\n * `callProviderCompletionStream` rather than as an `error` event, so callers\n * can distinguish \"didn't start\" from \"started but errored mid-stream.\"\n *\n * @public\n */\nexport interface IAiStreamError {\n readonly type: 'error';\n readonly message: string;\n}\n\n/**\n * Discriminated union of events emitted by a streaming completion.\n * @public\n */\nexport type IAiStreamEvent = IAiStreamTextDelta | IAiStreamToolEvent | IAiStreamDone | IAiStreamError;\n\n/**\n * Thinking/reasoning mode support for a provider.\n * @public\n */\nexport type AiThinkingMode = 'optional' | 'required' | 'unsupported';\n\n/**\n * Describes a single AI provider — single source of truth for all metadata.\n * @public\n */\nexport interface IAiProviderDescriptor {\n /** Provider identifier (e.g. 'xai-grok', 'anthropic') */\n readonly id: AiProviderId;\n /** Human-readable label (e.g. \"xAI Grok\") */\n readonly label: string;\n /** Button label for action buttons (e.g. \"AI Assist | Grok\") */\n readonly buttonLabel: string;\n /** Whether this provider requires an API key secret */\n readonly needsSecret: boolean;\n /** Which API adapter format to use */\n readonly apiFormat: AiApiFormat;\n /** Base URL for the API (e.g. 'https://api.x.ai/v1') */\n readonly baseUrl: string;\n /** Default model specification — string or context-aware map. */\n readonly defaultModel: ModelSpec;\n /** Which server-side tools this provider supports (empty = none). */\n readonly supportedTools: ReadonlyArray<AiServerToolType>;\n /** Whether this provider's API enforces CORS restrictions that prevent direct browser calls. */\n readonly corsRestricted: boolean;\n /**\n * Whether this provider's streaming completion endpoint requires a proxy\n * for direct browser calls. Some providers gate streaming separately from\n * non-streaming (rare), so this is tracked independently from\n * {@link IAiProviderDescriptor.corsRestricted}.\n *\n * @remarks\n * When `true`, `callProviderCompletionStream` rejects up front unless the\n * call is being routed through a proxy.\n */\n readonly streamingCorsRestricted: boolean;\n /**\n * Whether this provider's chat completions API accepts image input\n * (i.e. supports vision prompts). When false, calls with\n * `prompt.attachments` are rejected up front.\n */\n readonly acceptsImageInput: boolean;\n /**\n * Whether this provider supports thinking/reasoning mode.\n * - 'optional': thinking can be enabled but is not required\n * - 'required': thinking is always active (e.g. o-series models)\n * - 'unsupported': thinking is not supported\n */\n readonly thinkingMode: AiThinkingMode;\n /**\n * Image-generation capabilities, scoped to model id prefixes. Empty or\n * undefined means the provider does not support image generation.\n *\n * @remarks\n * The dispatcher matches the resolved model id against each rule's\n * `modelPrefix` and selects the longest match (see\n * {@link AiAssist.resolveImageCapability}). An empty `modelPrefix` is the\n * catch-all and matches every model id.\n *\n * Multiple entries support providers that host more than one image-API\n * surface under one baseUrl. Google Gemini is the canonical case: the\n * `imagen-*` family is predict-only via `:predict`, while\n * `gemini-2.5-flash-image` uses chat-style `:generateContent` and accepts\n * reference images. Listing both lets callers pick the right model and the\n * dispatcher routes accordingly.\n *\n * Image-model selection reuses the existing `image` {@link ModelSpecKey}.\n * Providers that declare `imageGeneration` should declare a model in\n * `defaultModel.image`, e.g. `{ base: 'gpt-4o', image: 'dall-e-3' }`.\n */\n readonly imageGeneration?: ReadonlyArray<IAiImageModelCapability>;\n}\n\n/**\n * Image-generation capability for a model family within a provider. Used as\n * an entry in {@link IAiProviderDescriptor.imageGeneration}.\n *\n * @public\n */\nexport interface IAiImageModelCapability {\n /**\n * Prefix matched against the resolved image model id. The empty string is\n * the catch-all and matches every model. When multiple rules' prefixes\n * match a model id, the longest prefix wins; ties are broken by\n * first-encountered.\n */\n readonly modelPrefix: string;\n /** API format used to dispatch requests for matching models. */\n readonly format: AiImageApiFormat;\n /**\n * Whether matching models accept reference images via\n * {@link AiAssist.IAiImageGenerationParams.referenceImages}. When false or\n * undefined, calls that include reference images are rejected up front.\n */\n readonly acceptsImageReferenceInput?: boolean;\n /** Accepted size strings. When present, dispatcher pre-validates. */\n readonly acceptedSizes?: ReadonlyArray<string>;\n /** When true, quality param is sent. When false/undefined, don't send quality. */\n readonly supportsQualityParam?: boolean;\n /** Accepted quality values when supportsQualityParam is true. */\n readonly acceptedQualities?: ReadonlyArray<string>;\n /** Maximum count (n). When present, dispatcher pre-validates. */\n readonly maxCount?: number;\n /**\n * How to encode the output format on the wire:\n * - 'response-format': send response_format: 'b64_json' (dall-e-2, dall-e-3)\n * - 'output-format': send output_format (gpt-image-1)\n * - 'none': send neither (Imagen, Gemini Flash)\n */\n readonly outputParamStyle?: 'response-format' | 'output-format' | 'none';\n /** Default MIME type for response images. */\n readonly defaultOutputMimeType?: string;\n}\n\n// ============================================================================\n// Image Generation — Layered Options Types\n// ============================================================================\n\n/** Pixel dimension sizes accepted by dall-e-2. @public */\nexport type DallE2Size = '256x256' | '512x512' | '1024x1024';\n\n/** Pixel dimension sizes accepted by dall-e-3. @public */\nexport type DallE3Size = '1024x1024' | '1792x1024' | '1024x1792';\n\n/** Pixel dimension sizes accepted by gpt-image-1. @public */\nexport type GptImageSize = '1024x1024' | '1536x1024' | '1024x1536' | 'auto';\n\n/** All accepted image size strings across all providers. @public */\nexport type AiImageSize = DallE2Size | DallE3Size | GptImageSize;\n\n/** Quality values for dall-e-3. @public */\nexport type DallE3Quality = 'standard' | 'hd';\n\n/** Quality values for gpt-image-1. @public */\nexport type GptImageQuality = 'low' | 'medium' | 'high' | 'auto';\n\n/** All accepted quality strings across all providers. @public */\nexport type AiImageQuality = DallE3Quality | GptImageQuality;\n\n/** Model names in the DALL-E family. @public */\nexport type DallEModelNames = 'dall-e-2' | 'dall-e-3';\n\n/** Model names in the GPT Image family. @public */\nexport type GptImageModelNames = 'gpt-image-1';\n\n/** Model names in the xAI Grok Imagine family. @public */\nexport type GrokImagineModelNames = 'grok-imagine-image' | 'grok-imagine-image-quality';\n\n/** Model names in the Imagen 4 family. @public */\nexport type Imagen4ModelNames =\n | 'imagen-4.0-generate-001'\n | 'imagen-4.0-ultra-generate-001'\n | 'imagen-4.0-fast-generate-001';\n\n/** Model names in the Gemini Flash Image family. @public */\nexport type GeminiFlashImageModelNames = 'gemini-2.5-flash-image';\n\n// ---- Family-level config shapes ----\n\n/**\n * Provider-specific config for DALL-E models (dall-e-2, dall-e-3).\n * @remarks\n * style is only valid for dall-e-3; the runtime validator rejects it for dall-e-2.\n * @public\n */\nexport interface IDallEImageGenerationConfig {\n /** Image dimensions (dall-e-2: 256x256|512x512|1024x1024; dall-e-3: 1024x1024|1792x1024|1024x1792). */\n readonly size?: DallE2Size | DallE3Size;\n /** dall-e-3 only. Quality tier. */\n readonly quality?: DallE3Quality;\n /** dall-e-3 only. Visual style. */\n readonly style?: 'vivid' | 'natural';\n}\n\n/**\n * Provider-specific config for gpt-image-1.\n * @public\n */\nexport interface IGptImageGenerationConfig {\n /** Image dimensions. */\n readonly size?: GptImageSize;\n /** Quality tier. */\n readonly quality?: GptImageQuality;\n /** Output format (replaces response_format for this model). */\n readonly outputFormat?: 'png' | 'jpeg' | 'webp';\n /** JPEG/WebP compression level 0–100. */\n readonly outputCompression?: number;\n /** Background transparency control. */\n readonly background?: 'transparent' | 'opaque' | 'auto';\n /** Content moderation strictness. */\n readonly moderation?: 'low' | 'auto';\n}\n\n/**\n * Provider-specific config for xAI Grok Imagine models.\n * @public\n */\nexport interface IGrokImagineImageGenerationConfig {\n /** Aspect ratio string (xAI uses aspect ratios, not pixel dimensions). */\n readonly aspectRatio?: string;\n /** Resolution hint. */\n readonly resolution?: string;\n}\n\n/**\n * Provider-specific config for Google Imagen 4 models.\n * @public\n */\nexport interface IImagen4GenerationConfig {\n /** Aspect ratio string. */\n readonly aspectRatio?: '1:1' | '3:4' | '4:3' | '9:16' | '16:9';\n /** Output resolution. */\n readonly imageSize?: '1K' | '2K';\n /** Whether to add SynthID watermark. Must be false to use seed. */\n readonly addWatermark?: boolean;\n /** LLM-based prompt rewriting. */\n readonly enhancePrompt?: boolean;\n /** Output MIME type. */\n readonly outputMimeType?: 'image/jpeg' | 'image/png';\n /** JPEG compression quality. */\n readonly outputCompressionQuality?: number;\n /** Person generation policy. */\n readonly personGeneration?: 'allow_all' | 'allow_adult' | 'dont_allow';\n}\n\n/**\n * Provider-specific config for Gemini Flash Image.\n * @public\n */\nexport interface IGeminiFlashImageGenerationConfig {\n /** Aspect ratio string. */\n readonly aspectRatio?: string;\n}\n\n// ---- Model-family option blocks ----\n\n/**\n * Base shape shared by all named family option blocks.\n * Provides a typed `models` field for applicability filtering without unsafe casts.\n * @internal\n */\nexport interface INamedModelFamilyConfig {\n readonly models?: readonly string[];\n}\n\n/**\n * Options block scoped to DALL-E family models.\n * @public\n */\nexport interface IDallEModelOptions extends INamedModelFamilyConfig {\n /** Discriminator: openai provider lineage. */\n readonly provider: 'openai';\n /** Family identifier. */\n readonly family: 'dall-e';\n /** Optional model names this block applies to. Omit = applies to all DALL-E models. */\n readonly models?: DallEModelNames[];\n /** Family-specific config. */\n readonly config: IDallEImageGenerationConfig;\n}\n\n/**\n * Options block scoped to GPT Image family models.\n * @public\n */\nexport interface IGptImageModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'openai';\n readonly family: 'gpt-image';\n readonly models?: GptImageModelNames[];\n readonly config: IGptImageGenerationConfig;\n}\n\n/**\n * Options block scoped to xAI Grok Imagine family models.\n * @public\n */\nexport interface IGrokImagineModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'xai';\n readonly family: 'grok-imagine';\n readonly models?: GrokImagineModelNames[];\n readonly config: IGrokImagineImageGenerationConfig;\n}\n\n/**\n * Options block scoped to Google Imagen 4 models.\n * @public\n */\nexport interface IImagen4ModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'google';\n readonly family: 'imagen-4';\n readonly models?: Imagen4ModelNames[];\n readonly config: IImagen4GenerationConfig;\n}\n\n/**\n * Options block scoped to Gemini Flash Image models.\n * @public\n */\nexport interface IGeminiFlashImageModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'google';\n readonly family: 'gemini-flash-image';\n readonly models?: GeminiFlashImageModelNames[];\n readonly config: IGeminiFlashImageGenerationConfig;\n}\n\n/**\n * Escape-hatch options block for models not covered by a named family.\n * @remarks\n * `models` is required — there is no implicit \"all\" for unknown model families.\n * `config` is `JsonObject` — passed verbatim to the wire request with no validation.\n * This is the \"trust me, I know what I'm doing\" path for callers who need to send\n * wire params our typed configs don't yet expose.\n * @public\n */\nexport interface IOtherModelOptions {\n readonly provider: 'other';\n readonly models: string[];\n readonly config: JsonObject;\n}\n\n/**\n * Discriminated union of all model-family option blocks.\n * Discriminated on `provider` + `family` fields.\n * @public\n */\nexport type IModelFamilyConfig =\n | IDallEModelOptions\n | IGptImageModelOptions\n | IGrokImagineModelOptions\n | IImagen4ModelOptions\n | IGeminiFlashImageModelOptions\n | IOtherModelOptions;\n\n// ============================================================================\n// Image Generation\n// ============================================================================\n\n/**\n * Options for image generation requests.\n *\n * @remarks\n * Uses a layered architecture:\n * 1. Generic top-level options (size, count, quality, seed) apply across providers\n * via the resolved model's registry mapping.\n * 2. Optional `models` array contains model-family-scoped blocks; the resolver\n * picks applicable blocks based on the resolved model and applies them in\n * declaration order.\n *\n * **Merge precedence (later wins):**\n * 1. Generic top-level options (lowest precedence)\n * 2. Family-generic blocks (matching family, models field omitted)\n * 3. Model-specific blocks (models array includes resolved model name)\n * 4. Other blocks (provider: 'other', models array includes resolved model name)\n *\n * Provider-mismatch: blocks whose provider doesn't match the dispatcher's\n * provider lineage are silently skipped.\n *\n * @public\n */\nexport interface IAiImageGenerationOptions {\n /**\n * Image dimensions for OpenAI models (mapped to `size` field).\n * For xAI aspect ratio or Imagen aspect ratio, use the corresponding `models` family block.\n */\n readonly size?: AiImageSize;\n /** Number of images. Default 1. Some models enforce a maximum. */\n readonly count?: number;\n /**\n * Quality tier. Accepted values differ per model:\n * - dall-e-3: 'standard' | 'hd'\n * - gpt-image-1: 'low' | 'medium' | 'high' | 'auto'\n * Other models ignore this field.\n */\n readonly quality?: AiImageQuality;\n /** Reproducibility seed, where supported. */\n readonly seed?: number;\n /**\n * Optional precision via model-family-scoped blocks. The resolver picks\n * applicable blocks dynamically based on the resolved model.\n */\n readonly models?: ReadonlyArray<IModelFamilyConfig>;\n}\n\n/**\n * Parameters for an image-generation request.\n * @public\n */\nexport interface IAiImageGenerationParams {\n /** The text prompt describing the desired image. */\n readonly prompt: string;\n /** Optional generation options. */\n readonly options?: IAiImageGenerationOptions;\n /**\n * Optional reference images. When present, the provider will use them as\n * visual context (e.g. to preserve a character's appearance across multiple\n * generations). The dispatcher resolves the\n * {@link AiAssist.IAiImageModelCapability} for the requested model and\n * rejects the call up front if `acceptsImageReferenceInput` is not set on\n * the matching capability. An empty array is treated identically to\n * `undefined`.\n */\n readonly referenceImages?: ReadonlyArray<IAiImageAttachment>;\n}\n\n/**\n * A single generated image.\n * @public\n */\nexport interface IAiGeneratedImage extends IAiImageData {\n /**\n * The prompt as rewritten by the provider, if any. OpenAI's image models\n * commonly rewrite prompts; other providers do not.\n */\n readonly revisedPrompt?: string;\n}\n\n// ============================================================================\n// Model Catalog (listModels)\n// ============================================================================\n\n/**\n * Capability vocabulary used to describe what a model can do. Used as both\n * a filter and as a tag in {@link AiAssist.IAiModelInfo.capabilities}.\n *\n * @remarks\n * Adding a new capability is cheap; adding the *first* one after consumers\n * already exist forces churn. The initial vocabulary is intentionally broad\n * even though only `image-generation` is fully exercised today.\n *\n * @public\n */\nexport type AiModelCapability = 'chat' | 'tools' | 'vision' | 'image-generation' | 'thinking';\n\n/**\n * Information about a single model returned by a provider's list endpoint,\n * with capabilities already resolved (native + config rules).\n * @public\n */\nexport interface IAiModelInfo {\n /** Provider-native model identifier. */\n readonly id: string;\n /** Resolved capability set — union of native declarations and config rules. */\n readonly capabilities: ReadonlySet<AiModelCapability>;\n /** Friendly name for display, when known. */\n readonly displayName?: string;\n}\n\n/**\n * One rule in an {@link IAiModelCapabilityConfig}. Multiple rules can match\n * a single model — their capability arrays are unioned.\n * @public\n */\nexport interface IAiModelCapabilityRule {\n /** RegExp tested against the model id (using `.test`). */\n readonly idPattern: RegExp;\n /** Capabilities this rule attributes to matching models. */\n readonly capabilities: ReadonlyArray<AiModelCapability>;\n /**\n * Friendly display-name override for matching models. The function form\n * lets one rule format many ids (e.g. `(id) => id.toUpperCase()`).\n * If multiple matching rules supply `displayName`, the first match wins.\n */\n readonly displayName?: string | ((id: string) => string);\n}\n\n/**\n * Configuration that maps model id patterns to capabilities. Used to\n * augment (or, where the provider supplies no capability info, fully\n * derive) the capability set for each listed model.\n * @public\n */\nexport interface IAiModelCapabilityConfig {\n /** Per-provider rules. Tried before {@link AiAssist.IAiModelCapabilityConfig.global}. */\n readonly perProvider?: { readonly [P in AiProviderId]?: ReadonlyArray<IAiModelCapabilityRule> };\n /** Cross-provider fallback rules. */\n readonly global?: ReadonlyArray<IAiModelCapabilityRule>;\n}\n\n/**\n * Result of an image-generation call.\n * @public\n */\nexport interface IAiImageGenerationResponse {\n /** The generated images, in provider-returned order. */\n readonly images: ReadonlyArray<IAiGeneratedImage>;\n}\n\n// ============================================================================\n// Thinking / Reasoning Config — Layered Options Types\n// ============================================================================\n\n/**\n * Model IDs for Anthropic thinking-capable models.\n * @public\n */\nexport type AnthropicThinkingModelNames =\n | 'claude-sonnet-4-5'\n | 'claude-sonnet-4-6'\n | 'claude-opus-4-6'\n | 'claude-opus-4-7';\n\n/**\n * Model IDs for OpenAI thinking-capable models.\n * @public\n */\nexport type OpenAiThinkingModelNames =\n | 'o3'\n | 'o4-mini'\n | 'o3-deep-research'\n | 'o4-mini-deep-research'\n | 'gpt-5'\n | 'gpt-5.1'\n | 'gpt-5.2'\n | 'gpt-5.5'\n | 'gpt-5-pro';\n\n/**\n * Model IDs for Google Gemini thinking-capable models.\n * @public\n */\nexport type GeminiThinkingModelNames = 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite';\n\n/**\n * Model IDs for xAI thinking-capable models.\n * @public\n */\nexport type XAiThinkingModelNames = 'grok-3-mini' | 'grok-4.3' | 'grok-4';\n\n/**\n * Anthropic-specific thinking configuration.\n * @public\n */\nexport interface IAnthropicThinkingConfig {\n /**\n * Anthropic effort level. Maps 1:1 to `output_config.effort` on the wire.\n * - 'low' | 'medium' | 'high': all thinking-capable models\n * - 'max': Opus 4.6 only\n */\n readonly effort?: 'low' | 'medium' | 'high' | 'max';\n}\n\n/**\n * OpenAI-specific thinking configuration.\n * @remarks\n * Maps to `reasoning_effort` (Chat Completions path) or `reasoning.effort`\n * (Responses API path) on the wire. The adapter selects the correct field.\n * @public\n */\nexport interface IOpenAiThinkingConfig {\n /**\n * OpenAI reasoning effort. Maps 1:1 to the wire field.\n * - 'none': disables reasoning (gpt-5.x only; rejected by o-series)\n * - 'minimal': fastest (gpt-5.x)\n * - 'low' | 'medium' | 'high': standard tiers\n * - 'xhigh': highest (select gpt-5.x models only)\n *\n * @remarks\n * When effective effort is 'none', reasoning is disabled and temperature is\n * accepted by gpt-5.x models. This is the only case where temperature and\n * thinking config co-exist without a Result.fail.\n */\n readonly effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';\n}\n\n/**\n * Google Gemini-specific thinking configuration.\n * @public\n */\nexport interface IGeminiThinkingConfig {\n /**\n * Token budget for thinking. Maps 1:1 to `thinkingBudget` on the wire.\n * - 0: disable thinking (Flash and Flash-Lite only; error on Pro)\n * - positive integer: soft token cap\n * - -1: dynamic\n * - omitted: model default\n */\n readonly thinkingBudget?: number;\n /**\n * Whether to include thought summaries in the response.\n * @remarks\n * INERT in phase B. Adapters never send `includeThoughts: true`.\n * Wired up by the followup stream `ai-assist-thinking-events`.\n */\n readonly includeThoughts?: boolean;\n}\n\n/**\n * xAI-specific thinking configuration.\n * @public\n */\nexport interface IXAiThinkingConfig {\n /**\n * xAI reasoning effort. Maps 1:1 to `reasoning_effort` on the wire.\n * For grok-4, the adapter omits this field (grok-4 always reasons and\n * rejects the parameter).\n */\n readonly effort?: 'none' | 'low' | 'medium' | 'high';\n}\n\n/**\n * Anthropic-specific thinking options block.\n * @public\n */\nexport interface IAnthropicThinkingOptions {\n readonly provider: 'anthropic';\n readonly models?: ReadonlyArray<AnthropicThinkingModelNames>;\n readonly config: IAnthropicThinkingConfig;\n}\n\n/**\n * OpenAI-specific thinking options block.\n * @public\n */\nexport interface IOpenAiThinkingOptions {\n readonly provider: 'openai';\n readonly models?: ReadonlyArray<OpenAiThinkingModelNames>;\n readonly config: IOpenAiThinkingConfig;\n}\n\n/**\n * Google Gemini-specific thinking options block.\n * @public\n */\nexport interface IGeminiThinkingOptions {\n readonly provider: 'google';\n readonly models?: ReadonlyArray<GeminiThinkingModelNames>;\n readonly config: IGeminiThinkingConfig;\n}\n\n/**\n * xAI-specific thinking options block.\n * @public\n */\nexport interface IXAiThinkingOptions {\n readonly provider: 'xai';\n readonly models?: ReadonlyArray<XAiThinkingModelNames>;\n readonly config: IXAiThinkingConfig;\n}\n\n/**\n * Escape-hatch options block for providers not covered by typed configs.\n * @remarks\n * `models` is required — no implicit \"all\" for unknown providers.\n * `config` fields are merged verbatim into the wire request.\n * @public\n */\nexport interface IOtherThinkingOptions {\n readonly provider: 'other';\n readonly models: ReadonlyArray<string>;\n readonly config: JsonObject;\n}\n\n/**\n * Discriminated union of per-provider thinking config blocks.\n * @public\n */\nexport type IThinkingProviderConfig =\n | IAnthropicThinkingOptions\n | IOpenAiThinkingOptions\n | IGeminiThinkingOptions\n | IXAiThinkingOptions\n | IOtherThinkingOptions;\n\n/**\n * Thinking/reasoning mode configuration for a completion request.\n *\n * @remarks\n * The generic `effort` field covers the common-subset cross-provider vocabulary.\n * For provider-specific precision (Anthropic 'max', OpenAI 'xhigh', Gemini token\n * budgets, xAI effort-level tuning), use the `providers` array.\n *\n * Absence (or undefined) means \"no thinking mode\" — existing callers are unaffected.\n *\n * @public\n */\nexport interface IThinkingConfig {\n /**\n * Cross-provider effort level. Common-subset mapping:\n * - 'low': Anthropic effort:low | OpenAI effort:low | Gemini thinkingBudget:1024 | xAI reasoning_effort:low\n * - 'medium': effort:medium | effort:medium | thinkingBudget:4096 | reasoning_effort:medium\n * - 'high': effort:high | effort:high | thinkingBudget:8192 | reasoning_effort:high\n */\n readonly effort?: 'low' | 'medium' | 'high';\n /**\n * Optional per-provider precision blocks. Blocks for providers that don't\n * match the resolved model's provider are silently skipped.\n */\n readonly providers?: ReadonlyArray<IThinkingProviderConfig>;\n}\n\n// ============================================================================\n// Settings\n// ============================================================================\n\n/**\n * Configuration for a single AI assist provider.\n * @public\n */\nexport interface IAiAssistProviderConfig {\n /** Which provider this configures */\n readonly provider: AiProviderId;\n /** For API-based providers: the keystore secret name holding the API key */\n readonly secretName?: string;\n /** Optional model override — string or context-aware map. */\n readonly model?: ModelSpec;\n /** Tool enablement/configuration. Tools are disabled unless explicitly enabled. */\n readonly tools?: ReadonlyArray<IAiToolEnablement>;\n /**\n * Optional caller-supplied endpoint URL (http/https). Overrides\n * `descriptor.baseUrl` for this provider. Used to point a provider at a\n * self-hosted server (Ollama, LM Studio, llama.cpp's openai-server) or a\n * local proxy. Validation lives in `@fgv/ts-extras` — query strings,\n * fragments, and userinfo are rejected.\n */\n readonly endpoint?: string;\n}\n\n/**\n * AI assist settings — which providers are enabled and their configuration.\n * @public\n */\nexport interface IAiAssistSettings {\n /** Enabled providers and their configuration. */\n readonly providers: ReadonlyArray<IAiAssistProviderConfig>;\n /** Which enabled provider is the default for the main button. Falls back to first in list. */\n readonly defaultProvider?: AiProviderId;\n /** Optional proxy URL for routing API requests through a backend server (e.g. `http://localhost:3002`). */\n readonly proxyUrl?: string;\n /** When true, route all providers through the proxy. When false (default), only CORS-restricted providers use the proxy. */\n readonly proxyAllProviders?: boolean;\n}\n\n/**\n * Default AI assist settings (copy-paste only).\n * @public\n */\nexport const DEFAULT_AI_ASSIST: IAiAssistSettings = {\n providers: [{ provider: 'copy-paste' }]\n};\n\n// ============================================================================\n// Keystore Interface\n// ============================================================================\n\n/**\n * Minimal keystore interface for AI assist API key resolution.\n * Satisfied structurally by the concrete `KeyStore` class from `@fgv/ts-extras`.\n * @public\n */\nexport interface IAiAssistKeyStore {\n /** Whether the keystore is currently unlocked */\n readonly isUnlocked: boolean;\n /** Check if a named secret exists */\n hasSecret(name: string): Result<boolean>;\n /** Get an API key by secret name */\n getApiKey(name: string): Result<string>;\n}\n"]}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/packlets/ai-assist/model.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;;;AAqCZ,8BAEC;AA6XD,oCAsBC;AA3ZD;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,KAAmB;IAC3C,OAAO,QAAQ,KAAK,CAAC,QAAQ,WAAW,KAAK,CAAC,MAAM,EAAE,CAAC;AACzD,CAAC;AAuBD,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E;;;;GAIG;AACH,MAAa,QAAQ;IAYnB,YAAmB,IAAY,EAAE,MAAc,EAAE,WAA+C;QAC9F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACr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IACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AA83BD;;;GAGG;AACU,QAAA,iBAAiB,GAAsB;IAClD,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;CACxC,CAAC","sourcesContent":["// Copyright (c) 2026 Erik Fortune\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/**\n * Core types for AI assist: prompt class, provider descriptors, settings, and chat messages.\n * @packageDocumentation\n */\n\nimport { type Result } from '@fgv/ts-utils';\nimport { type JsonObject, type JsonSchema } from '@fgv/ts-json-base';\n\n// ============================================================================\n// Image Data\n// ============================================================================\n\n/**\n * Universal image representation used for both image input (vision prompts)\n * and image output (generation responses).\n *\n * @remarks\n * The base64 string is raw — no `data:` URL prefix. Use {@link AiAssist.toDataUrl} to\n * format it for browser-display contexts.\n *\n * @public\n */\nexport interface IAiImageData {\n /** MIME type, e.g. `'image/png'`, `'image/jpeg'`, `'image/webp'`. */\n readonly mimeType: string;\n /** Base64-encoded image bytes (no `data:` prefix). */\n readonly base64: string;\n}\n\n/**\n * Formats an {@link IAiImageData} as a `data:` URL suitable for browser display.\n * @param image - The image to format\n * @returns A `data:<mime>;base64,<data>` URL string\n * @public\n */\nexport function toDataUrl(image: IAiImageData): string {\n return `data:${image.mimeType};base64,${image.base64}`;\n}\n\n/**\n * Image attachment for a vision (image-input) prompt.\n *\n * @remarks\n * Extends {@link IAiImageData} with an OpenAI-specific `detail` hint that is\n * silently ignored by Anthropic, Gemini, and other providers.\n *\n * @public\n */\nexport interface IAiImageAttachment extends IAiImageData {\n /**\n * OpenAI vision detail hint:\n * - `'low'`: faster, cheaper, lower fidelity\n * - `'high'`: slower, more expensive, higher fidelity\n * - `'auto'` (default): provider chooses\n *\n * Ignored by providers other than OpenAI.\n */\n readonly detail?: 'low' | 'high' | 'auto';\n}\n\n// ============================================================================\n// AiPrompt\n// ============================================================================\n\n/**\n * A structured AI prompt with system/user split for direct API calls,\n * and a lazily-constructed combined version for copy/paste workflows.\n * @public\n */\nexport class AiPrompt {\n /** System instructions: schema documentation, format rules, general guidance. */\n public readonly system: string;\n /** User request: the specific entity generation request. */\n public readonly user: string;\n /**\n * Optional image attachments. When present, vision-capable providers will\n * include them in the user message; non-vision providers will reject the\n * call up front (see {@link AiAssist.IAiProviderDescriptor.acceptsImageInput}).\n */\n public readonly attachments: ReadonlyArray<IAiImageAttachment>;\n\n public constructor(user: string, system: string, attachments?: ReadonlyArray<IAiImageAttachment>) {\n this.system = system;\n this.user = user;\n this.attachments = attachments ?? [];\n }\n\n /**\n * Combined single-string version (user + system joined) for copy/paste.\n * When attachments are present, includes a sentinel noting they aren't\n * part of the copied text.\n */\n public get combined(): string {\n const sentinel =\n this.attachments.length > 0\n ? `\\n\\n[${this.attachments.length} image attachment(s) — not included in copied text]`\n : '';\n return `${this.user}${sentinel}\\n\\n${this.system}`;\n }\n}\n\n// ============================================================================\n// Chat Message\n// ============================================================================\n\n/**\n * A single chat message in OpenAI format.\n * @public\n */\nexport interface IChatMessage {\n /** Message role */\n readonly role: 'system' | 'user' | 'assistant';\n /** Message content */\n readonly content: string;\n}\n\n// ============================================================================\n// Server-Side Tools\n// ============================================================================\n\n/**\n * Built-in server-side tool types supported across providers.\n * @public\n */\nexport type AiServerToolType = 'web_search';\n\n/**\n * Configuration specific to web search tools.\n * @public\n */\nexport interface IAiWebSearchToolConfig {\n readonly type: 'web_search';\n /** Optional: restrict search to these domains. */\n readonly allowedDomains?: ReadonlyArray<string>;\n /** Optional: exclude these domains from search. */\n readonly blockedDomains?: ReadonlyArray<string>;\n /** Optional: max number of searches per request. */\n readonly maxUses?: number;\n /**\n * Optional: enable image understanding during web search.\n * When true, the model can view and analyze images found during search.\n * Currently supported by xAI only; ignored by other providers.\n */\n readonly enableImageUnderstanding?: boolean;\n}\n\n/**\n * Union of all server-side tool configurations. Discriminated on `type`.\n * @public\n */\nexport type AiServerToolConfig = IAiWebSearchToolConfig;\n\n/**\n * Declares a tool as enabled/disabled in provider settings.\n * Tools are disabled by default — consuming apps must opt in explicitly.\n * @public\n */\nexport interface IAiToolEnablement {\n /** Which tool type. */\n readonly type: AiServerToolType;\n /** Whether this tool is enabled by default for this provider. */\n readonly enabled: boolean;\n /** Optional tool-specific configuration. */\n readonly config?: AiServerToolConfig;\n}\n\n// ============================================================================\n// Client-Defined Tools\n// ============================================================================\n\n/**\n * Configuration for a client-defined (harness-supplied) tool.\n *\n * @remarks\n * The `parametersSchema` is the single source of truth for both the wire-format\n * JSON Schema sent to the provider (via `.toJson()`) and the runtime argument\n * validation (via `.validate(rawArgs)`). Use `JsonSchema.object(...)` from\n * `@fgv/ts-json-base` to author the schema as a const (e.g. `const mySchema = JsonSchema.object({...})`);\n * the static type `TParams` is then derived via `JsonSchema.Static<typeof mySchema>` —\n * no drift between wire schema and runtime validation.\n *\n * @public\n */\nexport interface IAiClientToolConfig<TParams = unknown> {\n /** Discriminator — always `'client_tool'`. */\n readonly type: 'client_tool';\n /** Tool name sent to the model (must be unique within a call). */\n readonly name: string;\n /** Human-readable description of what the tool does, shown to the model. */\n readonly description: string;\n /**\n * JSON Schema validator for the tool's parameters. Emits wire format via\n * `.toJson()` and validates model-returned args via `.validate(rawArgs)`.\n */\n readonly parametersSchema: JsonSchema.ISchemaValidator<TParams>;\n}\n\n/**\n * A client-defined tool: configuration + execution callback pair.\n *\n * @remarks\n * The `execute` callback receives typed `TParams` (already validated by\n * `config.parametersSchema.validate()`) and returns a `Promise<Result<unknown>>`.\n * Thrown errors are caught via `captureAsyncResult` in the round-trip helper.\n *\n * @public\n */\nexport interface IAiClientTool<TParams = unknown> {\n /** The tool's configuration (name, description, parameters schema). */\n readonly config: IAiClientToolConfig<TParams>;\n /**\n * Execute the tool with validated parameters.\n * @param args - Typed arguments, already validated against `config.parametersSchema`.\n * @returns A `Promise<Result<unknown>>` — the result is stringified and sent back to the model.\n */\n readonly execute: (args: TParams) => Promise<Result<unknown>>;\n}\n\n/**\n * Union of all tool configurations: server-side or client-defined.\n * Discriminated on `type`.\n * @public\n */\nexport type AiToolConfig = AiServerToolConfig | IAiClientToolConfig;\n\n// ============================================================================\n// Client Tool Streaming Events\n// ============================================================================\n\n/**\n * Emitted when a client-defined tool call begins streaming. Carries the tool name\n * and optional provider-assigned call ID (Anthropic / OpenAI Responses API; absent\n * for Gemini which does not assign call IDs).\n * @public\n */\nexport interface IAiStreamToolUseStart {\n readonly type: 'client-tool-call-start';\n /** The name of the client tool being called. */\n readonly toolName: string;\n /**\n * Provider-assigned call identifier (Anthropic: `toolu_*`; OpenAI: `call_*`).\n * Absent for Gemini (correlation by name).\n */\n readonly callId?: string;\n}\n\n/**\n * Emitted when a client-defined tool call is complete and its arguments are fully\n * accumulated. The `args` object is the fully parsed JSON object — no further\n * streaming deltas follow for this call.\n * @public\n */\nexport interface IAiStreamToolUseDelta {\n readonly type: 'client-tool-call-done';\n /** The name of the client tool being called. */\n readonly toolName: string;\n /**\n * Provider-assigned call identifier. Absent for Gemini.\n */\n readonly callId?: string;\n /** The fully accumulated and parsed tool arguments. */\n readonly args: JsonObject;\n}\n\n/**\n * Emitted after a client-defined tool has been executed and the result is ready\n * to be fed back to the model in the round-trip continuation.\n * @public\n */\nexport interface IAiStreamToolUseComplete {\n readonly type: 'client-tool-result';\n /** The name of the client tool that was executed. */\n readonly toolName: string;\n /**\n * Provider-assigned call identifier. Absent for Gemini.\n */\n readonly callId?: string;\n /** The stringified result returned by the tool's execute callback. */\n readonly result: string;\n /** Whether the tool execution failed (schema validation failure, execute error, or unknown tool). */\n readonly isError: boolean;\n}\n\n// ============================================================================\n// Client Tool Round-Trip Types\n// ============================================================================\n\n/**\n * Summary of a single client tool call within a turn: the tool name, call ID,\n * raw arguments, execution result, and whether the execution was an error.\n * @public\n */\nexport interface IAiClientToolCallSummary {\n /** The name of the tool that was called. */\n readonly toolName: string;\n /** Provider-assigned call identifier (absent for Gemini). */\n readonly callId?: string;\n /** The fully accumulated raw arguments object as parsed JSON. */\n readonly args: JsonObject;\n /** The stringified result (success value or error message). */\n readonly result: string;\n /** Whether execution failed (schema validation failure, execute error, or unknown tool). */\n readonly isError: boolean;\n}\n\n/**\n * The provider-specific continuation data needed to build the follow-up request\n * for the next round of the conversation.\n *\n * @remarks\n * `messages` are provider-native request objects (Anthropic: content-block arrays,\n * OpenAI Responses API: input items, Gemini: content parts). The continuation\n * builder in `clientToolContinuationBuilder.ts` populates this.\n *\n * @public\n */\nexport interface IAiClientToolContinuation {\n /**\n * Provider-native wire-format message objects to supply back on the next\n * streaming call via `IExecuteClientToolTurnParams.continuationMessages`\n * (which is forwarded as `rawTail` to the underlying call). The exact\n * shape depends on the provider format and may contain provider-specific\n * blocks (e.g. Anthropic thinking/redacted_thinking/tool_use). These are\n * NOT `IChatMessage[]` and must not be prepended via `messagesBefore` —\n * the normalized-message path would strip the provider-native fields\n * (signatures, redacted thinking) that the server requires for\n * continuation validation.\n */\n readonly messages: ReadonlyArray<JsonObject>;\n /** Summary of each tool call that was executed in this turn. */\n readonly toolCallsSummary: ReadonlyArray<IAiClientToolCallSummary>;\n}\n\n/**\n * The result of a single client-tool turn: the optional continuation for the next\n * call (absent when no tool calls occurred) and whether the stream was truncated.\n * @public\n */\nexport interface IAiClientToolTurnResult {\n /**\n * The continuation data for the next round-trip. `undefined` when the model\n * completed without invoking any client tools.\n */\n readonly continuation: IAiClientToolContinuation | undefined;\n /** Whether the stream was truncated (token limit or stop reason). */\n readonly truncated: boolean;\n /** The full concatenated text from all `text-delta` events in this turn. */\n readonly fullText: string;\n}\n\n// ============================================================================\n// Model Specification\n// ============================================================================\n\n/**\n * Known context keys for model specification maps.\n * @public\n */\nexport type ModelSpecKey = 'base' | 'tools' | 'image' | 'thinking';\n\n/**\n * All valid {@link ModelSpecKey} values.\n * @public\n */\nexport const allModelSpecKeys: ReadonlyArray<ModelSpecKey> = ['base', 'tools', 'image', 'thinking'];\n\n/**\n * Default context key used as fallback when resolving a {@link ModelSpec}.\n * @public\n */\nexport const MODEL_SPEC_BASE_KEY: ModelSpecKey = 'base';\n\n/**\n * A model specification: either a simple model string or a record mapping\n * context keys to nested model specs.\n *\n * @remarks\n * A bare string is equivalent to `{ base: string }`. This keeps the simple\n * case simple while allowing context-aware model selection (e.g. different\n * models for tool-augmented vs. base completions).\n *\n * @example\n * ```typescript\n * // Simple — same model for all contexts:\n * const simple: ModelSpec = 'grok-4.3';\n *\n * // Context-aware — different model for tools and thinking:\n * const split: ModelSpec = { base: 'grok-4.3', tools: 'grok-4.3', thinking: 'grok-4.3' };\n *\n * // Future nested — per-tool model selection:\n * const nested: ModelSpec = { base: 'grok-fast', tools: { base: 'grok-r', image: 'grok-v' } };\n * ```\n * @public\n */\nexport interface IModelSpecMap {\n readonly [key: string]: ModelSpec;\n}\n\n/**\n * @public\n */\nexport type ModelSpec = string | IModelSpecMap;\n\n/**\n * Resolves a {@link ModelSpec} to a concrete model string given an optional context key.\n *\n * @remarks\n * Resolution rules:\n * 1. If the spec is a string, return it directly (context is irrelevant).\n * 2. If the spec is an object and the context key exists, recurse into that branch.\n * 3. Otherwise, fall back to the {@link MODEL_SPEC_BASE_KEY | 'base'} key.\n * 4. If neither context nor `'base'` exists, use the first available value.\n *\n * @param spec - The model specification to resolve\n * @param context - Optional context key (e.g. `'tools'`)\n * @returns The resolved model string\n * @public\n */\nexport function resolveModel(spec: ModelSpec, context?: string): string {\n if (typeof spec === 'string') {\n return spec;\n }\n\n // Try the requested context key first\n if (context !== undefined && context in spec) {\n return resolveModel(spec[context]);\n }\n\n // Fall back to 'base'\n if (MODEL_SPEC_BASE_KEY in spec) {\n return resolveModel(spec[MODEL_SPEC_BASE_KEY]);\n }\n\n // Last resort: first value in the record\n const first = Object.values(spec)[0];\n /* c8 ignore next 3 - defensive: only reachable with empty object (prevented by converter) */\n if (first === undefined) {\n return '';\n }\n return resolveModel(first);\n}\n\n// ============================================================================\n// Provider Descriptor\n// ============================================================================\n\n/**\n * All known AI provider identifiers.\n * @public\n */\nexport type AiProviderId =\n | 'copy-paste'\n | 'xai-grok'\n | 'openai'\n | 'openai-compat'\n | 'anthropic'\n | 'google-gemini'\n | 'groq'\n | 'mistral'\n | 'ollama';\n\n/**\n * API format categories for provider routing.\n * @public\n */\nexport type AiApiFormat = 'openai' | 'anthropic' | 'gemini';\n\n/**\n * API format categories for image-generation provider routing.\n *\n * @remarks\n * - `'openai-images'` — OpenAI Images API. Routes to `/images/generations`\n * (text-only) or `/images/edits` (when reference images are present).\n * - `'xai-images'` — xAI Images API. Text-only JSON generation request.\n * - `'xai-images-edits'` — xAI Images API for Grok Imagine models. Uses JSON\n * body with `{ type: \"image_url\" }` objects (not multipart).\n * - `'gemini-imagen'` — Google Imagen `:predict` endpoint. Text-only.\n * - `'gemini-image-out'` — Google Gemini chat-style `:generateContent`\n * endpoint that returns image parts (Gemini 2.5 Flash Image / \"Nano\n * Banana\"). Accepts reference images.\n *\n * @public\n */\nexport type AiImageApiFormat =\n | 'openai-images'\n | 'gemini-imagen'\n | 'xai-images'\n | 'xai-images-edits'\n | 'gemini-image-out';\n\n// ============================================================================\n// Completion Response\n// ============================================================================\n\n/**\n * Result of an AI provider completion call.\n * @public\n */\nexport interface IAiCompletionResponse {\n /** The generated text content */\n readonly content: string;\n /** Whether the response was truncated due to token limits */\n readonly truncated: boolean;\n}\n\n// ============================================================================\n// Streaming Events\n// ============================================================================\n\n/**\n * A text-content delta arriving during a streaming completion.\n * @public\n */\nexport interface IAiStreamTextDelta {\n readonly type: 'text-delta';\n /** The newly arrived text fragment. */\n readonly delta: string;\n}\n\n/**\n * A server-side tool progress event arriving during a streaming completion.\n * Surfaced for providers that emit explicit tool-progress markers (OpenAI\n * Responses API, Anthropic). Gemini's grounding doesn't emit these.\n * @public\n */\nexport interface IAiStreamToolEvent {\n readonly type: 'tool-event';\n /** Which server-side tool this event describes. */\n readonly toolType: AiServerToolType;\n /** Tool lifecycle phase. */\n readonly phase: 'started' | 'completed';\n /**\n * Optional provider-specific detail. For web_search this is typically the\n * search query when available; format varies by provider.\n */\n readonly detail?: string;\n}\n\n/**\n * Terminal success event for a streaming completion. Carries the aggregated\n * full text and truncation status for callers that want both the progressive\n * UI and the complete result.\n * @public\n */\nexport interface IAiStreamDone {\n readonly type: 'done';\n /** Whether the response was truncated due to token limits. */\n readonly truncated: boolean;\n /** The full concatenated text from all `text-delta` events. */\n readonly fullText: string;\n /**\n * Provider-reported reason a truncated response was cut short (e.g.\n * `'max_output_tokens'`, `'content_filter'`), when the provider supplies one.\n * Currently populated only by the OpenAI / xAI Responses adapter, from the\n * completed payload's `incomplete_details.reason`. Meaningful only when\n * `truncated === true`; `undefined` otherwise (and whenever the provider\n * reports truncation without a reason).\n */\n readonly incompleteReason?: string;\n}\n\n/**\n * Terminal failure event for a streaming completion. After this event no\n * further events are emitted.\n *\n * @remarks\n * Connection-time failures (auth, network, pre-flight CORS rejection) are\n * surfaced via the outer `Result.fail` returned by\n * `callProviderCompletionStream` rather than as an `error` event, so callers\n * can distinguish \"didn't start\" from \"started but errored mid-stream.\"\n *\n * @public\n */\nexport interface IAiStreamError {\n readonly type: 'error';\n readonly message: string;\n}\n\n/**\n * Discriminated union of events emitted by a streaming completion.\n *\n * @remarks\n * **Exhaustive-switch consumers must handle all variants.** The three\n * `client-tool-*` variants were added when client-tool support shipped;\n * update every exhaustive switch over this union in lockstep.\n *\n * @public\n */\nexport type IAiStreamEvent =\n | IAiStreamTextDelta\n | IAiStreamToolEvent\n | IAiStreamToolUseStart\n | IAiStreamToolUseDelta\n | IAiStreamToolUseComplete\n | IAiStreamDone\n | IAiStreamError;\n\n/**\n * Thinking/reasoning mode support for a provider.\n * @public\n */\nexport type AiThinkingMode = 'optional' | 'required' | 'unsupported';\n\n/**\n * Describes a single AI provider — single source of truth for all metadata.\n * @public\n */\nexport interface IAiProviderDescriptor {\n /** Provider identifier (e.g. 'xai-grok', 'anthropic') */\n readonly id: AiProviderId;\n /** Human-readable label (e.g. \"xAI Grok\") */\n readonly label: string;\n /** Button label for action buttons (e.g. \"AI Assist | Grok\") */\n readonly buttonLabel: string;\n /** Whether this provider requires an API key secret */\n readonly needsSecret: boolean;\n /** Which API adapter format to use */\n readonly apiFormat: AiApiFormat;\n /** Base URL for the API (e.g. 'https://api.x.ai/v1') */\n readonly baseUrl: string;\n /** Default model specification — string or context-aware map. */\n readonly defaultModel: ModelSpec;\n /** Which server-side tools this provider supports (empty = none). */\n readonly supportedTools: ReadonlyArray<AiServerToolType>;\n /** Whether this provider's API enforces CORS restrictions that prevent direct browser calls. */\n readonly corsRestricted: boolean;\n /**\n * Whether this provider's streaming completion endpoint requires a proxy\n * for direct browser calls. Some providers gate streaming separately from\n * non-streaming (rare), so this is tracked independently from\n * {@link IAiProviderDescriptor.corsRestricted}.\n *\n * @remarks\n * When `true`, `callProviderCompletionStream` rejects up front unless the\n * call is being routed through a proxy.\n */\n readonly streamingCorsRestricted: boolean;\n /**\n * Whether this provider's chat completions API accepts image input\n * (i.e. supports vision prompts). When false, calls with\n * `prompt.attachments` are rejected up front.\n */\n readonly acceptsImageInput: boolean;\n /**\n * Whether this provider supports thinking/reasoning mode.\n * - 'optional': thinking can be enabled but is not required\n * - 'required': thinking is always active (e.g. o-series models)\n * - 'unsupported': thinking is not supported\n */\n readonly thinkingMode: AiThinkingMode;\n /**\n * Image-generation capabilities, scoped to model id prefixes. Empty or\n * undefined means the provider does not support image generation.\n *\n * @remarks\n * The dispatcher matches the resolved model id against each rule's\n * `modelPrefix` and selects the longest match (see\n * {@link AiAssist.resolveImageCapability}). An empty `modelPrefix` is the\n * catch-all and matches every model id.\n *\n * Multiple entries support providers that host more than one image-API\n * surface under one baseUrl. Google Gemini is the canonical case: the\n * `imagen-*` family is predict-only via `:predict`, while\n * `gemini-2.5-flash-image` uses chat-style `:generateContent` and accepts\n * reference images. Listing both lets callers pick the right model and the\n * dispatcher routes accordingly.\n *\n * Image-model selection reuses the existing `image` {@link ModelSpecKey}.\n * Providers that declare `imageGeneration` should declare a model in\n * `defaultModel.image`, e.g. `{ base: 'gpt-4o', image: 'dall-e-3' }`.\n */\n readonly imageGeneration?: ReadonlyArray<IAiImageModelCapability>;\n}\n\n/**\n * Image-generation capability for a model family within a provider. Used as\n * an entry in {@link IAiProviderDescriptor.imageGeneration}.\n *\n * @public\n */\nexport interface IAiImageModelCapability {\n /**\n * Prefix matched against the resolved image model id. The empty string is\n * the catch-all and matches every model. When multiple rules' prefixes\n * match a model id, the longest prefix wins; ties are broken by\n * first-encountered.\n */\n readonly modelPrefix: string;\n /** API format used to dispatch requests for matching models. */\n readonly format: AiImageApiFormat;\n /**\n * Whether matching models accept reference images via\n * {@link AiAssist.IAiImageGenerationParams.referenceImages}. When false or\n * undefined, calls that include reference images are rejected up front.\n */\n readonly acceptsImageReferenceInput?: boolean;\n /** Accepted size strings. When present, dispatcher pre-validates. */\n readonly acceptedSizes?: ReadonlyArray<string>;\n /** When true, quality param is sent. When false/undefined, don't send quality. */\n readonly supportsQualityParam?: boolean;\n /** Accepted quality values when supportsQualityParam is true. */\n readonly acceptedQualities?: ReadonlyArray<string>;\n /** Maximum count (n). When present, dispatcher pre-validates. */\n readonly maxCount?: number;\n /**\n * How to encode the output format on the wire:\n * - 'response-format': send response_format: 'b64_json' (dall-e-2, dall-e-3)\n * - 'output-format': send output_format (gpt-image-1)\n * - 'none': send neither (Imagen, Gemini Flash)\n */\n readonly outputParamStyle?: 'response-format' | 'output-format' | 'none';\n /** Default MIME type for response images. */\n readonly defaultOutputMimeType?: string;\n}\n\n// ============================================================================\n// Image Generation — Layered Options Types\n// ============================================================================\n\n/** Pixel dimension sizes accepted by dall-e-2. @public */\nexport type DallE2Size = '256x256' | '512x512' | '1024x1024';\n\n/** Pixel dimension sizes accepted by dall-e-3. @public */\nexport type DallE3Size = '1024x1024' | '1792x1024' | '1024x1792';\n\n/** Pixel dimension sizes accepted by gpt-image-1. @public */\nexport type GptImageSize = '1024x1024' | '1536x1024' | '1024x1536' | 'auto';\n\n/** All accepted image size strings across all providers. @public */\nexport type AiImageSize = DallE2Size | DallE3Size | GptImageSize;\n\n/** Quality values for dall-e-3. @public */\nexport type DallE3Quality = 'standard' | 'hd';\n\n/** Quality values for gpt-image-1. @public */\nexport type GptImageQuality = 'low' | 'medium' | 'high' | 'auto';\n\n/** All accepted quality strings across all providers. @public */\nexport type AiImageQuality = DallE3Quality | GptImageQuality;\n\n/** Model names in the DALL-E family. @public */\nexport type DallEModelNames = 'dall-e-2' | 'dall-e-3';\n\n/** Model names in the GPT Image family. @public */\nexport type GptImageModelNames = 'gpt-image-1';\n\n/** Model names in the xAI Grok Imagine family. @public */\nexport type GrokImagineModelNames = 'grok-imagine-image' | 'grok-imagine-image-quality';\n\n/** Model names in the Imagen 4 family. @public */\nexport type Imagen4ModelNames =\n | 'imagen-4.0-generate-001'\n | 'imagen-4.0-ultra-generate-001'\n | 'imagen-4.0-fast-generate-001';\n\n/** Model names in the Gemini Flash Image family. @public */\nexport type GeminiFlashImageModelNames = 'gemini-2.5-flash-image';\n\n// ---- Family-level config shapes ----\n\n/**\n * Provider-specific config for DALL-E models (dall-e-2, dall-e-3).\n * @remarks\n * style is only valid for dall-e-3; the runtime validator rejects it for dall-e-2.\n * @public\n */\nexport interface IDallEImageGenerationConfig {\n /** Image dimensions (dall-e-2: 256x256|512x512|1024x1024; dall-e-3: 1024x1024|1792x1024|1024x1792). */\n readonly size?: DallE2Size | DallE3Size;\n /** dall-e-3 only. Quality tier. */\n readonly quality?: DallE3Quality;\n /** dall-e-3 only. Visual style. */\n readonly style?: 'vivid' | 'natural';\n}\n\n/**\n * Provider-specific config for gpt-image-1.\n * @public\n */\nexport interface IGptImageGenerationConfig {\n /** Image dimensions. */\n readonly size?: GptImageSize;\n /** Quality tier. */\n readonly quality?: GptImageQuality;\n /** Output format (replaces response_format for this model). */\n readonly outputFormat?: 'png' | 'jpeg' | 'webp';\n /** JPEG/WebP compression level 0–100. */\n readonly outputCompression?: number;\n /** Background transparency control. */\n readonly background?: 'transparent' | 'opaque' | 'auto';\n /** Content moderation strictness. */\n readonly moderation?: 'low' | 'auto';\n}\n\n/**\n * Provider-specific config for xAI Grok Imagine models.\n * @public\n */\nexport interface IGrokImagineImageGenerationConfig {\n /** Aspect ratio string (xAI uses aspect ratios, not pixel dimensions). */\n readonly aspectRatio?: string;\n /** Resolution hint. */\n readonly resolution?: string;\n}\n\n/**\n * Provider-specific config for Google Imagen 4 models.\n * @public\n */\nexport interface IImagen4GenerationConfig {\n /** Aspect ratio string. */\n readonly aspectRatio?: '1:1' | '3:4' | '4:3' | '9:16' | '16:9';\n /** Output resolution. */\n readonly imageSize?: '1K' | '2K';\n /** Whether to add SynthID watermark. Must be false to use seed. */\n readonly addWatermark?: boolean;\n /** LLM-based prompt rewriting. */\n readonly enhancePrompt?: boolean;\n /** Output MIME type. */\n readonly outputMimeType?: 'image/jpeg' | 'image/png';\n /** JPEG compression quality. */\n readonly outputCompressionQuality?: number;\n /** Person generation policy. */\n readonly personGeneration?: 'allow_all' | 'allow_adult' | 'dont_allow';\n}\n\n/**\n * Provider-specific config for Gemini Flash Image.\n * @public\n */\nexport interface IGeminiFlashImageGenerationConfig {\n /** Aspect ratio string. */\n readonly aspectRatio?: string;\n}\n\n// ---- Model-family option blocks ----\n\n/**\n * Base shape shared by all named family option blocks.\n * Provides a typed `models` field for applicability filtering without unsafe casts.\n * @internal\n */\nexport interface INamedModelFamilyConfig {\n readonly models?: readonly string[];\n}\n\n/**\n * Options block scoped to DALL-E family models.\n * @public\n */\nexport interface IDallEModelOptions extends INamedModelFamilyConfig {\n /** Discriminator: openai provider lineage. */\n readonly provider: 'openai';\n /** Family identifier. */\n readonly family: 'dall-e';\n /** Optional model names this block applies to. Omit = applies to all DALL-E models. */\n readonly models?: DallEModelNames[];\n /** Family-specific config. */\n readonly config: IDallEImageGenerationConfig;\n}\n\n/**\n * Options block scoped to GPT Image family models.\n * @public\n */\nexport interface IGptImageModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'openai';\n readonly family: 'gpt-image';\n readonly models?: GptImageModelNames[];\n readonly config: IGptImageGenerationConfig;\n}\n\n/**\n * Options block scoped to xAI Grok Imagine family models.\n * @public\n */\nexport interface IGrokImagineModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'xai';\n readonly family: 'grok-imagine';\n readonly models?: GrokImagineModelNames[];\n readonly config: IGrokImagineImageGenerationConfig;\n}\n\n/**\n * Options block scoped to Google Imagen 4 models.\n * @public\n */\nexport interface IImagen4ModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'google';\n readonly family: 'imagen-4';\n readonly models?: Imagen4ModelNames[];\n readonly config: IImagen4GenerationConfig;\n}\n\n/**\n * Options block scoped to Gemini Flash Image models.\n * @public\n */\nexport interface IGeminiFlashImageModelOptions extends INamedModelFamilyConfig {\n readonly provider: 'google';\n readonly family: 'gemini-flash-image';\n readonly models?: GeminiFlashImageModelNames[];\n readonly config: IGeminiFlashImageGenerationConfig;\n}\n\n/**\n * Escape-hatch options block for models not covered by a named family.\n * @remarks\n * `models` is required — there is no implicit \"all\" for unknown model families.\n * `config` is `JsonObject` — passed verbatim to the wire request with no validation.\n * This is the \"trust me, I know what I'm doing\" path for callers who need to send\n * wire params our typed configs don't yet expose.\n * @public\n */\nexport interface IOtherModelOptions {\n readonly provider: 'other';\n readonly models: string[];\n readonly config: JsonObject;\n}\n\n/**\n * Discriminated union of all model-family option blocks.\n * Discriminated on `provider` + `family` fields.\n * @public\n */\nexport type IModelFamilyConfig =\n | IDallEModelOptions\n | IGptImageModelOptions\n | IGrokImagineModelOptions\n | IImagen4ModelOptions\n | IGeminiFlashImageModelOptions\n | IOtherModelOptions;\n\n// ============================================================================\n// Image Generation\n// ============================================================================\n\n/**\n * Options for image generation requests.\n *\n * @remarks\n * Uses a layered architecture:\n * 1. Generic top-level options (size, count, quality, seed) apply across providers\n * via the resolved model's registry mapping.\n * 2. Optional `models` array contains model-family-scoped blocks; the resolver\n * picks applicable blocks based on the resolved model and applies them in\n * declaration order.\n *\n * **Merge precedence (later wins):**\n * 1. Generic top-level options (lowest precedence)\n * 2. Family-generic blocks (matching family, models field omitted)\n * 3. Model-specific blocks (models array includes resolved model name)\n * 4. Other blocks (provider: 'other', models array includes resolved model name)\n *\n * Provider-mismatch: blocks whose provider doesn't match the dispatcher's\n * provider lineage are silently skipped.\n *\n * @public\n */\nexport interface IAiImageGenerationOptions {\n /**\n * Image dimensions for OpenAI models (mapped to `size` field).\n * For xAI aspect ratio or Imagen aspect ratio, use the corresponding `models` family block.\n */\n readonly size?: AiImageSize;\n /** Number of images. Default 1. Some models enforce a maximum. */\n readonly count?: number;\n /**\n * Quality tier. Accepted values differ per model:\n * - dall-e-3: 'standard' | 'hd'\n * - gpt-image-1: 'low' | 'medium' | 'high' | 'auto'\n * Other models ignore this field.\n */\n readonly quality?: AiImageQuality;\n /** Reproducibility seed, where supported. */\n readonly seed?: number;\n /**\n * Optional precision via model-family-scoped blocks. The resolver picks\n * applicable blocks dynamically based on the resolved model.\n */\n readonly models?: ReadonlyArray<IModelFamilyConfig>;\n}\n\n/**\n * Parameters for an image-generation request.\n * @public\n */\nexport interface IAiImageGenerationParams {\n /** The text prompt describing the desired image. */\n readonly prompt: string;\n /** Optional generation options. */\n readonly options?: IAiImageGenerationOptions;\n /**\n * Optional reference images. When present, the provider will use them as\n * visual context (e.g. to preserve a character's appearance across multiple\n * generations). The dispatcher resolves the\n * {@link AiAssist.IAiImageModelCapability} for the requested model and\n * rejects the call up front if `acceptsImageReferenceInput` is not set on\n * the matching capability. An empty array is treated identically to\n * `undefined`.\n */\n readonly referenceImages?: ReadonlyArray<IAiImageAttachment>;\n}\n\n/**\n * A single generated image.\n * @public\n */\nexport interface IAiGeneratedImage extends IAiImageData {\n /**\n * The prompt as rewritten by the provider, if any. OpenAI's image models\n * commonly rewrite prompts; other providers do not.\n */\n readonly revisedPrompt?: string;\n}\n\n// ============================================================================\n// Model Catalog (listModels)\n// ============================================================================\n\n/**\n * Capability vocabulary used to describe what a model can do. Used as both\n * a filter and as a tag in {@link AiAssist.IAiModelInfo.capabilities}.\n *\n * @remarks\n * Adding a new capability is cheap; adding the *first* one after consumers\n * already exist forces churn. The initial vocabulary is intentionally broad\n * even though only `image-generation` is fully exercised today.\n *\n * @public\n */\nexport type AiModelCapability = 'chat' | 'tools' | 'vision' | 'image-generation' | 'thinking';\n\n/**\n * Information about a single model returned by a provider's list endpoint,\n * with capabilities already resolved (native + config rules).\n * @public\n */\nexport interface IAiModelInfo {\n /** Provider-native model identifier. */\n readonly id: string;\n /** Resolved capability set — union of native declarations and config rules. */\n readonly capabilities: ReadonlySet<AiModelCapability>;\n /** Friendly name for display, when known. */\n readonly displayName?: string;\n}\n\n/**\n * One rule in an {@link IAiModelCapabilityConfig}. Multiple rules can match\n * a single model — their capability arrays are unioned.\n * @public\n */\nexport interface IAiModelCapabilityRule {\n /** RegExp tested against the model id (using `.test`). */\n readonly idPattern: RegExp;\n /** Capabilities this rule attributes to matching models. */\n readonly capabilities: ReadonlyArray<AiModelCapability>;\n /**\n * Friendly display-name override for matching models. The function form\n * lets one rule format many ids (e.g. `(id) => id.toUpperCase()`).\n * If multiple matching rules supply `displayName`, the first match wins.\n */\n readonly displayName?: string | ((id: string) => string);\n}\n\n/**\n * Configuration that maps model id patterns to capabilities. Used to\n * augment (or, where the provider supplies no capability info, fully\n * derive) the capability set for each listed model.\n * @public\n */\nexport interface IAiModelCapabilityConfig {\n /** Per-provider rules. Tried before {@link AiAssist.IAiModelCapabilityConfig.global}. */\n readonly perProvider?: { readonly [P in AiProviderId]?: ReadonlyArray<IAiModelCapabilityRule> };\n /** Cross-provider fallback rules. */\n readonly global?: ReadonlyArray<IAiModelCapabilityRule>;\n}\n\n/**\n * Result of an image-generation call.\n * @public\n */\nexport interface IAiImageGenerationResponse {\n /** The generated images, in provider-returned order. */\n readonly images: ReadonlyArray<IAiGeneratedImage>;\n}\n\n// ============================================================================\n// Thinking / Reasoning Config — Layered Options Types\n// ============================================================================\n\n/**\n * Model IDs for Anthropic thinking-capable models.\n * @public\n */\nexport type AnthropicThinkingModelNames =\n | 'claude-sonnet-4-5'\n | 'claude-sonnet-4-6'\n | 'claude-opus-4-6'\n | 'claude-opus-4-7';\n\n/**\n * Model IDs for OpenAI thinking-capable models.\n * @public\n */\nexport type OpenAiThinkingModelNames =\n | 'o3'\n | 'o4-mini'\n | 'o3-deep-research'\n | 'o4-mini-deep-research'\n | 'gpt-5'\n | 'gpt-5.1'\n | 'gpt-5.2'\n | 'gpt-5.5'\n | 'gpt-5-pro';\n\n/**\n * Model IDs for Google Gemini thinking-capable models.\n * @public\n */\nexport type GeminiThinkingModelNames = 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite';\n\n/**\n * Model IDs for xAI thinking-capable models.\n * @public\n */\nexport type XAiThinkingModelNames = 'grok-3-mini' | 'grok-4.3' | 'grok-4';\n\n/**\n * Anthropic-specific thinking configuration.\n * @public\n */\nexport interface IAnthropicThinkingConfig {\n /**\n * Anthropic effort level. The emit-site converts to `thinking.budget_tokens`\n * (the integer budget the Anthropic API requires). Mapping policy: low = 2048,\n * medium = 8192, high = 24000, max = 32000.\n * - 'low' | 'medium' | 'high': all thinking-capable models\n * - 'max': Opus 4.6 only\n */\n readonly effort?: 'low' | 'medium' | 'high' | 'max';\n}\n\n/**\n * OpenAI-specific thinking configuration.\n * @remarks\n * Maps to `reasoning_effort` (Chat Completions path) or `reasoning.effort`\n * (Responses API path) on the wire. The adapter selects the correct field.\n * @public\n */\nexport interface IOpenAiThinkingConfig {\n /**\n * OpenAI reasoning effort. Maps 1:1 to the wire field.\n * - 'none': disables reasoning (gpt-5.x only; rejected by o-series)\n * - 'minimal': fastest (gpt-5.x)\n * - 'low' | 'medium' | 'high': standard tiers\n * - 'xhigh': highest (select gpt-5.x models only)\n *\n * @remarks\n * When effective effort is 'none', reasoning is disabled and temperature is\n * accepted by gpt-5.x models. This is the only case where temperature and\n * thinking config co-exist without a Result.fail.\n */\n readonly effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';\n}\n\n/**\n * Google Gemini-specific thinking configuration.\n * @public\n */\nexport interface IGeminiThinkingConfig {\n /**\n * Token budget for thinking. Maps 1:1 to `thinkingBudget` on the wire.\n * - 0: disable thinking (Flash and Flash-Lite only; error on Pro)\n * - positive integer: soft token cap\n * - -1: dynamic\n * - omitted: model default\n */\n readonly thinkingBudget?: number;\n /**\n * Whether to include thought summaries in the response.\n * @remarks\n * INERT in phase B. Adapters never send `includeThoughts: true`.\n * Wired up by the followup stream `ai-assist-thinking-events`.\n */\n readonly includeThoughts?: boolean;\n}\n\n/**\n * xAI-specific thinking configuration.\n * @public\n */\nexport interface IXAiThinkingConfig {\n /**\n * xAI reasoning effort. Maps 1:1 to `reasoning_effort` on the wire.\n * For grok-4, the adapter omits this field (grok-4 always reasons and\n * rejects the parameter).\n */\n readonly effort?: 'none' | 'low' | 'medium' | 'high';\n}\n\n/**\n * Anthropic-specific thinking options block.\n * @public\n */\nexport interface IAnthropicThinkingOptions {\n readonly provider: 'anthropic';\n readonly models?: ReadonlyArray<AnthropicThinkingModelNames>;\n readonly config: IAnthropicThinkingConfig;\n}\n\n/**\n * OpenAI-specific thinking options block.\n * @public\n */\nexport interface IOpenAiThinkingOptions {\n readonly provider: 'openai';\n readonly models?: ReadonlyArray<OpenAiThinkingModelNames>;\n readonly config: IOpenAiThinkingConfig;\n}\n\n/**\n * Google Gemini-specific thinking options block.\n * @public\n */\nexport interface IGeminiThinkingOptions {\n readonly provider: 'google';\n readonly models?: ReadonlyArray<GeminiThinkingModelNames>;\n readonly config: IGeminiThinkingConfig;\n}\n\n/**\n * xAI-specific thinking options block.\n * @public\n */\nexport interface IXAiThinkingOptions {\n readonly provider: 'xai';\n readonly models?: ReadonlyArray<XAiThinkingModelNames>;\n readonly config: IXAiThinkingConfig;\n}\n\n/**\n * Escape-hatch options block for providers not covered by typed configs.\n * @remarks\n * `models` is required — no implicit \"all\" for unknown providers.\n * `config` fields are merged verbatim into the wire request.\n * @public\n */\nexport interface IOtherThinkingOptions {\n readonly provider: 'other';\n readonly models: ReadonlyArray<string>;\n readonly config: JsonObject;\n}\n\n/**\n * Discriminated union of per-provider thinking config blocks.\n * @public\n */\nexport type IThinkingProviderConfig =\n | IAnthropicThinkingOptions\n | IOpenAiThinkingOptions\n | IGeminiThinkingOptions\n | IXAiThinkingOptions\n | IOtherThinkingOptions;\n\n/**\n * Thinking/reasoning mode configuration for a completion request.\n *\n * @remarks\n * The generic `effort` field covers the common-subset cross-provider vocabulary.\n * For provider-specific precision (Anthropic 'max', OpenAI 'xhigh', Gemini token\n * budgets, xAI effort-level tuning), use the `providers` array.\n *\n * Absence (or undefined) means \"no thinking mode\" — existing callers are unaffected.\n *\n * @public\n */\nexport interface IThinkingConfig {\n /**\n * Cross-provider effort level. Common-subset mapping:\n * - 'low': Anthropic effort:low | OpenAI effort:low | Gemini thinkingBudget:1024 | xAI reasoning_effort:low\n * - 'medium': effort:medium | effort:medium | thinkingBudget:4096 | reasoning_effort:medium\n * - 'high': effort:high | effort:high | thinkingBudget:8192 | reasoning_effort:high\n */\n readonly effort?: 'low' | 'medium' | 'high';\n /**\n * Optional per-provider precision blocks. Blocks for providers that don't\n * match the resolved model's provider are silently skipped.\n */\n readonly providers?: ReadonlyArray<IThinkingProviderConfig>;\n}\n\n// ============================================================================\n// Settings\n// ============================================================================\n\n/**\n * Configuration for a single AI assist provider.\n * @public\n */\nexport interface IAiAssistProviderConfig {\n /** Which provider this configures */\n readonly provider: AiProviderId;\n /** For API-based providers: the keystore secret name holding the API key */\n readonly secretName?: string;\n /** Optional model override — string or context-aware map. */\n readonly model?: ModelSpec;\n /** Tool enablement/configuration. Tools are disabled unless explicitly enabled. */\n readonly tools?: ReadonlyArray<IAiToolEnablement>;\n /**\n * Optional caller-supplied endpoint URL (http/https). Overrides\n * `descriptor.baseUrl` for this provider. Used to point a provider at a\n * self-hosted server (Ollama, LM Studio, llama.cpp's openai-server) or a\n * local proxy. Validation lives in `@fgv/ts-extras` — query strings,\n * fragments, and userinfo are rejected.\n */\n readonly endpoint?: string;\n}\n\n/**\n * AI assist settings — which providers are enabled and their configuration.\n * @public\n */\nexport interface IAiAssistSettings {\n /** Enabled providers and their configuration. */\n readonly providers: ReadonlyArray<IAiAssistProviderConfig>;\n /** Which enabled provider is the default for the main button. Falls back to first in list. */\n readonly defaultProvider?: AiProviderId;\n /** Optional proxy URL for routing API requests through a backend server (e.g. `http://localhost:3002`). */\n readonly proxyUrl?: string;\n /** When true, route all providers through the proxy. When false (default), only CORS-restricted providers use the proxy. */\n readonly proxyAllProviders?: boolean;\n}\n\n/**\n * Default AI assist settings (copy-paste only).\n * @public\n */\nexport const DEFAULT_AI_ASSIST: IAiAssistSettings = {\n providers: [{ provider: 'copy-paste' }]\n};\n\n// ============================================================================\n// Keystore Interface\n// ============================================================================\n\n/**\n * Minimal keystore interface for AI assist API key resolution.\n * Satisfied structurally by the concrete `KeyStore` class from `@fgv/ts-extras`.\n * @public\n */\nexport interface IAiAssistKeyStore {\n /** Whether the keystore is currently unlocked */\n readonly isUnlocked: boolean;\n /** Check if a named secret exists */\n hasSecret(name: string): Result<boolean>;\n /** Get an API key by secret name */\n getApiKey(name: string): Result<string>;\n}\n"]}
@@ -1,19 +1,72 @@
1
1
  /**
2
- * Streaming adapter for the Anthropic Messages API. Surfaces server tool
3
- * use (e.g. `web_search`) as unified `tool-event` markers based on the
4
- * `content_block_start` / `content_block_stop` lifecycle.
2
+ * Streaming adapter for the Anthropic Messages API. Handles server tool
3
+ * use (e.g. `web_search`) as unified `tool-event` markers and client-defined
4
+ * tool calls (type `tool_use`) with B4 thinking-block accumulation.
5
+ *
6
+ * The ordered accumulation buffer preserves all content blocks from the
7
+ * assistant turn in their original stream positions. The C3 continuation
8
+ * builder reads this buffer to reconstruct the assistant turn for the
9
+ * follow-up request.
5
10
  *
6
11
  * @packageDocumentation
7
12
  */
8
13
  import { type Logging, Result } from '@fgv/ts-utils';
9
- import { AiPrompt, type AiServerToolConfig, type IAiStreamEvent, type IChatMessage } from '../model';
14
+ import { type JsonObject } from '@fgv/ts-json-base';
15
+ import { AiPrompt, type AiToolConfig, type IAiStreamEvent, type IChatMessage } from '../model';
10
16
  import { type IResolvedThinkingConfig } from '../thinkingOptionsResolver';
11
17
  import { IStreamApiConfig } from './common';
18
+ /**
19
+ * An accumulated `thinking` block from the assistant turn. The `thinking` text
20
+ * and `signature` are both concatenated across their respective delta events.
21
+ * The full block is passed to the C3 continuation builder for round-trip preservation.
22
+ * @internal
23
+ */
24
+ export interface IAccumulatedThinkingBlock {
25
+ readonly type: 'thinking';
26
+ thinking: string;
27
+ signature: string;
28
+ }
29
+ /**
30
+ * An accumulated `redacted_thinking` block from the assistant turn. The `data`
31
+ * field is opaque and arrives complete in the `content_block_start` event — no
32
+ * delta events follow. Passed through unmodified to the C3 continuation builder.
33
+ * @internal
34
+ */
35
+ export interface IAccumulatedRedactedThinkingBlock {
36
+ readonly type: 'redacted_thinking';
37
+ readonly data: string;
38
+ }
39
+ /**
40
+ * An accumulated `text` block from the assistant turn.
41
+ * @internal
42
+ */
43
+ export interface IAccumulatedTextBlock {
44
+ readonly type: 'text';
45
+ text: string;
46
+ }
47
+ /**
48
+ * An accumulated `tool_use` block from the assistant turn (client-defined tool call).
49
+ * The `argsBuffer` is the concatenation of all `input_json_delta` chunks.
50
+ * @internal
51
+ */
52
+ export interface IAccumulatedToolUseBlock {
53
+ readonly type: 'tool_use';
54
+ readonly id: string;
55
+ readonly name: string;
56
+ argsBuffer: string;
57
+ }
58
+ /**
59
+ * Discriminated union of all accumulated Anthropic content block types.
60
+ * The ordered accumulation buffer is a `Map<number, IAccumulatedBlock>` keyed
61
+ * by the SSE `index` field from `content_block_start` events.
62
+ * @internal
63
+ */
64
+ export type IAccumulatedBlock = IAccumulatedThinkingBlock | IAccumulatedRedactedThinkingBlock | IAccumulatedTextBlock | IAccumulatedToolUseBlock;
12
65
  /**
13
66
  * Issues a streaming Anthropic Messages request and returns the
14
67
  * unified-event iterable on success.
15
68
  *
16
69
  * @internal
17
70
  */
18
- export declare function callAnthropicStream(config: IStreamApiConfig, prompt: AiPrompt, messagesBefore: ReadonlyArray<IChatMessage> | undefined, temperature: number, tools: ReadonlyArray<AiServerToolConfig> | undefined, logger?: Logging.ILogger, signal?: AbortSignal, resolvedThinking?: IResolvedThinkingConfig): Promise<Result<AsyncIterable<IAiStreamEvent>>>;
71
+ export declare function callAnthropicStream(config: IStreamApiConfig, prompt: AiPrompt, messagesBefore: ReadonlyArray<IChatMessage> | undefined, temperature: number, tools: ReadonlyArray<AiToolConfig> | undefined, logger?: Logging.ILogger, signal?: AbortSignal, resolvedThinking?: IResolvedThinkingConfig, accumulationBuffer?: Map<number, IAccumulatedBlock>, continuationMessages?: ReadonlyArray<JsonObject>): Promise<Result<AsyncIterable<IAiStreamEvent>>>;
19
72
  //# sourceMappingURL=anthropic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../../src/packlets/ai-assist/streamingAdapters/anthropic.ts"],"names":[],"mappings":"AAoB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