@tanstack/ai-angular 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,20 @@
1
- import { AnyClientTool, SchemaInput, InterruptDefinition, ModelMessage, RunAgentResumeItem, InferSchemaType, StreamChunk, ImageGenerationResult, AudioGenerationResult, TTSResult, TranscriptionResult, SummarizationResult } from '@tanstack/ai';
2
- import { InferredClientContext, DistributedOmit, ChatClientOptions, AIDevtoolsDisplayOptions, ClientContextOptionFromTools, UIMessage, MultimodalContent, SendMessageOptions, QueuedMessage, BoundInterrupts, ChatInterruptState, ResolvableChatInterrupt, ChatResumeState, ChatClientState, ConnectionStatus, SubscribeWebMCPToolsOptions, AnyClientTool as AnyClientTool$1, RegisterWebMCPToolsOptions, ConnectConnectionAdapter, GenerationFetcher, GenerationRestoredResult, GenerationClientState, InferGenerationOutputFromReturn, ImageGenerateInput, AudioGenerateInput, SpeechGenerateInput, TranscriptionGenerateInput, AudioRecorderOptions, AudioRecording, InferAudioRecordingOutput, SummarizeGenerateInput, VideoGenerateResult, VideoGenerateInput, VideoStatusInfo } from '@tanstack/ai-client';
3
- export { AudioGenerateInput, AudioRecorder, BatchStrategy, ChatClient, ChatClientPersistence, ChatPersistedState, ChatPersistenceOption, ChatRequestBody, ChatStorageAdapter, CompositeStrategy, ConnectConnectionAdapter, ConnectionAdapter, CreateMcpAppBridgeOptions, DurableStreamIncompleteError, FetchConnectionOptions, FetchJsonOptions, GENERATION_EVENTS, GenerationClient, GenerationClientState, GetWebMCPToolsOptions, ImageGenerateInput, ImmediateStrategy, IndexedDBPersistenceOptions, InferChatMessages, InterruptManager, McpAppBridge, MultimodalContent, PartialJSONParser, PunctuationStrategy, QueueConfig, QueueOption, QueueStrategy, QueuedMessage, RealtimeClient, RunAgentInputContext, SendMessageOptions, SpeechGenerateInput, StorageUnavailableError, StreamProcessor, StreamReconnectLimitError, StreamTruncatedError, SubscribeConnectionAdapter, SubscribeWebMCPToolsOptions, SummarizeGenerateInput, TranscriptionGenerateInput, UIMessage, UnsupportedResponseStreamError, VideoGenerateInput, VideoGenerateResult, VideoGenerationClient, VideoStatusInfo, WebMCPPageTool, WebSocketConnectionOptions, WebStoragePersistenceOptions, WhenBusy, WordBoundaryStrategy, XhrConnectionOptions, clientTools, convertMessagesToModelMessages, createAIDevtoolsGenerationPreview, createChatClientOptions, createMcpAppBridge, defaultJSONParser, fetchHttpStream, fetchJson, fetchServerSentEvents, generateMessageId, getWebMCPTools, indexedDBPersistence, localStoragePersistence, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, parsePartialJSON, reconstructAudioResult, reconstructImageResult, reconstructSpeechResult, reconstructSummarizeResult, reconstructTranscriptionResult, registerWebMCPTools, rpcStream, sessionStoragePersistence, stream, subscribeWebMCPTools, uiMessageToModelMessages, webSocket, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
4
- import { Signal } from '@angular/core';
5
- import { ByokClient, ByokSnapshot } from '@tanstack/ai-client/byok';
6
- import { ProviderId } from '@tanstack/ai/byok';
7
-
1
+ import { AnyClientTool, AudioGenerationResult, ImageGenerationResult, InferSchemaType, InterruptDefinition, ModelMessage, RunAgentResumeItem, SchemaInput, StreamChunk, SummarizationResult, TTSResult, TranscriptionResult } from "@tanstack/ai";
2
+ import { AIDevtoolsDisplayOptions, AnyClientTool as AnyClientTool$1, AudioGenerateInput, AudioGenerateInput as AudioGenerateInput$1, AudioRecorder, AudioRecorderOptions, AudioRecording, BatchStrategy, BoundInterrupts, ChatClient, ChatClientOptions, ChatClientPersistence, ChatClientState, ChatInterruptState, ChatPersistedState, ChatPersistenceOption, ChatRequestBody, ChatResumeState, ChatStorageAdapter, ClientContextOptionFromTools, CompositeStrategy, ConnectConnectionAdapter, ConnectConnectionAdapter as ConnectConnectionAdapter$1, ConnectionAdapter, ConnectionStatus, CreateMcpAppBridgeOptions, DistributedOmit, DurableStreamIncompleteError, FetchConnectionOptions, FetchJsonOptions, GENERATION_EVENTS, GenerationClient, GenerationClientState, GenerationClientState as GenerationClientState$1, GenerationFetcher, GenerationRestoredResult, GetWebMCPToolsOptions, ImageGenerateInput, ImageGenerateInput as ImageGenerateInput$1, ImmediateStrategy, IndexedDBPersistenceOptions, InferAudioRecordingOutput, InferChatMessages, InferGenerationOutputFromReturn, InferredClientContext, InterruptManager, McpAppBridge, MultimodalContent, PartialJSONParser, PunctuationStrategy, QueueConfig, QueueOption, QueueStrategy, QueuedMessage, RealtimeClient, RegisterWebMCPToolsOptions, ResolvableChatInterrupt, RunAgentInputContext, SendMessageOptions, SpeechGenerateInput, SpeechGenerateInput as SpeechGenerateInput$1, StorageUnavailableError, StreamProcessor, StreamReconnectLimitError, StreamTruncatedError, SubscribeConnectionAdapter, SubscribeWebMCPToolsOptions, SubscribeWebMCPToolsOptions as SubscribeWebMCPToolsOptions$1, SummarizeGenerateInput, SummarizeGenerateInput as SummarizeGenerateInput$1, TranscriptionGenerateInput, TranscriptionGenerateInput as TranscriptionGenerateInput$1, UIMessage, UnsupportedResponseStreamError, VideoGenerateInput, VideoGenerateInput as VideoGenerateInput$1, VideoGenerateResult, VideoGenerateResult as VideoGenerateResult$1, VideoGenerationClient, VideoStatusInfo, VideoStatusInfo as VideoStatusInfo$1, WebMCPPageTool, WebSocketConnectionOptions, WebStoragePersistenceOptions, WhenBusy, WordBoundaryStrategy, XhrConnectionOptions, clientTools, convertMessagesToModelMessages, createAIDevtoolsGenerationPreview, createChatClientOptions, createMcpAppBridge, defaultJSONParser, fetchHttpStream, fetchJson, fetchServerSentEvents, generateMessageId, getWebMCPTools, indexedDBPersistence, localStoragePersistence, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, parsePartialJSON, reconstructAudioResult, reconstructImageResult, reconstructSpeechResult, reconstructSummarizeResult, reconstructTranscriptionResult, registerWebMCPTools, rpcStream, sessionStoragePersistence, stream, subscribeWebMCPTools, uiMessageToModelMessages, webSocket, xhrHttpStream, xhrServerSentEvents } from "@tanstack/ai-client";
3
+ import { Signal } from "@angular/core";
4
+ import { ByokClient, ByokSnapshot } from "@tanstack/ai-client/byok";
5
+ import { ProviderId } from "@tanstack/ai/byok";
8
6
  /**
9
7
  * A value that may be supplied to `injectChat` either as a static value, an
10
8
  * Angular `Signal`, or a zero-arg getter. The getter form lets callers read
11
9
  * other signals so the option stays reactive.
12
10
  */
13
11
  type ReactiveOption<T> = T | Signal<T> | (() => T);
14
-
15
12
  /**
16
13
  * Recursive partial — every property and every nested array element is optional.
17
14
  * Used to type the in-flight `partial` value while a structured-output stream
18
15
  * is still arriving.
19
16
  */
20
- type DeepPartial<T> = T extends ReadonlyArray<infer U> ? Array<DeepPartial<U>> : T extends object ? {
21
- [K in keyof T]?: DeepPartial<T[K]>;
22
- } : T;
17
+ type DeepPartial<T> = T extends ReadonlyArray<infer U> ? Array<DeepPartial<U>> : T extends object ? { [K in keyof T]?: DeepPartial<T[K]>; } : T;
23
18
  /**
24
19
  * Options for {@link injectChat}.
25
20
  *
@@ -29,122 +24,119 @@ type DeepPartial<T> = T extends ReadonlyArray<infer U> ? Array<DeepPartial<U>> :
29
24
  * they can be a static value, a `Signal`, or a getter and stay reactive.
30
25
  */
31
26
  type InjectChatOptions<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> = DistributedOmit<ChatClientOptions<TTools, TContext, TInterrupts>, 'onMessagesChange' | 'onLoadingChange' | 'onErrorChange' | 'onStatusChange' | 'onSubscriptionChange' | 'onConnectionStatusChange' | 'onSessionGeneratingChange' | 'onHydratingChange' | 'onQueueChange' | 'onResumeStateChange' | 'onRunIdChange' | 'context' | 'devtools' | 'forwardedProps' | 'tools'> & {
32
- /** Display options for TanStack AI Devtools. */
33
- devtools?: AIDevtoolsDisplayOptions;
34
- /** Client-side tools with execution logic. Reactive. */
35
- tools?: ReactiveOption<TTools>;
36
- /** Forwarded request props. Reactive. */
37
- forwardedProps?: ReactiveOption<Record<string, any>>;
38
- /** Whether to keep a live subscription open. Reactive. */
39
- live?: ReactiveOption<boolean>;
40
- /**
41
- * Standard-schema-compatible schema (Zod, Valibot, ArkType, or JSON Schema).
42
- * Used to infer the shape of `partial` and `final`.
43
- */
44
- outputSchema?: TSchema;
27
+ /** Display options for TanStack AI Devtools. */
28
+ devtools?: AIDevtoolsDisplayOptions;
29
+ /** Client-side tools with execution logic. Reactive. */
30
+ tools?: ReactiveOption<TTools>;
31
+ /** Forwarded request props. Reactive. */
32
+ forwardedProps?: ReactiveOption<Record<string, any>>;
33
+ /** Whether to keep a live subscription open. Reactive. */
34
+ live?: ReactiveOption<boolean>;
35
+ /**
36
+ * Standard-schema-compatible schema (Zod, Valibot, ArkType, or JSON Schema).
37
+ * Used to infer the shape of `partial` and `final`.
38
+ */
39
+ outputSchema?: TSchema;
45
40
  } & ClientContextOptionFromTools<TTools, ReactiveOption<TContext>>;
46
41
  /**
47
42
  * Return shape of {@link injectChat}. When `outputSchema` is supplied, adds
48
43
  * typed `partial` / `final` signals; otherwise the return is unchanged.
49
44
  */
50
45
  type InjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> = BaseInjectChatResult<TTools, TSchema extends SchemaInput ? InferSchemaType<TSchema> : unknown, TInterrupts> & (TSchema extends SchemaInput ? {
51
- /** Live progressively-parsed structured output. */
52
- partial: Signal<DeepPartial<InferSchemaType<TSchema>>>;
53
- /** Final, schema-validated structured output. `null` until complete. */
54
- final: Signal<InferSchemaType<TSchema> | null>;
46
+ /** Live progressively-parsed structured output. */
47
+ partial: Signal<DeepPartial<InferSchemaType<TSchema>>>;
48
+ /** Final, schema-validated structured output. `null` until complete. */
49
+ final: Signal<InferSchemaType<TSchema> | null>;
55
50
  } : Record<never, never>);
56
51
  interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TData = unknown, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> {
57
- /** Current messages in the conversation. */
58
- messages: Signal<ReadonlyArray<UIMessage<TTools, TData>>>;
59
- /**
60
- * Send a message (string or multimodal content).
61
- * Pass `{ whenBusy }` to override the queue policy for a single send, or
62
- * `{ body }` to merge per-call JSON into this request's `forwardedProps`.
63
- */
64
- sendMessage: (content: string | MultimodalContent, options?: SendMessageOptions) => Promise<void>;
65
- /** Pending messages queued while a stream is in flight. */
66
- queue: Signal<ReadonlyArray<QueuedMessage>>;
67
- /** Cancel a queued message before it drains. */
68
- cancelQueued: (id: string) => void;
69
- /** Append a message to the conversation. */
70
- append: (message: ModelMessage | UIMessage<TTools, TData>) => Promise<void>;
71
- /** Add the result of a client-side tool execution. */
72
- addToolResult: (result: {
73
- toolCallId: string;
74
- tool: string;
75
- output: any;
76
- state?: 'output-available' | 'output-error';
77
- errorText?: string;
78
- }) => Promise<void>;
79
- /**
80
- * The id of the run this client has in flight — one it started or rejoined —
81
- * or `null` when there is none (including while a run sits paused on an
82
- * interrupt, waiting on approval).
83
- *
84
- * A run is one turn of the conversation, so this changes from turn to turn. A
85
- * whole tool loop stays inside one run, while resuming after an interrupt
86
- * continues the turn under a new id — so one user message can produce several
87
- * run ids. Use it to talk to your own server about that run (cancel it, poll
88
- * it, correlate a log line).
89
- */
90
- runId: Signal<string | null>;
91
- /** Immutable bound interrupts for the current interrupted run. */
92
- interrupts: Signal<BoundInterrupts<TTools, TInterrupts>>;
93
- /** Batch-level interrupt errors. */
94
- interruptErrors: Signal<ChatInterruptState<TTools, TInterrupts>['interruptErrors']>;
95
- /** Whether the client is submitting an interrupt batch. */
96
- resuming: Signal<boolean>;
97
- resolveInterrupts: {
98
- (approved: boolean): void;
99
- (resolver: (interrupt: ResolvableChatInterrupt<TTools, TInterrupts>) => undefined): void;
100
- };
101
- cancelInterrupts: () => void;
102
- retryInterrupts: () => void;
103
- resumeInterruptsUnsafe: (resume: Array<RunAgentResumeItem>, state?: ChatResumeState) => Promise<boolean>;
104
- /** Reload the last assistant message. */
105
- reload: () => Promise<void>;
106
- /** Stop the current response generation. */
107
- stop: () => void;
108
- /** Whether a response is currently being generated. */
109
- isLoading: Signal<boolean>;
110
- /**
111
- * True when the last hydrate or older-page response said more messages exist.
112
- */
113
- hasOlderMessages: Signal<boolean>;
114
- /**
115
- * Fetch the next older window and put it in front of the painted messages.
116
- */
117
- loadOlderMessages: () => Promise<void>;
118
- /** Current error, if any. */
119
- error: Signal<Error | undefined>;
120
- /** Set messages manually. */
121
- setMessages: (messages: ReadonlyArray<UIMessage<TTools, TData>>) => void;
122
- /** Clear all messages. */
123
- clear: () => void;
124
- /** Current generation status. */
125
- status: Signal<ChatClientState>;
126
- /** Whether the subscription loop is active. */
127
- isSubscribed: Signal<boolean>;
128
- /** Current connection lifecycle status. */
129
- connectionStatus: Signal<ConnectionStatus>;
130
- /** Whether the shared session is actively generating. */
131
- sessionGenerating: Signal<boolean>;
132
- /** Whether the chat is being rebuilt from persistence. */
133
- isHydrating: Signal<boolean>;
52
+ /** Current messages in the conversation. */
53
+ messages: Signal<ReadonlyArray<UIMessage<TTools, TData>>>;
54
+ /**
55
+ * Send a message (string or multimodal content).
56
+ * Pass `{ whenBusy }` to override the queue policy for a single send, or
57
+ * `{ body }` to merge per-call JSON into this request's `forwardedProps`.
58
+ */
59
+ sendMessage: (content: string | MultimodalContent, options?: SendMessageOptions) => Promise<void>;
60
+ /** Pending messages queued while a stream is in flight. */
61
+ queue: Signal<ReadonlyArray<QueuedMessage>>;
62
+ /** Cancel a queued message before it drains. */
63
+ cancelQueued: (id: string) => void;
64
+ /** Append a message to the conversation. */
65
+ append: (message: ModelMessage | UIMessage<TTools, TData>) => Promise<void>;
66
+ /** Add the result of a client-side tool execution. */
67
+ addToolResult: (result: {
68
+ toolCallId: string;
69
+ tool: string;
70
+ output: any;
71
+ state?: 'output-available' | 'output-error';
72
+ errorText?: string;
73
+ }) => Promise<void>;
74
+ /**
75
+ * The id of the run this client has in flight — one it started or rejoined —
76
+ * or `null` when there is none (including while a run sits paused on an
77
+ * interrupt, waiting on approval).
78
+ *
79
+ * A run is one turn of the conversation, so this changes from turn to turn. A
80
+ * whole tool loop stays inside one run, while resuming after an interrupt
81
+ * continues the turn under a new id — so one user message can produce several
82
+ * run ids. Use it to talk to your own server about that run (cancel it, poll
83
+ * it, correlate a log line).
84
+ */
85
+ runId: Signal<string | null>;
86
+ /** Immutable bound interrupts for the current interrupted run. */
87
+ interrupts: Signal<BoundInterrupts<TTools, TInterrupts>>;
88
+ /** Batch-level interrupt errors. */
89
+ interruptErrors: Signal<ChatInterruptState<TTools, TInterrupts>['interruptErrors']>;
90
+ /** Whether the client is submitting an interrupt batch. */
91
+ resuming: Signal<boolean>;
92
+ resolveInterrupts: {
93
+ (approved: boolean): void;
94
+ (resolver: (interrupt: ResolvableChatInterrupt<TTools, TInterrupts>) => undefined): void;
95
+ };
96
+ cancelInterrupts: () => void;
97
+ retryInterrupts: () => void;
98
+ resumeInterruptsUnsafe: (resume: Array<RunAgentResumeItem>, state?: ChatResumeState) => Promise<boolean>;
99
+ /** Reload the last assistant message. */
100
+ reload: () => Promise<void>;
101
+ /** Stop the current response generation. */
102
+ stop: () => void;
103
+ /** Whether a response is currently being generated. */
104
+ isLoading: Signal<boolean>;
105
+ /**
106
+ * True when the last hydrate or older-page response said more messages exist.
107
+ */
108
+ hasOlderMessages: Signal<boolean>;
109
+ /**
110
+ * Fetch the next older window and put it in front of the painted messages.
111
+ */
112
+ loadOlderMessages: () => Promise<void>;
113
+ /** Current error, if any. */
114
+ error: Signal<Error | undefined>;
115
+ /** Set messages manually. */
116
+ setMessages: (messages: ReadonlyArray<UIMessage<TTools, TData>>) => void;
117
+ /** Clear all messages. */
118
+ clear: () => void;
119
+ /** Current generation status. */
120
+ status: Signal<ChatClientState>;
121
+ /** Whether the subscription loop is active. */
122
+ isSubscribed: Signal<boolean>;
123
+ /** Current connection lifecycle status. */
124
+ connectionStatus: Signal<ConnectionStatus>;
125
+ /** Whether the shared session is actively generating. */
126
+ sessionGenerating: Signal<boolean>;
127
+ /** Whether the chat is being rebuilt from persistence. */
128
+ isHydrating: Signal<boolean>;
134
129
  }
135
-
136
- declare function injectChat<const TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>, const TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []>(options: InjectChatOptions<TTools, TSchema, TContext, TInterrupts>): InjectChatResult<TTools, TSchema, TInterrupts>;
137
-
138
- declare function injectByok(client: ByokClient): Signal<ByokSnapshot>;
139
-
130
+ export declare function injectChat<const TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>, const TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []>(options: InjectChatOptions<TTools, TSchema, TContext, TInterrupts>): InjectChatResult<TTools, TSchema, TInterrupts>;
131
+ export declare function injectByok(client: ByokClient): Signal<ByokSnapshot>;
140
132
  /**
141
133
  * Options for {@link injectRegisterWebMCPTools}.
142
134
  *
143
135
  * Context is required when a client tool declares a required runtime context.
144
136
  */
145
137
  type InjectRegisterWebMCPToolsOptions<TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>> = Omit<RegisterWebMCPToolsOptions<TTools, TContext>, 'signal'> & {
146
- /** Receives asynchronous WebMCP registration errors. */
147
- onError?: (error: unknown) => void;
138
+ /** Receives asynchronous WebMCP registration errors. */
139
+ onError?: (error: unknown) => void;
148
140
  };
149
141
  /**
150
142
  * Registers executable client tools with WebMCP for the current Angular owner.
@@ -162,9 +154,9 @@ type InjectRegisterWebMCPToolsOptions<TTools extends ReadonlyArray<AnyClientTool
162
154
  * })
163
155
  * ```
164
156
  */
165
- declare function injectRegisterWebMCPTools<const TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>>(tools: TTools, ...[options]: {} extends InjectRegisterWebMCPToolsOptions<TTools, TContext> ? [options?: InjectRegisterWebMCPToolsOptions<TTools, TContext>] : [options: InjectRegisterWebMCPToolsOptions<TTools, TContext>]): void;
157
+ export declare function injectRegisterWebMCPTools<const TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>>(tools: TTools, ...[options]: {} extends InjectRegisterWebMCPToolsOptions<TTools, TContext> ? [options?: InjectRegisterWebMCPToolsOptions<TTools, TContext>] : [options: InjectRegisterWebMCPToolsOptions<TTools, TContext>]): void;
166
158
  /** Options for {@link injectPageWebMCPTools}. */
167
- type InjectPageWebMCPToolsOptions = Omit<SubscribeWebMCPToolsOptions, 'signal'>;
159
+ type InjectPageWebMCPToolsOptions = Omit<SubscribeWebMCPToolsOptions$1, 'signal'>;
168
160
  /**
169
161
  * Returns the WebMCP tools on the page as client tools for `injectChat`.
170
162
  *
@@ -182,77 +174,76 @@ type InjectPageWebMCPToolsOptions = Omit<SubscribeWebMCPToolsOptions, 'signal'>;
182
174
  * chat = injectChat({ threadId: 'support-1', connection, tools: this.pageTools })
183
175
  * ```
184
176
  */
185
- declare function injectPageWebMCPTools(options?: InjectPageWebMCPToolsOptions): Signal<Array<AnyClientTool$1>>;
186
-
177
+ export declare function injectPageWebMCPTools(options?: InjectPageWebMCPToolsOptions): Signal<Array<AnyClientTool$1>>;
187
178
  interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
188
- /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
189
- connection?: ConnectConnectionAdapter;
190
- /** Direct async function for one-shot generation (no streaming protocol needed) */
191
- fetcher?: GenerationFetcher<TInput, TResult>;
192
- /** Additional request body params. Reactive. */
193
- body?: ReactiveOption<Record<string, any>>;
194
- /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */
195
- byok?: ByokClient;
196
- /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */
197
- byokProvider?: () => ProviderId | undefined;
198
- /** Display options for TanStack AI Devtools. */
199
- devtools?: AIDevtoolsDisplayOptions;
200
- /**
201
- * How this generation persists across reloads.
202
- * - Omit / `false`: ephemeral, in-memory only.
203
- * - `true`: server-driven — on mount the client hydrates the last generation
204
- * for its `threadId` from the server (needs a connection with a
205
- * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.
206
- */
207
- persistence?: boolean;
208
- /**
209
- * The **scope** this generation belongs to: a stable, app-chosen name for the
210
- * slot successive runs fill — not a link to a chat conversation.
211
- *
212
- * The hook starts empty and produces many runs over its life; each gets its
213
- * own `runId`, but all belong to one scope. Persistence keys on this, so
214
- * derive it from your own domain and keep it identical across reloads (e.g.
215
- * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread
216
- * id on the wire, which the protocol requires.
217
- *
218
- * Required. A generated id would change on every reload, so persistence
219
- * would restore nothing.
220
- */
221
- threadId: string;
222
- /**
223
- * Server-driven hydration handler for `persistence: true` when the
224
- * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /
225
- * `rpcStream()` adapter built without handlers) — typically a one-line
226
- * server-function call. The connection's own handler takes precedence.
227
- */
228
- hydrateGeneration?: ConnectConnectionAdapter['hydrateGeneration'];
229
- /**
230
- * Re-attach handler that replays a run still generating to completion on
231
- * mount, when the connection doesn't carry one. Without it, a restored
232
- * `running` snapshot surfaces as an (interrupted) error. The connection's
233
- * own handler takes precedence.
234
- */
235
- joinRun?: ConnectConnectionAdapter['joinRun'];
236
- /**
237
- * Callback when a result is received. Can optionally return a transformed value.
238
- *
239
- * - Return a non-null value to transform and store it as the result
240
- * - Return `null` to keep the previous result unchanged
241
- * - Return nothing (`void`) to store the raw result as-is
242
- */
243
- onResult?: (result: TResult) => TOutput | null | void;
244
- /** Callback when an error occurs */
245
- onError?: (error: Error) => void;
246
- /** Callback when progress is reported (0-100) */
247
- onProgress?: (progress: number, message?: string) => void;
248
- /** Callback for each stream chunk (connect-based adapter mode only) */
249
- onChunk?: (chunk: StreamChunk) => void;
250
- /**
251
- * @internal Rebuild a typed result from a restored snapshot, injected by each
252
- * specialized injectable (image / speech / audio / transcription / summarize).
253
- * Forwarded to the client so a server-hydrate restore repaints `result`.
254
- */
255
- reconstructResult?: (restored: GenerationRestoredResult) => TResult | null;
179
+ /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
180
+ connection?: ConnectConnectionAdapter$1;
181
+ /** Direct async function for one-shot generation (no streaming protocol needed) */
182
+ fetcher?: GenerationFetcher<TInput, TResult>;
183
+ /** Additional request body params. Reactive. */
184
+ body?: ReactiveOption<Record<string, any>>;
185
+ /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */
186
+ byok?: ByokClient;
187
+ /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */
188
+ byokProvider?: () => ProviderId | undefined;
189
+ /** Display options for TanStack AI Devtools. */
190
+ devtools?: AIDevtoolsDisplayOptions;
191
+ /**
192
+ * How this generation persists across reloads.
193
+ * - Omit / `false`: ephemeral, in-memory only.
194
+ * - `true`: server-driven — on mount the client hydrates the last generation
195
+ * for its `threadId` from the server (needs a connection with a
196
+ * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.
197
+ */
198
+ persistence?: boolean;
199
+ /**
200
+ * The **scope** this generation belongs to: a stable, app-chosen name for the
201
+ * slot successive runs fill — not a link to a chat conversation.
202
+ *
203
+ * The hook starts empty and produces many runs over its life; each gets its
204
+ * own `runId`, but all belong to one scope. Persistence keys on this, so
205
+ * derive it from your own domain and keep it identical across reloads (e.g.
206
+ * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread
207
+ * id on the wire, which the protocol requires.
208
+ *
209
+ * Required. A generated id would change on every reload, so persistence
210
+ * would restore nothing.
211
+ */
212
+ threadId: string;
213
+ /**
214
+ * Server-driven hydration handler for `persistence: true` when the
215
+ * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /
216
+ * `rpcStream()` adapter built without handlers) — typically a one-line
217
+ * server-function call. The connection's own handler takes precedence.
218
+ */
219
+ hydrateGeneration?: ConnectConnectionAdapter$1['hydrateGeneration'];
220
+ /**
221
+ * Re-attach handler that replays a run still generating to completion on
222
+ * mount, when the connection doesn't carry one. Without it, a restored
223
+ * `running` snapshot surfaces as an (interrupted) error. The connection's
224
+ * own handler takes precedence.
225
+ */
226
+ joinRun?: ConnectConnectionAdapter$1['joinRun'];
227
+ /**
228
+ * Callback when a result is received. Can optionally return a transformed value.
229
+ *
230
+ * - Return a non-null value to transform and store it as the result
231
+ * - Return `null` to keep the previous result unchanged
232
+ * - Return nothing (`void`) to store the raw result as-is
233
+ */
234
+ onResult?: (result: TResult) => TOutput | null | void;
235
+ /** Callback when an error occurs */
236
+ onError?: (error: Error) => void;
237
+ /** Callback when progress is reported (0-100) */
238
+ onProgress?: (progress: number, message?: string) => void;
239
+ /** Callback for each stream chunk (connect-based adapter mode only) */
240
+ onChunk?: (chunk: StreamChunk) => void;
241
+ /**
242
+ * @internal Rebuild a typed result from a restored snapshot, injected by each
243
+ * specialized injectable (image / speech / audio / transcription / summarize).
244
+ * Forwarded to the client so a server-hydrate restore repaints `result`.
245
+ */
246
+ reconstructResult?: (restored: GenerationRestoredResult) => TResult | null;
256
247
  }
