@tanstack/ai-angular 1.0.1 → 1.2.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.
- package/README.md +11 -10
- package/dist/README.md +11 -10
- package/dist/fesm2022/tanstack-ai-angular-byok.mjs +1 -6
- package/dist/fesm2022/tanstack-ai-angular-ui.mjs +578 -326
- package/dist/fesm2022/tanstack-ai-angular-ui.mjs.map +1 -1
- package/dist/fesm2022/tanstack-ai-angular.mjs +457 -665
- package/dist/fesm2022/tanstack-ai-angular.mjs.map +1 -1
- package/dist/types/tanstack-ai-angular-byok.d.ts +2 -1
- package/dist/types/tanstack-ai-angular-ui.d.ts +80 -95
- package/dist/types/tanstack-ai-angular.d.ts +414 -380
- package/package.json +17 -16
- package/src/index.ts +8 -0
- package/src/inject-generate-3d-model.ts +92 -0
- package/dist/fesm2022/tanstack-ai-angular-byok.mjs.map +0 -1
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { AnyClientTool,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ProviderId } from '@tanstack/ai/byok';
|
|
7
|
-
|
|
1
|
+
import { AnyClientTool, AudioGenerationResult, ImageGenerationResult, InferSchemaType, InterruptDefinition, Model3DResult, 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, Model3DGenerateInput, Model3DGenerateInput as Model3DGenerateInput$1, 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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
|
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
|
-
|
|
147
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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,125 @@ 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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
291
|
+
export declare function injectGenerateImage<TTransformed = void>(options: Omit<InjectGenerateImageOptions, 'onResult'> & {
|
|
292
|
+
onResult?: (result: ImageGenerationResult) => TTransformed;
|
|
303
293
|
}): InjectGenerateImageResult<InferGenerationOutputFromReturn<ImageGenerationResult, TTransformed>>;
|
|
304
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Options for {@link injectGenerate3DModel}.
|
|
296
|
+
*
|
|
297
|
+
* @experimental 3D model generation is experimental. The shape can change in
|
|
298
|
+
* a minor release.
|
|
299
|
+
*/
|
|
300
|
+
type InjectGenerate3DModelOptions<TOutput = Model3DResult> = Omit<InjectGenerationOptions<Model3DGenerateInput$1, Model3DResult, TOutput>, 'onResult' | 'reconstructResult' | 'persistence' | 'hydrateGeneration' | 'joinRun'> & {
|
|
301
|
+
onResult?: (result: Model3DResult) => TOutput | null | void;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Return type of {@link injectGenerate3DModel}.
|
|
305
|
+
*
|
|
306
|
+
* @experimental 3D model generation is experimental. The shape can change in
|
|
307
|
+
* a minor release.
|
|
308
|
+
*/
|
|
309
|
+
interface InjectGenerate3DModelResult<TOutput = Model3DResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
|
|
310
|
+
generate: (input: Model3DGenerateInput$1) => Promise<void>;
|
|
311
|
+
result: Signal<TOutput | null>;
|
|
312
|
+
isLoading: Signal<boolean>;
|
|
313
|
+
error: Signal<Error | undefined>;
|
|
314
|
+
status: Signal<GenerationClientState$1>;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Generates a 3D model from a text or image prompt, with Angular signals.
|
|
318
|
+
*
|
|
319
|
+
* The server route runs `generate3DModel()` and streams the response. The
|
|
320
|
+
* stream sends `generation:progress` events while the provider job runs, then
|
|
321
|
+
* one `generation:result` event with the `Model3DResult`. Call it in an
|
|
322
|
+
* injection context (a component field initializer, the constructor, or
|
|
323
|
+
* `runInInjectionContext`).
|
|
324
|
+
*
|
|
325
|
+
* @param options - A `connection` (streaming) or a `fetcher` (one request),
|
|
326
|
+
* a `threadId`, and optional callbacks (`onResult`, `onProgress`, `onError`).
|
|
327
|
+
* If `onResult` returns a value, `result` holds that value.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* model = injectGenerate3DModel({
|
|
332
|
+
* threadId: 'product-model',
|
|
333
|
+
* connection: fetchServerSentEvents('/api/generate/3d-model'),
|
|
334
|
+
* })
|
|
335
|
+
*
|
|
336
|
+
* this.model.generate({ prompt: 'A low-poly wooden chair' })
|
|
337
|
+
* // this.model.result()?.url is the GLB file
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* @experimental 3D model generation is experimental. The shape can change in
|
|
341
|
+
* a minor release.
|
|
342
|
+
*/
|
|
343
|
+
export declare function injectGenerate3DModel<TTransformed = void>(options: Omit<InjectGenerate3DModelOptions, 'onResult'> & {
|
|
344
|
+
onResult?: (result: Model3DResult) => TTransformed;
|
|
345
|
+
}): InjectGenerate3DModelResult<InferGenerationOutputFromReturn<Model3DResult, TTransformed>>;
|
|
305
346
|
/**
|
|
306
347
|
* Options for the injectGenerateAudio injectable.
|
|
307
348
|
*
|
|
308
349
|
* @template TOutput - The output type after optional transform (defaults to AudioGenerationResult)
|
|
309
350
|
*/
|
|
310
|
-
interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> extends Pick<InjectGenerationOptions<AudioGenerateInput, AudioGenerationResult, TOutput>, 'persistence' | 'threadId' | 'hydrateGeneration' | 'joinRun' | 'byok' | 'byokProvider'> {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
351
|
+
interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> extends Pick<InjectGenerationOptions<AudioGenerateInput$1, AudioGenerationResult, TOutput>, 'persistence' | 'threadId' | 'hydrateGeneration' | 'joinRun' | 'byok' | 'byokProvider'> {
|
|
352
|
+
/** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
|
|
353
|
+
connection?: ConnectConnectionAdapter$1;
|
|
354
|
+
/** Direct async function for audio generation */
|
|
355
|
+
fetcher?: GenerationFetcher<AudioGenerateInput$1, AudioGenerationResult>;
|
|
356
|
+
/** Additional body parameters to send with connect-based adapter requests. Reactive. */
|
|
357
|
+
body?: ReactiveOption<Record<string, any>>;
|
|
358
|
+
/** Display options for TanStack AI Devtools. */
|
|
359
|
+
devtools?: AIDevtoolsDisplayOptions;
|
|
360
|
+
/**
|
|
361
|
+
* Callback when audio is generated. Can optionally return a transformed value.
|
|
362
|
+
*
|
|
363
|
+
* - Return a non-null value to transform and store it as the result
|
|
364
|
+
* - Return `null` to keep the previous result unchanged
|
|
365
|
+
* - Return nothing (`void`) to store the raw result as-is
|
|
366
|
+
*/
|
|
367
|
+
onResult?: (result: AudioGenerationResult) => TOutput | null | void;
|
|
368
|
+
/** Callback when an error occurs */
|
|
369
|
+
onError?: (error: Error) => void;
|
|
370
|
+
/** Callback when progress is reported (0-100) */
|
|
371
|
+
onProgress?: (progress: number, message?: string) => void;
|
|
372
|
+
/** Callback for each stream chunk (connect-based adapter mode only) */
|
|
373
|
+
onChunk?: (chunk: StreamChunk) => void;
|
|
333
374
|
}
|
|
334
375
|
/**
|
|
335
376
|
* Return type for the injectGenerateAudio injectable.
|
|
@@ -337,16 +378,16 @@ interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> extends Pi
|
|
|
337
378
|
* @template TOutput - The output type (after optional transform)
|
|
338
379
|
*/
|
|
339
380
|
interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
381
|
+
/** Trigger audio generation */
|
|
382
|
+
generate: (input: AudioGenerateInput$1) => Promise<void>;
|
|
383
|
+
/** The generation result containing audio, or null */
|
|
384
|
+
result: Signal<TOutput | null>;
|
|
385
|
+
/** Whether generation is in progress */
|
|
386
|
+
isLoading: Signal<boolean>;
|
|
387
|
+
/** Current error, if any */
|
|
388
|
+
error: Signal<Error | undefined>;
|
|
389
|
+
/** Current state of the generation */
|
|
390
|
+
status: Signal<GenerationClientState$1>;
|
|
350
391
|
}
|
|
351
392
|
/**
|
|
352
393
|
* Angular injectable for generating audio (music, sound effects) using AI models.
|
|
@@ -380,58 +421,55 @@ interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> extends Omi
|
|
|
380
421
|
* }
|
|
381
422
|
* ```
|
|
382
423
|
*/
|
|
383
|
-
declare function injectGenerateAudio<TTransformed = void>(options: Omit<InjectGenerateAudioOptions, 'onResult'> & {
|
|
384
|
-
|
|
424
|
+
export declare function injectGenerateAudio<TTransformed = void>(options: Omit<InjectGenerateAudioOptions, 'onResult'> & {
|
|
425
|
+
onResult?: (result: AudioGenerationResult) => TTransformed;
|
|
385
426
|
}): InjectGenerateAudioResult<InferGenerationOutputFromReturn<AudioGenerationResult, TTransformed>>;
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
onResult?: (result: TTSResult) => TOutput | null | void;
|
|
427
|
+
type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<InjectGenerationOptions<SpeechGenerateInput$1, TTSResult, TOutput>, 'onResult' | 'reconstructResult'> & {
|
|
428
|
+
onResult?: (result: TTSResult) => TOutput | null | void;
|
|
389
429
|
};
|
|
390
430
|
interface InjectGenerateSpeechResult<TOutput = TTSResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
431
|
+
generate: (input: SpeechGenerateInput$1) => Promise<void>;
|
|
432
|
+
result: Signal<TOutput | null>;
|
|
433
|
+
isLoading: Signal<boolean>;
|
|
434
|
+
error: Signal<Error | undefined>;
|
|
435
|
+
status: Signal<GenerationClientState$1>;
|
|
396
436
|
}
|
|
397
|
-
declare function injectGenerateSpeech<TTransformed = void>(options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {
|
|
398
|
-
|
|
437
|
+
export declare function injectGenerateSpeech<TTransformed = void>(options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {
|
|
438
|
+
onResult?: (result: TTSResult) => TTransformed;
|
|
399
439
|
}): InjectGenerateSpeechResult<InferGenerationOutputFromReturn<TTSResult, TTransformed>>;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
onResult?: (result: TranscriptionResult) => TOutput | null | void;
|
|
440
|
+
type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<InjectGenerationOptions<TranscriptionGenerateInput$1, TranscriptionResult, TOutput>, 'onResult' | 'reconstructResult'> & {
|
|
441
|
+
onResult?: (result: TranscriptionResult) => TOutput | null | void;
|
|
403
442
|
};
|
|
404
443
|
interface InjectTranscriptionResult<TOutput = TranscriptionResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
444
|
+
generate: (input: TranscriptionGenerateInput$1) => Promise<void>;
|
|
445
|
+
result: Signal<TOutput | null>;
|
|
446
|
+
isLoading: Signal<boolean>;
|
|
447
|
+
error: Signal<Error | undefined>;
|
|
448
|
+
status: Signal<GenerationClientState$1>;
|
|
410
449
|
}
|
|
411
|
-
declare function injectTranscription<TTransformed = void>(options: Omit<InjectTranscriptionOptions, 'onResult'> & {
|
|
412
|
-
|
|
450
|
+
export declare function injectTranscription<TTransformed = void>(options: Omit<InjectTranscriptionOptions, 'onResult'> & {
|
|
451
|
+
onResult?: (result: TranscriptionResult) => TTransformed;
|
|
413
452
|
}): InjectTranscriptionResult<InferGenerationOutputFromReturn<TranscriptionResult, TTransformed>>;
|
|
414
|
-
|
|
415
453
|
type InjectAudioRecorderOptions<TOnComplete> = AudioRecorderOptions & {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
454
|
+
/**
|
|
455
|
+
* Optional transform applied to the recording when `stop()` resolves. Its
|
|
456
|
+
* (awaited) return value becomes `recording` and the resolved value of
|
|
457
|
+
* `stop()`. Return nothing to keep the raw `AudioRecording`.
|
|
458
|
+
*/
|
|
459
|
+
onComplete?: TOnComplete;
|
|
422
460
|
};
|
|
423
461
|
interface InjectAudioRecorderResult<TOutput> {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
462
|
+
/** Reactive: latest recording (transformed if `onComplete` provided), or null. */
|
|
463
|
+
recording: Signal<TOutput | null>;
|
|
464
|
+
/** Reactive: true while actively capturing audio. */
|
|
465
|
+
isRecording: Signal<boolean>;
|
|
466
|
+
/** Whether the browser supports recording. */
|
|
467
|
+
isSupported: boolean;
|
|
468
|
+
start: () => Promise<void>;
|
|
469
|
+
/** Stop and resolve with the completed recording (transformed if `onComplete` provided). */
|
|
470
|
+
stop: () => Promise<TOutput>;
|
|
471
|
+
/** Discard the in-progress recording and release the mic. */
|
|
472
|
+
cancel: () => void;
|
|
435
473
|
}
|
|
436
474
|
/**
|
|
437
475
|
* Angular injectable for recording an audio message. The resolved recording
|
|
@@ -442,98 +480,94 @@ interface InjectAudioRecorderResult<TOutput> {
|
|
|
442
480
|
* failure (and `stop()` rejects with `Recording cancelled` if `cancel()` runs
|
|
443
481
|
* while a stop is in flight, e.g. on destroy) — handle one channel, not both.
|
|
444
482
|
*/
|
|
445
|
-
declare function injectAudioRecorder<TOnComplete extends (recording: AudioRecording) => unknown>(options: InjectAudioRecorderOptions<TOnComplete> & {
|
|
446
|
-
|
|
483
|
+
export declare function injectAudioRecorder<TOnComplete extends (recording: AudioRecording) => unknown>(options: InjectAudioRecorderOptions<TOnComplete> & {
|
|
484
|
+
onComplete: TOnComplete;
|
|
447
485
|
}): InjectAudioRecorderResult<InferAudioRecordingOutput<TOnComplete>>;
|
|
448
|
-
declare function injectAudioRecorder(options?: InjectAudioRecorderOptions<undefined>): InjectAudioRecorderResult<AudioRecording>;
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
onResult?: (result: SummarizationResult) => TOutput | null | void;
|
|
486
|
+
export declare function injectAudioRecorder(options?: InjectAudioRecorderOptions<undefined>): InjectAudioRecorderResult<AudioRecording>;
|
|
487
|
+
type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<InjectGenerationOptions<SummarizeGenerateInput$1, SummarizationResult, TOutput>, 'onResult' | 'reconstructResult'> & {
|
|
488
|
+
onResult?: (result: SummarizationResult) => TOutput | null | void;
|
|
452
489
|
};
|
|
453
490
|
interface InjectSummarizeResult<TOutput = SummarizationResult> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
491
|
+
generate: (input: SummarizeGenerateInput$1) => Promise<void>;
|
|
492
|
+
result: Signal<TOutput | null>;
|
|
493
|
+
isLoading: Signal<boolean>;
|
|
494
|
+
error: Signal<Error | undefined>;
|
|
495
|
+
status: Signal<GenerationClientState$1>;
|
|
459
496
|
}
|
|
460
|
-
declare function injectSummarize<TTransformed = void>(options: Omit<InjectSummarizeOptions, 'onResult'> & {
|
|
461
|
-
|
|
497
|
+
export declare function injectSummarize<TTransformed = void>(options: Omit<InjectSummarizeOptions, 'onResult'> & {
|
|
498
|
+
onResult?: (result: SummarizationResult) => TTransformed;
|
|
462
499
|
}): InjectSummarizeResult<InferGenerationOutputFromReturn<SummarizationResult, TTransformed>>;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
onChunk?: (chunk: StreamChunk) => void;
|
|
500
|
+
interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult$1> {
|
|
501
|
+
connection?: ConnectConnectionAdapter$1;
|
|
502
|
+
fetcher?: GenerationFetcher<VideoGenerateInput$1, VideoGenerateResult$1>;
|
|
503
|
+
body?: ReactiveOption<Record<string, any>>;
|
|
504
|
+
/** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */
|
|
505
|
+
byok?: ByokClient;
|
|
506
|
+
/** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */
|
|
507
|
+
byokProvider?: () => ProviderId | undefined;
|
|
508
|
+
devtools?: AIDevtoolsDisplayOptions;
|
|
509
|
+
/**
|
|
510
|
+
* How this generation persists across reloads.
|
|
511
|
+
* - Omit / `false`: ephemeral, in-memory only.
|
|
512
|
+
* - `true`: server-driven — on mount the client hydrates the last generation
|
|
513
|
+
* for its `threadId` from the server (needs a connection with a
|
|
514
|
+
* `hydrateGeneration` handler) and repaints it; it never auto-starts a run.
|
|
515
|
+
*/
|
|
516
|
+
persistence?: boolean;
|
|
517
|
+
/**
|
|
518
|
+
* The **scope** this generation belongs to: a stable, app-chosen name for the
|
|
519
|
+
* slot successive runs fill — not a link to a chat conversation.
|
|
520
|
+
*
|
|
521
|
+
* The hook starts empty and produces many runs over its life; each gets its
|
|
522
|
+
* own `runId`, but all belong to one scope. Persistence keys on this, so
|
|
523
|
+
* derive it from your own domain and keep it identical across reloads (e.g.
|
|
524
|
+
* `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread
|
|
525
|
+
* id on the wire, which the protocol requires.
|
|
526
|
+
*
|
|
527
|
+
* Required. A generated id would change on every reload, so persistence
|
|
528
|
+
* would restore nothing.
|
|
529
|
+
*/
|
|
530
|
+
threadId: string;
|
|
531
|
+
/**
|
|
532
|
+
* Server-driven hydration handler for `persistence: true` when the
|
|
533
|
+
* connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /
|
|
534
|
+
* `rpcStream()` adapter built without handlers) — typically a one-line
|
|
535
|
+
* server-function call. The connection's own handler takes precedence.
|
|
536
|
+
*/
|
|
537
|
+
hydrateGeneration?: ConnectConnectionAdapter$1['hydrateGeneration'];
|
|
538
|
+
/**
|
|
539
|
+
* Re-attach handler that replays a run still generating to completion on
|
|
540
|
+
* mount, when the connection doesn't carry one. Without it, a restored
|
|
541
|
+
* `running` snapshot surfaces as an (interrupted) error. The connection's
|
|
542
|
+
* own handler takes precedence.
|
|
543
|
+
*/
|
|
544
|
+
joinRun?: ConnectConnectionAdapter$1['joinRun'];
|
|
545
|
+
onResult?: (result: VideoGenerateResult$1) => TOutput | null | void;
|
|
546
|
+
onError?: (error: Error) => void;
|
|
547
|
+
onProgress?: (progress: number, message?: string) => void;
|
|
548
|
+
onJobCreated?: (jobId: string) => void;
|
|
549
|
+
onStatusUpdate?: (status: VideoStatusInfo$1) => void;
|
|
550
|
+
onChunk?: (chunk: StreamChunk) => void;
|
|
515
551
|
}
|
|
516
|
-
interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
552
|
+
interface InjectGenerateVideoResult<TOutput = VideoGenerateResult$1> {
|
|
553
|
+
generate: (input: VideoGenerateInput$1) => Promise<void>;
|
|
554
|
+
result: Signal<TOutput | null>;
|
|
555
|
+
jobId: Signal<string | null>;
|
|
556
|
+
videoStatus: Signal<VideoStatusInfo$1 | null>;
|
|
557
|
+
isLoading: Signal<boolean>;
|
|
558
|
+
error: Signal<Error | undefined>;
|
|
559
|
+
status: Signal<GenerationClientState$1>;
|
|
560
|
+
stop: () => void;
|
|
561
|
+
reset: () => void;
|
|
562
|
+
/**
|
|
563
|
+
* The id of the generation job currently running, or `null` when nothing is in
|
|
564
|
+
* flight. Each call to `generate` is one job with its own id. Pass it to your
|
|
565
|
+
* own endpoint to cancel or poll the provider job — `stop()` only aborts the
|
|
566
|
+
* local stream, it does not stop work already running on the provider.
|
|
567
|
+
*/
|
|
568
|
+
runId: Signal<string | null>;
|
|
533
569
|
}
|
|
534
|
-
declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGenerateVideoOptions, 'onResult'> & {
|
|
535
|
-
|
|
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 };
|
|
570
|
+
export declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGenerateVideoOptions, 'onResult'> & {
|
|
571
|
+
onResult?: (result: VideoGenerateResult$1) => TTransformed;
|
|
572
|
+
}): InjectGenerateVideoResult<InferGenerationOutputFromReturn<VideoGenerateResult$1, TTransformed>>;
|
|
573
|
+
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 InjectGenerate3DModelOptions, type InjectGenerate3DModelResult, 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 Model3DGenerateInput, 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 };
|