@tanstack/ai-angular 0.1.11 → 0.2.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.
- package/dist/fesm2022/tanstack-ai-angular.mjs +55 -4
- package/dist/fesm2022/tanstack-ai-angular.mjs.map +1 -1
- package/dist/types/tanstack-ai-angular.d.ts +57 -24
- package/package.json +4 -4
- package/src/index.ts +7 -0
- package/src/inject-audio-recorder.ts +96 -0
- package/src/inject-generate-audio.ts +5 -8
- package/src/inject-generate-image.ts +5 -8
- package/src/inject-generate-speech.ts +7 -7
- package/src/inject-generate-video.ts +17 -9
- package/src/inject-generation.ts +19 -6
- package/src/inject-summarize.ts +10 -11
- package/src/inject-transcription.ts +5 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatClient, GenerationClient, VideoGenerationClient } from '@tanstack/ai-client';
|
|
1
|
+
import { ChatClient, GenerationClient, AudioRecorder, VideoGenerationClient } from '@tanstack/ai-client';
|
|
2
2
|
export { createChatClientOptions, fetchHttpStream, fetchServerSentEvents, rpcStream, stream, 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';
|
|
@@ -196,6 +196,12 @@ function injectChat(options = {}) {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
let nextId$1 = 0;
|
|
199
|
+
// `TTransformed` infers from the `onResult` return position (a covariant
|
|
200
|
+
// inference site that works even for an optional nested property), which types
|
|
201
|
+
// the callback parameter as `TResult` and narrows `result`. Inferring the
|
|
202
|
+
// whole callback as a defaulted type parameter instead collapses to the
|
|
203
|
+
// default, leaving the parameter `any` — a hard error under `strict`. See
|
|
204
|
+
// issue #848.
|
|
199
205
|
function injectGeneration(options) {
|
|
200
206
|
assertInInjectionContext(injectGeneration);
|
|
201
207
|
const destroyRef = inject(DestroyRef);
|
|
@@ -215,7 +221,10 @@ function injectGeneration(options) {
|
|
|
215
221
|
framework: 'angular',
|
|
216
222
|
hookName: 'injectGeneration',
|
|
217
223
|
},
|
|
218
|
-
|
|
224
|
+
// The transform's raw return type (`TTransformed`) and the stored output
|
|
225
|
+
// (`TOutput`, with null/void/undefined stripped) are identical at runtime;
|
|
226
|
+
// the cast bridges the relationship that the conditional type hides.
|
|
227
|
+
onResult: ((r) => options.onResult?.(r)),
|
|
219
228
|
onError: (e) => options.onError?.(e),
|
|
220
229
|
onProgress: (p, m) => options.onProgress?.(p, m),
|
|
221
230
|
onChunk: (c) => options.onChunk?.(c),
|
|
@@ -377,6 +386,42 @@ function injectTranscription(options) {
|
|
|
377
386
|
};
|
|
378
387
|
}
|
|
379
388
|
|
|
389
|
+
function injectAudioRecorder(options = {}) {
|
|
390
|
+
assertInInjectionContext(injectAudioRecorder);
|
|
391
|
+
const destroyRef = inject(DestroyRef);
|
|
392
|
+
const recorder = new AudioRecorder({
|
|
393
|
+
...(options.audio !== undefined && { audio: options.audio }),
|
|
394
|
+
...(options.mimeType !== undefined && { mimeType: options.mimeType }),
|
|
395
|
+
...(options.onError !== undefined && { onError: options.onError }),
|
|
396
|
+
});
|
|
397
|
+
const isRecording = signal(false, ...(ngDevMode ? [{ debugName: "isRecording" }] : /* istanbul ignore next */ []));
|
|
398
|
+
const recording = signal(null, ...(ngDevMode ? [{ debugName: "recording" }] : /* istanbul ignore next */ []));
|
|
399
|
+
const unsubscribe = recorder.subscribe((state) => {
|
|
400
|
+
isRecording.set(state === 'recording');
|
|
401
|
+
});
|
|
402
|
+
destroyRef.onDestroy(() => {
|
|
403
|
+
unsubscribe();
|
|
404
|
+
recorder.cancel();
|
|
405
|
+
});
|
|
406
|
+
const stop = async () => {
|
|
407
|
+
const rawRecording = await recorder.stop();
|
|
408
|
+
const transformed = await options.onComplete?.(rawRecording);
|
|
409
|
+
// Only `undefined` (returning nothing) keeps the raw recording; a returned
|
|
410
|
+
// null is a real value, matching the inferred output type.
|
|
411
|
+
const output = transformed === undefined ? rawRecording : transformed;
|
|
412
|
+
recording.set(output);
|
|
413
|
+
return output;
|
|
414
|
+
};
|
|
415
|
+
return {
|
|
416
|
+
recording: recording.asReadonly(),
|
|
417
|
+
isRecording: isRecording.asReadonly(),
|
|
418
|
+
isSupported: AudioRecorder.isSupported(),
|
|
419
|
+
start: () => recorder.start(),
|
|
420
|
+
stop,
|
|
421
|
+
cancel: () => recorder.cancel(),
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
380
425
|
function injectSummarize(options) {
|
|
381
426
|
const devtools = {
|
|
382
427
|
...options.devtools,
|
|
@@ -400,6 +445,9 @@ function injectSummarize(options) {
|
|
|
400
445
|
}
|
|
401
446
|
|
|
402
447
|
let nextId = 0;
|
|
448
|
+
// `TTransformed` infers from the `onResult` return position so the callback
|
|
449
|
+
// parameter is typed as `VideoGenerateResult` and `result` narrows to the
|
|
450
|
+
// transform's return. See issue #848.
|
|
403
451
|
function injectGenerateVideo(options) {
|
|
404
452
|
assertInInjectionContext(injectGenerateVideo);
|
|
405
453
|
const destroyRef = inject(DestroyRef);
|
|
@@ -422,7 +470,10 @@ function injectGenerateVideo(options) {
|
|
|
422
470
|
hookName: 'injectGenerateVideo',
|
|
423
471
|
outputKind: 'video',
|
|
424
472
|
},
|
|
425
|
-
|
|
473
|
+
// The transform's raw return type (`TTransformed`) and the stored output
|
|
474
|
+
// (`TOutput`, with null/void/undefined stripped) are identical at runtime;
|
|
475
|
+
// the cast bridges the relationship that the conditional type hides.
|
|
476
|
+
onResult: ((r) => options.onResult?.(r)),
|
|
426
477
|
onError: (e) => options.onError?.(e),
|
|
427
478
|
onProgress: (p, m) => options.onProgress?.(p, m),
|
|
428
479
|
onChunk: (c) => options.onChunk?.(c),
|
|
@@ -477,5 +528,5 @@ function injectGenerateVideo(options) {
|
|
|
477
528
|
* Generated bundle index. Do not edit.
|
|
478
529
|
*/
|
|
479
530
|
|
|
480
|
-
export { injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription };
|
|
531
|
+
export { injectAudioRecorder, injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription };
|
|
481
532
|
//# sourceMappingURL=tanstack-ai-angular.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstack-ai-angular.mjs","sources":["../../src/internal/to-reactive.ts","../../src/inject-chat.ts","../../src/inject-generation.ts","../../src/inject-generate-image.ts","../../src/inject-generate-audio.ts","../../src/inject-generate-speech.ts","../../src/inject-transcription.ts","../../src/inject-summarize.ts","../../src/inject-generate-video.ts","../../src/index.ts","../../src/tanstack-ai-angular.ts"],"sourcesContent":["import { computed, isSignal } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\n/**\n * A value that may be supplied to `injectChat` either as a static value, an\n * Angular `Signal`, or a zero-arg getter. The getter form lets callers read\n * other signals so the option stays reactive.\n */\nexport type ReactiveOption<T> = T | Signal<T> | (() => T)\n\n/**\n * Normalize a {@link ReactiveOption} into a `Signal`-like getter `() => T`.\n *\n * - A `Signal` is returned as-is (already a getter that tracks reads).\n * - A zero-arg function is wrapped in `computed` so reads inside it are tracked.\n * - A plain value becomes a constant 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 SchemaInput,\n StreamChunk,\n} from '@tanstack/ai'\nimport type {\n ChatClientState,\n ConnectionStatus,\n InferredClientContext,\n StructuredOutputPart,\n} from '@tanstack/ai-client'\nimport type {\n DeepPartial,\n InjectChatOptions,\n InjectChatResult,\n MultimodalContent,\n UIMessage,\n} from './types'\n\nlet nextId = 0\n\nexport function injectChat<\n TTools extends ReadonlyArray<AnyClientTool> = any,\n TSchema extends SchemaInput | undefined = undefined,\n TContext = InferredClientContext<TTools>,\n>(\n options: InjectChatOptions<\n TTools,\n TSchema,\n TContext\n > = {} as InjectChatOptions<TTools, TSchema, TContext>,\n): InjectChatResult<TTools, TSchema> {\n 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\n // Reactive option sources. Plain values become constant computeds.\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n const forwardedPropsSource =\n options.forwardedProps !== undefined\n ? toReactive(options.forwardedProps)\n : undefined\n const contextSource =\n options.context !== undefined ? toReactive(options.context) : undefined\n const liveSource =\n options.live !== undefined ? toReactive(options.live) : undefined\n\n const transport = options.connection\n ? { connection: options.connection }\n : { fetcher: options.fetcher }\n\n const client = new ChatClient<TTools, TContext>({\n devtoolsBridgeFactory: createChatDevtoolsBridge,\n ...transport,\n id: clientId,\n ...(options.initialMessages !== undefined && {\n initialMessages: options.initialMessages,\n }),\n ...(options.persistence !== undefined && {\n persistence: options.persistence,\n }),\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.threadId !== undefined && { threadId: options.threadId }),\n ...(forwardedPropsSource !== undefined && {\n forwardedProps: forwardedPropsSource(),\n }),\n ...(contextSource !== undefined && { context: contextSource() }),\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectChat',\n outputKind: options.outputSchema ? 'structured' : 'chat',\n },\n onResponse: (response) => options.onResponse?.(response),\n onChunk: (chunk: StreamChunk) => options.onChunk?.(chunk),\n onFinish: (message) => options.onFinish?.(message),\n onError: (err) => options.onError?.(err),\n tools: options.tools,\n onCustomEvent: (eventType, data, context) =>\n options.onCustomEvent?.(eventType, data, context),\n ...(options.streamProcessor !== undefined && {\n streamProcessor: options.streamProcessor,\n }),\n onMessagesChange: (m: Array<UIMessage<TTools>>) => messages.set(m),\n onLoadingChange: (v: boolean) => isLoading.set(v),\n onStatusChange: (v: ChatClientState) => status.set(v),\n onErrorChange: (v: Error | undefined) => error.set(v),\n onSubscriptionChange: (v: boolean) => isSubscribed.set(v),\n onConnectionStatusChange: (v: ConnectionStatus) => connectionStatus.set(v),\n onSessionGeneratingChange: (v: boolean) => sessionGenerating.set(v),\n })\n\n messages.set(client.getMessages())\n\n // Sync reactive body / forwardedProps / context to the client.\n if (bodySource || forwardedPropsSource || contextSource) {\n effect(\n () => {\n const newBody = bodySource?.()\n const newForwardedProps = forwardedPropsSource?.()\n const newContext = contextSource?.()\n client.updateOptions({\n ...(newBody !== undefined && { body: newBody }),\n ...(newForwardedProps !== undefined && {\n forwardedProps: newForwardedProps,\n }),\n ...(newContext !== undefined && { context: newContext }),\n })\n },\n { injector },\n )\n }\n\n // Subscribe / unsubscribe based on reactive `live`.\n if (liveSource) {\n effect(\n () => {\n if (liveSource()) {\n client.subscribe()\n } else {\n client.unsubscribe()\n }\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n\n destroyRef.onDestroy(() => {\n if (liveSource?.()) {\n client.unsubscribe()\n } else {\n client.stop()\n }\n client.dispose()\n })\n\n // Active structured-output part = the one on the assistant message after the\n // latest user message. Ported from ai-vue/src/use-chat.ts.\n const activeStructuredPart = computed<StructuredOutputPart | null>(() => {\n const list = messages()\n let lastUserIndex = -1\n for (let i = list.length - 1; i >= 0; i--) {\n if (list[i]?.role === 'user') {\n lastUserIndex = i\n break\n }\n }\n if (lastUserIndex === -1) return null\n for (let i = list.length - 1; i > lastUserIndex; i--) {\n const m = list[i]\n if (m?.role !== 'assistant') continue\n const part = m.parts.find(\n (p): p is StructuredOutputPart => p.type === 'structured-output',\n )\n if (part) return part\n }\n return null\n })\n\n const partial = computed<Partial>(() => {\n const part = activeStructuredPart()\n if (!part) return {} as Partial\n const v = part.partial ?? part.data\n return (v ?? {}) as Partial\n })\n\n const final = computed<Final | null>(() => {\n const part = activeStructuredPart()\n if (!part || part.status !== 'complete') return null\n return part.data as Final\n })\n\n const sendMessage = async (content: string | MultimodalContent) => {\n await client.sendMessage(content)\n }\n const append = async (message: ModelMessage | UIMessage<TTools>) => {\n await client.append(message)\n }\n const reload = async () => {\n await client.reload()\n }\n const stop = () => client.stop()\n const clear = () => client.clear()\n const setMessages = (m: Array<UIMessage<TTools>>) =>\n client.setMessagesManually(m)\n const addToolResult = async (result: {\n toolCallId: string\n tool: string\n output: any\n state?: 'output-available' | 'output-error'\n errorText?: string\n }) => {\n await client.addToolResult(result)\n }\n const addToolApprovalResponse = async (response: {\n id: string\n approved: boolean\n }) => {\n await client.addToolApprovalResponse(response)\n }\n\n // eslint-disable-next-line no-restricted-syntax -- return shape diverges from conditional InjectChatResult<TTools, TSchema>; TS can't structurally narrow the TSchema-gated partial/final signals\n return {\n messages: messages.asReadonly(),\n sendMessage,\n append,\n reload,\n stop,\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n isSubscribed: isSubscribed.asReadonly(),\n connectionStatus: connectionStatus.asReadonly(),\n sessionGenerating: sessionGenerating.asReadonly(),\n setMessages,\n clear,\n addToolResult,\n addToolApprovalResponse,\n partial,\n final,\n } as unknown as InjectChatResult<TTools, TSchema>\n}\n","import { GenerationClient } from '@tanstack/ai-client'\nimport { createGenerationDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n 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 InferGenerationOutput,\n} from '@tanstack/ai-client'\nimport type { ReactiveOption } from './internal/to-reactive'\n\nlet nextId = 0\n\nexport interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {\n /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */\n connection?: ConnectConnectionAdapter\n /** Direct async function for one-shot generation (no streaming protocol needed) */\n fetcher?: GenerationFetcher<TInput, TResult>\n /** Unique identifier for this generation instance */\n id?: string\n /** Additional request body params. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * Callback when a result is received. Can optionally return a transformed value.\n *\n * - Return a non-null value to transform and store it as the result\n * - Return `null` to keep the previous result unchanged\n * - Return nothing (`void`) to store the raw result as-is\n */\n onResult?: (result: TResult) => TOutput | null | void\n /** Callback when an error occurs */\n onError?: (error: Error) => void\n /** Callback when progress is reported (0-100) */\n onProgress?: (progress: number, message?: string) => void\n /** Callback for each stream chunk (connect-based adapter mode only) */\n onChunk?: (chunk: StreamChunk) => void\n}\n\nexport interface InjectGenerationResult<TOutput> {\n /** Trigger a generation request */\n generate: (input: Record<string, any>) => Promise<void>\n /** The generation result, or null if not yet generated */\n result: Signal<TOutput | null>\n /** Whether a generation is currently in progress */\n isLoading: Signal<boolean>\n /** Current error, if any */\n error: Signal<Error | undefined>\n /** Current state of the generation client */\n status: Signal<GenerationClientState>\n /** Abort the current generation */\n stop: () => void\n /** Clear result, error, and return to idle */\n reset: () => void\n}\n\nexport function injectGeneration<\n TInput extends Record<string, any>,\n TResult,\n TOnResult extends ((result: TResult) => any) | undefined = undefined,\n>(\n options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerationResult<InferGenerationOutput<TResult, TOnResult>> {\n assertInInjectionContext(injectGeneration)\n\n type TOutput = InferGenerationOutput<TResult, TOnResult>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\n const clientId = options.id || `injectGeneration-${nextId++}`\n\n const result = signal<TOutput | null>(null)\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<GenerationClientState>('idle')\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const clientOptions: GenerationClientOptions<TInput, TResult, TOutput> = {\n id: clientId,\n ...(bodySource !== undefined && { body: bodySource() }),\n devtoolsBridgeFactory: createGenerationDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGeneration',\n },\n onResult: (r: TResult) => options.onResult?.(r),\n onError: (e: Error) => options.onError?.(e),\n onProgress: (p: number, m?: string) => options.onProgress?.(p, m),\n onChunk: (c: StreamChunk) => options.onChunk?.(c),\n onResultChange: (r: TOutput | null) => result.set(r),\n onLoadingChange: (l: boolean) => isLoading.set(l),\n onErrorChange: (e: Error | undefined) => error.set(e),\n onStatusChange: (s: GenerationClientState) => status.set(s),\n }\n\n let client: GenerationClient<TInput, TResult, TOutput>\n if (options.connection) {\n client = new GenerationClient({\n ...clientOptions,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new GenerationClient({\n ...clientOptions,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGeneration requires either a connection or fetcher option',\n )\n }\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({ body: bodySource() })\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n destroyRef.onDestroy(() => client.dispose())\n\n return {\n generate: ((input: TInput) => client.generate(input)) as (\n input: Record<string, any>,\n ) => Promise<void>,\n result: result.asReadonly(),\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n stop: () => client.stop(),\n reset: () => client.reset(),\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { ImageGenerationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n ImageGenerateInput,\n InferGenerationOutput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<\n InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: ImageGenerationResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateImageResult<TOutput = ImageGenerationResult> {\n generate: (input: ImageGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateImage<\n TOnResult extends ((result: ImageGenerationResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectGenerateImageOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateImageResult<\n InferGenerationOutput<ImageGenerationResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateImage',\n outputKind: 'image' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<ImageGenerateInput, ImageGenerationResult, TOnResult>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: ImageGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { AudioGenerationResult, StreamChunk } from '@tanstack/ai'\nimport type {\n AIDevtoolsDisplayOptions,\n AudioGenerateInput,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n InferGenerationOutput,\n} from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { ReactiveOption } from './internal/to-reactive'\n\n/**\n * Options for the injectGenerateAudio injectable.\n *\n * @template TOutput - The output type after optional transform (defaults to AudioGenerationResult)\n */\nexport interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> {\n /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */\n connection?: ConnectConnectionAdapter\n /** Direct async function for audio generation */\n fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>\n /** Unique identifier for this generation instance */\n id?: string\n /** Additional body parameters to send with connect-based adapter requests. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * Callback when audio is generated. Can optionally return a transformed value.\n *\n * - Return a non-null value to transform and store it as the result\n * - Return `null` to keep the previous result unchanged\n * - Return nothing (`void`) to store the raw result as-is\n */\n onResult?: (result: AudioGenerationResult) => TOutput | null | void\n /** Callback when an error occurs */\n onError?: (error: Error) => void\n /** Callback when progress is reported (0-100) */\n onProgress?: (progress: number, message?: string) => void\n /** Callback for each stream chunk (connect-based adapter mode only) */\n onChunk?: (chunk: StreamChunk) => void\n}\n\n/**\n * Return type for the injectGenerateAudio injectable.\n *\n * @template TOutput - The output type (after optional transform)\n */\nexport interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> {\n /** Trigger audio generation */\n generate: (input: AudioGenerateInput) => Promise<void>\n /** The generation result containing audio, or null */\n result: Signal<TOutput | null>\n /** Whether generation is in progress */\n isLoading: Signal<boolean>\n /** Current error, if any */\n error: Signal<Error | undefined>\n /** Current state of the generation */\n status: Signal<GenerationClientState>\n /** Abort the current generation */\n stop: () => void\n /** Clear result, error, and return to idle */\n reset: () => void\n}\n\n/**\n * Angular injectable for generating audio (music, sound effects) using AI models.\n *\n * @example\n * ```typescript\n * import { Component } from '@angular/core'\n * import { injectGenerateAudio } from '@tanstack/ai-angular'\n * import { fetchServerSentEvents } from '@tanstack/ai-client'\n *\n * @Component({\n * selector: 'app-audio',\n * template: `\n * <button (click)=\"generate({ prompt: 'An upbeat electronic track', duration: 10 })\">\n * Generate\n * </button>\n * @if (result()) {\n * <audio [src]=\"result()!.audio.url\" controls></audio>\n * }\n * `,\n * })\n * export class AudioComponent {\n * private gen = injectGenerateAudio({\n * connection: fetchServerSentEvents('/api/generate/audio'),\n * })\n *\n * generate = this.gen.generate\n * result = this.gen.result\n * isLoading = this.gen.isLoading\n * }\n * ```\n */\nexport function injectGenerateAudio<\n TOnResult extends ((result: AudioGenerationResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectGenerateAudioOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateAudioResult<\n InferGenerationOutput<AudioGenerationResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateAudio',\n outputKind: 'audio' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<AudioGenerateInput, AudioGenerationResult, TOnResult>({\n ...options,\n devtools,\n })\n\n return {\n generate: generate as (input: AudioGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { TTSResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutput,\n SpeechGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<\n InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: TTSResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateSpeechResult<TOutput = TTSResult> {\n generate: (input: SpeechGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateSpeech<\n TOnResult extends ((result: TTSResult) => any) | undefined = undefined,\n>(\n options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateSpeechResult<InferGenerationOutput<TTSResult, TOnResult>> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectGenerateSpeech',\n outputKind: 'audio' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<SpeechGenerateInput, TTSResult, TOnResult>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: SpeechGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { TranscriptionResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutput,\n TranscriptionGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<\n InjectGenerationOptions<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TOutput\n >,\n 'onResult'\n> & {\n onResult?: (result: TranscriptionResult) => TOutput | null | void\n}\n\nexport interface InjectTranscriptionResult<TOutput = TranscriptionResult> {\n generate: (input: TranscriptionGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectTranscription<\n TOnResult extends ((result: TranscriptionResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectTranscriptionOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectTranscriptionResult<\n InferGenerationOutput<TranscriptionResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectTranscription',\n outputKind: 'text' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TOnResult\n >({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: TranscriptionGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { SummarizationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutput,\n SummarizeGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<\n InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: SummarizationResult) => TOutput | null | void\n}\n\nexport interface InjectSummarizeResult<TOutput = SummarizationResult> {\n generate: (input: SummarizeGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectSummarize<\n TOnResult extends ((result: SummarizationResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectSummarizeOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectSummarizeResult<\n InferGenerationOutput<SummarizationResult, TOnResult>\n> {\n const devtools = {\n ...options.devtools,\n framework: 'angular' as const,\n hookName: 'injectSummarize',\n outputKind: 'text' as const,\n }\n const { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<SummarizeGenerateInput, SummarizationResult, TOnResult>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: SummarizeGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { VideoGenerationClient } from '@tanstack/ai-client'\nimport { createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n 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 InferGenerationOutput,\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 onResult?: (result: VideoGenerateResult) => TOutput | null | void\n onError?: (error: Error) => void\n onProgress?: (progress: number, message?: string) => void\n onJobCreated?: (jobId: string) => void\n onStatusUpdate?: (status: VideoStatusInfo) => void\n onChunk?: (chunk: StreamChunk) => void\n}\n\nexport interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {\n generate: (input: VideoGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n jobId: Signal<string | null>\n videoStatus: Signal<VideoStatusInfo | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateVideo<\n TOnResult extends ((result: VideoGenerateResult) => any) | undefined =\n undefined,\n>(\n options: Omit<InjectGenerateVideoOptions, 'onResult'> & {\n onResult?: TOnResult\n },\n): InjectGenerateVideoResult<\n InferGenerationOutput<VideoGenerateResult, TOnResult>\n> {\n assertInInjectionContext(injectGenerateVideo)\n\n type TOutput = InferGenerationOutput<VideoGenerateResult, TOnResult>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\n const clientId = options.id || `injectGenerateVideo-${nextId++}`\n\n const result = signal<TOutput | null>(null)\n const jobId = signal<string | null>(null)\n const videoStatus = signal<VideoStatusInfo | null>(null)\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<GenerationClientState>('idle')\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const baseOptions = {\n id: clientId,\n ...(bodySource !== undefined && { body: bodySource() }),\n devtoolsBridgeFactory: createVideoDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateVideo',\n outputKind: 'video' as const,\n },\n onResult: (r: VideoGenerateResult) => options.onResult?.(r),\n onError: (e: Error) => options.onError?.(e),\n onProgress: (p: number, m?: string) => options.onProgress?.(p, m),\n onChunk: (c: StreamChunk) => options.onChunk?.(c),\n onJobCreated: (id: string) => options.onJobCreated?.(id),\n onStatusUpdate: (s: VideoStatusInfo) => options.onStatusUpdate?.(s),\n onResultChange: (r: TOutput | null) => result.set(r),\n onLoadingChange: (l: boolean) => isLoading.set(l),\n onErrorChange: (e: Error | undefined) => error.set(e),\n onStatusChange: (s: GenerationClientState) => status.set(s),\n onJobIdChange: (id: string | null) => jobId.set(id),\n onVideoStatusChange: (s: VideoStatusInfo | null) => videoStatus.set(s),\n }\n\n let client: VideoGenerationClient<TOutput>\n if (options.connection) {\n client = new VideoGenerationClient({\n ...baseOptions,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new VideoGenerationClient({\n ...baseOptions,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGenerateVideo requires either a connection or fetcher option',\n )\n }\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({ body: bodySource() })\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n destroyRef.onDestroy(() => client.dispose())\n\n return {\n generate: (input: VideoGenerateInput) => client.generate(input),\n result: result.asReadonly(),\n jobId: jobId.asReadonly(),\n videoStatus: videoStatus.asReadonly(),\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n stop: () => client.stop(),\n reset: () => client.reset(),\n }\n}\n","// Chat\nexport { injectChat } from './inject-chat'\n\n// Generation\nexport { injectGeneration } from './inject-generation'\nexport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\n// Generate Image\nexport { injectGenerateImage } from './inject-generate-image'\nexport type {\n InjectGenerateImageOptions,\n InjectGenerateImageResult,\n} from './inject-generate-image'\n\n// Generate Audio\nexport { injectGenerateAudio } from './inject-generate-audio'\nexport type {\n InjectGenerateAudioOptions,\n InjectGenerateAudioResult,\n} from './inject-generate-audio'\n\n// Generate Speech\nexport { injectGenerateSpeech } from './inject-generate-speech'\nexport type {\n InjectGenerateSpeechOptions,\n InjectGenerateSpeechResult,\n} from './inject-generate-speech'\n\n// Transcription\nexport { injectTranscription } from './inject-transcription'\nexport type {\n InjectTranscriptionOptions,\n InjectTranscriptionResult,\n} from './inject-transcription'\n\n// Summarize\nexport { injectSummarize } from './inject-summarize'\nexport type {\n InjectSummarizeOptions,\n InjectSummarizeResult,\n} from './inject-summarize'\n\n// Generate Video\nexport { injectGenerateVideo } from './inject-generate-video'\nexport type {\n InjectGenerateVideoOptions,\n InjectGenerateVideoResult,\n} from './inject-generate-video'\n\n// Types from ./types\nexport type {\n DeepPartial,\n InjectChatOptions,\n InjectChatResult,\n UIMessage,\n ChatRequestBody,\n MultimodalContent,\n ReactiveOption,\n} from './types'\n\n// Re-export from @tanstack/ai-client for convenience\nexport {\n fetchServerSentEvents,\n fetchHttpStream,\n xhrServerSentEvents,\n xhrHttpStream,\n stream,\n rpcStream,\n createChatClientOptions,\n type ConnectionAdapter,\n type ConnectConnectionAdapter,\n type SubscribeConnectionAdapter,\n type RunAgentInputContext,\n type FetchConnectionOptions,\n type XhrConnectionOptions,\n type InferChatMessages,\n type GenerationClientState,\n type ImageGenerateInput,\n type AudioGenerateInput,\n type SpeechGenerateInput,\n type TranscriptionGenerateInput,\n type SummarizeGenerateInput,\n type VideoGenerateInput,\n type VideoGenerateResult,\n type VideoStatusInfo,\n} from '@tanstack/ai-client'\n","/**\n * Generated bundle index.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UAAU,EAAE;AAC3B,QAAA,IAAI,EAAE,MAAM,MAAM,CAAC,IAAI,EAAE;AACzB,QAAA,KAAK,EAAE,MAAM,MAAM,CAAC,KAAK,EAAE;KAC5B;AACH;;AClJA;;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 InferSchemaType,\n ModelMessage,\n SchemaInput,\n StreamChunk,\n} from '@tanstack/ai'\nimport type {\n ChatClientState,\n ConnectionStatus,\n InferredClientContext,\n StructuredOutputPart,\n} from '@tanstack/ai-client'\nimport type {\n DeepPartial,\n InjectChatOptions,\n InjectChatResult,\n MultimodalContent,\n UIMessage,\n} from './types'\n\nlet nextId = 0\n\nexport function injectChat<\n TTools extends ReadonlyArray<AnyClientTool> = any,\n TSchema extends SchemaInput | undefined = undefined,\n TContext = InferredClientContext<TTools>,\n>(\n options: InjectChatOptions<\n TTools,\n TSchema,\n TContext\n > = {} as InjectChatOptions<TTools, TSchema, TContext>,\n): InjectChatResult<TTools, TSchema> {\n 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\n // Reactive option sources. Plain values become constant computeds.\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n const forwardedPropsSource =\n options.forwardedProps !== undefined\n ? toReactive(options.forwardedProps)\n : undefined\n const contextSource =\n options.context !== undefined ? toReactive(options.context) : undefined\n const liveSource =\n options.live !== undefined ? toReactive(options.live) : undefined\n\n const transport = options.connection\n ? { connection: options.connection }\n : { fetcher: options.fetcher }\n\n const client = new ChatClient<TTools, TContext>({\n devtoolsBridgeFactory: createChatDevtoolsBridge,\n ...transport,\n id: clientId,\n ...(options.initialMessages !== undefined && {\n initialMessages: options.initialMessages,\n }),\n ...(options.persistence !== undefined && {\n persistence: options.persistence,\n }),\n ...(bodySource !== undefined && { body: bodySource() }),\n ...(options.threadId !== undefined && { threadId: options.threadId }),\n ...(forwardedPropsSource !== undefined && {\n forwardedProps: forwardedPropsSource(),\n }),\n ...(contextSource !== undefined && { context: contextSource() }),\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectChat',\n outputKind: options.outputSchema ? 'structured' : 'chat',\n },\n onResponse: (response) => options.onResponse?.(response),\n onChunk: (chunk: StreamChunk) => options.onChunk?.(chunk),\n onFinish: (message) => options.onFinish?.(message),\n onError: (err) => options.onError?.(err),\n tools: options.tools,\n onCustomEvent: (eventType, data, context) =>\n options.onCustomEvent?.(eventType, data, context),\n ...(options.streamProcessor !== undefined && {\n streamProcessor: options.streamProcessor,\n }),\n onMessagesChange: (m: Array<UIMessage<TTools>>) => messages.set(m),\n onLoadingChange: (v: boolean) => isLoading.set(v),\n onStatusChange: (v: ChatClientState) => status.set(v),\n onErrorChange: (v: Error | undefined) => error.set(v),\n onSubscriptionChange: (v: boolean) => isSubscribed.set(v),\n onConnectionStatusChange: (v: ConnectionStatus) => connectionStatus.set(v),\n onSessionGeneratingChange: (v: boolean) => sessionGenerating.set(v),\n })\n\n messages.set(client.getMessages())\n\n // Sync reactive body / forwardedProps / context to the client.\n if (bodySource || forwardedPropsSource || contextSource) {\n effect(\n () => {\n const newBody = bodySource?.()\n const newForwardedProps = forwardedPropsSource?.()\n const newContext = contextSource?.()\n client.updateOptions({\n ...(newBody !== undefined && { body: newBody }),\n ...(newForwardedProps !== undefined && {\n forwardedProps: newForwardedProps,\n }),\n ...(newContext !== undefined && { context: newContext }),\n })\n },\n { injector },\n )\n }\n\n // Subscribe / unsubscribe based on reactive `live`.\n if (liveSource) {\n effect(\n () => {\n if (liveSource()) {\n client.subscribe()\n } else {\n client.unsubscribe()\n }\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n\n destroyRef.onDestroy(() => {\n if (liveSource?.()) {\n client.unsubscribe()\n } else {\n client.stop()\n }\n client.dispose()\n })\n\n // Active structured-output part = the one on the assistant message after the\n // latest user message. Ported from ai-vue/src/use-chat.ts.\n const activeStructuredPart = computed<StructuredOutputPart | null>(() => {\n const list = messages()\n let lastUserIndex = -1\n for (let i = list.length - 1; i >= 0; i--) {\n if (list[i]?.role === 'user') {\n lastUserIndex = i\n break\n }\n }\n if (lastUserIndex === -1) return null\n for (let i = list.length - 1; i > lastUserIndex; i--) {\n const m = list[i]\n if (m?.role !== 'assistant') continue\n const part = m.parts.find(\n (p): p is StructuredOutputPart => p.type === 'structured-output',\n )\n if (part) return part\n }\n return null\n })\n\n const partial = computed<Partial>(() => {\n const part = activeStructuredPart()\n if (!part) return {} as Partial\n const v = part.partial ?? part.data\n return (v ?? {}) as Partial\n })\n\n const final = computed<Final | null>(() => {\n const part = activeStructuredPart()\n if (!part || part.status !== 'complete') return null\n return part.data as Final\n })\n\n const sendMessage = async (content: string | MultimodalContent) => {\n await client.sendMessage(content)\n }\n const append = async (message: ModelMessage | UIMessage<TTools>) => {\n await client.append(message)\n }\n const reload = async () => {\n await client.reload()\n }\n const stop = () => client.stop()\n const clear = () => client.clear()\n const setMessages = (m: Array<UIMessage<TTools>>) =>\n client.setMessagesManually(m)\n const addToolResult = async (result: {\n toolCallId: string\n tool: string\n output: any\n state?: 'output-available' | 'output-error'\n errorText?: string\n }) => {\n await client.addToolResult(result)\n }\n const addToolApprovalResponse = async (response: {\n id: string\n approved: boolean\n }) => {\n await client.addToolApprovalResponse(response)\n }\n\n // eslint-disable-next-line no-restricted-syntax -- return shape diverges from conditional InjectChatResult<TTools, TSchema>; TS can't structurally narrow the TSchema-gated partial/final signals\n return {\n messages: messages.asReadonly(),\n sendMessage,\n append,\n reload,\n stop,\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n isSubscribed: isSubscribed.asReadonly(),\n connectionStatus: connectionStatus.asReadonly(),\n sessionGenerating: sessionGenerating.asReadonly(),\n setMessages,\n clear,\n addToolResult,\n addToolApprovalResponse,\n partial,\n final,\n } as unknown as InjectChatResult<TTools, TSchema>\n}\n","import { GenerationClient } from '@tanstack/ai-client'\nimport { createGenerationDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n 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 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 /** Unique identifier for this generation instance */\n id?: string\n /** Additional request body params. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * Callback when a result is received. Can optionally return a transformed value.\n *\n * - Return a non-null value to transform and store it as the result\n * - Return `null` to keep the previous result unchanged\n * - Return nothing (`void`) to store the raw result as-is\n */\n onResult?: (result: TResult) => TOutput | null | void\n /** Callback when an error occurs */\n onError?: (error: Error) => void\n /** Callback when progress is reported (0-100) */\n onProgress?: (progress: number, message?: string) => void\n /** Callback for each stream chunk (connect-based adapter mode only) */\n onChunk?: (chunk: StreamChunk) => void\n}\n\nexport interface InjectGenerationResult<TOutput> {\n /** Trigger a generation request */\n generate: (input: Record<string, any>) => Promise<void>\n /** The generation result, or null if not yet generated */\n result: Signal<TOutput | null>\n /** Whether a generation is currently in progress */\n isLoading: Signal<boolean>\n /** Current error, if any */\n error: Signal<Error | undefined>\n /** Current state of the generation client */\n status: Signal<GenerationClientState>\n /** Abort the current generation */\n stop: () => void\n /** Clear result, error, and return to idle */\n reset: () => void\n}\n\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<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {\n onResult?: (result: TResult) => TTransformed\n },\n): InjectGenerationResult<\n InferGenerationOutputFromReturn<TResult, TTransformed>\n> {\n assertInInjectionContext(injectGeneration)\n\n type TOutput = InferGenerationOutputFromReturn<TResult, TTransformed>\n\n const destroyRef = inject(DestroyRef)\n const injector = inject(Injector)\n const clientId = options.id || `injectGeneration-${nextId++}`\n\n const result = signal<TOutput | null>(null)\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<GenerationClientState>('idle')\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const clientOptions: GenerationClientOptions<TInput, TResult, TOutput> = {\n id: clientId,\n ...(bodySource !== undefined && { body: bodySource() }),\n devtoolsBridgeFactory: createGenerationDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGeneration',\n },\n // 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) => options.onError?.(e),\n onProgress: (p: number, m?: string) => options.onProgress?.(p, m),\n onChunk: (c: StreamChunk) => options.onChunk?.(c),\n onResultChange: (r: TOutput | null) => result.set(r),\n onLoadingChange: (l: boolean) => isLoading.set(l),\n onErrorChange: (e: Error | undefined) => error.set(e),\n onStatusChange: (s: GenerationClientState) => status.set(s),\n }\n\n let client: GenerationClient<TInput, TResult, TOutput>\n if (options.connection) {\n client = new GenerationClient({\n ...clientOptions,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new GenerationClient({\n ...clientOptions,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGeneration requires either a connection or fetcher option',\n )\n }\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({ body: bodySource() })\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n destroyRef.onDestroy(() => client.dispose())\n\n return {\n generate: ((input: TInput) => client.generate(input)) as (\n input: Record<string, any>,\n ) => Promise<void>,\n result: result.asReadonly(),\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n stop: () => client.stop(),\n reset: () => client.reset(),\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { ImageGenerationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n ImageGenerateInput,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<\n InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: ImageGenerationResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateImageResult<TOutput = ImageGenerationResult> {\n generate: (input: ImageGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateImage<TTransformed = void>(\n options: Omit<InjectGenerateImageOptions, 'onResult'> & {\n onResult?: (result: ImageGenerationResult) => TTransformed\n },\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 { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<ImageGenerateInput, ImageGenerationResult, TTransformed>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: ImageGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { AudioGenerationResult, StreamChunk } from '@tanstack/ai'\nimport type {\n AIDevtoolsDisplayOptions,\n AudioGenerateInput,\n ConnectConnectionAdapter,\n GenerationClientState,\n GenerationFetcher,\n InferGenerationOutputFromReturn,\n} from '@tanstack/ai-client'\nimport type { Signal } from '@angular/core'\nimport type { ReactiveOption } from './internal/to-reactive'\n\n/**\n * Options for the injectGenerateAudio injectable.\n *\n * @template TOutput - The output type after optional transform (defaults to AudioGenerationResult)\n */\nexport interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> {\n /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */\n connection?: ConnectConnectionAdapter\n /** Direct async function for audio generation */\n fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>\n /** Unique identifier for this generation instance */\n id?: string\n /** Additional body parameters to send with connect-based adapter requests. Reactive. */\n body?: ReactiveOption<Record<string, any>>\n /** Display options for TanStack AI Devtools. */\n devtools?: AIDevtoolsDisplayOptions\n /**\n * Callback when audio is generated. Can optionally return a transformed value.\n *\n * - Return a non-null value to transform and store it as the result\n * - Return `null` to keep the previous result unchanged\n * - Return nothing (`void`) to store the raw result as-is\n */\n onResult?: (result: AudioGenerationResult) => TOutput | null | void\n /** Callback when an error occurs */\n onError?: (error: Error) => void\n /** Callback when progress is reported (0-100) */\n onProgress?: (progress: number, message?: string) => void\n /** Callback for each stream chunk (connect-based adapter mode only) */\n onChunk?: (chunk: StreamChunk) => void\n}\n\n/**\n * Return type for the injectGenerateAudio injectable.\n *\n * @template TOutput - The output type (after optional transform)\n */\nexport interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> {\n /** Trigger audio generation */\n generate: (input: AudioGenerateInput) => Promise<void>\n /** The generation result containing audio, or null */\n result: Signal<TOutput | null>\n /** Whether generation is in progress */\n isLoading: Signal<boolean>\n /** Current error, if any */\n error: Signal<Error | undefined>\n /** Current state of the generation */\n status: Signal<GenerationClientState>\n /** Abort the current generation */\n stop: () => void\n /** Clear result, error, and return to idle */\n reset: () => void\n}\n\n/**\n * Angular injectable for generating audio (music, sound effects) using AI models.\n *\n * @example\n * ```typescript\n * import { Component } from '@angular/core'\n * import { injectGenerateAudio } from '@tanstack/ai-angular'\n * import { fetchServerSentEvents } from '@tanstack/ai-client'\n *\n * @Component({\n * selector: 'app-audio',\n * template: `\n * <button (click)=\"generate({ prompt: 'An upbeat electronic track', duration: 10 })\">\n * Generate\n * </button>\n * @if (result()) {\n * <audio [src]=\"result()!.audio.url\" controls></audio>\n * }\n * `,\n * })\n * export class AudioComponent {\n * private gen = injectGenerateAudio({\n * connection: fetchServerSentEvents('/api/generate/audio'),\n * })\n *\n * generate = this.gen.generate\n * result = this.gen.result\n * isLoading = this.gen.isLoading\n * }\n * ```\n */\nexport function injectGenerateAudio<TTransformed = void>(\n options: Omit<InjectGenerateAudioOptions, 'onResult'> & {\n onResult?: (result: AudioGenerationResult) => TTransformed\n },\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 { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<AudioGenerateInput, AudioGenerationResult, TTransformed>({\n ...options,\n devtools,\n })\n\n return {\n generate: generate as (input: AudioGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { TTSResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutputFromReturn,\n SpeechGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<\n InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: TTSResult) => TOutput | null | void\n}\n\nexport interface InjectGenerateSpeechResult<TOutput = TTSResult> {\n generate: (input: SpeechGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectGenerateSpeech<TTransformed = void>(\n options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {\n onResult?: (result: TTSResult) => TTransformed\n },\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 { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<SpeechGenerateInput, TTSResult, TTransformed>({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: SpeechGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { injectGeneration } from './inject-generation'\nimport type { Signal } from '@angular/core'\nimport type { TranscriptionResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutputFromReturn,\n TranscriptionGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<\n InjectGenerationOptions<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TOutput\n >,\n 'onResult'\n> & {\n onResult?: (result: TranscriptionResult) => TOutput | null | void\n}\n\nexport interface InjectTranscriptionResult<TOutput = TranscriptionResult> {\n generate: (input: TranscriptionGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectTranscription<TTransformed = void>(\n options: Omit<InjectTranscriptionOptions, 'onResult'> & {\n onResult?: (result: TranscriptionResult) => TTransformed\n },\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 { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<\n TranscriptionGenerateInput,\n TranscriptionResult,\n TTransformed\n >({\n ...options,\n devtools,\n })\n return {\n generate: generate as (input: TranscriptionGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import {\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 type { Signal } from '@angular/core'\nimport type { SummarizationResult } from '@tanstack/ai'\nimport type {\n GenerationClientState,\n InferGenerationOutputFromReturn,\n SummarizeGenerateInput,\n} from '@tanstack/ai-client'\nimport type { InjectGenerationOptions } from './inject-generation'\n\nexport type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<\n InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>,\n 'onResult'\n> & {\n onResult?: (result: SummarizationResult) => TOutput | null | void\n}\n\nexport interface InjectSummarizeResult<TOutput = SummarizationResult> {\n generate: (input: SummarizeGenerateInput) => Promise<void>\n result: Signal<TOutput | null>\n isLoading: Signal<boolean>\n error: Signal<Error | undefined>\n status: Signal<GenerationClientState>\n stop: () => void\n reset: () => void\n}\n\nexport function injectSummarize<TTransformed = void>(\n options: Omit<InjectSummarizeOptions, 'onResult'> & {\n onResult?: (result: SummarizationResult) => TTransformed\n },\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 { generate, result, isLoading, error, status, stop, reset } =\n injectGeneration<SummarizeGenerateInput, SummarizationResult, TTransformed>(\n {\n ...options,\n devtools,\n },\n )\n return {\n generate: generate as (input: SummarizeGenerateInput) => Promise<void>,\n result,\n isLoading,\n error,\n status,\n stop,\n reset,\n }\n}\n","import { VideoGenerationClient } from '@tanstack/ai-client'\nimport { createVideoDevtoolsBridge } from '@tanstack/ai-client/devtools'\nimport {\n DestroyRef,\n Injector,\n afterNextRender,\n 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 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 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\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<InjectGenerateVideoOptions, 'onResult'> & {\n onResult?: (result: VideoGenerateResult) => TTransformed\n },\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 const clientId = options.id || `injectGenerateVideo-${nextId++}`\n\n const result = signal<TOutput | null>(null)\n const jobId = signal<string | null>(null)\n const videoStatus = signal<VideoStatusInfo | null>(null)\n const isLoading = signal(false)\n const error = signal<Error | undefined>(undefined)\n const status = signal<GenerationClientState>('idle')\n\n const bodySource =\n options.body !== undefined ? toReactive(options.body) : undefined\n\n const baseOptions = {\n id: clientId,\n ...(bodySource !== undefined && { body: bodySource() }),\n devtoolsBridgeFactory: createVideoDevtoolsBridge,\n devtools: {\n ...options.devtools,\n framework: 'angular',\n hookName: 'injectGenerateVideo',\n outputKind: 'video' as const,\n },\n // 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) => options.onError?.(e),\n onProgress: (p: number, m?: string) => options.onProgress?.(p, m),\n onChunk: (c: StreamChunk) => options.onChunk?.(c),\n onJobCreated: (id: string) => options.onJobCreated?.(id),\n onStatusUpdate: (s: VideoStatusInfo) => options.onStatusUpdate?.(s),\n onResultChange: (r: TOutput | null) => result.set(r),\n onLoadingChange: (l: boolean) => isLoading.set(l),\n onErrorChange: (e: Error | undefined) => error.set(e),\n onStatusChange: (s: GenerationClientState) => status.set(s),\n onJobIdChange: (id: string | null) => jobId.set(id),\n onVideoStatusChange: (s: VideoStatusInfo | null) => videoStatus.set(s),\n }\n\n let client: VideoGenerationClient<TOutput>\n if (options.connection) {\n client = new VideoGenerationClient({\n ...baseOptions,\n connection: options.connection,\n })\n } else if (options.fetcher) {\n client = new VideoGenerationClient({\n ...baseOptions,\n fetcher: options.fetcher,\n })\n } else {\n throw new Error(\n 'injectGenerateVideo requires either a connection or fetcher option',\n )\n }\n\n if (bodySource) {\n effect(\n () => {\n client.updateOptions({ body: bodySource() })\n },\n { injector },\n )\n }\n\n afterNextRender(() => client.mountDevtools(), { injector })\n destroyRef.onDestroy(() => client.dispose())\n\n return {\n generate: (input: VideoGenerateInput) => client.generate(input),\n result: result.asReadonly(),\n jobId: jobId.asReadonly(),\n videoStatus: videoStatus.asReadonly(),\n isLoading: isLoading.asReadonly(),\n error: error.asReadonly(),\n status: status.asReadonly(),\n stop: () => client.stop(),\n reset: () => client.reset(),\n }\n}\n","// Chat\nexport { injectChat } from './inject-chat'\n\n// Generation\nexport { injectGeneration } from './inject-generation'\nexport type {\n InjectGenerationOptions,\n InjectGenerationResult,\n} from './inject-generation'\n\n// Generate Image\nexport { injectGenerateImage } from './inject-generate-image'\nexport type {\n InjectGenerateImageOptions,\n InjectGenerateImageResult,\n} from './inject-generate-image'\n\n// Generate Audio\nexport { injectGenerateAudio } from './inject-generate-audio'\nexport type {\n InjectGenerateAudioOptions,\n InjectGenerateAudioResult,\n} from './inject-generate-audio'\n\n// Generate Speech\nexport { injectGenerateSpeech } from './inject-generate-speech'\nexport type {\n InjectGenerateSpeechOptions,\n InjectGenerateSpeechResult,\n} from './inject-generate-speech'\n\n// Transcription\nexport { injectTranscription } from './inject-transcription'\nexport type {\n InjectTranscriptionOptions,\n InjectTranscriptionResult,\n} from './inject-transcription'\n\n// 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 ReactiveOption,\n} from './types'\n\n// Re-export from @tanstack/ai-client for convenience\nexport {\n fetchServerSentEvents,\n fetchHttpStream,\n xhrServerSentEvents,\n xhrHttpStream,\n stream,\n rpcStream,\n createChatClientOptions,\n type ConnectionAdapter,\n type ConnectConnectionAdapter,\n type SubscribeConnectionAdapter,\n type RunAgentInputContext,\n type FetchConnectionOptions,\n type XhrConnectionOptions,\n type InferChatMessages,\n type GenerationClientState,\n type ImageGenerateInput,\n type AudioGenerateInput,\n type SpeechGenerateInput,\n type TranscriptionGenerateInput,\n type SummarizeGenerateInput,\n type VideoGenerateInput,\n type VideoGenerateResult,\n type VideoStatusInfo,\n} from '@tanstack/ai-client'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["nextId"],"mappings":";;;;;AAUA;;;;;;AAMG;AACG,SAAU,UAAU,CAAI,KAAwB,EAAA;AACpD,IAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;AACnB,QAAA,OAAO,KAAK;IACd;AACA,IAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,QAAA,OAAO,QAAQ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AAE;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;KAC5B;AACH;;AC1JA;;ACAA;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyClientTool, SchemaInput, ModelMessage, InferSchemaType, StreamChunk, ImageGenerationResult, AudioGenerationResult, TTSResult, TranscriptionResult, SummarizationResult } from '@tanstack/ai';
|
|
2
|
-
import { InferredClientContext, DistributedOmit, ChatClientOptions, AIDevtoolsDisplayOptions, ClientContextOptionFromTools, UIMessage, MultimodalContent, ChatClientState, ConnectionStatus, ConnectConnectionAdapter, GenerationFetcher, GenerationClientState,
|
|
2
|
+
import { InferredClientContext, DistributedOmit, ChatClientOptions, AIDevtoolsDisplayOptions, ClientContextOptionFromTools, UIMessage, MultimodalContent, ChatClientState, ConnectionStatus, ConnectConnectionAdapter, GenerationFetcher, GenerationClientState, InferGenerationOutputFromReturn, ImageGenerateInput, AudioGenerateInput, SpeechGenerateInput, TranscriptionGenerateInput, AudioRecorderOptions, AudioRecording, InferAudioRecordingOutput, SummarizeGenerateInput, VideoGenerateResult, VideoGenerateInput, VideoStatusInfo } from '@tanstack/ai-client';
|
|
3
3
|
export { AudioGenerateInput, ChatRequestBody, ConnectConnectionAdapter, ConnectionAdapter, FetchConnectionOptions, GenerationClientState, ImageGenerateInput, InferChatMessages, MultimodalContent, RunAgentInputContext, SpeechGenerateInput, SubscribeConnectionAdapter, SummarizeGenerateInput, TranscriptionGenerateInput, UIMessage, VideoGenerateInput, VideoGenerateResult, VideoStatusInfo, XhrConnectionOptions, createChatClientOptions, fetchHttpStream, fetchServerSentEvents, rpcStream, stream, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
|
|
4
4
|
import { Signal } from '@angular/core';
|
|
5
5
|
|
|
@@ -137,9 +137,9 @@ interface InjectGenerationResult<TOutput> {
|
|
|
137
137
|
/** Clear result, error, and return to idle */
|
|
138
138
|
reset: () => void;
|
|
139
139
|
}
|
|
140
|
-
declare function injectGeneration<TInput extends Record<string, any>, TResult,
|
|
141
|
-
onResult?:
|
|
142
|
-
}): InjectGenerationResult<
|
|
140
|
+
declare function injectGeneration<TInput extends Record<string, any>, TResult, TTransformed = void>(options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {
|
|
141
|
+
onResult?: (result: TResult) => TTransformed;
|
|
142
|
+
}): InjectGenerationResult<InferGenerationOutputFromReturn<TResult, TTransformed>>;
|
|
143
143
|
|
|
144
144
|
type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>, 'onResult'> & {
|
|
145
145
|
onResult?: (result: ImageGenerationResult) => TOutput | null | void;
|
|
@@ -153,9 +153,9 @@ interface InjectGenerateImageResult<TOutput = ImageGenerationResult> {
|
|
|
153
153
|
stop: () => void;
|
|
154
154
|
reset: () => void;
|
|
155
155
|
}
|
|
156
|
-
declare function injectGenerateImage<
|
|
157
|
-
onResult?:
|
|
158
|
-
}): InjectGenerateImageResult<
|
|
156
|
+
declare function injectGenerateImage<TTransformed = void>(options: Omit<InjectGenerateImageOptions, 'onResult'> & {
|
|
157
|
+
onResult?: (result: ImageGenerationResult) => TTransformed;
|
|
158
|
+
}): InjectGenerateImageResult<InferGenerationOutputFromReturn<ImageGenerationResult, TTransformed>>;
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
161
|
* Options for the injectGenerateAudio injectable.
|
|
@@ -240,9 +240,9 @@ interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> {
|
|
|
240
240
|
* }
|
|
241
241
|
* ```
|
|
242
242
|
*/
|
|
243
|
-
declare function injectGenerateAudio<
|
|
244
|
-
onResult?:
|
|
245
|
-
}): InjectGenerateAudioResult<
|
|
243
|
+
declare function injectGenerateAudio<TTransformed = void>(options: Omit<InjectGenerateAudioOptions, 'onResult'> & {
|
|
244
|
+
onResult?: (result: AudioGenerationResult) => TTransformed;
|
|
245
|
+
}): InjectGenerateAudioResult<InferGenerationOutputFromReturn<AudioGenerationResult, TTransformed>>;
|
|
246
246
|
|
|
247
247
|
type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>, 'onResult'> & {
|
|
248
248
|
onResult?: (result: TTSResult) => TOutput | null | void;
|
|
@@ -256,9 +256,9 @@ interface InjectGenerateSpeechResult<TOutput = TTSResult> {
|
|
|
256
256
|
stop: () => void;
|
|
257
257
|
reset: () => void;
|
|
258
258
|
}
|
|
259
|
-
declare function injectGenerateSpeech<
|
|
260
|
-
onResult?:
|
|
261
|
-
}): InjectGenerateSpeechResult<
|
|
259
|
+
declare function injectGenerateSpeech<TTransformed = void>(options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {
|
|
260
|
+
onResult?: (result: TTSResult) => TTransformed;
|
|
261
|
+
}): InjectGenerateSpeechResult<InferGenerationOutputFromReturn<TTSResult, TTransformed>>;
|
|
262
262
|
|
|
263
263
|
type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<InjectGenerationOptions<TranscriptionGenerateInput, TranscriptionResult, TOutput>, 'onResult'> & {
|
|
264
264
|
onResult?: (result: TranscriptionResult) => TOutput | null | void;
|
|
@@ -272,9 +272,42 @@ interface InjectTranscriptionResult<TOutput = TranscriptionResult> {
|
|
|
272
272
|
stop: () => void;
|
|
273
273
|
reset: () => void;
|
|
274
274
|
}
|
|
275
|
-
declare function injectTranscription<
|
|
276
|
-
onResult?:
|
|
277
|
-
}): InjectTranscriptionResult<
|
|
275
|
+
declare function injectTranscription<TTransformed = void>(options: Omit<InjectTranscriptionOptions, 'onResult'> & {
|
|
276
|
+
onResult?: (result: TranscriptionResult) => TTransformed;
|
|
277
|
+
}): InjectTranscriptionResult<InferGenerationOutputFromReturn<TranscriptionResult, TTransformed>>;
|
|
278
|
+
|
|
279
|
+
type InjectAudioRecorderOptions<TOnComplete> = AudioRecorderOptions & {
|
|
280
|
+
/**
|
|
281
|
+
* Optional transform applied to the recording when `stop()` resolves. Its
|
|
282
|
+
* (awaited) return value becomes `recording` and the resolved value of
|
|
283
|
+
* `stop()`. Return nothing to keep the raw `AudioRecording`.
|
|
284
|
+
*/
|
|
285
|
+
onComplete?: TOnComplete;
|
|
286
|
+
};
|
|
287
|
+
interface InjectAudioRecorderResult<TOutput> {
|
|
288
|
+
/** Reactive: latest recording (transformed if `onComplete` provided), or null. */
|
|
289
|
+
recording: Signal<TOutput | null>;
|
|
290
|
+
/** Reactive: true while actively capturing audio. */
|
|
291
|
+
isRecording: Signal<boolean>;
|
|
292
|
+
/** Whether the browser supports recording. */
|
|
293
|
+
isSupported: boolean;
|
|
294
|
+
start: () => Promise<void>;
|
|
295
|
+
/** Stop and resolve with the completed recording (transformed if `onComplete` provided). */
|
|
296
|
+
stop: () => Promise<TOutput>;
|
|
297
|
+
/** Discard the in-progress recording and release the mic. */
|
|
298
|
+
cancel: () => void;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Angular injectable for recording an audio message. The resolved recording
|
|
302
|
+
* carries `.part` (for `injectChat`'s `sendMessage`) and `.base64` (for the
|
|
303
|
+
* generation injectables). Must be called in an injection context.
|
|
304
|
+
*
|
|
305
|
+
* Errors are delivered via `onError`. `start()` and `stop()` also reject on
|
|
306
|
+
* failure (and `stop()` rejects with `Recording cancelled` if `cancel()` runs
|
|
307
|
+
* while a stop is in flight, e.g. on destroy) — handle one channel, not both.
|
|
308
|
+
*/
|
|
309
|
+
declare function injectAudioRecorder<TOnComplete extends (recording: AudioRecording) => unknown>(options: InjectAudioRecorderOptions<TOnComplete>): InjectAudioRecorderResult<InferAudioRecordingOutput<TOnComplete>>;
|
|
310
|
+
declare function injectAudioRecorder(options?: InjectAudioRecorderOptions<undefined>): InjectAudioRecorderResult<AudioRecording>;
|
|
278
311
|
|
|
279
312
|
type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>, 'onResult'> & {
|
|
280
313
|
onResult?: (result: SummarizationResult) => TOutput | null | void;
|
|
@@ -288,9 +321,9 @@ interface InjectSummarizeResult<TOutput = SummarizationResult> {
|
|
|
288
321
|
stop: () => void;
|
|
289
322
|
reset: () => void;
|
|
290
323
|
}
|
|
291
|
-
declare function injectSummarize<
|
|
292
|
-
onResult?:
|
|
293
|
-
}): InjectSummarizeResult<
|
|
324
|
+
declare function injectSummarize<TTransformed = void>(options: Omit<InjectSummarizeOptions, 'onResult'> & {
|
|
325
|
+
onResult?: (result: SummarizationResult) => TTransformed;
|
|
326
|
+
}): InjectSummarizeResult<InferGenerationOutputFromReturn<SummarizationResult, TTransformed>>;
|
|
294
327
|
|
|
295
328
|
interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {
|
|
296
329
|
connection?: ConnectConnectionAdapter;
|
|
@@ -316,9 +349,9 @@ interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {
|
|
|
316
349
|
stop: () => void;
|
|
317
350
|
reset: () => void;
|
|
318
351
|
}
|
|
319
|
-
declare function injectGenerateVideo<
|
|
320
|
-
onResult?:
|
|
321
|
-
}): InjectGenerateVideoResult<
|
|
352
|
+
declare function injectGenerateVideo<TTransformed = void>(options: Omit<InjectGenerateVideoOptions, 'onResult'> & {
|
|
353
|
+
onResult?: (result: VideoGenerateResult) => TTransformed;
|
|
354
|
+
}): InjectGenerateVideoResult<InferGenerationOutputFromReturn<VideoGenerateResult, TTransformed>>;
|
|
322
355
|
|
|
323
|
-
export { injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription };
|
|
324
|
-
export type { DeepPartial, InjectChatOptions, InjectChatResult, InjectGenerateAudioOptions, InjectGenerateAudioResult, InjectGenerateImageOptions, InjectGenerateImageResult, InjectGenerateSpeechOptions, InjectGenerateSpeechResult, InjectGenerateVideoOptions, InjectGenerateVideoResult, InjectGenerationOptions, InjectGenerationResult, InjectSummarizeOptions, InjectSummarizeResult, InjectTranscriptionOptions, InjectTranscriptionResult, ReactiveOption };
|
|
356
|
+
export { injectAudioRecorder, injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription };
|
|
357
|
+
export type { DeepPartial, InjectAudioRecorderOptions, InjectAudioRecorderResult, InjectChatOptions, InjectChatResult, InjectGenerateAudioOptions, InjectGenerateAudioResult, InjectGenerateImageOptions, InjectGenerateImageResult, InjectGenerateSpeechOptions, InjectGenerateSpeechResult, InjectGenerateVideoOptions, InjectGenerateVideoResult, InjectGenerationOptions, InjectGenerationResult, InjectSummarizeOptions, InjectSummarizeResult, InjectTranscriptionOptions, InjectTranscriptionResult, ReactiveOption };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-angular",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.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.
|
|
48
|
+
"@tanstack/ai-client": "0.19.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@angular/core": ">=21.0.0",
|
|
52
|
-
"@tanstack/ai": "^0.
|
|
52
|
+
"@tanstack/ai": "^0.39.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@analogjs/vite-plugin-angular": "^1.10.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"vitest": "^4.0.14",
|
|
67
67
|
"zod": "^4.2.0",
|
|
68
68
|
"zone.js": "^0.15.0",
|
|
69
|
-
"@tanstack/ai": "0.
|
|
69
|
+
"@tanstack/ai": "0.39.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"clean": "premove ./build ./dist",
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,13 @@ export type {
|
|
|
36
36
|
InjectTranscriptionResult,
|
|
37
37
|
} from './inject-transcription'
|
|
38
38
|
|
|
39
|
+
// Audio Recorder
|
|
40
|
+
export { injectAudioRecorder } from './inject-audio-recorder'
|
|
41
|
+
export type {
|
|
42
|
+
InjectAudioRecorderOptions,
|
|
43
|
+
InjectAudioRecorderResult,
|
|
44
|
+
} from './inject-audio-recorder'
|
|
45
|
+
|
|
39
46
|
// Summarize
|
|
40
47
|
export { injectSummarize } from './inject-summarize'
|
|
41
48
|
export type {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DestroyRef,
|
|
3
|
+
assertInInjectionContext,
|
|
4
|
+
inject,
|
|
5
|
+
signal,
|
|
6
|
+
} from '@angular/core'
|
|
7
|
+
import { AudioRecorder } from '@tanstack/ai-client'
|
|
8
|
+
import type { Signal } from '@angular/core'
|
|
9
|
+
import type {
|
|
10
|
+
AudioRecorderOptions,
|
|
11
|
+
AudioRecording,
|
|
12
|
+
InferAudioRecordingOutput,
|
|
13
|
+
} from '@tanstack/ai-client'
|
|
14
|
+
|
|
15
|
+
export type InjectAudioRecorderOptions<TOnComplete> = AudioRecorderOptions & {
|
|
16
|
+
/**
|
|
17
|
+
* Optional transform applied to the recording when `stop()` resolves. Its
|
|
18
|
+
* (awaited) return value becomes `recording` and the resolved value of
|
|
19
|
+
* `stop()`. Return nothing to keep the raw `AudioRecording`.
|
|
20
|
+
*/
|
|
21
|
+
onComplete?: TOnComplete
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface InjectAudioRecorderResult<TOutput> {
|
|
25
|
+
/** Reactive: latest recording (transformed if `onComplete` provided), or null. */
|
|
26
|
+
recording: Signal<TOutput | null>
|
|
27
|
+
/** Reactive: true while actively capturing audio. */
|
|
28
|
+
isRecording: Signal<boolean>
|
|
29
|
+
/** Whether the browser supports recording. */
|
|
30
|
+
isSupported: boolean
|
|
31
|
+
start: () => Promise<void>
|
|
32
|
+
/** Stop and resolve with the completed recording (transformed if `onComplete` provided). */
|
|
33
|
+
stop: () => Promise<TOutput>
|
|
34
|
+
/** Discard the in-progress recording and release the mic. */
|
|
35
|
+
cancel: () => void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Angular injectable for recording an audio message. The resolved recording
|
|
40
|
+
* carries `.part` (for `injectChat`'s `sendMessage`) and `.base64` (for the
|
|
41
|
+
* generation injectables). Must be called in an injection context.
|
|
42
|
+
*
|
|
43
|
+
* Errors are delivered via `onError`. `start()` and `stop()` also reject on
|
|
44
|
+
* failure (and `stop()` rejects with `Recording cancelled` if `cancel()` runs
|
|
45
|
+
* while a stop is in flight, e.g. on destroy) — handle one channel, not both.
|
|
46
|
+
*/
|
|
47
|
+
export function injectAudioRecorder<
|
|
48
|
+
TOnComplete extends (recording: AudioRecording) => unknown,
|
|
49
|
+
>(
|
|
50
|
+
options: InjectAudioRecorderOptions<TOnComplete>,
|
|
51
|
+
): InjectAudioRecorderResult<InferAudioRecordingOutput<TOnComplete>>
|
|
52
|
+
export function injectAudioRecorder(
|
|
53
|
+
options?: InjectAudioRecorderOptions<undefined>,
|
|
54
|
+
): InjectAudioRecorderResult<AudioRecording>
|
|
55
|
+
export function injectAudioRecorder(
|
|
56
|
+
options: InjectAudioRecorderOptions<
|
|
57
|
+
(recording: AudioRecording) => unknown
|
|
58
|
+
> = {},
|
|
59
|
+
): InjectAudioRecorderResult<unknown> {
|
|
60
|
+
assertInInjectionContext(injectAudioRecorder)
|
|
61
|
+
const destroyRef = inject(DestroyRef)
|
|
62
|
+
const recorder = new AudioRecorder({
|
|
63
|
+
...(options.audio !== undefined && { audio: options.audio }),
|
|
64
|
+
...(options.mimeType !== undefined && { mimeType: options.mimeType }),
|
|
65
|
+
...(options.onError !== undefined && { onError: options.onError }),
|
|
66
|
+
})
|
|
67
|
+
const isRecording = signal(false)
|
|
68
|
+
const recording = signal<unknown>(null)
|
|
69
|
+
|
|
70
|
+
const unsubscribe = recorder.subscribe((state) => {
|
|
71
|
+
isRecording.set(state === 'recording')
|
|
72
|
+
})
|
|
73
|
+
destroyRef.onDestroy(() => {
|
|
74
|
+
unsubscribe()
|
|
75
|
+
recorder.cancel()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const stop = async (): Promise<unknown> => {
|
|
79
|
+
const rawRecording = await recorder.stop()
|
|
80
|
+
const transformed = await options.onComplete?.(rawRecording)
|
|
81
|
+
// Only `undefined` (returning nothing) keeps the raw recording; a returned
|
|
82
|
+
// null is a real value, matching the inferred output type.
|
|
83
|
+
const output = transformed === undefined ? rawRecording : transformed
|
|
84
|
+
recording.set(output)
|
|
85
|
+
return output
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
recording: recording.asReadonly(),
|
|
90
|
+
isRecording: isRecording.asReadonly(),
|
|
91
|
+
isSupported: AudioRecorder.isSupported(),
|
|
92
|
+
start: () => recorder.start(),
|
|
93
|
+
stop,
|
|
94
|
+
cancel: () => recorder.cancel(),
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ConnectConnectionAdapter,
|
|
7
7
|
GenerationClientState,
|
|
8
8
|
GenerationFetcher,
|
|
9
|
-
|
|
9
|
+
InferGenerationOutputFromReturn,
|
|
10
10
|
} from '@tanstack/ai-client'
|
|
11
11
|
import type { Signal } from '@angular/core'
|
|
12
12
|
import type { ReactiveOption } from './internal/to-reactive'
|
|
@@ -96,15 +96,12 @@ export interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> {
|
|
|
96
96
|
* }
|
|
97
97
|
* ```
|
|
98
98
|
*/
|
|
99
|
-
export function injectGenerateAudio<
|
|
100
|
-
TOnResult extends ((result: AudioGenerationResult) => any) | undefined =
|
|
101
|
-
undefined,
|
|
102
|
-
>(
|
|
99
|
+
export function injectGenerateAudio<TTransformed = void>(
|
|
103
100
|
options: Omit<InjectGenerateAudioOptions, 'onResult'> & {
|
|
104
|
-
onResult?:
|
|
101
|
+
onResult?: (result: AudioGenerationResult) => TTransformed
|
|
105
102
|
},
|
|
106
103
|
): InjectGenerateAudioResult<
|
|
107
|
-
|
|
104
|
+
InferGenerationOutputFromReturn<AudioGenerationResult, TTransformed>
|
|
108
105
|
> {
|
|
109
106
|
const devtools = {
|
|
110
107
|
...options.devtools,
|
|
@@ -113,7 +110,7 @@ export function injectGenerateAudio<
|
|
|
113
110
|
outputKind: 'audio' as const,
|
|
114
111
|
}
|
|
115
112
|
const { generate, result, isLoading, error, status, stop, reset } =
|
|
116
|
-
injectGeneration<AudioGenerateInput, AudioGenerationResult,
|
|
113
|
+
injectGeneration<AudioGenerateInput, AudioGenerationResult, TTransformed>({
|
|
117
114
|
...options,
|
|
118
115
|
devtools,
|
|
119
116
|
})
|
|
@@ -4,7 +4,7 @@ import type { ImageGenerationResult } from '@tanstack/ai'
|
|
|
4
4
|
import type {
|
|
5
5
|
GenerationClientState,
|
|
6
6
|
ImageGenerateInput,
|
|
7
|
-
|
|
7
|
+
InferGenerationOutputFromReturn,
|
|
8
8
|
} from '@tanstack/ai-client'
|
|
9
9
|
import type { InjectGenerationOptions } from './inject-generation'
|
|
10
10
|
|
|
@@ -25,15 +25,12 @@ export interface InjectGenerateImageResult<TOutput = ImageGenerationResult> {
|
|
|
25
25
|
reset: () => void
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function injectGenerateImage<
|
|
29
|
-
TOnResult extends ((result: ImageGenerationResult) => any) | undefined =
|
|
30
|
-
undefined,
|
|
31
|
-
>(
|
|
28
|
+
export function injectGenerateImage<TTransformed = void>(
|
|
32
29
|
options: Omit<InjectGenerateImageOptions, 'onResult'> & {
|
|
33
|
-
onResult?:
|
|
30
|
+
onResult?: (result: ImageGenerationResult) => TTransformed
|
|
34
31
|
},
|
|
35
32
|
): InjectGenerateImageResult<
|
|
36
|
-
|
|
33
|
+
InferGenerationOutputFromReturn<ImageGenerationResult, TTransformed>
|
|
37
34
|
> {
|
|
38
35
|
const devtools = {
|
|
39
36
|
...options.devtools,
|
|
@@ -42,7 +39,7 @@ export function injectGenerateImage<
|
|
|
42
39
|
outputKind: 'image' as const,
|
|
43
40
|
}
|
|
44
41
|
const { generate, result, isLoading, error, status, stop, reset } =
|
|
45
|
-
injectGeneration<ImageGenerateInput, ImageGenerationResult,
|
|
42
|
+
injectGeneration<ImageGenerateInput, ImageGenerationResult, TTransformed>({
|
|
46
43
|
...options,
|
|
47
44
|
devtools,
|
|
48
45
|
})
|
|
@@ -3,7 +3,7 @@ import type { Signal } from '@angular/core'
|
|
|
3
3
|
import type { TTSResult } from '@tanstack/ai'
|
|
4
4
|
import type {
|
|
5
5
|
GenerationClientState,
|
|
6
|
-
|
|
6
|
+
InferGenerationOutputFromReturn,
|
|
7
7
|
SpeechGenerateInput,
|
|
8
8
|
} from '@tanstack/ai-client'
|
|
9
9
|
import type { InjectGenerationOptions } from './inject-generation'
|
|
@@ -25,13 +25,13 @@ export interface InjectGenerateSpeechResult<TOutput = TTSResult> {
|
|
|
25
25
|
reset: () => void
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function injectGenerateSpeech<
|
|
29
|
-
TOnResult extends ((result: TTSResult) => any) | undefined = undefined,
|
|
30
|
-
>(
|
|
28
|
+
export function injectGenerateSpeech<TTransformed = void>(
|
|
31
29
|
options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {
|
|
32
|
-
onResult?:
|
|
30
|
+
onResult?: (result: TTSResult) => TTransformed
|
|
33
31
|
},
|
|
34
|
-
): InjectGenerateSpeechResult<
|
|
32
|
+
): InjectGenerateSpeechResult<
|
|
33
|
+
InferGenerationOutputFromReturn<TTSResult, TTransformed>
|
|
34
|
+
> {
|
|
35
35
|
const devtools = {
|
|
36
36
|
...options.devtools,
|
|
37
37
|
framework: 'angular' as const,
|
|
@@ -39,7 +39,7 @@ export function injectGenerateSpeech<
|
|
|
39
39
|
outputKind: 'audio' as const,
|
|
40
40
|
}
|
|
41
41
|
const { generate, result, isLoading, error, status, stop, reset } =
|
|
42
|
-
injectGeneration<SpeechGenerateInput, TTSResult,
|
|
42
|
+
injectGeneration<SpeechGenerateInput, TTSResult, TTransformed>({
|
|
43
43
|
...options,
|
|
44
44
|
devtools,
|
|
45
45
|
})
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
ConnectConnectionAdapter,
|
|
18
18
|
GenerationClientState,
|
|
19
19
|
GenerationFetcher,
|
|
20
|
-
|
|
20
|
+
InferGenerationOutputFromReturn,
|
|
21
21
|
VideoGenerateInput,
|
|
22
22
|
VideoGenerateResult,
|
|
23
23
|
VideoStatusInfo,
|
|
@@ -52,19 +52,22 @@ export interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {
|
|
|
52
52
|
reset: () => void
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
>(
|
|
55
|
+
// `TTransformed` infers from the `onResult` return position so the callback
|
|
56
|
+
// parameter is typed as `VideoGenerateResult` and `result` narrows to the
|
|
57
|
+
// transform's return. See issue #848.
|
|
58
|
+
export function injectGenerateVideo<TTransformed = void>(
|
|
59
59
|
options: Omit<InjectGenerateVideoOptions, 'onResult'> & {
|
|
60
|
-
onResult?:
|
|
60
|
+
onResult?: (result: VideoGenerateResult) => TTransformed
|
|
61
61
|
},
|
|
62
62
|
): InjectGenerateVideoResult<
|
|
63
|
-
|
|
63
|
+
InferGenerationOutputFromReturn<VideoGenerateResult, TTransformed>
|
|
64
64
|
> {
|
|
65
65
|
assertInInjectionContext(injectGenerateVideo)
|
|
66
66
|
|
|
67
|
-
type TOutput =
|
|
67
|
+
type TOutput = InferGenerationOutputFromReturn<
|
|
68
|
+
VideoGenerateResult,
|
|
69
|
+
TTransformed
|
|
70
|
+
>
|
|
68
71
|
|
|
69
72
|
const destroyRef = inject(DestroyRef)
|
|
70
73
|
const injector = inject(Injector)
|
|
@@ -90,7 +93,12 @@ export function injectGenerateVideo<
|
|
|
90
93
|
hookName: 'injectGenerateVideo',
|
|
91
94
|
outputKind: 'video' as const,
|
|
92
95
|
},
|
|
93
|
-
|
|
96
|
+
// The transform's raw return type (`TTransformed`) and the stored output
|
|
97
|
+
// (`TOutput`, with null/void/undefined stripped) are identical at runtime;
|
|
98
|
+
// the cast bridges the relationship that the conditional type hides.
|
|
99
|
+
onResult: ((r: VideoGenerateResult) => options.onResult?.(r)) as (
|
|
100
|
+
result: VideoGenerateResult,
|
|
101
|
+
) => TOutput | null | void,
|
|
94
102
|
onError: (e: Error) => options.onError?.(e),
|
|
95
103
|
onProgress: (p: number, m?: string) => options.onProgress?.(p, m),
|
|
96
104
|
onChunk: (c: StreamChunk) => options.onChunk?.(c),
|
package/src/inject-generation.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
GenerationClientOptions,
|
|
19
19
|
GenerationClientState,
|
|
20
20
|
GenerationFetcher,
|
|
21
|
-
|
|
21
|
+
InferGenerationOutputFromReturn,
|
|
22
22
|
} from '@tanstack/ai-client'
|
|
23
23
|
import type { ReactiveOption } from './internal/to-reactive'
|
|
24
24
|
|
|
@@ -68,18 +68,26 @@ export interface InjectGenerationResult<TOutput> {
|
|
|
68
68
|
reset: () => void
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// `TTransformed` infers from the `onResult` return position (a covariant
|
|
72
|
+
// inference site that works even for an optional nested property), which types
|
|
73
|
+
// the callback parameter as `TResult` and narrows `result`. Inferring the
|
|
74
|
+
// whole callback as a defaulted type parameter instead collapses to the
|
|
75
|
+
// default, leaving the parameter `any` — a hard error under `strict`. See
|
|
76
|
+
// issue #848.
|
|
71
77
|
export function injectGeneration<
|
|
72
78
|
TInput extends Record<string, any>,
|
|
73
79
|
TResult,
|
|
74
|
-
|
|
80
|
+
TTransformed = void,
|
|
75
81
|
>(
|
|
76
82
|
options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {
|
|
77
|
-
onResult?:
|
|
83
|
+
onResult?: (result: TResult) => TTransformed
|
|
78
84
|
},
|
|
79
|
-
): InjectGenerationResult<
|
|
85
|
+
): InjectGenerationResult<
|
|
86
|
+
InferGenerationOutputFromReturn<TResult, TTransformed>
|
|
87
|
+
> {
|
|
80
88
|
assertInInjectionContext(injectGeneration)
|
|
81
89
|
|
|
82
|
-
type TOutput =
|
|
90
|
+
type TOutput = InferGenerationOutputFromReturn<TResult, TTransformed>
|
|
83
91
|
|
|
84
92
|
const destroyRef = inject(DestroyRef)
|
|
85
93
|
const injector = inject(Injector)
|
|
@@ -102,7 +110,12 @@ export function injectGeneration<
|
|
|
102
110
|
framework: 'angular',
|
|
103
111
|
hookName: 'injectGeneration',
|
|
104
112
|
},
|
|
105
|
-
|
|
113
|
+
// The transform's raw return type (`TTransformed`) and the stored output
|
|
114
|
+
// (`TOutput`, with null/void/undefined stripped) are identical at runtime;
|
|
115
|
+
// the cast bridges the relationship that the conditional type hides.
|
|
116
|
+
onResult: ((r: TResult) => options.onResult?.(r)) as (
|
|
117
|
+
result: TResult,
|
|
118
|
+
) => TOutput | null | void,
|
|
106
119
|
onError: (e: Error) => options.onError?.(e),
|
|
107
120
|
onProgress: (p: number, m?: string) => options.onProgress?.(p, m),
|
|
108
121
|
onChunk: (c: StreamChunk) => options.onChunk?.(c),
|
package/src/inject-summarize.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Signal } from '@angular/core'
|
|
|
3
3
|
import type { SummarizationResult } from '@tanstack/ai'
|
|
4
4
|
import type {
|
|
5
5
|
GenerationClientState,
|
|
6
|
-
|
|
6
|
+
InferGenerationOutputFromReturn,
|
|
7
7
|
SummarizeGenerateInput,
|
|
8
8
|
} from '@tanstack/ai-client'
|
|
9
9
|
import type { InjectGenerationOptions } from './inject-generation'
|
|
@@ -25,15 +25,12 @@ export interface InjectSummarizeResult<TOutput = SummarizationResult> {
|
|
|
25
25
|
reset: () => void
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function injectSummarize<
|
|
29
|
-
TOnResult extends ((result: SummarizationResult) => any) | undefined =
|
|
30
|
-
undefined,
|
|
31
|
-
>(
|
|
28
|
+
export function injectSummarize<TTransformed = void>(
|
|
32
29
|
options: Omit<InjectSummarizeOptions, 'onResult'> & {
|
|
33
|
-
onResult?:
|
|
30
|
+
onResult?: (result: SummarizationResult) => TTransformed
|
|
34
31
|
},
|
|
35
32
|
): InjectSummarizeResult<
|
|
36
|
-
|
|
33
|
+
InferGenerationOutputFromReturn<SummarizationResult, TTransformed>
|
|
37
34
|
> {
|
|
38
35
|
const devtools = {
|
|
39
36
|
...options.devtools,
|
|
@@ -42,10 +39,12 @@ export function injectSummarize<
|
|
|
42
39
|
outputKind: 'text' as const,
|
|
43
40
|
}
|
|
44
41
|
const { generate, result, isLoading, error, status, stop, reset } =
|
|
45
|
-
injectGeneration<SummarizeGenerateInput, SummarizationResult,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
injectGeneration<SummarizeGenerateInput, SummarizationResult, TTransformed>(
|
|
43
|
+
{
|
|
44
|
+
...options,
|
|
45
|
+
devtools,
|
|
46
|
+
},
|
|
47
|
+
)
|
|
49
48
|
return {
|
|
50
49
|
generate: generate as (input: SummarizeGenerateInput) => Promise<void>,
|
|
51
50
|
result,
|
|
@@ -3,7 +3,7 @@ import type { Signal } from '@angular/core'
|
|
|
3
3
|
import type { TranscriptionResult } from '@tanstack/ai'
|
|
4
4
|
import type {
|
|
5
5
|
GenerationClientState,
|
|
6
|
-
|
|
6
|
+
InferGenerationOutputFromReturn,
|
|
7
7
|
TranscriptionGenerateInput,
|
|
8
8
|
} from '@tanstack/ai-client'
|
|
9
9
|
import type { InjectGenerationOptions } from './inject-generation'
|
|
@@ -29,15 +29,12 @@ export interface InjectTranscriptionResult<TOutput = TranscriptionResult> {
|
|
|
29
29
|
reset: () => void
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function injectTranscription<
|
|
33
|
-
TOnResult extends ((result: TranscriptionResult) => any) | undefined =
|
|
34
|
-
undefined,
|
|
35
|
-
>(
|
|
32
|
+
export function injectTranscription<TTransformed = void>(
|
|
36
33
|
options: Omit<InjectTranscriptionOptions, 'onResult'> & {
|
|
37
|
-
onResult?:
|
|
34
|
+
onResult?: (result: TranscriptionResult) => TTransformed
|
|
38
35
|
},
|
|
39
36
|
): InjectTranscriptionResult<
|
|
40
|
-
|
|
37
|
+
InferGenerationOutputFromReturn<TranscriptionResult, TTransformed>
|
|
41
38
|
> {
|
|
42
39
|
const devtools = {
|
|
43
40
|
...options.devtools,
|
|
@@ -49,7 +46,7 @@ export function injectTranscription<
|
|
|
49
46
|
injectGeneration<
|
|
50
47
|
TranscriptionGenerateInput,
|
|
51
48
|
TranscriptionResult,
|
|
52
|
-
|
|
49
|
+
TTransformed
|
|
53
50
|
>({
|
|
54
51
|
...options,
|
|
55
52
|
devtools,
|