257
248
  /**
258
249
  * Return type for the injectGeneration function.
@@ -261,75 +252,73 @@ interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
261
252
  * @template TInput - The input type accepted by `generate` (defaults to any object)
262
253
  */
263
254
  interface InjectGenerationResult<TOutput, TInput extends Record<string, any> = Record<string, any>> {
264
- /** Trigger a generation request */
265
- generate: (input: TInput) => Promise<void>;
266
- /** The generation result, or null if not yet generated */
267
- result: Signal<TOutput | null>;
268
- /** Whether a generation is currently in progress */
269
- isLoading: Signal<boolean>;
270
- /** Current error, if any */
271
- error: Signal<Error | undefined>;
272
- /** Current state of the generation client */
273
- status: Signal<GenerationClientState>;
274
- /** Abort the current generation */
275
- stop: () => void;
276
- /** Clear result, error, and return to idle */
277
- reset: () => void;
278
- /** Identity of the in-flight run while one is streaming, or null after it ends */
279
- /**
280
- * The id of the generation job currently running, or `null` when nothing is in
281
- * flight. Each call to `generate` is one job with its own id. Pass it to your
282
- * own endpoint to cancel or poll the provider job — `stop()` only aborts the
283
- * local stream, it does not stop work already running on the provider.
284
- */
285
- runId: Signal<string | null>;
255
+ /** Trigger a generation request */
256
+ generate: (input: TInput) => Promise<void>;
257
+ /** The generation result, or null if not yet generated */
258
+ result: Signal<TOutput | null>;
259
+ /** Whether a generation is currently in progress */
260
+ isLoading: Signal<boolean>;
261
+ /** Current error, if any */
262
+ error: Signal<Error | undefined>;
263
+ /** Current state of the generation client */
264
+ status: Signal<GenerationClientState$1>;
265
+ /** Abort the current generation */
266
+ stop: () => void;
267
+ /** Clear result, error, and return to idle */
268
+ reset: () => void;
269
+ /** Identity of the in-flight run while one is streaming, or null after it ends */
270
+ /**
271
+ * The id of the generation job currently running, or `null` when nothing is in
272
+ * flight. Each call to `generate` is one job with its own id. Pass it to your
273
+ * own endpoint to cancel or poll the provider job — `stop()` only aborts the
274
+ * local stream, it does not stop work already running on the provider.
275
+ */
276
+ runId: Signal<string | null>;
286
277
  }
