@tanstack/ai-angular 0.4.3 → 0.6.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
1
  import { ChatClient, GenerationClient, reconstructImageResult, reconstructAudioResult, reconstructSpeechResult, reconstructTranscriptionResult, AudioRecorder, reconstructSummarizeResult, VideoGenerationClient } from '@tanstack/ai-client';
2
- export { StorageUnavailableError, createChatClientOptions, fetchHttpStream, fetchServerSentEvents, indexedDBPersistence, localStoragePersistence, rpcStream, sessionStoragePersistence, stream, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
2
+ export { StorageUnavailableError, createChatClientOptions, fetchHttpStream, fetchServerSentEvents, indexedDBPersistence, localStoragePersistence, rpcStream, sessionStoragePersistence, stream, 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
 
@@ -22,12 +22,10 @@ function toReactive(value) {
22
22
 
23
23
  const EMPTY_INTERRUPTS = Object.freeze([]);
24
24
  const EMPTY_INTERRUPT_ERRORS = Object.freeze([]);
25
- let nextId$2 = 0;
26
25
  function injectChat(options = {}) {
27
26
  assertInInjectionContext(injectChat);
28
27
  const destroyRef = inject(DestroyRef);
29
28
  const injector = inject(Injector);
30
- const clientId = options.id || `injectChat-${nextId$2++}`;
31
29
  const messages = signal(options.initialMessages || [], ...(ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []));
32
30
  const isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
33
31
  const error = signal(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
@@ -56,18 +54,21 @@ function injectChat(options = {}) {
56
54
  const client = new ChatClient({
57
55
  devtoolsBridgeFactory: createChatDevtoolsBridge,
58
56
  ...transport,
59
- id: clientId,
60
57
  ...(options.initialMessages !== undefined && {
61
58
  initialMessages: options.initialMessages,
62
59
  }),
63
- ...(options.persistence !== undefined && {
64
- persistence: options.persistence,
65
- }),
60
+ ...(typeof options.threadId === 'string' && options.persistence
61
+ ? {
62
+ persistence: options.persistence,
63
+ threadId: options.threadId,
64
+ }
65
+ : {
66
+ ...(options.threadId !== undefined && { threadId: options.threadId }),
67
+ }),
66
68
  ...(options.initialResumeSnapshot !== undefined && {
67
69
  initialResumeSnapshot: options.initialResumeSnapshot,
68
70
  }),
69
71
  ...(bodySource !== undefined && { body: bodySource() }),
70
- ...(options.threadId !== undefined && { threadId: options.threadId }),
71
72
  ...(forwardedPropsSource !== undefined && {
72
73
  forwardedProps: forwardedPropsSource(),
73
74
  }),
@@ -87,11 +88,14 @@ function injectChat(options = {}) {
87
88
  // signal (via `onRunIdChange`) and pending interrupts arrive through
88
89
  // `onInterruptStateChange`, so there is nothing left for it to do — and it
89
90
  // is not a public option here, matching the other framework packages.
90
- onInterruptStateChange: (nextInterruptState) => {
91
+ onInterruptStateChange: (nextInterruptState, context) => {
91
92
  interruptState.set(nextInterruptState);
92
- options.onInterruptStateChange?.(nextInterruptState);
93
+ options.onInterruptStateChange?.(nextInterruptState, context);
93
94
  },
94
95
  tools: options.tools,
96
+ ...(options.interrupts !== undefined && {
97
+ interrupts: options.interrupts,
98
+ }),
95
99
  onCustomEvent: (eventType, data, context) => options.onCustomEvent?.(eventType, data, context),
96
100
  ...(options.streamProcessor !== undefined && {
97
101
  streamProcessor: options.streamProcessor,
@@ -261,7 +265,6 @@ function injectChat(options = {}) {
261
265
  };
262
266
  }
263
267
 
264
- let nextId$1 = 0;
265
268
  // `TTransformed` infers from the `onResult` return position (a covariant
266
269
  // inference site that works even for an optional nested property), which types
267
270
  // the callback parameter as `TResult` and narrows `result`. Inferring the
@@ -279,15 +282,8 @@ function injectGeneration(options) {
279
282
  const runId = signal(null, ...(ngDevMode ? [{ debugName: "runId" }] : /* istanbul ignore next */ []));
280
283
  let disposed = false;
281
284
  const bodySource = options.body !== undefined ? toReactive(options.body) : undefined;
282
- // Identity: pass `threadId` alone when set (never also pass deprecated `id`).
283
285
  const clientOptions = {
284
286
  ...(bodySource !== undefined && { body: bodySource() }),
285
- ...(options.threadId !== undefined
286
- ? { threadId: options.threadId }
287
- : { id: options.id ?? `injectGeneration-${nextId$1++}` }),
288
- ...(options.persistence !== undefined && {
289
- persistence: options.persistence,
290
- }),
291
287
  ...(options.hydrateGeneration !== undefined && {
292
288
  hydrateGeneration: options.hydrateGeneration,
293
289
  }),
@@ -338,16 +334,28 @@ function injectGeneration(options) {
338
334
  runId.set(rs?.runId ?? null);
339
335
  },
340
336
  };
337
+ const persistenceProps = typeof options.threadId === 'string' && options.persistence
338
+ ? {
339
+ persistence: options.persistence,
340
+ threadId: options.threadId,
341
+ }
342
+ : {
343
+ ...(options.threadId !== undefined && {
344
+ threadId: options.threadId,
345
+ }),
346
+ };
341
347
  let client;
342
348
  if (options.connection) {
343
349
  client = new GenerationClient({
344
350
  ...clientOptions,
351
+ ...persistenceProps,
345
352
  connection: options.connection,
346
353
  });
347
354
  }
348
355
  else if (options.fetcher) {
349
356
  client = new GenerationClient({
350
357
  ...clientOptions,
358
+ ...persistenceProps,
351
359
  fetcher: options.fetcher,
352
360
  });
353
361
  }
@@ -524,7 +532,6 @@ function injectSummarize(options) {
524
532
  return generation;
525
533
  }
526
534
 
527
- let nextId = 0;
528
535
  // `TTransformed` infers from the `onResult` return position so the callback
529
536
  // parameter is typed as `VideoGenerateResult` and `result` narrows to the
530
537
  // transform's return. See issue #848.
@@ -541,15 +548,18 @@ function injectGenerateVideo(options) {
541
548
  const runId = signal(null, ...(ngDevMode ? [{ debugName: "runId" }] : /* istanbul ignore next */ []));
542
549
  let disposed = false;
543
550
  const bodySource = options.body !== undefined ? toReactive(options.body) : undefined;
544
- // Identity: pass `threadId` alone when set (never also pass deprecated `id`).
545
551
  const baseOptions = {
546
552
  ...(bodySource !== undefined && { body: bodySource() }),
547
- ...(options.threadId !== undefined
548
- ? { threadId: options.threadId }
549
- : { id: options.id ?? `injectGenerateVideo-${nextId++}` }),
550
- ...(options.persistence !== undefined && {
551
- persistence: options.persistence,
552
- }),
553
+ ...(typeof options.threadId === 'string' && options.persistence
554
+ ? {
555
+ persistence: options.persistence,
556
+ threadId: options.threadId,
557
+ }
558
+ : {
559
+ ...(options.threadId !== undefined && {
560
+ threadId: options.threadId,
561
+ }),
562
+ }),
553
563
  ...(options.hydrateGeneration !== undefined && {
554
564
  hydrateGeneration: options.hydrateGeneration,
555
565
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"tanstack-ai-angular.mjs","sources":["../../src/internal/to-reactive.ts","../../src/inject-chat.ts","../../src/inject-generation.ts","../../src/inject-generate-image.ts","../../src/inject-generate-audio.ts","../../src/inject-generate-speech.ts","../../src/inject-transcription.ts","../../src/inject-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 InferSchemaType,\n ModelMessage,\n RunAgentResumeItem,\n SchemaInput,\n StreamChunk,\n} from '@tanstack/ai'\nimport type {\n ChatClientState,\n ChatInterrupt,\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\nlet nextId = 0\n\nexport function injectChat<\n const TTools extends ReadonlyArray<AnyClientTool> = any,\n TSchema extends SchemaInput | undefined = undefined,\n TContext = InferredClientContext<TTools>,\n>(\n options: InjectChatOptions<\n TTools,\n TSchema,\n TContext\n > = {} as InjectChatOptions<TTools, TSchema, TContext>,\n): InjectChatResult<TTools, TSchema> {\n 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 const clientId = options.id || `injectChat-${nextId++}`\n\n const messages = signal<Array<UIMessage<TTools>>>(\n options.initialMessages || [],\n )\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<ChatClientState>('ready')\n const isSubscribed = signal(false)\n const connectionStatus = signal<ConnectionStatus>('disconnected')\n const sessionGenerating = signal(false)\n const queue = signal<Array<QueuedMessage>>([])\n const runId = signal<string | null>(null)\n const interruptState = signal<ChatInterruptState<TTools>>({\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>({\n devtoolsBridgeFactory: createChatDevtoolsBridge,\n ...transport,\n id: clientId,\n ...(options.initialMessages !== undefined && {\n initialMessages: options.initialMessages,\n }),\n ...(options.persistence !== undefined && {\n persistence: options.persistence,\n }),\n ...(options.initialResumeSnapshot !== undefined && {\n initialResumeSnapshot: options.initialResumeSnapshot,\n }),\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.threadId !== undefined && { threadId: options.threadId }),\n ...(forwardedPropsSource !== undefined && {\n forwardedProps: forwardedPropsSource(),\n }),\n ...(contextSource !== undefined && { context: contextSource() }),\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectChat',\n outputKind: options.outputSchema ? 'structured' : 'chat',\n },\n onResponse: (response) => options.onResponse?.(response),\n onChunk: (chunk: StreamChunk) => options.onChunk?.(chunk),\n onFinish: (message) => options.onFinish?.(message),\n onError: (err) => options.onError?.(err),\n 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) => {\n interruptState.set(nextInterruptState)\n options.onInterruptStateChange?.(nextInterruptState)\n },\n tools: options.tools,\n onCustomEvent: (eventType, data, context) =>\n options.onCustomEvent?.(eventType, data, context),\n ...(options.streamProcessor !== undefined && {\n streamProcessor: options.streamProcessor,\n }),\n onMessagesChange: (m: Array<UIMessage<TTools>>) => messages.set(m),\n onLoadingChange: (v: boolean) => isLoading.set(v),\n onStatusChange: (v: ChatClientState) => status.set(v),\n onErrorChange: (v: Error | undefined) => error.set(v),\n onSubscriptionChange: (v: boolean) => isSubscribed.set(v),\n onConnectionStatusChange: (v: ConnectionStatus) => connectionStatus.set(v),\n onSessionGeneratingChange: (v: boolean) => sessionGenerating.set(v),\n ...(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\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 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: boolean | ((interrupt: ChatInterrupt<TTools>) => 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 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>\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 { ReactiveOption } from './internal/to-reactive'\n\nlet nextId = 0\n\nexport interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {\n /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */\n connection?: ConnectConnectionAdapter\n /** Direct async function for one-shot generation (no streaming protocol needed) */\n fetcher?: GenerationFetcher<TInput, TResult>\n /**\n * @deprecated Prefer `threadId`. Only allowed when `threadId` is omitted (see `GenerationPersistenceOptions`).\n */\n id?: string\n /** Additional request body params. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * 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, where\n * it falls back to `id` purely to satisfy the wire.\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' | 'id'\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 // Identity: pass `threadId` alone when set (never also pass deprecated `id`).\n const clientOptions: GenerationClientOptions<TInput, TResult, TOutput> = {\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.threadId !== undefined\n ? { threadId: options.threadId }\n : { id: options.id ?? `injectGeneration-${nextId++}` }),\n ...(options.persistence !== undefined && {\n persistence: options.persistence,\n }),\n ...(options.hydrateGeneration !== undefined && {\n hydrateGeneration: options.hydrateGeneration,\n }),\n ...(options.joinRun !== undefined && { joinRun: options.joinRun }),\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 let client: GenerationClient<TInput, TResult, TOutput>\n if (options.connection) {\n client = new GenerationClient({\n ...clientOptions,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new GenerationClient({\n ...clientOptions,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGeneration requires either a connection or fetcher option',\n )\n }\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({\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' | 'id'\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' | 'threadId' | 'hydrateGeneration' | 'joinRun'\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 /**\n * @deprecated Prefer `threadId`. Only allowed when `threadId` is omitted (see `GenerationPersistenceOptions`).\n */\n id?: string\n /** Additional body parameters to send with connect-based adapter requests. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * Callback when audio is generated. Can optionally return a transformed value.\n *\n * - Return a non-null value to transform and store it as the result\n * - Return `null` to keep the previous result unchanged\n * - Return nothing (`void`) to store the raw result as-is\n */\n onResult?: (result: AudioGenerationResult) => TOutput | null | void\n /** Callback when an error occurs */\n onError?: (error: Error) => void\n /** Callback when progress is reported (0-100) */\n onProgress?: (progress: number, message?: string) => void\n /** Callback for each stream chunk (connect-based adapter mode only) */\n onChunk?: (chunk: StreamChunk) => void\n}\n\n/**\n * Return type for the injectGenerateAudio injectable.\n *\n * @template TOutput - The output type (after optional transform)\n */\nexport interface InjectGenerateAudioResult<\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' | 'id'\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' | 'id'\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' | 'id'\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 */\nexport function injectAudioRecorder<\n TOnComplete extends (recording: AudioRecording) => unknown,\n>(\n options: InjectAudioRecorderOptions<TOnComplete>,\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' | 'id'\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 { StreamChunk } from '@tanstack/ai'\n\nlet nextId = 0\n\nexport interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {\n connection?: ConnectConnectionAdapter\n fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>\n id?: string\n body?: ReactiveOption<Record<string, any>>\n devtools?: AIDevtoolsDisplayOptions\n /**\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, where\n * it falls back to `id` purely to satisfy the wire.\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' | 'id'\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 // Identity: pass `threadId` alone when set (never also pass deprecated `id`).\n const baseOptions = {\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.threadId !== undefined\n ? { threadId: options.threadId }\n : { id: options.id ?? `injectGenerateVideo-${nextId++}` }),\n ...(options.persistence !== undefined && {\n persistence: options.persistence,\n }),\n ...(options.hydrateGeneration !== undefined && {\n hydrateGeneration: options.hydrateGeneration,\n }),\n ...(options.joinRun !== undefined && { joinRun: options.joinRun }),\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'\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 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 createChatClientOptions,\n type ConnectionAdapter,\n type ConnectConnectionAdapter,\n type SubscribeConnectionAdapter,\n type RunAgentInputContext,\n type FetchConnectionOptions,\n type XhrConnectionOptions,\n type InferChatMessages,\n type GenerationClientState,\n type ImageGenerateInput,\n type AudioGenerateInput,\n type SpeechGenerateInput,\n type TranscriptionGenerateInput,\n type SummarizeGenerateInput,\n type VideoGenerateInput,\n type VideoGenerateResult,\n type VideoStatusInfo,\n} from '@tanstack/ai-client'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["nextId"],"mappings":";;;;;AAUA;;;;;;AAMG;AACG,SAAU,UAAU,CAAI,KAAwB,EAAA;AACpD,IAAA,IAAI,QAAQ,CA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AC1B;AACH;;AC3PA;;ACAA;;AAEG;;;;"}
1
+ {"version":3,"file":"tanstack-ai-angular.mjs","sources":["../../src/internal/to-reactive.ts","../../src/inject-chat.ts","../../src/inject-generation.ts","../../src/inject-generate-image.ts","../../src/inject-generate-audio.ts","../../src/inject-generate-speech.ts","../../src/inject-transcription.ts","../../src/inject-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 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\n ? {\n persistence: options.persistence,\n threadId: options.threadId,\n }\n : {\n ...(options.threadId !== undefined && { threadId: options.threadId }),\n }),\n ...(options.initialResumeSnapshot !== undefined && {\n initialResumeSnapshot: options.initialResumeSnapshot,\n }),\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(forwardedPropsSource !== undefined && {\n forwardedProps: forwardedPropsSource(),\n }),\n ...(contextSource !== undefined && { context: contextSource() }),\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectChat',\n outputKind: options.outputSchema ? 'structured' : 'chat',\n },\n onResponse: (response) => options.onResponse?.(response),\n onChunk: (chunk: StreamChunk) => options.onChunk?.(chunk),\n onFinish: (message) => options.onFinish?.(message),\n onError: (err) => options.onError?.(err),\n 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>>) => messages.set(m),\n onLoadingChange: (v: boolean) => isLoading.set(v),\n onStatusChange: (v: ChatClientState) => status.set(v),\n onErrorChange: (v: Error | undefined) => error.set(v),\n onSubscriptionChange: (v: boolean) => isSubscribed.set(v),\n onConnectionStatusChange: (v: ConnectionStatus) => connectionStatus.set(v),\n onSessionGeneratingChange: (v: boolean) => sessionGenerating.set(v),\n ...(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\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 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 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 { 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 { 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 /** 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.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' | 'threadId' | 'hydrateGeneration' | 'joinRun'\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 */\nexport function injectAudioRecorder<\n TOnComplete extends (recording: AudioRecording) => unknown,\n>(\n options: InjectAudioRecorderOptions<TOnComplete>,\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 { 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 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 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'\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 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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AAC;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;;AC3PA;;ACAA;;AAEG;;;;"}
@@ -1,6 +1,6 @@
1
- import { AnyClientTool, SchemaInput, 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, ChatInterrupt, ChatResumeState, ChatClientState, ConnectionStatus, ConnectConnectionAdapter, GenerationFetcher, GenerationRestoredResult, GenerationClientState, GenerationPersistenceOptions, InferGenerationOutputFromReturn, ImageGenerateInput, AudioGenerateInput, SpeechGenerateInput, TranscriptionGenerateInput, AudioRecorderOptions, AudioRecording, InferAudioRecordingOutput, SummarizeGenerateInput, VideoGenerateResult, VideoGenerateInput, VideoStatusInfo } from '@tanstack/ai-client';
3
- export { AudioGenerateInput, ChatClientPersistence, ChatPersistedState, ChatPersistenceOption, ChatRequestBody, ChatStorageAdapter, ConnectConnectionAdapter, ConnectionAdapter, FetchConnectionOptions, GenerationClientState, ImageGenerateInput, IndexedDBPersistenceOptions, InferChatMessages, MultimodalContent, QueueConfig, QueueOption, QueueStrategy, QueuedMessage, RunAgentInputContext, SendMessageOptions, SpeechGenerateInput, StorageUnavailableError, SubscribeConnectionAdapter, SummarizeGenerateInput, TranscriptionGenerateInput, UIMessage, VideoGenerateInput, VideoGenerateResult, VideoStatusInfo, WebStoragePersistenceOptions, WhenBusy, XhrConnectionOptions, createChatClientOptions, fetchHttpStream, fetchServerSentEvents, indexedDBPersistence, localStoragePersistence, rpcStream, sessionStoragePersistence, stream, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
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, ConnectConnectionAdapter, GenerationFetcher, GenerationRestoredResult, GenerationClientState, GenerationPersistenceOptions, InferGenerationOutputFromReturn, ImageGenerateInput, AudioGenerateInput, SpeechGenerateInput, TranscriptionGenerateInput, AudioRecorderOptions, AudioRecording, InferAudioRecordingOutput, SummarizeGenerateInput, VideoGenerateResult, VideoGenerateInput, VideoStatusInfo } from '@tanstack/ai-client';
3
+ export { AudioGenerateInput, ChatClientPersistence, ChatPersistedState, ChatPersistenceOption, ChatRequestBody, ChatStorageAdapter, ConnectConnectionAdapter, ConnectionAdapter, FetchConnectionOptions, GenerationClientState, ImageGenerateInput, IndexedDBPersistenceOptions, InferChatMessages, MultimodalContent, QueueConfig, QueueOption, QueueStrategy, QueuedMessage, RunAgentInputContext, SendMessageOptions, SpeechGenerateInput, StorageUnavailableError, SubscribeConnectionAdapter, SummarizeGenerateInput, TranscriptionGenerateInput, UIMessage, VideoGenerateInput, VideoGenerateResult, VideoStatusInfo, WebSocketConnectionOptions, WebStoragePersistenceOptions, WhenBusy, XhrConnectionOptions, createChatClientOptions, fetchHttpStream, fetchServerSentEvents, indexedDBPersistence, localStoragePersistence, rpcStream, sessionStoragePersistence, stream, webSocket, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
4
4
  import { Signal } from '@angular/core';
5
5
 
6
6
  /**
@@ -26,7 +26,7 @@ type DeepPartial<T> = T extends ReadonlyArray<infer U> ? Array<DeepPartial<U>> :
26
26
  * - `body`, `forwardedProps`, and `live` accept a {@link ReactiveOption} so
27
27
  * they can be a static value, a `Signal`, or a getter and stay reactive.
28
28
  */
29
- type InjectChatOptions<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>> = DistributedOmit<ChatClientOptions<TTools, TContext>, 'onMessagesChange' | 'onLoadingChange' | 'onErrorChange' | 'onStatusChange' | 'onSubscriptionChange' | 'onConnectionStatusChange' | 'onSessionGeneratingChange' | 'onQueueChange' | 'onResumeStateChange' | 'onRunIdChange' | 'context' | 'devtools' | 'body' | 'forwardedProps'> & {
29
+ 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'> & {
30
30
  /** Display options for TanStack AI Devtools. */
31
31
  devtools?: AIDevtoolsDisplayOptions;
32
32
  /** Additional request body params. Reactive. */
@@ -45,13 +45,13 @@ type InjectChatOptions<TTools extends ReadonlyArray<AnyClientTool> = any, TSchem
45
45
  * Return shape of {@link injectChat}. When `outputSchema` is supplied, adds
46
46
  * typed `partial` / `final` signals; otherwise the return is unchanged.
47
47
  */
48
- type InjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined> = BaseInjectChatResult<TTools, TSchema extends SchemaInput ? InferSchemaType<TSchema> : unknown> & (TSchema extends SchemaInput ? {
48
+ type InjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> = BaseInjectChatResult<TTools, TSchema extends SchemaInput ? InferSchemaType<TSchema> : unknown, TInterrupts> & (TSchema extends SchemaInput ? {
49
49
  /** Live progressively-parsed structured output. */
50
50
  partial: Signal<DeepPartial<InferSchemaType<TSchema>>>;
51
51
  /** Final, schema-validated structured output. `null` until complete. */
52
52
  final: Signal<InferSchemaType<TSchema> | null>;
53
53
  } : Record<never, never>);
54
- interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TData = unknown> {
54
+ interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TData = unknown, TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []> {
55
55
  /** Current messages in the conversation. */
56
56
  messages: Signal<Array<UIMessage<TTools, TData>>>;
57
57
  /** Send a message (string or multimodal content). */
@@ -88,16 +88,16 @@ interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any
88
88
  */
89
89
  runId: Signal<string | null>;
90
90
  /** Immutable bound interrupts for the current interrupted run. */
91
- interrupts: Signal<BoundInterrupts<TTools>>;
91
+ interrupts: Signal<BoundInterrupts<TTools, TInterrupts>>;
92
92
  /** @deprecated Use `interrupts`. */
93
- pendingInterrupts: Signal<BoundInterrupts<TTools>>;
93
+ pendingInterrupts: Signal<BoundInterrupts<TTools, TInterrupts>>;
94
94
  /** Batch-level interrupt errors. */
95
- interruptErrors: Signal<ChatInterruptState<TTools>['interruptErrors']>;
95
+ interruptErrors: Signal<ChatInterruptState<TTools, TInterrupts>['interruptErrors']>;
96
96
  /** Whether the client is submitting an interrupt batch. */
97
97
  resuming: Signal<boolean>;
98
98
  resolveInterrupts: {
99
99
  (approved: boolean): void;
100
- (resolver: (interrupt: ChatInterrupt<TTools>) => undefined): void;
100
+ (resolver: (interrupt: ResolvableChatInterrupt<TTools, TInterrupts>) => undefined): void;
101
101
  };
102
102
  cancelInterrupts: () => void;
103
103
  retryInterrupts: () => void;
@@ -124,17 +124,13 @@ interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any
124
124
  sessionGenerating: Signal<boolean>;
125
125
  }
126
126
 
127
- declare function injectChat<const TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>>(options?: InjectChatOptions<TTools, TSchema, TContext>): InjectChatResult<TTools, TSchema>;
127
+ declare function injectChat<const TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>, const TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> = readonly []>(options?: InjectChatOptions<TTools, TSchema, TContext, TInterrupts>): InjectChatResult<TTools, TSchema, TInterrupts>;
128
128
 
129
129
  interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
130
130
  /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
131
131
  connection?: ConnectConnectionAdapter;
132
132
  /** Direct async function for one-shot generation (no streaming protocol needed) */
133
133
  fetcher?: GenerationFetcher<TInput, TResult>;
134
- /**
135
- * @deprecated Prefer `threadId`. Only allowed when `threadId` is omitted (see `GenerationPersistenceOptions`).
136
- */
137
- id?: string;
138
134
  /** Additional request body params. Reactive. */
139
135
  body?: ReactiveOption<Record<string, any>>;
140
136
  /** Display options for TanStack AI Devtools. */
@@ -158,8 +154,8 @@ interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
158
154
  * id on the wire, which the protocol requires.
159
155
  *
160
156
  * **Required whenever `persistence` is set** — an app that cannot name the
161
- * scope has nothing to restore to. Optional for ephemeral generations, where
162
- * it falls back to `id` purely to satisfy the wire.
157
+ * scope has nothing to restore to. Optional for ephemeral generations. If
158
+ * omitted, the client mints a wire id after mount.
163
159
  */
164
160
  threadId?: string;
165
161
  /**
@@ -227,7 +223,7 @@ interface InjectGenerationResult<TOutput, TInput extends Record<string, any> = R
227
223
  */
228
224
  runId: Signal<string | null>;
229
225
  }
230
- declare function injectGeneration<TInput extends Record<string, any>, TResult, TTransformed = void>(options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult' | 'persistence' | 'threadId' | 'id'> & {
226
+ declare function injectGeneration<TInput extends Record<string, any>, TResult, TTransformed = void>(options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult' | 'persistence' | 'threadId'> & {
231
227
  onResult?: (result: TResult) => TTransformed;
232
228
  } & GenerationPersistenceOptions): InjectGenerationResult<InferGenerationOutputFromReturn<TResult, TTransformed>, TInput>;
233
229
 
@@ -241,7 +237,7 @@ interface InjectGenerateImageResult<TOutput = ImageGenerationResult> extends Omi
241
237
  error: Signal<Error | undefined>;
242
238
  status: Signal<GenerationClientState>;
243
239
  }
244
- declare function injectGenerateImage<TTransformed = void>(options: Omit<InjectGenerateImageOptions, 'onResult' | 'persistence' | 'threadId' | 'id'> & {
240
+ declare function injectGenerateImage<TTransformed = void>(options: Omit<InjectGenerateImageOptions, 'onResult' | 'persistence' | 'threadId'> & {
245
241
  onResult?: (result: ImageGenerationResult) => TTransformed;
246
242
  } & GenerationPersistenceOptions): InjectGenerateImageResult<InferGenerationOutputFromReturn<ImageGenerationResult, TTransformed>>;
247
243
 
@@ -255,10 +251,6 @@ interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> extends Pi
255
251
  connection?: ConnectConnectionAdapter;
256
252
  /** Direct async function for audio generation */
257
253
  fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>;
258
- /**
259
- * @deprecated Prefer `threadId`. Only allowed when `threadId` is omitted (see `GenerationPersistenceOptions`).
260
- */
261
- id?: string;
262
254
  /** Additional body parameters to send with connect-based adapter requests. Reactive. */
263
255
  body?: ReactiveOption<Record<string, any>>;
264
256
  /** Display options for TanStack AI Devtools. */
@@ -326,7 +318,7 @@ interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> extends Omi
326
318
  * }
327
319
  * ```
328
320
  */
329
- declare function injectGenerateAudio<TTransformed = void>(options: Omit<InjectGenerateAudioOptions, 'onResult' | 'persistence' | 'threadId' | 'id'> & {
321
+ declare function injectGenerateAudio<TTransformed = void>(options: Omit<InjectGenerateAudioOptions, 'onResult' | 'persistence' | 'threadId'> & {
330
322
  onResult?: (result: AudioGenerationResult) => TTransformed;
331
323
  } & GenerationPersistenceOptions): InjectGenerateAudioResult<InferGenerationOutputFromReturn<AudioGenerationResult, TTransformed>>;
332
324
 
@@ -340,7 +332,7 @@ interface InjectGenerateSpeechResult<TOutput = TTSResult> extends Omit<InjectGen
340
332
  error: Signal<Error | undefined>;
341
333
  status: Signal<GenerationClientState>;
342
334
  }
343
- declare function injectGenerateSpeech<TTransformed = void>(options: Omit<InjectGenerateSpeechOptions, 'onResult' | 'persistence' | 'threadId' | 'id'> & {
335
+ declare function injectGenerateSpeech<TTransformed = void>(options: Omit<InjectGenerateSpeechOptions, 'onResult' | 'persistence' | 'threadId'> & {
344
336
  onResult?: (result: TTSResult) => TTransformed;
345
337
  } & GenerationPersistenceOptions): InjectGenerateSpeechResult<InferGenerationOutputFromReturn<TTSResult, TTransformed>>;
346
338
 
@@ -354,7 +346,7 @@ interface InjectTranscriptionResult<TOutput = TranscriptionResult> extends Omit<
354
346
  error: Signal<Error | undefined>;
355
347
  status: Signal<GenerationClientState>;
356
348
  }
357
- declare function injectTranscription<TTransformed = void>(options: Omit<InjectTranscriptionOptions, 'onResult' | 'persistence' | 'threadId' | 'id'> & {
349
+ declare function injectTranscription<TTransformed = void>(options: Omit<InjectTranscriptionOptions, 'onResult' | 'persistence' | 'threadId'> & {
358
350
  onResult?: (result: TranscriptionResult) => TTransformed;
359
351
  } & GenerationPersistenceOptions): InjectTranscriptionResult<InferGenerationOutputFromReturn<TranscriptionResult, TTransformed>>;
360
352
 
@@ -401,14 +393,13 @@ interface InjectSummarizeResult<TOutput = SummarizationResult> extends Omit<Inje
401
393
  error: Signal<Error | undefined>;
402
394
  status: Signal<GenerationClientState>;
403
395
  }
404
- declare function injectSummarize<TTransformed = void>(options: Omit<InjectSummarizeOptions, 'onResult' | 'persistence' | 'threadId' | 'id'> & {
396
+ declare function injectSummarize<TTransformed = void>(options: Omit<InjectSummarizeOptions, 'onResult' | 'persistence' | 'threadId'> & {
405
397
  onResult?: (result: SummarizationResult) => TTransformed;
406
398
  } & GenerationPersistenceOptions): InjectSummarizeResult<InferGenerationOutputFromReturn<SummarizationResult, TTransformed>>;
407
399
 
408
400
  interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {
409
401
  connection?: ConnectConnectionAdapter;
410
402
  fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>;
411
- id?: string;
412
403
  body?: ReactiveOption<Record<string, any>>;
413
404
  devtools?: AIDevtoolsDisplayOptions;
414
405
  /**
@@ -430,8 +421,8 @@ interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {
430
421
  * id on the wire, which the protocol requires.
431
422
  *
432
423
  * **Required whenever `persistence` is set** — an app that cannot name the
433
- * scope has nothing to restore to. Optional for ephemeral generations, where
434
- * it falls back to `id` purely to satisfy the wire.
424
+ * scope has nothing to restore to. Optional for ephemeral generations. If
425
+ * omitted, the client mints a wire id after mount.
435
426
  */
436
427
  threadId?: string;
437
428
  /**
@@ -473,7 +464,7 @@ interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {
473
464
  */
474
465
  runId: Signal<string | null>;
475
466
  }
476
- declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGenerateVideoOptions, 'onResult' | 'persistence' | 'threadId' | 'id'> & {
467
+ declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGenerateVideoOptions, 'onResult' | 'persistence' | 'threadId'> & {
477
468
  onResult?: (result: VideoGenerateResult) => TTransformed;
478
469
  } & GenerationPersistenceOptions): InjectGenerateVideoResult<InferGenerationOutputFromReturn<VideoGenerateResult, TTransformed>>;
479
470
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-angular",
3
- "version": "0.4.3",
3
+ "version": "0.6.1",
4
4
  "description": "Angular signals integration for TanStack AI streaming chat, structured outputs, and media generation.",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -45,11 +45,11 @@
45
45
  ],
46
46
  "dependencies": {
47
47
  "tslib": "^2.8.1",
48
- "@tanstack/ai-client": "^0.23.3"
48
+ "@tanstack/ai-client": "^0.25.1"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@angular/core": ">=21.0.0",
52
- "@tanstack/ai": "^0.45.0"
52
+ "@tanstack/ai": "^0.47.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@analogjs/vite-plugin-angular": "^2.6.2",
@@ -66,7 +66,7 @@
66
66
  "vitest": "^4.1.10",
67
67
  "zod": "^4.2.0",
68
68
  "zone.js": "^0.15.0",
69
- "@tanstack/ai": "0.45.0"
69
+ "@tanstack/ai": "0.47.1"
70
70
  },
71
71
  "scripts": {
72
72
  "clean": "premove ./build ./dist",
package/src/index.ts CHANGED
@@ -92,6 +92,7 @@ export {
92
92
  xhrHttpStream,
93
93
  stream,
94
94
  rpcStream,
95
+ webSocket,
95
96
  createChatClientOptions,
96
97
  type ConnectionAdapter,
97
98
  type ConnectConnectionAdapter,
@@ -99,6 +100,7 @@ export {
99
100
  type RunAgentInputContext,
100
101
  type FetchConnectionOptions,
101
102
  type XhrConnectionOptions,
103
+ type WebSocketConnectionOptions,
102
104
  type InferChatMessages,
103
105
  type GenerationClientState,
104
106
  type ImageGenerateInput,
@@ -13,6 +13,7 @@ import {
13
13
  import { toReactive } from './internal/to-reactive'
14
14
  import type {
15
15
  AnyClientTool,
16
+ InterruptDefinition,
16
17
  InferSchemaType,
17
18
  ModelMessage,
18
19
  RunAgentResumeItem,
@@ -21,7 +22,7 @@ import type {
21
22
  } from '@tanstack/ai'
22
23
  import type {
23
24
  ChatClientState,
24
- ChatInterrupt,
25
+ ResolvableChatInterrupt,
25
26
  ChatInterruptState,
26
27
  ChatResumeState,
27
28
  ConnectionStatus,
@@ -41,19 +42,21 @@ import type {
41
42
  const EMPTY_INTERRUPTS = Object.freeze([])
42
43
  const EMPTY_INTERRUPT_ERRORS = Object.freeze([])
43
44
 
44
- let nextId = 0
45
-
46
45
  export function injectChat<
47
46
  const TTools extends ReadonlyArray<AnyClientTool> = any,
48
47
  TSchema extends SchemaInput | undefined = undefined,
49
48
  TContext = InferredClientContext<TTools>,
49
+ const TInterrupts extends ReadonlyArray<
50
+ InterruptDefinition<any, any, any, any>
51
+ > = readonly [],
50
52
  >(
51
53
  options: InjectChatOptions<
52
54
  TTools,
53
55
  TSchema,
54
- TContext
55
- > = {} as InjectChatOptions<TTools, TSchema, TContext>,
56
- ): InjectChatResult<TTools, TSchema> {
56
+ TContext,
57
+ TInterrupts
58
+ > = {} as InjectChatOptions<TTools, TSchema, TContext, TInterrupts>,
59
+ ): InjectChatResult<TTools, TSchema, TInterrupts> {
57
60
  assertInInjectionContext(injectChat)
58
61
 
59
62
  type Partial = DeepPartial<InferSchemaType<NonNullable<TSchema>>>
@@ -61,7 +64,6 @@ export function injectChat<
61
64
 
62
65
  const destroyRef = inject(DestroyRef)
63
66
  const injector = inject(Injector)
64
- const clientId = options.id || `injectChat-${nextId++}`
65
67
 
66
68
  const messages = signal<Array<UIMessage<TTools>>>(
67
69
  options.initialMessages || [],
@@ -74,7 +76,7 @@ export function injectChat<
74
76
  const sessionGenerating = signal(false)
75
77
  const queue = signal<Array<QueuedMessage>>([])
76
78
  const runId = signal<string | null>(null)
77
- const interruptState = signal<ChatInterruptState<TTools>>({
79
+ const interruptState = signal<ChatInterruptState<TTools, TInterrupts>>({
78
80
  interrupts: EMPTY_INTERRUPTS,
79
81
  pendingInterrupts: EMPTY_INTERRUPTS,
80
82
  interruptErrors: EMPTY_INTERRUPT_ERRORS,
@@ -97,21 +99,24 @@ export function injectChat<
97
99
  ? { connection: options.connection }
98
100
  : { fetcher: options.fetcher }
99
101
 
100
- const client = new ChatClient<TTools, TContext>({
102
+ const client = new ChatClient<TTools, TContext, TInterrupts>({
101
103
  devtoolsBridgeFactory: createChatDevtoolsBridge,
102
104
  ...transport,
103
- id: clientId,
104
105
  ...(options.initialMessages !== undefined && {
105
106
  initialMessages: options.initialMessages,
106
107
  }),
107
- ...(options.persistence !== undefined && {
108
- persistence: options.persistence,
109
- }),
108
+ ...(typeof options.threadId === 'string' && options.persistence
109
+ ? {
110
+ persistence: options.persistence,
111
+ threadId: options.threadId,
112
+ }
113
+ : {
114
+ ...(options.threadId !== undefined && { threadId: options.threadId }),
115
+ }),
110
116
  ...(options.initialResumeSnapshot !== undefined && {
111
117
  initialResumeSnapshot: options.initialResumeSnapshot,
112
118
  }),
113
119
  ...(bodySource !== undefined && { body: bodySource() }),
114
- ...(options.threadId !== undefined && { threadId: options.threadId }),
115
120
  ...(forwardedPropsSource !== undefined && {
116
121
  forwardedProps: forwardedPropsSource(),
117
122
  }),
@@ -131,11 +136,14 @@ export function injectChat<
131
136
  // signal (via `onRunIdChange`) and pending interrupts arrive through
132
137
  // `onInterruptStateChange`, so there is nothing left for it to do — and it
133
138
  // is not a public option here, matching the other framework packages.
134
- onInterruptStateChange: (nextInterruptState) => {
139
+ onInterruptStateChange: (nextInterruptState, context) => {
135
140
  interruptState.set(nextInterruptState)
136
- options.onInterruptStateChange?.(nextInterruptState)
141
+ options.onInterruptStateChange?.(nextInterruptState, context)
137
142
  },
138
143
  tools: options.tools,
144
+ ...(options.interrupts !== undefined && {
145
+ interrupts: options.interrupts,
146
+ }),
139
147
  onCustomEvent: (eventType, data, context) =>
140
148
  options.onCustomEvent?.(eventType, data, context),
141
149
  ...(options.streamProcessor !== undefined && {
@@ -290,7 +298,11 @@ export function injectChat<
290
298
  const interruptErrors = computed(() => interruptState().interruptErrors)
291
299
  const resuming = computed(() => interruptState().resuming)
292
300
  const resolveInterrupts = (
293
- resolution: boolean | ((interrupt: ChatInterrupt<TTools>) => undefined),
301
+ resolution:
302
+ | boolean
303
+ | ((
304
+ interrupt: ResolvableChatInterrupt<TTools, TInterrupts>,
305
+ ) => undefined),
294
306
  ) => {
295
307
  if (typeof resolution === 'boolean') {
296
308
  client.resolveInterrupts(resolution)
@@ -335,5 +347,5 @@ export function injectChat<
335
347
  resumeInterruptsUnsafe,
336
348
  partial,
337
349
  final,
338
- } as unknown as InjectChatResult<TTools, TSchema>
350
+ } as unknown as InjectChatResult<TTools, TSchema, TInterrupts>
339
351
  }
@@ -32,10 +32,6 @@ export interface InjectGenerateAudioOptions<
32
32
  connection?: ConnectConnectionAdapter
33
33
  /** Direct async function for audio generation */
34
34
  fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>
35
- /**
36
- * @deprecated Prefer `threadId`. Only allowed when `threadId` is omitted (see `GenerationPersistenceOptions`).
37
- */
38
- id?: string
39
35
  /** Additional body parameters to send with connect-based adapter requests. Reactive. */
40
36
  body?: ReactiveOption<Record<string, any>>
41
37
  /** Display options for TanStack AI Devtools. */
@@ -110,7 +106,7 @@ export interface InjectGenerateAudioResult<
110
106
  export function injectGenerateAudio<TTransformed = void>(
111
107
  options: Omit<
112
108
  InjectGenerateAudioOptions,
113
- 'onResult' | 'persistence' | 'threadId' | 'id'
109
+ 'onResult' | 'persistence' | 'threadId'
114
110
  > & {
115
111
  onResult?: (result: AudioGenerationResult) => TTransformed
116
112
  } & GenerationPersistenceOptions,
@@ -33,7 +33,7 @@ export interface InjectGenerateImageResult<
33
33
  export function injectGenerateImage<TTransformed = void>(
34
34
  options: Omit<
35
35
  InjectGenerateImageOptions,
36
- 'onResult' | 'persistence' | 'threadId' | 'id'
36
+ 'onResult' | 'persistence' | 'threadId'
37
37
  > & {
38
38
  onResult?: (result: ImageGenerationResult) => TTransformed
39
39
  } & GenerationPersistenceOptions,
@@ -34,7 +34,7 @@ export interface InjectGenerateSpeechResult<TOutput = TTSResult> extends Omit<
34
34
  export function injectGenerateSpeech<TTransformed = void>(
35
35
  options: Omit<
36
36
  InjectGenerateSpeechOptions,
37
- 'onResult' | 'persistence' | 'threadId' | 'id'
37
+ 'onResult' | 'persistence' | 'threadId'
38
38
  > & {
39
39
  onResult?: (result: TTSResult) => TTransformed
40
40
  } & GenerationPersistenceOptions,
@@ -25,12 +25,9 @@ import type {
25
25
  } from '@tanstack/ai-client'
26
26
  import type { StreamChunk } from '@tanstack/ai'
27
27
 
28
- let nextId = 0
29
-
30
28
  export interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {
31
29
  connection?: ConnectConnectionAdapter
32
30
  fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>
33
- id?: string
34
31
  body?: ReactiveOption<Record<string, any>>
35
32
  devtools?: AIDevtoolsDisplayOptions
36
33
  /**
@@ -52,8 +49,8 @@ export interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {
52
49
  * id on the wire, which the protocol requires.
53
50
  *
54
51
  * **Required whenever `persistence` is set** — an app that cannot name the
55
- * scope has nothing to restore to. Optional for ephemeral generations, where
56
- * it falls back to `id` purely to satisfy the wire.
52
+ * scope has nothing to restore to. Optional for ephemeral generations. If
53
+ * omitted, the client mints a wire id after mount.
57
54
  */
58
55
  threadId?: string
59
56
  /**
@@ -103,7 +100,7 @@ export interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {
103
100
  export function injectGenerateVideo<TTransformed = void>(
104
101
  options: Omit<
105
102
  InjectGenerateVideoOptions,
106
- 'onResult' | 'persistence' | 'threadId' | 'id'
103
+ 'onResult' | 'persistence' | 'threadId'
107
104
  > & {
108
105
  onResult?: (result: VideoGenerateResult) => TTransformed
109
106
  } & GenerationPersistenceOptions,
@@ -132,15 +129,18 @@ export function injectGenerateVideo<TTransformed = void>(
132
129
  const bodySource =
133
130
  options.body !== undefined ? toReactive(options.body) : undefined
134
131
 
135
- // Identity: pass `threadId` alone when set (never also pass deprecated `id`).
136
132
  const baseOptions = {
137
133
  ...(bodySource !== undefined && { body: bodySource() }),
138
- ...(options.threadId !== undefined
139
- ? { threadId: options.threadId }
140
- : { id: options.id ?? `injectGenerateVideo-${nextId++}` }),
141
- ...(options.persistence !== undefined && {
142
- persistence: options.persistence,
143
- }),
134
+ ...(typeof options.threadId === 'string' && options.persistence
135
+ ? {
136
+ persistence: options.persistence,
137
+ threadId: options.threadId,
138
+ }
139
+ : {
140
+ ...(options.threadId !== undefined && {
141
+ threadId: options.threadId,
142
+ }),
143
+ }),
144
144
  ...(options.hydrateGeneration !== undefined && {
145
145
  hydrateGeneration: options.hydrateGeneration,
146
146
  }),
@@ -24,17 +24,11 @@ import type {
24
24
  } from '@tanstack/ai-client'
25
25
  import type { ReactiveOption } from './internal/to-reactive'
26
26
 
27
- let nextId = 0
28
-
29
27
  export interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
30
28
  /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
31
29
  connection?: ConnectConnectionAdapter
32
30
  /** Direct async function for one-shot generation (no streaming protocol needed) */
33
31
  fetcher?: GenerationFetcher<TInput, TResult>
34
- /**
35
- * @deprecated Prefer `threadId`. Only allowed when `threadId` is omitted (see `GenerationPersistenceOptions`).
36
- */
37
- id?: string
38
32
  /** Additional request body params. Reactive. */
39
33
  body?: ReactiveOption<Record<string, any>>
40
34
  /** Display options for TanStack AI Devtools. */
@@ -58,8 +52,8 @@ export interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
58
52
  * id on the wire, which the protocol requires.
59
53
  *
60
54
  * **Required whenever `persistence` is set** — an app that cannot name the
61
- * scope has nothing to restore to. Optional for ephemeral generations, where
62
- * it falls back to `id` purely to satisfy the wire.
55
+ * scope has nothing to restore to. Optional for ephemeral generations. If
56
+ * omitted, the client mints a wire id after mount.
63
57
  */
64
58
  threadId?: string
65
59
  /**
@@ -145,7 +139,7 @@ export function injectGeneration<
145
139
  >(
146
140
  options: Omit<
147
141
  InjectGenerationOptions<TInput, TResult>,
148
- 'onResult' | 'persistence' | 'threadId' | 'id'
142
+ 'onResult' | 'persistence' | 'threadId'
149
143
  > & {
150
144
  onResult?: (result: TResult) => TTransformed
151
145
  } & GenerationPersistenceOptions,
@@ -170,15 +164,11 @@ export function injectGeneration<
170
164
  const bodySource =
171
165
  options.body !== undefined ? toReactive(options.body) : undefined
172
166
 
173
- // Identity: pass `threadId` alone when set (never also pass deprecated `id`).
174
- const clientOptions: GenerationClientOptions<TInput, TResult, TOutput> = {
167
+ const clientOptions: Omit<
168
+ GenerationClientOptions<TInput, TResult, TOutput>,
169
+ 'persistence' | 'threadId'
170
+ > = {
175
171
  ...(bodySource !== undefined && { body: bodySource() }),
176
- ...(options.threadId !== undefined
177
- ? { threadId: options.threadId }
178
- : { id: options.id ?? `injectGeneration-${nextId++}` }),
179
- ...(options.persistence !== undefined && {
180
- persistence: options.persistence,
181
- }),
182
172
  ...(options.hydrateGeneration !== undefined && {
183
173
  hydrateGeneration: options.hydrateGeneration,
184
174
  }),
@@ -224,15 +214,29 @@ export function injectGeneration<
224
214
  },
225
215
  }
226
216
 
217
+ const persistenceProps =
218
+ typeof options.threadId === 'string' && options.persistence
219
+ ? {
220
+ persistence: options.persistence,
221
+ threadId: options.threadId,
222
+ }
223
+ : {
224
+ ...(options.threadId !== undefined && {
225
+ threadId: options.threadId,
226
+ }),
227
+ }
228
+
227
229
  let client: GenerationClient<TInput, TResult, TOutput>
228
230
  if (options.connection) {
229
231
  client = new GenerationClient({
230
232
  ...clientOptions,
233
+ ...persistenceProps,
231
234
  connection: options.connection,
232
235
  })
233
236
  } else if (options.fetcher) {
234
237
  client = new GenerationClient({
235
238
  ...clientOptions,
239
+ ...persistenceProps,
236
240
  fetcher: options.fetcher,
237
241
  })
238
242
  } else {
@@ -33,7 +33,7 @@ export interface InjectSummarizeResult<
33
33
  export function injectSummarize<TTransformed = void>(
34
34
  options: Omit<
35
35
  InjectSummarizeOptions,
36
- 'onResult' | 'persistence' | 'threadId' | 'id'
36
+ 'onResult' | 'persistence' | 'threadId'
37
37
  > & {
38
38
  onResult?: (result: SummarizationResult) => TTransformed
39
39
  } & GenerationPersistenceOptions,
@@ -37,7 +37,7 @@ export interface InjectTranscriptionResult<
37
37
  export function injectTranscription<TTransformed = void>(
38
38
  options: Omit<
39
39
  InjectTranscriptionOptions,
40
- 'onResult' | 'persistence' | 'threadId' | 'id'
40
+ 'onResult' | 'persistence' | 'threadId'
41
41
  > & {
42
42
  onResult?: (result: TranscriptionResult) => TTransformed
43
43
  } & GenerationPersistenceOptions,
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  AnyClientTool,
3
+ InterruptDefinition,
3
4
  InferSchemaType,
4
5
  ModelMessage,
5
6
  RunAgentResumeItem,
@@ -10,7 +11,7 @@ import type {
10
11
  BoundInterrupts,
11
12
  ChatClientOptions,
12
13
  ChatClientState,
13
- ChatInterrupt,
14
+ ResolvableChatInterrupt,
14
15
  ChatInterruptState,
15
16
  ChatRequestBody,
16
17
  ChatResumeState,
@@ -67,8 +68,10 @@ export type InjectChatOptions<
67
68
  TTools extends ReadonlyArray<AnyClientTool> = any,
68
69
  TSchema extends SchemaInput | undefined = undefined,
69
70
  TContext = InferredClientContext<TTools>,
71
+ TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> =
72
+ readonly [],
70
73
  > = DistributedOmit<
71
- ChatClientOptions<TTools, TContext>,
74
+ ChatClientOptions<TTools, TContext, TInterrupts>,
72
75
  | 'onMessagesChange'
73
76
  | 'onLoadingChange'
74
77
  | 'onErrorChange'
@@ -106,9 +109,12 @@ export type InjectChatOptions<
106
109
  export type InjectChatResult<
107
110
  TTools extends ReadonlyArray<AnyClientTool> = any,
108
111
  TSchema extends SchemaInput | undefined = undefined,
112
+ TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> =
113
+ readonly [],
109
114
  > = BaseInjectChatResult<
110
115
  TTools,
111
- TSchema extends SchemaInput ? InferSchemaType<TSchema> : unknown
116
+ TSchema extends SchemaInput ? InferSchemaType<TSchema> : unknown,
117
+ TInterrupts
112
118
  > &
113
119
  (TSchema extends SchemaInput
114
120
  ? {
@@ -122,6 +128,8 @@ export type InjectChatResult<
122
128
  interface BaseInjectChatResult<
123
129
  TTools extends ReadonlyArray<AnyClientTool> = any,
124
130
  TData = unknown,
131
+ TInterrupts extends ReadonlyArray<InterruptDefinition<any, any, any, any>> =
132
+ readonly [],
125
133
  > {
126
134
  /** Current messages in the conversation. */
127
135
  messages: Signal<Array<UIMessage<TTools, TData>>>
@@ -162,16 +170,22 @@ interface BaseInjectChatResult<
162
170
  */
163
171
  runId: Signal<string | null>
164
172
  /** Immutable bound interrupts for the current interrupted run. */
165
- interrupts: Signal<BoundInterrupts<TTools>>
173
+ interrupts: Signal<BoundInterrupts<TTools, TInterrupts>>
166
174
  /** @deprecated Use `interrupts`. */
167
- pendingInterrupts: Signal<BoundInterrupts<TTools>>
175
+ pendingInterrupts: Signal<BoundInterrupts<TTools, TInterrupts>>
168
176
  /** Batch-level interrupt errors. */
169
- interruptErrors: Signal<ChatInterruptState<TTools>['interruptErrors']>
177
+ interruptErrors: Signal<
178
+ ChatInterruptState<TTools, TInterrupts>['interruptErrors']
179
+ >
170
180
  /** Whether the client is submitting an interrupt batch. */
171
181
  resuming: Signal<boolean>
172
182
  resolveInterrupts: {
173
183
  (approved: boolean): void
174
- (resolver: (interrupt: ChatInterrupt<TTools>) => undefined): void
184
+ (
185
+ resolver: (
186
+ interrupt: ResolvableChatInterrupt<TTools, TInterrupts>,
187
+ ) => undefined,
188
+ ): void
175
189
  }
176
190
  cancelInterrupts: () => void
177
191
  retryInterrupts: () => void