import { BaseSummarizeAdapter } from './adapter.js'; import { StreamChunk, SummarizationOptions, SummarizationResult, TextOptions } from '../../types.js'; /** * Minimal contract for a text adapter that supports `chatStream`. Lets * `ChatStreamSummarizeAdapter` work with any text adapter without coupling * to a specific implementation. * * The provider-options shape is intentionally `any` here — the wrapper only * forwards `modelOptions` straight through, so a text adapter with a richer * per-model options type (e.g. `ResolveProviderOptions`) is still * acceptable. Summarize-level type safety is enforced via * `SummarizationOptions` on the wrapper itself. */ export interface ChatStreamCapable { chatStream: (options: TextOptions) => AsyncIterable; } /** * Extract the per-model `modelOptions` type a text adapter accepts. Used by * provider summarize factories so their `modelOptions` IntelliSense matches * what the underlying text adapter actually understands. */ export type InferTextProviderOptions = TAdapter extends { '~types': { providerOptions: infer P; }; } ? P extends object ? P : object : object; /** * Summarize adapter that wraps any `ChatStreamCapable` text adapter and * prompts it for summarization. Not tied to any wire format. */ export declare class ChatStreamSummarizeAdapter> extends BaseSummarizeAdapter { readonly name: string; private readonly textAdapter; constructor(textAdapter: ChatStreamCapable, model: TModel, name?: string); summarize(options: SummarizationOptions): Promise; summarizeStream(options: SummarizationOptions): AsyncIterable; /** * Build the TextOptions passed to the underlying chatStream. Provider * `modelOptions` from the summarize call are forwarded as-is so knobs like * Anthropic cache headers, Gemini safety settings, or Ollama tuning params * still reach the wire layer. */ protected buildTextOptions(options: SummarizationOptions, systemPrompt: string): TextOptions; protected buildSummarizationPrompt(options: SummarizationOptions): string; }