287
- declare function injectGeneration<TInput extends Record<string, any>, TResult, TTransformed = void>(options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {
288
- onResult?: (result: TResult) => TTransformed;
278
+ export declare function injectGeneration<TInput extends Record<string, any>, TResult, TTransformed = void>(options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {
279
+ onResult?: (result: TResult) => TTransformed;
289
280
  }): InjectGenerationResult<InferGenerationOutputFromReturn<TResult, TTransformed>, TInput>;
290
-
291
- type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>, 'onResult' | 'reconstructResult'> & {
292
- onResult?: (result: ImageGenerationResult) => TOutput | null | void;
281
+ type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<InjectGenerationOptions<ImageGenerateInput$1, ImageGenerationResult, TOutput>, 'onResult' | 'reconstructResult'> & {
282
+ onResult?: (result: ImageGenerationResult) => TOutput | null | void;
293
283
  };
294
284
  interface InjectGenerateImageResult<TOutput = ImageGenerationResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
295
- generate: (input: ImageGenerateInput) => Promise<void>;
296
- result: Signal<TOutput | null>;
297
- isLoading: Signal<boolean>;
298
- error: Signal<Error | undefined>;
299
- status: Signal<GenerationClientState>;
285
+ generate: (input: ImageGenerateInput$1) => Promise<void>;
286
+ result: Signal<TOutput | null>;
287
+ isLoading: Signal<boolean>;
288
+ error: Signal<Error | undefined>;
289
+ status: Signal<GenerationClientState$1>;
300
290
  }
301
- declare function injectGenerateImage<TTransformed = void>(options: Omit<InjectGenerateImageOptions, 'onResult'> & {
302
- onResult?: (result: ImageGenerationResult) => TTransformed;
291
+ export declare function injectGenerateImage<TTransformed = void>(options: Omit<InjectGenerateImageOptions, 'onResult'> & {
292
+ onResult?: (result: ImageGenerationResult) => TTransformed;
303
293
  }): InjectGenerateImageResult<InferGenerationOutputFromReturn<ImageGenerationResult, TTransformed>>;
304
-
305
294
  /**
306
295
  * Options for the injectGenerateAudio injectable.
307
296
  *
308
297
  * @template TOutput - The output type after optional transform (defaults to AudioGenerationResult)
309
298
  */
310
- interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> extends Pick<InjectGenerationOptions<AudioGenerateInput, AudioGenerationResult, TOutput>, 'persistence' | 'threadId' | 'hydrateGeneration' | 'joinRun' | 'byok' | 'byokProvider'> {
311
- /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
312
- connection?: ConnectConnectionAdapter;
313
- /** Direct async function for audio generation */
314
- fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>;
315
- /** Additional body parameters to send with connect-based adapter requests. Reactive. */
316
- body?: ReactiveOption<Record<string, any>>;
317
- /** Display options for TanStack AI Devtools. */
318
- devtools?: AIDevtoolsDisplayOptions;
319
- /**
320
- * Callback when audio is generated. Can optionally return a transformed value.
321
- *
322
- * - Return a non-null value to transform and store it as the result
323
- * - Return `null` to keep the previous result unchanged
324
- * - Return nothing (`void`) to store the raw result as-is
325
- */
326
- onResult?: (result: AudioGenerationResult) => TOutput | null | void;
327
- /** Callback when an error occurs */
328
- onError?: (error: Error) => void;
329
- /** Callback when progress is reported (0-100) */
330
- onProgress?: (progress: number, message?: string) => void;
331
- /** Callback for each stream chunk (connect-based adapter mode only) */
332
- onChunk?: (chunk: StreamChunk) => void;
299
+ interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> extends Pick<InjectGenerationOptions<AudioGenerateInput$1, AudioGenerationResult, TOutput>, 'persistence' | 'threadId' | 'hydrateGeneration' | 'joinRun' | 'byok' | 'byokProvider'> {
300
+ /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
301
+ connection?: ConnectConnectionAdapter$1;
302
+ /** Direct async function for audio generation */
303
+ fetcher?: GenerationFetcher<AudioGenerateInput$1, AudioGenerationResult>;
304
+ /** Additional body parameters to send with connect-based adapter requests. Reactive. */
305
+ body?: ReactiveOption<Record<string, any>>;
306
+ /** Display options for TanStack AI Devtools. */
307
+ devtools?: AIDevtoolsDisplayOptions;
308
+ /**
309
+ * Callback when audio is generated. Can optionally return a transformed value.
310
+ *
311
+ * - Return a non-null value to transform and store it as the result
312
+ * - Return `null` to keep the previous result unchanged
313
+ * - Return nothing (`void`) to store the raw result as-is
314
+ */
315
+ onResult?: (result: AudioGenerationResult) => TOutput | null | void;
316
+ /** Callback when an error occurs */
317
+ onError?: (error: Error) => void;
318
+ /** Callback when progress is reported (0-100) */
319
+ onProgress?: (progress: number, message?: string) => void;
320
+ /** Callback for each stream chunk (connect-based adapter mode only) */
321
+ onChunk?: (chunk: StreamChunk) => void;
333
322
  }
334
323
  /**
335
324
  * Return type for the injectGenerateAudio injectable.
@@ -337,16 +326,16 @@ interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> extends Pi
337
326
  * @template TOutput - The output type (after optional transform)
338
327
  */
339
328
  interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
340
- /** Trigger audio generation */
341
- generate: (input: AudioGenerateInput) => Promise<void>;
342
- /** The generation result containing audio, or null */
343
- result: Signal<TOutput | null>;
344
- /** Whether generation is in progress */
345
- isLoading: Signal<boolean>;
346
- /** Current error, if any */
347
- error: Signal<Error | undefined>;
348
- /** Current state of the generation */
349
- status: Signal<GenerationClientState>;
329
+ /** Trigger audio generation */
330
+ generate: (input: AudioGenerateInput$1) => Promise<void>;
331
+ /** The generation result containing audio, or null */
332
+ result: Signal<TOutput | null>;
333
+ /** Whether generation is in progress */
334
+ isLoading: Signal<boolean>;
335
+ /** Current error, if any */
336
+ error: Signal<Error | undefined>;
337
+ /** Current state of the generation */
338
+ status: Signal<GenerationClientState$1>;
350
339
  }
351
340
  /**
352
341
  * Angular injectable for generating audio (music, sound effects) using AI models.
@@ -380,58 +369,55 @@ interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> extends Omi
380
369
  * }
381
370
  * ```
382
371
  */
383
- declare function injectGenerateAudio<TTransformed = void>(options: Omit<InjectGenerateAudioOptions, 'onResult'> & {
384
- onResult?: (result: AudioGenerationResult) => TTransformed;
372
+ export declare function injectGenerateAudio<TTransformed = void>(options: Omit<InjectGenerateAudioOptions, 'onResult'> & {
373
+ onResult?: (result: AudioGenerationResult) => TTransformed;
385
374
  }): InjectGenerateAudioResult<InferGenerationOutputFromReturn<AudioGenerationResult, TTransformed>>;
386
-
387
- type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>, 'onResult' | 'reconstructResult'> & {
388
- onResult?: (result: TTSResult) => TOutput | null | void;
375
+ type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<InjectGenerationOptions<SpeechGenerateInput$1, TTSResult, TOutput>, 'onResult' | 'reconstructResult'> & {
376
+ onResult?: (result: TTSResult) => TOutput | null | void;
389
377
  };
390
378
  interface InjectGenerateSpeechResult<TOutput = TTSResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
391
- generate: (input: SpeechGenerateInput) => Promise<void>;
392
- result: Signal<TOutput | null>;
393
- isLoading: Signal<boolean>;
394
- error: Signal<Error | undefined>;
395
- status: Signal<GenerationClientState>;
379
+ generate: (input: SpeechGenerateInput$1) => Promise<void>;
380
+ result: Signal<TOutput | null>;
381
+ isLoading: Signal<boolean>;
382
+ error: Signal<Error | undefined>;
383
+ status: Signal<GenerationClientState$1>;
396
384
  }
397
- declare function injectGenerateSpeech<TTransformed = void>(options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {
398
- onResult?: (result: TTSResult) => TTransformed;
385
+ export declare function injectGenerateSpeech<TTransformed = void>(options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {
386
+ onResult?: (result: TTSResult) => TTransformed;
399
387
  }): InjectGenerateSpeechResult<InferGenerationOutputFromReturn<TTSResult, TTransformed>>;
400
-
401
- type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<InjectGenerationOptions<TranscriptionGenerateInput, TranscriptionResult, TOutput>, 'onResult' | 'reconstructResult'> & {
402
- onResult?: (result: TranscriptionResult) => TOutput | null | void;
388
+ type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<InjectGenerationOptions<TranscriptionGenerateInput$1, TranscriptionResult, TOutput>, 'onResult' | 'reconstructResult'> & {
389
+ onResult?: (result: TranscriptionResult) => TOutput | null | void;
403
390
  };
404
391
  interface InjectTranscriptionResult<TOutput = TranscriptionResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
405
- generate: (input: TranscriptionGenerateInput) => Promise<void>;
406
- result: Signal<TOutput | null>;
407
- isLoading: Signal<boolean>;
408
- error: Signal<Error | undefined>;
409
- status: Signal<GenerationClientState>;
392
+ generate: (input: TranscriptionGenerateInput$1) => Promise<void>;
393
+ result: Signal<TOutput | null>;
394
+ isLoading: Signal<boolean>;
395
+ error: Signal<Error | undefined>;
396
+ status: Signal<GenerationClientState$1>;
410
397
  }
411
- declare function injectTranscription<TTransformed = void>(options: Omit<InjectTranscriptionOptions, 'onResult'> & {
412
- onResult?: (result: TranscriptionResult) => TTransformed;
398
+ export declare function injectTranscription<TTransformed = void>(options: Omit<InjectTranscriptionOptions, 'onResult'> & {
399
+ onResult?: (result: TranscriptionResult) => TTransformed;
413
400
  }): InjectTranscriptionResult<InferGenerationOutputFromReturn<TranscriptionResult, TTransformed>>;
414
-
415
401
  type InjectAudioRecorderOptions<TOnComplete> = AudioRecorderOptions & {
416
- /**
417
- * Optional transform applied to the recording when `stop()` resolves. Its
418
- * (awaited) return value becomes `recording` and the resolved value of
419
- * `stop()`. Return nothing to keep the raw `AudioRecording`.
420
- */
421
- onComplete?: TOnComplete;
402
+ /**
403
+ * Optional transform applied to the recording when `stop()` resolves. Its
404
+ * (awaited) return value becomes `recording` and the resolved value of
405
+ * `stop()`. Return nothing to keep the raw `AudioRecording`.
406
+ */
407
+ onComplete?: TOnComplete;
422
408
  };
423
409
  interface InjectAudioRecorderResult<TOutput> {
424
- /** Reactive: latest recording (transformed if `onComplete` provided), or null. */
425
- recording: Signal<TOutput | null>;
426
- /** Reactive: true while actively capturing audio. */
427
- isRecording: Signal<boolean>;
428
- /** Whether the browser supports recording. */
429
- isSupported: boolean;
430
- start: () => Promise<void>;
431
- /** Stop and resolve with the completed recording (transformed if `onComplete` provided). */
432
- stop: () => Promise<TOutput>;
433
- /** Discard the in-progress recording and release the mic. */
434
- cancel: () => void;
410
+ /** Reactive: latest recording (transformed if `onComplete` provided), or null. */
411
+ recording: Signal<TOutput | null>;
412
+ /** Reactive: true while actively capturing audio. */
413
+ isRecording: Signal<boolean>;
414
+ /** Whether the browser supports recording. */
415
+ isSupported: boolean;
416
+ start: () => Promise<void>;
417
+ /** Stop and resolve with the completed recording (transformed if `onComplete` provided). */
418
+ stop: () => Promise<TOutput>;
419
+ /** Discard the in-progress recording and release the mic. */
420
+ cancel: () => void;
435
421
  }
436
422
  /**
437
423
  * Angular injectable for recording an audio message. The resolved recording
@@ -442,98 +428,94 @@ interface InjectAudioRecorderResult<TOutput> {
442
428
  * failure (and `stop()` rejects with `Recording cancelled` if `cancel()` runs
443
429
  * while a stop is in flight, e.g. on destroy) — handle one channel, not both.
444
430
  */
445
- declare function injectAudioRecorder<TOnComplete extends (recording: AudioRecording) => unknown>(options: InjectAudioRecorderOptions<TOnComplete> & {
446
- onComplete: TOnComplete;
431
+ export declare function injectAudioRecorder<TOnComplete extends (recording: AudioRecording) => unknown>(options: InjectAudioRecorderOptions<TOnComplete> & {
432
+ onComplete: TOnComplete;
447
433
  }): InjectAudioRecorderResult<InferAudioRecordingOutput<TOnComplete>>;
448
- declare function injectAudioRecorder(options?: InjectAudioRecorderOptions<undefined>): InjectAudioRecorderResult<AudioRecording>;
449
-
450
- type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>, 'onResult' | 'reconstructResult'> & {
451
- onResult?: (result: SummarizationResult) => TOutput | null | void;
434
+ export declare function injectAudioRecorder(options?: InjectAudioRecorderOptions<undefined>): InjectAudioRecorderResult<AudioRecording>;
435
+ type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<InjectGenerationOptions<SummarizeGenerateInput$1, SummarizationResult, TOutput>, 'onResult' | 'reconstructResult'> & {
436
+ onResult?: (result: SummarizationResult) => TOutput | null | void;
452
437
  };
453
438
  interface InjectSummarizeResult<TOutput = SummarizationResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
454
- generate: (input: SummarizeGenerateInput) => Promise<void>;
455
- result: Signal<TOutput | null>;
456
- isLoading: Signal<boolean>;
457
- error: Signal<Error | undefined>;
458
- status: Signal<GenerationClientState>;
439
+ generate: (input: SummarizeGenerateInput$1) => Promise<void>;
440
+ result: Signal<TOutput | null>;
441
+ isLoading: Signal<boolean>;
442
+ error: Signal<Error | undefined>;
443
+ status: Signal<GenerationClientState$1>;
459
444
  }
460
- declare function injectSummarize<TTransformed = void>(options: Omit<InjectSummarizeOptions, 'onResult'> & {
461
- onResult?: (result: SummarizationResult) => TTransformed;
445
+ export declare function injectSummarize<TTransformed = void>(options: Omit<InjectSummarizeOptions, 'onResult'> & {
446
+ onResult?: (result: SummarizationResult) => TTransformed;
462
447
  }): InjectSummarizeResult<InferGenerationOutputFromReturn<SummarizationResult, TTransformed>>;
463
-
464
- interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {
465
- connection?: ConnectConnectionAdapter;
466
- fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>;
467
- body?: ReactiveOption<Record<string, any>>;
468
- /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */
469
- byok?: ByokClient;
470
- /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */
471
- byokProvider?: () => ProviderId | undefined;
472
- devtools?: AIDevtoolsDisplayOptions;
473
- /**
474
- * How this generation persists across reloads.
475
- * - Omit / `false`: ephemeral, in-memory only.
476
- * - `true`: server-driven — on mount the client hydrates the last generation
477
- * for its `threadId` from the server (needs a connection with a
478
- * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.
479
- */
480
- persistence?: boolean;
481
- /**
482
- * The **scope** this generation belongs to: a stable, app-chosen name for the
483
- * slot successive runs fill — not a link to a chat conversation.
484
- *
485
- * The hook starts empty and produces many runs over its life; each gets its
486
- * own `runId`, but all belong to one scope. Persistence keys on this, so
487
- * derive it from your own domain and keep it identical across reloads (e.g.
488
- * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread
489
- * id on the wire, which the protocol requires.
490
- *
491
- * Required. A generated id would change on every reload, so persistence
492
- * would restore nothing.
493
- */
494
- threadId: string;
495
- /**
496
- * Server-driven hydration handler for `persistence: true` when the
497
- * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /
498
- * `rpcStream()` adapter built without handlers) — typically a one-line
499
- * server-function call. The connection's own handler takes precedence.
500
- */
501
- hydrateGeneration?: ConnectConnectionAdapter['hydrateGeneration'];
502
- /**
503
- * Re-attach handler that replays a run still generating to completion on
504
- * mount, when the connection doesn't carry one. Without it, a restored
505
- * `running` snapshot surfaces as an (interrupted) error. The connection's
506
- * own handler takes precedence.
507
- */
508
- joinRun?: ConnectConnectionAdapter['joinRun'];
509
- onResult?: (result: VideoGenerateResult) => TOutput | null | void;
510
- onError?: (error: Error) => void;
511
- onProgress?: (progress: number, message?: string) => void;
512
- onJobCreated?: (jobId: string) => void;
513
- onStatusUpdate?: (status: VideoStatusInfo) => void;
514
- onChunk?: (chunk: StreamChunk) => void;
448
+ interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult$1> {
449
+ connection?: ConnectConnectionAdapter$1;
450
+ fetcher?: GenerationFetcher<VideoGenerateInput$1, VideoGenerateResult$1>;
451
+ body?: ReactiveOption<Record<string, any>>;
452
+ /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */
453
+ byok?: ByokClient;
454
+ /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */
455
+ byokProvider?: () => ProviderId | undefined;
456
+ devtools?: AIDevtoolsDisplayOptions;
457
+ /**
458
+ * How this generation persists across reloads.
459
+ * - Omit / `false`: ephemeral, in-memory only.
460
+ * - `true`: server-driven — on mount the client hydrates the last generation
461
+ * for its `threadId` from the server (needs a connection with a
462
+ * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.
463
+ */
464
+ persistence?: boolean;
465
+ /**
466
+ * The **scope** this generation belongs to: a stable, app-chosen name for the
467
+ * slot successive runs fill — not a link to a chat conversation.
468
+ *
469
+ * The hook starts empty and produces many runs over its life; each gets its
470
+ * own `runId`, but all belong to one scope. Persistence keys on this, so
471
+ * derive it from your own domain and keep it identical across reloads (e.g.
472
+ * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread
473
+ * id on the wire, which the protocol requires.
474
+ *
475
+ * Required. A generated id would change on every reload, so persistence
476
+ * would restore nothing.
477
+ */
478
+ threadId: string;
479
+ /**
480
+ * Server-driven hydration handler for `persistence: true` when the
481
+ * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /
482
+ * `rpcStream()` adapter built without handlers) — typically a one-line
483
+ * server-function call. The connection's own handler takes precedence.
484
+ */
485
+ hydrateGeneration?: ConnectConnectionAdapter$1['hydrateGeneration'];
486
+ /**
487
+ * Re-attach handler that replays a run still generating to completion on
488
+ * mount, when the connection doesn't carry one. Without it, a restored
489
+ * `running` snapshot surfaces as an (interrupted) error. The connection's
490
+ * own handler takes precedence.
491
+ */
492
+ joinRun?: ConnectConnectionAdapter$1['joinRun'];
493
+ onResult?: (result: VideoGenerateResult$1) => TOutput | null | void;
494
+ onError?: (error: Error) => void;
495
+ onProgress?: (progress: number, message?: string) => void;
496
+ onJobCreated?: (jobId: string) => void;
497
+ onStatusUpdate?: (status: VideoStatusInfo$1) => void;
498
+ onChunk?: (chunk: StreamChunk) => void;
515
499
  }
516
- interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {
517
- generate: (input: VideoGenerateInput) => Promise<void>;
518
- result: Signal<TOutput | null>;
519
- jobId: Signal<string | null>;
520
- videoStatus: Signal<VideoStatusInfo | null>;
521
- isLoading: Signal<boolean>;
522
- error: Signal<Error | undefined>;
523
- status: Signal<GenerationClientState>;
524
- stop: () => void;
525
- reset: () => void;
526
- /**
527
- * The id of the generation job currently running, or `null` when nothing is in
528
- * flight. Each call to `generate` is one job with its own id. Pass it to your
529
- * own endpoint to cancel or poll the provider job — `stop()` only aborts the
530
- * local stream, it does not stop work already running on the provider.
531
- */
532
- runId: Signal<string | null>;
500
+ interface InjectGenerateVideoResult<TOutput = VideoGenerateResult$1> {
501
+ generate: (input: VideoGenerateInput$1) => Promise<void>;
502
+ result: Signal<TOutput | null>;
503
+ jobId: Signal<string | null>;
504
+ videoStatus: Signal<VideoStatusInfo$1 | null>;
505
+ isLoading: Signal<boolean>;
506
+ error: Signal<Error | undefined>;
507
+ status: Signal<GenerationClientState$1>;
508
+ stop: () => void;
509
+ reset: () => void;
510
+ /**
511
+ * The id of the generation job currently running, or `null` when nothing is in
512
+ * flight. Each call to `generate` is one job with its own id. Pass it to your
513
+ * own endpoint to cancel or poll the provider job — `stop()` only aborts the
514
+ * local stream, it does not stop work already running on the provider.
515
+ */
516
+ runId: Signal<string | null>;
533
517
  }
534
- declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGenerateVideoOptions, 'onResult'> & {
535
- onResult?: (result: VideoGenerateResult) => TTransformed;
536
- }): InjectGenerateVideoResult<InferGenerationOutputFromReturn<VideoGenerateResult, TTransformed>>;
537
-
538
- export { injectAudioRecorder, injectByok, injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectPageWebMCPTools, injectRegisterWebMCPTools, injectSummarize, injectTranscription };
539
- export type { DeepPartial, InjectAudioRecorderOptions, InjectAudioRecorderResult, InjectChatOptions, InjectChatResult, InjectGenerateAudioOptions, InjectGenerateAudioResult, InjectGenerateImageOptions, InjectGenerateImageResult, InjectGenerateSpeechOptions, InjectGenerateSpeechResult, InjectGenerateVideoOptions, InjectGenerateVideoResult, InjectGenerationOptions, InjectGenerationResult, InjectPageWebMCPToolsOptions, InjectRegisterWebMCPToolsOptions, InjectSummarizeOptions, InjectSummarizeResult, InjectTranscriptionOptions, InjectTranscriptionResult, ReactiveOption };
518
+ export declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGenerateVideoOptions, 'onResult'> & {
519
+ onResult?: (result: VideoGenerateResult$1) => TTransformed;
520
+ }): InjectGenerateVideoResult<InferGenerationOutputFromReturn<VideoGenerateResult$1, TTransformed>>;
521
+ export { type AudioGenerateInput, AudioRecorder, BatchStrategy, ChatClient, type ChatClientPersistence, type ChatPersistedState, type ChatPersistenceOption, type ChatRequestBody, type ChatStorageAdapter, CompositeStrategy, type ConnectConnectionAdapter, type ConnectionAdapter, type CreateMcpAppBridgeOptions, type DeepPartial, DurableStreamIncompleteError, type FetchConnectionOptions, type FetchJsonOptions, GENERATION_EVENTS, GenerationClient, type GenerationClientState, type GetWebMCPToolsOptions, type ImageGenerateInput, ImmediateStrategy, type IndexedDBPersistenceOptions, type InferChatMessages, type InjectAudioRecorderOptions, type InjectAudioRecorderResult, type InjectChatOptions, type InjectChatResult, type InjectGenerateAudioOptions, type InjectGenerateAudioResult, type InjectGenerateImageOptions, type InjectGenerateImageResult, type InjectGenerateSpeechOptions, type InjectGenerateSpeechResult, type InjectGenerateVideoOptions, type InjectGenerateVideoResult, type InjectGenerationOptions, type InjectGenerationResult, type InjectPageWebMCPToolsOptions, type InjectRegisterWebMCPToolsOptions, type InjectSummarizeOptions, type InjectSummarizeResult, type InjectTranscriptionOptions, type InjectTranscriptionResult, InterruptManager, type McpAppBridge, type MultimodalContent, PartialJSONParser, PunctuationStrategy, type QueueConfig, type QueueOption, type QueueStrategy, type QueuedMessage, type ReactiveOption, RealtimeClient, type RunAgentInputContext, type SendMessageOptions, type SpeechGenerateInput, StorageUnavailableError, StreamProcessor, StreamReconnectLimitError, StreamTruncatedError, type SubscribeConnectionAdapter, type SubscribeWebMCPToolsOptions, type SummarizeGenerateInput, type TranscriptionGenerateInput, type UIMessage, UnsupportedResponseStreamError, type VideoGenerateInput, type VideoGenerateResult, VideoGenerationClient, type VideoStatusInfo, type WebMCPPageTool, type WebSocketConnectionOptions, type WebStoragePersistenceOptions, type WhenBusy, WordBoundaryStrategy, type XhrConnectionOptions, clientTools, convertMessagesToModelMessages, createAIDevtoolsGenerationPreview, createChatClientOptions, createMcpAppBridge, defaultJSONParser, fetchHttpStream, fetchJson, fetchServerSentEvents, generateMessageId, getWebMCPTools, indexedDBPersistence, localStoragePersistence, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, parsePartialJSON, reconstructAudioResult, reconstructImageResult, reconstructSpeechResult, reconstructSummarizeResult, reconstructTranscriptionResult, registerWebMCPTools, rpcStream, sessionStoragePersistence, stream, subscribeWebMCPTools, uiMessageToModelMessages, webSocket, xhrHttpStream, xhrServerSentEvents };