@tanstack/ai-angular 0.13.4 → 0.14.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.
@@ -20,29 +20,10 @@ function toReactive(value) {
20
20
  return () => value;
21
21
  }
22
22
 
23
- const EMPTY_INTERRUPTS = Object.freeze([]);
24
- const EMPTY_INTERRUPT_ERRORS = Object.freeze([]);
25
23
  function injectChat(options = {}) {
26
24
  assertInInjectionContext(injectChat);
27
25
  const destroyRef = inject(DestroyRef);
28
26
  const injector = inject(Injector);
29
- const messages = signal(options.initialMessages || [], ...(ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []));
30
- const isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
31
- const hasOlderMessages = signal(false, ...(ngDevMode ? [{ debugName: "hasOlderMessages" }] : /* istanbul ignore next */ []));
32
- const error = signal(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
33
- const status = signal('ready', ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
34
- const isSubscribed = signal(false, ...(ngDevMode ? [{ debugName: "isSubscribed" }] : /* istanbul ignore next */ []));
35
- const connectionStatus = signal('disconnected', ...(ngDevMode ? [{ debugName: "connectionStatus" }] : /* istanbul ignore next */ []));
36
- const sessionGenerating = signal(false, ...(ngDevMode ? [{ debugName: "sessionGenerating" }] : /* istanbul ignore next */ []));
37
- const isHydrating = signal(false, ...(ngDevMode ? [{ debugName: "isHydrating" }] : /* istanbul ignore next */ []));
38
- const queue = signal([], ...(ngDevMode ? [{ debugName: "queue" }] : /* istanbul ignore next */ []));
39
- const runId = signal(null, ...(ngDevMode ? [{ debugName: "runId" }] : /* istanbul ignore next */ []));
40
- const interruptState = signal({
41
- interrupts: EMPTY_INTERRUPTS,
42
- pendingInterrupts: EMPTY_INTERRUPTS,
43
- interruptErrors: EMPTY_INTERRUPT_ERRORS,
44
- resuming: false,
45
- }, ...(ngDevMode ? [{ debugName: "interruptState" }] : /* istanbul ignore next */ []));
46
27
  // Reactive option sources. Plain values become constant computeds.
47
28
  const bodySource = options.body !== undefined ? toReactive(options.body) : undefined;
48
29
  const forwardedPropsSource = options.forwardedProps !== undefined
@@ -98,13 +79,7 @@ function injectChat(options = {}) {
98
79
  onChunk: (chunk) => options.onChunk?.(chunk),
99
80
  onFinish: (message) => options.onFinish?.(message),
100
81
  onError: (err) => options.onError?.(err),
101
- onRunIdChange: (nextRunId) => runId.set(nextRunId),
102
- // No `onResumeStateChange`: the run identity is surfaced as the `runId`
103
- // signal (via `onRunIdChange`) and pending interrupts arrive through
104
- // `onInterruptStateChange`, so there is nothing left for it to do — and it
105
- // is not a public option here, matching the other framework packages.
106
82
  onInterruptStateChange: (nextInterruptState, context) => {
107
- interruptState.set(nextInterruptState);
108
83
  options.onInterruptStateChange?.(nextInterruptState, context);
109
84
  },
110
85
  tools: toolsSource?.(),
@@ -115,24 +90,12 @@ function injectChat(options = {}) {
115
90
  ...(options.streamProcessor !== undefined && {
116
91
  streamProcessor: options.streamProcessor,
117
92
  }),
118
- onMessagesChange: (m) => {
119
- messages.set(m);
120
- hasOlderMessages.set(client.getHasOlderMessages());
121
- },
122
- onLoadingChange: (v) => isLoading.set(v),
123
- onStatusChange: (v) => status.set(v),
124
- onErrorChange: (v) => error.set(v),
125
- onSubscriptionChange: (v) => isSubscribed.set(v),
126
- onConnectionStatusChange: (v) => connectionStatus.set(v),
127
- onSessionGeneratingChange: (v) => sessionGenerating.set(v),
128
- onHydratingChange: (v) => isHydrating.set(v),
129
93
  ...(options.queue !== undefined && { queue: options.queue }),
130
- onQueueChange: (nextQueue) => queue.set(nextQueue),
131
94
  });
132
- messages.set(client.getMessages());
133
- interruptState.set(client.getInterruptState());
134
- hasOlderMessages.set(client.getHasOlderMessages());
135
- isHydrating.set(client.getIsHydrating());
95
+ const snapshot = signal(client.getSnapshot(), ...(ngDevMode ? [{ debugName: "snapshot" }] : /* istanbul ignore next */ []));
96
+ const messages = computed(() => snapshot().messages, ...(ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []));
97
+ const interruptState = computed(() => snapshot().interruptState, ...(ngDevMode ? [{ debugName: "interruptState" }] : /* istanbul ignore next */ []));
98
+ const unsubscribeSnapshot = client.subscribeSnapshot(() => snapshot.set(client.getSnapshot()));
136
99
  // START TAILING HERE, not in the constructor. A client is idle until something
137
100
  // attaches it, so a client that gets built and thrown away never opens a
138
101
  // connection — an unreachable stream would hold one of the browser's ~6
@@ -177,6 +140,7 @@ function injectChat(options = {}) {
177
140
  // on reconnect. No client-side auto-resume wiring is needed.
178
141
  }, { injector });
179
142
  destroyRef.onDestroy(() => {
143
+ unsubscribeSnapshot();
180
144
  // Release the connection first: the counterpart of the `attach` above.
181
145
  client.detach();
182
146
  if (liveSource?.()) {
@@ -235,7 +199,6 @@ function injectChat(options = {}) {
235
199
  };
236
200
  const loadOlderMessages = async () => {
237
201
  await client.loadOlderMessages();
238
- hasOlderMessages.set(client.getHasOlderMessages());
239
202
  };
240
203
  const stop = () => client.stop();
241
204
  const clear = () => client.clear();
@@ -263,27 +226,27 @@ function injectChat(options = {}) {
263
226
  const resumeInterruptsUnsafe = (resumeItems, state) => client.resumeInterruptsUnsafe(resumeItems, state);
264
227
  // oxlint-disable-next-line eslint-js/no-restricted-syntax -- return shape diverges from conditional InjectChatResult<TTools, TSchema>; TS can't structurally narrow the TSchema-gated partial/final signals
265
228
  return {
266
- messages: messages.asReadonly(),
229
+ messages,
267
230
  sendMessage,
268
- queue: queue.asReadonly(),
231
+ queue: computed(() => snapshot().queue),
269
232
  cancelQueued,
270
233
  append,
271
234
  reload,
272
235
  stop,
273
- isLoading: isLoading.asReadonly(),
274
- hasOlderMessages: hasOlderMessages.asReadonly(),
236
+ isLoading: computed(() => snapshot().isLoading),
237
+ hasOlderMessages: computed(() => snapshot().hasOlderMessages),
275
238
  loadOlderMessages,
276
- error: error.asReadonly(),
277
- status: status.asReadonly(),
278
- isSubscribed: isSubscribed.asReadonly(),
279
- connectionStatus: connectionStatus.asReadonly(),
280
- sessionGenerating: sessionGenerating.asReadonly(),
281
- isHydrating: isHydrating.asReadonly(),
239
+ error: computed(() => snapshot().error),
240
+ status: computed(() => snapshot().status),
241
+ isSubscribed: computed(() => snapshot().isSubscribed),
242
+ connectionStatus: computed(() => snapshot().connectionStatus),
243
+ sessionGenerating: computed(() => snapshot().sessionGenerating),
244
+ isHydrating: computed(() => snapshot().isHydrating),
282
245
  setMessages,
283
246
  clear,
284
247
  addToolResult,
285
248
  addToolApprovalResponse,
286
- runId: runId.asReadonly(),
249
+ runId: computed(() => snapshot().runId),
287
250
  interrupts,
288
251
  pendingInterrupts,
289
252
  interruptErrors,
@@ -425,26 +388,6 @@ function injectGeneration(options) {
425
388
  if (!disposed)
426
389
  options.onChunk?.(c);
427
390
  },
428
- onResultChange: (r) => {
429
- if (!disposed)
430
- result.set(r);
431
- },
432
- onLoadingChange: (l) => {
433
- if (!disposed)
434
- isLoading.set(l);
435
- },
436
- onErrorChange: (e) => {
437
- if (!disposed)
438
- error.set(e);
439
- },
440
- onStatusChange: (s) => {
441
- if (!disposed)
442
- status.set(s);
443
- },
444
- onResumeStateChange: (rs) => {
445
- if (!disposed)
446
- runId.set(rs?.runId ?? null);
447
- },
448
391
  };
449
392
  const persistenceProps = typeof options.threadId === 'string' && options.persistence
450
393
  ? {
@@ -474,6 +417,16 @@ function injectGeneration(options) {
474
417
  else {
475
418
  throw new Error('injectGeneration requires either a connection or fetcher option');
476
419
  }
420
+ const applySnapshot = () => {
421
+ const next = client.getSnapshot();
422
+ result.set(next.result);
423
+ isLoading.set(next.isLoading);
424
+ error.set(next.error);
425
+ status.set(next.status);
426
+ runId.set(next.runId);
427
+ };
428
+ applySnapshot();
429
+ const unsubscribeSnapshot = client.subscribe(applySnapshot);
477
430
  if (bodySource) {
478
431
  effect(() => {
479
432
  client.updateOptions({
@@ -488,6 +441,7 @@ function injectGeneration(options) {
488
441
  }, { injector });
489
442
  destroyRef.onDestroy(() => {
490
443
  disposed = true;
444
+ unsubscribeSnapshot();
491
445
  client.dispose();
492
446
  });
493
447
  return {
@@ -709,34 +663,6 @@ function injectGenerateVideo(options) {
709
663
  if (!disposed)
710
664
  options.onStatusUpdate?.(s);
711
665
  },
712
- onResultChange: (r) => {
713
- if (!disposed)
714
- result.set(r);
715
- },
716
- onLoadingChange: (l) => {
717
- if (!disposed)
718
- isLoading.set(l);
719
- },
720
- onErrorChange: (e) => {
721
- if (!disposed)
722
- error.set(e);
723
- },
724
- onStatusChange: (s) => {
725
- if (!disposed)
726
- status.set(s);
727
- },
728
- onJobIdChange: (id) => {
729
- if (!disposed)
730
- jobId.set(id);
731
- },
732
- onVideoStatusChange: (s) => {
733
- if (!disposed)
734
- videoStatus.set(s);
735
- },
736
- onResumeStateChange: (rs) => {
737
- if (!disposed)
738
- runId.set(rs?.runId ?? null);
739
- },
740
666
  };
741
667
  let client;
742
668
  if (options.connection) {
@@ -754,6 +680,18 @@ function injectGenerateVideo(options) {
754
680
  else {
755
681
  throw new Error('injectGenerateVideo requires either a connection or fetcher option');
756
682
  }
683
+ const applySnapshot = () => {
684
+ const next = client.getSnapshot();
685
+ result.set(next.result);
686
+ isLoading.set(next.isLoading);
687
+ error.set(next.error);
688
+ status.set(next.status);
689
+ runId.set(next.runId);
690
+ jobId.set(next.jobId);
691
+ videoStatus.set(next.videoStatus);
692
+ };
693
+ applySnapshot();
694
+ const unsubscribeSnapshot = client.subscribe(applySnapshot);
757
695
  if (bodySource) {
758
696
  effect(() => {
759
697
  client.updateOptions({
@@ -768,6 +706,7 @@ function injectGenerateVideo(options) {
768
706
  }, { injector });
769
707
  destroyRef.onDestroy(() => {
770
708
  disposed = true;
709
+ unsubscribeSnapshot();
771
710
  client.dispose();
772
711
  });
773
712
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"tanstack-ai-angular.mjs","sources":["../../src/internal/to-reactive.ts","../../src/inject-chat.ts","../../src/inject-byok.ts","../../src/inject-web-mcp-tools.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-audio-recorder.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 non-reactive fn (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 () => value\n}\n","import { ChatClient } from '@tanstack/ai-client'\nimport { createChatDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { toReactive } from './internal/to-reactive'\nimport type {\n AnyClientTool,\n InterruptDefinition,\n InferSchemaType,\n ModelMessage,\n RunAgentResumeItem,\n SchemaInput,\n StreamChunk,\n} from '@tanstack/ai'\nimport type {\n ChatClientState,\n ResolvableChatInterrupt,\n ChatInterruptState,\n ChatResumeState,\n ConnectionStatus,\n InferredClientContext,\n QueuedMessage,\n SendMessageOptions,\n StructuredOutputPart,\n} from '@tanstack/ai-client'\nimport type {\n DeepPartial,\n InjectChatOptions,\n InjectChatResult,\n MultimodalContent,\n UIMessage,\n} from './types'\n\nconst EMPTY_INTERRUPTS = Object.freeze([])\nconst EMPTY_INTERRUPT_ERRORS = Object.freeze([])\n\nexport function injectChat<\n const TTools extends ReadonlyArray<AnyClientTool> = any,\n TSchema extends SchemaInput | undefined = undefined,\n TContext = InferredClientContext<TTools>,\n const TInterrupts extends ReadonlyArray<\n InterruptDefinition<any, any, any, any>\n > = readonly [],\n>(\n options: InjectChatOptions<\n TTools,\n TSchema,\n TContext,\n TInterrupts\n > = {} as InjectChatOptions<TTools, TSchema, TContext, TInterrupts>,\n): InjectChatResult<TTools, TSchema, TInterrupts> {\n assertInInjectionContext(injectChat)\n\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\n const messages = signal<Array<UIMessage<TTools>>>(\n options.initialMessages || [],\n )\n const isLoading = signal(false)\n const hasOlderMessages = 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 const isHydrating = signal(false)\n const queue = signal<Array<QueuedMessage>>([])\n const runId = signal<string | null>(null)\n const interruptState = signal<ChatInterruptState<TTools, TInterrupts>>({\n interrupts: EMPTY_INTERRUPTS,\n pendingInterrupts: EMPTY_INTERRUPTS,\n interruptErrors: EMPTY_INTERRUPT_ERRORS,\n resuming: false,\n })\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 const toolsSource =\n options.tools !== undefined ? toReactive(options.tools) : undefined\n\n const transport = options.connection\n ? { connection: options.connection }\n : { fetcher: options.fetcher }\n\n const client = new ChatClient<TTools, TContext, TInterrupts>({\n devtoolsBridgeFactory: createChatDevtoolsBridge,\n ...transport,\n ...(options.initialMessages !== undefined && {\n initialMessages: options.initialMessages,\n }),\n ...(typeof options.threadId === 'string' && options.persistence === true\n ? {\n persistence: true,\n threadId: options.threadId,\n ...(options.history !== undefined && {\n history: options.history,\n }),\n }\n : typeof options.threadId === 'string' && options.persistence\n ? {\n persistence: options.persistence,\n threadId: options.threadId,\n }\n : {\n ...(options.threadId !== undefined && {\n threadId: options.threadId,\n }),\n }),\n ...(options.initialResumeSnapshot !== undefined && {\n initialResumeSnapshot: options.initialResumeSnapshot,\n }),\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(forwardedPropsSource !== undefined && {\n forwardedProps: forwardedPropsSource(),\n }),\n ...(options.byok !== undefined && { byok: options.byok }),\n byokProvider: () => options.byokProvider?.(),\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 onRunIdChange: (nextRunId) => runId.set(nextRunId),\n // No `onResumeStateChange`: the run identity is surfaced as the `runId`\n // signal (via `onRunIdChange`) and pending interrupts arrive through\n // `onInterruptStateChange`, so there is nothing left for it to do — and it\n // is not a public option here, matching the other framework packages.\n onInterruptStateChange: (nextInterruptState, context) => {\n interruptState.set(nextInterruptState)\n options.onInterruptStateChange?.(nextInterruptState, context)\n },\n tools: toolsSource?.(),\n ...(options.interrupts !== undefined && {\n interrupts: options.interrupts,\n }),\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>>) => {\n messages.set(m)\n hasOlderMessages.set(client.getHasOlderMessages())\n },\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 onHydratingChange: (v: boolean) => isHydrating.set(v),\n ...(options.queue !== undefined && { queue: options.queue }),\n onQueueChange: (nextQueue: Array<QueuedMessage>) => queue.set(nextQueue),\n })\n\n messages.set(client.getMessages())\n interruptState.set(client.getInterruptState())\n hasOlderMessages.set(client.getHasOlderMessages())\n isHydrating.set(client.getIsHydrating())\n\n // START TAILING HERE, not in the constructor. A client is idle until something\n // attaches it, so a client that gets built and thrown away never opens a\n // connection — an unreachable stream would hold one of the browser's ~6\n // connections per origin until the page reloaded. `inject*` runs in an injection\n // context tied to the consumer's lifetime, and `destroyRef.onDestroy` below is the\n // matching `detach`.\n client.attach()\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 // Sync reactive tools to the client.\n if (toolsSource) {\n effect(() => client.updateOptions({ tools: toolsSource() }), { injector })\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(\n () => {\n client.mountDevtools()\n // Delivery-durability resume is transparent: the resumable SSE\n // connection adapter reattaches via the browser's native Last-Event-ID\n // on reconnect. No client-side auto-resume wiring is needed.\n },\n { injector },\n )\n\n destroyRef.onDestroy(() => {\n // Release the connection first: the counterpart of the `attach` above.\n client.detach()\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 (\n content: string | MultimodalContent,\n sendOptions?: SendMessageOptions,\n ) => {\n await client.sendMessage(content, undefined, sendOptions)\n }\n const cancelQueued = (id: string) => client.cancelQueued(id)\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 loadOlderMessages = async () => {\n await client.loadOlderMessages()\n hasOlderMessages.set(client.getHasOlderMessages())\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 const interrupts = computed(() => interruptState().interrupts)\n const pendingInterrupts = computed(() => interruptState().interrupts)\n const interruptErrors = computed(() => interruptState().interruptErrors)\n const resuming = computed(() => interruptState().resuming)\n const resolveInterrupts = (\n resolution:\n | boolean\n | ((\n interrupt: ResolvableChatInterrupt<TTools, TInterrupts>,\n ) => undefined),\n ) => {\n if (typeof resolution === 'boolean') {\n client.resolveInterrupts(resolution)\n } else {\n client.resolveInterrupts(resolution)\n }\n }\n const cancelInterrupts = () => client.cancelInterrupts()\n const retryInterrupts = () => client.retryInterrupts()\n const resumeInterruptsUnsafe = (\n resumeItems: Array<RunAgentResumeItem>,\n state?: ChatResumeState,\n ) => client.resumeInterruptsUnsafe(resumeItems, state)\n\n // oxlint-disable-next-line eslint-js/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 queue: queue.asReadonly(),\n cancelQueued,\n append,\n reload,\n stop,\n isLoading: isLoading.asReadonly(),\n hasOlderMessages: hasOlderMessages.asReadonly(),\n loadOlderMessages,\n error: error.asReadonly(),\n status: status.asReadonly(),\n isSubscribed: isSubscribed.asReadonly(),\n connectionStatus: connectionStatus.asReadonly(),\n sessionGenerating: sessionGenerating.asReadonly(),\n isHydrating: isHydrating.asReadonly(),\n setMessages,\n clear,\n addToolResult,\n addToolApprovalResponse,\n runId: runId.asReadonly(),\n interrupts,\n pendingInterrupts,\n interruptErrors,\n resuming,\n resolveInterrupts,\n cancelInterrupts,\n retryInterrupts,\n resumeInterruptsUnsafe,\n partial,\n final,\n } as unknown as InjectChatResult<TTools, TSchema, TInterrupts>\n}\n","import {\n DestroyRef,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport type { Signal } from '@angular/core'\nimport type { ByokClient, ByokSnapshot } from '@tanstack/ai-client/byok'\n\nexport function injectByok(client: ByokClient): Signal<ByokSnapshot> {\n assertInInjectionContext(injectByok)\n const destroyRef = inject(DestroyRef)\n const snapshot = signal(client.getSnapshot())\n const unsubscribe = client.subscribe(() => {\n snapshot.set(client.getSnapshot())\n })\n destroyRef.onDestroy(unsubscribe)\n return snapshot.asReadonly()\n}\n","import {\n DestroyRef,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport { registerWebMCPTools, subscribeWebMCPTools } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type {\n AnyClientTool,\n InferredClientContext,\n RegisterWebMCPToolsOptions,\n SubscribeWebMCPToolsOptions,\n} from '@tanstack/ai-client'\n\n/**\n * Options for {@link injectRegisterWebMCPTools}.\n *\n * Context is required when a client tool declares a required runtime context.\n */\nexport type InjectRegisterWebMCPToolsOptions<\n TTools extends ReadonlyArray<AnyClientTool>,\n TContext = InferredClientContext<TTools>,\n> = Omit<RegisterWebMCPToolsOptions<TTools, TContext>, 'signal'> & {\n /** Receives asynchronous WebMCP registration errors. */\n onError?: (error: unknown) => void\n}\n\n/** @deprecated Use `InjectRegisterWebMCPToolsOptions`. Removed in 1.0.0. */\nexport type InjectWebMCPToolsOptions<\n TTools extends ReadonlyArray<AnyClientTool>,\n TContext = InferredClientContext<TTools>,\n> = InjectRegisterWebMCPToolsOptions<TTools, TContext>\n\n/**\n * Registers executable client tools with WebMCP for the current Angular owner.\n *\n * Angular removes the registrations when it destroys the injection owner. Call\n * this function in an injection context, such as a component field initializer.\n *\n * @param tools - The executable client tools to expose through WebMCP.\n * @param options - Runtime context, per-tool options, and error handling.\n *\n * @example\n * ```ts\n * registration = injectRegisterWebMCPTools([statusTool], {\n * onError: (error) => console.error(error),\n * })\n * ```\n */\nexport function injectRegisterWebMCPTools<\n const TTools extends ReadonlyArray<AnyClientTool>,\n TContext = InferredClientContext<TTools>,\n>(\n tools: TTools,\n ...[options]: {} extends InjectRegisterWebMCPToolsOptions<TTools, TContext>\n ? [options?: InjectRegisterWebMCPToolsOptions<TTools, TContext>]\n : [options: InjectRegisterWebMCPToolsOptions<TTools, TContext>]\n) {\n assertInInjectionContext(injectRegisterWebMCPTools)\n const destroyRef = inject(DestroyRef)\n const registrationController = new AbortController()\n const { onError, ...registrationOptions } = options ?? {}\n\n destroyRef.onDestroy(() => registrationController.abort())\n\n void registerWebMCPTools(tools, {\n ...registrationOptions,\n signal: registrationController.signal,\n }).catch((error) => {\n if (!registrationController.signal.aborted) {\n onError?.(error)\n }\n })\n}\n\n/**\n * @deprecated Use `injectRegisterWebMCPTools`. Removed in 1.0.0.\n * @alias\n */\nexport const injectWebMCPTools = injectRegisterWebMCPTools\n\n/** Options for {@link injectPageWebMCPTools}. */\nexport type InjectPageWebMCPToolsOptions = Omit<\n SubscribeWebMCPToolsOptions,\n 'signal'\n>\n\n/**\n * Returns the WebMCP tools on the page as client tools for `injectChat`.\n *\n * The signal starts empty and updates when the page registers or removes a\n * tool. Angular stops the updates when it destroys the injection owner. Call\n * this function in an injection context.\n *\n * @param options - A filter that skips tools, and an error callback.\n *\n * @example\n * ```ts\n * pageTools = injectPageWebMCPTools({\n * filter: (tool) => tool.origin === location.origin,\n * })\n * chat = injectChat({ connection, tools: this.pageTools })\n * ```\n */\nexport function injectPageWebMCPTools(\n options?: InjectPageWebMCPToolsOptions,\n): Signal<Array<AnyClientTool>> {\n assertInInjectionContext(injectPageWebMCPTools)\n const destroyRef = inject(DestroyRef)\n const tools = signal<Array<AnyClientTool>>([])\n const controller = new AbortController()\n\n destroyRef.onDestroy(() => controller.abort())\n\n subscribeWebMCPTools((nextTools) => tools.set(nextTools), {\n signal: controller.signal,\n filter: (tool) => options?.filter?.(tool) ?? true,\n onError: (error) => options?.onError?.(error),\n })\n\n return tools.asReadonly()\n}\n","import { GenerationClient } from '@tanstack/ai-client'\nimport { createGenerationDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n assertInInjectionContext,\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 GenerationPersistenceOptions,\n GenerationRestoredResult,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type { ByokClient } from '@tanstack/ai-client/byok'\nimport type { ProviderId } from '@tanstack/ai/byok'\nimport type { ReactiveOption } from './internal/to-reactive'\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 /** Additional request body params. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */\n byok?: ByokClient\n /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */\n byokProvider?: () => ProviderId | undefined\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * How this generation persists across reloads.\n * - Omit / `false`: ephemeral, in-memory only.\n * - `true`: server-driven — on mount the client hydrates the last generation\n * for its `threadId` from the server (needs a connection with a\n * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.\n */\n persistence?: boolean\n /**\n * The **scope** this generation belongs to: a stable, app-chosen name for the\n * slot successive runs fill — not a link to a chat conversation.\n *\n * The hook starts empty and produces many runs over its life; each gets its\n * own `runId`, but all belong to one scope. Persistence keys on this, so\n * derive it from your own domain and keep it identical across reloads (e.g.\n * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread\n * id on the wire, which the protocol requires.\n *\n * **Required whenever `persistence` is set** — an app that cannot name the\n * scope has nothing to restore to. Optional for ephemeral generations. If\n * omitted, the client mints a wire id after mount.\n */\n threadId?: string\n /**\n * Server-driven hydration handler for `persistence: true` when the\n * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /\n * `rpcStream()` adapter built without handlers) — typically a one-line\n * server-function call. The connection's own handler takes precedence.\n */\n hydrateGeneration?: ConnectConnectionAdapter['hydrateGeneration']\n /**\n * Re-attach handler that replays a run still generating to completion on\n * mount, when the connection doesn't carry one. Without it, a restored\n * `running` snapshot surfaces as an (interrupted) error. The connection's\n * own handler takes precedence.\n */\n joinRun?: ConnectConnectionAdapter['joinRun']\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 * @internal Rebuild a typed result from a restored snapshot, injected by each\n * specialized injectable (image / speech / audio / transcription / summarize).\n * Forwarded to the client so a server-hydrate restore repaints `result`.\n */\n reconstructResult?: (restored: GenerationRestoredResult) => TResult | null\n}\n\n/**\n * Return type for the injectGeneration function.\n *\n * @template TOutput - The output type (after optional transform)\n * @template TInput - The input type accepted by `generate` (defaults to any object)\n */\nexport interface InjectGenerationResult<\n TOutput,\n TInput extends Record<string, any> = Record<string, any>,\n> {\n /** Trigger a generation request */\n generate: (input: TInput) => 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 /** Identity of the in-flight run while one is streaming, or null after it ends */\n /**\n * The id of the generation job currently running, or `null` when nothing is in\n * flight. Each call to `generate` is one job with its own id. Pass it to your\n * own endpoint to cancel or poll the provider job — `stop()` only aborts the\n * local stream, it does not stop work already running on the provider.\n */\n runId: Signal<string | null>\n}\n\n// `TTransformed` infers from the `onResult` return position (a covariant\n// inference site that works even for an optional nested property), which types\n// the callback parameter as `TResult` and narrows `result`. Inferring the\n// whole callback as a defaulted type parameter instead collapses to the\n// default, leaving the parameter `any` — a hard error under `strict`. See\n// issue #848.\nexport function injectGeneration<\n TInput extends Record<string, any>,\n TResult,\n TTransformed = void,\n>(\n options: Omit<\n InjectGenerationOptions<TInput, TResult>,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: TResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerationResult<\n InferGenerationOutputFromReturn<TResult, TTransformed>,\n TInput\n> {\n assertInInjectionContext(injectGeneration)\n\n type TOutput = InferGenerationOutputFromReturn<TResult, TTransformed>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\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 const runId = signal<string | null>(null)\n let disposed = false\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const clientOptions: Omit<\n GenerationClientOptions<TInput, TResult, TOutput>,\n 'persistence' | 'threadId'\n > = {\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.hydrateGeneration !== undefined && {\n hydrateGeneration: options.hydrateGeneration,\n }),\n ...(options.joinRun !== undefined && { joinRun: options.joinRun }),\n ...(options.byok !== undefined && { byok: options.byok }),\n byokProvider: () => options.byokProvider?.(),\n ...(options.reconstructResult\n ? { reconstructResult: options.reconstructResult }\n : {}),\n devtoolsBridgeFactory: createGenerationDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGeneration',\n },\n // The transform's raw return type (`TTransformed`) and the stored output\n // (`TOutput`, with null/void/undefined stripped) are identical at runtime;\n // the cast bridges the relationship that the conditional type hides.\n onResult: ((r: TResult) => options.onResult?.(r)) as (\n result: TResult,\n ) => TOutput | null | void,\n onError: (e: Error) => {\n if (!disposed) options.onError?.(e)\n },\n onProgress: (p: number, m?: string) => {\n if (!disposed) options.onProgress?.(p, m)\n },\n onChunk: (c: StreamChunk) => {\n if (!disposed) options.onChunk?.(c)\n },\n onResultChange: (r: TOutput | null) => {\n if (!disposed) result.set(r)\n },\n onLoadingChange: (l: boolean) => {\n if (!disposed) isLoading.set(l)\n },\n onErrorChange: (e: Error | undefined) => {\n if (!disposed) error.set(e)\n },\n onStatusChange: (s: GenerationClientState) => {\n if (!disposed) status.set(s)\n },\n onResumeStateChange: (rs) => {\n if (!disposed) runId.set(rs?.runId ?? null)\n },\n }\n\n const persistenceProps =\n typeof options.threadId === 'string' && options.persistence\n ? {\n persistence: options.persistence,\n threadId: options.threadId,\n }\n : {\n ...(options.threadId !== undefined && {\n threadId: options.threadId,\n }),\n }\n\n let client: GenerationClient<TInput, TResult, TOutput>\n if (options.connection) {\n client = new GenerationClient({\n ...clientOptions,\n ...persistenceProps,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new GenerationClient({\n ...clientOptions,\n ...persistenceProps,\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({\n body: bodySource(),\n })\n },\n { injector },\n )\n }\n\n // Mount devtools only. Generation runs are never auto-started after render —\n // persisted state is read-only for display.\n afterNextRender(\n () => {\n client.mountDevtools()\n },\n { injector },\n )\n destroyRef.onDestroy(() => {\n disposed = true\n client.dispose()\n })\n\n return {\n generate: (input: TInput) => client.generate(input),\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 runId: runId.asReadonly(),\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructImageResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { ImageGenerationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n ImageGenerateInput,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<\n InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: ImageGenerationResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateImageResult<\n TOutput = ImageGenerationResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\n\nexport function injectGenerateImage<TTransformed = void>(\n options: Omit<\n InjectGenerateImageOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: ImageGenerationResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateImageResult<\n InferGenerationOutputFromReturn<ImageGenerationResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateImage',\n outputKind: 'image' as const,\n }\n const generation = injectGeneration<\n ImageGenerateInput,\n ImageGenerationResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructImageResult,\n })\n return generation\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructAudioResult } from '@tanstack/ai-client'\nimport type { AudioGenerationResult, StreamChunk } from '@tanstack/ai'\nimport type {\n AIDevtoolsDisplayOptions,\n AudioGenerateInput,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { ReactiveOption } from './internal/to-reactive'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\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<\n TOutput = AudioGenerationResult,\n> extends Pick<\n InjectGenerationOptions<AudioGenerateInput, AudioGenerationResult, TOutput>,\n | 'persistence'\n | 'threadId'\n | 'hydrateGeneration'\n | 'joinRun'\n | 'byok'\n | 'byokProvider'\n> {\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 /** 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<\n TOutput = AudioGenerationResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\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<TTransformed = void>(\n options: Omit<\n InjectGenerateAudioOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: AudioGenerationResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateAudioResult<\n InferGenerationOutputFromReturn<AudioGenerationResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateAudio',\n outputKind: 'audio' as const,\n }\n const generation = injectGeneration<\n AudioGenerateInput,\n AudioGenerationResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructAudioResult,\n })\n\n return generation\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructSpeechResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { TTSResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n SpeechGenerateInput,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<\n InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: TTSResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateSpeechResult<TOutput = TTSResult> extends Omit<\n InjectGenerationResult<TOutput>,\n 'generate'\n> {\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}\n\nexport function injectGenerateSpeech<TTransformed = void>(\n options: Omit<\n InjectGenerateSpeechOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: TTSResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateSpeechResult<\n InferGenerationOutputFromReturn<TTSResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateSpeech',\n outputKind: 'audio' as const,\n }\n const generation = injectGeneration<\n SpeechGenerateInput,\n TTSResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructSpeechResult,\n })\n return generation\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructTranscriptionResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { TranscriptionResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n TranscriptionGenerateInput,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<\n InjectGenerationOptions<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TOutput\n >,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: TranscriptionResult) => TOutput | null | void\n}\n\nexport interface InjectTranscriptionResult<\n TOutput = TranscriptionResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\n\nexport function injectTranscription<TTransformed = void>(\n options: Omit<\n InjectTranscriptionOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: TranscriptionResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectTranscriptionResult<\n InferGenerationOutputFromReturn<TranscriptionResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectTranscription',\n outputKind: 'text' as const,\n }\n const generation = injectGeneration<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructTranscriptionResult,\n })\n return generation\n}\n","import {\n DestroyRef,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport { AudioRecorder } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type {\n AudioRecorderOptions,\n AudioRecording,\n InferAudioRecordingOutput,\n} from '@tanstack/ai-client'\n\nexport type InjectAudioRecorderOptions<TOnComplete> = AudioRecorderOptions & {\n /**\n * Optional transform applied to the recording when `stop()` resolves. Its\n * (awaited) return value becomes `recording` and the resolved value of\n * `stop()`. Return nothing to keep the raw `AudioRecording`.\n */\n onComplete?: TOnComplete\n}\n\nexport interface InjectAudioRecorderResult<TOutput> {\n /** Reactive: latest recording (transformed if `onComplete` provided), or null. */\n recording: Signal<TOutput | null>\n /** Reactive: true while actively capturing audio. */\n isRecording: Signal<boolean>\n /** Whether the browser supports recording. */\n isSupported: boolean\n start: () => Promise<void>\n /** Stop and resolve with the completed recording (transformed if `onComplete` provided). */\n stop: () => Promise<TOutput>\n /** Discard the in-progress recording and release the mic. */\n cancel: () => void\n}\n\n/**\n * Angular injectable for recording an audio message. The resolved recording\n * carries `.part` (for `injectChat`'s `sendMessage`) and `.base64` (for the\n * generation injectables). Must be called in an injection context.\n *\n * Errors are delivered via `onError`. `start()` and `stop()` also reject on\n * failure (and `stop()` rejects with `Recording cancelled` if `cancel()` runs\n * while a stop is in flight, e.g. on destroy) — handle one channel, not both.\n */\n// The transforming overload requires `onComplete`. Without that constraint an\n// options object carrying only unrelated keys (`injectAudioRecorder({ onError })`)\n// still matches it, `TOnComplete` infers as `unknown`, and `recording`/`stop()`\n// collapse to `unknown` — so passing any option would silently cost you the\n// `AudioRecording` type. Requiring it here sends those calls to the second\n// overload instead (issue #1001).\nexport function injectAudioRecorder<\n TOnComplete extends (recording: AudioRecording) => unknown,\n>(\n options: InjectAudioRecorderOptions<TOnComplete> & {\n onComplete: TOnComplete\n },\n): InjectAudioRecorderResult<InferAudioRecordingOutput<TOnComplete>>\nexport function injectAudioRecorder(\n options?: InjectAudioRecorderOptions<undefined>,\n): InjectAudioRecorderResult<AudioRecording>\nexport function injectAudioRecorder(\n options: InjectAudioRecorderOptions<\n (recording: AudioRecording) => unknown\n > = {},\n): InjectAudioRecorderResult<unknown> {\n assertInInjectionContext(injectAudioRecorder)\n const destroyRef = inject(DestroyRef)\n const recorder = new AudioRecorder({\n ...(options.audio !== undefined && { audio: options.audio }),\n ...(options.mimeType !== undefined && { mimeType: options.mimeType }),\n ...(options.onError !== undefined && { onError: options.onError }),\n })\n const isRecording = signal(false)\n const recording = signal<unknown>(null)\n\n const unsubscribe = recorder.subscribe((state) => {\n isRecording.set(state === 'recording')\n })\n destroyRef.onDestroy(() => {\n unsubscribe()\n recorder.cancel()\n })\n\n const stop = async (): Promise<unknown> => {\n const rawRecording = await recorder.stop()\n const transformed = await options.onComplete?.(rawRecording)\n // Only `undefined` (returning nothing) keeps the raw recording; a returned\n // null is a real value, matching the inferred output type.\n const output = transformed === undefined ? rawRecording : transformed\n recording.set(output)\n return output\n }\n\n return {\n recording: recording.asReadonly(),\n isRecording: isRecording.asReadonly(),\n isSupported: AudioRecorder.isSupported(),\n start: () => recorder.start(),\n stop,\n cancel: () => recorder.cancel(),\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructSummarizeResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { SummarizationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n SummarizeGenerateInput,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<\n InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: SummarizationResult) => TOutput | null | void\n}\n\nexport interface InjectSummarizeResult<\n TOutput = SummarizationResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\n\nexport function injectSummarize<TTransformed = void>(\n options: Omit<\n InjectSummarizeOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: SummarizationResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectSummarizeResult<\n InferGenerationOutputFromReturn<SummarizationResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectSummarize',\n outputKind: 'text' as const,\n }\n const generation = injectGeneration<\n SummarizeGenerateInput,\n SummarizationResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructSummarizeResult,\n })\n return generation\n}\n","import { VideoGenerationClient } from '@tanstack/ai-client'\nimport { createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n assertInInjectionContext,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { toReactive } from './internal/to-reactive'\nimport type { Signal } from '@angular/core'\nimport type { ReactiveOption } from './internal/to-reactive'\nimport type {\n AIDevtoolsDisplayOptions,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n VideoGenerateInput,\n VideoGenerateResult,\n VideoStatusInfo,\n} from '@tanstack/ai-client'\nimport type { ByokClient } from '@tanstack/ai-client/byok'\nimport type { ProviderId } from '@tanstack/ai/byok'\nimport type { StreamChunk } from '@tanstack/ai'\n\nexport interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {\n connection?: ConnectConnectionAdapter\n fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>\n body?: ReactiveOption<Record<string, any>>\n /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */\n byok?: ByokClient\n /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */\n byokProvider?: () => ProviderId | undefined\n devtools?: AIDevtoolsDisplayOptions\n /**\n * How this generation persists across reloads.\n * - Omit / `false`: ephemeral, in-memory only.\n * - `true`: server-driven — on mount the client hydrates the last generation\n * for its `threadId` from the server (needs a connection with a\n * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.\n */\n persistence?: boolean\n /**\n * The **scope** this generation belongs to: a stable, app-chosen name for the\n * slot successive runs fill — not a link to a chat conversation.\n *\n * The hook starts empty and produces many runs over its life; each gets its\n * own `runId`, but all belong to one scope. Persistence keys on this, so\n * derive it from your own domain and keep it identical across reloads (e.g.\n * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread\n * id on the wire, which the protocol requires.\n *\n * **Required whenever `persistence` is set** — an app that cannot name the\n * scope has nothing to restore to. Optional for ephemeral generations. If\n * omitted, the client mints a wire id after mount.\n */\n threadId?: string\n /**\n * Server-driven hydration handler for `persistence: true` when the\n * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /\n * `rpcStream()` adapter built without handlers) — typically a one-line\n * server-function call. The connection's own handler takes precedence.\n */\n hydrateGeneration?: ConnectConnectionAdapter['hydrateGeneration']\n /**\n * Re-attach handler that replays a run still generating to completion on\n * mount, when the connection doesn't carry one. Without it, a restored\n * `running` snapshot surfaces as an (interrupted) error. The connection's\n * own handler takes precedence.\n */\n joinRun?: ConnectConnectionAdapter['joinRun']\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 * The id of the generation job currently running, or `null` when nothing is in\n * flight. Each call to `generate` is one job with its own id. Pass it to your\n * own endpoint to cancel or poll the provider job — `stop()` only aborts the\n * local stream, it does not stop work already running on the provider.\n */\n runId: Signal<string | null>\n}\n\n// `TTransformed` infers from the `onResult` return position so the callback\n// parameter is typed as `VideoGenerateResult` and `result` narrows to the\n// transform's return. See issue #848.\nexport function injectGenerateVideo<TTransformed = void>(\n options: Omit<\n InjectGenerateVideoOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: VideoGenerateResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateVideoResult<\n InferGenerationOutputFromReturn<VideoGenerateResult, TTransformed>\n> {\n assertInInjectionContext(injectGenerateVideo)\n\n type TOutput = InferGenerationOutputFromReturn<\n VideoGenerateResult,\n TTransformed\n >\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\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 const runId = signal<string | null>(null)\n let disposed = false\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const baseOptions = {\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(typeof options.threadId === 'string' && options.persistence\n ? {\n persistence: options.persistence,\n threadId: options.threadId,\n }\n : {\n ...(options.threadId !== undefined && {\n threadId: options.threadId,\n }),\n }),\n ...(options.hydrateGeneration !== undefined && {\n hydrateGeneration: options.hydrateGeneration,\n }),\n ...(options.joinRun !== undefined && { joinRun: options.joinRun }),\n ...(options.byok !== undefined && { byok: options.byok }),\n byokProvider: () => options.byokProvider?.(),\n devtoolsBridgeFactory: createVideoDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateVideo',\n outputKind: 'video' as const,\n },\n // The transform's raw return type (`TTransformed`) and the stored output\n // (`TOutput`, with null/void/undefined stripped) are identical at runtime;\n // the cast bridges the relationship that the conditional type hides.\n onResult: ((r: VideoGenerateResult) => options.onResult?.(r)) as (\n result: VideoGenerateResult,\n ) => TOutput | null | void,\n onError: (e: Error) => {\n if (!disposed) options.onError?.(e)\n },\n onProgress: (p: number, m?: string) => {\n if (!disposed) options.onProgress?.(p, m)\n },\n onChunk: (c: StreamChunk) => {\n if (!disposed) options.onChunk?.(c)\n },\n onJobCreated: (id: string) => {\n if (!disposed) options.onJobCreated?.(id)\n },\n onStatusUpdate: (s: VideoStatusInfo) => {\n if (!disposed) options.onStatusUpdate?.(s)\n },\n onResultChange: (r: TOutput | null) => {\n if (!disposed) result.set(r)\n },\n onLoadingChange: (l: boolean) => {\n if (!disposed) isLoading.set(l)\n },\n onErrorChange: (e: Error | undefined) => {\n if (!disposed) error.set(e)\n },\n onStatusChange: (s: GenerationClientState) => {\n if (!disposed) status.set(s)\n },\n onJobIdChange: (id: string | null) => {\n if (!disposed) jobId.set(id)\n },\n onVideoStatusChange: (s: VideoStatusInfo | null) => {\n if (!disposed) videoStatus.set(s)\n },\n onResumeStateChange: (rs: { runId: string } | null) => {\n if (!disposed) runId.set(rs?.runId ?? null)\n },\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({\n body: bodySource(),\n })\n },\n { injector },\n )\n }\n\n // Mount devtools only. Generation runs are never auto-started after render —\n // persisted state is read-only for display.\n afterNextRender(\n () => {\n client.mountDevtools()\n },\n { injector },\n )\n destroyRef.onDestroy(() => {\n disposed = true\n client.dispose()\n })\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 runId: runId.asReadonly(),\n }\n}\n","// Chat\nexport { injectChat } from './inject-chat'\nexport { injectByok } from './inject-byok'\n\n// WebMCP Tools\nexport {\n injectPageWebMCPTools,\n injectRegisterWebMCPTools,\n injectWebMCPTools,\n} from './inject-web-mcp-tools'\nexport type {\n InjectPageWebMCPToolsOptions,\n InjectRegisterWebMCPToolsOptions,\n InjectWebMCPToolsOptions,\n} from './inject-web-mcp-tools'\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// Audio Recorder\nexport { injectAudioRecorder } from './inject-audio-recorder'\nexport type {\n InjectAudioRecorderOptions,\n InjectAudioRecorderResult,\n} from './inject-audio-recorder'\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 QueueConfig,\n QueuedMessage,\n QueueOption,\n QueueStrategy,\n SendMessageOptions,\n WhenBusy,\n ReactiveOption,\n} from './types'\n\n// Re-export from @tanstack/ai-client for convenience\nexport {\n AudioRecorder,\n ChatClient,\n InterruptManager,\n RealtimeClient,\n GenerationClient,\n VideoGenerationClient,\n GENERATION_EVENTS,\n reconstructImageResult,\n reconstructAudioResult,\n reconstructSpeechResult,\n reconstructTranscriptionResult,\n reconstructSummarizeResult,\n UnsupportedResponseStreamError,\n createAIDevtoolsGenerationPreview,\n StreamTruncatedError,\n DurableStreamIncompleteError,\n StreamReconnectLimitError,\n uiMessageToModelMessages,\n modelMessageToUIMessage,\n modelMessagesToUIMessages,\n convertMessagesToModelMessages,\n normalizeToUIMessage,\n generateMessageId,\n StreamProcessor,\n ImmediateStrategy,\n PunctuationStrategy,\n BatchStrategy,\n WordBoundaryStrategy,\n CompositeStrategy,\n parsePartialJSON,\n PartialJSONParser,\n defaultJSONParser,\n registerWebMCPTools,\n getWebMCPTools,\n subscribeWebMCPTools,\n type GetWebMCPToolsOptions,\n type SubscribeWebMCPToolsOptions,\n type WebMCPPageTool,\n clientTools,\n createMcpAppBridge,\n type McpAppBridge,\n type CreateMcpAppBridgeOptions,\n fetchServerSentEvents,\n localStoragePersistence,\n sessionStoragePersistence,\n indexedDBPersistence,\n StorageUnavailableError,\n type ChatClientPersistence,\n type ChatPersistedState,\n type ChatPersistenceOption,\n type ChatStorageAdapter,\n type WebStoragePersistenceOptions,\n type IndexedDBPersistenceOptions,\n fetchHttpStream,\n fetchJson,\n xhrServerSentEvents,\n xhrHttpStream,\n stream,\n rpcStream,\n webSocket,\n createChatClientOptions,\n type ConnectionAdapter,\n type ConnectConnectionAdapter,\n type SubscribeConnectionAdapter,\n type RunAgentInputContext,\n type FetchConnectionOptions,\n type FetchJsonOptions,\n type XhrConnectionOptions,\n type WebSocketConnectionOptions,\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":[],"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,MAAM,KAAK;AACpB;;ACgBA,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1C,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAE1C,SAAU,UAAU,CAQxB,OAAA,GAKI,EAA+D,EAAA;IAEnE,wBAAwB,CAAC,UAAU,CAAC;AAKpC,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AACrC,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEjC,MAAM,QAAQ,GAAG,MAAM,CACrB,OAAO,CAAC,eAAe,IAAI,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,UAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAC9B;AACD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,gFAAC;AAC/B,IAAA,MAAM,gBAAgB,G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E;AAC3B,QAAA,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE;AACzB,QAAA,WAAW,EAAE,WAAW,CAAC,UAAU,EAAE;AACrC,QAAA,SAAS,EAAE,SAAS,CAAC,UAAU,EAAE;AACjC,QAAA,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE;AACzB,QAAA,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE;AAC3B,QAAA,IAAI,EAAE,MAAM,MAAM,CAAC,IAAI,EAAE;AACzB,QAAA,KAAK,EAAE,MAAM,MAAM,CAAC,KAAK,EAAE;AAC3B,QAAA,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE;KAC1B;AACH;;ACnQA;;ACAA;;AAEG;;;;"}
1
+ {"version":3,"file":"tanstack-ai-angular.mjs","sources":["../../src/internal/to-reactive.ts","../../src/inject-chat.ts","../../src/inject-byok.ts","../../src/inject-web-mcp-tools.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-audio-recorder.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 non-reactive fn (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 () => value\n}\n","import { ChatClient } from '@tanstack/ai-client'\nimport { createChatDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { toReactive } from './internal/to-reactive'\nimport type {\n AnyClientTool,\n InterruptDefinition,\n InferSchemaType,\n ModelMessage,\n RunAgentResumeItem,\n SchemaInput,\n StreamChunk,\n} from '@tanstack/ai'\nimport type {\n ResolvableChatInterrupt,\n ChatResumeState,\n InferredClientContext,\n SendMessageOptions,\n StructuredOutputPart,\n} from '@tanstack/ai-client'\nimport type {\n DeepPartial,\n InjectChatOptions,\n InjectChatResult,\n MultimodalContent,\n UIMessage,\n} from './types'\n\nexport function injectChat<\n const TTools extends ReadonlyArray<AnyClientTool> = any,\n TSchema extends SchemaInput | undefined = undefined,\n TContext = InferredClientContext<TTools>,\n const TInterrupts extends ReadonlyArray<\n InterruptDefinition<any, any, any, any>\n > = readonly [],\n>(\n options: InjectChatOptions<\n TTools,\n TSchema,\n TContext,\n TInterrupts\n > = {} as InjectChatOptions<TTools, TSchema, TContext, TInterrupts>,\n): InjectChatResult<TTools, TSchema, TInterrupts> {\n assertInInjectionContext(injectChat)\n\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\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 const toolsSource =\n options.tools !== undefined ? toReactive(options.tools) : undefined\n\n const transport = options.connection\n ? { connection: options.connection }\n : { fetcher: options.fetcher }\n\n const client = new ChatClient<TTools, TContext, TInterrupts>({\n devtoolsBridgeFactory: createChatDevtoolsBridge,\n ...transport,\n ...(options.initialMessages !== undefined && {\n initialMessages: options.initialMessages,\n }),\n ...(typeof options.threadId === 'string' && options.persistence === true\n ? {\n persistence: true,\n threadId: options.threadId,\n ...(options.history !== undefined && {\n history: options.history,\n }),\n }\n : typeof options.threadId === 'string' && options.persistence\n ? {\n persistence: options.persistence,\n threadId: options.threadId,\n }\n : {\n ...(options.threadId !== undefined && {\n threadId: options.threadId,\n }),\n }),\n ...(options.initialResumeSnapshot !== undefined && {\n initialResumeSnapshot: options.initialResumeSnapshot,\n }),\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(forwardedPropsSource !== undefined && {\n forwardedProps: forwardedPropsSource(),\n }),\n ...(options.byok !== undefined && { byok: options.byok }),\n byokProvider: () => options.byokProvider?.(),\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 onInterruptStateChange: (nextInterruptState, context) => {\n options.onInterruptStateChange?.(nextInterruptState, context)\n },\n tools: toolsSource?.(),\n ...(options.interrupts !== undefined && {\n interrupts: options.interrupts,\n }),\n onCustomEvent: (eventType, data, context) =>\n options.onCustomEvent?.(eventType, data, context),\n ...(options.streamProcessor !== undefined && {\n streamProcessor: options.streamProcessor,\n }),\n ...(options.queue !== undefined && { queue: options.queue }),\n })\n\n const snapshot = signal(client.getSnapshot())\n const messages = computed(() => snapshot().messages)\n const interruptState = computed(() => snapshot().interruptState)\n const unsubscribeSnapshot = client.subscribeSnapshot(() =>\n snapshot.set(client.getSnapshot()),\n )\n\n // START TAILING HERE, not in the constructor. A client is idle until something\n // attaches it, so a client that gets built and thrown away never opens a\n // connection — an unreachable stream would hold one of the browser's ~6\n // connections per origin until the page reloaded. `inject*` runs in an injection\n // context tied to the consumer's lifetime, and `destroyRef.onDestroy` below is the\n // matching `detach`.\n client.attach()\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 // Sync reactive tools to the client.\n if (toolsSource) {\n effect(() => client.updateOptions({ tools: toolsSource() }), { injector })\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(\n () => {\n client.mountDevtools()\n // Delivery-durability resume is transparent: the resumable SSE\n // connection adapter reattaches via the browser's native Last-Event-ID\n // on reconnect. No client-side auto-resume wiring is needed.\n },\n { injector },\n )\n\n destroyRef.onDestroy(() => {\n unsubscribeSnapshot()\n // Release the connection first: the counterpart of the `attach` above.\n client.detach()\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 (\n content: string | MultimodalContent,\n sendOptions?: SendMessageOptions,\n ) => {\n await client.sendMessage(content, undefined, sendOptions)\n }\n const cancelQueued = (id: string) => client.cancelQueued(id)\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 loadOlderMessages = async () => {\n await client.loadOlderMessages()\n }\n const stop = () => client.stop()\n const clear = () => client.clear()\n const setMessages = (m: ReadonlyArray<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 const interrupts = computed(() => interruptState().interrupts)\n const pendingInterrupts = computed(() => interruptState().interrupts)\n const interruptErrors = computed(() => interruptState().interruptErrors)\n const resuming = computed(() => interruptState().resuming)\n const resolveInterrupts = (\n resolution:\n | boolean\n | ((\n interrupt: ResolvableChatInterrupt<TTools, TInterrupts>,\n ) => undefined),\n ) => {\n if (typeof resolution === 'boolean') {\n client.resolveInterrupts(resolution)\n } else {\n client.resolveInterrupts(resolution)\n }\n }\n const cancelInterrupts = () => client.cancelInterrupts()\n const retryInterrupts = () => client.retryInterrupts()\n const resumeInterruptsUnsafe = (\n resumeItems: Array<RunAgentResumeItem>,\n state?: ChatResumeState,\n ) => client.resumeInterruptsUnsafe(resumeItems, state)\n\n // oxlint-disable-next-line eslint-js/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,\n sendMessage,\n queue: computed(() => snapshot().queue),\n cancelQueued,\n append,\n reload,\n stop,\n isLoading: computed(() => snapshot().isLoading),\n hasOlderMessages: computed(() => snapshot().hasOlderMessages),\n loadOlderMessages,\n error: computed(() => snapshot().error),\n status: computed(() => snapshot().status),\n isSubscribed: computed(() => snapshot().isSubscribed),\n connectionStatus: computed(() => snapshot().connectionStatus),\n sessionGenerating: computed(() => snapshot().sessionGenerating),\n isHydrating: computed(() => snapshot().isHydrating),\n setMessages,\n clear,\n addToolResult,\n addToolApprovalResponse,\n runId: computed(() => snapshot().runId),\n interrupts,\n pendingInterrupts,\n interruptErrors,\n resuming,\n resolveInterrupts,\n cancelInterrupts,\n retryInterrupts,\n resumeInterruptsUnsafe,\n partial,\n final,\n } as unknown as InjectChatResult<TTools, TSchema, TInterrupts>\n}\n","import {\n DestroyRef,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport type { Signal } from '@angular/core'\nimport type { ByokClient, ByokSnapshot } from '@tanstack/ai-client/byok'\n\nexport function injectByok(client: ByokClient): Signal<ByokSnapshot> {\n assertInInjectionContext(injectByok)\n const destroyRef = inject(DestroyRef)\n const snapshot = signal(client.getSnapshot())\n const unsubscribe = client.subscribe(() => {\n snapshot.set(client.getSnapshot())\n })\n destroyRef.onDestroy(unsubscribe)\n return snapshot.asReadonly()\n}\n","import {\n DestroyRef,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport { registerWebMCPTools, subscribeWebMCPTools } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type {\n AnyClientTool,\n InferredClientContext,\n RegisterWebMCPToolsOptions,\n SubscribeWebMCPToolsOptions,\n} from '@tanstack/ai-client'\n\n/**\n * Options for {@link injectRegisterWebMCPTools}.\n *\n * Context is required when a client tool declares a required runtime context.\n */\nexport type InjectRegisterWebMCPToolsOptions<\n TTools extends ReadonlyArray<AnyClientTool>,\n TContext = InferredClientContext<TTools>,\n> = Omit<RegisterWebMCPToolsOptions<TTools, TContext>, 'signal'> & {\n /** Receives asynchronous WebMCP registration errors. */\n onError?: (error: unknown) => void\n}\n\n/** @deprecated Use `InjectRegisterWebMCPToolsOptions`. Removed in 1.0.0. */\nexport type InjectWebMCPToolsOptions<\n TTools extends ReadonlyArray<AnyClientTool>,\n TContext = InferredClientContext<TTools>,\n> = InjectRegisterWebMCPToolsOptions<TTools, TContext>\n\n/**\n * Registers executable client tools with WebMCP for the current Angular owner.\n *\n * Angular removes the registrations when it destroys the injection owner. Call\n * this function in an injection context, such as a component field initializer.\n *\n * @param tools - The executable client tools to expose through WebMCP.\n * @param options - Runtime context, per-tool options, and error handling.\n *\n * @example\n * ```ts\n * registration = injectRegisterWebMCPTools([statusTool], {\n * onError: (error) => console.error(error),\n * })\n * ```\n */\nexport function injectRegisterWebMCPTools<\n const TTools extends ReadonlyArray<AnyClientTool>,\n TContext = InferredClientContext<TTools>,\n>(\n tools: TTools,\n ...[options]: {} extends InjectRegisterWebMCPToolsOptions<TTools, TContext>\n ? [options?: InjectRegisterWebMCPToolsOptions<TTools, TContext>]\n : [options: InjectRegisterWebMCPToolsOptions<TTools, TContext>]\n) {\n assertInInjectionContext(injectRegisterWebMCPTools)\n const destroyRef = inject(DestroyRef)\n const registrationController = new AbortController()\n const { onError, ...registrationOptions } = options ?? {}\n\n destroyRef.onDestroy(() => registrationController.abort())\n\n void registerWebMCPTools(tools, {\n ...registrationOptions,\n signal: registrationController.signal,\n }).catch((error) => {\n if (!registrationController.signal.aborted) {\n onError?.(error)\n }\n })\n}\n\n/**\n * @deprecated Use `injectRegisterWebMCPTools`. Removed in 1.0.0.\n * @alias\n */\nexport const injectWebMCPTools = injectRegisterWebMCPTools\n\n/** Options for {@link injectPageWebMCPTools}. */\nexport type InjectPageWebMCPToolsOptions = Omit<\n SubscribeWebMCPToolsOptions,\n 'signal'\n>\n\n/**\n * Returns the WebMCP tools on the page as client tools for `injectChat`.\n *\n * The signal starts empty and updates when the page registers or removes a\n * tool. Angular stops the updates when it destroys the injection owner. Call\n * this function in an injection context.\n *\n * @param options - A filter that skips tools, and an error callback.\n *\n * @example\n * ```ts\n * pageTools = injectPageWebMCPTools({\n * filter: (tool) => tool.origin === location.origin,\n * })\n * chat = injectChat({ connection, tools: this.pageTools })\n * ```\n */\nexport function injectPageWebMCPTools(\n options?: InjectPageWebMCPToolsOptions,\n): Signal<Array<AnyClientTool>> {\n assertInInjectionContext(injectPageWebMCPTools)\n const destroyRef = inject(DestroyRef)\n const tools = signal<Array<AnyClientTool>>([])\n const controller = new AbortController()\n\n destroyRef.onDestroy(() => controller.abort())\n\n subscribeWebMCPTools((nextTools) => tools.set(nextTools), {\n signal: controller.signal,\n filter: (tool) => options?.filter?.(tool) ?? true,\n onError: (error) => options?.onError?.(error),\n })\n\n return tools.asReadonly()\n}\n","import { GenerationClient } from '@tanstack/ai-client'\nimport { createGenerationDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n assertInInjectionContext,\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 GenerationPersistenceOptions,\n GenerationRestoredResult,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type { ByokClient } from '@tanstack/ai-client/byok'\nimport type { ProviderId } from '@tanstack/ai/byok'\nimport type { ReactiveOption } from './internal/to-reactive'\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 /** Additional request body params. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */\n byok?: ByokClient\n /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */\n byokProvider?: () => ProviderId | undefined\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * How this generation persists across reloads.\n * - Omit / `false`: ephemeral, in-memory only.\n * - `true`: server-driven — on mount the client hydrates the last generation\n * for its `threadId` from the server (needs a connection with a\n * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.\n */\n persistence?: boolean\n /**\n * The **scope** this generation belongs to: a stable, app-chosen name for the\n * slot successive runs fill — not a link to a chat conversation.\n *\n * The hook starts empty and produces many runs over its life; each gets its\n * own `runId`, but all belong to one scope. Persistence keys on this, so\n * derive it from your own domain and keep it identical across reloads (e.g.\n * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread\n * id on the wire, which the protocol requires.\n *\n * **Required whenever `persistence` is set** — an app that cannot name the\n * scope has nothing to restore to. Optional for ephemeral generations. If\n * omitted, the client mints a wire id after mount.\n */\n threadId?: string\n /**\n * Server-driven hydration handler for `persistence: true` when the\n * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /\n * `rpcStream()` adapter built without handlers) — typically a one-line\n * server-function call. The connection's own handler takes precedence.\n */\n hydrateGeneration?: ConnectConnectionAdapter['hydrateGeneration']\n /**\n * Re-attach handler that replays a run still generating to completion on\n * mount, when the connection doesn't carry one. Without it, a restored\n * `running` snapshot surfaces as an (interrupted) error. The connection's\n * own handler takes precedence.\n */\n joinRun?: ConnectConnectionAdapter['joinRun']\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 * @internal Rebuild a typed result from a restored snapshot, injected by each\n * specialized injectable (image / speech / audio / transcription / summarize).\n * Forwarded to the client so a server-hydrate restore repaints `result`.\n */\n reconstructResult?: (restored: GenerationRestoredResult) => TResult | null\n}\n\n/**\n * Return type for the injectGeneration function.\n *\n * @template TOutput - The output type (after optional transform)\n * @template TInput - The input type accepted by `generate` (defaults to any object)\n */\nexport interface InjectGenerationResult<\n TOutput,\n TInput extends Record<string, any> = Record<string, any>,\n> {\n /** Trigger a generation request */\n generate: (input: TInput) => 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 /** Identity of the in-flight run while one is streaming, or null after it ends */\n /**\n * The id of the generation job currently running, or `null` when nothing is in\n * flight. Each call to `generate` is one job with its own id. Pass it to your\n * own endpoint to cancel or poll the provider job — `stop()` only aborts the\n * local stream, it does not stop work already running on the provider.\n */\n runId: Signal<string | null>\n}\n\n// `TTransformed` infers from the `onResult` return position (a covariant\n// inference site that works even for an optional nested property), which types\n// the callback parameter as `TResult` and narrows `result`. Inferring the\n// whole callback as a defaulted type parameter instead collapses to the\n// default, leaving the parameter `any` — a hard error under `strict`. See\n// issue #848.\nexport function injectGeneration<\n TInput extends Record<string, any>,\n TResult,\n TTransformed = void,\n>(\n options: Omit<\n InjectGenerationOptions<TInput, TResult>,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: TResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerationResult<\n InferGenerationOutputFromReturn<TResult, TTransformed>,\n TInput\n> {\n assertInInjectionContext(injectGeneration)\n\n type TOutput = InferGenerationOutputFromReturn<TResult, TTransformed>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\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 const runId = signal<string | null>(null)\n let disposed = false\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const clientOptions: Omit<\n GenerationClientOptions<TInput, TResult, TOutput>,\n 'persistence' | 'threadId'\n > = {\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.hydrateGeneration !== undefined && {\n hydrateGeneration: options.hydrateGeneration,\n }),\n ...(options.joinRun !== undefined && { joinRun: options.joinRun }),\n ...(options.byok !== undefined && { byok: options.byok }),\n byokProvider: () => options.byokProvider?.(),\n ...(options.reconstructResult\n ? { reconstructResult: options.reconstructResult }\n : {}),\n devtoolsBridgeFactory: createGenerationDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGeneration',\n },\n // The transform's raw return type (`TTransformed`) and the stored output\n // (`TOutput`, with null/void/undefined stripped) are identical at runtime;\n // the cast bridges the relationship that the conditional type hides.\n onResult: ((r: TResult) => options.onResult?.(r)) as (\n result: TResult,\n ) => TOutput | null | void,\n onError: (e: Error) => {\n if (!disposed) options.onError?.(e)\n },\n onProgress: (p: number, m?: string) => {\n if (!disposed) options.onProgress?.(p, m)\n },\n onChunk: (c: StreamChunk) => {\n if (!disposed) options.onChunk?.(c)\n },\n }\n\n const persistenceProps =\n typeof options.threadId === 'string' && options.persistence\n ? {\n persistence: options.persistence,\n threadId: options.threadId,\n }\n : {\n ...(options.threadId !== undefined && {\n threadId: options.threadId,\n }),\n }\n\n let client: GenerationClient<TInput, TResult, TOutput>\n if (options.connection) {\n client = new GenerationClient({\n ...clientOptions,\n ...persistenceProps,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new GenerationClient({\n ...clientOptions,\n ...persistenceProps,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGeneration requires either a connection or fetcher option',\n )\n }\n\n const applySnapshot = () => {\n const next = client.getSnapshot()\n result.set(next.result)\n isLoading.set(next.isLoading)\n error.set(next.error)\n status.set(next.status)\n runId.set(next.runId)\n }\n applySnapshot()\n const unsubscribeSnapshot = client.subscribe(applySnapshot)\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({\n body: bodySource(),\n })\n },\n { injector },\n )\n }\n\n // Mount devtools only. Generation runs are never auto-started after render —\n // persisted state is read-only for display.\n afterNextRender(\n () => {\n client.mountDevtools()\n },\n { injector },\n )\n destroyRef.onDestroy(() => {\n disposed = true\n unsubscribeSnapshot()\n client.dispose()\n })\n\n return {\n generate: (input: TInput) => client.generate(input),\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 runId: runId.asReadonly(),\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructImageResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { ImageGenerationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n ImageGenerateInput,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<\n InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: ImageGenerationResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateImageResult<\n TOutput = ImageGenerationResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\n\nexport function injectGenerateImage<TTransformed = void>(\n options: Omit<\n InjectGenerateImageOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: ImageGenerationResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateImageResult<\n InferGenerationOutputFromReturn<ImageGenerationResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateImage',\n outputKind: 'image' as const,\n }\n const generation = injectGeneration<\n ImageGenerateInput,\n ImageGenerationResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructImageResult,\n })\n return generation\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructAudioResult } from '@tanstack/ai-client'\nimport type { AudioGenerationResult, StreamChunk } from '@tanstack/ai'\nimport type {\n AIDevtoolsDisplayOptions,\n AudioGenerateInput,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { ReactiveOption } from './internal/to-reactive'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\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<\n TOutput = AudioGenerationResult,\n> extends Pick<\n InjectGenerationOptions<AudioGenerateInput, AudioGenerationResult, TOutput>,\n | 'persistence'\n | 'threadId'\n | 'hydrateGeneration'\n | 'joinRun'\n | 'byok'\n | 'byokProvider'\n> {\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 /** 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<\n TOutput = AudioGenerationResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\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<TTransformed = void>(\n options: Omit<\n InjectGenerateAudioOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: AudioGenerationResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateAudioResult<\n InferGenerationOutputFromReturn<AudioGenerationResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateAudio',\n outputKind: 'audio' as const,\n }\n const generation = injectGeneration<\n AudioGenerateInput,\n AudioGenerationResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructAudioResult,\n })\n\n return generation\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructSpeechResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { TTSResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n SpeechGenerateInput,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<\n InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: TTSResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateSpeechResult<TOutput = TTSResult> extends Omit<\n InjectGenerationResult<TOutput>,\n 'generate'\n> {\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}\n\nexport function injectGenerateSpeech<TTransformed = void>(\n options: Omit<\n InjectGenerateSpeechOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: TTSResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateSpeechResult<\n InferGenerationOutputFromReturn<TTSResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateSpeech',\n outputKind: 'audio' as const,\n }\n const generation = injectGeneration<\n SpeechGenerateInput,\n TTSResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructSpeechResult,\n })\n return generation\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructTranscriptionResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { TranscriptionResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n TranscriptionGenerateInput,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<\n InjectGenerationOptions<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TOutput\n >,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: TranscriptionResult) => TOutput | null | void\n}\n\nexport interface InjectTranscriptionResult<\n TOutput = TranscriptionResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\n\nexport function injectTranscription<TTransformed = void>(\n options: Omit<\n InjectTranscriptionOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: TranscriptionResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectTranscriptionResult<\n InferGenerationOutputFromReturn<TranscriptionResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectTranscription',\n outputKind: 'text' as const,\n }\n const generation = injectGeneration<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructTranscriptionResult,\n })\n return generation\n}\n","import {\n DestroyRef,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport { AudioRecorder } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type {\n AudioRecorderOptions,\n AudioRecording,\n InferAudioRecordingOutput,\n} from '@tanstack/ai-client'\n\nexport type InjectAudioRecorderOptions<TOnComplete> = AudioRecorderOptions & {\n /**\n * Optional transform applied to the recording when `stop()` resolves. Its\n * (awaited) return value becomes `recording` and the resolved value of\n * `stop()`. Return nothing to keep the raw `AudioRecording`.\n */\n onComplete?: TOnComplete\n}\n\nexport interface InjectAudioRecorderResult<TOutput> {\n /** Reactive: latest recording (transformed if `onComplete` provided), or null. */\n recording: Signal<TOutput | null>\n /** Reactive: true while actively capturing audio. */\n isRecording: Signal<boolean>\n /** Whether the browser supports recording. */\n isSupported: boolean\n start: () => Promise<void>\n /** Stop and resolve with the completed recording (transformed if `onComplete` provided). */\n stop: () => Promise<TOutput>\n /** Discard the in-progress recording and release the mic. */\n cancel: () => void\n}\n\n/**\n * Angular injectable for recording an audio message. The resolved recording\n * carries `.part` (for `injectChat`'s `sendMessage`) and `.base64` (for the\n * generation injectables). Must be called in an injection context.\n *\n * Errors are delivered via `onError`. `start()` and `stop()` also reject on\n * failure (and `stop()` rejects with `Recording cancelled` if `cancel()` runs\n * while a stop is in flight, e.g. on destroy) — handle one channel, not both.\n */\n// The transforming overload requires `onComplete`. Without that constraint an\n// options object carrying only unrelated keys (`injectAudioRecorder({ onError })`)\n// still matches it, `TOnComplete` infers as `unknown`, and `recording`/`stop()`\n// collapse to `unknown` — so passing any option would silently cost you the\n// `AudioRecording` type. Requiring it here sends those calls to the second\n// overload instead (issue #1001).\nexport function injectAudioRecorder<\n TOnComplete extends (recording: AudioRecording) => unknown,\n>(\n options: InjectAudioRecorderOptions<TOnComplete> & {\n onComplete: TOnComplete\n },\n): InjectAudioRecorderResult<InferAudioRecordingOutput<TOnComplete>>\nexport function injectAudioRecorder(\n options?: InjectAudioRecorderOptions<undefined>,\n): InjectAudioRecorderResult<AudioRecording>\nexport function injectAudioRecorder(\n options: InjectAudioRecorderOptions<\n (recording: AudioRecording) => unknown\n > = {},\n): InjectAudioRecorderResult<unknown> {\n assertInInjectionContext(injectAudioRecorder)\n const destroyRef = inject(DestroyRef)\n const recorder = new AudioRecorder({\n ...(options.audio !== undefined && { audio: options.audio }),\n ...(options.mimeType !== undefined && { mimeType: options.mimeType }),\n ...(options.onError !== undefined && { onError: options.onError }),\n })\n const isRecording = signal(false)\n const recording = signal<unknown>(null)\n\n const unsubscribe = recorder.subscribe((state) => {\n isRecording.set(state === 'recording')\n })\n destroyRef.onDestroy(() => {\n unsubscribe()\n recorder.cancel()\n })\n\n const stop = async (): Promise<unknown> => {\n const rawRecording = await recorder.stop()\n const transformed = await options.onComplete?.(rawRecording)\n // Only `undefined` (returning nothing) keeps the raw recording; a returned\n // null is a real value, matching the inferred output type.\n const output = transformed === undefined ? rawRecording : transformed\n recording.set(output)\n return output\n }\n\n return {\n recording: recording.asReadonly(),\n isRecording: isRecording.asReadonly(),\n isSupported: AudioRecorder.isSupported(),\n start: () => recorder.start(),\n stop,\n cancel: () => recorder.cancel(),\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport { reconstructSummarizeResult } from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { SummarizationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n SummarizeGenerateInput,\n} from '@tanstack/ai-client'\nimport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\nexport type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<\n InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>,\n 'onResult' | 'reconstructResult'\n> & {\n onResult?: (result: SummarizationResult) => TOutput | null | void\n}\n\nexport interface InjectSummarizeResult<\n TOutput = SummarizationResult,\n> extends Omit<InjectGenerationResult<TOutput>, 'generate'> {\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}\n\nexport function injectSummarize<TTransformed = void>(\n options: Omit<\n InjectSummarizeOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: SummarizationResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectSummarizeResult<\n InferGenerationOutputFromReturn<SummarizationResult, TTransformed>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectSummarize',\n outputKind: 'text' as const,\n }\n const generation = injectGeneration<\n SummarizeGenerateInput,\n SummarizationResult,\n TTransformed\n >({\n ...options,\n devtools,\n reconstructResult: reconstructSummarizeResult,\n })\n return generation\n}\n","import { VideoGenerationClient } from '@tanstack/ai-client'\nimport { createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n assertInInjectionContext,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { toReactive } from './internal/to-reactive'\nimport type { Signal } from '@angular/core'\nimport type { ReactiveOption } from './internal/to-reactive'\nimport type {\n AIDevtoolsDisplayOptions,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n GenerationPersistenceOptions,\n InferGenerationOutputFromReturn,\n VideoGenerateInput,\n VideoGenerateResult,\n VideoStatusInfo,\n} from '@tanstack/ai-client'\nimport type { ByokClient } from '@tanstack/ai-client/byok'\nimport type { ProviderId } from '@tanstack/ai/byok'\nimport type { StreamChunk } from '@tanstack/ai'\n\nexport interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {\n connection?: ConnectConnectionAdapter\n fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>\n body?: ReactiveOption<Record<string, any>>\n /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */\n byok?: ByokClient\n /** Optional provider id. If it returns a slug, only that key is sent. If no slug resolves (`byokProvider`, then `body.provider`), generate throws. */\n byokProvider?: () => ProviderId | undefined\n devtools?: AIDevtoolsDisplayOptions\n /**\n * How this generation persists across reloads.\n * - Omit / `false`: ephemeral, in-memory only.\n * - `true`: server-driven — on mount the client hydrates the last generation\n * for its `threadId` from the server (needs a connection with a\n * `hydrateGeneration` handler) and repaints it; it never auto-starts a run.\n */\n persistence?: boolean\n /**\n * The **scope** this generation belongs to: a stable, app-chosen name for the\n * slot successive runs fill — not a link to a chat conversation.\n *\n * The hook starts empty and produces many runs over its life; each gets its\n * own `runId`, but all belong to one scope. Persistence keys on this, so\n * derive it from your own domain and keep it identical across reloads (e.g.\n * `` `video-${videoId}-start-frame` ``). It is also sent as the AG-UI thread\n * id on the wire, which the protocol requires.\n *\n * **Required whenever `persistence` is set** — an app that cannot name the\n * scope has nothing to restore to. Optional for ephemeral generations. If\n * omitted, the client mints a wire id after mount.\n */\n threadId?: string\n /**\n * Server-driven hydration handler for `persistence: true` when the\n * connection doesn't carry one (e.g. alongside `fetcher`, or a `stream()` /\n * `rpcStream()` adapter built without handlers) — typically a one-line\n * server-function call. The connection's own handler takes precedence.\n */\n hydrateGeneration?: ConnectConnectionAdapter['hydrateGeneration']\n /**\n * Re-attach handler that replays a run still generating to completion on\n * mount, when the connection doesn't carry one. Without it, a restored\n * `running` snapshot surfaces as an (interrupted) error. The connection's\n * own handler takes precedence.\n */\n joinRun?: ConnectConnectionAdapter['joinRun']\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 * The id of the generation job currently running, or `null` when nothing is in\n * flight. Each call to `generate` is one job with its own id. Pass it to your\n * own endpoint to cancel or poll the provider job — `stop()` only aborts the\n * local stream, it does not stop work already running on the provider.\n */\n runId: Signal<string | null>\n}\n\n// `TTransformed` infers from the `onResult` return position so the callback\n// parameter is typed as `VideoGenerateResult` and `result` narrows to the\n// transform's return. See issue #848.\nexport function injectGenerateVideo<TTransformed = void>(\n options: Omit<\n InjectGenerateVideoOptions,\n 'onResult' | 'persistence' | 'threadId'\n > & {\n onResult?: (result: VideoGenerateResult) => TTransformed\n } & GenerationPersistenceOptions,\n): InjectGenerateVideoResult<\n InferGenerationOutputFromReturn<VideoGenerateResult, TTransformed>\n> {\n assertInInjectionContext(injectGenerateVideo)\n\n type TOutput = InferGenerationOutputFromReturn<\n VideoGenerateResult,\n TTransformed\n >\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\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 const runId = signal<string | null>(null)\n let disposed = false\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const baseOptions = {\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(typeof options.threadId === 'string' && options.persistence\n ? {\n persistence: options.persistence,\n threadId: options.threadId,\n }\n : {\n ...(options.threadId !== undefined && {\n threadId: options.threadId,\n }),\n }),\n ...(options.hydrateGeneration !== undefined && {\n hydrateGeneration: options.hydrateGeneration,\n }),\n ...(options.joinRun !== undefined && { joinRun: options.joinRun }),\n ...(options.byok !== undefined && { byok: options.byok }),\n byokProvider: () => options.byokProvider?.(),\n devtoolsBridgeFactory: createVideoDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateVideo',\n outputKind: 'video' as const,\n },\n // The transform's raw return type (`TTransformed`) and the stored output\n // (`TOutput`, with null/void/undefined stripped) are identical at runtime;\n // the cast bridges the relationship that the conditional type hides.\n onResult: ((r: VideoGenerateResult) => options.onResult?.(r)) as (\n result: VideoGenerateResult,\n ) => TOutput | null | void,\n onError: (e: Error) => {\n if (!disposed) options.onError?.(e)\n },\n onProgress: (p: number, m?: string) => {\n if (!disposed) options.onProgress?.(p, m)\n },\n onChunk: (c: StreamChunk) => {\n if (!disposed) options.onChunk?.(c)\n },\n onJobCreated: (id: string) => {\n if (!disposed) options.onJobCreated?.(id)\n },\n onStatusUpdate: (s: VideoStatusInfo) => {\n if (!disposed) options.onStatusUpdate?.(s)\n },\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 const applySnapshot = () => {\n const next = client.getSnapshot()\n result.set(next.result)\n isLoading.set(next.isLoading)\n error.set(next.error)\n status.set(next.status)\n runId.set(next.runId)\n jobId.set(next.jobId)\n videoStatus.set(next.videoStatus)\n }\n applySnapshot()\n const unsubscribeSnapshot = client.subscribe(applySnapshot)\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({\n body: bodySource(),\n })\n },\n { injector },\n )\n }\n\n // Mount devtools only. Generation runs are never auto-started after render —\n // persisted state is read-only for display.\n afterNextRender(\n () => {\n client.mountDevtools()\n },\n { injector },\n )\n destroyRef.onDestroy(() => {\n disposed = true\n unsubscribeSnapshot()\n client.dispose()\n })\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 runId: runId.asReadonly(),\n }\n}\n","// Chat\nexport { injectChat } from './inject-chat'\nexport { injectByok } from './inject-byok'\n\n// WebMCP Tools\nexport {\n injectPageWebMCPTools,\n injectRegisterWebMCPTools,\n injectWebMCPTools,\n} from './inject-web-mcp-tools'\nexport type {\n InjectPageWebMCPToolsOptions,\n InjectRegisterWebMCPToolsOptions,\n InjectWebMCPToolsOptions,\n} from './inject-web-mcp-tools'\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// Audio Recorder\nexport { injectAudioRecorder } from './inject-audio-recorder'\nexport type {\n InjectAudioRecorderOptions,\n InjectAudioRecorderResult,\n} from './inject-audio-recorder'\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 QueueConfig,\n QueuedMessage,\n QueueOption,\n QueueStrategy,\n SendMessageOptions,\n WhenBusy,\n ReactiveOption,\n} from './types'\n\n// Re-export from @tanstack/ai-client for convenience\nexport {\n AudioRecorder,\n ChatClient,\n InterruptManager,\n RealtimeClient,\n GenerationClient,\n VideoGenerationClient,\n GENERATION_EVENTS,\n reconstructImageResult,\n reconstructAudioResult,\n reconstructSpeechResult,\n reconstructTranscriptionResult,\n reconstructSummarizeResult,\n UnsupportedResponseStreamError,\n createAIDevtoolsGenerationPreview,\n StreamTruncatedError,\n DurableStreamIncompleteError,\n StreamReconnectLimitError,\n uiMessageToModelMessages,\n modelMessageToUIMessage,\n modelMessagesToUIMessages,\n convertMessagesToModelMessages,\n normalizeToUIMessage,\n generateMessageId,\n StreamProcessor,\n ImmediateStrategy,\n PunctuationStrategy,\n BatchStrategy,\n WordBoundaryStrategy,\n CompositeStrategy,\n parsePartialJSON,\n PartialJSONParser,\n defaultJSONParser,\n registerWebMCPTools,\n getWebMCPTools,\n subscribeWebMCPTools,\n type GetWebMCPToolsOptions,\n type SubscribeWebMCPToolsOptions,\n type WebMCPPageTool,\n clientTools,\n createMcpAppBridge,\n type McpAppBridge,\n type CreateMcpAppBridgeOptions,\n fetchServerSentEvents,\n localStoragePersistence,\n sessionStoragePersistence,\n indexedDBPersistence,\n StorageUnavailableError,\n type ChatClientPersistence,\n type ChatPersistedState,\n type ChatPersistenceOption,\n type ChatStorageAdapter,\n type WebStoragePersistenceOptions,\n type IndexedDBPersistenceOptions,\n fetchHttpStream,\n fetchJson,\n xhrServerSentEvents,\n xhrHttpStream,\n stream,\n rpcStream,\n webSocket,\n createChatClientOptions,\n type ConnectionAdapter,\n type ConnectConnectionAdapter,\n type SubscribeConnectionAdapter,\n type RunAgentInputContext,\n type FetchConnectionOptions,\n type FetchJsonOptions,\n type XhrConnectionOptions,\n type WebSocketConnectionOptions,\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":[],"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,MAAM,KAAK;AACpB;;ACYM,SAAU,UAAU,CAQxB,OAAA,GAKI,EAA+D,EAAA;IAEnE,wBAAwB,C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AAM,MAAM,CAAC,KAAK,EAAE;AAC3B,QAAA,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE;KAC1B;AACH;;AC5PA;;ACAA;;AAEG;;;;"}
@@ -57,7 +57,7 @@ type InjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema
57
57
  } : Record<never, never>);
58
58
  interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TData = unknown, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> {
59
59
  /** Current messages in the conversation. */
60
- messages: Signal<Array<UIMessage<TTools, TData>>>;
60
+ messages: Signal<ReadonlyArray<UIMessage<TTools, TData>>>;
61
61
  /**
62
62
  * Send a message (string or multimodal content).
63
63
  * Pass `{ whenBusy }` to override the queue policy for a single send, or
@@ -127,7 +127,7 @@ interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any
127
127
  /** Current error, if any. */
128
128
  error: Signal<Error | undefined>;
129
129
  /** Set messages manually. */
130
- setMessages: (messages: Array<UIMessage<TTools, TData>>) => void;
130
+ setMessages: (messages: ReadonlyArray<UIMessage<TTools, TData>>) => void;
131
131
  /** Clear all messages. */
132
132
  clear: () => void;
133
133
  /** Current generation status. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-angular",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "description": "Angular signals integration for TanStack AI streaming chat, structured outputs, and media generation.",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -54,12 +54,12 @@
54
54
  ],
55
55
  "dependencies": {
56
56
  "tslib": "^2.8.1",
57
- "@tanstack/ai-client": "^0.39.3"
57
+ "@tanstack/ai-client": "^0.40.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@angular/common": ">=21.0.0",
61
61
  "@angular/core": ">=21.0.0",
62
- "@tanstack/ai": "^0.69.0"
62
+ "@tanstack/ai": "^0.70.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@analogjs/vite-plugin-angular": "^2.6.2",
@@ -76,7 +76,7 @@
76
76
  "vitest": "^4.1.10",
77
77
  "zod": "^4.2.0",
78
78
  "zone.js": "^0.15.0",
79
- "@tanstack/ai": "0.69.0"
79
+ "@tanstack/ai": "0.70.0"
80
80
  },
81
81
  "scripts": {
82
82
  "clean": "premove ./build ./dist",
@@ -21,13 +21,9 @@ import type {
21
21
  StreamChunk,
22
22
  } from '@tanstack/ai'
23
23
  import type {
24
- ChatClientState,
25
24
  ResolvableChatInterrupt,
26
- ChatInterruptState,
27
25
  ChatResumeState,
28
- ConnectionStatus,
29
26
  InferredClientContext,
30
- QueuedMessage,
31
27
  SendMessageOptions,
32
28
  StructuredOutputPart,
33
29
  } from '@tanstack/ai-client'
@@ -39,9 +35,6 @@ import type {
39
35
  UIMessage,
40
36
  } from './types'
41
37
 
42
- const EMPTY_INTERRUPTS = Object.freeze([])
43
- const EMPTY_INTERRUPT_ERRORS = Object.freeze([])
44
-
45
38
  export function injectChat<
46
39
  const TTools extends ReadonlyArray<AnyClientTool> = any,
47
40
  TSchema extends SchemaInput | undefined = undefined,
@@ -65,26 +58,6 @@ export function injectChat<
65
58
  const destroyRef = inject(DestroyRef)
66
59
  const injector = inject(Injector)
67
60
 
68
- const messages = signal<Array<UIMessage<TTools>>>(
69
- options.initialMessages || [],
70
- )
71
- const isLoading = signal(false)
72
- const hasOlderMessages = signal(false)
73
- const error = signal<Error | undefined>(undefined)
74
- const status = signal<ChatClientState>('ready')
75
- const isSubscribed = signal(false)
76
- const connectionStatus = signal<ConnectionStatus>('disconnected')
77
- const sessionGenerating = signal(false)
78
- const isHydrating = signal(false)
79
- const queue = signal<Array<QueuedMessage>>([])
80
- const runId = signal<string | null>(null)
81
- const interruptState = signal<ChatInterruptState<TTools, TInterrupts>>({
82
- interrupts: EMPTY_INTERRUPTS,
83
- pendingInterrupts: EMPTY_INTERRUPTS,
84
- interruptErrors: EMPTY_INTERRUPT_ERRORS,
85
- resuming: false,
86
- })
87
-
88
61
  // Reactive option sources. Plain values become constant computeds.
89
62
  const bodySource =
90
63
  options.body !== undefined ? toReactive(options.body) : undefined
@@ -147,13 +120,7 @@ export function injectChat<
147
120
  onChunk: (chunk: StreamChunk) => options.onChunk?.(chunk),
148
121
  onFinish: (message) => options.onFinish?.(message),
149
122
  onError: (err) => options.onError?.(err),
150
- onRunIdChange: (nextRunId) => runId.set(nextRunId),
151
- // No `onResumeStateChange`: the run identity is surfaced as the `runId`
152
- // signal (via `onRunIdChange`) and pending interrupts arrive through
153
- // `onInterruptStateChange`, so there is nothing left for it to do — and it
154
- // is not a public option here, matching the other framework packages.
155
123
  onInterruptStateChange: (nextInterruptState, context) => {
156
- interruptState.set(nextInterruptState)
157
124
  options.onInterruptStateChange?.(nextInterruptState, context)
158
125
  },
159
126
  tools: toolsSource?.(),
@@ -165,25 +132,15 @@ export function injectChat<
165
132
  ...(options.streamProcessor !== undefined && {
166
133
  streamProcessor: options.streamProcessor,
167
134
  }),
168
- onMessagesChange: (m: Array<UIMessage<TTools>>) => {
169
- messages.set(m)
170
- hasOlderMessages.set(client.getHasOlderMessages())
171
- },
172
- onLoadingChange: (v: boolean) => isLoading.set(v),
173
- onStatusChange: (v: ChatClientState) => status.set(v),
174
- onErrorChange: (v: Error | undefined) => error.set(v),
175
- onSubscriptionChange: (v: boolean) => isSubscribed.set(v),
176
- onConnectionStatusChange: (v: ConnectionStatus) => connectionStatus.set(v),
177
- onSessionGeneratingChange: (v: boolean) => sessionGenerating.set(v),
178
- onHydratingChange: (v: boolean) => isHydrating.set(v),
179
135
  ...(options.queue !== undefined && { queue: options.queue }),
180
- onQueueChange: (nextQueue: Array<QueuedMessage>) => queue.set(nextQueue),
181
136
  })
182
137
 
183
- messages.set(client.getMessages())
184
- interruptState.set(client.getInterruptState())
185
- hasOlderMessages.set(client.getHasOlderMessages())
186
- isHydrating.set(client.getIsHydrating())
138
+ const snapshot = signal(client.getSnapshot())
139
+ const messages = computed(() => snapshot().messages)
140
+ const interruptState = computed(() => snapshot().interruptState)
141
+ const unsubscribeSnapshot = client.subscribeSnapshot(() =>
142
+ snapshot.set(client.getSnapshot()),
143
+ )
187
144
 
188
145
  // START TAILING HERE, not in the constructor. A client is idle until something
189
146
  // attaches it, so a client that gets built and thrown away never opens a
@@ -242,6 +199,7 @@ export function injectChat<
242
199
  )
243
200
 
244
201
  destroyRef.onDestroy(() => {
202
+ unsubscribeSnapshot()
245
203
  // Release the connection first: the counterpart of the `attach` above.
246
204
  client.detach()
247
205
  if (liveSource?.()) {
@@ -303,11 +261,10 @@ export function injectChat<
303
261
  }
304
262
  const loadOlderMessages = async () => {
305
263
  await client.loadOlderMessages()
306
- hasOlderMessages.set(client.getHasOlderMessages())
307
264
  }
308
265
  const stop = () => client.stop()
309
266
  const clear = () => client.clear()
310
- const setMessages = (m: Array<UIMessage<TTools>>) =>
267
+ const setMessages = (m: ReadonlyArray<UIMessage<TTools>>) =>
311
268
  client.setMessagesManually(m)
312
269
  const addToolResult = async (result: {
313
270
  toolCallId: string
@@ -350,27 +307,27 @@ export function injectChat<
350
307
 
351
308
  // oxlint-disable-next-line eslint-js/no-restricted-syntax -- return shape diverges from conditional InjectChatResult<TTools, TSchema>; TS can't structurally narrow the TSchema-gated partial/final signals
352
309
  return {
353
- messages: messages.asReadonly(),
310
+ messages,
354
311
  sendMessage,
355
- queue: queue.asReadonly(),
312
+ queue: computed(() => snapshot().queue),
356
313
  cancelQueued,
357
314
  append,
358
315
  reload,
359
316
  stop,
360
- isLoading: isLoading.asReadonly(),
361
- hasOlderMessages: hasOlderMessages.asReadonly(),
317
+ isLoading: computed(() => snapshot().isLoading),
318
+ hasOlderMessages: computed(() => snapshot().hasOlderMessages),
362
319
  loadOlderMessages,
363
- error: error.asReadonly(),
364
- status: status.asReadonly(),
365
- isSubscribed: isSubscribed.asReadonly(),
366
- connectionStatus: connectionStatus.asReadonly(),
367
- sessionGenerating: sessionGenerating.asReadonly(),
368
- isHydrating: isHydrating.asReadonly(),
320
+ error: computed(() => snapshot().error),
321
+ status: computed(() => snapshot().status),
322
+ isSubscribed: computed(() => snapshot().isSubscribed),
323
+ connectionStatus: computed(() => snapshot().connectionStatus),
324
+ sessionGenerating: computed(() => snapshot().sessionGenerating),
325
+ isHydrating: computed(() => snapshot().isHydrating),
369
326
  setMessages,
370
327
  clear,
371
328
  addToolResult,
372
329
  addToolApprovalResponse,
373
- runId: runId.asReadonly(),
330
+ runId: computed(() => snapshot().runId),
374
331
  interrupts,
375
332
  pendingInterrupts,
376
333
  interruptErrors,
@@ -181,27 +181,6 @@ export function injectGenerateVideo<TTransformed = void>(
181
181
  onStatusUpdate: (s: VideoStatusInfo) => {
182
182
  if (!disposed) options.onStatusUpdate?.(s)
183
183
  },
184
- onResultChange: (r: TOutput | null) => {
185
- if (!disposed) result.set(r)
186
- },
187
- onLoadingChange: (l: boolean) => {
188
- if (!disposed) isLoading.set(l)
189
- },
190
- onErrorChange: (e: Error | undefined) => {
191
- if (!disposed) error.set(e)
192
- },
193
- onStatusChange: (s: GenerationClientState) => {
194
- if (!disposed) status.set(s)
195
- },
196
- onJobIdChange: (id: string | null) => {
197
- if (!disposed) jobId.set(id)
198
- },
199
- onVideoStatusChange: (s: VideoStatusInfo | null) => {
200
- if (!disposed) videoStatus.set(s)
201
- },
202
- onResumeStateChange: (rs: { runId: string } | null) => {
203
- if (!disposed) runId.set(rs?.runId ?? null)
204
- },
205
184
  }
206
185
 
207
186
  let client: VideoGenerationClient<TOutput>
@@ -221,6 +200,19 @@ export function injectGenerateVideo<TTransformed = void>(
221
200
  )
222
201
  }
223
202
 
203
+ const applySnapshot = () => {
204
+ const next = client.getSnapshot()
205
+ result.set(next.result)
206
+ isLoading.set(next.isLoading)
207
+ error.set(next.error)
208
+ status.set(next.status)
209
+ runId.set(next.runId)
210
+ jobId.set(next.jobId)
211
+ videoStatus.set(next.videoStatus)
212
+ }
213
+ applySnapshot()
214
+ const unsubscribeSnapshot = client.subscribe(applySnapshot)
215
+
224
216
  if (bodySource) {
225
217
  effect(
226
218
  () => {
@@ -242,6 +234,7 @@ export function injectGenerateVideo<TTransformed = void>(
242
234
  )
243
235
  destroyRef.onDestroy(() => {
244
236
  disposed = true
237
+ unsubscribeSnapshot()
245
238
  client.dispose()
246
239
  })
247
240
 
@@ -205,21 +205,6 @@ export function injectGeneration<
205
205
  onChunk: (c: StreamChunk) => {
206
206
  if (!disposed) options.onChunk?.(c)
207
207
  },
208
- onResultChange: (r: TOutput | null) => {
209
- if (!disposed) result.set(r)
210
- },
211
- onLoadingChange: (l: boolean) => {
212
- if (!disposed) isLoading.set(l)
213
- },
214
- onErrorChange: (e: Error | undefined) => {
215
- if (!disposed) error.set(e)
216
- },
217
- onStatusChange: (s: GenerationClientState) => {
218
- if (!disposed) status.set(s)
219
- },
220
- onResumeStateChange: (rs) => {
221
- if (!disposed) runId.set(rs?.runId ?? null)
222
- },
223
208
  }
224
209
 
225
210
  const persistenceProps =
@@ -253,6 +238,17 @@ export function injectGeneration<
253
238
  )
254
239
  }
255
240
 
241
+ const applySnapshot = () => {
242
+ const next = client.getSnapshot()
243
+ result.set(next.result)
244
+ isLoading.set(next.isLoading)
245
+ error.set(next.error)
246
+ status.set(next.status)
247
+ runId.set(next.runId)
248
+ }
249
+ applySnapshot()
250
+ const unsubscribeSnapshot = client.subscribe(applySnapshot)
251
+
256
252
  if (bodySource) {
257
253
  effect(
258
254
  () => {
@@ -274,6 +270,7 @@ export function injectGeneration<
274
270
  )
275
271
  destroyRef.onDestroy(() => {
276
272
  disposed = true
273
+ unsubscribeSnapshot()
277
274
  client.dispose()
278
275
  })
279
276
 
package/src/types.ts CHANGED
@@ -136,7 +136,7 @@ interface BaseInjectChatResult<
136
136
  readonly [],
137
137
  > {
138
138
  /** Current messages in the conversation. */
139
- messages: Signal<Array<UIMessage<TTools, TData>>>
139
+ messages: Signal<ReadonlyArray<UIMessage<TTools, TData>>>
140
140
  /**
141
141
  * Send a message (string or multimodal content).
142
142
  * Pass `{ whenBusy }` to override the queue policy for a single send, or
@@ -218,7 +218,7 @@ interface BaseInjectChatResult<
218
218
  /** Current error, if any. */
219
219
  error: Signal<Error | undefined>
220
220
  /** Set messages manually. */
221
- setMessages: (messages: Array<UIMessage<TTools, TData>>) => void
221
+ setMessages: (messages: ReadonlyArray<UIMessage<TTools, TData>>) => void
222
222
  /** Clear all messages. */
223
223
  clear: () => void
224
224
  /** Current generation status. */