@tanstack/ai-angular 0.11.3 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { ChatClient, registerWebMCPTools, GenerationClient, reconstructImageResult, reconstructAudioResult, reconstructSpeechResult, reconstructTranscriptionResult, AudioRecorder, reconstructSummarizeResult, VideoGenerationClient } from '@tanstack/ai-client';
2
- export { AudioRecorder, BatchStrategy, ChatClient, CompositeStrategy, DurableStreamIncompleteError, GENERATION_EVENTS, GenerationClient, ImmediateStrategy, InterruptManager, PartialJSONParser, PunctuationStrategy, RealtimeClient, StorageUnavailableError, StreamProcessor, StreamReconnectLimitError, StreamTruncatedError, UnsupportedResponseStreamError, VideoGenerationClient, WordBoundaryStrategy, clientTools, convertMessagesToModelMessages, createAIDevtoolsGenerationPreview, createChatClientOptions, createMcpAppBridge, defaultJSONParser, fetchHttpStream, fetchServerSentEvents, generateMessageId, indexedDBPersistence, localStoragePersistence, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, parsePartialJSON, reconstructAudioResult, reconstructImageResult, reconstructSpeechResult, reconstructSummarizeResult, reconstructTranscriptionResult, registerWebMCPTools, rpcStream, sessionStoragePersistence, stream, uiMessageToModelMessages, webSocket, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
1
+ import { ChatClient, registerWebMCPTools, subscribeWebMCPTools, GenerationClient, reconstructImageResult, reconstructAudioResult, reconstructSpeechResult, reconstructTranscriptionResult, AudioRecorder, reconstructSummarizeResult, VideoGenerationClient } from '@tanstack/ai-client';
2
+ export { AudioRecorder, BatchStrategy, ChatClient, CompositeStrategy, DurableStreamIncompleteError, GENERATION_EVENTS, GenerationClient, ImmediateStrategy, InterruptManager, PartialJSONParser, PunctuationStrategy, RealtimeClient, StorageUnavailableError, StreamProcessor, StreamReconnectLimitError, StreamTruncatedError, UnsupportedResponseStreamError, VideoGenerationClient, WordBoundaryStrategy, clientTools, convertMessagesToModelMessages, createAIDevtoolsGenerationPreview, createChatClientOptions, createMcpAppBridge, defaultJSONParser, fetchHttpStream, fetchServerSentEvents, generateMessageId, getWebMCPTools, indexedDBPersistence, localStoragePersistence, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, parsePartialJSON, reconstructAudioResult, reconstructImageResult, reconstructSpeechResult, reconstructSummarizeResult, reconstructTranscriptionResult, registerWebMCPTools, rpcStream, sessionStoragePersistence, stream, subscribeWebMCPTools, uiMessageToModelMessages, webSocket, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
3
3
  import { createChatDevtoolsBridge, createGenerationDevtoolsBridge, createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools';
4
4
  import { isSignal, computed, assertInInjectionContext, inject, DestroyRef, Injector, signal, effect, afterNextRender } from '@angular/core';
5
5
 
@@ -49,6 +49,7 @@ function injectChat(options = {}) {
49
49
  : undefined;
50
50
  const contextSource = options.context !== undefined ? toReactive(options.context) : undefined;
51
51
  const liveSource = options.live !== undefined ? toReactive(options.live) : undefined;
52
+ const toolsSource = options.tools !== undefined ? toReactive(options.tools) : undefined;
52
53
  const transport = options.connection
53
54
  ? { connection: options.connection }
54
55
  : { fetcher: options.fetcher };
@@ -105,7 +106,7 @@ function injectChat(options = {}) {
105
106
  interruptState.set(nextInterruptState);
106
107
  options.onInterruptStateChange?.(nextInterruptState, context);
107
108
  },
108
- tools: options.tools,
109
+ tools: toolsSource?.(),
109
110
  ...(options.interrupts !== undefined && {
110
111
  interrupts: options.interrupts,
111
112
  }),
@@ -151,6 +152,10 @@ function injectChat(options = {}) {
151
152
  });
152
153
  }, { injector });
153
154
  }
155
+ // Sync reactive tools to the client.
156
+ if (toolsSource) {
157
+ effect(() => client.updateOptions({ tools: toolsSource() }), { injector });
158
+ }
154
159
  // Subscribe / unsubscribe based on reactive `live`.
