@tanstack/ai-angular 0.0.1

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.
@@ -0,0 +1,478 @@
1
+ import { ChatClient, GenerationClient, VideoGenerationClient } from '@tanstack/ai-client';
2
+ export { createChatClientOptions, fetchHttpStream, fetchServerSentEvents, rpcStream, stream, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
3
+ import { createChatDevtoolsBridge, createGenerationDevtoolsBridge, createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools';
4
+ import { isSignal, computed, inject, DestroyRef, Injector, signal, effect, afterNextRender } from '@angular/core';
5
+
6
+ /**
7
+ * Normalize a {@link ReactiveOption} into a `Signal`-like getter `() => T`.
8
+ *
9
+ * - A `Signal` is returned as-is (already a getter that tracks reads).
10
+ * - A zero-arg function is wrapped in `computed` so reads inside it are tracked.
11
+ * - A plain value becomes a constant `computed` (never re-fires).
12
+ */
13
+ function toReactive(value) {
14
+ if (isSignal(value)) {
15
+ return value;
16
+ }
17
+ if (typeof value === 'function') {
18
+ return computed(value);
19
+ }
20
+ return computed(() => value);
21
+ }
22
+
23
+ let nextId$2 = 0;
24
+ function injectChat(options = {}) {
25
+ const destroyRef = inject(DestroyRef);
26
+ const injector = inject(Injector);
27
+ const clientId = options.id || `injectChat-${nextId$2++}`;
28
+ const messages = signal(options.initialMessages || [], ...(ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []));
29
+ const isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
30
+ const error = signal(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
31
+ const status = signal('ready', ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
32
+ const isSubscribed = signal(false, ...(ngDevMode ? [{ debugName: "isSubscribed" }] : /* istanbul ignore next */ []));
33
+ const connectionStatus = signal('disconnected', ...(ngDevMode ? [{ debugName: "connectionStatus" }] : /* istanbul ignore next */ []));
34
+ const sessionGenerating = signal(false, ...(ngDevMode ? [{ debugName: "sessionGenerating" }] : /* istanbul ignore next */ []));
35
+ // Reactive option sources. Plain values become constant computeds.
36
+ const bodySource = options.body !== undefined ? toReactive(options.body) : undefined;
37
+ const forwardedPropsSource = options.forwardedProps !== undefined
38
+ ? toReactive(options.forwardedProps)
39
+ : undefined;
40
+ const contextSource = options.context !== undefined ? toReactive(options.context) : undefined;
41
+ const liveSource = options.live !== undefined ? toReactive(options.live) : undefined;
42
+ const transport = options.connection
43
+ ? { connection: options.connection }
44
+ : { fetcher: options.fetcher };
45
+ const client = new ChatClient({
46
+ devtoolsBridgeFactory: createChatDevtoolsBridge,
47
+ ...transport,
48
+ id: clientId,
49
+ ...(options.initialMessages !== undefined && {
50
+ initialMessages: options.initialMessages,
51
+ }),
52
+ ...(options.persistence !== undefined && {
53
+ persistence: options.persistence,
54
+ }),
55
+ ...(bodySource !== undefined && { body: bodySource() }),
56
+ ...(options.threadId !== undefined && { threadId: options.threadId }),
57
+ ...(forwardedPropsSource !== undefined && {
58
+ forwardedProps: forwardedPropsSource(),
59
+ }),
60
+ ...(contextSource !== undefined && { context: contextSource() }),
61
+ devtools: {
62
+ ...options.devtools,
63
+ framework: 'angular',
64
+ hookName: 'injectChat',
65
+ outputKind: options.outputSchema ? 'structured' : 'chat',
66
+ },
67
+ onResponse: (response) => options.onResponse?.(response),
68
+ onChunk: (chunk) => options.onChunk?.(chunk),
69
+ onFinish: (message) => options.onFinish?.(message),
70
+ onError: (err) => options.onError?.(err),
71
+ tools: options.tools,
72
+ onCustomEvent: (eventType, data, context) => options.onCustomEvent?.(eventType, data, context),
73
+ ...(options.streamProcessor !== undefined && {
74
+ streamProcessor: options.streamProcessor,
75
+ }),
76
+ onMessagesChange: (m) => messages.set(m),
77
+ onLoadingChange: (v) => isLoading.set(v),
78
+ onStatusChange: (v) => status.set(v),
79
+ onErrorChange: (v) => error.set(v),
80
+ onSubscriptionChange: (v) => isSubscribed.set(v),
81
+ onConnectionStatusChange: (v) => connectionStatus.set(v),
82
+ onSessionGeneratingChange: (v) => sessionGenerating.set(v),
83
+ });
84
+ messages.set(client.getMessages());
85
+ // Sync reactive body / forwardedProps / context to the client.
86
+ if (bodySource || forwardedPropsSource || contextSource) {
87
+ effect(() => {
88
+ const newBody = bodySource?.();
89
+ const newForwardedProps = forwardedPropsSource?.();
90
+ const newContext = contextSource?.();
91
+ client.updateOptions({
92
+ ...(newBody !== undefined && { body: newBody }),
93
+ ...(newForwardedProps !== undefined && {
94
+ forwardedProps: newForwardedProps,
95
+ }),
96
+ ...(newContext !== undefined && { context: newContext }),
97
+ });
98
+ }, { injector });
99
+ }
100
+ // Subscribe / unsubscribe based on reactive `live`.
101
+ if (liveSource) {
102
+ effect(() => {
103
+ if (liveSource()) {
104
+ client.subscribe();
105
+ }
106
+ else {
107
+ client.unsubscribe();
108
+ }
109
+ }, { injector });
110
+ }
111
+ afterNextRender(() => client.mountDevtools(), { injector });
112
+ destroyRef.onDestroy(() => {
113
+ if (liveSource?.()) {
114
+ client.unsubscribe();
115
+ }
116
+ else {
117
+ client.stop();
118
+ }
119
+ client.dispose();
120
+ });
121
+ // Active structured-output part = the one on the assistant message after the
122
+ // latest user message. Ported from ai-vue/src/use-chat.ts.
123
+ const activeStructuredPart = computed(() => {
124
+ const list = messages();
125
+ let lastUserIndex = -1;
126
+ for (let i = list.length - 1; i >= 0; i--) {
127
+ if (list[i]?.role === 'user') {
128
+ lastUserIndex = i;
129
+ break;
130
+ }
131
+ }
132
+ if (lastUserIndex === -1)
133
+ return null;
134
+ for (let i = list.length - 1; i > lastUserIndex; i--) {
135
+ const m = list[i];
136
+ if (m?.role !== 'assistant')
137
+ continue;
138
+ const part = m.parts.find((p) => p.type === 'structured-output');
139
+ if (part)
140
+ return part;
141
+ }
142
+ return null;
143
+ }, ...(ngDevMode ? [{ debugName: "activeStructuredPart" }] : /* istanbul ignore next */ []));
144
+ const partial = computed(() => {
145
+ const part = activeStructuredPart();
146
+ if (!part)
147
+ return {};
148
+ const v = part.partial ?? part.data;
149
+ return (v ?? {});
150
+ }, ...(ngDevMode ? [{ debugName: "partial" }] : /* istanbul ignore next */ []));
151
+ const final = computed(() => {
152
+ const part = activeStructuredPart();
153
+ if (!part || part.status !== 'complete')
154
+ return null;
155
+ return part.data;
156
+ }, ...(ngDevMode ? [{ debugName: "final" }] : /* istanbul ignore next */ []));
157
+ const sendMessage = async (content) => {
158
+ await client.sendMessage(content);
159
+ };
160
+ const append = async (message) => {
161
+ await client.append(message);
162
+ };
163
+ const reload = async () => {
164
+ await client.reload();
165
+ };
166
+ const stop = () => client.stop();
167
+ const clear = () => client.clear();
168
+ const setMessages = (m) => client.setMessagesManually(m);
169
+ const addToolResult = async (result) => {
170
+ await client.addToolResult(result);
171
+ };
172
+ const addToolApprovalResponse = async (response) => {
173
+ await client.addToolApprovalResponse(response);
174
+ };
175
+ // eslint-disable-next-line no-restricted-syntax -- return shape diverges from conditional InjectChatResult<TTools, TSchema>; TS can't structurally narrow the TSchema-gated partial/final signals
176
+ return {
177
+ messages: messages.asReadonly(),
178
+ sendMessage,
179
+ append,
180
+ reload,
181
+ stop,
182
+ isLoading: isLoading.asReadonly(),
183
+ error: error.asReadonly(),
184
+ status: status.asReadonly(),
185
+ isSubscribed: isSubscribed.asReadonly(),
186
+ connectionStatus: connectionStatus.asReadonly(),
187
+ sessionGenerating: sessionGenerating.asReadonly(),
188
+ setMessages,
189
+ clear,
190
+ addToolResult,
191
+ addToolApprovalResponse,
192
+ partial,
193
+ final,
194
+ };
195
+ }
196
+
197
+ let nextId$1 = 0;
198
+ function injectGeneration(options) {
199
+ const destroyRef = inject(DestroyRef);
200
+ const injector = inject(Injector);
201
+ const clientId = options.id || `injectGeneration-${nextId$1++}`;
202
+ const result = signal(null, ...(ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []));
203
+ const isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
204
+ const error = signal(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
205
+ const status = signal('idle', ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
206
+ const bodySource = options.body !== undefined ? toReactive(options.body) : undefined;
207
+ const clientOptions = {
208
+ id: clientId,
209
+ ...(bodySource !== undefined && { body: bodySource() }),
210
+ devtoolsBridgeFactory: createGenerationDevtoolsBridge,
211
+ devtools: {
212
+ ...options.devtools,
213
+ framework: 'angular',
214
+ hookName: 'injectGeneration',
215
+ },
216
+ onResult: (r) => options.onResult?.(r),
217
+ onError: (e) => options.onError?.(e),
218
+ onProgress: (p, m) => options.onProgress?.(p, m),
219
+ onChunk: (c) => options.onChunk?.(c),
220
+ onResultChange: (r) => result.set(r),
221
+ onLoadingChange: (l) => isLoading.set(l),
222
+ onErrorChange: (e) => error.set(e),
223
+ onStatusChange: (s) => status.set(s),
224
+ };
225
+ let client;
226
+ if (options.connection) {
227
+ client = new GenerationClient({
228
+ ...clientOptions,
229
+ connection: options.connection,
230
+ });
231
+ }
232
+ else if (options.fetcher) {
233
+ client = new GenerationClient({
234
+ ...clientOptions,
235
+ fetcher: options.fetcher,
236
+ });
237
+ }
238
+ else {
239
+ throw new Error('injectGeneration requires either a connection or fetcher option');
240
+ }
241
+ if (bodySource) {
242
+ effect(() => {
243
+ client.updateOptions({ body: bodySource() });
244
+ }, { injector });
245
+ }
246
+ afterNextRender(() => client.mountDevtools(), { injector });
247
+ destroyRef.onDestroy(() => client.dispose());
248
+ return {
249
+ generate: ((input) => client.generate(input)),
250
+ result: result.asReadonly(),
251
+ isLoading: isLoading.asReadonly(),
252
+ error: error.asReadonly(),
253
+ status: status.asReadonly(),
254
+ stop: () => client.stop(),
255
+ reset: () => client.reset(),
256
+ };
257
+ }
258
+
259
+ function injectGenerateImage(options) {
260
+ const devtools = {
261
+ ...options.devtools,
262
+ framework: 'angular',
263
+ hookName: 'injectGenerateImage',
264
+ outputKind: 'image',
265
+ };
266
+ const { generate, result, isLoading, error, status, stop, reset } = injectGeneration({
267
+ ...options,
268
+ devtools,
269
+ });
270
+ return {
271
+ generate: generate,
272
+ result,
273
+ isLoading,
274
+ error,
275
+ status,
276
+ stop,
277
+ reset,
278
+ };
279
+ }
280
+
281
+ /**
282
+ * Angular injectable for generating audio (music, sound effects) using AI models.
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * import { Component } from '@angular/core'
287
+ * import { injectGenerateAudio } from '@tanstack/ai-angular'
288
+ * import { fetchServerSentEvents } from '@tanstack/ai-client'
289
+ *
290
+ * @Component({
291
+ * selector: 'app-audio',
292
+ * template: `
293
+ * <button (click)="generate({ prompt: 'An upbeat electronic track', duration: 10 })">
294
+ * Generate
295
+ * </button>
296
+ * @if (result()) {
297
+ * <audio [src]="result()!.audio.url" controls></audio>
298
+ * }
299
+ * `,
300
+ * })
301
+ * export class AudioComponent {
302
+ * private gen = injectGenerateAudio({
303
+ * connection: fetchServerSentEvents('/api/generate/audio'),
304
+ * })
305
+ *
306
+ * generate = this.gen.generate
307
+ * result = this.gen.result
308
+ * isLoading = this.gen.isLoading
309
+ * }
310
+ * ```
311
+ */
312
+ function injectGenerateAudio(options) {
313
+ const devtools = {
314
+ ...options.devtools,
315
+ framework: 'angular',
316
+ hookName: 'injectGenerateAudio',
317
+ outputKind: 'audio',
318
+ };
319
+ const { generate, result, isLoading, error, status, stop, reset } = injectGeneration({
320
+ ...options,
321
+ devtools,
322
+ });
323
+ return {
324
+ generate: generate,
325
+ result,
326
+ isLoading,
327
+ error,
328
+ status,
329
+ stop,
330
+ reset,
331
+ };
332
+ }
333
+
334
+ function injectGenerateSpeech(options) {
335
+ const devtools = {
336
+ ...options.devtools,
337
+ framework: 'angular',
338
+ hookName: 'injectGenerateSpeech',
339
+ outputKind: 'audio',
340
+ };
341
+ const { generate, result, isLoading, error, status, stop, reset } = injectGeneration({
342
+ ...options,
343
+ devtools,
344
+ });
345
+ return {
346
+ generate: generate,
347
+ result,
348
+ isLoading,
349
+ error,
350
+ status,
351
+ stop,
352
+ reset,
353
+ };
354
+ }
355
+
356
+ function injectTranscription(options) {
357
+ const devtools = {
358
+ ...options.devtools,
359
+ framework: 'angular',
360
+ hookName: 'injectTranscription',
361
+ outputKind: 'text',
362
+ };
363
+ const { generate, result, isLoading, error, status, stop, reset } = injectGeneration({
364
+ ...options,
365
+ devtools,
366
+ });
367
+ return {
368
+ generate: generate,
369
+ result,
370
+ isLoading,
371
+ error,
372
+ status,
373
+ stop,
374
+ reset,
375
+ };
376
+ }
377
+
378
+ function injectSummarize(options) {
379
+ const devtools = {
380
+ ...options.devtools,
381
+ framework: 'angular',
382
+ hookName: 'injectSummarize',
383
+ outputKind: 'text',
384
+ };
385
+ const { generate, result, isLoading, error, status, stop, reset } = injectGeneration({
386
+ ...options,
387
+ devtools,
388
+ });
389
+ return {
390
+ generate: generate,
391
+ result,
392
+ isLoading,
393
+ error,
394
+ status,
395
+ stop,
396
+ reset,
397
+ };
398
+ }
399
+
400
+ let nextId = 0;
401
+ function injectGenerateVideo(options) {
402
+ const destroyRef = inject(DestroyRef);
403
+ const injector = inject(Injector);
404
+ const clientId = options.id || `injectGenerateVideo-${nextId++}`;
405
+ const result = signal(null, ...(ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []));
406
+ const jobId = signal(null, ...(ngDevMode ? [{ debugName: "jobId" }] : /* istanbul ignore next */ []));
407
+ const videoStatus = signal(null, ...(ngDevMode ? [{ debugName: "videoStatus" }] : /* istanbul ignore next */ []));
408
+ const isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
409
+ const error = signal(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
410
+ const status = signal('idle', ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
411
+ const bodySource = options.body !== undefined ? toReactive(options.body) : undefined;
412
+ const baseOptions = {
413
+ id: clientId,
414
+ ...(bodySource !== undefined && { body: bodySource() }),
415
+ devtoolsBridgeFactory: createVideoDevtoolsBridge,
416
+ devtools: {
417
+ ...options.devtools,
418
+ framework: 'angular',
419
+ hookName: 'injectGenerateVideo',
420
+ outputKind: 'video',
421
+ },
422
+ onResult: (r) => options.onResult?.(r),
423
+ onError: (e) => options.onError?.(e),
424
+ onProgress: (p, m) => options.onProgress?.(p, m),
425
+ onChunk: (c) => options.onChunk?.(c),
426
+ onJobCreated: (id) => options.onJobCreated?.(id),
427
+ onStatusUpdate: (s) => options.onStatusUpdate?.(s),
428
+ onResultChange: (r) => result.set(r),
429
+ onLoadingChange: (l) => isLoading.set(l),
430
+ onErrorChange: (e) => error.set(e),
431
+ onStatusChange: (s) => status.set(s),
432
+ onJobIdChange: (id) => jobId.set(id),
433
+ onVideoStatusChange: (s) => videoStatus.set(s),
434
+ };
435
+ let client;
436
+ if (options.connection) {
437
+ client = new VideoGenerationClient({
438
+ ...baseOptions,
439
+ connection: options.connection,
440
+ });
441
+ }
442
+ else if (options.fetcher) {
443
+ client = new VideoGenerationClient({
444
+ ...baseOptions,
445
+ fetcher: options.fetcher,
446
+ });
447
+ }
448
+ else {
449
+ throw new Error('injectGenerateVideo requires either a connection or fetcher option');
450
+ }
451
+ if (bodySource) {
452
+ effect(() => {
453
+ client.updateOptions({ body: bodySource() });
454
+ }, { injector });
455
+ }
456
+ afterNextRender(() => client.mountDevtools(), { injector });
457
+ destroyRef.onDestroy(() => client.dispose());
458
+ return {
459
+ generate: (input) => client.generate(input),
460
+ result: result.asReadonly(),
461
+ jobId: jobId.asReadonly(),
462
+ videoStatus: videoStatus.asReadonly(),
463
+ isLoading: isLoading.asReadonly(),
464
+ error: error.asReadonly(),
465
+ status: status.asReadonly(),
466
+ stop: () => client.stop(),
467
+ reset: () => client.reset(),
468
+ };
469
+ }
470
+
471
+ // Chat
472
+
473
+ /**
474
+ * Generated bundle index. Do not edit.
475
+ */
476
+
477
+ export { injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription };
478
+ //# sourceMappingURL=tanstack-ai-angular.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tanstack-ai-angular.mjs","sources":["../../src/internal/to-reactive.ts","../../src/inject-chat.ts","../../src/inject-generation.ts","../../src/inject-generate-image.ts","../../src/inject-generate-audio.ts","../../src/inject-generate-speech.ts","../../src/inject-transcription.ts","../../src/inject-summarize.ts","../../src/inject-generate-video.ts","../../src/index.ts","../../src/tanstack-ai-angular.ts"],"sourcesContent":["import { computed, isSignal } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\n/**\n * A value that may be supplied to `injectChat` either as a static value, an\n * Angular `Signal`, or a zero-arg getter. The getter form lets callers read\n * other signals so the option stays reactive.\n */\nexport type ReactiveOption<T> = T | Signal<T> | (() => T)\n\n/**\n * Normalize a {@link ReactiveOption} into a `Signal`-like getter `() => T`.\n *\n * - A `Signal` is returned as-is (already a getter that tracks reads).\n * - A zero-arg function is wrapped in `computed` so reads inside it are tracked.\n * - A plain value becomes a constant `computed` (never re-fires).\n */\nexport function toReactive<T>(value: ReactiveOption<T>): () => T {\n if (isSignal(value)) {\n return value\n }\n if (typeof value === 'function') {\n return computed(value as () => T)\n }\n return computed(() => value)\n}\n","import { ChatClient } from '@tanstack/ai-client'\nimport { createChatDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n computed,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { toReactive } from './internal/to-reactive'\nimport type {\n AnyClientTool,\n InferSchemaType,\n ModelMessage,\n SchemaInput,\n StreamChunk,\n} from '@tanstack/ai'\nimport type {\n ChatClientState,\n ConnectionStatus,\n InferredClientContext,\n StructuredOutputPart,\n} from '@tanstack/ai-client'\nimport type {\n DeepPartial,\n InjectChatOptions,\n InjectChatResult,\n MultimodalContent,\n UIMessage,\n} from './types'\n\nlet nextId = 0\n\nexport function injectChat<\n TTools extends ReadonlyArray<AnyClientTool> = any,\n TSchema extends SchemaInput | undefined = undefined,\n TContext = InferredClientContext<TTools>,\n>(\n options: InjectChatOptions<\n TTools,\n TSchema,\n TContext\n > = {} as InjectChatOptions<TTools, TSchema, TContext>,\n): InjectChatResult<TTools, TSchema> {\n type Partial = DeepPartial<InferSchemaType<NonNullable<TSchema>>>\n type Final = InferSchemaType<NonNullable<TSchema>>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\n const clientId = options.id || `injectChat-${nextId++}`\n\n const messages = signal<Array<UIMessage<TTools>>>(\n options.initialMessages || [],\n )\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<ChatClientState>('ready')\n const isSubscribed = signal(false)\n const connectionStatus = signal<ConnectionStatus>('disconnected')\n const sessionGenerating = signal(false)\n\n // Reactive option sources. Plain values become constant computeds.\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n const forwardedPropsSource =\n options.forwardedProps !== undefined\n ? toReactive(options.forwardedProps)\n : undefined\n const contextSource =\n options.context !== undefined ? toReactive(options.context) : undefined\n const liveSource =\n options.live !== undefined ? toReactive(options.live) : undefined\n\n const transport = options.connection\n ? { connection: options.connection }\n : { fetcher: options.fetcher }\n\n const client = new ChatClient<TTools, TContext>({\n devtoolsBridgeFactory: createChatDevtoolsBridge,\n ...transport,\n id: clientId,\n ...(options.initialMessages !== undefined && {\n initialMessages: options.initialMessages,\n }),\n ...(options.persistence !== undefined && {\n persistence: options.persistence,\n }),\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.threadId !== undefined && { threadId: options.threadId }),\n ...(forwardedPropsSource !== undefined && {\n forwardedProps: forwardedPropsSource(),\n }),\n ...(contextSource !== undefined && { context: contextSource() }),\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectChat',\n outputKind: options.outputSchema ? 'structured' : 'chat',\n },\n onResponse: (response) => options.onResponse?.(response),\n onChunk: (chunk: StreamChunk) => options.onChunk?.(chunk),\n onFinish: (message) => options.onFinish?.(message),\n onError: (err) => options.onError?.(err),\n tools: options.tools,\n onCustomEvent: (eventType, data, context) =>\n options.onCustomEvent?.(eventType, data, context),\n ...(options.streamProcessor !== undefined && {\n streamProcessor: options.streamProcessor,\n }),\n onMessagesChange: (m: Array<UIMessage<TTools>>) => messages.set(m),\n onLoadingChange: (v: boolean) => isLoading.set(v),\n onStatusChange: (v: ChatClientState) => status.set(v),\n onErrorChange: (v: Error | undefined) => error.set(v),\n onSubscriptionChange: (v: boolean) => isSubscribed.set(v),\n onConnectionStatusChange: (v: ConnectionStatus) => connectionStatus.set(v),\n onSessionGeneratingChange: (v: boolean) => sessionGenerating.set(v),\n })\n\n messages.set(client.getMessages())\n\n // Sync reactive body / forwardedProps / context to the client.\n if (bodySource || forwardedPropsSource || contextSource) {\n effect(\n () => {\n const newBody = bodySource?.()\n const newForwardedProps = forwardedPropsSource?.()\n const newContext = contextSource?.()\n client.updateOptions({\n ...(newBody !== undefined && { body: newBody }),\n ...(newForwardedProps !== undefined && {\n forwardedProps: newForwardedProps,\n }),\n ...(newContext !== undefined && { context: newContext }),\n })\n },\n { injector },\n )\n }\n\n // Subscribe / unsubscribe based on reactive `live`.\n if (liveSource) {\n effect(\n () => {\n if (liveSource()) {\n client.subscribe()\n } else {\n client.unsubscribe()\n }\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n\n destroyRef.onDestroy(() => {\n if (liveSource?.()) {\n client.unsubscribe()\n } else {\n client.stop()\n }\n client.dispose()\n })\n\n // Active structured-output part = the one on the assistant message after the\n // latest user message. Ported from ai-vue/src/use-chat.ts.\n const activeStructuredPart = computed<StructuredOutputPart | null>(() => {\n const list = messages()\n let lastUserIndex = -1\n for (let i = list.length - 1; i >= 0; i--) {\n if (list[i]?.role === 'user') {\n lastUserIndex = i\n break\n }\n }\n if (lastUserIndex === -1) return null\n for (let i = list.length - 1; i > lastUserIndex; i--) {\n const m = list[i]\n if (m?.role !== 'assistant') continue\n const part = m.parts.find(\n (p): p is StructuredOutputPart => p.type === 'structured-output',\n )\n if (part) return part\n }\n return null\n })\n\n const partial = computed<Partial>(() => {\n const part = activeStructuredPart()\n if (!part) return {} as Partial\n const v = part.partial ?? part.data\n return (v ?? {}) as Partial\n })\n\n const final = computed<Final | null>(() => {\n const part = activeStructuredPart()\n if (!part || part.status !== 'complete') return null\n return part.data as Final\n })\n\n const sendMessage = async (content: string | MultimodalContent) => {\n await client.sendMessage(content)\n }\n const append = async (message: ModelMessage | UIMessage<TTools>) => {\n await client.append(message)\n }\n const reload = async () => {\n await client.reload()\n }\n const stop = () => client.stop()\n const clear = () => client.clear()\n const setMessages = (m: Array<UIMessage<TTools>>) =>\n client.setMessagesManually(m)\n const addToolResult = async (result: {\n toolCallId: string\n tool: string\n output: any\n state?: 'output-available' | 'output-error'\n errorText?: string\n }) => {\n await client.addToolResult(result)\n }\n const addToolApprovalResponse = async (response: {\n id: string\n approved: boolean\n }) => {\n await client.addToolApprovalResponse(response)\n }\n\n // eslint-disable-next-line no-restricted-syntax -- return shape diverges from conditional InjectChatResult<TTools, TSchema>; TS can't structurally narrow the TSchema-gated partial/final signals\n return {\n messages: messages.asReadonly(),\n sendMessage,\n append,\n reload,\n stop,\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n isSubscribed: isSubscribed.asReadonly(),\n connectionStatus: connectionStatus.asReadonly(),\n sessionGenerating: sessionGenerating.asReadonly(),\n setMessages,\n clear,\n addToolResult,\n addToolApprovalResponse,\n partial,\n final,\n } as unknown as InjectChatResult<TTools, TSchema>\n}\n","import { GenerationClient } from '@tanstack/ai-client'\nimport { createGenerationDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { toReactive } from './internal/to-reactive'\nimport type { Signal } from '@angular/core'\nimport type { StreamChunk } from '@tanstack/ai'\nimport type {\n AIDevtoolsDisplayOptions,\n ConnectConnectionAdapter,\n GenerationClientOptions,\n GenerationClientState,\n GenerationFetcher,\n InferGenerationOutput,\n} from '@tanstack/ai-client'\nimport type { ReactiveOption } from './internal/to-reactive'\n\nlet nextId = 0\n\nexport interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {\n /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */\n connection?: ConnectConnectionAdapter\n /** Direct async function for one-shot generation (no streaming protocol needed) */\n fetcher?: GenerationFetcher<TInput, TResult>\n /** Unique identifier for this generation instance */\n id?: string\n /** Additional request body params. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * Callback when a result is received. Can optionally return a transformed value.\n *\n * - Return a non-null value to transform and store it as the result\n * - Return `null` to keep the previous result unchanged\n * - Return nothing (`void`) to store the raw result as-is\n */\n onResult?: (result: TResult) => TOutput | null | void\n /** Callback when an error occurs */\n onError?: (error: Error) => void\n /** Callback when progress is reported (0-100) */\n onProgress?: (progress: number, message?: string) => void\n /** Callback for each stream chunk (connect-based adapter mode only) */\n onChunk?: (chunk: StreamChunk) => void\n}\n\nexport interface InjectGenerationResult<TOutput> {\n /** Trigger a generation request */\n generate: (input: Record<string, any>) => Promise<void>\n /** The generation result, or null if not yet generated */\n result: Signal<TOutput | null>\n /** Whether a generation is currently in progress */\n isLoading: Signal<boolean>\n /** Current error, if any */\n error: Signal<Error | undefined>\n /** Current state of the generation client */\n status: Signal<GenerationClientState>\n /** Abort the current generation */\n stop: () => void\n /** Clear result, error, and return to idle */\n reset: () => void\n}\n\nexport function injectGeneration<\n TInput extends Record<string, any>,\n TResult,\n TOnResult extends ((result: TResult) => any) | undefined = undefined,\n>(\n options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerationResult<InferGenerationOutput<TResult, TOnResult>> {\n type TOutput = InferGenerationOutput<TResult, TOnResult>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\n const clientId = options.id || `injectGeneration-${nextId++}`\n\n const result = signal<TOutput | null>(null)\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<GenerationClientState>('idle')\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const clientOptions: GenerationClientOptions<TInput, TResult, TOutput> = {\n id: clientId,\n ...(bodySource !== undefined && { body: bodySource() }),\n devtoolsBridgeFactory: createGenerationDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGeneration',\n },\n onResult: (r: TResult) => options.onResult?.(r),\n onError: (e: Error) => options.onError?.(e),\n onProgress: (p: number, m?: string) => options.onProgress?.(p, m),\n onChunk: (c: StreamChunk) => options.onChunk?.(c),\n onResultChange: (r: TOutput | null) => result.set(r),\n onLoadingChange: (l: boolean) => isLoading.set(l),\n onErrorChange: (e: Error | undefined) => error.set(e),\n onStatusChange: (s: GenerationClientState) => status.set(s),\n }\n\n let client: GenerationClient<TInput, TResult, TOutput>\n if (options.connection) {\n client = new GenerationClient({\n ...clientOptions,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new GenerationClient({\n ...clientOptions,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGeneration requires either a connection or fetcher option',\n )\n }\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({ body: bodySource() })\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n destroyRef.onDestroy(() => client.dispose())\n\n return {\n generate: ((input: TInput) => client.generate(input)) as (\n input: Record<string, any>,\n ) => Promise<void>,\n result: result.asReadonly(),\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n stop: () => client.stop(),\n reset: () => client.reset(),\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { ImageGenerationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n ImageGenerateInput,\n InferGenerationOutput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<\n InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: ImageGenerationResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateImageResult<TOutput = ImageGenerationResult> {\n generate: (input: ImageGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateImage<\n TOnResult extends ((result: ImageGenerationResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectGenerateImageOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateImageResult<\n InferGenerationOutput<ImageGenerationResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateImage',\n outputKind: 'image' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<ImageGenerateInput, ImageGenerationResult, TOnResult>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: ImageGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { AudioGenerationResult, StreamChunk } from '@tanstack/ai'\nimport type {\n AIDevtoolsDisplayOptions,\n AudioGenerateInput,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n InferGenerationOutput,\n} from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { ReactiveOption } from './internal/to-reactive'\n\n/**\n * Options for the injectGenerateAudio injectable.\n *\n * @template TOutput - The output type after optional transform (defaults to AudioGenerationResult)\n */\nexport interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> {\n /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */\n connection?: ConnectConnectionAdapter\n /** Direct async function for audio generation */\n fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>\n /** Unique identifier for this generation instance */\n id?: string\n /** Additional body parameters to send with connect-based adapter requests. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * Callback when audio is generated. Can optionally return a transformed value.\n *\n * - Return a non-null value to transform and store it as the result\n * - Return `null` to keep the previous result unchanged\n * - Return nothing (`void`) to store the raw result as-is\n */\n onResult?: (result: AudioGenerationResult) => TOutput | null | void\n /** Callback when an error occurs */\n onError?: (error: Error) => void\n /** Callback when progress is reported (0-100) */\n onProgress?: (progress: number, message?: string) => void\n /** Callback for each stream chunk (connect-based adapter mode only) */\n onChunk?: (chunk: StreamChunk) => void\n}\n\n/**\n * Return type for the injectGenerateAudio injectable.\n *\n * @template TOutput - The output type (after optional transform)\n */\nexport interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> {\n /** Trigger audio generation */\n generate: (input: AudioGenerateInput) => Promise<void>\n /** The generation result containing audio, or null */\n result: Signal<TOutput | null>\n /** Whether generation is in progress */\n isLoading: Signal<boolean>\n /** Current error, if any */\n error: Signal<Error | undefined>\n /** Current state of the generation */\n status: Signal<GenerationClientState>\n /** Abort the current generation */\n stop: () => void\n /** Clear result, error, and return to idle */\n reset: () => void\n}\n\n/**\n * Angular injectable for generating audio (music, sound effects) using AI models.\n *\n * @example\n * ```typescript\n * import { Component } from '@angular/core'\n * import { injectGenerateAudio } from '@tanstack/ai-angular'\n * import { fetchServerSentEvents } from '@tanstack/ai-client'\n *\n * @Component({\n * selector: 'app-audio',\n * template: `\n * <button (click)=\"generate({ prompt: 'An upbeat electronic track', duration: 10 })\">\n * Generate\n * </button>\n * @if (result()) {\n * <audio [src]=\"result()!.audio.url\" controls></audio>\n * }\n * `,\n * })\n * export class AudioComponent {\n * private gen = injectGenerateAudio({\n * connection: fetchServerSentEvents('/api/generate/audio'),\n * })\n *\n * generate = this.gen.generate\n * result = this.gen.result\n * isLoading = this.gen.isLoading\n * }\n * ```\n */\nexport function injectGenerateAudio<\n TOnResult extends ((result: AudioGenerationResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectGenerateAudioOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateAudioResult<\n InferGenerationOutput<AudioGenerationResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateAudio',\n outputKind: 'audio' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<AudioGenerateInput, AudioGenerationResult, TOnResult>({\n ...options,\n devtools,\n })\n\n return {\n generate: generate as (input: AudioGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { TTSResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutput,\n SpeechGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<\n InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: TTSResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateSpeechResult<TOutput = TTSResult> {\n generate: (input: SpeechGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateSpeech<\n TOnResult extends ((result: TTSResult) => any) | undefined = undefined,\n>(\n options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateSpeechResult<InferGenerationOutput<TTSResult, TOnResult>> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateSpeech',\n outputKind: 'audio' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<SpeechGenerateInput, TTSResult, TOnResult>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: SpeechGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { TranscriptionResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutput,\n TranscriptionGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<\n InjectGenerationOptions<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TOutput\n >,\n 'onResult'\n> & {\n onResult?: (result: TranscriptionResult) => TOutput | null | void\n}\n\nexport interface InjectTranscriptionResult<TOutput = TranscriptionResult> {\n generate: (input: TranscriptionGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectTranscription<\n TOnResult extends ((result: TranscriptionResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectTranscriptionOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectTranscriptionResult<\n InferGenerationOutput<TranscriptionResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectTranscription',\n outputKind: 'text' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TOnResult\n >({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: TranscriptionGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { SummarizationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutput,\n SummarizeGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<\n InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: SummarizationResult) => TOutput | null | void\n}\n\nexport interface InjectSummarizeResult<TOutput = SummarizationResult> {\n generate: (input: SummarizeGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectSummarize<\n TOnResult extends ((result: SummarizationResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectSummarizeOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectSummarizeResult<\n InferGenerationOutput<SummarizationResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectSummarize',\n outputKind: 'text' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<SummarizeGenerateInput, SummarizationResult, TOnResult>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: SummarizeGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { VideoGenerationClient } from '@tanstack/ai-client'\nimport { createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { toReactive } from './internal/to-reactive'\nimport type { Signal } from '@angular/core'\nimport type { StreamChunk } from '@tanstack/ai'\nimport type {\n AIDevtoolsDisplayOptions,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n InferGenerationOutput,\n VideoGenerateInput,\n VideoGenerateResult,\n VideoStatusInfo,\n} from '@tanstack/ai-client'\nimport type { ReactiveOption } from './internal/to-reactive'\n\nlet nextId = 0\n\nexport interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {\n connection?: ConnectConnectionAdapter\n fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>\n id?: string\n body?: ReactiveOption<Record<string, any>>\n devtools?: AIDevtoolsDisplayOptions\n onResult?: (result: VideoGenerateResult) => TOutput | null | void\n onError?: (error: Error) => void\n onProgress?: (progress: number, message?: string) => void\n onJobCreated?: (jobId: string) => void\n onStatusUpdate?: (status: VideoStatusInfo) => void\n onChunk?: (chunk: StreamChunk) => void\n}\n\nexport interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {\n generate: (input: VideoGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n jobId: Signal<string | null>\n videoStatus: Signal<VideoStatusInfo | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateVideo<\n TOnResult extends ((result: VideoGenerateResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectGenerateVideoOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateVideoResult<\n InferGenerationOutput<VideoGenerateResult, TOnResult>\n> {\n type TOutput = InferGenerationOutput<VideoGenerateResult, TOnResult>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\n const clientId = options.id || `injectGenerateVideo-${nextId++}`\n\n const result = signal<TOutput | null>(null)\n const jobId = signal<string | null>(null)\n const videoStatus = signal<VideoStatusInfo | null>(null)\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<GenerationClientState>('idle')\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const baseOptions = {\n id: clientId,\n ...(bodySource !== undefined && { body: bodySource() }),\n devtoolsBridgeFactory: createVideoDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateVideo',\n outputKind: 'video' as const,\n },\n onResult: (r: VideoGenerateResult) => options.onResult?.(r),\n onError: (e: Error) => options.onError?.(e),\n onProgress: (p: number, m?: string) => options.onProgress?.(p, m),\n onChunk: (c: StreamChunk) => options.onChunk?.(c),\n onJobCreated: (id: string) => options.onJobCreated?.(id),\n onStatusUpdate: (s: VideoStatusInfo) => options.onStatusUpdate?.(s),\n onResultChange: (r: TOutput | null) => result.set(r),\n onLoadingChange: (l: boolean) => isLoading.set(l),\n onErrorChange: (e: Error | undefined) => error.set(e),\n onStatusChange: (s: GenerationClientState) => status.set(s),\n onJobIdChange: (id: string | null) => jobId.set(id),\n onVideoStatusChange: (s: VideoStatusInfo | null) => videoStatus.set(s),\n }\n\n let client: VideoGenerationClient<TOutput>\n if (options.connection) {\n client = new VideoGenerationClient({\n ...baseOptions,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new VideoGenerationClient({\n ...baseOptions,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGenerateVideo requires either a connection or fetcher option',\n )\n }\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({ body: bodySource() })\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n destroyRef.onDestroy(() => client.dispose())\n\n return {\n generate: (input: VideoGenerateInput) => client.generate(input),\n result: result.asReadonly(),\n jobId: jobId.asReadonly(),\n videoStatus: videoStatus.asReadonly(),\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n stop: () => client.stop(),\n reset: () => client.reset(),\n }\n}\n","// Chat\nexport { injectChat } from './inject-chat'\n\n// Generation\nexport { injectGeneration } from './inject-generation'\nexport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\n// Generate Image\nexport { injectGenerateImage } from './inject-generate-image'\nexport type {\n InjectGenerateImageOptions,\n InjectGenerateImageResult,\n} from './inject-generate-image'\n\n// Generate Audio\nexport { injectGenerateAudio } from './inject-generate-audio'\nexport type {\n InjectGenerateAudioOptions,\n InjectGenerateAudioResult,\n} from './inject-generate-audio'\n\n// Generate Speech\nexport { injectGenerateSpeech } from './inject-generate-speech'\nexport type {\n InjectGenerateSpeechOptions,\n InjectGenerateSpeechResult,\n} from './inject-generate-speech'\n\n// Transcription\nexport { injectTranscription } from './inject-transcription'\nexport type {\n InjectTranscriptionOptions,\n InjectTranscriptionResult,\n} from './inject-transcription'\n\n// Summarize\nexport { injectSummarize } from './inject-summarize'\nexport type {\n InjectSummarizeOptions,\n InjectSummarizeResult,\n} from './inject-summarize'\n\n// Generate Video\nexport { injectGenerateVideo } from './inject-generate-video'\nexport type {\n InjectGenerateVideoOptions,\n InjectGenerateVideoResult,\n} from './inject-generate-video'\n\n// Types from ./types\nexport type {\n DeepPartial,\n InjectChatOptions,\n InjectChatResult,\n UIMessage,\n ChatRequestBody,\n MultimodalContent,\n ReactiveOption,\n} from './types'\n\n// Re-export from @tanstack/ai-client for convenience\nexport {\n fetchServerSentEvents,\n fetchHttpStream,\n xhrServerSentEvents,\n xhrHttpStream,\n stream,\n rpcStream,\n createChatClientOptions,\n type ConnectionAdapter,\n type ConnectConnectionAdapter,\n type SubscribeConnectionAdapter,\n type RunAgentInputContext,\n type FetchConnectionOptions,\n type XhrConnectionOptions,\n type InferChatMessages,\n type GenerationClientState,\n type ImageGenerateInput,\n type AudioGenerateInput,\n type SpeechGenerateInput,\n type TranscriptionGenerateInput,\n type SummarizeGenerateInput,\n type VideoGenerateInput,\n type VideoGenerateResult,\n type VideoStatusInfo,\n} from '@tanstack/ai-client'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["nextId"],"mappings":";;;;;AAUA;;;;;;AAMG;AACG,SAAU,UAAU,CAAI,KAAwB,EAAA;AACpD,IAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;AACnB,QAAA,OAAO,KAAK;IACd;AACA,IAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,QAAA,OAAO,QAAQ,CAAC,KAAgB,CAAC;IACnC;AACA,IAAA,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC;AAC9B;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