155
160
  if (liveSource) {
156
161
  effect(() => {
@@ -310,13 +315,13 @@ function injectByok(client) {
310
315
  *
311
316
  * @example
312
317
  * ```ts
313
- * registration = injectWebMCPTools([statusTool], {
318
+ * registration = injectRegisterWebMCPTools([statusTool], {
314
319
  * onError: (error) => console.error(error),
315
320
  * })
316
321
  * ```
317
322
  */
318
- function injectWebMCPTools(tools, ...[options]) {
319
- assertInInjectionContext(injectWebMCPTools);
323
+ function injectRegisterWebMCPTools(tools, ...[options]) {
324
+ assertInInjectionContext(injectRegisterWebMCPTools);
320
325
  const destroyRef = inject(DestroyRef);
321
326
  const registrationController = new AbortController();
322
327
  const { onError, ...registrationOptions } = options ?? {};
@@ -330,6 +335,41 @@ function injectWebMCPTools(tools, ...[options]) {
330
335
  }
331
336
  });
332
337
  }
338
+ /**
339
+ * @deprecated Use `injectRegisterWebMCPTools`. Removed in 1.0.0.
340
+ * @alias
341
+ */
342
+ const injectWebMCPTools = injectRegisterWebMCPTools;
343
+ /**
344
+ * Returns the WebMCP tools on the page as client tools for `injectChat`.
345
+ *
346
+ * The signal starts empty and updates when the page registers or removes a
347
+ * tool. Angular stops the updates when it destroys the injection owner. Call
348
+ * this function in an injection context.
349
+ *
350
+ * @param options - A filter that skips tools, and an error callback.
351
+ *
352
+ * @example
353
+ * ```ts
354
+ * pageTools = injectPageWebMCPTools({
355
+ * filter: (tool) => tool.origin === location.origin,
356
+ * })
357
+ * chat = injectChat({ connection, tools: this.pageTools })
358
+ * ```
359
+ */
360
+ function injectPageWebMCPTools(options) {
361
+ assertInInjectionContext(injectPageWebMCPTools);
362
+ const destroyRef = inject(DestroyRef);
363
+ const tools = signal([], ...(ngDevMode ? [{ debugName: "tools" }] : /* istanbul ignore next */ []));
364
+ const controller = new AbortController();
365
+ destroyRef.onDestroy(() => controller.abort());
366
+ subscribeWebMCPTools((nextTools) => tools.set(nextTools), {
367
+ signal: controller.signal,
368
+ filter: (tool) => options?.filter?.(tool) ?? true,
369
+ onError: (error) => options?.onError?.(error),
370
+ });
371
+ return tools.asReadonly();
372
+ }
333
373
 
334
374
  // `TTransformed` infers from the `onResult` return position (a covariant
335
375
  // inference site that works even for an optional nested property), which types
@@ -746,5 +786,5 @@ function injectGenerateVideo(options) {
746
786
  * Generated bundle index. Do not edit.
747
787
  */
748
788
 
749
- export { injectAudioRecorder, injectByok, injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription, injectWebMCPTools };
789
+ export { injectAudioRecorder, injectByok, injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectPageWebMCPTools, injectRegisterWebMCPTools, injectSummarize, injectTranscription, injectWebMCPTools };
750
790
  //# sourceMappingURL=tanstack-ai-angular.mjs.map
@@ -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 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\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: options.tools,\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 ...(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\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 // 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 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 { DestroyRef, assertInInjectionContext, inject } from '@angular/core'\nimport { registerWebMCPTools } from '@tanstack/ai-client'\nimport type {\n AnyClientTool,\n InferredClientContext,\n RegisterWebMCPToolsOptions,\n} from '@tanstack/ai-client'\n\n/**\n * Options for {@link injectWebMCPTools}.\n *\n * Context is required when a client tool declares a required runtime context.\n */\nexport type InjectWebMCPToolsOptions<\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/**\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 = injectWebMCPTools([statusTool], {\n * onError: (error) => console.error(error),\n * })\n * ```\n */\nexport function injectWebMCPTools<\n const TTools extends ReadonlyArray<AnyClientTool>,\n TContext = InferredClientContext<TTools>,\n>(\n tools: TTools,\n ...[options]: {} extends InjectWebMCPToolsOptions<TTools, TContext>\n ? [options?: InjectWebMCPToolsOptions<TTools, TContext>]\n : [options: InjectWebMCPToolsOptions<TTools, TContext>]\n) {\n assertInInjectionContext(injectWebMCPTools)\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","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 { injectWebMCPTools } from './inject-web-mcp-tools'\nexport type { InjectWebMCPToolsOptions } 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 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 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 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,QAA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AE,CACb;AACD,IAAA,UAAU,CAAC,SAAS,CAAC,MAAK;QACxB,QAAQ,GAAG,IAAI;QACf,MAAM,CAAC,OAAO,EAAE;AAClB,IAAA,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,CAAC,KAAyB,KAAK,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC/D,QAAA,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE;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 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 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 ...(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\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 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 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 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,U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EAAE;AACnB,aAAA,CAAC;AACJ,QAAA,CAAC,EACD,EAAE,QAAQ,EAAE,CACb;IACH;;;IAIA,eAAe,CACb,MAAK;QACH,MAAM,CAAC,aAAa,EAAE;AACxB,IAAA,CAAC,EACD,EAAE,QAAQ,EAAE,CACb;AACD,IAAA,UAAU,CAAC,SAAS,CAAC,MAAK;QACxB,QAAQ,GAAG,IAAI;QACf,MAAM,CAAC,OAAO,EAAE;AAClB,IAAA,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,CAAC,KAAyB,KAAK,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC/D,QAAA,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE;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,6 +1,6 @@
1
1
  import { AnyClientTool, SchemaInput, InterruptDefinition, ModelMessage, RunAgentResumeItem, InferSchemaType, StreamChunk, ImageGenerationResult, AudioGenerationResult, TTSResult, TranscriptionResult, SummarizationResult } from '@tanstack/ai';
2
- import { InferredClientContext, DistributedOmit, ChatClientOptions, AIDevtoolsDisplayOptions, ClientContextOptionFromTools, UIMessage, MultimodalContent, SendMessageOptions, QueuedMessage, BoundInterrupts, ChatInterruptState, ResolvableChatInterrupt, ChatResumeState, ChatClientState, ConnectionStatus, AnyClientTool as AnyClientTool$1, RegisterWebMCPToolsOptions, ConnectConnectionAdapter, GenerationFetcher, GenerationRestoredResult, GenerationClientState, GenerationPersistenceOptions, InferGenerationOutputFromReturn, ImageGenerateInput, AudioGenerateInput, SpeechGenerateInput, TranscriptionGenerateInput, AudioRecorderOptions, AudioRecording, InferAudioRecordingOutput, SummarizeGenerateInput, VideoGenerateResult, VideoGenerateInput, VideoStatusInfo } from '@tanstack/ai-client';
3
- export { AudioGenerateInput, AudioRecorder, BatchStrategy, ChatClient, ChatClientPersistence, ChatPersistedState, ChatPersistenceOption, ChatRequestBody, ChatStorageAdapter, CompositeStrategy, ConnectConnectionAdapter, ConnectionAdapter, CreateMcpAppBridgeOptions, DurableStreamIncompleteError, FetchConnectionOptions, GENERATION_EVENTS, GenerationClient, GenerationClientState, ImageGenerateInput, ImmediateStrategy, IndexedDBPersistenceOptions, InferChatMessages, InterruptManager, McpAppBridge, MultimodalContent, PartialJSONParser, PunctuationStrategy, QueueConfig, QueueOption, QueueStrategy, QueuedMessage, RealtimeClient, RunAgentInputContext, SendMessageOptions, SpeechGenerateInput, StorageUnavailableError, StreamProcessor, StreamReconnectLimitError, StreamTruncatedError, SubscribeConnectionAdapter, SummarizeGenerateInput, TranscriptionGenerateInput, UIMessage, UnsupportedResponseStreamError, VideoGenerateInput, VideoGenerateResult, VideoGenerationClient, VideoStatusInfo, WebSocketConnectionOptions, WebStoragePersistenceOptions, WhenBusy, WordBoundaryStrategy, XhrConnectionOptions, clientTools, convertMessagesToModelMessages, createAIDevtoolsGenerationPreview, createChatClientOptions, createMcpAppBridge, defaultJSONParser, fetchHttpStream, fetchServerSentEvents, generateMessageId, indexedDBPersistence, localStoragePersistence, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, parsePartialJSON, reconstructAudioResult, reconstructImageResult, reconstructSpeechResult, reconstructSummarizeResult, reconstructTranscriptionResult, registerWebMCPTools, rpcStream, sessionStoragePersistence, stream, uiMessageToModelMessages, webSocket, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
2
+ import { InferredClientContext, DistributedOmit, ChatClientOptions, AIDevtoolsDisplayOptions, ClientContextOptionFromTools, UIMessage, MultimodalContent, SendMessageOptions, QueuedMessage, BoundInterrupts, ChatInterruptState, ResolvableChatInterrupt, ChatResumeState, ChatClientState, ConnectionStatus, SubscribeWebMCPToolsOptions, AnyClientTool as AnyClientTool$1, RegisterWebMCPToolsOptions, ConnectConnectionAdapter, GenerationFetcher, GenerationRestoredResult, GenerationClientState, GenerationPersistenceOptions, InferGenerationOutputFromReturn, ImageGenerateInput, AudioGenerateInput, SpeechGenerateInput, TranscriptionGenerateInput, AudioRecorderOptions, AudioRecording, InferAudioRecordingOutput, SummarizeGenerateInput, VideoGenerateResult, VideoGenerateInput, VideoStatusInfo } from '@tanstack/ai-client';
3
+ export { AudioGenerateInput, AudioRecorder, BatchStrategy, ChatClient, ChatClientPersistence, ChatPersistedState, ChatPersistenceOption, ChatRequestBody, ChatStorageAdapter, CompositeStrategy, ConnectConnectionAdapter, ConnectionAdapter, CreateMcpAppBridgeOptions, DurableStreamIncompleteError, FetchConnectionOptions, GENERATION_EVENTS, GenerationClient, GenerationClientState, GetWebMCPToolsOptions, ImageGenerateInput, ImmediateStrategy, IndexedDBPersistenceOptions, InferChatMessages, InterruptManager, McpAppBridge, MultimodalContent, PartialJSONParser, PunctuationStrategy, QueueConfig, QueueOption, QueueStrategy, QueuedMessage, RealtimeClient, RunAgentInputContext, SendMessageOptions, SpeechGenerateInput, StorageUnavailableError, StreamProcessor, StreamReconnectLimitError, StreamTruncatedError, SubscribeConnectionAdapter, SubscribeWebMCPToolsOptions, SummarizeGenerateInput, TranscriptionGenerateInput, UIMessage, UnsupportedResponseStreamError, VideoGenerateInput, VideoGenerateResult, VideoGenerationClient, VideoStatusInfo, WebMCPPageTool, WebSocketConnectionOptions, WebStoragePersistenceOptions, WhenBusy, WordBoundaryStrategy, XhrConnectionOptions, clientTools, convertMessagesToModelMessages, createAIDevtoolsGenerationPreview, createChatClientOptions, createMcpAppBridge, defaultJSONParser, fetchHttpStream, fetchServerSentEvents, generateMessageId, getWebMCPTools, indexedDBPersistence, localStoragePersistence, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, parsePartialJSON, reconstructAudioResult, reconstructImageResult, reconstructSpeechResult, reconstructSummarizeResult, reconstructTranscriptionResult, registerWebMCPTools, rpcStream, sessionStoragePersistence, stream, subscribeWebMCPTools, uiMessageToModelMessages, webSocket, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
4
4
  import { Signal } from '@angular/core';
5
5
  import { ByokClient, ByokSnapshot } from '@tanstack/ai-client/byok';
6
6
  import { ProviderId } from '@tanstack/ai/byok';
@@ -25,12 +25,14 @@ type DeepPartial<T> = T extends ReadonlyArray<infer U> ? Array<DeepPartial<U>> :
25
25
  *
26
26
  * Mirrors the Vue `useChat` options, except:
27
27
  * - State-change callbacks are managed internally and exposed as signals.
28
- * - `body`, `forwardedProps`, and `live` accept a {@link ReactiveOption} so
28
+ * - `tools`, `body`, `forwardedProps`, and `live` accept a {@link ReactiveOption} so
29
29
  * they can be a static value, a `Signal`, or a getter and stay reactive.
30
30
  */
31
- type InjectChatOptions<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> = DistributedOmit<ChatClientOptions<TTools, TContext, TInterrupts>, 'onMessagesChange' | 'onLoadingChange' | 'onErrorChange' | 'onStatusChange' | 'onSubscriptionChange' | 'onConnectionStatusChange' | 'onSessionGeneratingChange' | 'onQueueChange' | 'onResumeStateChange' | 'onRunIdChange' | 'context' | 'devtools' | 'body' | 'forwardedProps'> & {
31
+ type InjectChatOptions<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> = DistributedOmit<ChatClientOptions<TTools, TContext, TInterrupts>, 'onMessagesChange' | 'onLoadingChange' | 'onErrorChange' | 'onStatusChange' | 'onSubscriptionChange' | 'onConnectionStatusChange' | 'onSessionGeneratingChange' | 'onQueueChange' | 'onResumeStateChange' | 'onRunIdChange' | 'context' | 'devtools' | 'body' | 'forwardedProps' | 'tools'> & {
32
32
  /** Display options for TanStack AI Devtools. */
33
33
  devtools?: AIDevtoolsDisplayOptions;
34
+ /** Client-side tools with execution logic. Reactive. */
35
+ tools?: ReactiveOption<TTools>;
34
36
  /** Additional request body params. Reactive. */
35
37
  body?: ReactiveOption<Record<string, any>>;
36
38
  /** Forwarded request props (preferred over `body`). Reactive. */
@@ -143,14 +145,16 @@ declare function injectChat<const TTools extends ReadonlyArray<AnyClientTool> =
143
145
  declare function injectByok(client: ByokClient): Signal<ByokSnapshot>;
144
146
 
145
147
  /**
146
- * Options for {@link injectWebMCPTools}.
148
+ * Options for {@link injectRegisterWebMCPTools}.
147
149
  *
148
150
  * Context is required when a client tool declares a required runtime context.
149
151
  */
150
- type InjectWebMCPToolsOptions<TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>> = Omit<RegisterWebMCPToolsOptions<TTools, TContext>, 'signal'> & {
152
+ type InjectRegisterWebMCPToolsOptions<TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>> = Omit<RegisterWebMCPToolsOptions<TTools, TContext>, 'signal'> & {
151
153
  /** Receives asynchronous WebMCP registration errors. */
152
154
  onError?: (error: unknown) => void;
153
155
  };
156
+ /** @deprecated Use `InjectRegisterWebMCPToolsOptions`. Removed in 1.0.0. */
157
+ type InjectWebMCPToolsOptions<TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>> = InjectRegisterWebMCPToolsOptions<TTools, TContext>;
154
158
  /**
155
159
  * Registers executable client tools with WebMCP for the current Angular owner.
156
160
  *
@@ -162,12 +166,37 @@ type InjectWebMCPToolsOptions<TTools extends ReadonlyArray<AnyClientTool$1>, TCo
162
166
  *
163
167
  * @example
164
168
  * ```ts
165
- * registration = injectWebMCPTools([statusTool], {
169
+ * registration = injectRegisterWebMCPTools([statusTool], {
166
170
  * onError: (error) => console.error(error),
167
171
  * })
168
172
  * ```
169
173
  */
170
- declare function injectWebMCPTools<const TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>>(tools: TTools, ...[options]: {} extends InjectWebMCPToolsOptions<TTools, TContext> ? [options?: InjectWebMCPToolsOptions<TTools, TContext>] : [options: InjectWebMCPToolsOptions<TTools, TContext>]): void;
174
+ declare function injectRegisterWebMCPTools<const TTools extends ReadonlyArray<AnyClientTool$1>, TContext = InferredClientContext<TTools>>(tools: TTools, ...[options]: {} extends InjectRegisterWebMCPToolsOptions<TTools, TContext> ? [options?: InjectRegisterWebMCPToolsOptions<TTools, TContext>] : [options: InjectRegisterWebMCPToolsOptions<TTools, TContext>]): void;
175
+ /**
176
+ * @deprecated Use `injectRegisterWebMCPTools`. Removed in 1.0.0.
177
+ * @alias
178
+ */
179
+ declare const injectWebMCPTools: typeof injectRegisterWebMCPTools;
180
+ /** Options for {@link injectPageWebMCPTools}. */
181
+ type InjectPageWebMCPToolsOptions = Omit<SubscribeWebMCPToolsOptions, 'signal'>;
182
+ /**
183
+ * Returns the WebMCP tools on the page as client tools for `injectChat`.
184
+ *
185
+ * The signal starts empty and updates when the page registers or removes a
186
+ * tool. Angular stops the updates when it destroys the injection owner. Call
187
+ * this function in an injection context.
188
+ *
189
+ * @param options - A filter that skips tools, and an error callback.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * pageTools = injectPageWebMCPTools({
194
+ * filter: (tool) => tool.origin === location.origin,
195
+ * })
196
+ * chat = injectChat({ connection, tools: this.pageTools })
197
+ * ```
198
+ */
199
+ declare function injectPageWebMCPTools(options?: InjectPageWebMCPToolsOptions): Signal<Array<AnyClientTool$1>>;
171
200
 
172
201
  interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
173
202
  /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
@@ -521,5 +550,5 @@ declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGe
521
550
  onResult?: (result: VideoGenerateResult) => TTransformed;
522
551
  } & GenerationPersistenceOptions): InjectGenerateVideoResult<InferGenerationOutputFromReturn<VideoGenerateResult, TTransformed>>;
523
552
 
524
- export { injectAudioRecorder, injectByok, injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription, injectWebMCPTools };
525
- export type { DeepPartial, InjectAudioRecorderOptions, InjectAudioRecorderResult, InjectChatOptions, InjectChatResult, InjectGenerateAudioOptions, InjectGenerateAudioResult, InjectGenerateImageOptions, InjectGenerateImageResult, InjectGenerateSpeechOptions, InjectGenerateSpeechResult, InjectGenerateVideoOptions, InjectGenerateVideoResult, InjectGenerationOptions, InjectGenerationResult, InjectSummarizeOptions, InjectSummarizeResult, InjectTranscriptionOptions, InjectTranscriptionResult, InjectWebMCPToolsOptions, ReactiveOption };
553
+ export { injectAudioRecorder, injectByok, injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectPageWebMCPTools, injectRegisterWebMCPTools, injectSummarize, injectTranscription, injectWebMCPTools };
554
+ export type { DeepPartial, InjectAudioRecorderOptions, InjectAudioRecorderResult, InjectChatOptions, InjectChatResult, InjectGenerateAudioOptions, InjectGenerateAudioResult, InjectGenerateImageOptions, InjectGenerateImageResult, InjectGenerateSpeechOptions, InjectGenerateSpeechResult, InjectGenerateVideoOptions, InjectGenerateVideoResult, InjectGenerationOptions, InjectGenerationResult, InjectPageWebMCPToolsOptions, InjectRegisterWebMCPToolsOptions, InjectSummarizeOptions, InjectSummarizeResult, InjectTranscriptionOptions, InjectTranscriptionResult, InjectWebMCPToolsOptions, ReactiveOption };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-angular",
3
- "version": "0.11.3",
3
+ "version": "0.12.1",
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.33.2"
57
+ "@tanstack/ai-client": "^0.35.1"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@angular/common": ">=21.0.0",
61
61
  "@angular/core": ">=21.0.0",
62
- "@tanstack/ai": "^0.58.0"
62
+ "@tanstack/ai": "^0.61.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.58.0"
79
+ "@tanstack/ai": "0.61.0"
80
80
  },
81
81
  "scripts": {
82
82
  "clean": "premove ./build ./dist",
package/src/index.ts CHANGED
@@ -3,8 +3,16 @@ export { injectChat } from './inject-chat'
3
3
  export { injectByok } from './inject-byok'
4
4
 
5
5
  // WebMCP Tools
6
- export { injectWebMCPTools } from './inject-web-mcp-tools'
7
- export type { InjectWebMCPToolsOptions } from './inject-web-mcp-tools'
6
+ export {
7
+ injectPageWebMCPTools,
8
+ injectRegisterWebMCPTools,
9
+ injectWebMCPTools,
10
+ } from './inject-web-mcp-tools'
11
+ export type {
12
+ InjectPageWebMCPToolsOptions,
13
+ InjectRegisterWebMCPToolsOptions,
14
+ InjectWebMCPToolsOptions,
15
+ } from './inject-web-mcp-tools'
8
16
 
9
17
  // Generation
10
18
  export { injectGeneration } from './inject-generation'
@@ -114,6 +122,11 @@ export {
114
122
  PartialJSONParser,
115
123
  defaultJSONParser,
116
124
  registerWebMCPTools,
125
+ getWebMCPTools,
126
+ subscribeWebMCPTools,
127
+ type GetWebMCPToolsOptions,
128
+ type SubscribeWebMCPToolsOptions,
129
+ type WebMCPPageTool,
117
130
  clientTools,
118
131
  createMcpAppBridge,
119
132
  type McpAppBridge,
@@ -95,6 +95,8 @@ export function injectChat<
95
95
  options.context !== undefined ? toReactive(options.context) : undefined
96
96
  const liveSource =
97
97
  options.live !== undefined ? toReactive(options.live) : undefined
98
+ const toolsSource =
99
+ options.tools !== undefined ? toReactive(options.tools) : undefined
98
100
 
99
101
  const transport = options.connection
100
102
  ? { connection: options.connection }
@@ -153,7 +155,7 @@ export function injectChat<
153
155
  interruptState.set(nextInterruptState)
154
156
  options.onInterruptStateChange?.(nextInterruptState, context)
155
157
  },
156
- tools: options.tools,
158
+ tools: toolsSource?.(),
157
159
  ...(options.interrupts !== undefined && {
158
160
  interrupts: options.interrupts,
159
161
  }),
@@ -207,6 +209,11 @@ export function injectChat<
207
209
  )
208
210
  }
209
211
 
212
+ // Sync reactive tools to the client.
213
+ if (toolsSource) {
214
+ effect(() => client.updateOptions({ tools: toolsSource() }), { injector })
215
+ }
216
+
210
217
  // Subscribe / unsubscribe based on reactive `live`.
211
218
  if (liveSource) {
212
219
  effect(
@@ -1,17 +1,24 @@
1
- import { DestroyRef, assertInInjectionContext, inject } from '@angular/core'
2
- import { registerWebMCPTools } from '@tanstack/ai-client'
1
+ import {
2
+ DestroyRef,
3
+ assertInInjectionContext,
4
+ inject,
5
+ signal,
6
+ } from '@angular/core'
7
+ import { registerWebMCPTools, subscribeWebMCPTools } from '@tanstack/ai-client'
8
+ import type { Signal } from '@angular/core'
3
9
  import type {
4
10
  AnyClientTool,
5
11
  InferredClientContext,
6
12
  RegisterWebMCPToolsOptions,
13
+ SubscribeWebMCPToolsOptions,
7
14
  } from '@tanstack/ai-client'
8
15
 
9
16
  /**
10
- * Options for {@link injectWebMCPTools}.
17
+ * Options for {@link injectRegisterWebMCPTools}.
11
18
  *
12
19
  * Context is required when a client tool declares a required runtime context.
13
20
  */
14
- export type InjectWebMCPToolsOptions<
21
+ export type InjectRegisterWebMCPToolsOptions<
15
22
  TTools extends ReadonlyArray<AnyClientTool>,
16
23
  TContext = InferredClientContext<TTools>,
17
24
  > = Omit<RegisterWebMCPToolsOptions<TTools, TContext>, 'signal'> & {
@@ -19,6 +26,12 @@ export type InjectWebMCPToolsOptions<
19
26
  onError?: (error: unknown) => void
20
27
  }
21
28
 
29
+ /** @deprecated Use `InjectRegisterWebMCPToolsOptions`. Removed in 1.0.0. */
30
+ export type InjectWebMCPToolsOptions<
31
+ TTools extends ReadonlyArray<AnyClientTool>,
32
+ TContext = InferredClientContext<TTools>,
33
+ > = InjectRegisterWebMCPToolsOptions<TTools, TContext>
34
+
22
35
  /**
23
36
  * Registers executable client tools with WebMCP for the current Angular owner.
24
37
  *
@@ -30,21 +43,21 @@ export type InjectWebMCPToolsOptions<
30
43
  *
31
44
  * @example
32
45
  * ```ts
33
- * registration = injectWebMCPTools([statusTool], {
46
+ * registration = injectRegisterWebMCPTools([statusTool], {
34
47
  * onError: (error) => console.error(error),
35
48
  * })
36
49
  * ```
37
50
  */
38
- export function injectWebMCPTools<
51
+ export function injectRegisterWebMCPTools<
39
52
  const TTools extends ReadonlyArray<AnyClientTool>,
40
53
  TContext = InferredClientContext<TTools>,
41
54
  >(
42
55
  tools: TTools,
43
- ...[options]: {} extends InjectWebMCPToolsOptions<TTools, TContext>
44
- ? [options?: InjectWebMCPToolsOptions<TTools, TContext>]
45
- : [options: InjectWebMCPToolsOptions<TTools, TContext>]
56
+ ...[options]: {} extends InjectRegisterWebMCPToolsOptions<TTools, TContext>
57
+ ? [options?: InjectRegisterWebMCPToolsOptions<TTools, TContext>]
58
+ : [options: InjectRegisterWebMCPToolsOptions<TTools, TContext>]
46
59
  ) {
47
- assertInInjectionContext(injectWebMCPTools)
60
+ assertInInjectionContext(injectRegisterWebMCPTools)
48
61
  const destroyRef = inject(DestroyRef)
49
62
  const registrationController = new AbortController()
50
63
  const { onError, ...registrationOptions } = options ?? {}
@@ -60,3 +73,51 @@ export function injectWebMCPTools<
60
73
  }
61
74
  })
62
75
  }
76
+
77
+ /**
78
+ * @deprecated Use `injectRegisterWebMCPTools`. Removed in 1.0.0.
79
+ * @alias
80
+ */
81
+ export const injectWebMCPTools = injectRegisterWebMCPTools
82
+
83
+ /** Options for {@link injectPageWebMCPTools}. */
84
+ export type InjectPageWebMCPToolsOptions = Omit<
85
+ SubscribeWebMCPToolsOptions,
86
+ 'signal'
87
+ >
88
+
89
+ /**
90
+ * Returns the WebMCP tools on the page as client tools for `injectChat`.
91
+ *
92
+ * The signal starts empty and updates when the page registers or removes a
93
+ * tool. Angular stops the updates when it destroys the injection owner. Call
94
+ * this function in an injection context.
95
+ *
96
+ * @param options - A filter that skips tools, and an error callback.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * pageTools = injectPageWebMCPTools({
101
+ * filter: (tool) => tool.origin === location.origin,
102
+ * })
103
+ * chat = injectChat({ connection, tools: this.pageTools })
104
+ * ```
105
+ */
106
+ export function injectPageWebMCPTools(
107
+ options?: InjectPageWebMCPToolsOptions,
108
+ ): Signal<Array<AnyClientTool>> {
109
+ assertInInjectionContext(injectPageWebMCPTools)
110
+ const destroyRef = inject(DestroyRef)
111
+ const tools = signal<Array<AnyClientTool>>([])
112
+ const controller = new AbortController()
113
+
114
+ destroyRef.onDestroy(() => controller.abort())
115
+
116
+ subscribeWebMCPTools((nextTools) => tools.set(nextTools), {
117
+ signal: controller.signal,
118
+ filter: (tool) => options?.filter?.(tool) ?? true,
119
+ onError: (error) => options?.onError?.(error),
120
+ })
121
+
122
+ return tools.asReadonly()
123
+ }
package/src/types.ts CHANGED
@@ -61,7 +61,7 @@ export type DeepPartial<T> =
61
61
  *
62
62
  * Mirrors the Vue `useChat` options, except:
63
63
  * - State-change callbacks are managed internally and exposed as signals.
64
- * - `body`, `forwardedProps`, and `live` accept a {@link ReactiveOption} so
64
+ * - `tools`, `body`, `forwardedProps`, and `live` accept a {@link ReactiveOption} so
65
65
  * they can be a static value, a `Signal`, or a getter and stay reactive.
66
66
  */
67
67
  export type InjectChatOptions<
@@ -86,9 +86,12 @@ export type InjectChatOptions<
86
86
  | 'devtools'
87
87
  | 'body'
88
88
  | 'forwardedProps'
89
+ | 'tools'
89
90
  > & {
90
91
  /** Display options for TanStack AI Devtools. */
91
92
  devtools?: AIDevtoolsDisplayOptions
93
+ /** Client-side tools with execution logic. Reactive. */
94
+ tools?: ReactiveOption<TTools>
92
95
  /** Additional request body params. Reactive. */
93
96
  body?: ReactiveOption<Record<string, any>>
94
97
  /** Forwarded request props (preferred over `body`). Reactive. */