diff --git a/.changeset/fix-null-tool-input-normalization.md b/.changeset/fix-null-tool-input-normalization.md deleted file mode 100644 index b15c356f6b..0000000000 --- a/.changeset/fix-null-tool-input-normalization.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -'@tanstack/ai': patch -'@tanstack/ai-openai': patch -'@tanstack/ai-gemini': patch -'@tanstack/ai-ollama': patch ---- - -fix(ai, ai-openai, ai-gemini, ai-ollama): normalize null tool input to empty object - -When a model produces a `tool_use` block with no input, `JSON.parse('null')` returns `null` which fails Zod schema validation and silently kills the agent loop. Normalize null/non-object parsed tool input to `{}` in `executeToolCalls`, `ToolCallManager.completeToolCall`, `ToolCallManager.executeTools`, and the OpenAI/Gemini/Ollama adapter `TOOL_CALL_END` emissions. The Anthropic adapter already had this fix. diff --git a/.changeset/stream-adapter-server-functions.md b/.changeset/stream-adapter-server-functions.md new file mode 100644 index 0000000000..6ca95b5b9c --- /dev/null +++ b/.changeset/stream-adapter-server-functions.md @@ -0,0 +1,25 @@ +--- +'@tanstack/ai-client': minor +--- + +feat(ai-client): support TanStack Start server functions in `stream()` connection adapter + +The `stream()` factory now accepts any of three return shapes, so a TanStack Start server function can be wired directly into `useChat`: + +- `AsyncIterable` — direct in-process stream (existing behavior) +- `Promise>` — server function returning the chat stream +- `Promise` — server function returning `toServerSentEventsResponse(stream)` + +`rpcStream()` likewise accepts a `Promise>`. + +```ts +const chatFn = createServerFn({ method: 'POST' }) + .inputValidator((data: { messages: Array }) => data) + .handler(({ data }) => + toServerSentEventsResponse(chat({ adapter, messages: data.messages })), + ) + +useChat({ connection: stream((messages) => chatFn({ data: { messages } })) }) +``` + +The `stream()` callback's `messages` parameter is now typed as `Array` (was `Array | Array`) — matching what `useChat`/`ChatClient` actually sends. A runtime assertion guards against misuse. Existing callbacks typed against the union remain assignable (wider declared input satisfies narrower expected input). diff --git a/.changeset/sync-models.md b/.changeset/sync-models.md deleted file mode 100644 index 63eef764c5..0000000000 --- a/.changeset/sync-models.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/ai-openrouter': patch ---- - -Update model metadata from OpenRouter API diff --git a/docs/adapters/anthropic.md b/docs/adapters/anthropic.md index 2e8f36b2f6..50e7ef1554 100644 --- a/docs/adapters/anthropic.md +++ b/docs/adapters/anthropic.md @@ -2,6 +2,15 @@ title: Anthropic id: anthropic-adapter order: 2 +description: "Use Anthropic Claude models with TanStack AI — Claude Sonnet 4.5, Claude Opus, and more via the @tanstack/ai-anthropic adapter." +keywords: + - tanstack ai + - anthropic + - claude + - claude sonnet 4.5 + - claude opus + - adapter + - llm --- The Anthropic adapter provides access to Claude models, including Claude Sonnet 4.5, Claude Opus 4.5, and more. @@ -228,3 +237,198 @@ Creates an Anthropic summarization adapter with an explicit API key. - [Getting Started](../getting-started/quick-start) - Learn the basics - [Tools Guide](../tools/tools) - Learn about tools - [Other Adapters](./openai) - Explore other providers + +## Provider Tools + +Anthropic exposes several native tools beyond user-defined function calls. +Import them from `@tanstack/ai-anthropic/tools` and pass them into +`chat({ tools: [...] })`. + +> For the full concept, a comparison matrix, and type-gating details, see +> [Provider Tools](../tools/provider-tools.md). + +### `webSearchTool` + +Enables Claude to run Anthropic's native web search with inline citations. +Scope the search with `allowed_domains` or `blocked_domains` (mutually +exclusive); set `max_uses` to cap per-turn cost. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { webSearchTool } from "@tanstack/ai-anthropic/tools"; + +const stream = chat({ + adapter: anthropicText("claude-opus-4-6"), + messages: [{ role: "user", content: "What's new in AI this week?" }], + tools: [ + webSearchTool({ + name: "web_search", + type: "web_search_20250305", + max_uses: 2, + }), + ], +}); +``` + +**Supported models:** every current Claude model. `claude-3-haiku` supports +only `web_search` (not `web_fetch`). See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `webFetchTool` + +Lets Claude fetch the contents of a URL directly, useful when you want the +model to read a specific page rather than run a search. Takes no required +arguments — pass an optional config object to override defaults. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { webFetchTool } from "@tanstack/ai-anthropic/tools"; + +const stream = chat({ + adapter: anthropicText("claude-sonnet-4-5"), + messages: [{ role: "user", content: "Summarise https://example.com" }], + tools: [webFetchTool()], +}); +``` + +**Supported models:** Claude Sonnet 4.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `codeExecutionTool` + +Gives Claude a sandboxed code-execution environment so it can run Python +snippets, analyse data, and return results inline. Choose the version string +that matches your desired API revision. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { codeExecutionTool } from "@tanstack/ai-anthropic/tools"; + +const stream = chat({ + adapter: anthropicText("claude-sonnet-4-5"), + messages: [{ role: "user", content: "Plot a histogram of [1,2,2,3,3,3]" }], + tools: [ + codeExecutionTool({ name: "code_execution", type: "code_execution_20250825" }), + ], +}); +``` + +**Supported models:** Claude Sonnet 4.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `computerUseTool` + +Allows Claude to observe a virtual desktop (screenshots) and interact with it +via keyboard and mouse events. Provide the screen resolution so Claude can +calculate accurate coordinates. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { computerUseTool } from "@tanstack/ai-anthropic/tools"; + +const stream = chat({ + adapter: anthropicText("claude-sonnet-4-5"), + messages: [{ role: "user", content: "Open the browser and go to example.com" }], + tools: [ + computerUseTool({ + type: "computer_20250124", + name: "computer", + display_width_px: 1024, + display_height_px: 768, + }), + ], +}); +``` + +**Supported models:** Claude Sonnet 3.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `bashTool` + +Provides Claude with a persistent bash shell session, letting it run arbitrary +commands, install packages, or manipulate files on the host. Choose the type +string that matches your API revision. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { bashTool } from "@tanstack/ai-anthropic/tools"; + +const stream = chat({ + adapter: anthropicText("claude-sonnet-4-5"), + messages: [{ role: "user", content: "List all TypeScript files in src/" }], + tools: [bashTool({ name: "bash", type: "bash_20250124" })], +}); +``` + +**Supported models:** Claude Sonnet 3.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `textEditorTool` + +Gives Claude a structured text-editor interface for viewing and modifying files +using `str_replace`, `create`, `view`, and `undo_edit` commands. Choose the +type string for the API revision you target. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { textEditorTool } from "@tanstack/ai-anthropic/tools"; + +const stream = chat({ + adapter: anthropicText("claude-sonnet-4-5"), + messages: [{ role: "user", content: "Fix the bug in src/index.ts" }], + tools: [ + textEditorTool({ type: "text_editor_20250124", name: "str_replace_editor" }), + ], +}); +``` + +**Supported models:** Claude Sonnet 3.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `memoryTool` + +Enables Claude to store and retrieve information across conversation turns +using Anthropic's managed memory service. Call with no arguments to use +default configuration. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { memoryTool } from "@tanstack/ai-anthropic/tools"; + +const stream = chat({ + adapter: anthropicText("claude-sonnet-4-5"), + messages: [{ role: "user", content: "Remember that I prefer metric units" }], + tools: [memoryTool()], +}); +``` + +**Supported models:** Claude Sonnet 4.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `customTool` + +Creates a tool with an inline JSON Schema input definition instead of going +through `toolDefinition()`. Useful when you need fine-grained control over the +schema shape or want to add `cache_control`. Unlike branded provider tools, +`customTool` returns a plain `Tool` and is accepted by any chat model. + +```typescript +import { chat } from "@tanstack/ai"; +import { anthropicText } from "@tanstack/ai-anthropic"; +import { customTool } from "@tanstack/ai-anthropic/tools"; +import { z } from "zod"; + +const stream = chat({ + adapter: anthropicText("claude-sonnet-4-5"), + messages: [{ role: "user", content: "Look up user 42" }], + tools: [ + customTool( + "lookup_user", + "Look up a user by ID and return their profile", + z.object({ userId: z.number() }), + ), + ], +}); +``` + +**Supported models:** all current Claude models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). diff --git a/docs/adapters/elevenlabs.md b/docs/adapters/elevenlabs.md index 88590aaf30..83a108ef90 100644 --- a/docs/adapters/elevenlabs.md +++ b/docs/adapters/elevenlabs.md @@ -2,6 +2,15 @@ title: ElevenLabs id: elevenlabs-adapter order: 9 +description: "Build realtime voice-to-voice conversational AI with ElevenLabs agents in TanStack AI via the @tanstack/ai-elevenlabs adapter." +keywords: + - tanstack ai + - elevenlabs + - realtime voice ai + - conversational ai + - voice chat + - voice agents + - adapter --- The ElevenLabs adapter provides realtime conversational voice AI for TanStack AI. Unlike text-focused adapters, the ElevenLabs adapter is **voice-focused** -- it integrates with TanStack AI's realtime system to enable voice-to-voice conversations. It does not support `chat()`, `embedding()`, or `summarize()`. diff --git a/docs/adapters/fal.md b/docs/adapters/fal.md index 5be52698e7..76ae715999 100644 --- a/docs/adapters/fal.md +++ b/docs/adapters/fal.md @@ -1,9 +1,19 @@ --- title: fal.ai id: fal-adapter +description: "Generate images and videos with 600+ models on fal.ai using TanStack AI — Nano Banana Pro, FLUX, and more via the @tanstack/ai-fal adapter." +keywords: + - tanstack ai + - fal.ai + - fal + - image generation + - video generation + - flux + - nano banana + - adapter --- -The fal.ai adapter provides access to 600+ models on the fal.ai platform for image generation and video generation. Unlike text-focused adapters, the fal adapter is **media-focused** — it supports `generateImage()` and `generateVideo()` but does not support `chat()` or tools. Audio and speech support are coming soon. +The fal.ai adapter provides access to 600+ models on the fal.ai platform for image, video, audio, speech, and transcription. Unlike text-focused adapters, the fal adapter is **media-focused** — it supports `generateImage()`, `generateVideo()`, `generateAudio()`, `generateSpeech()`, and `generateTranscription()` but does not support `chat()` or tools. For a full working example, see the [fal.ai example app](https://github.com/TanStack/ai/tree/main/examples/ts-react-media). @@ -199,6 +209,113 @@ const job = await generateVideo({ }); ``` +## Text-to-Speech + +Text-to-speech uses `falSpeech()` with the `generateSpeech()` activity. The adapter fetches the generated audio from fal's CDN and returns it as base64-encoded data to match the `TTSResult` contract. + +```typescript +import { generateSpeech } from "@tanstack/ai"; +import { falSpeech } from "@tanstack/ai-fal"; + +const result = await generateSpeech({ + adapter: falSpeech("fal-ai/kokoro/american-english"), + text: "Hello from fal!", + voice: "af_heart", + speed: 1.0, +}); + +// result.audio is a base64-encoded string +console.log(result.format); // e.g. "wav" +console.log(result.contentType); // e.g. "audio/wav" +``` + +### Google Gemini 3.1 Flash TTS + +Google's newest TTS model (`fal-ai/gemini-3.1-flash-tts`) supports 80+ languages and introduces **granular audio tags** for expressive control — you can embed speaker tags and style cues directly in the text. + +```typescript +const result = await generateSpeech({ + adapter: falSpeech("fal-ai/gemini-3.1-flash-tts"), + text: "[warm, enthusiastic] Welcome to TanStack AI! [pause] Let's build something great.", + voice: "Kore", +}); +``` + +> **Note:** This model is newer than `@fal-ai/client@1.9.1`'s type map, so `modelOptions` won't autocomplete. The call still works — the fal adapter accepts any model ID as a string. Type-safe autocomplete will land when fal's SDK types catch up. + +### ElevenLabs v3 + +```typescript +const result = await generateSpeech({ + adapter: falSpeech("fal-ai/elevenlabs/tts/eleven-v3"), + text: "Welcome to TanStack AI.", + modelOptions: { + voice: "Rachel", + stability: 0.5, + }, +}); +``` + +## Transcription + +Speech-to-text uses `falTranscription()` with the `generateTranscription()` activity. The `audio` input accepts a URL string, `Blob`, `File`, or `ArrayBuffer` — `ArrayBuffer` is automatically wrapped in a `Blob` for upload. + +```typescript +import { generateTranscription } from "@tanstack/ai"; +import { falTranscription } from "@tanstack/ai-fal"; + +const result = await generateTranscription({ + adapter: falTranscription("fal-ai/whisper"), + audio: "https://example.com/recording.mp3", + language: "en", +}); + +console.log(result.text); +console.log(result.language); + +// When the model returns word/segment timestamps, they're mapped to result.segments +for (const segment of result.segments ?? []) { + console.log(`[${segment.start}s → ${segment.end}s] ${segment.text}`); +} +``` + +## Audio Generation (Music & Sound Effects) + +Music and sound-effect generation uses `falAudio()` with the `generateAudio()` activity. Unlike TTS, the result is returned as a URL in `result.audio.url` (you can fetch it yourself if you need raw bytes). + +```typescript +import { generateAudio } from "@tanstack/ai"; +import { falAudio } from "@tanstack/ai-fal"; + +// Music generation with MiniMax Music 2.6 (latest) +const music = await generateAudio({ + adapter: falAudio("fal-ai/minimax-music/v2.6"), + prompt: "City Pop, 80s retro, groovy synth bass, warm female vocal, 104 BPM, nostalgic urban night", +}); + +console.log(music.audio.url); +``` + +```typescript +// DiffRhythm with explicit lyrics +const lyrical = await generateAudio({ + adapter: falAudio("fal-ai/diffrhythm"), + prompt: "An upbeat electronic track with synths", + modelOptions: { + lyrics: "[verse]\nHello world\n[chorus]\nLa la la", + }, +}); +``` + +```typescript +// Sound effects +const sfx = await generateAudio({ + adapter: falAudio("fal-ai/elevenlabs/sound-effects/v2"), + prompt: "Thunderclap with rain", + duration: 5, +}); +``` + ## Popular Models ### Image Models @@ -223,6 +340,49 @@ const job = await generateVideo({ | `fal-ai/ltx-2/text-to-video/fast` | Text-to-Video | Fast text-to-video | | `fal-ai/ltx-2/image-to-video/fast` | Image-to-Video | Fast image-to-video animation | +### Text-to-Speech Models + +| Model | Description | +|-------|-------------| +| `fal-ai/gemini-3.1-flash-tts` | **New** — Google's flagship TTS with 80+ languages and expressive audio tags | +| `fal-ai/elevenlabs/tts/eleven-v3` | ElevenLabs v3 expressive multi-voice TTS | +| `fal-ai/elevenlabs/tts/turbo-v2.5` | Low-latency ElevenLabs TTS | +| `fal-ai/minimax/speech-2.6-hd` | MiniMax HD speech synthesis | +| `fal-ai/minimax/speech-2.6-turbo` | MiniMax low-latency variant | +| `fal-ai/kokoro/american-english` | Kokoro multilingual TTS — also `british-english`, `french`, `spanish`, `italian`, `japanese`, `mandarin-chinese`, `hindi`, `brazilian-portuguese` | +| `fal-ai/inworld-tts` | Inworld TTS-1.5 Max | +| `fal-ai/chatterbox/text-to-speech/multilingual` | Chatterbox multilingual TTS | +| `fal-ai/dia-tts` | Dia expressive dialogue TTS | +| `fal-ai/orpheus-tts` | Orpheus open-source TTS | +| `fal-ai/f5-tts` | F5-TTS voice cloning | +| `fal-ai/vibevoice/7b` | VibeVoice 7B conversational TTS | + +### Transcription Models + +| Model | Description | +|-------|-------------| +| `fal-ai/whisper` | OpenAI Whisper on fal infra | +| `fal-ai/wizper` | Faster-whisper variant with word-level timestamps | +| `fal-ai/speech-to-text/turbo` | Turbo STT with diarization | +| `fal-ai/elevenlabs/speech-to-text` | ElevenLabs STT | + +### Audio / Music Models + +| Model | Mode | Description | +|-------|------|-------------| +| `fal-ai/minimax-music/v2.6` | Music | **New** — MiniMax Music 2.6, full vocal + instrumental compositions from a prompt | +| `fal-ai/minimax-music/v2.5` | Music | MiniMax Music 2.5 | +| `fal-ai/minimax-music/v2` | Music | MiniMax Music v2 — supports `lyrics_prompt` | +| `fal-ai/diffrhythm` | Music | DiffRhythm — prompt + lyrics | +| `fal-ai/lyria2` | Music | Google Lyria 2 high-fidelity music | +| `fal-ai/stable-audio-25/text-to-audio` | Music / Audio | Stability AI Stable Audio 2.5 | +| `fal-ai/mmaudio-v2/text-to-audio` | Audio | MMAudio v2 text-to-audio | +| `fal-ai/elevenlabs/sound-effects/v2` | SFX | ElevenLabs sound-effect generation | +| `fal-ai/beatoven/sound-effect-generation` | SFX | Beatoven professional sound effects | +| `fal-ai/thinksound` | Audio | Thinksound reasoning-based audio generation | + +> **Very new models** (e.g. `gemini-3.1-flash-tts`, `minimax-music/v2.6`, `beatoven/sound-effect-generation`) may not yet appear in `@fal-ai/client`'s type map — they still work as plain string model IDs, you just won't get autocomplete for their `modelOptions`. + ## Environment Variables Create an API key at [fal.ai](https://fal.ai) and set it in your environment: @@ -265,6 +425,42 @@ Creates a fal.ai video adapter using the `FAL_KEY` environment variable or an ex Alias for `falVideo()`. +### `falSpeech(model, config?)` + +Creates a fal.ai text-to-speech adapter. + +**Parameters:** + +- `model` - The fal.ai TTS model ID (e.g., `"fal-ai/kokoro/american-english"`) +- `config.apiKey?` - Your fal.ai API key (falls back to `FAL_KEY` env var) +- `config.proxyUrl?` - Proxy URL for client-side usage + +**Returns:** A `FalSpeechAdapter` instance for use with `generateSpeech()`. The adapter fetches the generated audio URL from fal and returns it as base64 in `result.audio`. + +### `falTranscription(model, config?)` + +Creates a fal.ai transcription (speech-to-text) adapter. + +**Parameters:** + +- `model` - The fal.ai STT model ID (e.g., `"fal-ai/whisper"`) +- `config.apiKey?` - Your fal.ai API key (falls back to `FAL_KEY` env var) +- `config.proxyUrl?` - Proxy URL for client-side usage + +**Returns:** A `FalTranscriptionAdapter` instance for use with `generateTranscription()`. + +### `falAudio(model, config?)` + +Creates a fal.ai audio generation adapter (music and sound effects). + +**Parameters:** + +- `model` - The fal.ai audio model ID (e.g., `"fal-ai/diffrhythm"`, `"fal-ai/minimax-music/v2"`) +- `config.apiKey?` - Your fal.ai API key (falls back to `FAL_KEY` env var) +- `config.proxyUrl?` - Proxy URL for client-side usage + +**Returns:** A `FalAudioAdapter` instance for use with `generateAudio()`. The result contains a URL at `result.audio.url`. + ### `getFalApiKeyFromEnv()` Reads the `FAL_KEY` environment variable. Throws if not set. @@ -278,9 +474,8 @@ Configures the underlying `@fal-ai/client`. Called automatically by adapter cons ## Limitations - **No text/chat support** — Use OpenAI, Anthropic, Gemini, or another text adapter for `chat()` -- **No tools support** — Tool definitions are not applicable to image/video generation +- **No tools support** — Tool definitions are not applicable to media generation - **No summarization** — Use a text adapter for `summarize()` -- **No TTS or transcription yet** — Audio and speech support are coming soon - **Video is experimental** — The video generation API may change in future releases ## Next Steps diff --git a/docs/adapters/gemini.md b/docs/adapters/gemini.md index 84b5e95158..a3e4ff7e4e 100644 --- a/docs/adapters/gemini.md +++ b/docs/adapters/gemini.md @@ -2,6 +2,16 @@ title: Google Gemini id: gemini-adapter order: 3 +description: "Use Google Gemini with TanStack AI — text, image generation via Imagen and Gemini native (NanoBanana), and experimental TTS via @tanstack/ai-gemini." +keywords: + - tanstack ai + - gemini + - google gemini + - imagen + - nano banana + - image generation + - adapter + - google ai --- The Google Gemini adapter provides access to Google's Gemini models, including text generation, image generation with both Imagen and Gemini native image models (NanoBanana), and experimental text-to-speech. @@ -385,3 +395,162 @@ Creates a Gemini TTS adapter with an explicit API key. - [Getting Started](../getting-started/quick-start) - Learn the basics - [Tools Guide](../tools/tools) - Learn about tools - [Other Adapters](./openai) - Explore other providers + +## Provider Tools + +Google Gemini exposes several native tools beyond user-defined function calls. +Import them from `@tanstack/ai-gemini/tools` and pass them into +`chat({ tools: [...] })`. + +> For the full concept, a comparison matrix, and type-gating details, see +> [Provider Tools](../tools/provider-tools.md). + +### `codeExecutionTool` + +Enables Gemini to execute Python code in a sandboxed environment and return +results inline. Takes no arguments — include it in the `tools` array to +activate code execution. + +```typescript +import { chat } from "@tanstack/ai"; +import { geminiText } from "@tanstack/ai-gemini"; +import { codeExecutionTool } from "@tanstack/ai-gemini/tools"; + +const stream = chat({ + adapter: geminiText("gemini-2.5-pro"), + messages: [{ role: "user", content: "Calculate the first 10 Fibonacci numbers" }], + tools: [codeExecutionTool()], +}); +``` + +**Supported models:** Gemini 1.5 Pro, Gemini 2.x, Gemini 2.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `fileSearchTool` + +Searches files that have been uploaded to the Gemini File API. Pass a +`FileSearch` config object with the corpus and file IDs to scope the search. + +```typescript +import { chat } from "@tanstack/ai"; +import { geminiText } from "@tanstack/ai-gemini"; +import { fileSearchTool } from "@tanstack/ai-gemini/tools"; + +const stream = chat({ + adapter: geminiText("gemini-2.5-pro"), + messages: [{ role: "user", content: "Find the quarterly revenue figures" }], + tools: [ + fileSearchTool({ + fileSearchStoreNames: ["fileSearchStores/my-file-search-store-123"], + }), + ], +}); +``` + +**Supported models:** Gemini 2.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `googleSearchTool` + +Enables Gemini to query Google Search and incorporate grounded search results +into its response. Pass an optional `GoogleSearch` config or call with no +arguments to use defaults. + +```typescript +import { chat } from "@tanstack/ai"; +import { geminiText } from "@tanstack/ai-gemini"; +import { googleSearchTool } from "@tanstack/ai-gemini/tools"; + +const stream = chat({ + adapter: geminiText("gemini-2.5-pro"), + messages: [{ role: "user", content: "What's the weather in Tokyo right now?" }], + tools: [googleSearchTool()], +}); +``` + +**Supported models:** Gemini 1.5 Pro, Gemini 2.x, Gemini 2.5. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `googleSearchRetrievalTool` + +A retrieval-augmented variant of Google Search that returns ranked passages +from the web with configurable dynamic retrieval mode. Pass an optional +`GoogleSearchRetrieval` config. + +```typescript +import { chat } from "@tanstack/ai"; +import { geminiText } from "@tanstack/ai-gemini"; +import { googleSearchRetrievalTool } from "@tanstack/ai-gemini/tools"; + +const stream = chat({ + adapter: geminiText("gemini-2.5-pro"), + messages: [{ role: "user", content: "Explain the latest JavaScript proposals" }], + tools: [ + googleSearchRetrievalTool({ + dynamicRetrievalConfig: { mode: "MODE_DYNAMIC", dynamicThreshold: 0.7 }, + }), + ], +}); +``` + +**Supported models:** Gemini 1.5 Pro and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `googleMapsTool` + +Connects Gemini to the Google Maps API for location-aware queries such as +directions, place search, and geocoding. Pass an optional `GoogleMaps` config +or call with no arguments. + +```typescript +import { chat } from "@tanstack/ai"; +import { geminiText } from "@tanstack/ai-gemini"; +import { googleMapsTool } from "@tanstack/ai-gemini/tools"; + +const stream = chat({ + adapter: geminiText("gemini-2.5-pro"), + messages: [{ role: "user", content: "Find coffee shops near Union Square, SF" }], + tools: [googleMapsTool()], +}); +``` + +**Supported models:** Gemini 2.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `urlContextTool` + +Fetches and includes the content of URLs mentioned in the conversation so +Gemini can reason over live web pages. Takes no arguments. + +```typescript +import { chat } from "@tanstack/ai"; +import { geminiText } from "@tanstack/ai-gemini"; +import { urlContextTool } from "@tanstack/ai-gemini/tools"; + +const stream = chat({ + adapter: geminiText("gemini-2.5-pro"), + messages: [{ role: "user", content: "Summarise https://example.com/article" }], + tools: [urlContextTool()], +}); +``` + +**Supported models:** Gemini 2.x and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `computerUseTool` + +Allows Gemini to observe a virtual desktop via screenshots and interact with +it using predefined computer-use functions. Provide the `environment` and +optionally restrict callable functions via `excludedPredefinedFunctions`. + +```typescript +import { chat } from "@tanstack/ai"; +import { geminiText } from "@tanstack/ai-gemini"; +import { computerUseTool } from "@tanstack/ai-gemini/tools"; + +const stream = chat({ + adapter: geminiText("gemini-2.5-pro"), + messages: [{ role: "user", content: "Navigate to example.com in the browser" }], + tools: [ + computerUseTool({ + environment: "browser", + }), + ], +}); +``` + +**Supported models:** Gemini 2.5 and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). diff --git a/docs/adapters/grok.md b/docs/adapters/grok.md index b73662b9c6..b08cf40912 100644 --- a/docs/adapters/grok.md +++ b/docs/adapters/grok.md @@ -2,6 +2,15 @@ title: Grok (xAI) id: grok-adapter order: 5 +description: "Use xAI Grok models with TanStack AI — Grok 4.1, Grok 4, Grok 3, and Grok 2 Image generation via @tanstack/ai-grok." +keywords: + - tanstack ai + - grok + - xai + - grok 4 + - grok 4.1 + - image generation + - adapter --- The Grok adapter provides access to xAI's Grok models, including Grok 4.1, Grok 4, Grok 3, and image generation with Grok 2 Image. @@ -230,3 +239,12 @@ Creates a Grok image generation adapter with an explicit API key. - [Getting Started](../getting-started/quick-start) - Learn the basics - [Tools Guide](../tools/tools) - Learn about tools - [Other Adapters](./openai) - Explore other providers + +## Provider Tools + +Grok does not currently expose provider-specific tool factories. +Define your own tools with `toolDefinition()` from `@tanstack/ai`. + +See [Tools](../tools/tools.md) for the general tool-definition flow, or +[Provider Tools](../tools/provider-tools.md) for other providers' +native-tool offerings. diff --git a/docs/adapters/groq.md b/docs/adapters/groq.md index b6fcf4991d..b6ab115303 100644 --- a/docs/adapters/groq.md +++ b/docs/adapters/groq.md @@ -2,6 +2,15 @@ title: Groq id: groq-adapter order: 6 +description: "Use Groq's fast inference API with TanStack AI for low-latency LLM responses — Llama and other open-weight models via @tanstack/ai-groq." +keywords: + - tanstack ai + - groq + - fast inference + - llama + - low latency + - adapter + - llm --- The Groq adapter provides access to Groq's fast inference API, featuring the world's fastest LLM inference. @@ -270,3 +279,12 @@ Creates a Groq TTS adapter with an explicit API key. - [Getting Started](../getting-started/quick-start) - Learn the basics - [Tools Guide](../tools/tools) - Learn about tools - [Other Adapters](./openai) - Explore other providers + +## Provider Tools + +Groq does not currently expose provider-specific tool factories. +Define your own tools with `toolDefinition()` from `@tanstack/ai`. + +See [Tools](../tools/tools.md) for the general tool-definition flow, or +[Provider Tools](../tools/provider-tools.md) for other providers' +native-tool offerings. diff --git a/docs/adapters/ollama.md b/docs/adapters/ollama.md index 03bad0052f..0a83335a46 100644 --- a/docs/adapters/ollama.md +++ b/docs/adapters/ollama.md @@ -2,6 +2,16 @@ title: Ollama id: ollama-adapter order: 4 +description: "Run local LLMs with Ollama in TanStack AI for private, no-cost AI on your own hardware via the @tanstack/ai-ollama adapter." +keywords: + - tanstack ai + - ollama + - local llm + - self-hosted + - privacy + - llama + - offline ai + - adapter --- The Ollama adapter provides access to local models running via Ollama, allowing you to run AI models on your own infrastructure with full privacy and no API costs. diff --git a/docs/adapters/openai.md b/docs/adapters/openai.md index eda51463d5..122aaf520a 100644 --- a/docs/adapters/openai.md +++ b/docs/adapters/openai.md @@ -2,6 +2,17 @@ title: OpenAI id: openai-adapter order: 1 +description: "Use OpenAI models with TanStack AI — GPT-4o, GPT-5, DALL-E image generation, TTS, and Whisper transcription via @tanstack/ai-openai." +keywords: + - tanstack ai + - openai + - gpt-4o + - gpt-5 + - dall-e + - whisper + - openai tts + - adapter + - chatgpt --- The OpenAI adapter provides access to OpenAI's models, including GPT-4o, GPT-5, image generation (DALL-E), text-to-speech (TTS), and audio transcription (Whisper). @@ -331,3 +342,265 @@ Creates an OpenAI transcription adapter with an explicit API key. - [Getting Started](../getting-started/quick-start) - Learn the basics - [Tools Guide](../tools/tools) - Learn about tools - [Other Adapters](./anthropic) - Explore other providers + +## Provider Tools + +OpenAI exposes several native tools beyond user-defined function calls. +Import them from `@tanstack/ai-openai/tools` and pass them into +`chat({ tools: [...] })`. + +> For the full concept, a comparison matrix, and type-gating details, see +> [Provider Tools](../tools/provider-tools.md). + +### `webSearchTool` + +Enables the model to run a web search and return grounded results with +citations. Pass a `WebSearchToolConfig` object (typed from the OpenAI SDK) +to configure the tool. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { webSearchTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "What's new in AI this week?" }], + tools: [webSearchTool({ type: "web_search" })], +}); +``` + +**Supported models:** GPT-4o, GPT-5, and Responses API-capable models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `webSearchPreviewTool` + +The preview variant of web search with additional options for controlling +search context size and user location. Use this when you want fine-grained +control over the search context sent to the model. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { webSearchPreviewTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "Latest news about TypeScript" }], + tools: [ + webSearchPreviewTool({ + type: "web_search_preview_2025_03_11", + search_context_size: "high", + }), + ], +}); +``` + +**Supported models:** GPT-4o and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `fileSearchTool` + +Searches OpenAI vector stores that you have pre-populated, letting the model +retrieve relevant document chunks. Provide the `vector_store_ids` to search +and optionally limit results with `max_num_results` (1–50). + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { fileSearchTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "What does the handbook say about PTO?" }], + tools: [ + fileSearchTool({ + type: "file_search", + vector_store_ids: ["vs_abc123"], + max_num_results: 5, + }), + ], +}); +``` + +**Supported models:** GPT-4o and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `imageGenerationTool` + +Allows the model to generate images inline during a conversation using +DALL-E/GPT-Image. Pass quality, size, and style options via the config object. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { imageGenerationTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "Draw a logo for my app" }], + tools: [ + imageGenerationTool({ + quality: "high", + size: "1024x1024", + }), + ], +}); +``` + +**Supported models:** GPT-5 and GPT-Image-capable models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `codeInterpreterTool` + +Gives the model a sandboxed Python execution environment. The `container` +field configures the execution environment; pass the full +`CodeInterpreterToolConfig` object. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { codeInterpreterTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "Analyse this CSV and plot a chart" }], + tools: [ + codeInterpreterTool({ type: "code_interpreter", container: { type: "auto" } }), + ], +}); +``` + +**Supported models:** GPT-4o and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `mcpTool` + +Connects the model to a remote MCP (Model Context Protocol) server, exposing +all its capabilities as callable tools. Provide either `server_url` or +`connector_id` — not both. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { mcpTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "List my GitHub issues" }], + tools: [ + mcpTool({ + server_url: "https://mcp.example.com", + server_label: "github", + }), + ], +}); +``` + +**Supported models:** GPT-4o and above. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `computerUseTool` + +Lets the model observe a virtual desktop via screenshots and interact with +it using keyboard and mouse events. Provide the display dimensions and the +execution environment type. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { computerUseTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("computer-use-preview"), + messages: [{ role: "user", content: "Open Chrome and navigate to example.com" }], + tools: [ + computerUseTool({ + type: "computer_use_preview", + display_width: 1024, + display_height: 768, + environment: "browser", + }), + ], +}); +``` + +**Supported models:** `computer-use-preview`. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `localShellTool` + +Provides the model with a local shell for executing system commands. Takes no +arguments — the tool is enabled simply by including it in the `tools` array. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { localShellTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "Run the test suite and summarise failures" }], + tools: [localShellTool()], +}); +``` + +**Supported models:** GPT-5.x and other agent-capable models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `shellTool` + +A function-style shell tool that exposes shell execution as a structured +function call. Takes no arguments. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { shellTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "Count lines in all JS files" }], + tools: [shellTool()], +}); +``` + +**Supported models:** GPT-5.x and other agent-capable models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `applyPatchTool` + +Lets the model apply unified-diff patches to modify files directly. Takes no +arguments — include it in the `tools` array to enable patch application. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { applyPatchTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "Fix the import paths in src/index.ts" }], + tools: [applyPatchTool()], +}); +``` + +**Supported models:** GPT-5.x and other agent-capable models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). + +### `customTool` + +Defines a custom Responses API tool with an explicit name, description, and +format. Use this when none of the structured tool types fits your use case. +Unlike branded provider tools, `customTool` returns a plain `Tool` and is +accepted by any chat model. + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import { customTool } from "@tanstack/ai-openai/tools"; + +const stream = chat({ + adapter: openaiText("gpt-5.2"), + messages: [{ role: "user", content: "Look up order #1234" }], + tools: [ + customTool({ + type: "custom", + name: "lookup_order", + description: "Look up the status of a customer order by order ID", + }), + ], +}); +``` + +**Supported models:** all Responses API models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). diff --git a/docs/adapters/openrouter.md b/docs/adapters/openrouter.md index b51c18ca49..c61fcff96e 100644 --- a/docs/adapters/openrouter.md +++ b/docs/adapters/openrouter.md @@ -1,6 +1,15 @@ --- title: OpenRouter Adapter id: openrouter-adapter +description: "Access 300+ LLMs from OpenAI, Anthropic, Google, Meta, Mistral, and more through a single API with OpenRouter in TanStack AI." +keywords: + - tanstack ai + - openrouter + - multi-provider + - unified api + - llm gateway + - 300 models + - adapter --- OpenRouter is TanStack AI's first official AI partner and the recommended starting point for most projects. It provides access to 300+ models from OpenAI, Anthropic, Google, Meta, Mistral, and many more — all through a single API key and unified interface. @@ -128,5 +137,44 @@ const stream = chat({ ## Next Steps - [Getting Started](../getting-started/quick-start) - Learn the basics -- [Tools Guide](../tools/tools) - Learn about tools +- [Tools Guide](../tools/tools) - Learn about tools + +## Provider Tools + +> **Migrated from `createWebSearchTool`?** This factory was renamed to +> `webSearchTool` and moved to the `/tools` subpath in this release. +> See [Migration Guide §6](../migration/migration.md#6-provider-tools-moved-to-tools-subpath) +> for the exact before/after. + +OpenRouter's gateway exposes web search via a plugin that works across +any proxied chat model. Import it from `@tanstack/ai-openrouter/tools`. + +> For the full concept, a comparison matrix, and type-gating details, see +> [Provider Tools](../tools/provider-tools.md). + +### `webSearchTool` + +Adds web search capability to any OpenRouter-proxied chat model. Choose the +search `engine` (`native` or `exa`), cap results with `maxResults`, and +optionally provide a `searchPrompt` to guide query formation. + +```typescript +import { chat } from "@tanstack/ai"; +import { openRouterText } from "@tanstack/ai-openrouter"; +import { webSearchTool } from "@tanstack/ai-openrouter/tools"; + +const stream = chat({ + adapter: openRouterText("openai/gpt-5"), + messages: [{ role: "user", content: "What's new in AI this week?" }], + tools: [ + webSearchTool({ + engine: "exa", + maxResults: 5, + searchPrompt: "Recent AI news and research papers", + }), + ], +}); +``` + +**Supported models:** all OpenRouter chat models. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools). diff --git a/docs/advanced/debug-logging.md b/docs/advanced/debug-logging.md new file mode 100644 index 0000000000..3ebec740b6 --- /dev/null +++ b/docs/advanced/debug-logging.md @@ -0,0 +1,167 @@ +--- +title: Debug Logging +id: debug-logging +order: 3 +description: "Turn on structured, category-toggleable debug logging to see every chunk, middleware transform, and tool call inside TanStack AI." +keywords: + - tanstack ai + - debug + - logging + - logger + - pino + - troubleshooting + - chunks + - middleware debugging +--- + +# Debug Logging + +You have a `chat()` that isn't behaving as expected — a missing chunk, a middleware that doesn't seem to fire, a tool call with wrong args. By the end of this guide, you'll have turned on debug logging and will see every chunk, middleware transform, and tool call flowing through your call. + +## Turn it on + +Add `debug: true` to any activity call: + +```typescript +import { chat } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; + +const stream = chat({ + adapter: openaiText("gpt-4o"), + messages: [{ role: "user", content: "Hello" }], + debug: true, +}); +``` + +Every internal event now prints to the console with a `[tanstack-ai:]` prefix: + +``` +[tanstack-ai:request] activity=chat provider=openai model=gpt-4o messages=1 tools=0 stream=true +[tanstack-ai:agentLoop] run started +[tanstack-ai:provider] provider=openai type=response.output_text.delta +[tanstack-ai:output] type=TEXT_MESSAGE_CONTENT +... +``` + +## Narrow what's printed + +Pass a `DebugConfig` object instead of `true`. Every unspecified category defaults to `true`, so toggle by setting specific flags to `false`: + +```typescript +chat({ + adapter: openaiText("gpt-4o"), + messages, + debug: { middleware: false }, // everything except middleware +}); +``` + +If you want to see ONLY a specific set of categories, set the rest to `false` explicitly. Errors default to `true` — keep them on unless you really want total silence: + +```typescript +chat({ + adapter: openaiText("gpt-4o"), + messages, + debug: { + provider: true, + output: true, + middleware: false, + tools: false, + agentLoop: false, + config: false, + errors: true, // keep errors on — they're cheap and important + request: false, + }, +}); +``` + +## Pipe into your own logger + +Pass a `Logger` implementation and all debug output flows through it instead of `console`: + +```typescript +import type { Logger } from "@tanstack/ai"; +import pino from "pino"; + +const pinoLogger = pino(); +const logger: Logger = { + debug: (msg, meta) => pinoLogger.debug(meta, msg), + info: (msg, meta) => pinoLogger.info(meta, msg), + warn: (msg, meta) => pinoLogger.warn(meta, msg), + error: (msg, meta) => pinoLogger.error(meta, msg), +}; + +chat({ + adapter: openaiText("gpt-4o"), + messages, + debug: { logger }, // all categories on, piped to pino +}); +``` + +The default logger is exported as `ConsoleLogger` if you want to wrap it: + +```typescript +import { ConsoleLogger } from "@tanstack/ai"; +``` + +### Your `Logger` is wrapped in a try/catch + +If your `Logger` implementation throws — a cyclic-meta `JSON.stringify`, a transport that rejects synchronously, a typo in a bound `this` — the exception is swallowed so it never masks the real error that triggered the log call (for example, a provider SDK failure inside the chat stream). You won't see the log line, but the pipeline error still surfaces through thrown exceptions and `RUN_ERROR` chunks. + +If you need to know when your own logger is failing, guard inside your implementation: + +```typescript +const logger: Logger = { + debug: (msg, meta) => { + try { + pinoLogger.debug(meta, msg); + } catch (err) { + // surface to wherever you track infra errors + process.stderr.write(`logger failed: ${String(err)}\n`); + } + }, + // ... info, warn, error +}; +``` + +## Categories reference + +| Category | Logs | Applies to | +|----------|------|------------| +| `request` | Outgoing call to a provider (model, message count, tool count) | All activities | +| `provider` | Every raw chunk/frame received from a provider SDK | Streaming activities (`chat`, `realtime`, and streaming `generateAudio`/`generateSpeech`/`generateTranscription`) | +| `output` | Every chunk or result yielded to the caller | All activities | +| `middleware` | Inputs and outputs around every middleware hook | `chat()` only | +| `tools` | Before/after tool call execution | `chat()` only | +| `agentLoop` | Agent-loop iterations and phase transitions | `chat()` only | +| `config` | Config transforms returned by middleware `onConfig` hooks | `chat()` only | +| `errors` | Every caught error anywhere in the pipeline | All activities | + +## Errors are always logged + +Errors flow through the logger unconditionally — even when you omit `debug`: + +```typescript +chat({ adapter, messages }); // still prints [tanstack-ai:errors] ... on failure +``` + +To fully silence (including errors), set `debug: false` or `debug: { errors: false }`. Errors also always reach the caller via thrown exceptions or `RUN_ERROR` stream chunks — the logger is additive, not the only surface. + +## Non-chat activities + +The same `debug` option works on every activity: + +```typescript +summarize({ adapter, text, debug: true }); +generateImage({ adapter, prompt: "a cat", debug: { logger } }); +generateSpeech({ adapter, text, debug: { request: true } }); +generateAudio({ adapter, prompt: "ambient piano", debug: true }); +generateTranscription({ adapter, audio, debug: { provider: true } }); +``` + +When streaming any of these (`generateAudio`, `generateSpeech`, `generateTranscription` with `stream: true`), the `provider` category emits the raw SDK chunks and `output` emits the AG-UI-shaped chunks yielded to the caller — useful when a media pipeline looks stuck or the bytes arriving don't match what you expected. + +The chat-only categories (`middleware`, `tools`, `agentLoop`, `config`) simply never fire for these activities because those concepts don't exist in their pipelines. + +## Related + +If you're building middleware and want to see chunks flow through it, `debug: { middleware: true }` is faster than writing a logging middleware. See [Middleware](./middleware) for writing your own middleware, or [Observability](./observability) for the programmatic event client. diff --git a/docs/advanced/extend-adapter.md b/docs/advanced/extend-adapter.md index 5197e74766..145432b214 100644 --- a/docs/advanced/extend-adapter.md +++ b/docs/advanced/extend-adapter.md @@ -1,7 +1,16 @@ --- title: Extend Adapter id: extend-adapter -order: 7 +order: 8 +description: "Extend TanStack AI adapter factories with custom model IDs and fine-tuned models while keeping full type safety for input modalities and provider options." +keywords: + - tanstack ai + - extendAdapter + - custom models + - fine-tuned models + - createModel + - type safety + - adapter factory --- # Extending Adapters with Custom Models diff --git a/docs/advanced/middleware.md b/docs/advanced/middleware.md index 63a11898a3..91de53d957 100644 --- a/docs/advanced/middleware.md +++ b/docs/advanced/middleware.md @@ -2,6 +2,16 @@ title: Middleware id: middleware order: 1 +description: "Hook into every stage of TanStack AI's chat() lifecycle with middleware — logging, analytics, stream transforms, tool interception, and side effects." +keywords: + - tanstack ai + - middleware + - chat middleware + - lifecycle hooks + - observability + - logging + - tool interception + - stream transform --- Middleware lets you hook into every stage of the `chat()` lifecycle — from configuration to streaming, tool execution, usage tracking, and completion. You can observe, transform, or short-circuit behavior at each stage without modifying your adapter or tool implementations. @@ -39,6 +49,9 @@ const stream = chat({ }); ``` +> **Just want to see chunks flowing through your middleware during development?** +> Use `debug: { middleware: true }` on your `chat()` call — no custom middleware required. See [Debug Logging](./debug-logging). + ## Lifecycle Overview Every `chat()` invocation follows a predictable lifecycle. Middleware hooks fire at specific phases: diff --git a/docs/advanced/multimodal-content.md b/docs/advanced/multimodal-content.md index 6e9e626527..f30301e1bb 100644 --- a/docs/advanced/multimodal-content.md +++ b/docs/advanced/multimodal-content.md @@ -1,7 +1,18 @@ --- title: Multimodal Content id: multimodal-content -order: 3 +order: 4 +description: "Send images, audio, video, and documents alongside text in TanStack AI messages with typed ContentPart primitives for multimodal models." +keywords: + - tanstack ai + - multimodal + - vision + - images + - audio + - video + - documents + - ContentPart + - ImagePart --- TanStack AI supports multimodal content in messages, allowing you to send images, audio, video, and documents alongside text to AI models that support these modalities. diff --git a/docs/advanced/observability.md b/docs/advanced/observability.md index 95ebd79b0d..a9f9b0d546 100644 --- a/docs/advanced/observability.md +++ b/docs/advanced/observability.md @@ -2,6 +2,15 @@ title: Observability id: observability order: 2 +description: "Subscribe to TanStack AI events for observability and debugging — tool calls, streaming chunks, usage, and errors via the type-safe event client." +keywords: + - tanstack ai + - observability + - event client + - telemetry + - debugging + - tracing + - devtools --- # Event client @@ -10,6 +19,9 @@ The `@tanstack/ai` package offers you an event client for observability and debu It's a fully type-safe decoupled event-driven system that emits events whenever they are internally triggered and you can subscribe to those events for observability. +> **Looking for quick diagnostic console output instead of a programmatic event stream?** +> See [Debug Logging](./debug-logging) for turning on category-toggleable logging across every adapter and middleware hook. + Because the same event client is used for both the TanStack Devtools system and observability locally it will work by subscribing to the event bus and emitting events to/from the event bus into the listeners by default. If you want to subscribe to events in production as well you need to pass in a third argument to the `on` function, diff --git a/docs/advanced/per-model-type-safety.md b/docs/advanced/per-model-type-safety.md index 5e1857183f..27468ac380 100644 --- a/docs/advanced/per-model-type-safety.md +++ b/docs/advanced/per-model-type-safety.md @@ -1,7 +1,16 @@ --- title: Per-Model Type Safety id: per-model-type-safety -order: 4 +order: 5 +description: "TanStack AI narrows modelOptions and content types to the specific model you select, enforcing capabilities at compile time." +keywords: + - tanstack ai + - type safety + - per-model types + - modelOptions + - typescript + - autocomplete + - compile-time --- The AI SDK provides **model-specific type safety** for `modelOptions`. Each model's capabilities determine which model options are allowed, and TypeScript will enforce this at compile time. diff --git a/docs/advanced/runtime-adapter-switching.md b/docs/advanced/runtime-adapter-switching.md index ece1684604..ba13debb32 100644 --- a/docs/advanced/runtime-adapter-switching.md +++ b/docs/advanced/runtime-adapter-switching.md @@ -1,7 +1,15 @@ --- title: Runtime Adapter Switching id: runtime-adapter-switching -order: 5 +order: 6 +description: "Let users switch between LLM providers at runtime in TanStack AI while keeping full TypeScript type safety for each adapter's model options." +keywords: + - tanstack ai + - runtime switching + - multi-provider + - adapter factory + - type safety + - dynamic adapter --- # Runtime Adapter Switching with Type Safety diff --git a/docs/advanced/tree-shaking.md b/docs/advanced/tree-shaking.md index d8aca8d817..51b6162e65 100644 --- a/docs/advanced/tree-shaking.md +++ b/docs/advanced/tree-shaking.md @@ -1,7 +1,15 @@ --- title: Tree-Shaking id: tree-shaking -order: 6 +order: 7 +description: "TanStack AI's tree-shakeable architecture — import only the activities and adapters you use for minimal bundle size across chat, image, and speech." +keywords: + - tanstack ai + - tree-shaking + - bundle size + - modular imports + - performance + - tree-shakeable --- # Tree-Shaking & Bundle Optimization diff --git a/docs/api/ai-client.md b/docs/api/ai-client.md index f1a259babb..379e58589c 100644 --- a/docs/api/ai-client.md +++ b/docs/api/ai-client.md @@ -2,6 +2,15 @@ title: "@tanstack/ai-client" slug: /api/ai-client order: 2 +description: "API reference for @tanstack/ai-client — the framework-agnostic headless client for managing chat state and streaming transports." +keywords: + - tanstack ai + - "@tanstack/ai-client" + - headless client + - ChatClient + - chat state + - connection adapters + - api reference --- Framework-agnostic headless client for managing chat state and streaming. diff --git a/docs/api/ai-preact.md b/docs/api/ai-preact.md index 2dd31863ce..91ae5b7f58 100644 --- a/docs/api/ai-preact.md +++ b/docs/api/ai-preact.md @@ -2,6 +2,14 @@ title: "@tanstack/ai-preact" slug: /api/ai-preact order: 5 +description: "API reference for @tanstack/ai-preact — Preact hooks including useChat for streaming chat with full type safety in Preact apps." +keywords: + - tanstack ai + - "@tanstack/ai-preact" + - preact + - useChat + - preact hooks + - api reference --- Preact hooks for TanStack AI, providing convenient Preact bindings for the headless client. diff --git a/docs/api/ai-react.md b/docs/api/ai-react.md index e4b04c55f8..c736e207a8 100644 --- a/docs/api/ai-react.md +++ b/docs/api/ai-react.md @@ -2,6 +2,14 @@ title: "@tanstack/ai-react" slug: /api/ai-react order: 3 +description: "API reference for @tanstack/ai-react — React hooks including useChat for streaming chat with full type safety in React apps." +keywords: + - tanstack ai + - "@tanstack/ai-react" + - react + - useChat + - react hooks + - api reference --- React hooks for TanStack AI, providing convenient React bindings for the headless client. diff --git a/docs/api/ai-solid.md b/docs/api/ai-solid.md index 12c5ece16a..daaade764c 100644 --- a/docs/api/ai-solid.md +++ b/docs/api/ai-solid.md @@ -2,6 +2,15 @@ title: "@tanstack/ai-solid" slug: /api/ai-solid order: 4 +description: "API reference for @tanstack/ai-solid — SolidJS primitives including useChat for streaming chat with full type safety." +keywords: + - tanstack ai + - "@tanstack/ai-solid" + - solidjs + - solid + - useChat + - solid primitives + - api reference --- SolidJS primitives for TanStack AI, providing convenient SolidJS bindings for the headless client. diff --git a/docs/api/ai-svelte.md b/docs/api/ai-svelte.md index f67a3c1e3b..09e4340328 100644 --- a/docs/api/ai-svelte.md +++ b/docs/api/ai-svelte.md @@ -2,6 +2,15 @@ title: "@tanstack/ai-svelte" id: ai-svelte order: 6 +description: "API reference for @tanstack/ai-svelte — Svelte 5 reactive factory functions for streaming chat built on runes." +keywords: + - tanstack ai + - "@tanstack/ai-svelte" + - svelte + - svelte 5 + - createChat + - runes + - api reference --- Svelte 5 bindings for TanStack AI, providing reactive factory functions for the headless client using Svelte runes. diff --git a/docs/api/ai-vue.md b/docs/api/ai-vue.md index 68e566aea3..be3d6f681b 100644 --- a/docs/api/ai-vue.md +++ b/docs/api/ai-vue.md @@ -2,6 +2,15 @@ title: "@tanstack/ai-vue" id: ai-vue order: 5 +description: "API reference for @tanstack/ai-vue — Vue 3 composables including useChat for streaming chat with full type safety." +keywords: + - tanstack ai + - "@tanstack/ai-vue" + - vue + - vue 3 + - useChat + - composables + - api reference --- Vue composables for TanStack AI, providing convenient Vue 3 bindings for the headless client. diff --git a/docs/api/ai.md b/docs/api/ai.md index f98010cd0c..da0970d141 100644 --- a/docs/api/ai.md +++ b/docs/api/ai.md @@ -2,6 +2,15 @@ title: "@tanstack/ai" id: tanstack-ai-api order: 1 +description: "API reference for @tanstack/ai — the core TanStack AI library providing chat(), generateImage(), toolDefinition(), and streaming utilities." +keywords: + - tanstack ai + - "@tanstack/ai" + - api reference + - chat + - toolDefinition + - generateImage + - core library --- The core AI library for TanStack AI. diff --git a/docs/architecture/approval-flow-processing.md b/docs/architecture/approval-flow-processing.md index 5f033a406e..0441ea4167 100644 --- a/docs/architecture/approval-flow-processing.md +++ b/docs/architecture/approval-flow-processing.md @@ -1,3 +1,18 @@ +--- +title: Approval Flow Processing Architecture +id: approval-flow-processing +description: "Internal architecture of TanStack AI's tool approval system — state machine, streaming protocol, concurrency control, and chained approval mechanics." +keywords: + - tanstack ai + - approval flow + - tool approval + - architecture + - state machine + - streaming protocol + - internals + - concurrency +--- + # Approval Flow Processing Architecture > Internal architecture reference for the tool approval system in TanStack AI. diff --git a/docs/chat/agentic-cycle.md b/docs/chat/agentic-cycle.md index d0627ba3f1..bdabba19f1 100644 --- a/docs/chat/agentic-cycle.md +++ b/docs/chat/agentic-cycle.md @@ -2,6 +2,14 @@ title: Agentic Cycle id: agentic-cycle order: 1 +description: "The agentic cycle in TanStack AI — how the LLM loops through tool calls, results, and reasoning until it produces a final answer." +keywords: + - tanstack ai + - agentic cycle + - agent loop + - tool calling + - multi-step reasoning + - ai agents --- The agentic cycle is the pattern where the LLM repeatedly calls tools, receives results, and continues reasoning until it can provide a final answer. This enables complex multi-step operations. diff --git a/docs/chat/connection-adapters.md b/docs/chat/connection-adapters.md index 70329125c7..e2e5706c62 100644 --- a/docs/chat/connection-adapters.md +++ b/docs/chat/connection-adapters.md @@ -2,6 +2,15 @@ title: Connection Adapters id: connection-adapters order: 3 +description: "Connection adapters in TanStack AI bridge client and server for streaming chat responses — SSE, HTTP stream, direct async iterables, and custom transports." +keywords: + - tanstack ai + - connection adapters + - sse + - server-sent events + - http stream + - streaming transport + - fetchServerSentEvents --- @@ -72,6 +81,62 @@ const { messages } = useChat({ }); ``` +### TanStack Start Server Functions + +`stream()` adapts a TanStack Start server function into a `useChat` connection so you get end-to-end type safety from the call site to the handler. The factory you pass to `stream()` may return either the chat `AsyncIterable` directly, or an SSE `Response` produced by `toServerSentEventsResponse()` — `stream()` awaits the result and unwraps a `Response` if it sees one. + +#### Returning an SSE Response (recommended) + +Wrap the chat stream in `toServerSentEventsResponse()` so only encoded bytes flow over the wire. The client parses the SSE automatically: + +```typescript +// server-fns.ts +import { createServerFn } from "@tanstack/react-start"; +import { chat, toServerSentEventsResponse } from "@tanstack/ai"; +import { openaiText } from "@tanstack/ai-openai"; +import type { UIMessage } from "@tanstack/ai"; + +export const chatFn = createServerFn({ method: "POST" }) + .inputValidator((data: { messages: Array }) => data) + .handler(({ data }) => + toServerSentEventsResponse( + chat({ + adapter: openaiText("gpt-4o"), + messages: data.messages, + }), + ), + ); +``` + +```tsx +// client +import { useChat, stream } from "@tanstack/ai-react"; +import { chatFn } from "./server-fns"; + +const { messages, sendMessage } = useChat({ + connection: stream((messages) => chatFn({ data: { messages } })), +}); +``` + +#### Returning the AsyncIterable directly + +If you don't want to encode an HTTP response, return the chat stream itself. `stream()` awaits the server function and yields chunks straight through: + +```typescript +// server-fns.ts +export const chatFn = createServerFn({ method: "POST" }) + .inputValidator((data: { messages: Array }) => data) + .handler(({ data }) => + chat({ adapter: openaiText("gpt-4o"), messages: data.messages }), + ); +``` + +```tsx +const { messages, sendMessage } = useChat({ + connection: stream((messages) => chatFn({ data: { messages } })), +}); +``` + ## Custom Adapters For specialized use cases, you can create custom adapters to meet specific protocols or requirements: diff --git a/docs/chat/streaming.md b/docs/chat/streaming.md index 2c799a7727..a11bd2ca26 100644 --- a/docs/chat/streaming.md +++ b/docs/chat/streaming.md @@ -2,6 +2,15 @@ title: Streaming id: streaming-responses order: 2 +description: "Stream AI responses in real time with TanStack AI — async iterable chunks, chunk strategies, and partial JSON for responsive chat UIs." +keywords: + - tanstack ai + - streaming + - streaming responses + - real-time ai + - async iterable + - chunks + - partial json --- TanStack AI supports streaming responses for real-time chat experiences. Streaming allows you to display responses as they're generated, rather than waiting for the complete response. diff --git a/docs/chat/structured-outputs.md b/docs/chat/structured-outputs.md index fa25babc7d..6bcd9c7a73 100644 --- a/docs/chat/structured-outputs.md +++ b/docs/chat/structured-outputs.md @@ -2,6 +2,16 @@ title: Structured Outputs id: structured-outputs order: 4 +description: "Constrain TanStack AI responses to a JSON Schema for typed, predictable structured output using Zod, Valibot, or any Standard Schema library." +keywords: + - tanstack ai + - structured outputs + - json schema + - zod + - valibot + - standard schema + - type-safe llm + - outputSchema --- Structured outputs allow you to constrain AI model responses to match a specific JSON schema, ensuring consistent and type-safe data extraction. TanStack AI uses the [Standard JSON Schema](https://standardschema.dev/) specification, allowing you to use any compatible schema library. diff --git a/docs/chat/thinking-content.md b/docs/chat/thinking-content.md index 72c1cd515a..831f2ce4ef 100644 --- a/docs/chat/thinking-content.md +++ b/docs/chat/thinking-content.md @@ -2,6 +2,16 @@ title: Thinking & Reasoning id: thinking-content order: 5 +description: "Render reasoning tokens from thinking models (Claude extended thinking, OpenAI o-series) as streamed ThinkingPart in TanStack AI chat UIs." +keywords: + - tanstack ai + - thinking + - reasoning + - extended thinking + - claude thinking + - o-series + - chain of thought + - ThinkingPart --- Some models expose their internal reasoning as "thinking" content -- Claude with extended thinking, OpenAI o-series models with reasoning, and others. TanStack AI captures this as `ThinkingPart` in messages, streamed to your UI in real-time alongside text and tool calls. diff --git a/docs/code-mode/client-integration.md b/docs/code-mode/client-integration.md index e91ad77aa3..1a4a69c156 100644 --- a/docs/code-mode/client-integration.md +++ b/docs/code-mode/client-integration.md @@ -2,6 +2,15 @@ title: Showing Code Mode in the UI id: code-mode-client-integration order: 2 +description: "Stream Code Mode execution events to your React app — console output, external calls, and results as they happen, via onCustomEvent." +keywords: + - tanstack ai + - code mode + - react ui + - custom events + - onCustomEvent + - streaming ui + - execution progress --- You have [Code Mode](./code-mode) working on your server — the LLM writes and executes TypeScript, and you get results back. But your users see nothing while the sandbox runs. By the end of this guide, your React app will show real-time execution progress: console output, external function calls, and final results as they stream in. diff --git a/docs/code-mode/code-mode-isolates.md b/docs/code-mode/code-mode-isolates.md index ed1d44eb89..81c447fcda 100644 --- a/docs/code-mode/code-mode-isolates.md +++ b/docs/code-mode/code-mode-isolates.md @@ -2,6 +2,16 @@ title: Code Mode Isolate Drivers id: code-mode-isolates order: 4 +description: "Compare Code Mode sandbox drivers — Node isolated-vm, QuickJS WASM, and Cloudflare Workers — and choose the right runtime for your deployment." +keywords: + - tanstack ai + - code mode + - isolate driver + - isolated-vm + - quickjs + - cloudflare workers + - sandbox + - secure execution --- Isolate drivers provide the secure sandbox runtimes that [Code Mode](./code-mode.md) uses to execute generated TypeScript. All drivers implement the same `IsolateDriver` interface, so you can swap them without changing any other code. diff --git a/docs/code-mode/code-mode-with-skills.md b/docs/code-mode/code-mode-with-skills.md index 59c1e1f81b..a77a0b7369 100644 --- a/docs/code-mode/code-mode-with-skills.md +++ b/docs/code-mode/code-mode-with-skills.md @@ -2,10 +2,22 @@ title: Code Mode with Skills id: code-mode-with-skills order: 3 +description: "Teach Code Mode to save and reuse working code as named skills backed by persistent storage — faster follow-up requests and composable agent memory." +keywords: + - tanstack ai + - code mode + - skills + - skill library + - register_skill + - reusable snippets + - agent memory + - skill storage --- Skills extend [Code Mode](./code-mode.md) with a persistent library of reusable TypeScript snippets. When the LLM writes a useful piece of code — say, a function that fetches and ranks NPM packages — it can save that code as a _skill_. On future requests, relevant skills are loaded from storage and made available as first-class tools the LLM can call without re-writing the logic. +> **Different from agent-authoring skills.** The skills on this page are _runtime_ snippets the chat LLM saves and reuses. If you're looking to teach your coding assistant (Claude Code, Cursor, etc.) how TanStack AI itself works, see [Agent Skills (TanStack Intent)](../getting-started/agent-skills). + ## Overview The skills system has two integration paths: diff --git a/docs/code-mode/code-mode.md b/docs/code-mode/code-mode.md index 52a9228663..aa2f9ddbef 100644 --- a/docs/code-mode/code-mode.md +++ b/docs/code-mode/code-mode.md @@ -2,6 +2,15 @@ title: Code Mode id: code-mode order: 1 +description: "Let LLMs write and execute TypeScript programs that orchestrate tools in a secure sandbox with TanStack AI Code Mode — fewer loops, richer logic." +keywords: + - tanstack ai + - code mode + - sandbox + - typescript execution + - tool orchestration + - execute_typescript + - ai agents --- Code Mode lets an LLM write and execute TypeScript programs inside a secure sandbox. Instead of making one tool call at a time, the model writes a short script that orchestrates multiple tools with loops, conditionals, `Promise.all`, and data transformations — then returns a single result. diff --git a/docs/community-adapters/cencori.md b/docs/community-adapters/cencori.md index f75b12f46d..f1de312174 100644 --- a/docs/community-adapters/cencori.md +++ b/docs/community-adapters/cencori.md @@ -2,6 +2,15 @@ title: Cencori id: cencori-adapter order: 3 +description: "Access 14+ AI providers (OpenAI, Anthropic, Google, xAI, and more) through Cencori's unified interface with built-in security, observability, and cost tracking in TanStack AI." +keywords: + - tanstack ai + - cencori + - multi-provider + - observability + - cost tracking + - security + - community adapter --- The Cencori adapter provides access to 14+ AI providers (OpenAI, Anthropic, Google, xAI, and more) through a unified interface with built-in security, observability, and cost tracking. diff --git a/docs/community-adapters/cloudflare.md b/docs/community-adapters/cloudflare.md index 3c9001543c..a34e54860d 100644 --- a/docs/community-adapters/cloudflare.md +++ b/docs/community-adapters/cloudflare.md @@ -2,6 +2,16 @@ title: Cloudflare id: cloudflare-adapter order: 3 +description: "Use Cloudflare Workers AI and AI Gateway with TanStack AI for edge inference, caching, rate limiting, and unified billing across providers." +keywords: + - tanstack ai + - cloudflare + - workers ai + - ai gateway + - edge inference + - caching + - rate limiting + - community adapter --- The Cloudflare adapter provides access to [Cloudflare Workers AI](https://developers.cloudflare.com/workers-ai/) models and [AI Gateway](https://developers.cloudflare.com/ai-gateway/) for routing requests to OpenAI, Anthropic, Gemini, Grok, and OpenRouter with caching, rate limiting, and unified billing. diff --git a/docs/community-adapters/decart.md b/docs/community-adapters/decart.md index be61d401b6..d7bd463218 100644 --- a/docs/community-adapters/decart.md +++ b/docs/community-adapters/decart.md @@ -2,6 +2,13 @@ title: Decart id: decart-adapter order: 2 +description: "Generate images and videos with Decart's AI models in TanStack AI via the Decart community adapter." +keywords: + - tanstack ai + - decart + - image generation + - video generation + - community adapter --- The Decart adapter provides access to Decart's image and video generation models. diff --git a/docs/community-adapters/guide.md b/docs/community-adapters/guide.md index 2216856492..3c85c3fae8 100644 --- a/docs/community-adapters/guide.md +++ b/docs/community-adapters/guide.md @@ -1,7 +1,16 @@ ---- +--- title: "Community Adapters Guide" slug: /community-adapters/guide order: 1 +description: "Build and publish a community adapter for TanStack AI — package conventions, implementing the adapter interface, and publishing to npm." +keywords: + - tanstack ai + - community adapters + - build adapter + - custom adapter + - provider integration + - adapter authoring + - contribute --- # Community Adapters Guide diff --git a/docs/community-adapters/mynth.md b/docs/community-adapters/mynth.md index 6f2183a1dd..d9a68b045c 100644 --- a/docs/community-adapters/mynth.md +++ b/docs/community-adapters/mynth.md @@ -1,3 +1,18 @@ +--- +title: Mynth +id: mynth-adapter +description: "Generate images with Mynth models — Flux, Recraft, Gemini, Qwen, Seedream, Wan, and Grok Imagine — in TanStack AI via the Mynth community adapter." +keywords: + - tanstack ai + - mynth + - image generation + - flux + - recraft + - qwen + - seedream + - community adapter +--- + # Mynth > **Alpha:** Mynth is currently in public alpha. We are publishing TanStack AI adapters early to gather feedback on the API, supported models, and integration experience while the platform is still evolving. diff --git a/docs/community-adapters/soniox.md b/docs/community-adapters/soniox.md index e941c3e0b4..77abce377e 100644 --- a/docs/community-adapters/soniox.md +++ b/docs/community-adapters/soniox.md @@ -2,6 +2,14 @@ title: Soniox id: soniox-adapter order: 3 +description: "Transcribe audio with Soniox speech-to-text models in TanStack AI via the Soniox community adapter." +keywords: + - tanstack ai + - soniox + - transcription + - speech-to-text + - asr + - community adapter --- The Soniox adapter provides access to Soniox transcription models. diff --git a/docs/comparison/vercel-ai-sdk.md b/docs/comparison/vercel-ai-sdk.md index 02ce2b8881..415a4731cd 100644 --- a/docs/comparison/vercel-ai-sdk.md +++ b/docs/comparison/vercel-ai-sdk.md @@ -2,6 +2,16 @@ title: TanStack AI vs Vercel AI SDK id: vercel-ai-sdk order: 1 +description: "How TanStack AI compares to the Vercel AI SDK — feature matrix, philosophy, type safety, tool calling, streaming, and framework support." +keywords: + - tanstack ai + - vercel ai sdk + - comparison + - ai sdk + - alternatives + - typescript ai sdk + - tool calling + - llm --- Both TanStack AI and Vercel AI SDK are open-source TypeScript toolkits for building AI-powered applications. They share common ground - streaming chat, tool calling, multi-provider support, and deploy-anywhere flexibility - but they approach the problem from fundamentally different directions. diff --git a/docs/config.json b/docs/config.json index a4377a9af2..f24a5fa0af 100644 --- a/docs/config.json +++ b/docs/config.json @@ -32,6 +32,10 @@ { "label": "Quick Start: Server Only", "to": "getting-started/quick-start-server" + }, + { + "label": "Agent Skills (TanStack Intent)", + "to": "getting-started/agent-skills" } ] }, @@ -51,6 +55,10 @@ "label": "Tools", "to": "tools/tools" }, + { + "label": "Provider Tools", + "to": "tools/provider-tools" + }, { "label": "Tool Architecture", "to": "tools/tool-architecture" @@ -138,6 +146,10 @@ "label": "Transcription", "to": "media/transcription" }, + { + "label": "Audio Generation", + "to": "media/audio-generation" + }, { "label": "Image Generation", "to": "media/image-generation" @@ -159,6 +171,10 @@ "label": "Middleware", "to": "advanced/middleware" }, + { + "label": "Debug Logging", + "to": "advanced/debug-logging" + }, { "label": "Observability", "to": "advanced/observability" @@ -191,6 +207,10 @@ { "label": "Migration Guide", "to": "migration/migration" + }, + { + "label": "From Vercel AI SDK", + "to": "migration/migration-from-vercel-ai" } ] }, diff --git a/docs/getting-started/agent-skills.md b/docs/getting-started/agent-skills.md new file mode 100644 index 0000000000..a3441133dd --- /dev/null +++ b/docs/getting-started/agent-skills.md @@ -0,0 +1,109 @@ +--- +title: Agent Skills (TanStack Intent) +id: agent-skills +order: 6 +description: "Use TanStack Intent to wire TanStack AI's bundled Agent Skills into Claude Code, Cursor, GitHub Copilot, and other AI coding assistants." +keywords: + - tanstack ai + - tanstack intent + - agent skills + - claude code + - cursor + - github copilot + - ai coding agents + - SKILL.md + - AGENTS.md +--- + +You're building with TanStack AI and using an AI coding agent — Claude Code, Cursor, GitHub Copilot, or similar. The agent keeps suggesting Vercel-AI-SDK patterns like `streamText()` or `createOpenAI()`, or it wires streams manually instead of using `toServerSentEventsResponse()`. By the end of this guide, your agent will load TanStack AI's bundled skills automatically whenever you work on AI code — and those skills will stay in sync with whichever `@tanstack/ai` version your project installs. + +> **Looking for runtime skills inside Code Mode?** Those are a different feature — see [Code Mode with Skills](../code-mode/code-mode-with-skills). This page is about _agent-authoring_ skills: markdown files that teach your coding assistant how TanStack AI works. + +## What are Agent Skills? + +Agent Skills are markdown documents (`SKILL.md`) that ship inside npm packages and tell AI coding agents how to use a library correctly — which functions to use, which patterns to avoid, and when to reach for which module. The format is an open standard supported by Claude Code, Cursor, GitHub Copilot, Codex, and others. + +TanStack AI publishes skills inside its packages so the guidance travels with `npm update` instead of being pinned in a model's training data or copy-pasted into `CLAUDE.md` manually. + +## Skills Shipped by TanStack AI + +| Package | Skill | What it teaches | +|---------|-------|-----------------| +| `@tanstack/ai` | `ai-core` | Chat experience, tool calling, adapters, middleware, structured outputs, media generation, AG-UI protocol, custom backends | +| `@tanstack/ai-code-mode` | `ai-code-mode` | Setting up Code Mode with a sandbox driver and registering server tools | + +Each skill lives under `node_modules//skills//SKILL.md` once the package is installed. + +## Step 1: Install TanStack AI + +If you haven't already, install `@tanstack/ai` plus any adapter packages you need. See the [Quick Start](./quick-start) for a full walkthrough. + +```bash +pnpm add @tanstack/ai @tanstack/ai-openai +``` + +## Step 2: Run `intent install` + +From the root of your project, run: + +```bash +npx @tanstack/intent@latest install +``` + +The CLI walks your agent through the setup. It scans `node_modules` for every package that ships skills (any package with the `tanstack-intent` keyword), asks your agent to propose task-to-skill mappings that match your codebase, and writes them into your agent's config file. + +By default the mappings land in `AGENTS.md`. The CLI can also target: + +- `CLAUDE.md` — Claude Code +- `.cursorrules` — Cursor +- any other agent config file you point it at + +## Step 3: Review the Generated Mappings + +The install command appends (or creates) an `intent-skills` block that looks like this: + +```yaml + +# Skill mappings — when working in these areas, load the linked skill file into context. +skills: + - task: "Building chat, tool calling, adapters, or streaming with TanStack AI" + load: "node_modules/@tanstack/ai/skills/ai-core/SKILL.md" + - task: "Setting up Code Mode with TanStack AI" + load: "node_modules/@tanstack/ai-code-mode/skills/ai-code-mode/SKILL.md" + +``` + +Check that the `task:` descriptions match areas you actually work in. Tighten or reword them if needed — they're how your agent decides when to pull the skill into context. + +## Step 4: Confirm It's Wired Up + +Open a fresh session in your coding agent and ask it to build something with TanStack AI — for example: _"Add a streaming chat endpoint using `@tanstack/ai` and the OpenAI adapter."_ + +You should see: + +- The agent uses `chat()`, not `streamText()`. +- The adapter is imported as `openaiText()` from `@tanstack/ai-openai`, not `createOpenAI()`. +- The response is wrapped with `toServerSentEventsResponse()` instead of manual SSE wiring. +- Middleware is used for lifecycle events (no `onFinish` callback on `chat()`). + +If the agent still falls back to other-SDK patterns, re-open its config file and confirm the `intent-skills` block is present and the `task:` descriptions clearly cover the area you're asking about. + +## Keeping Skills Current + +Skills are versioned with the package. When you bump `@tanstack/ai`, the `SKILL.md` files under `node_modules` update with it — no CLI re-run needed. Re-run `npx @tanstack/intent@latest install` only when you _add_ a new intent-enabled package (for example, adding `@tanstack/ai-code-mode` later) or want to refresh the task mappings. + +## Using Skills Without the CLI + +If you'd rather wire skills in yourself, you can reference them directly from `node_modules` in any agent config file. The minimum your agent needs is a pointer to the file: + +```markdown +When working on TanStack AI code, read and follow: +node_modules/@tanstack/ai/skills/ai-core/SKILL.md +``` + +The CLI is recommended because it discovers packages automatically and stays consistent with the agent-skills standard, but the underlying file paths are stable. + +## Learn More + +- [TanStack Intent documentation](https://tanstack.com/intent/latest/docs/overview) — the CLI's full reference, including `scaffold`, `validate`, and CI setup for library maintainers. +- [Agent Skills registry](https://tanstack.com/intent/registry) — browse other intent-enabled packages. diff --git a/docs/getting-started/devtools.md b/docs/getting-started/devtools.md index 83d7b10c6e..5178dbef06 100644 --- a/docs/getting-started/devtools.md +++ b/docs/getting-started/devtools.md @@ -2,6 +2,15 @@ title: Devtools id: devtools order: 3 +description: "Inspect and debug TanStack AI apps with the TanStack Devtools panel — live chat messages, tool call inputs and outputs, state, and errors." +keywords: + - tanstack ai + - devtools + - debugging + - tool inspection + - chat inspector + - react devtools + - observability --- TanStack Devtools is a unified devtools panel for inspecting and debugging TanStack libraries, including TanStack AI. It provides real-time insights into AI interactions, tool calls, and state changes, making it easier to develop and troubleshoot AI-powered applications. diff --git a/docs/getting-started/overview.md b/docs/getting-started/overview.md index 84447eba8a..0523af39b7 100644 --- a/docs/getting-started/overview.md +++ b/docs/getting-started/overview.md @@ -2,6 +2,16 @@ title: Overview id: overview order: 1 +description: "TanStack AI is a type-safe, provider-agnostic TypeScript SDK for building streaming chat, tool calling, and AI features that work across any framework." +keywords: + - tanstack ai + - ai sdk + - typescript ai + - streaming chat + - tool calling + - isomorphic tools + - framework agnostic + - llm sdk --- TanStack AI is a lightweight, type-safe SDK for building production-ready AI experiences. Its framework-agnostic core provides type-safe tool/function calling, streaming responses, and first-class React and Solid integrations, with adapters for multiple LLM providers — enabling predictable, composable, and testable AI features across any stack. diff --git a/docs/getting-started/quick-start-server.md b/docs/getting-started/quick-start-server.md index 96bd272f6e..6ef6176714 100644 --- a/docs/getting-started/quick-start-server.md +++ b/docs/getting-started/quick-start-server.md @@ -2,6 +2,16 @@ title: "Quick Start: Server Only" id: quick-start-server order: 5 +description: "Add a streaming AI chat endpoint to a Node.js backend with TanStack AI — no UI framework required." +keywords: + - tanstack ai + - node.js + - server + - backend + - quick start + - streaming chat + - openai + - sse --- You have a Node.js backend and want to add AI capabilities. By the end of this guide, you'll have a working chat endpoint powered by TanStack AI and OpenAI -- no UI framework required. diff --git a/docs/getting-started/quick-start-svelte.md b/docs/getting-started/quick-start-svelte.md index 7e2e06df73..0d3b6b14d3 100644 --- a/docs/getting-started/quick-start-svelte.md +++ b/docs/getting-started/quick-start-svelte.md @@ -2,6 +2,16 @@ title: "Quick Start: Svelte" id: quick-start-svelte order: 4 +description: "Add a streaming TanStack AI chat component to a SvelteKit app using Svelte 5 runes and the OpenAI adapter." +keywords: + - tanstack ai + - svelte + - sveltekit + - svelte 5 + - quick start + - streaming chat + - openai + - runes --- You have a SvelteKit app and want to add AI chat. By the end of this guide, you'll have a streaming chat component powered by TanStack AI and OpenAI. diff --git a/docs/getting-started/quick-start-vue.md b/docs/getting-started/quick-start-vue.md index dc092045bd..23547fbcc6 100644 --- a/docs/getting-started/quick-start-vue.md +++ b/docs/getting-started/quick-start-vue.md @@ -2,6 +2,16 @@ title: "Quick Start: Vue" id: quick-start-vue order: 3 +description: "Build a streaming TanStack AI chat component in a Vue 3 app using the useChat composable and the OpenAI adapter." +keywords: + - tanstack ai + - vue + - vue 3 + - quick start + - useChat + - streaming chat + - openai + - composable --- You have a Vue 3 app and want to add AI chat. By the end of this guide, you'll have a streaming chat component powered by TanStack AI and OpenAI. diff --git a/docs/getting-started/quick-start.md b/docs/getting-started/quick-start.md index 02fc29aa39..fb5e925772 100644 --- a/docs/getting-started/quick-start.md +++ b/docs/getting-started/quick-start.md @@ -2,6 +2,16 @@ title: "Quick Start: React" id: quick-start order: 2 +description: "Add a streaming TanStack AI chat to a React app in minutes using the useChat hook and the OpenAI adapter." +keywords: + - tanstack ai + - react + - quick start + - useChat + - streaming chat + - openai + - tutorial + - ai chatbot --- Get started with TanStack AI in minutes. This guide will walk you through creating a simple chat application using the React integration and OpenAI adapter. diff --git a/docs/media/audio-generation.md b/docs/media/audio-generation.md new file mode 100644 index 0000000000..6cc3e5aeb2 --- /dev/null +++ b/docs/media/audio-generation.md @@ -0,0 +1,218 @@ +--- +title: Audio Generation +id: audio-generation +order: 15 +--- + +# Audio Generation + +TanStack AI's `generateAudio()` activity produces audio content — music, soundscapes, or sound effects — from a text prompt. It's distinct from [Text-to-Speech](./text-to-speech), which is optimized for spoken-word synthesis. + +## Overview + +Audio generation is handled by audio adapters that follow the same tree-shakeable architecture as other adapters in TanStack AI. + +Currently supported: + +- **Google Gemini**: Lyria 3 Pro and Lyria 3 Clip music generation +- **fal.ai**: MiniMax Music, DiffRhythm, Google Lyria 2, Stable Audio 2.5, MMAudio, ElevenLabs sound effects, Thinksound, and more + +## Basic Usage + +### Google Lyria (Music) + +Google's Lyria models generate full-length songs with vocals and instrumentation. `lyria-3-pro-preview` handles multi-verse compositions, while `lyria-3-clip-preview` produces 30-second clips. + +```typescript +import { generateAudio } from '@tanstack/ai' +import { geminiAudio } from '@tanstack/ai-gemini' + +const result = await generateAudio({ + adapter: geminiAudio('lyria-3-pro-preview'), + prompt: 'Uplifting indie pop with layered vocals and jangly guitars', +}) + +console.log(result.audio.url) // URL to the generated audio file +console.log(result.audio.contentType) // e.g. "audio/mpeg" +``` + +### fal.ai + +fal.ai gives access to a broad catalogue of music, SFX, and general audio models through a single `falAudio` adapter. + +#### Music Generation (MiniMax Music 2.6) + +MiniMax's latest music model creates full compositions — vocals, backing music, and arrangements — from a single prompt. + +```typescript +import { generateAudio } from '@tanstack/ai' +import { falAudio } from '@tanstack/ai-fal' + +const result = await generateAudio({ + adapter: falAudio('fal-ai/minimax-music/v2.6'), + prompt: 'City Pop, 80s retro, groovy synth bass, warm female vocal, 104 BPM', +}) + +console.log(result.audio.url) // URL to the generated audio file +console.log(result.audio.contentType) // e.g. "audio/wav" +``` + +#### Music with Explicit Lyrics (DiffRhythm) + +```typescript +const result = await generateAudio({ + adapter: falAudio('fal-ai/diffrhythm'), + prompt: 'An upbeat electronic track with synths', + modelOptions: { + lyrics: '[verse]\nHello world\n[chorus]\nLa la la', + }, +}) +``` + +#### Sound Effects + +```typescript +const result = await generateAudio({ + adapter: falAudio('fal-ai/elevenlabs/sound-effects/v2'), + prompt: 'Thunderclap followed by heavy rain', + duration: 5, +}) +``` + +#### MiniMax Music v2 (lyrics_prompt) + +Earlier MiniMax variants use a `lyrics_prompt` field for lyric guidance. + +```typescript +const result = await generateAudio({ + adapter: falAudio('fal-ai/minimax-music/v2'), + prompt: 'A dreamy pop ballad in the style of the 80s', + modelOptions: { + lyrics_prompt: '[instrumental]', + }, +}) +``` + +If a request doesn't return the audio you expected — a model silently truncates, a provider rejects a prompt, or the response shape looks off — pass `debug: true` to see every chunk the provider SDK emits. See [Debug Logging](../advanced/debug-logging). + +## Options + +| Option | Type | Description | +|--------|------|-------------| +| `adapter` | `AudioAdapter` | The adapter created via `falAudio()` (required) | +| `prompt` | `string` | Text description of the audio to generate (required) | +| `duration` | `number` | Desired duration in seconds (model-dependent) | +| `modelOptions` | `object` | Provider-specific options (fully typed when the model ID is passed as a string literal) | +| `debug` | `DebugOption` | Enable per-category debug logging (`true`, `false`, or a `DebugConfig` — see [Debug Logging](../advanced/debug-logging)) | + +## Result Shape + +```typescript +interface AudioGenerationResult { + id: string + model: string + audio: { + url?: string + b64Json?: string + contentType?: string + duration?: number + } + usage?: { inputTokens?: number; outputTokens?: number; totalTokens?: number } +} +``` + +Gemini returns base64-encoded bytes in `result.audio.b64Json`. The fal adapter returns a URL in `result.audio.url` — if you need raw bytes, `fetch()` the URL yourself: + +```typescript +const bytes = new Uint8Array( + await (await fetch(result.audio.url!)).arrayBuffer() +) +``` + +## Client Hook (`useGenerateAudio`) + +For client-side usage, framework integrations expose a `useGenerateAudio` +hook (or `createGenerateAudio` in Svelte) that wraps the same generation +flow. It mirrors the API of `useGenerateSpeech`, `useGenerateImage`, and +other media hooks — see [Generation Hooks](./generation-hooks) for the full +shape. + +### Server (streaming SSE route) + +```typescript +// routes/api/generate/audio.ts +import { generateAudio, toServerSentEventsResponse } from '@tanstack/ai' +import { falAudio } from '@tanstack/ai-fal' + +export async function POST(req: Request) { + const { prompt, duration } = await req.json() + + return toServerSentEventsResponse( + generateAudio({ + adapter: falAudio('fal-ai/diffrhythm'), + prompt, + duration, + stream: true, + }), + ) +} +``` + +### Client (React) + +```tsx +import { useGenerateAudio } from '@tanstack/ai-react' +import { fetchServerSentEvents } from '@tanstack/ai-client' + +function AudioGenerator() { + const { generate, result, isLoading, error, reset } = useGenerateAudio({ + connection: fetchServerSentEvents('/api/generate/audio'), + }) + + return ( +
+ + {error &&

Error: {error.message}

} + {result?.audio.url &&
+ ) +} +``` + +Use the `fetcher` option instead of `connection` when calling a TanStack +Start server function directly. + +## Differences vs Text-to-Speech + +| | `generateAudio()` | `generateSpeech()` | +|---|---|---| +| Purpose | Music, soundscapes, SFX | Spoken-word TTS | +| Result | `result.audio.url` or `result.audio.b64Json` | Base64 in `result.audio` | +| Primary input | `prompt` | `text` | +| Voice/speed controls | No | Yes (`voice`, `speed`) | + +Use `generateSpeech()` when you want a spoken voice, and `generateAudio()` when you want non-speech audio. + +## Environment Variables + +Each provider reads its own API key from the environment by default: + +```bash +GOOGLE_API_KEY=your-google-api-key +FAL_KEY=your-fal-api-key +``` + +Or pass it explicitly to the adapter: + +```typescript +geminiAudio('lyria-3-pro-preview', { apiKey: 'your-key' }) +falAudio('fal-ai/diffrhythm', { apiKey: 'your-key' }) +``` diff --git a/docs/media/generation-hooks.md b/docs/media/generation-hooks.md index e4252a6765..d9adadc6af 100644 --- a/docs/media/generation-hooks.md +++ b/docs/media/generation-hooks.md @@ -2,11 +2,22 @@ title: Generation Hooks id: generation-hooks order: 7 +description: "Framework hooks for every TanStack AI media generation type — useGenerateImage, useGenerateAudio, useGenerateSpeech, useTranscription, useSummarize, useGenerateVideo." +keywords: + - tanstack ai + - generation hooks + - useGenerateImage + - useGenerateAudio + - useGenerateSpeech + - useTranscription + - useSummarize + - useGenerateVideo + - react hooks --- # Generation Hooks -TanStack AI provides framework hooks for every generation type: image, speech, transcription, summarization, and video. Each hook connects to a server endpoint and manages loading, error, and result state for you. +TanStack AI provides framework hooks for every generation type: image, audio, speech, transcription, summarization, and video. Each hook connects to a server endpoint and manages loading, error, and result state for you. ## Overview @@ -15,6 +26,7 @@ Generation hooks share a consistent API across all media types: | Hook | Input | Result Type | |------|-------|-------------| | `useGenerateImage` | `ImageGenerateInput` | `ImageGenerationResult` | +| `useGenerateAudio` | `AudioGenerateInput` | `AudioGenerationResult` | | `useGenerateSpeech` | `SpeechGenerateInput` | `TTSResult` | | `useTranscription` | `TranscriptionGenerateInput` | `TranscriptionResult` | | `useSummarize` | `SummarizeGenerateInput` | `SummarizationResult` | diff --git a/docs/media/generations.md b/docs/media/generations.md index ffeebe6acb..cc94a28db3 100644 --- a/docs/media/generations.md +++ b/docs/media/generations.md @@ -2,6 +2,16 @@ title: Generations id: generations order: 1 +description: "The unified pattern for non-chat activities in TanStack AI — image generation, text-to-speech, transcription, summarization, and video." +keywords: + - tanstack ai + - generations + - media generation + - image generation + - transcription + - tts + - summarization + - video generation --- # Generations diff --git a/docs/media/image-generation.md b/docs/media/image-generation.md index 00b99cefa4..6c3c6e1155 100644 --- a/docs/media/image-generation.md +++ b/docs/media/image-generation.md @@ -2,6 +2,16 @@ title: Image Generation id: image-generation order: 5 +description: "Generate images with OpenAI DALL-E, Gemini NanoBanana and Imagen, and fal.ai models via TanStack AI's unified generateImage() API." +keywords: + - tanstack ai + - image generation + - generateImage + - dall-e + - imagen + - nano banana + - flux + - fal.ai --- # Image Generation diff --git a/docs/media/realtime-chat.md b/docs/media/realtime-chat.md index 51039c66f3..d67eee05e5 100644 --- a/docs/media/realtime-chat.md +++ b/docs/media/realtime-chat.md @@ -2,6 +2,17 @@ title: Realtime Voice Chat id: realtime-chat order: 2 +description: "Build realtime voice-to-voice AI chat with TanStack AI — WebRTC and WebSocket, voice activity detection, interruptions, and multimodal input." +keywords: + - tanstack ai + - realtime voice + - voice chat + - webrtc + - websocket + - vad + - voice ai + - multimodal + - useRealtimeChat --- TanStack AI provides a complete realtime voice chat system for building voice-to-voice AI interactions. The realtime API supports multiple providers (OpenAI, ElevenLabs), automatic tool execution, audio visualization, and multimodal input including images. diff --git a/docs/media/text-to-speech.md b/docs/media/text-to-speech.md index c902654446..e281ff69b3 100644 --- a/docs/media/text-to-speech.md +++ b/docs/media/text-to-speech.md @@ -2,6 +2,15 @@ title: Text-to-Speech id: text-to-speech order: 3 +description: "Convert text to spoken audio with OpenAI TTS and Gemini voice models via TanStack AI's generateSpeech() API." +keywords: + - tanstack ai + - text-to-speech + - tts + - generateSpeech + - openai tts + - voice synthesis + - speech generation --- # Text-to-Speech (TTS) @@ -14,6 +23,7 @@ Text-to-speech (TTS) is handled by TTS adapters that follow the same tree-shakea - **OpenAI**: TTS-1, TTS-1-HD, and audio-capable GPT-4o models - **Gemini**: Gemini 2.5 Flash TTS (experimental) +- **fal.ai**: Kokoro, ElevenLabs, MiniMax, Chatterbox, Dia, Orpheus, F5-TTS, VibeVoice, and more ## Basic Usage @@ -56,6 +66,47 @@ const result = await generateSpeech({ console.log(result.audio) // Base64 encoded audio ``` +### fal.ai Text-to-Speech + +fal.ai offers a broad selection of TTS models — Google's brand-new `gemini-3.1-flash-tts`, ElevenLabs v3, MiniMax 2.6 HD, Kokoro's multilingual voices, and more. Pass the model ID as a string literal for fully typed `modelOptions`. + +```typescript +import { generateSpeech } from '@tanstack/ai' +import { falSpeech } from '@tanstack/ai-fal' + +// Google Gemini 3.1 Flash TTS — 80+ languages, expressive audio tags +const result = await generateSpeech({ + adapter: falSpeech('fal-ai/gemini-3.1-flash-tts'), + text: '[warm, enthusiastic] Welcome to TanStack AI!', + voice: 'Kore', +}) +``` + +```typescript +// Kokoro multilingual +const result = await generateSpeech({ + adapter: falSpeech('fal-ai/kokoro/american-english'), + text: 'Hello from fal!', + voice: 'af_heart', + speed: 1.0, +}) + +console.log(result.audio) // Base64 encoded audio +console.log(result.format) // e.g. "wav" +``` + +```typescript +// ElevenLabs v3 with model-specific options +const result = await generateSpeech({ + adapter: falSpeech('fal-ai/elevenlabs/tts/eleven-v3'), + text: 'Welcome to TanStack AI.', + modelOptions: { + voice: 'Rachel', + stability: 0.5, + }, +}) +``` + ## Options ### Common Options @@ -435,6 +486,8 @@ try { > **Tip:** To trigger speech generation from your frontend with loading states, see [Generation Hooks](./generation-hooks). +> **Debugging:** When a TTS request fails or produces unexpected output, pass `debug: true` on `generateSpeech({...})` to log the outgoing request, every raw provider chunk, and any caught error. See [Debug Logging](../advanced/debug-logging). + ## Environment Variables The TTS adapters use the same environment variables as other adapters: diff --git a/docs/media/transcription.md b/docs/media/transcription.md index a4cf0ad7ec..eaf64dfad1 100644 --- a/docs/media/transcription.md +++ b/docs/media/transcription.md @@ -2,6 +2,15 @@ title: Transcription id: transcription order: 4 +description: "Transcribe audio to text with OpenAI Whisper and GPT-4o-transcribe via TanStack AI's generateTranscription() API." +keywords: + - tanstack ai + - transcription + - speech-to-text + - asr + - whisper + - generateTranscription + - openai --- # Audio Transcription @@ -14,6 +23,7 @@ Audio transcription is handled by transcription adapters that follow the same tr Currently supported: - **OpenAI**: Whisper-1, GPT-4o-transcribe, GPT-4o-mini-transcribe +- **fal.ai**: Whisper, Wizper, speech-to-text turbo, ElevenLabs speech-to-text ## Basic Usage @@ -66,6 +76,29 @@ const result = await generateTranscription({ }) ``` +### fal.ai Transcription + +fal.ai offers Whisper, Wizper, and other STT models. The `audio` input accepts a URL, `File`, `Blob`, or `ArrayBuffer` (auto-wrapped in a `Blob`). + +```typescript +import { generateTranscription } from '@tanstack/ai' +import { falTranscription } from '@tanstack/ai-fal' + +const result = await generateTranscription({ + adapter: falTranscription('fal-ai/whisper'), + audio: 'https://example.com/recording.mp3', + language: 'en', +}) + +console.log(result.text) +console.log(result.language) + +// Models that return word/chunk timestamps populate result.segments +for (const segment of result.segments ?? []) { + console.log(`[${segment.start}s → ${segment.end}s] ${segment.text}`) +} +``` + ## Options ### Common Options @@ -479,6 +512,8 @@ try { } ``` +> **Debugging:** When a transcription returns garbage, empty segments, or the provider rejects your audio format, pass `debug: true` on `generateTranscription({...})` to log the outgoing request and every raw provider chunk. See [Debug Logging](../advanced/debug-logging). + ## Environment Variables The transcription adapter uses: diff --git a/docs/media/video-generation.md b/docs/media/video-generation.md index 4088121a6c..b42e88b6be 100644 --- a/docs/media/video-generation.md +++ b/docs/media/video-generation.md @@ -2,6 +2,15 @@ title: Video Generation id: video-generation order: 6 +description: "Generate video from text prompts with OpenAI Sora using TanStack AI's experimental generateVideo() jobs/polling API." +keywords: + - tanstack ai + - video generation + - sora + - generateVideo + - jobs api + - experimental + - text-to-video --- # Video Generation (Experimental) diff --git a/docs/migration/migration-from-vercel-ai.md b/docs/migration/migration-from-vercel-ai.md new file mode 100644 index 0000000000..25e045e424 --- /dev/null +++ b/docs/migration/migration-from-vercel-ai.md @@ -0,0 +1,1464 @@ +--- +title: Migration from Vercel AI SDK +id: migration-from-vercel-ai +order: 2 +description: "Port an app from the Vercel AI SDK (ai / @ai-sdk/*) to TanStack AI — option-by-option mapping of streamText, generateText, generateObject, useChat, tools, middleware, structured output, and the agent loop." +keywords: + - tanstack ai + - vercel ai sdk + - migration + - streamText + - generateText + - generateObject + - useChat + - ai sdk v5 + - ai sdk v6 + - middleware + - agent loop +--- + +# Migration from Vercel AI SDK + +This guide helps you migrate from the Vercel AI SDK (`ai` + `@ai-sdk/*`) to TanStack AI. Both libraries cover the same problem space — LLM calls, streaming, tool use, structured output, framework hooks — but TanStack AI uses a different architecture with enhanced type safety, tree-shakeable adapters, an isomorphic tool system, and a first-class middleware pipeline. + +The "Before" examples target **AI SDK v5 and v6**. Older v4 naming is called out inline where it differs. + +## Why Migrate? + +TanStack AI provides several advantages: + +- **Tree-shakeable adapters** - Import only what you need, reducing bundle size +- **Isomorphic tools** - Define tools once, implement for server and client separately +- **Per-model type safety** - TypeScript knows exact options available for each model +- **Framework agnostic** - Works with React, Vue, Solid, Svelte, and vanilla JS +- **Full streaming type safety** - Typed stream chunks and message parts + +## Quick Reference + +| Vercel AI SDK | TanStack AI | +|--------------|-------------| +| `ai` | `@tanstack/ai` | +| `@ai-sdk/openai` | `@tanstack/ai-openai` | +| `@ai-sdk/anthropic` | `@tanstack/ai-anthropic` | +| `@ai-sdk/google` | `@tanstack/ai-gemini` | +| `@ai-sdk/react` | `@tanstack/ai-react` | +| `@ai-sdk/vue` | `@tanstack/ai-vue` | +| `@ai-sdk/solid` | `@tanstack/ai-solid` | +| `@ai-sdk/svelte` | `@tanstack/ai-svelte` | + +> **Note:** Since AI SDK v5, framework hooks moved from `ai/react` (v4) to dedicated packages like `@ai-sdk/react`. If you are on v4, swap the old subpaths for their v5 equivalents. + +## Installation + +### Before (Vercel AI SDK) + +```bash +# v5+ (framework hook lives in @ai-sdk/react) +npm install ai @ai-sdk/react @ai-sdk/openai @ai-sdk/anthropic +``` + +### After (TanStack AI) + +```bash +npm install @tanstack/ai @tanstack/ai-react @tanstack/ai-openai @tanstack/ai-anthropic +``` + +## Server-Side Migration + +### Basic Text Generation + +#### Before (Vercel AI SDK) + +```typescript +import { streamText, convertToModelMessages } from 'ai' +import { openai } from '@ai-sdk/openai' + +export async function POST(request: Request) { + const { messages } = await request.json() + + const result = streamText({ + model: openai('gpt-4o'), + messages: convertToModelMessages(messages), + }) + + return result.toUIMessageStreamResponse() + // (v4: result.toDataStreamResponse()) +} +``` + +#### After (TanStack AI) + +```typescript +import { chat, toServerSentEventsResponse } from '@tanstack/ai' +import { openaiText } from '@tanstack/ai-openai' + +export async function POST(request: Request) { + const { messages } = await request.json() + + const stream = chat({ + adapter: openaiText('gpt-4o'), + messages, + }) + + return toServerSentEventsResponse(stream) +} +``` + +### Key Differences + +| Vercel AI SDK | TanStack AI | Notes | +|--------------|-------------|-------| +| `streamText()` | `chat()` | Main text generation function | +| `generateText()` | `chat({ stream: false })` | Returns `Promise` | +| `generateObject()` / `streamObject()` / `Output.object()` | `chat({ outputSchema })` | Returns `Promise` — see [Structured Output](#structured-output) | +| `openai('gpt-4o')` | `openaiText('gpt-4o')` | Activity-specific adapters | +| `result.toUIMessageStreamResponse()` / `.toTextStreamResponse()` | `toServerSentEventsResponse(stream)` / `toHttpResponse(stream)` | Separate utility functions | +| `model` parameter | `adapter` parameter | Model baked into adapter | + +### Full `streamText` → `chat()` Option Mapping + +Options accepted by `streamText` as of AI SDK v6, and where each lives in TanStack AI's `chat()`. Options that exist on both sides keep the same semantics unless noted. + +| `streamText` option | `chat()` equivalent | Notes | +|--------------------|--------------------|-------| +| `model: openai('gpt-4o')` | `adapter: openaiText('gpt-4o')` | Activity-specific adapters | +| `prompt: 'Hello'` | `messages: [{ role: 'user', content: 'Hello' }]` | TanStack is messages-only | +| `messages` | `messages` | Same concept; content parts differ (see [Multimodal](#multimodal-content)) | +| `system: 'You are…'` | `systemPrompts: ['You are…']` | Root-level `string[]` | +| `tools: { name: tool({…}) }` | `tools: [toolInstance, …]` | Array of tool instances instead of a keyed object | +| `toolChoice: 'auto' \| 'required' \| 'none' \| { type, toolName }` | `modelOptions.toolChoice` (provider-specific) | Not a top-level option — set on the adapter's `modelOptions` | +| `activeTools: string[]` | Filter `tools` yourself, or use `prepareStep` equivalent via middleware | No dedicated option — see [Middleware](#middleware) for dynamic tool filtering | +| `maxOutputTokens` | `maxTokens` | Renamed to match the original OpenAI naming | +| `temperature` | `temperature` | Same | +| `topP` | `topP` | Same | +| `topK` | `modelOptions.topK` (where the provider supports it) | Lives under typed `modelOptions` | +| `presencePenalty` | `modelOptions.presencePenalty` | Lives under typed `modelOptions` | +| `frequencyPenalty` | `modelOptions.frequencyPenalty` | Lives under typed `modelOptions` | +| `seed` | `modelOptions.seed` | Lives under typed `modelOptions` | +| `stopSequences` | `modelOptions.stop` (provider-specific) | Lives under typed `modelOptions` | +| `maxRetries` | Wrap your fetch/adapter, or add a retry `middleware` | Not built into `chat()` | +| `timeout` | Combine `abortController` + `AbortSignal.timeout(ms)` | Not built into `chat()` | +| `abortSignal: controller.signal` | `abortController: controller` | Pass the controller itself, not just the signal | +| `headers` | Configure on the adapter (e.g., `openaiText({ headers })`) | Not a per-call option | +| `providerOptions: { openai: { … } }` | `modelOptions: { … }` | Flat; the adapter already knows which provider it is. Typed per model | +| `stopWhen: stepCountIs(5)` | `agentLoopStrategy: maxIterations(5)` | See [Agent Loop Control](#agent-loop-control) | +| `stopWhen: hasToolCall('x')` | Custom `AgentLoopStrategy` that inspects `messages` | No built-in "stop on specific tool" preset yet — one-liner custom strategy; see [Agent Loop Control](#agent-loop-control) | +| `stopWhen: [a, b]` | `agentLoopStrategy: combineStrategies([a, b])` | Multiple conditions, AND semantics | +| `prepareStep` | `middleware` with `onConfig`/`onIteration` | See [Middleware](#middleware) | +| `experimental_transform` | `middleware.onChunk` (transform / drop / expand chunks) | See [Middleware](#middleware) | +| `experimental_context` | `context` (root-level) | Passed through to every middleware hook | +| `experimental_telemetry` | `middleware` + your tracer of choice | See [Observability](#observability-logging-metrics-tracing) | +| `experimental_repairToolCall` | `middleware.onBeforeToolCall` | Return transformed args or a decision | +| `experimental_download` | Preprocess your `messages` before calling `chat()` | No built-in hook | +| `onChunk` (streamText) | `middleware.onChunk` | Also reachable by consuming the returned iterable | +| `onError` | `middleware.onError` | Terminal hook | +| `onStepFinish` | `middleware.onIteration` / `onToolPhaseComplete` / `onUsage` | Split into finer-grained hooks | +| `onFinish` | `middleware.onFinish` | Terminal hook | +| `onAbort` | `middleware.onAbort` | Terminal hook | +| `output: Output.object({ schema })` | `outputSchema` | See [Structured Output](#structured-output) | +| — | `conversationId` / `threadId` / `runId` | TanStack-only, for correlating requests across your system and AG-UI | + +### `streamText` result → TanStack AI equivalents + +`streamText` returns an object with accessor promises; TanStack AI returns the stream directly. Everything you can pull off that object is available via stream consumption, middleware, or response helpers. + +| `streamText` result member | TanStack AI equivalent | +|---------------------------|------------------------| +| `result.textStream` | Filter the async iterable: `for await (const c of stream) if (c.type === 'text-delta') …` | +| `result.fullStream` | The `stream` returned by `chat()` **is** the full stream (`AsyncIterable`) | +| `result.text` | `await streamToText(stream)` or `chat({ …, stream: false })` | +| `result.content` | Accumulate parts in `middleware.onChunk`, or read the final `UIMessage` in `onFinish` | +| `result.toolCalls` / `result.toolResults` | Read from chunks in `middleware.onChunk` / `onAfterToolCall` | +| `result.usage` / `result.totalUsage` | `middleware.onUsage(ctx, usage)` | +| `result.finishReason` | `middleware.onFinish(ctx, info)` | +| `result.steps` | Accumulate via `middleware.onIteration` / `onToolPhaseComplete` | +| `result.toUIMessageStreamResponse()` | `toServerSentEventsResponse(stream)` | +| `result.toTextStreamResponse()` | Collect with `streamToText(stream)` and return a plain `Response`, **or** pair with the client's `fetchHttpStream` via `toHttpResponse(stream)` | +| `result.pipeUIMessageStreamToResponse(res)` | `toServerSentEventsStream(stream).pipeTo(…)` | +| `result.consumeStream()` | `for await (const _ of stream) {}` | + +### Generation Options + +TanStack AI promotes a small, cross-provider set of options to the top level (`temperature`, `topP`, `maxTokens`) and pushes everything provider-specific into a single typed `modelOptions` bag. There's no `providerOptions: { openai: {…} }` nesting — the adapter already knows which provider it is, so `modelOptions` is flat and typed against the selected model. + +#### Before (Vercel AI SDK v5+) + +```typescript +const result = streamText({ + model: openai('gpt-4o'), + messages, + temperature: 0.7, + maxOutputTokens: 1000, // (v5+); `maxTokens` on v4 + topP: 0.9, + topK: 40, + presencePenalty: 0.1, + frequencyPenalty: 0.1, + seed: 42, + stopSequences: ['\n\nUser:'], + // Provider-specific options (v5+) + providerOptions: { + openai: { + responseFormat: { type: 'json_object' }, + }, + }, +}) +``` + +#### After (TanStack AI) + +```typescript +const stream = chat({ + adapter: openaiText('gpt-4o'), + messages, + temperature: 0.7, + maxTokens: 1000, + topP: 0.9, + // Everything else lives under modelOptions — typed for gpt-4o specifically + modelOptions: { + topK: 40, + presencePenalty: 0.1, + frequencyPenalty: 0.1, + seed: 42, + stop: ['\n\nUser:'], + responseFormat: { type: 'json_object' }, + }, +}) +``` + +> Autocomplete in `modelOptions` reflects the **exact** adapter and model you passed. Swap `openaiText('gpt-4o')` for `anthropicText('claude-sonnet-4-5')` and the shape changes to match Anthropic's options. + +### System Messages + +TanStack AI accepts system prompts at the **root level** via the `systemPrompts` option. You pass an array of strings, and each adapter merges them into whatever format the provider expects. You don't manually prepend a `system` message to the `messages` array. + +#### Before (Vercel AI SDK) + +```typescript +const result = streamText({ + model: openai('gpt-4o'), + system: 'You are a helpful assistant.', + messages, +}) +``` + +#### After (TanStack AI) + +```typescript +const stream = chat({ + adapter: openaiText('gpt-4o'), + systemPrompts: ['You are a helpful assistant.'], + messages, +}) +``` + +Multiple system prompts are supported — useful for composing persona, policies, and tool-usage guidance without string concatenation: + +```typescript +const stream = chat({ + adapter: openaiText('gpt-4o'), + systemPrompts: [ + 'You are a helpful assistant.', + 'Respond in concise, plain English.', + 'Never fabricate citations.', + ], + messages, +}) +``` + +## Client-Side Migration + +### Basic useChat Hook + +#### Before (Vercel AI SDK v5+) + +```typescript +import { useChat } from '@ai-sdk/react' +import { DefaultChatTransport } from 'ai' +import { useState } from 'react' + +export function Chat() { + const [input, setInput] = useState('') + const { messages, sendMessage, status } = useChat({ + transport: new DefaultChatTransport({ api: '/api/chat' }), + }) + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + if (input.trim() && status !== 'streaming') { + sendMessage({ text: input }) + setInput('') + } + } + + return ( +
+ {messages.map((m) => ( +
+ {m.role}:{' '} + {m.parts.map((p, i) => (p.type === 'text' ? {p.text} : null))} +
+ ))} +
+ setInput(e.target.value)} /> + +
+
+ ) +} +``` + +#### After (TanStack AI) + +```typescript +import { useState } from 'react' +import { useChat, fetchServerSentEvents } from '@tanstack/ai-react' + +export function Chat() { + const [input, setInput] = useState('') + const { messages, sendMessage, isLoading } = useChat({ + connection: fetchServerSentEvents('/api/chat'), + }) + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + if (input.trim() && !isLoading) { + sendMessage(input) + setInput('') + } + } + + return ( +
+ {messages.map((message) => ( +
+ {message.role}:{' '} + {message.parts.map((part, idx) => + part.type === 'text' ? {part.content} : null + )} +
+ ))} +
+ setInput(e.target.value)} /> + +
+
+ ) +} +``` + +### useChat API Differences + +Vercel AI SDK v5+ already moved away from the magic `input`/`handleInputChange`/`handleSubmit` of v4 and now expects you to manage your own input state. TanStack AI follows that same philosophy — the hook is headless and gives you building blocks instead of form glue. + +| Vercel AI SDK (v5+) | TanStack AI | Notes | +|--------------------|-------------|-------| +| `transport: new DefaultChatTransport({ api: '/api/chat' })` | `connection: fetchServerSentEvents('/api/chat')` | Pluggable connection adapter | +| `sendMessage({ text })` | `sendMessage(text)` | Accepts plain string; pass `UIMessage` objects via `append()` | +| `status` (`'submitted' \| 'streaming' \| 'ready' \| 'error'`) | `isLoading` (boolean) | Coarser in TanStack; full stream state available via events | +| `regenerate()` | `reload()` | Re-runs the last assistant turn | +| `stop()` | `stop()` | Cancel the in-flight stream | +| `setMessages(messages)` | `setMessages(messages)` | Direct message replacement | +| `addToolOutput({ tool, toolCallId, output })` (v6; was `addToolResult` in v5) | `addToolResult({ tool, toolCallId, output })` | Resolve a client-side tool call | +| `addToolApprovalResponse({ id, approved })` (v6) | `addToolApprovalResponse({ id, approved })` | First-class user-approval flow for tools | +| `m.parts` (typed union) | `message.parts` (typed union) | Both render via structured parts | + +### Message Structure + +#### Before (Vercel AI SDK) + +```typescript +interface Message { + id: string + role: 'user' | 'assistant' | 'system' + content: string + toolInvocations?: ToolInvocation[] +} +``` + +#### After (TanStack AI) + +These are the `@tanstack/ai-client` shapes (what `useChat` gives you). The core `@tanstack/ai` message types are similar, but `input` (parsed tool input) is a client-layer projection — server-side code reads the raw JSON from `arguments` directly. + +```typescript +interface UIMessage = any> { + id: string + role: 'system' | 'user' | 'assistant' + parts: Array> + createdAt?: Date +} + +type MessagePart = + | TextPart + | ToolCallPart + | ToolResultPart + | ThinkingPart + +interface TextPart { + type: 'text' + content: string +} + +interface ThinkingPart { + type: 'thinking' + content: string +} + +interface ToolCallPart { + type: 'tool-call' + id: string + name: string + arguments: string // Raw JSON string (may be partial while streaming) + input?: unknown // Parsed input (typed when tools are typed) + output?: unknown // Execution output once available + state: ToolCallState + approval?: { + id: string // Approval request ID + needsApproval: boolean + approved?: boolean // undefined until the user responds + } +} + +interface ToolResultPart { + type: 'tool-result' + toolCallId: string + content: string + state: ToolResultState + error?: string // Present when state is 'error' +} + +type ToolCallState = + | 'awaiting-input' + | 'input-streaming' + | 'input-complete' + | 'approval-requested' + | 'approval-responded' + +type ToolResultState = 'streaming' | 'complete' | 'error' +``` + +> TanStack AI does not have separate `reasoning`, `source-url`, `source-document`, or `file` part types that you may have seen in other SDKs. Provider-specific reasoning traces arrive as `thinking` parts; citations and inline files are surfaced through `metadata` on text parts or through your tool outputs. + +### Rendering Messages + +#### Before (Vercel AI SDK) + +```typescript +{messages.map((m) => ( +
+ {m.role}: {m.content} + {m.toolInvocations?.map((tool) => ( +
+ Tool: {tool.toolName} - {JSON.stringify(tool.result)} +
+ ))} +
+))} +``` + +#### After (TanStack AI) + +```typescript +{messages.map((message) => ( +
+ {message.role}:{' '} + {message.parts.map((part, idx) => { + if (part.type === 'text') { + return {part.content} + } + if (part.type === 'thinking') { + return Thinking: {part.content} + } + if (part.type === 'tool-call') { + return ( +
+ Tool: {part.name} - {JSON.stringify(part.output)} +
+ ) + } + return null + })} +
+))} +``` + +## Tools / Function Calling + +TanStack AI uses an isomorphic tool system where you define the schema once and implement it separately for server and client. + +### Basic Tool Definition + +#### Before (Vercel AI SDK v5+) + +```typescript +import { streamText, tool } from 'ai' +import { openai } from '@ai-sdk/openai' +import { z } from 'zod' + +const result = streamText({ + model: openai('gpt-4o'), + messages, + tools: { + getWeather: tool({ + description: 'Get weather for a location', + inputSchema: z.object({ // renamed from `parameters` in v5 + location: z.string(), + }), + execute: async ({ location }) => { + const weather = await fetchWeather(location) + return weather + }, + }), + }, +}) +``` + +#### After (TanStack AI) + +```typescript +import { chat, toolDefinition } from '@tanstack/ai' +import { openaiText } from '@tanstack/ai-openai' +import { z } from 'zod' + +// Step 1: Define the tool schema +const getWeatherDef = toolDefinition({ + name: 'getWeather', + description: 'Get weather for a location', + inputSchema: z.object({ + location: z.string(), + }), + outputSchema: z.object({ + temperature: z.number(), + conditions: z.string(), + }), +}) + +// Step 2: Create server implementation +const getWeather = getWeatherDef.server(async ({ location }) => { + const weather = await fetchWeather(location) + return weather +}) + +// Step 3: Use in chat +const stream = chat({ + adapter: openaiText('gpt-4o'), + messages, + tools: [getWeather], +}) +``` + +### Tool Schema Differences + +| Vercel AI SDK | TanStack AI | +|--------------|-------------| +| `parameters` (v4) / `inputSchema` (v5+) | `inputSchema` | +| N/A | `outputSchema` (optional — enables end-to-end type safety) | +| `execute` inline on the server | `.server()` or `.client()` methods (isomorphic definition) | +| Object with tool names as keys | Array of tool instances | + +### Client-Side Tools + +#### Before (Vercel AI SDK v5+) + +```typescript +import { tool } from 'ai' +import { z } from 'zod' +import { useChat } from '@ai-sdk/react' + +const { messages, addToolOutput } = useChat({ + transport: new DefaultChatTransport({ api: '/api/chat' }), + onToolCall: async ({ toolCall }) => { + if (toolCall.toolName === 'showNotification') { + showNotification(toolCall.input.message) + // v6: addToolOutput (was addToolResult in v5) + addToolOutput({ + tool: 'showNotification', + toolCallId: toolCall.toolCallId, + output: { success: true }, + }) + } + }, +}) +``` + +#### After (TanStack AI) + +```typescript +import { useChat, fetchServerSentEvents } from '@tanstack/ai-react' +import { clientTools } from '@tanstack/ai-client' + +// Define once (can be shared with server) +const showNotificationDef = toolDefinition({ + name: 'showNotification', + description: 'Show a toast notification in the browser', + inputSchema: z.object({ message: z.string() }), + outputSchema: z.object({ success: z.boolean() }), +}) + +// Client implementation +const showNotification = showNotificationDef.client(({ message }) => { + toast(message) + return { success: true } +}) + +// Use in component — `clientTools()` wires each client tool's `.client(...)` +// handler to run automatically when the server-side agent calls it; you don't +// need an onToolCall handler or an addToolOutput/addToolResult call. +const { messages } = useChat({ + connection: fetchServerSentEvents('/api/chat'), + tools: clientTools(showNotification), +}) +``` + +### Tool Approval Flow + +Both libraries expose first-class human-in-the-loop approval. The shapes are similar — a tool opts in with `needsApproval: true`, the client renders UI on an `approval-requested` state, and you call `addToolApprovalResponse` with the approval ID. + +#### Before (Vercel AI SDK v6) + +```typescript +// Tool definition (server) +import { tool } from 'ai' +const bookFlight = tool({ + description: 'Book a flight', + inputSchema: z.object({ flightId: z.string() }), + needsApproval: true, // v6: first-class approval + execute: async ({ flightId }) => bookingService.book(flightId), +}) + +// Client +const { messages, addToolApprovalResponse } = useChat({ + transport: new DefaultChatTransport({ api: '/api/chat' }), + sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses, +}) +``` + +#### After (TanStack AI) + +```typescript +// Built-in approval support +const bookFlightDef = toolDefinition({ + name: 'bookFlight', + description: 'Book a flight on behalf of the user', + inputSchema: z.object({ flightId: z.string() }), + needsApproval: true, // Request user approval +}) + +// In component +const { messages, addToolApprovalResponse } = useChat({ + connection: fetchServerSentEvents('/api/chat'), +}) + +// Render approval UI +{message.parts.map((part, idx) => { + if ( + part.type === 'tool-call' && + part.state === 'approval-requested' && + part.approval + ) { + return ( +
+

Approve booking flight {part.input?.flightId}?

+ + +
+ ) + } + return null +})} +``` + +> `part.input` is the **parsed** tool input (typed when your tools are typed via `clientTools()` + `InferChatMessages`). The raw streaming JSON is available as `part.arguments` if you need to show progress before input parsing completes. + +## Structured Output + +This section covers the `generateObject` / `streamObject` / `Output.object(...)` migration path. In AI SDK v6, structured generation lives on `generateText` / `streamText` via the `output:` parameter (e.g. `Output.object({ schema })`). The dedicated `generateObject` / `streamObject` functions are deprecated but still present. TanStack AI follows the same "one function" philosophy — pass `outputSchema` to `chat()` and it runs the full agentic loop (tools, retries, loop strategy) and returns a typed, validated value. + +### Before (Vercel AI SDK v6) + +```typescript +import { generateText, Output } from 'ai' +import { openai } from '@ai-sdk/openai' +import { z } from 'zod' + +const { output } = await generateText({ + model: openai('gpt-4o'), + prompt: 'Extract the user profile from this bio…', + output: Output.object({ + schema: z.object({ + name: z.string(), + age: z.number(), + interests: z.array(z.string()), + }), + }), +}) +// output is typed as { name: string; age: number; interests: string[] } +``` + +### After (TanStack AI) + +```typescript +import { chat } from '@tanstack/ai' +import { openaiText } from '@tanstack/ai-openai' +import { z } from 'zod' + +const profile = await chat({ + adapter: openaiText('gpt-4o'), + messages: [{ role: 'user', content: 'Extract the user profile from this bio…' }], + outputSchema: z.object({ + name: z.string(), + age: z.number(), + interests: z.array(z.string()), + }), +}) +// profile: { name: string; age: number; interests: string[] } +``` + +### Notes + +- `outputSchema` accepts any **Standard Schema**-compatible library: **Zod v4.2+**, **ArkType v2.1.28+**, **Valibot v1.2+** (via `toStandardJsonSchema()`), or a plain JSON Schema object (which loses TS inference and falls back to `unknown`). +- When `outputSchema` is set, `chat()` always returns a `Promise` — the `stream` flag is ignored, because the value only makes sense once the schema has validated the final output. +- Adapters implement structured output the best way for their provider: OpenAI uses `response_format: json_schema`, Anthropic uses tool-based extraction, Gemini uses `responseSchema`, Ollama uses JSON mode. You don't need to pick the strategy. +- Arrays are just `z.array(z.object({ … }))`. TanStack AI does not yet stream partial objects the way `streamObject().elementStream` does on the Vercel side — if that's load-bearing, stay on `streamText` for now and migrate the object case when partial streaming lands. + +## Agent Loop Control + +Both SDKs let the model call tools in a loop. The shape of the control knob is different: + +| Vercel AI SDK v6 | TanStack AI | +|------------------|-------------| +| `stopWhen: stepCountIs(5)` | `agentLoopStrategy: maxIterations(5)` | +| `stopWhen: hasToolCall('bookFlight')` | Custom `AgentLoopStrategy` that inspects `messages` for the tool name | +| `stopWhen: untilFinishReason(['stop'])` (custom condition) | `agentLoopStrategy: untilFinishReason(['stop'])` | +| `stopWhen: [stepCountIs(20), hasToolCall('done')]` | `agentLoopStrategy: combineStrategies([maxIterations(20), /* your hasToolCall */ ])` | +| `prepareStep({ stepNumber, messages, steps, model })` | `middleware.onConfig(ctx, config)` + `middleware.onIteration(ctx, info)` | + +Default loop budget: TanStack AI defaults to `maxIterations(5)` if you don't pass a strategy. + +### Before (Vercel AI SDK v6) + +```typescript +import { streamText, stepCountIs } from 'ai' +import { openai } from '@ai-sdk/openai' + +const result = streamText({ + model: openai('gpt-4o'), + messages, + tools: { getWeather }, + stopWhen: stepCountIs(10), + prepareStep: async ({ stepNumber, messages }) => { + // log/rewrite messages between steps, filter tools, etc. + if (stepNumber > 0) return { /* partial config for this step */ } + return {} + }, +}) +``` + +### After (TanStack AI) + +```typescript +import { + chat, + combineStrategies, + maxIterations, + untilFinishReason, +} from '@tanstack/ai' +import { openaiText } from '@tanstack/ai-openai' + +const stream = chat({ + adapter: openaiText('gpt-4o'), + messages, + tools: [getWeather], + agentLoopStrategy: combineStrategies([ + maxIterations(10), + untilFinishReason(['stop']), // stop when the model says it's done + ]), + middleware: [ + { + // `prepareStep` analogue: inspect/rewrite config at the start of each iteration + onConfig: (ctx, config) => { + if (ctx.iteration > 0) { + // e.g. return a Partial to filter tools, trim + // messages, or change modelOptions for this iteration + return { /* partial overrides */ } + } + }, + }, + ], +}) +``` + +#### Mid-loop model switching + +`prepareStep` in AI SDK v6 lets you return a different `model` per step. TanStack AI doesn't support swapping the adapter inside a single `chat()` run — `modelOptions` is typed per adapter, which is what gives you compile-time model safety. The equivalent is to end the current loop (via an `agentLoopStrategy`) and start a new `chat()` with a different adapter, feeding it the in-progress messages: + +```typescript +// Stage 1: heavy model for the opening turn +const firstPass = await chat({ + adapter: openaiText('gpt-4o'), + messages, + agentLoopStrategy: maxIterations(1), + stream: false, +}) + +// Stage 2: cheaper model for the rest +const followUp = chat({ + adapter: openaiText('gpt-4o-mini'), + messages: [...messages, { role: 'assistant', content: firstPass }], + tools: [getWeather], +}) +``` + +## Middleware + +AI SDK v6 has two middleware-ish extension points: + +1. **`wrapLanguageModel({ model, middleware })`** — provider-level interception (`transformParams`, `wrapGenerate`, `wrapStream`) for logging, caching, guardrails, RAG. +2. **`experimental_transform`** on `streamText` — transforms the stream of chunks. + +TanStack AI collapses both into a single first-class `middleware: ChatMiddleware[]` option on `chat()`. It hooks into the full lifecycle, not just the model call or the chunk stream, and is the recommended place for logging, tracing, caching, redaction, and tool interception. + +### Before (Vercel AI SDK v6) + +```typescript +import { wrapLanguageModel, streamText } from 'ai' +import { openai } from '@ai-sdk/openai' + +const loggingMiddleware = { + wrapGenerate: async ({ doGenerate, params }) => { + console.log('params', params) + const result = await doGenerate() + console.log('text', result.text) + return result + }, + wrapStream: async ({ doStream, params }) => doStream(), + transformParams: async ({ params }) => params, +} + +const wrapped = wrapLanguageModel({ + model: openai('gpt-4o'), + middleware: [loggingMiddleware], +}) + +const result = streamText({ model: wrapped, messages }) +``` + +### After (TanStack AI) + +```typescript +import { chat, type ChatMiddleware } from '@tanstack/ai' +import { openaiText } from '@tanstack/ai-openai' + +const loggingMiddleware: ChatMiddleware = { + onStart: (ctx) => console.log('start', { requestId: ctx.requestId, model: ctx.model }), + onConfig: (ctx, config) => console.log('config', config), + onChunk: (ctx, chunk) => { /* observe or transform; return null to drop */ }, + onUsage: (ctx, usage) => console.log('usage', usage), + onFinish: (ctx, info) => console.log('finish', info), + onError: (ctx, err) => console.error('error', err), +} + +const stream = chat({ + adapter: openaiText('gpt-4o'), + messages, + middleware: [loggingMiddleware], + context: { userId: 'u_123' }, // passed to every hook as ctx.context +}) +``` + +### Full hook inventory + +Each middleware is a plain object. Every hook is optional, so pick what you need. + +| Hook | Called when | Can transform? | +|------|-------------|----------------| +| `onStart(ctx)` | Chat run starts | — | +| `onConfig(ctx, config)` | Init + before each model call | Return `Partial` to mutate messages, systemPrompts, tools, temperature, etc. | +| `onIteration(ctx, info)` | Start of each agent-loop iteration | — | +| `onChunk(ctx, chunk)` | Every yielded `StreamChunk` | Return a chunk / array of chunks / `null` to drop | +| `onBeforeToolCall(ctx, hookCtx)` | Before a tool executes | Return a `BeforeToolCallDecision` to rewrite args, skip, or abort | +| `onAfterToolCall(ctx, info)` | After a tool executes (success or failure) | — | +| `onToolPhaseComplete(ctx, info)` | All tools in an iteration done | — | +| `onUsage(ctx, usage)` | Provider reports token usage | — | +| `onFinish(ctx, info)` | Run finished normally (terminal) | — | +| `onAbort(ctx, info)` | Run aborted (terminal) | — | +| `onError(ctx, info)` | Unhandled error (terminal) | — | + +`ctx` carries `requestId`, `streamId`, `conversationId`, `iteration`, `model`, `provider`, `systemPrompts`, `toolNames`, `messages`, `context` (your opaque value), `abort(reason)`, `defer(promise)`, `createId(prefix)`, and more. See [the middleware guide](../advanced/middleware) for the full reference. + +### Built-in: tool-call cache + +TanStack AI ships a `toolCacheMiddleware` that memoizes tool results by `name + args`. There's no direct Vercel equivalent — on the Vercel side you'd compose it yourself in `wrapGenerate` or inside each tool's `execute`. Example: + +```typescript +import { chat } from '@tanstack/ai' +import { toolCacheMiddleware } from '@tanstack/ai/middlewares' + +const stream = chat({ + adapter: openaiText('gpt-4o'), + messages, + tools: [searchDocs, getWeather], + middleware: [ + toolCacheMiddleware({ + maxSize: 100, + ttl: 5 * 60_000, // 5 minutes + toolNames: ['searchDocs'], // only cache these + // storage: redisStorage, // plug in Redis / localStorage / custom + }), + ], +}) +``` + +### Mapping common Vercel patterns to TanStack middleware + +| Vercel pattern | TanStack middleware hook | +|----------------|--------------------------| +| `experimental_transform` (chunk transform) | `onChunk` | +| `experimental_repairToolCall` | `onBeforeToolCall` | +| `prepareStep` (dynamic model/tools/messages) | `onConfig` + `onIteration` | +| `wrapLanguageModel` logging | `onStart` + `onConfig` + `onFinish` | +| Custom caching in `wrapGenerate` | `toolCacheMiddleware` or your own `onBeforeToolCall`/`onAfterToolCall` | +| `experimental_telemetry` | Any terminal hook (`onFinish`/`onAbort`/`onError`) + your tracer | + +## Observability (logging, metrics, tracing) + +Both libraries leave the wire to your tracer of choice (OpenTelemetry, Sentry, Datadog, …). The plug point differs: + +- **Vercel AI SDK**: `experimental_telemetry` on `streamText` + the lifecycle callbacks (`onChunk`, `onStepFinish`, `onFinish`, `onError`). +- **TanStack AI**: a middleware with the hooks you need. `onStart` + `onFinish`/`onAbort`/`onError` covers request-level spans; `onChunk` + `onUsage` gives you fine-grained timing; `onBeforeToolCall`/`onAfterToolCall` for tool spans. + +Because `ctx.requestId` and `ctx.streamId` are stable across hooks, you get one trace per request without threading IDs manually. + +## Provider Adapters + +TanStack AI uses activity-specific adapters for optimal tree-shaking. + +### OpenAI + +#### Before (Vercel AI SDK) + +```typescript +import { openai } from '@ai-sdk/openai' + +// Chat +streamText({ model: openai('gpt-4o'), ... }) + +// Embeddings +embed({ model: openai.embedding('text-embedding-3-small'), ... }) + +// Image generation +generateImage({ model: openai.image('dall-e-3'), ... }) +``` + +#### After (TanStack AI) + +```typescript +import { openaiText, openaiImage, openaiSpeech } from '@tanstack/ai-openai' + +// Chat +chat({ adapter: openaiText('gpt-4o'), ... }) + +// Image generation +generateImage({ adapter: openaiImage('dall-e-3'), ... }) + +// Text to speech +generateSpeech({ adapter: openaiSpeech('tts-1'), ... }) + +// Embeddings: Use OpenAI SDK directly or your vector DB's built-in support +``` + +### Anthropic + +#### Before (Vercel AI SDK) + +```typescript +import { anthropic } from '@ai-sdk/anthropic' + +streamText({ model: anthropic('claude-sonnet-4-5-20250514'), ... }) +``` + +#### After (TanStack AI) + +```typescript +import { anthropicText } from '@tanstack/ai-anthropic' + +chat({ adapter: anthropicText('claude-sonnet-4-5-20250514'), ... }) +``` + +### Google (Gemini) + +#### Before (Vercel AI SDK) + +```typescript +import { google } from '@ai-sdk/google' + +streamText({ model: google('gemini-1.5-pro'), ... }) +``` + +#### After (TanStack AI) + +```typescript +import { geminiText } from '@tanstack/ai-gemini' + +chat({ adapter: geminiText('gemini-1.5-pro'), ... }) +``` + +## Streaming Responses + +### Server Response Formats + +#### Before (Vercel AI SDK v5+) + +```typescript +// UI message stream (default, for useChat) +return result.toUIMessageStreamResponse() + +// Plain text stream +return result.toTextStreamResponse() +``` + +#### After (TanStack AI) + +```typescript +import { + chat, + toServerSentEventsResponse, + toServerSentEventsStream, + toHttpResponse, + toHttpStream, +} from '@tanstack/ai' + +const stream = chat({ adapter: openaiText('gpt-4o'), messages }) + +// SSE response (recommended; pairs with fetchServerSentEvents on the client). +// Both response helpers accept a ResponseInit with an optional abortController +// — merge custom headers, status, or cancellation without unwrapping the helper. +return toServerSentEventsResponse(stream, { + abortController, + status: 200, + headers: { 'X-Trace-Id': traceId }, +}) + +// Newline-delimited JSON response (pairs with fetchHttpStream on the client). +return toHttpResponse(stream, { abortController }) + +// Or grab the raw ReadableStream if you need to pipe it somewhere else +// (writing to a Node ServerResponse, wrapping in a transform, etc.). +const sseStream = toServerSentEventsStream(stream, abortController) +const ndjsonStream = toHttpStream(stream, abortController) +``` + +### Client Connection Adapters + +#### Before (Vercel AI SDK v5+) + +```typescript +import { DefaultChatTransport } from 'ai' + +useChat({ + transport: new DefaultChatTransport({ api: '/api/chat' }), +}) +``` + +#### After (TanStack AI) + +```typescript +import { fetchServerSentEvents, fetchHttpStream, stream } from '@tanstack/ai-react' + +// SSE (matches toServerSentEventsResponse) +useChat({ connection: fetchServerSentEvents('/api/chat') }) + +// HTTP stream (matches toHttpResponse / toHttpStream on the server) +useChat({ connection: fetchHttpStream('/api/chat') }) + +// Custom adapter: return an AsyncIterable, e.g. from a TanStack +// Start server function or an RPC client +useChat({ + connection: stream((messages, data) => customServerFn({ messages, data })), +}) +``` + +## AbortController / Cancellation + +### Before (Vercel AI SDK) + +```typescript +const result = streamText({ + model: openai('gpt-4o'), + messages, + abortSignal: controller.signal, +}) +``` + +### After (TanStack AI) + +TanStack AI takes an `AbortController` (not a bare signal) so helpers like `toServerSentEventsStream` can wire cancellation into the response stream for you. + +```typescript +const abortController = new AbortController() + +const stream = chat({ + adapter: openaiText('gpt-4o'), + messages, + abortController, +}) + +// Cancel the stream +abortController.abort() +``` + +## Callbacks and Events + +### Stream Callbacks + +#### Before (Vercel AI SDK v5+) + +```typescript +const { messages } = useChat({ + transport: new DefaultChatTransport({ api: '/api/chat' }), + onFinish: ({ message }) => console.log('Finished:', message), + onError: (error) => console.error('Error:', error), +}) +``` + +#### After (TanStack AI) + +```typescript +const { messages } = useChat({ + connection: fetchServerSentEvents('/api/chat'), + onResponse: (response) => console.log('Response started'), + onChunk: (chunk) => console.log('Chunk received:', chunk), + onFinish: (message) => console.log('Finished:', message), + onError: (error) => console.error('Error:', error), +}) +``` + +TanStack AI also lets you hook into the **server-side** stream lifecycle by subscribing to the async iterable returned from `chat()`, which preserves the full typed `StreamChunk` union — useful for logging, analytics, or sending custom SSE events alongside the response. + +## Multimodal Content + +### Image Inputs + +#### Before (Vercel AI SDK) + +```typescript +streamText({ + model: openai('gpt-4o'), + messages: [ + { + role: 'user', + content: [ + { type: 'text', text: 'Describe this image' }, + { type: 'image', image: imageUrl }, + ], + }, + ], +}) +``` + +#### After (TanStack AI) + +```typescript +chat({ + adapter: openaiText('gpt-4o'), + messages: [ + { + role: 'user', + content: [ + { type: 'text', text: 'Describe this image' }, + { type: 'image', source: { type: 'url', value: imageUrl } }, + // Or inline base64 data + { type: 'image', source: { type: 'data', value: imageData, mimeType: 'image/png' } }, + ], + }, + ], +}) +``` + +> The source discriminant is `'url'` or `'data'`. Both carry the payload on `value` (a URL or base64 string). `mimeType` is required for `'data'` and optional for `'url'`. + +## Dynamic Provider Switching + +### Before (Vercel AI SDK) + +```typescript +const providers = { + openai: openai('gpt-4o'), + anthropic: anthropic('claude-sonnet-4-5-20250514'), +} + +streamText({ + model: providers[selectedProvider], + messages, +}) +``` + +### After (TanStack AI) + +```typescript +const adapters = { + openai: () => openaiText('gpt-4o'), + anthropic: () => anthropicText('claude-sonnet-4-5-20250514'), +} + +chat({ + adapter: adapters[selectedProvider](), + messages, +}) +``` + +## Type Safety Enhancements + +TanStack AI provides enhanced type safety that Vercel AI SDK doesn't offer: + +### Typed Message Parts + +```typescript +import { createChatClientOptions, clientTools, type InferChatMessages } from '@tanstack/ai-client' + +const tools = clientTools(updateUI, saveData) + +const chatOptions = createChatClientOptions({ + connection: fetchServerSentEvents('/api/chat'), + tools, +}) + +// Infer fully typed messages +type ChatMessages = InferChatMessages + +// Now TypeScript knows: +// - Exact tool names available +// - Input types for each tool +// - Output types for each tool +``` + +### Per-Model Type Safety + +```typescript +const adapter = openaiText('gpt-4o') + +chat({ + adapter, + messages, + modelOptions: { + // TypeScript autocompletes options specific to gpt-4o + responseFormat: { type: 'json_object' }, + logitBias: { '123': 1.0 }, + }, +}) +``` + +## Non-streaming Generation (`generateText`) + +TanStack AI doesn't ship a separate `generateText` function — the same `chat()` covers both modes. Pass `stream: false` and the return type flips from `AsyncIterable` to `Promise`: + +```typescript +import { chat } from '@tanstack/ai' +import { openaiText } from '@tanstack/ai-openai' + +const text = await chat({ + adapter: openaiText('gpt-4o'), + messages: [{ role: 'user', content: 'Summarize TanStack AI in one sentence.' }], + stream: false, +}) +// text: string +``` + +If you already have a stream for another reason, `streamToText(stream)` collects it into a string: + +```typescript +import { chat, streamToText } from '@tanstack/ai' + +const stream = chat({ adapter: openaiText('gpt-4o'), messages }) +const text = await streamToText(stream) +``` + +For structured (non-streaming) output — the `generateObject` equivalent — pass `outputSchema` instead; see [Structured Output](#structured-output). + +## Features Not Yet Covered + +A few AI SDK features don't have direct TanStack AI equivalents today: + +### Embeddings + +TanStack AI doesn't include embeddings. Use your provider's SDK directly, or the built-in embedding support most vector DBs already offer: + +```typescript +import OpenAI from 'openai' + +const openai = new OpenAI() +const result = await openai.embeddings.create({ + model: 'text-embedding-3-small', + input: 'Hello, world!', +}) +``` + +### Partial object streaming (`streamObject().elementStream` / `partialObjectStream`) + +TanStack AI's `outputSchema` always returns a `Promise` once the full response has validated. If you need to render partial JSON as it streams, stay on `streamText` + `onChunk` for that specific case (or parse from TanStack's raw stream with your own incremental JSON parser). + +### Built-in retries and timeouts + +Vercel's `maxRetries` / `timeout` options have no direct `chat()` equivalent. Use `AbortSignal.timeout(ms)` via `abortController`, and add retries in a custom middleware or in your fetch layer. + +## Complete Migration Example + +> On the Vercel side, the v5+ server handler runs incoming UI messages through `convertToModelMessages(messages)` before handing them to `streamText`. TanStack AI's `chat()` accepts the UI-message shape directly — its adapters do the conversion internally — so the equivalent line simply disappears on the After side. + +### Before (Vercel AI SDK v5+) + +```typescript +// server/api/chat.ts +import { streamText, tool, convertToModelMessages } from 'ai' +import { openai } from '@ai-sdk/openai' +import { z } from 'zod' + +export async function POST(request: Request) { + const { messages } = await request.json() + + const result = streamText({ + model: openai('gpt-4o'), + system: 'You are a helpful assistant.', + messages: convertToModelMessages(messages), + temperature: 0.7, + tools: { + getWeather: tool({ + description: 'Get weather', + inputSchema: z.object({ city: z.string() }), + execute: async ({ city }) => fetchWeather(city), + }), + }, + }) + + return result.toUIMessageStreamResponse() +} + +// components/Chat.tsx +import { useState } from 'react' +import { useChat } from '@ai-sdk/react' +import { DefaultChatTransport } from 'ai' + +export function Chat() { + const [input, setInput] = useState('') + const { messages, sendMessage, status } = useChat({ + transport: new DefaultChatTransport({ api: '/api/chat' }), + }) + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + if (input.trim() && status !== 'streaming') { + sendMessage({ text: input }) + setInput('') + } + } + + return ( +
+ {messages.map((m) => ( +
+ {m.parts.map((p, i) => (p.type === 'text' ? {p.text} : null))} +
+ ))} +
+ setInput(e.target.value)} + disabled={status === 'streaming'} + /> + +
+
+ ) +} +``` + +### After (TanStack AI) + +```typescript +// server/api/chat.ts +import { chat, toServerSentEventsResponse, toolDefinition } from '@tanstack/ai' +import { openaiText } from '@tanstack/ai-openai' +import { z } from 'zod' + +const getWeatherDef = toolDefinition({ + name: 'getWeather', + description: 'Get weather', + inputSchema: z.object({ city: z.string() }), + outputSchema: z.object({ temp: z.number(), conditions: z.string() }), +}) + +const getWeather = getWeatherDef.server(async ({ city }) => fetchWeather(city)) + +export async function POST(request: Request) { + const { messages } = await request.json() + + const stream = chat({ + adapter: openaiText('gpt-4o'), + systemPrompts: ['You are a helpful assistant.'], + messages, + temperature: 0.7, + tools: [getWeather], + }) + + return toServerSentEventsResponse(stream) +} + +// components/Chat.tsx +import { useState } from 'react' +import { useChat, fetchServerSentEvents } from '@tanstack/ai-react' + +export function Chat() { + const [input, setInput] = useState('') + const { messages, sendMessage, isLoading } = useChat({ + connection: fetchServerSentEvents('/api/chat'), + }) + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + if (input.trim() && !isLoading) { + sendMessage(input) + setInput('') + } + } + + return ( +
+ {messages.map((message) => ( +
+ {message.parts.map((part, idx) => + part.type === 'text' ? {part.content} : null + )} +
+ ))} +
+ setInput(e.target.value)} + disabled={isLoading} + /> + +
+
+ ) +} +``` + +## Need Help? + +If you hit something that isn't covered here, the deep-dive docs pick up where this guide stops: + +1. [Quick Start](../getting-started/quick-start) — minimal working setup +2. [Tools](../tools/tools), [Tool Architecture](../tools/tool-architecture), and [Tool Approval](../tools/tool-approval) — the isomorphic tool system +3. [Agentic Cycle](../chat/agentic-cycle) — agent loop internals and strategy composition +4. [Structured Outputs](../chat/structured-outputs) — `outputSchema`, provider implementations, schema libraries +5. [Middleware](../advanced/middleware) — full hook reference, context object, built-in middleware +6. [Connection Adapters](../chat/connection-adapters) — SSE, HTTP stream, custom transports +7. [Per-Model Type Safety](../advanced/per-model-type-safety) — how `modelOptions` is typed +8. [API Reference](../api/ai) — every exported symbol diff --git a/docs/migration/migration.md b/docs/migration/migration.md index 2a1093b47b..72c077fe7e 100644 --- a/docs/migration/migration.md +++ b/docs/migration/migration.md @@ -2,6 +2,15 @@ title: Migration Guide id: migration order: 1 +description: "Migrate existing TanStack AI code to the latest version — adapter function splits, flattened options, renamed modelOptions, and removed embeddings." +keywords: + - tanstack ai + - migration + - upgrade + - breaking changes + - tree-shaking + - modelOptions + - toServerSentEventsStream --- # Migration Guide @@ -355,6 +364,56 @@ const result = await openai.embeddings.create({ - **Direct provider access** - You can use the provider SDK directly for embeddings - **Focused scope** - TanStack AI focuses on chat, tools, and agentic workflows +## 6. Provider Tools Moved to `/tools` Subpath + +Provider-specific tools (web search, code execution, computer use, etc.) are now +exported from a dedicated `/tools` subpath on every adapter package. This keeps +tool imports tree-shakeable and avoids name collisions between providers. + +The only breaking change is in `@tanstack/ai-openrouter`: +`createWebSearchTool` has been removed from the package root, renamed to +`webSearchTool`, and moved to `@tanstack/ai-openrouter/tools`. Every other +provider tool (Anthropic, OpenAI, Gemini) is newly exported — no existing +import breaks. + +### Before + +```typescript +import { createWebSearchTool } from '@tanstack/ai-openrouter' + +const tools = [ + createWebSearchTool({ engine: 'native', maxResults: 5 }), +] +``` + +### After + +```typescript +import { webSearchTool } from '@tanstack/ai-openrouter/tools' + +const tools = [ + webSearchTool({ engine: 'native', maxResults: 5 }), +] +``` + +### Key Changes + +- **Import path is now `/tools`** — matches the existing `/adapters` subpath + pattern used elsewhere in each provider package. +- **Factory renamed** — `createWebSearchTool` → `webSearchTool`. The `create*` + prefix has been dropped to align with every other provider + (`webSearchTool` in `@tanstack/ai-anthropic/tools`, + `@tanstack/ai-openai/tools`, etc.). +- **Runtime behavior is unchanged** — the factory accepts the same config + object and returns a tool that works identically in `chat({ tools: [...] })`. +- **Type-level gating is new** — if you pass a provider tool to a model that + doesn't support it (per the model's `supports.tools` array), you now get a + type error on the `tools` array. User-defined `toolDefinition()` tools are + unaffected. + +For the full list of available provider tools and which models support each +one, see [Provider Tools](../tools/provider-tools.md). + ## Complete Migration Example Here's a complete example showing all the changes together: diff --git a/docs/protocol/chunk-definitions.md b/docs/protocol/chunk-definitions.md index 4c9ccdb306..3b24b92072 100644 --- a/docs/protocol/chunk-definitions.md +++ b/docs/protocol/chunk-definitions.md @@ -1,6 +1,15 @@ --- title: AG-UI Event Definitions id: chunk-definitions +description: "TanStack AI implements the AG-UI protocol — full event definitions, types, and streaming semantics for agent-to-UI communication." +keywords: + - tanstack ai + - ag-ui + - ag-ui protocol + - events + - stream chunks + - streaming protocol + - agent protocol --- TanStack AI implements the [AG-UI (Agent-User Interaction) Protocol](https://docs.ag-ui.com/introduction), an open, lightweight, event-based protocol that standardizes how AI agents connect to user-facing applications. diff --git a/docs/protocol/http-stream-protocol.md b/docs/protocol/http-stream-protocol.md index b632c503af..0318557bb3 100644 --- a/docs/protocol/http-stream-protocol.md +++ b/docs/protocol/http-stream-protocol.md @@ -1,6 +1,14 @@ --- title: HTTP Stream Protocol id: http-stream-protocol +description: "TanStack AI's HTTP streaming protocol spec using newline-delimited JSON (NDJSON) — an alternative to SSE for simpler line-based transport." +keywords: + - tanstack ai + - http stream + - ndjson + - newline-delimited json + - streaming protocol + - protocol spec --- HTTP streaming with newline-delimited JSON (NDJSON) is a simpler protocol than SSE that sends one JSON object per line. It's useful when: diff --git a/docs/protocol/sse-protocol.md b/docs/protocol/sse-protocol.md index 52b57beebf..1fec1b74a1 100644 --- a/docs/protocol/sse-protocol.md +++ b/docs/protocol/sse-protocol.md @@ -1,6 +1,14 @@ --- title: Server-Sent Events (SSE) Protocol id: sse-protocol +description: "TanStack AI's Server-Sent Events protocol spec — the recommended streaming transport for chat and media generations, with auto-reconnection." +keywords: + - tanstack ai + - sse + - server-sent events + - streaming protocol + - protocol spec + - eventsource --- Server-Sent Events (SSE) is a standard HTTP-based protocol for server-to-client streaming. It provides: diff --git a/docs/reference/classes/BatchStrategy.md b/docs/reference/classes/BatchStrategy.md index 555db34f03..3038659a8d 100644 --- a/docs/reference/classes/BatchStrategy.md +++ b/docs/reference/classes/BatchStrategy.md @@ -5,7 +5,7 @@ title: BatchStrategy # Class: BatchStrategy -Defined in: [activities/chat/stream/strategies.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L34) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L34) Batch Strategy - emit every N chunks Useful for reducing UI update frequency @@ -22,7 +22,7 @@ Useful for reducing UI update frequency new BatchStrategy(batchSize): BatchStrategy; ``` -Defined in: [activities/chat/stream/strategies.ts:37](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L37) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:37](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L37) #### Parameters @@ -42,7 +42,7 @@ Defined in: [activities/chat/stream/strategies.ts:37](https://github.com/TanStac reset(): void; ``` -Defined in: [activities/chat/stream/strategies.ts:48](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L48) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:48](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L48) Optional: Reset strategy state (called when streaming starts) @@ -62,7 +62,7 @@ Optional: Reset strategy state (called when streaming starts) shouldEmit(_chunk, _accumulated): boolean; ``` -Defined in: [activities/chat/stream/strategies.ts:39](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L39) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:39](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L39) Called for each text chunk received diff --git a/docs/reference/classes/CompositeStrategy.md b/docs/reference/classes/CompositeStrategy.md index 2b4e0347ef..584f00d57f 100644 --- a/docs/reference/classes/CompositeStrategy.md +++ b/docs/reference/classes/CompositeStrategy.md @@ -5,7 +5,7 @@ title: CompositeStrategy # Class: CompositeStrategy -Defined in: [activities/chat/stream/strategies.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L68) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L68) Composite Strategy - combine multiple strategies (OR logic) Emits if ANY strategy says to emit @@ -22,7 +22,7 @@ Emits if ANY strategy says to emit new CompositeStrategy(strategies): CompositeStrategy; ``` -Defined in: [activities/chat/stream/strategies.ts:69](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L69) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:69](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L69) #### Parameters @@ -42,7 +42,7 @@ Defined in: [activities/chat/stream/strategies.ts:69](https://github.com/TanStac reset(): void; ``` -Defined in: [activities/chat/stream/strategies.ts:75](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L75) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:75](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L75) Optional: Reset strategy state (called when streaming starts) @@ -62,7 +62,7 @@ Optional: Reset strategy state (called when streaming starts) shouldEmit(chunk, accumulated): boolean; ``` -Defined in: [activities/chat/stream/strategies.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L71) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L71) Called for each text chunk received diff --git a/docs/reference/classes/ConsoleLogger.md b/docs/reference/classes/ConsoleLogger.md new file mode 100644 index 0000000000..400b565de2 --- /dev/null +++ b/docs/reference/classes/ConsoleLogger.md @@ -0,0 +1,146 @@ +--- +id: ConsoleLogger +title: ConsoleLogger +--- + +# Class: ConsoleLogger + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L25) + +Pluggable logger interface consumed by every `@tanstack/ai` activity when `debug` is enabled. Supply a custom implementation via `debug: { logger }` on `chat()`, `summarize()`, `generateImage()`, etc. The four methods correspond to log levels: use `debug` for chunk-level diagnostic output, `info`/`warn` for notable events, `error` for caught exceptions. + +## Implements + +- [`Logger`](../interfaces/Logger.md) + +## Constructors + +### Constructor + +```ts +new ConsoleLogger(): ConsoleLogger; +``` + +#### Returns + +`ConsoleLogger` + +## Methods + +### debug() + +```ts +debug(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:27](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L27) + +Log a debug-level message; forwards to `console.debug`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`debug`](../interfaces/Logger.md#debug) + +*** + +### error() + +```ts +error(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L45) + +Log an error-level message; forwards to `console.error`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`error`](../interfaces/Logger.md#error) + +*** + +### info() + +```ts +info(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L33) + +Log an info-level message; forwards to `console.info`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`info`](../interfaces/Logger.md#info) + +*** + +### warn() + +```ts +warn(message, meta?): void; +``` + +Defined in: [packages/typescript/ai/src/logger/console-logger.ts:39](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/console-logger.ts#L39) + +Log a warning-level message; forwards to `console.warn`. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +#### Returns + +`void` + +#### Implementation of + +[`Logger`](../interfaces/Logger.md).[`warn`](../interfaces/Logger.md#warn) diff --git a/docs/reference/classes/ImmediateStrategy.md b/docs/reference/classes/ImmediateStrategy.md index 7d3504e0ae..50c0c2bd79 100644 --- a/docs/reference/classes/ImmediateStrategy.md +++ b/docs/reference/classes/ImmediateStrategy.md @@ -5,7 +5,7 @@ title: ImmediateStrategy # Class: ImmediateStrategy -Defined in: [activities/chat/stream/strategies.ts:12](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L12) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:12](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L12) Immediate Strategy - emit on every chunk (default behavior) @@ -33,7 +33,7 @@ new ImmediateStrategy(): ImmediateStrategy; shouldEmit(_chunk, _accumulated): boolean; ``` -Defined in: [activities/chat/stream/strategies.ts:13](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L13) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:13](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L13) Called for each text chunk received diff --git a/docs/reference/classes/PartialJSONParser.md b/docs/reference/classes/PartialJSONParser.md index d60510d446..6842d87492 100644 --- a/docs/reference/classes/PartialJSONParser.md +++ b/docs/reference/classes/PartialJSONParser.md @@ -5,7 +5,7 @@ title: PartialJSONParser # Class: PartialJSONParser -Defined in: [activities/chat/stream/json-parser.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L25) +Defined in: [packages/typescript/ai/src/activities/chat/stream/json-parser.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L25) Partial JSON Parser implementation using the partial-json library This parser can handle incomplete JSON strings during streaming @@ -34,7 +34,7 @@ new PartialJSONParser(): PartialJSONParser; parse(jsonString): any; ``` -Defined in: [activities/chat/stream/json-parser.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L31) +Defined in: [packages/typescript/ai/src/activities/chat/stream/json-parser.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L31) Parse a potentially incomplete JSON string diff --git a/docs/reference/classes/PunctuationStrategy.md b/docs/reference/classes/PunctuationStrategy.md index cdc403dbbd..8e899c8f60 100644 --- a/docs/reference/classes/PunctuationStrategy.md +++ b/docs/reference/classes/PunctuationStrategy.md @@ -5,7 +5,7 @@ title: PunctuationStrategy # Class: PunctuationStrategy -Defined in: [activities/chat/stream/strategies.ts:22](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L22) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:22](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L22) Punctuation Strategy - emit when chunk contains punctuation Useful for natural text flow in UI @@ -34,7 +34,7 @@ new PunctuationStrategy(): PunctuationStrategy; shouldEmit(chunk, _accumulated): boolean; ``` -Defined in: [activities/chat/stream/strategies.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L25) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L25) Called for each text chunk received diff --git a/docs/reference/classes/StreamProcessor.md b/docs/reference/classes/StreamProcessor.md index a9d18e793b..83bc01e50c 100644 --- a/docs/reference/classes/StreamProcessor.md +++ b/docs/reference/classes/StreamProcessor.md @@ -5,7 +5,7 @@ title: StreamProcessor # Class: StreamProcessor -Defined in: [activities/chat/stream/processor.ts:128](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L128) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:128](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L128) StreamProcessor - State machine for processing AI response streams @@ -32,7 +32,7 @@ State tracking: new StreamProcessor(options): StreamProcessor; ``` -Defined in: [activities/chat/stream/processor.ts:155](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L155) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:155](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L155) #### Parameters @@ -52,7 +52,7 @@ Defined in: [activities/chat/stream/processor.ts:155](https://github.com/TanStac addToolApprovalResponse(approvalId, approved): void; ``` -Defined in: [activities/chat/stream/processor.ts:313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L313) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L313) Add an approval response (called by client after handling onApprovalRequest) @@ -81,7 +81,7 @@ addToolResult( error?): void; ``` -Defined in: [activities/chat/stream/processor.ts:269](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L269) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:269](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L269) Add a tool result (called by client after handling onToolCall) @@ -111,7 +111,7 @@ Add a tool result (called by client after handling onToolCall) addUserMessage(content, id?): UIMessage; ``` -Defined in: [activities/chat/stream/processor.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L202) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L202) Add a user message to the conversation. Supports both simple string content and multimodal content arrays. @@ -160,7 +160,7 @@ processor.addUserMessage('Hello!', 'custom-id-123') areAllToolsComplete(): boolean; ``` -Defined in: [activities/chat/stream/processor.ts:344](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L344) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:344](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L344) Check if all tool calls in the last assistant message are complete Useful for auto-continue logic @@ -177,7 +177,7 @@ Useful for auto-continue logic clearMessages(): void; ``` -Defined in: [activities/chat/stream/processor.ts:388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L388) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L388) Clear all messages @@ -193,7 +193,7 @@ Clear all messages finalizeStream(): void; ``` -Defined in: [activities/chat/stream/processor.ts:1317](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1317) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1444](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1444) Finalize the stream — complete all pending operations. @@ -217,7 +217,7 @@ docs/chat-architecture.md#single-shot-text-response — Finalization step getCurrentAssistantMessageId(): string | null; ``` -Defined in: [activities/chat/stream/processor.ts:253](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L253) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:253](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L253) Get the current assistant message ID (if one has been created). Returns null if prepareAssistantMessage() was called but no content @@ -235,7 +235,7 @@ has arrived yet. getMessages(): UIMessage[]; ``` -Defined in: [activities/chat/stream/processor.ts:336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L336) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L336) Get current messages @@ -251,7 +251,7 @@ Get current messages getRecording(): ChunkRecording | null; ``` -Defined in: [activities/chat/stream/processor.ts:1449](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1449) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1576](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1576) Get the current recording @@ -267,7 +267,7 @@ Get the current recording getState(): ProcessorState; ``` -Defined in: [activities/chat/stream/processor.ts:1408](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1408) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1535](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1535) Get current processor state (aggregated across all messages) @@ -283,7 +283,7 @@ Get current processor state (aggregated across all messages) prepareAssistantMessage(): void; ``` -Defined in: [activities/chat/stream/processor.ts:232](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L232) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:232](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L232) Prepare for a new assistant message stream. Does NOT create the message immediately -- the message is created lazily @@ -303,7 +303,7 @@ auto-continuation produces no content. process(stream): Promise; ``` -Defined in: [activities/chat/stream/processor.ts:404](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L404) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:404](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L404) Process a stream and emit events through handlers @@ -325,13 +325,13 @@ Process a stream and emit events through handlers processChunk(chunk): void; ``` -Defined in: [activities/chat/stream/processor.ts:438](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L438) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:438](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L438) Process a single chunk from the stream. Central dispatch for all AG-UI events. Each event type maps to a specific handler. Events not listed in the switch are intentionally ignored -(RUN_STARTED, STEP_STARTED, STATE_DELTA). +(STEP_STARTED, STATE_SNAPSHOT, STATE_DELTA). #### Parameters @@ -355,7 +355,7 @@ docs/chat-architecture.md#adapter-contract — Expected event types and ordering removeMessagesAfter(index): void; ``` -Defined in: [activities/chat/stream/processor.ts:380](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L380) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:380](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L380) Remove messages after a certain index (for reload/retry) @@ -377,7 +377,7 @@ Remove messages after a certain index (for reload/retry) reset(): void; ``` -Defined in: [activities/chat/stream/processor.ts:1471](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1471) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1598](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1598) Full reset (including messages) @@ -393,7 +393,7 @@ Full reset (including messages) setMessages(messages): void; ``` -Defined in: [activities/chat/stream/processor.ts:174](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L174) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:174](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L174) Set the messages array (e.g., from persisted state) @@ -415,7 +415,7 @@ Set the messages array (e.g., from persisted state) startAssistantMessage(messageId?): string; ``` -Defined in: [activities/chat/stream/processor.ts:241](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L241) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:241](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L241) #### Parameters @@ -440,7 +440,7 @@ an assistant message which can cause empty message flicker. startRecording(): void; ``` -Defined in: [activities/chat/stream/processor.ts:1436](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1436) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1563](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1563) Start recording chunks @@ -459,7 +459,7 @@ toModelMessages(): ModelMessage< | null>[]; ``` -Defined in: [activities/chat/stream/processor.ts:325](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L325) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:325](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L325) Get the conversation as ModelMessages (for sending to LLM) @@ -478,7 +478,7 @@ Get the conversation as ModelMessages (for sending to LLM) static replay(recording, options?): Promise; ``` -Defined in: [activities/chat/stream/processor.ts:1490](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1490) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1617](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1617) Replay a recording through the processor diff --git a/docs/reference/classes/ToolCallManager.md b/docs/reference/classes/ToolCallManager.md index 83dccc820d..8b8d9f1f98 100644 --- a/docs/reference/classes/ToolCallManager.md +++ b/docs/reference/classes/ToolCallManager.md @@ -5,7 +5,7 @@ title: ToolCallManager # Class: ToolCallManager -Defined in: [activities/chat/tools/tool-calls.ts:83](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L83) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:83](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L83) Manages tool call accumulation and execution for the chat() method's automatic tool execution loop. @@ -49,7 +49,7 @@ if (manager.hasToolCalls()) { new ToolCallManager(tools): ToolCallManager; ``` -Defined in: [activities/chat/tools/tool-calls.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L87) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L87) #### Parameters @@ -69,7 +69,7 @@ readonly [`Tool`](../interfaces/Tool.md)\<[`SchemaInput`](../type-aliases/Schema addToolCallArgsEvent(event): void; ``` -Defined in: [activities/chat/tools/tool-calls.ts:112](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L112) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:113](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L113) Add a TOOL_CALL_ARGS event to accumulate arguments (AG-UI) @@ -91,7 +91,7 @@ Add a TOOL_CALL_ARGS event to accumulate arguments (AG-UI) addToolCallStartEvent(event): void; ``` -Defined in: [activities/chat/tools/tool-calls.ts:94](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L94) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:94](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L94) Add a TOOL_CALL_START event to begin tracking a tool call (AG-UI) @@ -113,7 +113,7 @@ Add a TOOL_CALL_START event to begin tracking a tool call (AG-UI) clear(): void; ``` -Defined in: [activities/chat/tools/tool-calls.ts:256](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L256) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L262) Clear the tool calls map for the next iteration @@ -129,7 +129,7 @@ Clear the tool calls map for the next iteration completeToolCall(event): void; ``` -Defined in: [activities/chat/tools/tool-calls.ts:126](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L126) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:127](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L127) Complete a tool call with its final input Called when TOOL_CALL_END is received @@ -155,7 +155,7 @@ executeTools(finishEvent): AsyncGenerator[], void>; ``` -Defined in: [activities/chat/tools/tool-calls.ts:158](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L158) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L162) Execute all tool calls and return tool result messages Yields TOOL_CALL_END events for streaming @@ -183,7 +183,7 @@ RUN_FINISHED event from the stream getToolCalls(): ToolCall[]; ``` -Defined in: [activities/chat/tools/tool-calls.ts:147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L147) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:151](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L151) Get all complete tool calls (filtered for valid ID and name) @@ -199,7 +199,7 @@ Get all complete tool calls (filtered for valid ID and name) hasToolCalls(): boolean; ``` -Defined in: [activities/chat/tools/tool-calls.ts:140](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L140) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:144](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L144) Check if there are any complete tool calls to execute diff --git a/docs/reference/classes/WordBoundaryStrategy.md b/docs/reference/classes/WordBoundaryStrategy.md index 3f54ff3dea..91390d65ef 100644 --- a/docs/reference/classes/WordBoundaryStrategy.md +++ b/docs/reference/classes/WordBoundaryStrategy.md @@ -5,7 +5,7 @@ title: WordBoundaryStrategy # Class: WordBoundaryStrategy -Defined in: [activities/chat/stream/strategies.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L57) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L57) Word Boundary Strategy - emit at word boundaries Prevents cutting words in half @@ -34,7 +34,7 @@ new WordBoundaryStrategy(): WordBoundaryStrategy; shouldEmit(chunk, _accumulated): boolean; ``` -Defined in: [activities/chat/stream/strategies.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L58) +Defined in: [packages/typescript/ai/src/activities/chat/stream/strategies.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/strategies.ts#L58) Called for each text chunk received diff --git a/docs/reference/functions/chat.md b/docs/reference/functions/chat.md index 9e5bdb1f5c..f65c579a82 100644 --- a/docs/reference/functions/chat.md +++ b/docs/reference/functions/chat.md @@ -9,7 +9,7 @@ title: chat function chat(options): TextActivityResult; ``` -Defined in: [activities/chat/index.ts:1373](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L1373) +Defined in: [packages/typescript/ai/src/activities/chat/index.ts:1512](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L1512) Text activity - handles agentic text generation, one-shot text generation, and agentic structured output. diff --git a/docs/reference/functions/combineStrategies.md b/docs/reference/functions/combineStrategies.md index 618f93a929..f6feb2be31 100644 --- a/docs/reference/functions/combineStrategies.md +++ b/docs/reference/functions/combineStrategies.md @@ -9,7 +9,7 @@ title: combineStrategies function combineStrategies(strategies): AgentLoopStrategy; ``` -Defined in: [activities/chat/agent-loop-strategies.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts#L79) +Defined in: [packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts#L79) Creates a strategy that combines multiple strategies with AND logic All strategies must return true to continue diff --git a/docs/reference/functions/convertMessagesToModelMessages.md b/docs/reference/functions/convertMessagesToModelMessages.md index 7ffe1ccb59..fd04e1120b 100644 --- a/docs/reference/functions/convertMessagesToModelMessages.md +++ b/docs/reference/functions/convertMessagesToModelMessages.md @@ -12,7 +12,7 @@ function convertMessagesToModelMessages(messages): ModelMessage< | null>[]; ``` -Defined in: [activities/chat/messages.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L63) +Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L63) Convert UIMessages or ModelMessages to ModelMessages diff --git a/docs/reference/functions/convertSchemaToJsonSchema.md b/docs/reference/functions/convertSchemaToJsonSchema.md index 2e0d7cdfd6..64258aa980 100644 --- a/docs/reference/functions/convertSchemaToJsonSchema.md +++ b/docs/reference/functions/convertSchemaToJsonSchema.md @@ -9,7 +9,7 @@ title: convertSchemaToJsonSchema function convertSchemaToJsonSchema(schema, options): JSONSchema | undefined; ``` -Defined in: [activities/chat/tools/schema-converter.ts:199](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/schema-converter.ts#L199) +Defined in: [packages/typescript/ai/src/activities/chat/tools/schema-converter.ts:205](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/schema-converter.ts#L205) Converts a Standard JSON Schema compliant schema or plain JSONSchema to JSON Schema format compatible with LLM providers. diff --git a/docs/reference/functions/createAudioOptions.md b/docs/reference/functions/createAudioOptions.md new file mode 100644 index 0000000000..89f58378a9 --- /dev/null +++ b/docs/reference/functions/createAudioOptions.md @@ -0,0 +1,34 @@ +--- +id: createAudioOptions +title: createAudioOptions +--- + +# Function: createAudioOptions() + +```ts +function createAudioOptions(options): AudioActivityOptions; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/index.ts:209](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/index.ts#L209) + +Create typed options for the generateAudio() function without executing. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`AudioAdapter`](../interfaces/AudioAdapter.md)\<`string`, `AudioProviderOptions`\<`TAdapter`\>\> + +### TStream + +`TStream` *extends* `boolean` = `false` + +## Parameters + +### options + +`AudioActivityOptions`\<`TAdapter`, `TStream`\> + +## Returns + +`AudioActivityOptions`\<`TAdapter`, `TStream`\> diff --git a/docs/reference/functions/createChatOptions.md b/docs/reference/functions/createChatOptions.md index 2da693d2b2..a05f78cf2d 100644 --- a/docs/reference/functions/createChatOptions.md +++ b/docs/reference/functions/createChatOptions.md @@ -9,7 +9,7 @@ title: createChatOptions function createChatOptions(options): TextActivityOptions; ``` -Defined in: [activities/chat/index.ts:185](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L185) +Defined in: [packages/typescript/ai/src/activities/chat/index.ts:213](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L213) Create typed options for the chat() function without executing. This is useful for pre-defining configurations with full type inference. diff --git a/docs/reference/functions/createFrozenRegistry.md b/docs/reference/functions/createFrozenRegistry.md index 9682a8fedd..03be7bef43 100644 --- a/docs/reference/functions/createFrozenRegistry.md +++ b/docs/reference/functions/createFrozenRegistry.md @@ -9,7 +9,7 @@ title: createFrozenRegistry function createFrozenRegistry(tools): ToolRegistry; ``` -Defined in: [tool-registry.ts:119](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L119) +Defined in: [packages/typescript/ai/src/tool-registry.ts:119](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L119) Create a frozen (immutable) tool registry from a tools array. diff --git a/docs/reference/functions/createImageOptions.md b/docs/reference/functions/createImageOptions.md index 93ae325d5b..af24183cc2 100644 --- a/docs/reference/functions/createImageOptions.md +++ b/docs/reference/functions/createImageOptions.md @@ -9,7 +9,7 @@ title: createImageOptions function createImageOptions(options): ImageActivityOptions; ``` -Defined in: [activities/generateImage/index.ts:244](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L244) +Defined in: [packages/typescript/ai/src/activities/generateImage/index.ts:270](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L270) Create typed options for the generateImage() function without executing. diff --git a/docs/reference/functions/createModel.md b/docs/reference/functions/createModel.md index 7670dfbe82..a644e10413 100644 --- a/docs/reference/functions/createModel.md +++ b/docs/reference/functions/createModel.md @@ -9,7 +9,7 @@ title: createModel function createModel(name, input): ExtendedModelDef; ``` -Defined in: [extend-adapter.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L61) +Defined in: [packages/typescript/ai/src/extend-adapter.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L61) Creates a custom model definition for use with `extendAdapter`. diff --git a/docs/reference/functions/createReplayStream.md b/docs/reference/functions/createReplayStream.md index 56f9e15f1f..8823b2c81e 100644 --- a/docs/reference/functions/createReplayStream.md +++ b/docs/reference/functions/createReplayStream.md @@ -9,7 +9,7 @@ title: createReplayStream function createReplayStream(recording): AsyncIterable; ``` -Defined in: [activities/chat/stream/processor.ts:1502](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1502) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1629](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1629) Create an async iterable from a recording diff --git a/docs/reference/functions/createSpeechOptions.md b/docs/reference/functions/createSpeechOptions.md index 990fb5400a..cf28e6c3c9 100644 --- a/docs/reference/functions/createSpeechOptions.md +++ b/docs/reference/functions/createSpeechOptions.md @@ -9,7 +9,7 @@ title: createSpeechOptions function createSpeechOptions(options): TTSActivityOptions; ``` -Defined in: [activities/generateSpeech/index.ts:181](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L181) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/index.ts:223](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L223) Create typed options for the generateSpeech() function without executing. @@ -17,7 +17,7 @@ Create typed options for the generateSpeech() function without executing. ### TAdapter -`TAdapter` *extends* [`TTSAdapter`](../interfaces/TTSAdapter.md)\<`string`, `object`\> +`TAdapter` *extends* [`TTSAdapter`](../interfaces/TTSAdapter.md)\<`string`, `TTSProviderOptions`\<`TAdapter`\>\> ### TStream diff --git a/docs/reference/functions/createSummarizeOptions.md b/docs/reference/functions/createSummarizeOptions.md index f612b7129d..4423c9e1ba 100644 --- a/docs/reference/functions/createSummarizeOptions.md +++ b/docs/reference/functions/createSummarizeOptions.md @@ -9,7 +9,7 @@ title: createSummarizeOptions function createSummarizeOptions(options): SummarizeActivityOptions; ``` -Defined in: [activities/summarize/index.ts:254](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L254) +Defined in: [packages/typescript/ai/src/activities/summarize/index.ts:300](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L300) Create typed options for the summarize() function without executing. diff --git a/docs/reference/functions/createToolRegistry.md b/docs/reference/functions/createToolRegistry.md index d104341933..3f713c9858 100644 --- a/docs/reference/functions/createToolRegistry.md +++ b/docs/reference/functions/createToolRegistry.md @@ -9,7 +9,7 @@ title: createToolRegistry function createToolRegistry(initialTools): ToolRegistry; ``` -Defined in: [tool-registry.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L78) +Defined in: [packages/typescript/ai/src/tool-registry.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L78) Create a mutable tool registry for dynamic tool scenarios. diff --git a/docs/reference/functions/createTranscriptionOptions.md b/docs/reference/functions/createTranscriptionOptions.md index d539de99ac..a68ae761ff 100644 --- a/docs/reference/functions/createTranscriptionOptions.md +++ b/docs/reference/functions/createTranscriptionOptions.md @@ -9,7 +9,7 @@ title: createTranscriptionOptions function createTranscriptionOptions(options): TranscriptionActivityOptions; ``` -Defined in: [activities/generateTranscription/index.ts:199](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L199) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/index.ts:251](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L251) Create typed options for the generateTranscription() function without executing. @@ -17,7 +17,7 @@ Create typed options for the generateTranscription() function without executing. ### TAdapter -`TAdapter` *extends* [`TranscriptionAdapter`](../interfaces/TranscriptionAdapter.md)\<`string`, `object`\> +`TAdapter` *extends* [`TranscriptionAdapter`](../interfaces/TranscriptionAdapter.md)\<`string`, `TranscriptionProviderOptions`\<`TAdapter`\>\> ### TStream diff --git a/docs/reference/functions/createVideoOptions.md b/docs/reference/functions/createVideoOptions.md index 0cda333dad..ad322b459e 100644 --- a/docs/reference/functions/createVideoOptions.md +++ b/docs/reference/functions/createVideoOptions.md @@ -9,7 +9,7 @@ title: createVideoOptions function createVideoOptions(options): VideoCreateOptions; ``` -Defined in: [activities/generateVideo/index.ts:481](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L481) +Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:547](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L547) Create typed options for the generateVideo() function without executing. diff --git a/docs/reference/functions/detectImageMimeType.md b/docs/reference/functions/detectImageMimeType.md index 1a1f09925c..88a04a4add 100644 --- a/docs/reference/functions/detectImageMimeType.md +++ b/docs/reference/functions/detectImageMimeType.md @@ -9,7 +9,7 @@ title: detectImageMimeType function detectImageMimeType(base64Data): "image/jpeg" | "image/png" | "image/gif" | "image/webp" | undefined; ``` -Defined in: [utils.ts:17](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/utils.ts#L17) +Defined in: [packages/typescript/ai/src/utils.ts:17](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/utils.ts#L17) Detect image mime type from base64 data using magic bytes. Returns undefined if the format cannot be detected. diff --git a/docs/reference/functions/extendAdapter.md b/docs/reference/functions/extendAdapter.md index ac3f2b18e3..e76df1d714 100644 --- a/docs/reference/functions/extendAdapter.md +++ b/docs/reference/functions/extendAdapter.md @@ -9,7 +9,7 @@ title: extendAdapter function extendAdapter(factory, _customModels): (model, ...args) => InferAdapterReturn; ``` -Defined in: [extend-adapter.ts:166](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L166) +Defined in: [packages/typescript/ai/src/extend-adapter.ts:166](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L166) Extends an existing adapter factory with additional custom models. diff --git a/docs/reference/functions/generateAudio.md b/docs/reference/functions/generateAudio.md new file mode 100644 index 0000000000..52b6bea147 --- /dev/null +++ b/docs/reference/functions/generateAudio.md @@ -0,0 +1,51 @@ +--- +id: generateAudio +title: generateAudio +--- + +# Function: generateAudio() + +```ts +function generateAudio(options): AudioActivityResult; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/index.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/index.ts#L115) + +Audio generation activity - generates audio from text prompts. + +Uses AI models to create music, sound effects, and other audio content. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`AudioAdapter`](../interfaces/AudioAdapter.md)\<`string`, `AudioProviderOptions`\<`TAdapter`\>\> + +### TStream + +`TStream` *extends* `boolean` = `false` + +## Parameters + +### options + +`AudioActivityOptions`\<`TAdapter`, `TStream`\> + +## Returns + +`AudioActivityResult`\<`TStream`\> + +## Example + +```ts +import { generateAudio } from '@tanstack/ai' +import { falAudio } from '@tanstack/ai-fal' + +const result = await generateAudio({ + adapter: falAudio('fal-ai/diffrhythm'), + prompt: 'An upbeat electronic track with synths', + duration: 10 +}) + +console.log(result.audio.url) // URL to generated audio +``` diff --git a/docs/reference/functions/generateImage.md b/docs/reference/functions/generateImage.md index cc430263b0..bd3d002b37 100644 --- a/docs/reference/functions/generateImage.md +++ b/docs/reference/functions/generateImage.md @@ -9,7 +9,7 @@ title: generateImage function generateImage(options): ImageActivityResult; ``` -Defined in: [activities/generateImage/index.ts:167](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L167) +Defined in: [packages/typescript/ai/src/activities/generateImage/index.ts:176](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/index.ts#L176) Image activity - generates images from text prompts. diff --git a/docs/reference/functions/generateMessageId.md b/docs/reference/functions/generateMessageId.md index 07c1d2b52e..4d95ea5413 100644 --- a/docs/reference/functions/generateMessageId.md +++ b/docs/reference/functions/generateMessageId.md @@ -9,7 +9,7 @@ title: generateMessageId function generateMessageId(): string; ``` -Defined in: [activities/chat/messages.ts:434](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L434) +Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:434](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L434) Generate a unique message ID diff --git a/docs/reference/functions/generateSpeech.md b/docs/reference/functions/generateSpeech.md index 61f49a287d..3b46735df6 100644 --- a/docs/reference/functions/generateSpeech.md +++ b/docs/reference/functions/generateSpeech.md @@ -9,7 +9,7 @@ title: generateSpeech function generateSpeech(options): TTSActivityResult; ``` -Defined in: [activities/generateSpeech/index.ts:119](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L119) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/index.ts:128](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/index.ts#L128) TTS activity - generates speech from text. @@ -19,7 +19,7 @@ Uses AI text-to-speech models to create audio from natural language text. ### TAdapter -`TAdapter` *extends* [`TTSAdapter`](../interfaces/TTSAdapter.md)\<`string`, `object`\> +`TAdapter` *extends* [`TTSAdapter`](../interfaces/TTSAdapter.md)\<`string`, `TTSProviderOptions`\<`TAdapter`\>\> ### TStream diff --git a/docs/reference/functions/generateTranscription.md b/docs/reference/functions/generateTranscription.md index c935da92ea..0b7de30aa9 100644 --- a/docs/reference/functions/generateTranscription.md +++ b/docs/reference/functions/generateTranscription.md @@ -9,7 +9,7 @@ title: generateTranscription function generateTranscription(options): TranscriptionActivityResult; ``` -Defined in: [activities/generateTranscription/index.ts:134](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L134) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/index.ts:146](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/index.ts#L146) Transcription activity - converts audio to text. @@ -19,7 +19,7 @@ Uses AI speech-to-text models to transcribe audio content. ### TAdapter -`TAdapter` *extends* [`TranscriptionAdapter`](../interfaces/TranscriptionAdapter.md)\<`string`, `object`\> +`TAdapter` *extends* [`TranscriptionAdapter`](../interfaces/TranscriptionAdapter.md)\<`string`, `TranscriptionProviderOptions`\<`TAdapter`\>\> ### TStream diff --git a/docs/reference/functions/generateVideo.md b/docs/reference/functions/generateVideo.md index 2f2a915e8b..9ca9f6b29d 100644 --- a/docs/reference/functions/generateVideo.md +++ b/docs/reference/functions/generateVideo.md @@ -9,7 +9,7 @@ title: generateVideo function generateVideo(options): TStream extends true ? AsyncIterable : Promise; ``` -Defined in: [activities/generateVideo/index.ts:221](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L221) +Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:231](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L231) **`Experimental`** diff --git a/docs/reference/functions/getVideoJobStatus.md b/docs/reference/functions/getVideoJobStatus.md index 38fecc3d5a..44247c5b58 100644 --- a/docs/reference/functions/getVideoJobStatus.md +++ b/docs/reference/functions/getVideoJobStatus.md @@ -14,7 +14,7 @@ function getVideoJobStatus(options): Promise<{ }>; ``` -Defined in: [activities/generateVideo/index.ts:381](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L381) +Defined in: [packages/typescript/ai/src/activities/generateVideo/index.ts:447](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/index.ts#L447) **`Experimental`** diff --git a/docs/reference/functions/maxIterations.md b/docs/reference/functions/maxIterations.md index bdcab002a3..f8a50c1acb 100644 --- a/docs/reference/functions/maxIterations.md +++ b/docs/reference/functions/maxIterations.md @@ -9,7 +9,7 @@ title: maxIterations function maxIterations(max): AgentLoopStrategy; ``` -Defined in: [activities/chat/agent-loop-strategies.ts:20](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts#L20) +Defined in: [packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts:20](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts#L20) Creates a strategy that continues for a maximum number of iterations diff --git a/docs/reference/functions/modelMessageToUIMessage.md b/docs/reference/functions/modelMessageToUIMessage.md index b7f1b30d28..ed3bafd0c0 100644 --- a/docs/reference/functions/modelMessageToUIMessage.md +++ b/docs/reference/functions/modelMessageToUIMessage.md @@ -9,7 +9,7 @@ title: modelMessageToUIMessage function modelMessageToUIMessage(modelMessage, id?): UIMessage; ``` -Defined in: [activities/chat/messages.ts:303](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L303) +Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:303](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L303) Convert a ModelMessage to UIMessage diff --git a/docs/reference/functions/modelMessagesToUIMessages.md b/docs/reference/functions/modelMessagesToUIMessages.md index a867e1ec29..55bdf67000 100644 --- a/docs/reference/functions/modelMessagesToUIMessages.md +++ b/docs/reference/functions/modelMessagesToUIMessages.md @@ -9,7 +9,7 @@ title: modelMessagesToUIMessages function modelMessagesToUIMessages(modelMessages): UIMessage[]; ``` -Defined in: [activities/chat/messages.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L362) +Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L362) Convert an array of ModelMessages to UIMessages diff --git a/docs/reference/functions/normalizeToUIMessage.md b/docs/reference/functions/normalizeToUIMessage.md index e3bd724f60..be16a29e4b 100644 --- a/docs/reference/functions/normalizeToUIMessage.md +++ b/docs/reference/functions/normalizeToUIMessage.md @@ -9,7 +9,7 @@ title: normalizeToUIMessage function normalizeToUIMessage(message, generateId): UIMessage; ``` -Defined in: [activities/chat/messages.ts:411](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L411) +Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:411](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L411) Normalize a message (UIMessage or ModelMessage) to a UIMessage Ensures the message has an ID and createdAt timestamp diff --git a/docs/reference/functions/parsePartialJSON.md b/docs/reference/functions/parsePartialJSON.md index 0afc507501..22211a927b 100644 --- a/docs/reference/functions/parsePartialJSON.md +++ b/docs/reference/functions/parsePartialJSON.md @@ -9,7 +9,7 @@ title: parsePartialJSON function parsePartialJSON(jsonString): any; ``` -Defined in: [activities/chat/stream/json-parser.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L56) +Defined in: [packages/typescript/ai/src/activities/chat/stream/json-parser.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L56) Parse partial JSON string (convenience function) diff --git a/docs/reference/functions/realtimeToken.md b/docs/reference/functions/realtimeToken.md index caa4865d41..522fcab6b8 100644 --- a/docs/reference/functions/realtimeToken.md +++ b/docs/reference/functions/realtimeToken.md @@ -9,7 +9,7 @@ title: realtimeToken function realtimeToken(options): Promise; ``` -Defined in: [realtime/index.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/index.ts#L33) +Defined in: [packages/typescript/ai/src/realtime/index.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/index.ts#L33) Generate a realtime token using the provided adapter. diff --git a/docs/reference/functions/streamToText.md b/docs/reference/functions/streamToText.md index b13f038c4f..0a502e5823 100644 --- a/docs/reference/functions/streamToText.md +++ b/docs/reference/functions/streamToText.md @@ -9,7 +9,7 @@ title: streamToText function streamToText(stream): Promise; ``` -Defined in: [stream-to-response.ts:23](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L23) +Defined in: [packages/typescript/ai/src/stream-to-response.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L24) Collect all text content from a StreamChunk async iterable and return as a string. diff --git a/docs/reference/functions/summarize.md b/docs/reference/functions/summarize.md index 1581360934..e352801898 100644 --- a/docs/reference/functions/summarize.md +++ b/docs/reference/functions/summarize.md @@ -9,7 +9,7 @@ title: summarize function summarize(options): SummarizeActivityResult; ``` -Defined in: [activities/summarize/index.ts:147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L147) +Defined in: [packages/typescript/ai/src/activities/summarize/index.ts:156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/index.ts#L156) Summarize activity - generates summaries from text. diff --git a/docs/reference/functions/toHttpResponse.md b/docs/reference/functions/toHttpResponse.md index ec96973b5b..25edca7736 100644 --- a/docs/reference/functions/toHttpResponse.md +++ b/docs/reference/functions/toHttpResponse.md @@ -9,7 +9,7 @@ title: toHttpResponse function toHttpResponse(stream, init?): Response; ``` -Defined in: [stream-to-response.ts:247](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L247) +Defined in: [packages/typescript/ai/src/stream-to-response.ts:240](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L240) Convert a StreamChunk async iterable to a Response in HTTP stream format (newline-delimited JSON) diff --git a/docs/reference/functions/toHttpStream.md b/docs/reference/functions/toHttpStream.md index 8c4361a8dd..445b431584 100644 --- a/docs/reference/functions/toHttpStream.md +++ b/docs/reference/functions/toHttpStream.md @@ -9,7 +9,7 @@ title: toHttpStream function toHttpStream(stream, abortController?): ReadableStream>; ``` -Defined in: [stream-to-response.ts:175](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L175) +Defined in: [packages/typescript/ai/src/stream-to-response.ts:171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L171) Convert a StreamChunk async iterable to a ReadableStream in HTTP stream format (newline-delimited JSON) diff --git a/docs/reference/functions/toServerSentEventsResponse.md b/docs/reference/functions/toServerSentEventsResponse.md index 8886b3c71c..94c1a1dd51 100644 --- a/docs/reference/functions/toServerSentEventsResponse.md +++ b/docs/reference/functions/toServerSentEventsResponse.md @@ -9,14 +9,14 @@ title: toServerSentEventsResponse function toServerSentEventsResponse(stream, init?): Response; ``` -Defined in: [stream-to-response.ts:124](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L124) +Defined in: [packages/typescript/ai/src/stream-to-response.ts:120](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L120) Convert a StreamChunk async iterable to a Response in Server-Sent Events format This creates a Response that emits chunks in SSE format: - Each chunk is prefixed with "data: " - Each chunk is followed by "\n\n" -- Stream ends with "data: [DONE]\n\n" +- Stream ends when the underlying iterable is exhausted (RUN_FINISHED is the terminal event) ## Parameters diff --git a/docs/reference/functions/toServerSentEventsStream.md b/docs/reference/functions/toServerSentEventsStream.md index e172f8da29..08e03cc879 100644 --- a/docs/reference/functions/toServerSentEventsStream.md +++ b/docs/reference/functions/toServerSentEventsStream.md @@ -9,14 +9,14 @@ title: toServerSentEventsStream function toServerSentEventsStream(stream, abortController?): ReadableStream>; ``` -Defined in: [stream-to-response.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L49) +Defined in: [packages/typescript/ai/src/stream-to-response.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/stream-to-response.ts#L50) Convert a StreamChunk async iterable to a ReadableStream in Server-Sent Events format This creates a ReadableStream that emits chunks in SSE format: - Each chunk is prefixed with "data: " - Each chunk is followed by "\n\n" -- Stream ends with "data: [DONE]\n\n" +- Stream ends when the underlying iterable is exhausted (RUN_FINISHED is the terminal event) ## Parameters diff --git a/docs/reference/functions/toolDefinition.md b/docs/reference/functions/toolDefinition.md index 5e2fe21934..e6dea7fa03 100644 --- a/docs/reference/functions/toolDefinition.md +++ b/docs/reference/functions/toolDefinition.md @@ -9,7 +9,7 @@ title: toolDefinition function toolDefinition(config): ToolDefinition; ``` -Defined in: [activities/chat/tools/tool-definition.ts:187](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L187) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:187](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L187) Create an isomorphic tool definition that can be used directly or instantiated for server/client diff --git a/docs/reference/functions/uiMessageToModelMessages.md b/docs/reference/functions/uiMessageToModelMessages.md index 52107288b8..109cfcdd59 100644 --- a/docs/reference/functions/uiMessageToModelMessages.md +++ b/docs/reference/functions/uiMessageToModelMessages.md @@ -12,7 +12,7 @@ function uiMessageToModelMessages(uiMessage): ModelMessage< | null>[]; ``` -Defined in: [activities/chat/messages.ts:98](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L98) +Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:98](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L98) Convert a UIMessage to ModelMessage(s) diff --git a/docs/reference/functions/untilFinishReason.md b/docs/reference/functions/untilFinishReason.md index 0ad4c70db7..55a6f8e705 100644 --- a/docs/reference/functions/untilFinishReason.md +++ b/docs/reference/functions/untilFinishReason.md @@ -9,7 +9,7 @@ title: untilFinishReason function untilFinishReason(stopReasons): AgentLoopStrategy; ``` -Defined in: [activities/chat/agent-loop-strategies.ts:41](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts#L41) +Defined in: [packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts:41](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/agent-loop-strategies.ts#L41) Creates a strategy that continues until a specific finish reason is encountered diff --git a/docs/reference/index.md b/docs/reference/index.md index d7c63aa135..efc8d61653 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -9,6 +9,7 @@ title: "@tanstack/ai" - [BatchStrategy](classes/BatchStrategy.md) - [CompositeStrategy](classes/CompositeStrategy.md) +- [ConsoleLogger](classes/ConsoleLogger.md) - [ImmediateStrategy](classes/ImmediateStrategy.md) - [PartialJSONParser](classes/PartialJSONParser.md) - [PunctuationStrategy](classes/PunctuationStrategy.md) @@ -21,6 +22,9 @@ title: "@tanstack/ai" - [AbortInfo](interfaces/AbortInfo.md) - [AfterToolCallInfo](interfaces/AfterToolCallInfo.md) - [AgentLoopState](interfaces/AgentLoopState.md) +- [AudioAdapter](interfaces/AudioAdapter.md) +- [AudioGenerationOptions](interfaces/AudioGenerationOptions.md) +- [AudioGenerationResult](interfaces/AudioGenerationResult.md) - [AudioPart](interfaces/AudioPart.md) - [AudioVisualization](interfaces/AudioVisualization.md) - [BaseAGUIEvent](interfaces/BaseAGUIEvent.md) @@ -33,12 +37,13 @@ title: "@tanstack/ai" - [ContentPartDataSource](interfaces/ContentPartDataSource.md) - [ContentPartUrlSource](interfaces/ContentPartUrlSource.md) - [CustomEvent](interfaces/CustomEvent.md) +- [DebugCategories](interfaces/DebugCategories.md) +- [DebugConfig](interfaces/DebugConfig.md) - [DefaultMessageMetadataByModality](interfaces/DefaultMessageMetadataByModality.md) - [DocumentPart](interfaces/DocumentPart.md) - [ErrorInfo](interfaces/ErrorInfo.md) - [ExtendedModelDef](interfaces/ExtendedModelDef.md) - [FinishInfo](interfaces/FinishInfo.md) -- [GeneratedImage](interfaces/GeneratedImage.md) - [ImageAdapter](interfaces/ImageAdapter.md) - [ImageGenerationOptions](interfaces/ImageGenerationOptions.md) - [ImageGenerationResult](interfaces/ImageGenerationResult.md) @@ -47,10 +52,12 @@ title: "@tanstack/ai" - [IterationInfo](interfaces/IterationInfo.md) - [JSONParser](interfaces/JSONParser.md) - [JSONSchema](interfaces/JSONSchema.md) +- [Logger](interfaces/Logger.md) - [MessagesSnapshotEvent](interfaces/MessagesSnapshotEvent.md) - [ModelMessage](interfaces/ModelMessage.md) - [ProcessorResult](interfaces/ProcessorResult.md) - [ProcessorState](interfaces/ProcessorState.md) +- [ProviderTool](interfaces/ProviderTool.md) - [RealtimeAudioPart](interfaces/RealtimeAudioPart.md) - [RealtimeError](interfaces/RealtimeError.md) - [RealtimeEventPayloads](interfaces/RealtimeEventPayloads.md) @@ -63,6 +70,12 @@ title: "@tanstack/ai" - [RealtimeTokenOptions](interfaces/RealtimeTokenOptions.md) - [RealtimeToolCallPart](interfaces/RealtimeToolCallPart.md) - [RealtimeToolResultPart](interfaces/RealtimeToolResultPart.md) +- [ReasoningEncryptedValueEvent](interfaces/ReasoningEncryptedValueEvent.md) +- [ReasoningEndEvent](interfaces/ReasoningEndEvent.md) +- [ReasoningMessageContentEvent](interfaces/ReasoningMessageContentEvent.md) +- [ReasoningMessageEndEvent](interfaces/ReasoningMessageEndEvent.md) +- [ReasoningMessageStartEvent](interfaces/ReasoningMessageStartEvent.md) +- [ReasoningStartEvent](interfaces/ReasoningStartEvent.md) - [ResponseFormat](interfaces/ResponseFormat.md) - [RunErrorEvent](interfaces/RunErrorEvent.md) - [RunFinishedEvent](interfaces/RunFinishedEvent.md) @@ -91,6 +104,7 @@ title: "@tanstack/ai" - [ToolCallEndEvent](interfaces/ToolCallEndEvent.md) - [ToolCallHookContext](interfaces/ToolCallHookContext.md) - [ToolCallPart](interfaces/ToolCallPart.md) +- [ToolCallResultEvent](interfaces/ToolCallResultEvent.md) - [ToolCallStartEvent](interfaces/ToolCallStartEvent.md) - [ToolConfig](interfaces/ToolConfig.md) - [ToolDefinition](interfaces/ToolDefinition.md) @@ -122,8 +136,9 @@ title: "@tanstack/ai" - [AgentLoopStrategy](type-aliases/AgentLoopStrategy.md) - [AGUIEvent](type-aliases/AGUIEvent.md) -- [AGUIEventType](type-aliases/AGUIEventType.md) +- [~~AGUIEventType~~](type-aliases/AGUIEventType.md) - [AIAdapter](type-aliases/AIAdapter.md) +- [AnyAudioAdapter](type-aliases/AnyAudioAdapter.md) - [AnyClientTool](type-aliases/AnyClientTool.md) - [AnyImageAdapter](type-aliases/AnyImageAdapter.md) - [AnySummarizeAdapter](type-aliases/AnySummarizeAdapter.md) @@ -138,6 +153,10 @@ title: "@tanstack/ai" - [ContentPart](type-aliases/ContentPart.md) - [ContentPartForInputModalitiesTypes](type-aliases/ContentPartForInputModalitiesTypes.md) - [ContentPartSource](type-aliases/ContentPartSource.md) +- [DebugOption](type-aliases/DebugOption.md) +- [GeneratedAudio](type-aliases/GeneratedAudio.md) +- [GeneratedImage](type-aliases/GeneratedImage.md) +- [GeneratedMediaSource](type-aliases/GeneratedMediaSource.md) - [InferSchemaType](type-aliases/InferSchemaType.md) - [InferToolInput](type-aliases/InferToolInput.md) - [InferToolName](type-aliases/InferToolName.md) @@ -154,7 +173,7 @@ title: "@tanstack/ai" - [RealtimeStatus](type-aliases/RealtimeStatus.md) - [SchemaInput](type-aliases/SchemaInput.md) - [StreamChunk](type-aliases/StreamChunk.md) -- [StreamChunkType](type-aliases/StreamChunkType.md) +- [~~StreamChunkType~~](type-aliases/StreamChunkType.md) - [ToolCallState](type-aliases/ToolCallState.md) - [ToolResultState](type-aliases/ToolResultState.md) @@ -168,6 +187,7 @@ title: "@tanstack/ai" - [combineStrategies](functions/combineStrategies.md) - [convertMessagesToModelMessages](functions/convertMessagesToModelMessages.md) - [convertSchemaToJsonSchema](functions/convertSchemaToJsonSchema.md) +- [createAudioOptions](functions/createAudioOptions.md) - [createChatOptions](functions/createChatOptions.md) - [createFrozenRegistry](functions/createFrozenRegistry.md) - [createImageOptions](functions/createImageOptions.md) @@ -180,6 +200,7 @@ title: "@tanstack/ai" - [createVideoOptions](functions/createVideoOptions.md) - [detectImageMimeType](functions/detectImageMimeType.md) - [extendAdapter](functions/extendAdapter.md) +- [generateAudio](functions/generateAudio.md) - [generateImage](functions/generateImage.md) - [generateMessageId](functions/generateMessageId.md) - [generateSpeech](functions/generateSpeech.md) diff --git a/docs/reference/interfaces/AbortInfo.md b/docs/reference/interfaces/AbortInfo.md index 5797487e94..b146708c4f 100644 --- a/docs/reference/interfaces/AbortInfo.md +++ b/docs/reference/interfaces/AbortInfo.md @@ -5,7 +5,7 @@ title: AbortInfo # Interface: AbortInfo -Defined in: [activities/chat/middleware/types.ts:258](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L258) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:258](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L258) Information passed to onAbort. @@ -17,7 +17,7 @@ Information passed to onAbort. duration: number; ``` -Defined in: [activities/chat/middleware/types.ts:262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L262) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L262) Duration until abort in milliseconds @@ -29,6 +29,6 @@ Duration until abort in milliseconds optional reason: string; ``` -Defined in: [activities/chat/middleware/types.ts:260](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L260) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:260](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L260) The reason for the abort, if provided diff --git a/docs/reference/interfaces/AfterToolCallInfo.md b/docs/reference/interfaces/AfterToolCallInfo.md index 68e1d75253..de50854b08 100644 --- a/docs/reference/interfaces/AfterToolCallInfo.md +++ b/docs/reference/interfaces/AfterToolCallInfo.md @@ -5,7 +5,7 @@ title: AfterToolCallInfo # Interface: AfterToolCallInfo -Defined in: [activities/chat/middleware/types.ts:154](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L154) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:154](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L154) Outcome information provided to onAfterToolCall. @@ -17,7 +17,7 @@ Outcome information provided to onAfterToolCall. duration: number; ``` -Defined in: [activities/chat/middleware/types.ts:166](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L166) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:166](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L166) Duration of tool execution in milliseconds @@ -29,7 +29,7 @@ Duration of tool execution in milliseconds optional error: unknown; ``` -Defined in: [activities/chat/middleware/types.ts:169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L169) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L169) *** @@ -39,7 +39,7 @@ Defined in: [activities/chat/middleware/types.ts:169](https://github.com/TanStac ok: boolean; ``` -Defined in: [activities/chat/middleware/types.ts:164](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L164) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:164](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L164) Whether the execution succeeded @@ -51,7 +51,7 @@ Whether the execution succeeded optional result: unknown; ``` -Defined in: [activities/chat/middleware/types.ts:168](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L168) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:168](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L168) The result (if ok) or error (if not ok) @@ -65,7 +65,7 @@ tool: | undefined; ``` -Defined in: [activities/chat/middleware/types.ts:158](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L158) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:158](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L158) The resolved tool definition @@ -77,7 +77,7 @@ The resolved tool definition toolCall: ToolCall; ``` -Defined in: [activities/chat/middleware/types.ts:156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L156) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L156) The tool call that was executed @@ -89,7 +89,7 @@ The tool call that was executed toolCallId: string; ``` -Defined in: [activities/chat/middleware/types.ts:162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L162) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L162) ID of the tool call @@ -101,6 +101,6 @@ ID of the tool call toolName: string; ``` -Defined in: [activities/chat/middleware/types.ts:160](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L160) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:160](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L160) Name of the tool diff --git a/docs/reference/interfaces/AgentLoopState.md b/docs/reference/interfaces/AgentLoopState.md index 359e961810..7135a6645f 100644 --- a/docs/reference/interfaces/AgentLoopState.md +++ b/docs/reference/interfaces/AgentLoopState.md @@ -5,7 +5,7 @@ title: AgentLoopState # Interface: AgentLoopState -Defined in: [types.ts:604](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L604) +Defined in: [packages/typescript/ai/src/types.ts:631](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L631) State passed to agent loop strategy for determining whether to continue @@ -17,7 +17,7 @@ State passed to agent loop strategy for determining whether to continue finishReason: string | null; ``` -Defined in: [types.ts:610](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L610) +Defined in: [packages/typescript/ai/src/types.ts:637](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L637) Finish reason from the last response @@ -29,7 +29,7 @@ Finish reason from the last response iterationCount: number; ``` -Defined in: [types.ts:606](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L606) +Defined in: [packages/typescript/ai/src/types.ts:633](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L633) Current iteration count (0-indexed) @@ -44,6 +44,6 @@ messages: ModelMessage< | null>[]; ``` -Defined in: [types.ts:608](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L608) +Defined in: [packages/typescript/ai/src/types.ts:635](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L635) Current messages array diff --git a/docs/reference/interfaces/AudioAdapter.md b/docs/reference/interfaces/AudioAdapter.md new file mode 100644 index 0000000000..b2c0c389d5 --- /dev/null +++ b/docs/reference/interfaces/AudioAdapter.md @@ -0,0 +1,105 @@ +--- +id: AudioAdapter +title: AudioAdapter +--- + +# Interface: AudioAdapter\ + +Defined in: [packages/typescript/ai/src/activities/generateAudio/adapter.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/adapter.ts#L24) + +Audio generation adapter interface with pre-resolved generics. + +An adapter is created by a provider function: `provider('model')` → `adapter` +All type resolution happens at the provider call site, not in this interface. + +Generic parameters: +- TModel: The specific model name (e.g., 'fal-ai/diffrhythm') +- TProviderOptions: Provider-specific options (already resolved) + +## Type Parameters + +### TModel + +`TModel` *extends* `string` = `string` + +### TProviderOptions + +`TProviderOptions` *extends* `object` = `Record`\<`string`, `unknown`\> + +## Properties + +### ~types + +```ts +~types: object; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/adapter.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/adapter.ts#L38) + +**`Internal`** + +Type-only properties for inference. Not assigned at runtime. + +#### providerOptions + +```ts +providerOptions: TProviderOptions; +``` + +*** + +### generateAudio() + +```ts +generateAudio: (options) => Promise; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/adapter.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/adapter.ts#L45) + +Generate audio from a text prompt + +#### Parameters + +##### options + +[`AudioGenerationOptions`](AudioGenerationOptions.md)\<`TProviderOptions`\> + +#### Returns + +`Promise`\<[`AudioGenerationResult`](AudioGenerationResult.md)\> + +*** + +### kind + +```ts +readonly kind: "audio"; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/adapter.ts#L29) + +Discriminator for adapter kind - used to determine API shape + +*** + +### model + +```ts +readonly model: TModel; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/adapter.ts#L33) + +The model this adapter is configured for + +*** + +### name + +```ts +readonly name: string; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/adapter.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/adapter.ts#L31) + +Adapter name identifier diff --git a/docs/reference/interfaces/AudioGenerationOptions.md b/docs/reference/interfaces/AudioGenerationOptions.md new file mode 100644 index 0000000000..85a21a101c --- /dev/null +++ b/docs/reference/interfaces/AudioGenerationOptions.md @@ -0,0 +1,79 @@ +--- +id: AudioGenerationOptions +title: AudioGenerationOptions +--- + +# Interface: AudioGenerationOptions\ + +Defined in: [packages/typescript/ai/src/types.ts:1274](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1274) + +Options for audio generation (music, sound effects, etc.). +These are the common options supported across providers. + +## Type Parameters + +### TProviderOptions + +`TProviderOptions` *extends* `object` = `object` + +## Properties + +### duration? + +```ts +optional duration: number; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1282](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1282) + +Desired duration in seconds + +*** + +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1290](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1290) + +Internal logger threaded from the generateAudio() entry point. Adapters +must call logger.request() before the SDK call and logger.errors() in +catch blocks. + +*** + +### model + +```ts +model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1278](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1278) + +The model to use for audio generation + +*** + +### modelOptions? + +```ts +optional modelOptions: TProviderOptions; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1284](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1284) + +Model-specific options for audio generation + +*** + +### prompt + +```ts +prompt: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1280](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1280) + +Text description of the desired audio diff --git a/docs/reference/interfaces/AudioGenerationResult.md b/docs/reference/interfaces/AudioGenerationResult.md new file mode 100644 index 0000000000..7517448ec9 --- /dev/null +++ b/docs/reference/interfaces/AudioGenerationResult.md @@ -0,0 +1,76 @@ +--- +id: AudioGenerationResult +title: AudioGenerationResult +--- + +# Interface: AudioGenerationResult + +Defined in: [packages/typescript/ai/src/types.ts:1306](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1306) + +Result of audio generation + +## Properties + +### audio + +```ts +audio: GeneratedAudio; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1312](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1312) + +The generated audio + +*** + +### id + +```ts +id: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1308](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1308) + +Unique identifier for the generation + +*** + +### model + +```ts +model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1310](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1310) + +Model used for generation + +*** + +### usage? + +```ts +optional usage: object; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1314](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1314) + +Token usage information (if available) + +#### inputTokens? + +```ts +optional inputTokens: number; +``` + +#### outputTokens? + +```ts +optional outputTokens: number; +``` + +#### totalTokens? + +```ts +optional totalTokens: number; +``` diff --git a/docs/reference/interfaces/AudioPart.md b/docs/reference/interfaces/AudioPart.md index 7b9f47a03f..f9aae479b5 100644 --- a/docs/reference/interfaces/AudioPart.md +++ b/docs/reference/interfaces/AudioPart.md @@ -5,7 +5,7 @@ title: AudioPart # Interface: AudioPart\ -Defined in: [types.ts:175](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L175) +Defined in: [packages/typescript/ai/src/types.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L202) Audio content part for multimodal messages. @@ -25,7 +25,7 @@ Provider-specific metadata type optional metadata: TMetadata; ``` -Defined in: [types.ts:180](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L180) +Defined in: [packages/typescript/ai/src/types.ts:207](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L207) Provider-specific metadata (e.g., format, sample rate) @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., format, sample rate) source: ContentPartSource; ``` -Defined in: [types.ts:178](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L178) +Defined in: [packages/typescript/ai/src/types.ts:205](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L205) Source of the audio content @@ -49,4 +49,4 @@ Source of the audio content type: "audio"; ``` -Defined in: [types.ts:176](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L176) +Defined in: [packages/typescript/ai/src/types.ts:203](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L203) diff --git a/docs/reference/interfaces/AudioVisualization.md b/docs/reference/interfaces/AudioVisualization.md index f7de7a28e7..382ad128ca 100644 --- a/docs/reference/interfaces/AudioVisualization.md +++ b/docs/reference/interfaces/AudioVisualization.md @@ -5,7 +5,7 @@ title: AudioVisualization # Interface: AudioVisualization -Defined in: [realtime/types.ts:200](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L200) +Defined in: [packages/typescript/ai/src/realtime/types.ts:200](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L200) Interface for accessing audio visualization data @@ -17,7 +17,7 @@ Interface for accessing audio visualization data getInputFrequencyData: () => Uint8Array; ``` -Defined in: [realtime/types.ts:207](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L207) +Defined in: [packages/typescript/ai/src/realtime/types.ts:207](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L207) Get frequency data for input audio visualization @@ -33,7 +33,7 @@ Get frequency data for input audio visualization getInputTimeDomainData: () => Uint8Array; ``` -Defined in: [realtime/types.ts:212](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L212) +Defined in: [packages/typescript/ai/src/realtime/types.ts:212](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L212) Get time domain data for input waveform @@ -49,7 +49,7 @@ Get time domain data for input waveform getOutputFrequencyData: () => Uint8Array; ``` -Defined in: [realtime/types.ts:209](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L209) +Defined in: [packages/typescript/ai/src/realtime/types.ts:209](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L209) Get frequency data for output audio visualization @@ -65,7 +65,7 @@ Get frequency data for output audio visualization getOutputTimeDomainData: () => Uint8Array; ``` -Defined in: [realtime/types.ts:214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L214) +Defined in: [packages/typescript/ai/src/realtime/types.ts:214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L214) Get time domain data for output waveform @@ -81,7 +81,7 @@ Get time domain data for output waveform readonly inputLevel: number; ``` -Defined in: [realtime/types.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L202) +Defined in: [packages/typescript/ai/src/realtime/types.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L202) Input volume level (0-1 normalized) @@ -93,7 +93,7 @@ Input volume level (0-1 normalized) readonly inputSampleRate: number; ``` -Defined in: [realtime/types.ts:217](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L217) +Defined in: [packages/typescript/ai/src/realtime/types.ts:217](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L217) Input sample rate @@ -105,7 +105,7 @@ Input sample rate optional onInputAudio: (callback) => () => void; ``` -Defined in: [realtime/types.ts:222](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L222) +Defined in: [packages/typescript/ai/src/realtime/types.ts:222](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L222) Subscribe to raw input audio samples @@ -133,7 +133,7 @@ Subscribe to raw input audio samples optional onOutputAudio: (callback) => () => void; ``` -Defined in: [realtime/types.ts:226](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L226) +Defined in: [packages/typescript/ai/src/realtime/types.ts:226](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L226) Subscribe to raw output audio samples @@ -161,7 +161,7 @@ Subscribe to raw output audio samples readonly outputLevel: number; ``` -Defined in: [realtime/types.ts:204](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L204) +Defined in: [packages/typescript/ai/src/realtime/types.ts:204](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L204) Output volume level (0-1 normalized) @@ -173,6 +173,6 @@ Output volume level (0-1 normalized) readonly outputSampleRate: number; ``` -Defined in: [realtime/types.ts:219](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L219) +Defined in: [packages/typescript/ai/src/realtime/types.ts:219](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L219) Output sample rate diff --git a/docs/reference/interfaces/BaseAGUIEvent.md b/docs/reference/interfaces/BaseAGUIEvent.md index a0d263941c..c2d5a5557f 100644 --- a/docs/reference/interfaces/BaseAGUIEvent.md +++ b/docs/reference/interfaces/BaseAGUIEvent.md @@ -5,69 +5,32 @@ title: BaseAGUIEvent # Interface: BaseAGUIEvent -Defined in: [types.ts:752](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L752) +Defined in: [packages/typescript/ai/src/types.ts:794](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L794) Base structure for AG-UI events. -Extends AG-UI spec with TanStack AI additions (model field). +Extends @ag-ui/core BaseEvent with TanStack AI additions. -## Extended by +@ag-ui/core provides: `type`, `timestamp?`, `rawEvent?` +TanStack AI adds: `model?` -- [`RunStartedEvent`](RunStartedEvent.md) -- [`RunFinishedEvent`](RunFinishedEvent.md) -- [`RunErrorEvent`](RunErrorEvent.md) -- [`TextMessageStartEvent`](TextMessageStartEvent.md) -- [`TextMessageContentEvent`](TextMessageContentEvent.md) -- [`TextMessageEndEvent`](TextMessageEndEvent.md) -- [`ToolCallStartEvent`](ToolCallStartEvent.md) -- [`ToolCallArgsEvent`](ToolCallArgsEvent.md) -- [`ToolCallEndEvent`](ToolCallEndEvent.md) -- [`StepStartedEvent`](StepStartedEvent.md) -- [`StepFinishedEvent`](StepFinishedEvent.md) -- [`MessagesSnapshotEvent`](MessagesSnapshotEvent.md) -- [`StateSnapshotEvent`](StateSnapshotEvent.md) -- [`StateDeltaEvent`](StateDeltaEvent.md) -- [`CustomEvent`](CustomEvent.md) +## Extends -## Properties - -### model? - -```ts -optional model: string; -``` - -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) - -Model identifier for multi-model support - -*** +- `BaseEvent` -### rawEvent? +## Indexable ```ts -optional rawEvent: unknown; +[k: string]: unknown ``` -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -*** +## Properties -### timestamp +### model? ```ts -timestamp: number; +optional model: string; ``` -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -*** +Defined in: [packages/typescript/ai/src/types.ts:796](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L796) -### type - -```ts -type: AGUIEventType; -``` - -Defined in: [types.ts:753](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L753) +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ChatMiddleware.md b/docs/reference/interfaces/ChatMiddleware.md index 1a06b9e1e4..263bca3fc8 100644 --- a/docs/reference/interfaces/ChatMiddleware.md +++ b/docs/reference/interfaces/ChatMiddleware.md @@ -5,7 +5,7 @@ title: ChatMiddleware # Interface: ChatMiddleware -Defined in: [activities/chat/middleware/types.ts:308](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L308) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:308](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L308) Chat middleware interface. @@ -43,7 +43,7 @@ const redactionMiddleware: ChatMiddleware = { optional name: string; ``` -Defined in: [activities/chat/middleware/types.ts:310](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L310) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:310](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L310) Optional name for debugging and identification @@ -55,7 +55,7 @@ Optional name for debugging and identification optional onAbort: (ctx, info) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:406](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L406) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:406](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L406) Called when the chat run is aborted. Exactly one of onFinish/onAbort/onError will be called per run. @@ -82,7 +82,7 @@ Exactly one of onFinish/onAbort/onError will be called per run. optional onAfterToolCall: (ctx, info) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:370](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L370) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:370](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L370) Called after a tool execution completes (success or failure). @@ -110,7 +110,7 @@ optional onBeforeToolCall: (ctx, hookCtx) => | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L362) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L362) Called before a tool is executed. Can observe, transform args, skip execution, or abort the run. @@ -143,7 +143,7 @@ optional onChunk: (ctx, chunk) => | null; ``` -Defined in: [activities/chat/middleware/types.ts:348](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L348) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:348](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L348) Called for every chunk yielded by chat(). Can observe, transform, expand, or drop chunks. @@ -180,7 +180,7 @@ optional onConfig: (ctx, config) => | null; ``` -Defined in: [activities/chat/middleware/types.ts:319](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L319) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:319](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L319) Called to observe or transform the chat configuration. Called at init and at the beginning of each agent iteration. @@ -213,7 +213,7 @@ Only the fields you return are overwritten — everything else is preserved. optional onError: (ctx, info) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:415](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L415) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:415](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L415) Called when the chat run encounters an unhandled error. Exactly one of onFinish/onAbort/onError will be called per run. @@ -240,7 +240,7 @@ Exactly one of onFinish/onAbort/onError will be called per run. optional onFinish: (ctx, info) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:397](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L397) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:397](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L397) Called when the chat run completes normally. Exactly one of onFinish/onAbort/onError will be called per run. @@ -267,7 +267,7 @@ Exactly one of onFinish/onAbort/onError will be called per run. optional onIteration: (ctx, info) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:337](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L337) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:337](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L337) Called at the start of each agent loop iteration, after a new assistant message ID is created. Use this to observe iteration boundaries. @@ -294,7 +294,7 @@ is created. Use this to observe iteration boundaries. optional onStart: (ctx) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L331) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L331) Called when the chat run starts (after initial onConfig). @@ -316,7 +316,7 @@ Called when the chat run starts (after initial onConfig). optional onToolPhaseComplete: (ctx, info) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:379](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L379) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:379](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L379) Called after all tool calls in an iteration have been processed. Provides aggregate data about tool execution results, approvals, and client tools. @@ -343,7 +343,7 @@ Provides aggregate data about tool execution results, approvals, and client tool optional onUsage: (ctx, usage) => void | Promise; ``` -Defined in: [activities/chat/middleware/types.ts:388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L388) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L388) Called when usage data is available from a RUN_FINISHED chunk. Called once per model iteration that reports usage. diff --git a/docs/reference/interfaces/ChatMiddlewareConfig.md b/docs/reference/interfaces/ChatMiddlewareConfig.md index 94e674da67..bbacf98b8e 100644 --- a/docs/reference/interfaces/ChatMiddlewareConfig.md +++ b/docs/reference/interfaces/ChatMiddlewareConfig.md @@ -5,7 +5,7 @@ title: ChatMiddlewareConfig # Interface: ChatMiddlewareConfig -Defined in: [activities/chat/middleware/types.ts:105](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L105) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:105](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L105) Chat configuration that middleware can observe or transform. This is a subset of the chat engine's effective configuration @@ -19,7 +19,7 @@ that middleware is allowed to modify. optional maxTokens: number; ``` -Defined in: [activities/chat/middleware/types.ts:111](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L111) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:111](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L111) *** @@ -32,7 +32,7 @@ messages: ModelMessage< | null>[]; ``` -Defined in: [activities/chat/middleware/types.ts:106](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L106) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:106](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L106) *** @@ -42,7 +42,7 @@ Defined in: [activities/chat/middleware/types.ts:106](https://github.com/TanStac optional metadata: Record; ``` -Defined in: [activities/chat/middleware/types.ts:112](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L112) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:112](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L112) *** @@ -52,7 +52,7 @@ Defined in: [activities/chat/middleware/types.ts:112](https://github.com/TanStac optional modelOptions: Record; ``` -Defined in: [activities/chat/middleware/types.ts:113](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L113) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:113](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L113) *** @@ -62,7 +62,7 @@ Defined in: [activities/chat/middleware/types.ts:113](https://github.com/TanStac systemPrompts: string[]; ``` -Defined in: [activities/chat/middleware/types.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L107) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L107) *** @@ -72,7 +72,7 @@ Defined in: [activities/chat/middleware/types.ts:107](https://github.com/TanStac optional temperature: number; ``` -Defined in: [activities/chat/middleware/types.ts:109](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L109) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:109](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L109) *** @@ -82,7 +82,7 @@ Defined in: [activities/chat/middleware/types.ts:109](https://github.com/TanStac tools: Tool[]; ``` -Defined in: [activities/chat/middleware/types.ts:108](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L108) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:108](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L108) *** @@ -92,4 +92,4 @@ Defined in: [activities/chat/middleware/types.ts:108](https://github.com/TanStac optional topP: number; ``` -Defined in: [activities/chat/middleware/types.ts:110](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L110) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:110](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L110) diff --git a/docs/reference/interfaces/ChatMiddlewareContext.md b/docs/reference/interfaces/ChatMiddlewareContext.md index 82c5125eed..d5151ad768 100644 --- a/docs/reference/interfaces/ChatMiddlewareContext.md +++ b/docs/reference/interfaces/ChatMiddlewareContext.md @@ -5,7 +5,7 @@ title: ChatMiddlewareContext # Interface: ChatMiddlewareContext -Defined in: [activities/chat/middleware/types.ts:26](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L26) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:26](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L26) Stable context object passed to all middleware hooks. Created once per chat() invocation and shared across all hooks. @@ -18,7 +18,7 @@ Created once per chat() invocation and shared across all hooks. abort: (reason?) => void; ``` -Defined in: [activities/chat/middleware/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L42) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L42) Abort the chat run with a reason @@ -40,7 +40,7 @@ Abort the chat run with a reason accumulatedContent: string; ``` -Defined in: [activities/chat/middleware/types.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L86) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L86) Accumulated text content for the current iteration @@ -52,7 +52,7 @@ Accumulated text content for the current iteration chunkIndex: number; ``` -Defined in: [activities/chat/middleware/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L38) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L38) Running count of chunks yielded so far @@ -64,7 +64,7 @@ Running count of chunks yielded so far context: unknown; ``` -Defined in: [activities/chat/middleware/types.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L44) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L44) Opaque user-provided value from chat() options @@ -76,7 +76,7 @@ Opaque user-provided value from chat() options optional conversationId: string; ``` -Defined in: [activities/chat/middleware/types.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L32) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L32) Conversation identifier, if provided by the caller @@ -88,7 +88,7 @@ Conversation identifier, if provided by the caller createId: (prefix) => string; ``` -Defined in: [activities/chat/middleware/types.ts:93](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L93) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:93](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L93) Generate a unique ID with the given prefix @@ -110,7 +110,7 @@ Generate a unique ID with the given prefix currentMessageId: string | null; ``` -Defined in: [activities/chat/middleware/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L84) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L84) Current assistant message ID (changes per iteration) @@ -122,7 +122,7 @@ Current assistant message ID (changes per iteration) defer: (promise) => void; ``` -Defined in: [activities/chat/middleware/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L50) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L50) Defer a non-blocking side-effect promise. Deferred promises do not block streaming and are awaited @@ -146,7 +146,7 @@ after the terminal hook (onFinish/onAbort/onError). hasTools: boolean; ``` -Defined in: [activities/chat/middleware/types.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L79) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L79) Whether tools are configured @@ -158,7 +158,7 @@ Whether tools are configured iteration: number; ``` -Defined in: [activities/chat/middleware/types.ts:36](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L36) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:36](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L36) Current agent loop iteration (0-indexed) @@ -170,7 +170,7 @@ Current agent loop iteration (0-indexed) messageCount: number; ``` -Defined in: [activities/chat/middleware/types.ts:77](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L77) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:77](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L77) Number of messages at the start of the request @@ -185,7 +185,7 @@ messages: readonly ModelMessage< | null>[]; ``` -Defined in: [activities/chat/middleware/types.ts:91](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L91) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:91](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L91) Current messages array (read-only view) @@ -197,7 +197,7 @@ Current messages array (read-only view) model: string; ``` -Defined in: [activities/chat/middleware/types.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L57) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L57) Model identifier (e.g., 'gpt-4o') @@ -209,7 +209,7 @@ Model identifier (e.g., 'gpt-4o') optional modelOptions: Record; ``` -Defined in: [activities/chat/middleware/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L72) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L72) Provider-specific model options @@ -221,7 +221,7 @@ Provider-specific model options optional options: Record; ``` -Defined in: [activities/chat/middleware/types.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L70) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L70) Flattened generation options (temperature, topP, maxTokens, metadata) @@ -233,7 +233,7 @@ Flattened generation options (temperature, topP, maxTokens, metadata) phase: ChatMiddlewarePhase; ``` -Defined in: [activities/chat/middleware/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L34) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L34) Current lifecycle phase @@ -245,7 +245,7 @@ Current lifecycle phase provider: string; ``` -Defined in: [activities/chat/middleware/types.ts:55](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L55) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:55](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L55) Provider name (e.g., 'openai', 'anthropic') @@ -257,7 +257,7 @@ Provider name (e.g., 'openai', 'anthropic') requestId: string; ``` -Defined in: [activities/chat/middleware/types.ts:28](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L28) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:28](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L28) Unique identifier for this chat request @@ -269,7 +269,7 @@ Unique identifier for this chat request optional signal: AbortSignal; ``` -Defined in: [activities/chat/middleware/types.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L40) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L40) Abort signal from the chat request @@ -281,7 +281,7 @@ Abort signal from the chat request source: "client" | "server"; ``` -Defined in: [activities/chat/middleware/types.ts:59](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L59) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:59](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L59) Source of the chat invocation — always 'server' for server-side chat @@ -293,7 +293,7 @@ Source of the chat invocation — always 'server' for server-side chat streamId: string; ``` -Defined in: [activities/chat/middleware/types.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L30) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L30) Unique identifier for this stream @@ -305,7 +305,7 @@ Unique identifier for this stream streaming: boolean; ``` -Defined in: [activities/chat/middleware/types.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L61) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L61) Whether the chat is streaming @@ -317,7 +317,7 @@ Whether the chat is streaming systemPrompts: string[]; ``` -Defined in: [activities/chat/middleware/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L66) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L66) System prompts configured for this chat @@ -329,6 +329,6 @@ System prompts configured for this chat optional toolNames: string[]; ``` -Defined in: [activities/chat/middleware/types.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L68) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L68) Names of configured tools, if any diff --git a/docs/reference/interfaces/ChunkRecording.md b/docs/reference/interfaces/ChunkRecording.md index 198d174dc5..3deb313102 100644 --- a/docs/reference/interfaces/ChunkRecording.md +++ b/docs/reference/interfaces/ChunkRecording.md @@ -5,7 +5,7 @@ title: ChunkRecording # Interface: ChunkRecording -Defined in: [activities/chat/stream/types.ts:91](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L91) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:92](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L92) Recording format for replay testing @@ -17,7 +17,7 @@ Recording format for replay testing chunks: object[]; ``` -Defined in: [activities/chat/stream/types.ts:96](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L96) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:97](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L97) #### chunk @@ -45,7 +45,7 @@ timestamp: number; optional model: string; ``` -Defined in: [activities/chat/stream/types.ts:94](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L94) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:95](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L95) *** @@ -55,7 +55,7 @@ Defined in: [activities/chat/stream/types.ts:94](https://github.com/TanStack/ai/ optional provider: string; ``` -Defined in: [activities/chat/stream/types.ts:95](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L95) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:96](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L96) *** @@ -65,7 +65,7 @@ Defined in: [activities/chat/stream/types.ts:95](https://github.com/TanStack/ai/ optional result: ProcessorResult; ``` -Defined in: [activities/chat/stream/types.ts:101](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L101) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:102](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L102) *** @@ -75,7 +75,7 @@ Defined in: [activities/chat/stream/types.ts:101](https://github.com/TanStack/ai timestamp: number; ``` -Defined in: [activities/chat/stream/types.ts:93](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L93) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:94](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L94) *** @@ -85,4 +85,4 @@ Defined in: [activities/chat/stream/types.ts:93](https://github.com/TanStack/ai/ version: "1.0"; ``` -Defined in: [activities/chat/stream/types.ts:92](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L92) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:93](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L93) diff --git a/docs/reference/interfaces/ChunkStrategy.md b/docs/reference/interfaces/ChunkStrategy.md index a6652233d7..f06570ec76 100644 --- a/docs/reference/interfaces/ChunkStrategy.md +++ b/docs/reference/interfaces/ChunkStrategy.md @@ -5,7 +5,7 @@ title: ChunkStrategy # Interface: ChunkStrategy -Defined in: [activities/chat/stream/types.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L33) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L33) Strategy for determining when to emit text updates @@ -17,7 +17,7 @@ Strategy for determining when to emit text updates optional reset: () => void; ``` -Defined in: [activities/chat/stream/types.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L45) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L45) Optional: Reset strategy state (called when streaming starts) @@ -33,7 +33,7 @@ Optional: Reset strategy state (called when streaming starts) shouldEmit: (chunk, accumulated) => boolean; ``` -Defined in: [activities/chat/stream/types.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L40) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L40) Called for each text chunk received diff --git a/docs/reference/interfaces/ClientTool.md b/docs/reference/interfaces/ClientTool.md index 6f5839d209..404b5850b5 100644 --- a/docs/reference/interfaces/ClientTool.md +++ b/docs/reference/interfaces/ClientTool.md @@ -5,7 +5,7 @@ title: ClientTool # Interface: ClientTool\ -Defined in: [activities/chat/tools/tool-definition.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L24) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L24) Marker type for client-side tools @@ -31,7 +31,7 @@ Marker type for client-side tools __toolSide: "client"; ``` -Defined in: [activities/chat/tools/tool-definition.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L29) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L29) *** @@ -41,7 +41,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:29](https://github.com/Tan description: string; ``` -Defined in: [activities/chat/tools/tool-definition.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L31) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L31) *** @@ -53,7 +53,7 @@ optional execute: (args) => | Promise>; ``` -Defined in: [activities/chat/tools/tool-definition.ts:37](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L37) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:37](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L37) #### Parameters @@ -74,7 +74,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:37](https://github.com/Tan optional inputSchema: TInput; ``` -Defined in: [activities/chat/tools/tool-definition.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L32) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L32) *** @@ -84,7 +84,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:32](https://github.com/Tan optional lazy: boolean; ``` -Defined in: [activities/chat/tools/tool-definition.ts:35](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L35) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:35](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L35) *** @@ -94,7 +94,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:35](https://github.com/Tan optional metadata: Record; ``` -Defined in: [activities/chat/tools/tool-definition.ts:36](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L36) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:36](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L36) *** @@ -104,7 +104,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:36](https://github.com/Tan name: TName; ``` -Defined in: [activities/chat/tools/tool-definition.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L30) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L30) *** @@ -114,7 +114,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:30](https://github.com/Tan optional needsApproval: boolean; ``` -Defined in: [activities/chat/tools/tool-definition.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L34) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L34) *** @@ -124,4 +124,4 @@ Defined in: [activities/chat/tools/tool-definition.ts:34](https://github.com/Tan optional outputSchema: TOutput; ``` -Defined in: [activities/chat/tools/tool-definition.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L33) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L33) diff --git a/docs/reference/interfaces/ContentPartDataSource.md b/docs/reference/interfaces/ContentPartDataSource.md index bb275cef28..f56a29cbb2 100644 --- a/docs/reference/interfaces/ContentPartDataSource.md +++ b/docs/reference/interfaces/ContentPartDataSource.md @@ -5,7 +5,7 @@ title: ContentPartDataSource # Interface: ContentPartDataSource -Defined in: [types.ts:116](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L116) +Defined in: [packages/typescript/ai/src/types.ts:143](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L143) Source specification for inline data content (base64). Requires a mimeType to ensure providers receive proper content type information. @@ -18,7 +18,7 @@ Requires a mimeType to ensure providers receive proper content type information. mimeType: string; ``` -Defined in: [types.ts:129](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L129) +Defined in: [packages/typescript/ai/src/types.ts:156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L156) The MIME type of the content (e.g., 'image/png', 'audio/wav'). Required for data sources to ensure proper handling by providers. @@ -31,7 +31,7 @@ Required for data sources to ensure proper handling by providers. type: "data"; ``` -Defined in: [types.ts:120](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L120) +Defined in: [packages/typescript/ai/src/types.ts:147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L147) Indicates this is inline data content. @@ -43,6 +43,6 @@ Indicates this is inline data content. value: string; ``` -Defined in: [types.ts:124](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L124) +Defined in: [packages/typescript/ai/src/types.ts:151](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L151) The base64-encoded content value. diff --git a/docs/reference/interfaces/ContentPartUrlSource.md b/docs/reference/interfaces/ContentPartUrlSource.md index 1f8dc4e8ff..1c88477775 100644 --- a/docs/reference/interfaces/ContentPartUrlSource.md +++ b/docs/reference/interfaces/ContentPartUrlSource.md @@ -5,7 +5,7 @@ title: ContentPartUrlSource # Interface: ContentPartUrlSource -Defined in: [types.ts:136](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L136) +Defined in: [packages/typescript/ai/src/types.ts:163](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L163) Source specification for URL-based content. mimeType is optional as it can often be inferred from the URL or response headers. @@ -18,7 +18,7 @@ mimeType is optional as it can often be inferred from the URL or response header optional mimeType: string; ``` -Defined in: [types.ts:148](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L148) +Defined in: [packages/typescript/ai/src/types.ts:175](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L175) Optional MIME type hint for cases where providers can't infer it from the URL. @@ -30,7 +30,7 @@ Optional MIME type hint for cases where providers can't infer it from the URL. type: "url"; ``` -Defined in: [types.ts:140](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L140) +Defined in: [packages/typescript/ai/src/types.ts:167](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L167) Indicates this is URL-referenced content. @@ -42,6 +42,6 @@ Indicates this is URL-referenced content. value: string; ``` -Defined in: [types.ts:144](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L144) +Defined in: [packages/typescript/ai/src/types.ts:171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L171) HTTP(S) URL or data URI pointing to the content. diff --git a/docs/reference/interfaces/CustomEvent.md b/docs/reference/interfaces/CustomEvent.md index 799044a376..1b213a7a84 100644 --- a/docs/reference/interfaces/CustomEvent.md +++ b/docs/reference/interfaces/CustomEvent.md @@ -5,94 +5,31 @@ title: CustomEvent # Interface: CustomEvent -Defined in: [types.ts:944](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L944) +Defined in: [packages/typescript/ai/src/types.ts:1042](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1042) Custom event for extensibility. -## Extends - -- [`BaseAGUIEvent`](BaseAGUIEvent.md) - -## Properties - -### model? - -```ts -optional model: string; -``` - -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) - -Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### name - -```ts -name: string; -``` - -Defined in: [types.ts:947](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L947) - -Custom event name - -*** +@ag-ui/core provides: `name`, `value` +TanStack AI adds: `model?` -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) +## Extends -*** +- `CustomEvent` -### type +## Indexable ```ts -type: "CUSTOM"; +[k: string]: unknown ``` -Defined in: [types.ts:945](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L945) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) - -*** +## Properties -### value? +### model? ```ts -optional value: unknown; +optional model: string; ``` -Defined in: [types.ts:949](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L949) +Defined in: [packages/typescript/ai/src/types.ts:1044](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1044) -Custom event value +Model identifier for multi-model support diff --git a/docs/reference/interfaces/DebugCategories.md b/docs/reference/interfaces/DebugCategories.md new file mode 100644 index 0000000000..4cc4612796 --- /dev/null +++ b/docs/reference/interfaces/DebugCategories.md @@ -0,0 +1,110 @@ +--- +id: DebugCategories +title: DebugCategories +--- + +# Interface: DebugCategories + +Defined in: [packages/typescript/ai/src/logger/types.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L30) + +Per-category toggles for debug logging. Each flag enables or disables one class of log message. Unspecified flags default to `true` when `DebugConfig` is partially specified; `undefined` on the `debug` option defaults all flags to `false` except `errors`. + +## Extended by + +- [`DebugConfig`](DebugConfig.md) + +## Properties + +### agentLoop? + +```ts +optional agentLoop: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L50) + +Iteration markers and phase transitions in the chat agent loop. Chat-only. + +*** + +### config? + +```ts +optional config: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L54) + +Config transforms returned by middleware `onConfig` hooks. Chat-only. + +*** + +### errors? + +```ts +optional errors: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L58) + +Caught errors throughout the pipeline. Unlike other categories, defaults to `true` even when `debug` is unspecified. Explicitly set `errors: false` or `debug: false` to silence. + +*** + +### middleware? + +```ts +optional middleware: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L42) + +Inputs and outputs around each middleware hook invocation. Chat-only. + +*** + +### output? + +```ts +optional output: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L38) + +Chunks/results yielded to the consumer after all middleware. For streaming activities this fires per chunk; for non-streaming activities it fires once per result. + +*** + +### provider? + +```ts +optional provider: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L34) + +Raw chunks/frames received from a provider SDK (OpenAI, Anthropic, Gemini, Ollama, Grok, Groq, OpenRouter, fal, ElevenLabs). Emitted inside every streaming adapter's chunk loop. + +*** + +### request? + +```ts +optional request: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L62) + +Outgoing call metadata (provider, model, message/tool counts) emitted before each adapter SDK call. + +*** + +### tools? + +```ts +optional tools: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L46) + +Before/after tool-call execution in the chat agent loop. Chat-only. diff --git a/docs/reference/interfaces/DebugConfig.md b/docs/reference/interfaces/DebugConfig.md new file mode 100644 index 0000000000..1bfd337ef1 --- /dev/null +++ b/docs/reference/interfaces/DebugConfig.md @@ -0,0 +1,154 @@ +--- +id: DebugConfig +title: DebugConfig +--- + +# Interface: DebugConfig + +Defined in: [packages/typescript/ai/src/logger/types.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L68) + +Granular debug configuration combining per-category toggles with an optional custom logger. Any unspecified category flag defaults to `true`. + +## Extends + +- [`DebugCategories`](DebugCategories.md) + +## Properties + +### agentLoop? + +```ts +optional agentLoop: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L50) + +Iteration markers and phase transitions in the chat agent loop. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`agentLoop`](DebugCategories.md#agentloop) + +*** + +### config? + +```ts +optional config: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L54) + +Config transforms returned by middleware `onConfig` hooks. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`config`](DebugCategories.md#config) + +*** + +### errors? + +```ts +optional errors: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L58) + +Caught errors throughout the pipeline. Unlike other categories, defaults to `true` even when `debug` is unspecified. Explicitly set `errors: false` or `debug: false` to silence. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`errors`](DebugCategories.md#errors) + +*** + +### logger? + +```ts +optional logger: Logger; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L72) + +Custom `Logger` implementation. When omitted, a default `ConsoleLogger` routes output to `console.debug`/`info`/`warn`/`error`. + +*** + +### middleware? + +```ts +optional middleware: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L42) + +Inputs and outputs around each middleware hook invocation. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`middleware`](DebugCategories.md#middleware) + +*** + +### output? + +```ts +optional output: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L38) + +Chunks/results yielded to the consumer after all middleware. For streaming activities this fires per chunk; for non-streaming activities it fires once per result. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`output`](DebugCategories.md#output) + +*** + +### provider? + +```ts +optional provider: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L34) + +Raw chunks/frames received from a provider SDK (OpenAI, Anthropic, Gemini, Ollama, Grok, Groq, OpenRouter, fal, ElevenLabs). Emitted inside every streaming adapter's chunk loop. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`provider`](DebugCategories.md#provider) + +*** + +### request? + +```ts +optional request: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L62) + +Outgoing call metadata (provider, model, message/tool counts) emitted before each adapter SDK call. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`request`](DebugCategories.md#request) + +*** + +### tools? + +```ts +optional tools: boolean; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L46) + +Before/after tool-call execution in the chat agent loop. Chat-only. + +#### Inherited from + +[`DebugCategories`](DebugCategories.md).[`tools`](DebugCategories.md#tools) diff --git a/docs/reference/interfaces/DefaultMessageMetadataByModality.md b/docs/reference/interfaces/DefaultMessageMetadataByModality.md index 3463c74902..e892dd82ed 100644 --- a/docs/reference/interfaces/DefaultMessageMetadataByModality.md +++ b/docs/reference/interfaces/DefaultMessageMetadataByModality.md @@ -5,7 +5,7 @@ title: DefaultMessageMetadataByModality # Interface: DefaultMessageMetadataByModality -Defined in: [types.ts:1254](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1254) +Defined in: [packages/typescript/ai/src/types.ts:1526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1526) Default metadata type for adapters that don't define custom metadata. Uses unknown for all modalities. @@ -18,7 +18,7 @@ Uses unknown for all modalities. audio: unknown; ``` -Defined in: [types.ts:1257](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1257) +Defined in: [packages/typescript/ai/src/types.ts:1529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1529) *** @@ -28,7 +28,7 @@ Defined in: [types.ts:1257](https://github.com/TanStack/ai/blob/main/packages/ty document: unknown; ``` -Defined in: [types.ts:1259](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1259) +Defined in: [packages/typescript/ai/src/types.ts:1531](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1531) *** @@ -38,7 +38,7 @@ Defined in: [types.ts:1259](https://github.com/TanStack/ai/blob/main/packages/ty image: unknown; ``` -Defined in: [types.ts:1256](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1256) +Defined in: [packages/typescript/ai/src/types.ts:1528](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1528) *** @@ -48,7 +48,7 @@ Defined in: [types.ts:1256](https://github.com/TanStack/ai/blob/main/packages/ty text: unknown; ``` -Defined in: [types.ts:1255](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1255) +Defined in: [packages/typescript/ai/src/types.ts:1527](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1527) *** @@ -58,4 +58,4 @@ Defined in: [types.ts:1255](https://github.com/TanStack/ai/blob/main/packages/ty video: unknown; ``` -Defined in: [types.ts:1258](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1258) +Defined in: [packages/typescript/ai/src/types.ts:1530](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1530) diff --git a/docs/reference/interfaces/DocumentPart.md b/docs/reference/interfaces/DocumentPart.md index 82bccade98..040f058af4 100644 --- a/docs/reference/interfaces/DocumentPart.md +++ b/docs/reference/interfaces/DocumentPart.md @@ -5,7 +5,7 @@ title: DocumentPart # Interface: DocumentPart\ -Defined in: [types.ts:199](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L199) +Defined in: [packages/typescript/ai/src/types.ts:226](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L226) Document content part for multimodal messages (e.g., PDFs). @@ -25,7 +25,7 @@ Provider-specific metadata type (e.g., Anthropic's media_type) optional metadata: TMetadata; ``` -Defined in: [types.ts:204](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L204) +Defined in: [packages/typescript/ai/src/types.ts:231](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L231) Provider-specific metadata (e.g., media_type for PDFs) @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., media_type for PDFs) source: ContentPartSource; ``` -Defined in: [types.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L202) +Defined in: [packages/typescript/ai/src/types.ts:229](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L229) Source of the document content @@ -49,4 +49,4 @@ Source of the document content type: "document"; ``` -Defined in: [types.ts:200](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L200) +Defined in: [packages/typescript/ai/src/types.ts:227](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L227) diff --git a/docs/reference/interfaces/ErrorInfo.md b/docs/reference/interfaces/ErrorInfo.md index b497142f97..73cd2fc8f1 100644 --- a/docs/reference/interfaces/ErrorInfo.md +++ b/docs/reference/interfaces/ErrorInfo.md @@ -5,7 +5,7 @@ title: ErrorInfo # Interface: ErrorInfo -Defined in: [activities/chat/middleware/types.ts:268](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L268) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:268](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L268) Information passed to onError. @@ -17,7 +17,7 @@ Information passed to onError. duration: number; ``` -Defined in: [activities/chat/middleware/types.ts:272](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L272) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:272](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L272) Duration until error in milliseconds @@ -29,6 +29,6 @@ Duration until error in milliseconds error: unknown; ``` -Defined in: [activities/chat/middleware/types.ts:270](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L270) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:270](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L270) The error that caused the failure diff --git a/docs/reference/interfaces/ExtendedModelDef.md b/docs/reference/interfaces/ExtendedModelDef.md index 2c837ef36f..2d197faa51 100644 --- a/docs/reference/interfaces/ExtendedModelDef.md +++ b/docs/reference/interfaces/ExtendedModelDef.md @@ -5,7 +5,7 @@ title: ExtendedModelDef # Interface: ExtendedModelDef\ -Defined in: [extend-adapter.ts:21](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L21) +Defined in: [packages/typescript/ai/src/extend-adapter.ts:21](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L21) Definition for a custom model to add to an adapter. @@ -45,7 +45,7 @@ Provider options type for this model input: TInput; ``` -Defined in: [extend-adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L29) +Defined in: [packages/typescript/ai/src/extend-adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L29) Supported input modalities for this model @@ -57,7 +57,7 @@ Supported input modalities for this model modelOptions: TOptions; ``` -Defined in: [extend-adapter.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L31) +Defined in: [packages/typescript/ai/src/extend-adapter.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L31) Type brand for provider options - use `{} as YourOptionsType` @@ -69,6 +69,6 @@ Type brand for provider options - use `{} as YourOptionsType` name: TName; ``` -Defined in: [extend-adapter.ts:27](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L27) +Defined in: [packages/typescript/ai/src/extend-adapter.ts:27](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/extend-adapter.ts#L27) The model name identifier diff --git a/docs/reference/interfaces/FinishInfo.md b/docs/reference/interfaces/FinishInfo.md index a4bd76a60a..cd000f75c3 100644 --- a/docs/reference/interfaces/FinishInfo.md +++ b/docs/reference/interfaces/FinishInfo.md @@ -5,7 +5,7 @@ title: FinishInfo # Interface: FinishInfo -Defined in: [activities/chat/middleware/types.ts:240](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L240) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:240](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L240) Information passed to onFinish. @@ -17,7 +17,7 @@ Information passed to onFinish. content: string; ``` -Defined in: [activities/chat/middleware/types.ts:246](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L246) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:246](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L246) Final accumulated text content @@ -29,7 +29,7 @@ Final accumulated text content duration: number; ``` -Defined in: [activities/chat/middleware/types.ts:244](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L244) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:244](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L244) Total duration of the chat run in milliseconds @@ -41,7 +41,7 @@ Total duration of the chat run in milliseconds finishReason: string | null; ``` -Defined in: [activities/chat/middleware/types.ts:242](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L242) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:242](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L242) The finish reason from the last model response @@ -53,7 +53,7 @@ The finish reason from the last model response optional usage: object; ``` -Defined in: [activities/chat/middleware/types.ts:248](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L248) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:248](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L248) Final usage totals, if available diff --git a/docs/reference/interfaces/GeneratedImage.md b/docs/reference/interfaces/GeneratedImage.md deleted file mode 100644 index fc85fdcc03..0000000000 --- a/docs/reference/interfaces/GeneratedImage.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -id: GeneratedImage -title: GeneratedImage ---- - -# Interface: GeneratedImage - -Defined in: [types.ts:1039](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1039) - -A single generated image - -## Properties - -### b64Json? - -```ts -optional b64Json: string; -``` - -Defined in: [types.ts:1041](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1041) - -Base64-encoded image data - -*** - -### revisedPrompt? - -```ts -optional revisedPrompt: string; -``` - -Defined in: [types.ts:1045](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1045) - -Revised prompt used by the model (if applicable) - -*** - -### url? - -```ts -optional url: string; -``` - -Defined in: [types.ts:1043](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1043) - -URL to the generated image (may be temporary) diff --git a/docs/reference/interfaces/ImageAdapter.md b/docs/reference/interfaces/ImageAdapter.md index 762fa78986..c2e49e1f80 100644 --- a/docs/reference/interfaces/ImageAdapter.md +++ b/docs/reference/interfaces/ImageAdapter.md @@ -5,7 +5,7 @@ title: ImageAdapter # Interface: ImageAdapter\ -Defined in: [activities/generateImage/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L33) +Defined in: [packages/typescript/ai/src/activities/generateImage/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L33) Image adapter interface with pre-resolved generics. @@ -44,7 +44,7 @@ Generic parameters: ~types: object; ``` -Defined in: [activities/generateImage/adapter.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L49) +Defined in: [packages/typescript/ai/src/activities/generateImage/adapter.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L49) **`Internal`** @@ -76,7 +76,7 @@ providerOptions: TProviderOptions; generateImages: (options) => Promise; ``` -Defined in: [activities/generateImage/adapter.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L58) +Defined in: [packages/typescript/ai/src/activities/generateImage/adapter.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L58) Generate images from a prompt @@ -98,7 +98,7 @@ Generate images from a prompt readonly kind: "image"; ``` -Defined in: [activities/generateImage/adapter.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L40) +Defined in: [packages/typescript/ai/src/activities/generateImage/adapter.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L40) Discriminator for adapter kind - used by generate() to determine API shape @@ -110,7 +110,7 @@ Discriminator for adapter kind - used by generate() to determine API shape readonly model: TModel; ``` -Defined in: [activities/generateImage/adapter.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L44) +Defined in: [packages/typescript/ai/src/activities/generateImage/adapter.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L44) The model this adapter is configured for @@ -122,6 +122,6 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [activities/generateImage/adapter.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L42) +Defined in: [packages/typescript/ai/src/activities/generateImage/adapter.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L42) Adapter name identifier diff --git a/docs/reference/interfaces/ImageGenerationOptions.md b/docs/reference/interfaces/ImageGenerationOptions.md index d532ccc4bb..b7dca106b3 100644 --- a/docs/reference/interfaces/ImageGenerationOptions.md +++ b/docs/reference/interfaces/ImageGenerationOptions.md @@ -5,7 +5,7 @@ title: ImageGenerationOptions # Interface: ImageGenerationOptions\ -Defined in: [types.ts:1020](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1020) +Defined in: [packages/typescript/ai/src/types.ts:1201](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1201) Options for image generation. These are the common options supported across providers. @@ -22,13 +22,26 @@ These are the common options supported across providers. ## Properties +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1219](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1219) + +Internal logger threaded from the generateImage() entry point. Adapters must +call logger.request() before the SDK call and logger.errors() in catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [types.ts:1025](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1025) +Defined in: [packages/typescript/ai/src/types.ts:1206](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1206) The model to use for image generation @@ -40,7 +53,7 @@ The model to use for image generation optional modelOptions: TProviderOptions; ``` -Defined in: [types.ts:1033](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1033) +Defined in: [packages/typescript/ai/src/types.ts:1214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1214) Model-specific options for image generation @@ -52,7 +65,7 @@ Model-specific options for image generation optional numberOfImages: number; ``` -Defined in: [types.ts:1029](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1029) +Defined in: [packages/typescript/ai/src/types.ts:1210](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1210) Number of images to generate (default: 1) @@ -64,7 +77,7 @@ Number of images to generate (default: 1) prompt: string; ``` -Defined in: [types.ts:1027](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1027) +Defined in: [packages/typescript/ai/src/types.ts:1208](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1208) Text description of the desired image(s) @@ -76,6 +89,6 @@ Text description of the desired image(s) optional size: TSize; ``` -Defined in: [types.ts:1031](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1031) +Defined in: [packages/typescript/ai/src/types.ts:1212](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1212) Image size in WIDTHxHEIGHT format (e.g., "1024x1024") diff --git a/docs/reference/interfaces/ImageGenerationResult.md b/docs/reference/interfaces/ImageGenerationResult.md index 3866823dde..d64881043e 100644 --- a/docs/reference/interfaces/ImageGenerationResult.md +++ b/docs/reference/interfaces/ImageGenerationResult.md @@ -5,7 +5,7 @@ title: ImageGenerationResult # Interface: ImageGenerationResult -Defined in: [types.ts:1051](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1051) +Defined in: [packages/typescript/ai/src/types.ts:1251](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1251) Result of image generation @@ -17,7 +17,7 @@ Result of image generation id: string; ``` -Defined in: [types.ts:1053](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1053) +Defined in: [packages/typescript/ai/src/types.ts:1253](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1253) Unique identifier for the generation @@ -29,7 +29,7 @@ Unique identifier for the generation images: GeneratedImage[]; ``` -Defined in: [types.ts:1057](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1057) +Defined in: [packages/typescript/ai/src/types.ts:1257](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1257) Array of generated images @@ -41,7 +41,7 @@ Array of generated images model: string; ``` -Defined in: [types.ts:1055](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1055) +Defined in: [packages/typescript/ai/src/types.ts:1255](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1255) Model used for generation @@ -53,7 +53,7 @@ Model used for generation optional usage: object; ``` -Defined in: [types.ts:1059](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1059) +Defined in: [packages/typescript/ai/src/types.ts:1259](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1259) Token usage information (if available) diff --git a/docs/reference/interfaces/ImagePart.md b/docs/reference/interfaces/ImagePart.md index 6ac2413103..1cf7f928be 100644 --- a/docs/reference/interfaces/ImagePart.md +++ b/docs/reference/interfaces/ImagePart.md @@ -5,7 +5,7 @@ title: ImagePart # Interface: ImagePart\ -Defined in: [types.ts:163](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L163) +Defined in: [packages/typescript/ai/src/types.ts:190](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L190) Image content part for multimodal messages. @@ -25,7 +25,7 @@ Provider-specific metadata type (e.g., OpenAI's detail level) optional metadata: TMetadata; ``` -Defined in: [types.ts:168](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L168) +Defined in: [packages/typescript/ai/src/types.ts:195](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L195) Provider-specific metadata (e.g., OpenAI's detail: 'auto' | 'low' | 'high') @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., OpenAI's detail: 'auto' | 'low' | 'high') source: ContentPartSource; ``` -Defined in: [types.ts:166](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L166) +Defined in: [packages/typescript/ai/src/types.ts:193](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L193) Source of the image content @@ -49,4 +49,4 @@ Source of the image content type: "image"; ``` -Defined in: [types.ts:164](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L164) +Defined in: [packages/typescript/ai/src/types.ts:191](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L191) diff --git a/docs/reference/interfaces/InternalToolCallState.md b/docs/reference/interfaces/InternalToolCallState.md index 2f8e501485..909e64b32b 100644 --- a/docs/reference/interfaces/InternalToolCallState.md +++ b/docs/reference/interfaces/InternalToolCallState.md @@ -5,7 +5,7 @@ title: InternalToolCallState # Interface: InternalToolCallState -Defined in: [activities/chat/stream/types.ts:21](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L21) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:21](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L21) Internal state for a tool call being tracked @@ -17,7 +17,7 @@ Internal state for a tool call being tracked arguments: string; ``` -Defined in: [activities/chat/stream/types.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L24) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L24) *** @@ -27,7 +27,7 @@ Defined in: [activities/chat/stream/types.ts:24](https://github.com/TanStack/ai/ id: string; ``` -Defined in: [activities/chat/stream/types.ts:22](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L22) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:22](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L22) *** @@ -37,7 +37,7 @@ Defined in: [activities/chat/stream/types.ts:22](https://github.com/TanStack/ai/ index: number; ``` -Defined in: [activities/chat/stream/types.ts:27](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L27) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:27](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L27) *** @@ -47,7 +47,7 @@ Defined in: [activities/chat/stream/types.ts:27](https://github.com/TanStack/ai/ name: string; ``` -Defined in: [activities/chat/stream/types.ts:23](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L23) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:23](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L23) *** @@ -57,7 +57,7 @@ Defined in: [activities/chat/stream/types.ts:23](https://github.com/TanStack/ai/ optional parsedArguments: any; ``` -Defined in: [activities/chat/stream/types.ts:26](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L26) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:26](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L26) *** @@ -67,4 +67,4 @@ Defined in: [activities/chat/stream/types.ts:26](https://github.com/TanStack/ai/ state: ToolCallState; ``` -Defined in: [activities/chat/stream/types.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L25) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L25) diff --git a/docs/reference/interfaces/IterationInfo.md b/docs/reference/interfaces/IterationInfo.md index 589b9da7b0..dee9ebb80a 100644 --- a/docs/reference/interfaces/IterationInfo.md +++ b/docs/reference/interfaces/IterationInfo.md @@ -5,7 +5,7 @@ title: IterationInfo # Interface: IterationInfo -Defined in: [activities/chat/middleware/types.ts:179](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L179) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:179](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L179) Information passed to onIteration at the start of each agent loop iteration. @@ -17,7 +17,7 @@ Information passed to onIteration at the start of each agent loop iteration. iteration: number; ``` -Defined in: [activities/chat/middleware/types.ts:181](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L181) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:181](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L181) 0-based iteration index @@ -29,6 +29,6 @@ Defined in: [activities/chat/middleware/types.ts:181](https://github.com/TanStac messageId: string; ``` -Defined in: [activities/chat/middleware/types.ts:183](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L183) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:183](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L183) The assistant message ID created for this iteration diff --git a/docs/reference/interfaces/JSONParser.md b/docs/reference/interfaces/JSONParser.md index b0b665af9b..1cb7a7f902 100644 --- a/docs/reference/interfaces/JSONParser.md +++ b/docs/reference/interfaces/JSONParser.md @@ -5,7 +5,7 @@ title: JSONParser # Interface: JSONParser -Defined in: [activities/chat/stream/json-parser.ts:12](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L12) +Defined in: [packages/typescript/ai/src/activities/chat/stream/json-parser.ts:12](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L12) JSON Parser interface - allows for custom parser implementations @@ -17,7 +17,7 @@ JSON Parser interface - allows for custom parser implementations parse: (jsonString) => any; ``` -Defined in: [activities/chat/stream/json-parser.ts:18](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L18) +Defined in: [packages/typescript/ai/src/activities/chat/stream/json-parser.ts:18](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L18) Parse a JSON string (may be incomplete/partial) diff --git a/docs/reference/interfaces/JSONSchema.md b/docs/reference/interfaces/JSONSchema.md index 096b771788..23072a6677 100644 --- a/docs/reference/interfaces/JSONSchema.md +++ b/docs/reference/interfaces/JSONSchema.md @@ -5,7 +5,7 @@ title: JSONSchema # Interface: JSONSchema -Defined in: [types.ts:25](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L25) +Defined in: [packages/typescript/ai/src/types.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L52) JSON Schema type for defining tool input/output schemas as raw JSON Schema objects. This allows tools to be defined without schema libraries when you have JSON Schema definitions available. @@ -24,7 +24,7 @@ This allows tools to be defined without schema libraries when you have JSON Sche optional $defs: Record; ``` -Defined in: [types.ts:35](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L35) +Defined in: [packages/typescript/ai/src/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L62) *** @@ -34,7 +34,7 @@ Defined in: [types.ts:35](https://github.com/TanStack/ai/blob/main/packages/type optional $ref: string; ``` -Defined in: [types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L34) +Defined in: [packages/typescript/ai/src/types.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L61) *** @@ -44,7 +44,7 @@ Defined in: [types.ts:34](https://github.com/TanStack/ai/blob/main/packages/type optional additionalItems: boolean | JSONSchema; ``` -Defined in: [types.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L56) +Defined in: [packages/typescript/ai/src/types.ts:83](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L83) *** @@ -54,7 +54,7 @@ Defined in: [types.ts:56](https://github.com/TanStack/ai/blob/main/packages/type optional additionalProperties: boolean | JSONSchema; ``` -Defined in: [types.ts:55](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L55) +Defined in: [packages/typescript/ai/src/types.ts:82](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L82) *** @@ -64,7 +64,7 @@ Defined in: [types.ts:55](https://github.com/TanStack/ai/blob/main/packages/type optional allOf: JSONSchema[]; ``` -Defined in: [types.ts:37](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L37) +Defined in: [packages/typescript/ai/src/types.ts:64](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L64) *** @@ -74,7 +74,7 @@ Defined in: [types.ts:37](https://github.com/TanStack/ai/blob/main/packages/type optional anyOf: JSONSchema[]; ``` -Defined in: [types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L38) +Defined in: [packages/typescript/ai/src/types.ts:65](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L65) *** @@ -84,7 +84,7 @@ Defined in: [types.ts:38](https://github.com/TanStack/ai/blob/main/packages/type optional const: unknown; ``` -Defined in: [types.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L31) +Defined in: [packages/typescript/ai/src/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L58) *** @@ -94,7 +94,7 @@ Defined in: [types.ts:31](https://github.com/TanStack/ai/blob/main/packages/type optional default: unknown; ``` -Defined in: [types.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L33) +Defined in: [packages/typescript/ai/src/types.ts:60](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L60) *** @@ -104,7 +104,7 @@ Defined in: [types.ts:33](https://github.com/TanStack/ai/blob/main/packages/type optional definitions: Record; ``` -Defined in: [types.ts:36](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L36) +Defined in: [packages/typescript/ai/src/types.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L63) *** @@ -114,7 +114,7 @@ Defined in: [types.ts:36](https://github.com/TanStack/ai/blob/main/packages/type optional description: string; ``` -Defined in: [types.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L32) +Defined in: [packages/typescript/ai/src/types.ts:59](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L59) *** @@ -124,7 +124,7 @@ Defined in: [types.ts:32](https://github.com/TanStack/ai/blob/main/packages/type optional else: JSONSchema; ``` -Defined in: [types.ts:43](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L43) +Defined in: [packages/typescript/ai/src/types.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L70) *** @@ -134,7 +134,7 @@ Defined in: [types.ts:43](https://github.com/TanStack/ai/blob/main/packages/type optional enum: unknown[]; ``` -Defined in: [types.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L30) +Defined in: [packages/typescript/ai/src/types.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L57) *** @@ -144,7 +144,7 @@ Defined in: [types.ts:30](https://github.com/TanStack/ai/blob/main/packages/type optional examples: unknown[]; ``` -Defined in: [types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L62) +Defined in: [packages/typescript/ai/src/types.ts:89](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L89) *** @@ -154,7 +154,7 @@ Defined in: [types.ts:62](https://github.com/TanStack/ai/blob/main/packages/type optional exclusiveMaximum: number; ``` -Defined in: [types.ts:47](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L47) +Defined in: [packages/typescript/ai/src/types.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L74) *** @@ -164,7 +164,7 @@ Defined in: [types.ts:47](https://github.com/TanStack/ai/blob/main/packages/type optional exclusiveMinimum: number; ``` -Defined in: [types.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L46) +Defined in: [packages/typescript/ai/src/types.ts:73](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L73) *** @@ -174,7 +174,7 @@ Defined in: [types.ts:46](https://github.com/TanStack/ai/blob/main/packages/type optional format: string; ``` -Defined in: [types.ts:51](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L51) +Defined in: [packages/typescript/ai/src/types.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L78) *** @@ -184,7 +184,7 @@ Defined in: [types.ts:51](https://github.com/TanStack/ai/blob/main/packages/type optional if: JSONSchema; ``` -Defined in: [types.ts:41](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L41) +Defined in: [packages/typescript/ai/src/types.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L68) *** @@ -194,7 +194,7 @@ Defined in: [types.ts:41](https://github.com/TanStack/ai/blob/main/packages/type optional items: JSONSchema | JSONSchema[]; ``` -Defined in: [types.ts:28](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L28) +Defined in: [packages/typescript/ai/src/types.ts:55](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L55) *** @@ -204,7 +204,7 @@ Defined in: [types.ts:28](https://github.com/TanStack/ai/blob/main/packages/type optional maximum: number; ``` -Defined in: [types.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L45) +Defined in: [packages/typescript/ai/src/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L72) *** @@ -214,7 +214,7 @@ Defined in: [types.ts:45](https://github.com/TanStack/ai/blob/main/packages/type optional maxItems: number; ``` -Defined in: [types.ts:53](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L53) +Defined in: [packages/typescript/ai/src/types.ts:80](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L80) *** @@ -224,7 +224,7 @@ Defined in: [types.ts:53](https://github.com/TanStack/ai/blob/main/packages/type optional maxLength: number; ``` -Defined in: [types.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L49) +Defined in: [packages/typescript/ai/src/types.ts:76](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L76) *** @@ -234,7 +234,7 @@ Defined in: [types.ts:49](https://github.com/TanStack/ai/blob/main/packages/type optional maxProperties: number; ``` -Defined in: [types.ts:60](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L60) +Defined in: [packages/typescript/ai/src/types.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L87) *** @@ -244,7 +244,7 @@ Defined in: [types.ts:60](https://github.com/TanStack/ai/blob/main/packages/type optional minimum: number; ``` -Defined in: [types.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L44) +Defined in: [packages/typescript/ai/src/types.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L71) *** @@ -254,7 +254,7 @@ Defined in: [types.ts:44](https://github.com/TanStack/ai/blob/main/packages/type optional minItems: number; ``` -Defined in: [types.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L52) +Defined in: [packages/typescript/ai/src/types.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L79) *** @@ -264,7 +264,7 @@ Defined in: [types.ts:52](https://github.com/TanStack/ai/blob/main/packages/type optional minLength: number; ``` -Defined in: [types.ts:48](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L48) +Defined in: [packages/typescript/ai/src/types.ts:75](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L75) *** @@ -274,7 +274,7 @@ Defined in: [types.ts:48](https://github.com/TanStack/ai/blob/main/packages/type optional minProperties: number; ``` -Defined in: [types.ts:59](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L59) +Defined in: [packages/typescript/ai/src/types.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L86) *** @@ -284,7 +284,7 @@ Defined in: [types.ts:59](https://github.com/TanStack/ai/blob/main/packages/type optional not: JSONSchema; ``` -Defined in: [types.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L40) +Defined in: [packages/typescript/ai/src/types.ts:67](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L67) *** @@ -294,7 +294,7 @@ Defined in: [types.ts:40](https://github.com/TanStack/ai/blob/main/packages/type optional oneOf: JSONSchema[]; ``` -Defined in: [types.ts:39](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L39) +Defined in: [packages/typescript/ai/src/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L66) *** @@ -304,7 +304,7 @@ Defined in: [types.ts:39](https://github.com/TanStack/ai/blob/main/packages/type optional pattern: string; ``` -Defined in: [types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L50) +Defined in: [packages/typescript/ai/src/types.ts:77](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L77) *** @@ -314,7 +314,7 @@ Defined in: [types.ts:50](https://github.com/TanStack/ai/blob/main/packages/type optional patternProperties: Record; ``` -Defined in: [types.ts:57](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L57) +Defined in: [packages/typescript/ai/src/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L84) *** @@ -324,7 +324,7 @@ Defined in: [types.ts:57](https://github.com/TanStack/ai/blob/main/packages/type optional properties: Record; ``` -Defined in: [types.ts:27](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L27) +Defined in: [packages/typescript/ai/src/types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L54) *** @@ -334,7 +334,7 @@ Defined in: [types.ts:27](https://github.com/TanStack/ai/blob/main/packages/type optional propertyNames: JSONSchema; ``` -Defined in: [types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L58) +Defined in: [packages/typescript/ai/src/types.ts:85](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L85) *** @@ -344,7 +344,7 @@ Defined in: [types.ts:58](https://github.com/TanStack/ai/blob/main/packages/type optional required: string[]; ``` -Defined in: [types.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L29) +Defined in: [packages/typescript/ai/src/types.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L56) *** @@ -354,7 +354,7 @@ Defined in: [types.ts:29](https://github.com/TanStack/ai/blob/main/packages/type optional then: JSONSchema; ``` -Defined in: [types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L42) +Defined in: [packages/typescript/ai/src/types.ts:69](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L69) *** @@ -364,7 +364,7 @@ Defined in: [types.ts:42](https://github.com/TanStack/ai/blob/main/packages/type optional title: string; ``` -Defined in: [types.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L61) +Defined in: [packages/typescript/ai/src/types.ts:88](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L88) *** @@ -374,7 +374,7 @@ Defined in: [types.ts:61](https://github.com/TanStack/ai/blob/main/packages/type optional type: string | string[]; ``` -Defined in: [types.ts:26](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L26) +Defined in: [packages/typescript/ai/src/types.ts:53](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L53) *** @@ -384,4 +384,4 @@ Defined in: [types.ts:26](https://github.com/TanStack/ai/blob/main/packages/type optional uniqueItems: boolean; ``` -Defined in: [types.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L54) +Defined in: [packages/typescript/ai/src/types.ts:81](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L81) diff --git a/docs/reference/interfaces/Logger.md b/docs/reference/interfaces/Logger.md new file mode 100644 index 0000000000..05463eebac --- /dev/null +++ b/docs/reference/interfaces/Logger.md @@ -0,0 +1,122 @@ +--- +id: Logger +title: Logger +--- + +# Interface: Logger + +Defined in: [packages/typescript/ai/src/logger/types.ts:4](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L4) + +Pluggable logger interface consumed by every `@tanstack/ai` activity when `debug` is enabled. Supply a custom implementation via `debug: { logger }` on `chat()`, `summarize()`, `generateImage()`, etc. The four methods correspond to log levels: use `debug` for chunk-level diagnostic output, `info`/`warn` for notable events, `error` for caught exceptions. + +## Properties + +### debug() + +```ts +debug: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:9](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L9) + +Called for chunk-level diagnostic output (raw provider chunks, per-chunk output, agent-loop iteration markers). + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` + +*** + +### error() + +```ts +error: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L24) + +Called for caught exceptions throughout the pipeline. + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` + +*** + +### info() + +```ts +info: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:14](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L14) + +Called for notable informational events (outgoing requests, tool invocations, middleware transitions). + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` + +*** + +### warn() + +```ts +warn: (message, meta?) => void; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:19](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L19) + +Called for notable warnings that don't halt execution (deprecations, recoverable anomalies). + +#### Parameters + +##### message + +`string` + +##### meta? + +`Record`\<`string`, `unknown`\> + +Structured data forwarded to the underlying logger. Loggers like pino will preserve this as a structured record; console-based loggers pass it as the second argument to `console.`. + +#### Returns + +`void` diff --git a/docs/reference/interfaces/MessagesSnapshotEvent.md b/docs/reference/interfaces/MessagesSnapshotEvent.md index 37c42584fb..7a41d6d2cf 100644 --- a/docs/reference/interfaces/MessagesSnapshotEvent.md +++ b/docs/reference/interfaces/MessagesSnapshotEvent.md @@ -5,31 +5,30 @@ title: MessagesSnapshotEvent # Interface: MessagesSnapshotEvent -Defined in: [types.ts:917](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L917) +Defined in: [packages/typescript/ai/src/types.ts:1004](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1004) Emitted to provide a snapshot of all messages in a conversation. Unlike StateSnapshot (which carries arbitrary application state), MessagesSnapshot specifically delivers the conversation transcript. -This is a first-class AG-UI event type. -## Extends +@ag-ui/core provides: `messages` (as @ag-ui/core Message[]) +TanStack AI adds: `model?` -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +Note: The `messages` field uses the @ag-ui/core Message type. +Use converters to transform to/from TanStack UIMessage format. -## Properties +## Extends -### messages +- `MessagesSnapshotEvent` + +## Indexable ```ts -messages: UIMessage[]; +[k: string]: unknown ``` -Defined in: [types.ts:920](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L920) - -Complete array of messages in the conversation - -*** +## Properties ### model? @@ -37,54 +36,6 @@ Complete array of messages in the conversation optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:1006](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1006) Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### type - -```ts -type: "MESSAGES_SNAPSHOT"; -``` - -Defined in: [types.ts:918](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L918) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) diff --git a/docs/reference/interfaces/ModelMessage.md b/docs/reference/interfaces/ModelMessage.md index 1cbc74cf5c..f1a8187a6d 100644 --- a/docs/reference/interfaces/ModelMessage.md +++ b/docs/reference/interfaces/ModelMessage.md @@ -5,7 +5,7 @@ title: ModelMessage # Interface: ModelMessage\ -Defined in: [types.ts:262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L262) +Defined in: [packages/typescript/ai/src/types.ts:289](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L289) ## Type Parameters @@ -21,7 +21,7 @@ Defined in: [types.ts:262](https://github.com/TanStack/ai/blob/main/packages/typ content: TContent; ``` -Defined in: [types.ts:269](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L269) +Defined in: [packages/typescript/ai/src/types.ts:296](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L296) *** @@ -31,7 +31,7 @@ Defined in: [types.ts:269](https://github.com/TanStack/ai/blob/main/packages/typ optional name: string; ``` -Defined in: [types.ts:270](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L270) +Defined in: [packages/typescript/ai/src/types.ts:297](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L297) *** @@ -41,7 +41,7 @@ Defined in: [types.ts:270](https://github.com/TanStack/ai/blob/main/packages/typ role: "user" | "assistant" | "tool"; ``` -Defined in: [types.ts:268](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L268) +Defined in: [packages/typescript/ai/src/types.ts:295](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L295) *** @@ -51,7 +51,7 @@ Defined in: [types.ts:268](https://github.com/TanStack/ai/blob/main/packages/typ optional toolCallId: string; ``` -Defined in: [types.ts:272](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L272) +Defined in: [packages/typescript/ai/src/types.ts:299](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L299) *** @@ -61,4 +61,4 @@ Defined in: [types.ts:272](https://github.com/TanStack/ai/blob/main/packages/typ optional toolCalls: ToolCall[]; ``` -Defined in: [types.ts:271](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L271) +Defined in: [packages/typescript/ai/src/types.ts:298](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L298) diff --git a/docs/reference/interfaces/ProcessorResult.md b/docs/reference/interfaces/ProcessorResult.md index 6cf48f12ea..b9de1f31cb 100644 --- a/docs/reference/interfaces/ProcessorResult.md +++ b/docs/reference/interfaces/ProcessorResult.md @@ -5,7 +5,7 @@ title: ProcessorResult # Interface: ProcessorResult -Defined in: [activities/chat/stream/types.ts:69](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L69) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L70) Result from processing a stream @@ -17,7 +17,7 @@ Result from processing a stream content: string; ``` -Defined in: [activities/chat/stream/types.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L70) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L71) *** @@ -27,7 +27,7 @@ Defined in: [activities/chat/stream/types.ts:70](https://github.com/TanStack/ai/ optional finishReason: string | null; ``` -Defined in: [activities/chat/stream/types.ts:73](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L73) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L74) *** @@ -37,7 +37,7 @@ Defined in: [activities/chat/stream/types.ts:73](https://github.com/TanStack/ai/ optional thinking: string; ``` -Defined in: [activities/chat/stream/types.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L71) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L72) *** @@ -47,4 +47,4 @@ Defined in: [activities/chat/stream/types.ts:71](https://github.com/TanStack/ai/ optional toolCalls: ToolCall[]; ``` -Defined in: [activities/chat/stream/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L72) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:73](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L73) diff --git a/docs/reference/interfaces/ProcessorState.md b/docs/reference/interfaces/ProcessorState.md index 0acd15e754..164fb79968 100644 --- a/docs/reference/interfaces/ProcessorState.md +++ b/docs/reference/interfaces/ProcessorState.md @@ -5,7 +5,7 @@ title: ProcessorState # Interface: ProcessorState -Defined in: [activities/chat/stream/types.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L79) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:80](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L80) Current state of the processor @@ -17,7 +17,7 @@ Current state of the processor content: string; ``` -Defined in: [activities/chat/stream/types.ts:80](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L80) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:81](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L81) *** @@ -27,7 +27,7 @@ Defined in: [activities/chat/stream/types.ts:80](https://github.com/TanStack/ai/ done: boolean; ``` -Defined in: [activities/chat/stream/types.ts:85](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L85) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L86) *** @@ -37,7 +37,7 @@ Defined in: [activities/chat/stream/types.ts:85](https://github.com/TanStack/ai/ finishReason: string | null; ``` -Defined in: [activities/chat/stream/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L84) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:85](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L85) *** @@ -47,7 +47,7 @@ Defined in: [activities/chat/stream/types.ts:84](https://github.com/TanStack/ai/ thinking: string; ``` -Defined in: [activities/chat/stream/types.ts:81](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L81) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:82](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L82) *** @@ -57,7 +57,7 @@ Defined in: [activities/chat/stream/types.ts:81](https://github.com/TanStack/ai/ toolCallOrder: string[]; ``` -Defined in: [activities/chat/stream/types.ts:83](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L83) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L84) *** @@ -67,4 +67,4 @@ Defined in: [activities/chat/stream/types.ts:83](https://github.com/TanStack/ai/ toolCalls: Map; ``` -Defined in: [activities/chat/stream/types.ts:82](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L82) +Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:83](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L83) diff --git a/docs/reference/interfaces/ProviderTool.md b/docs/reference/interfaces/ProviderTool.md new file mode 100644 index 0000000000..19a6efc20e --- /dev/null +++ b/docs/reference/interfaces/ProviderTool.md @@ -0,0 +1,297 @@ +--- +id: ProviderTool +title: ProviderTool +--- + +# Interface: ProviderTool\ + +Defined in: [packages/typescript/ai/src/tools/provider-tool.ts:19](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tools/provider-tool.ts#L19) + +A provider-specific tool produced by an adapter-package factory +(e.g. `webSearchTool` from `@tanstack/ai-anthropic/tools`). + +The two `~`-prefixed fields are type-only phantom brands — they are never +assigned at runtime. They allow the core type system to match a factory's +output against the selected model's `supports.tools` list and surface a +compile-time error when the combination is unsupported. + +User-defined tools (via `toolDefinition()`) remain plain `Tool` and stay +assignable to any model. + +## Extends + +- [`Tool`](Tool.md) + +## Type Parameters + +### TProvider + +`TProvider` *extends* `string` + +Provider identifier (e.g. `'anthropic'`, `'openai'`). + +### TKind + +`TKind` *extends* `string` + +Canonical tool-kind string matching the provider's + `supports.tools` entries (e.g. `'web_search'`, `'code_execution'`). + +## Properties + +### ~provider + +```ts +readonly ~provider: TProvider; +``` + +Defined in: [packages/typescript/ai/src/tools/provider-tool.ts:23](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tools/provider-tool.ts#L23) + +*** + +### ~toolKind + +```ts +readonly ~toolKind: TKind; +``` + +Defined in: [packages/typescript/ai/src/tools/provider-tool.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tools/provider-tool.ts#L24) + +*** + +### description + +```ts +description: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) + +Clear description of what the tool does. + +This is crucial - the model uses this to decide when to call the tool. +Be specific about what the tool does, what parameters it needs, and what it returns. + +#### Example + +```ts +"Get the current weather in a given location. Returns temperature, conditions, and forecast." +``` + +#### Inherited from + +[`Tool`](Tool.md).[`description`](Tool.md#description) + +*** + +### execute()? + +```ts +optional execute: (args, context?) => any; +``` + +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) + +Optional function to execute when the model calls this tool. + +If provided, the SDK will automatically execute the function with the model's arguments +and feed the result back to the model. This enables autonomous tool use loops. + +Can return any value - will be automatically stringified if needed. + +#### Parameters + +##### args + +`any` + +The arguments parsed from the model's tool call (validated against inputSchema) + +##### context? + +[`ToolExecutionContext`](ToolExecutionContext.md) + +#### Returns + +`any` + +Result to send back to the model (validated against outputSchema if provided) + +#### Example + +```ts +execute: async (args) => { + const weather = await fetchWeather(args.location); + return weather; // Can return object or string +} +``` + +#### Inherited from + +[`Tool`](Tool.md).[`execute`](Tool.md#execute) + +*** + +### inputSchema? + +```ts +optional inputSchema: SchemaInput; +``` + +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) + +Schema describing the tool's input parameters. + +Can be any Standard JSON Schema compliant schema (Zod, ArkType, Valibot, etc.) or a plain JSON Schema object. +Defines the structure and types of arguments the tool accepts. +The model will generate arguments matching this schema. +Standard JSON Schema compliant schemas are converted to JSON Schema for LLM providers. + +#### See + + - https://standardschema.dev/json-schema + - https://json-schema.org/ + +#### Examples + +```ts +// Using Zod v4+ schema (natively supports Standard JSON Schema) +import { z } from 'zod'; +z.object({ + location: z.string().describe("City name or coordinates"), + unit: z.enum(["celsius", "fahrenheit"]).optional() +}) +``` + +```ts +// Using ArkType (natively supports Standard JSON Schema) +import { type } from 'arktype'; +type({ + location: 'string', + unit: "'celsius' | 'fahrenheit'" +}) +``` + +```ts +// Using plain JSON Schema +{ + type: 'object', + properties: { + location: { type: 'string', description: 'City name or coordinates' }, + unit: { type: 'string', enum: ['celsius', 'fahrenheit'] } + }, + required: ['location'] +} +``` + +#### Inherited from + +[`Tool`](Tool.md).[`inputSchema`](Tool.md#inputschema) + +*** + +### lazy? + +```ts +optional lazy: boolean; +``` + +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) + +If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). + +#### Inherited from + +[`Tool`](Tool.md).[`lazy`](Tool.md#lazy) + +*** + +### metadata? + +```ts +optional metadata: Record; +``` + +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) + +Additional metadata for adapters or custom extensions + +#### Inherited from + +[`Tool`](Tool.md).[`metadata`](Tool.md#metadata) + +*** + +### name + +```ts +name: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) + +Unique name of the tool (used by the model to call it). + +Should be descriptive and follow naming conventions (e.g., snake_case or camelCase). +Must be unique within the tools array. + +#### Example + +```ts +"get_weather", "search_database", "sendEmail" +``` + +#### Inherited from + +[`Tool`](Tool.md).[`name`](Tool.md#name) + +*** + +### needsApproval? + +```ts +optional needsApproval: boolean; +``` + +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) + +If true, tool execution requires user approval before running. Works with both server and client tools. + +#### Inherited from + +[`Tool`](Tool.md).[`needsApproval`](Tool.md#needsapproval) + +*** + +### outputSchema? + +```ts +optional outputSchema: SchemaInput; +``` + +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) + +Optional schema for validating tool output. + +Can be any Standard JSON Schema compliant schema or a plain JSON Schema object. +If provided with a Standard Schema compliant schema, tool results will be validated +against this schema before being sent back to the model. This catches bugs in tool +implementations and ensures consistent output formatting. + +Note: This is client-side validation only - not sent to LLM providers. +Note: Plain JSON Schema output validation is not performed at runtime. + +#### Example + +```ts +// Using Zod +z.object({ + temperature: z.number(), + conditions: z.string(), + forecast: z.array(z.string()).optional() +}) +``` + +#### Inherited from + +[`Tool`](Tool.md).[`outputSchema`](Tool.md#outputschema) diff --git a/docs/reference/interfaces/RealtimeAudioPart.md b/docs/reference/interfaces/RealtimeAudioPart.md index 79ac1c2b55..90554e120c 100644 --- a/docs/reference/interfaces/RealtimeAudioPart.md +++ b/docs/reference/interfaces/RealtimeAudioPart.md @@ -5,7 +5,7 @@ title: RealtimeAudioPart # Interface: RealtimeAudioPart -Defined in: [realtime/types.ts:102](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L102) +Defined in: [packages/typescript/ai/src/realtime/types.ts:102](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L102) Audio content part in a realtime message @@ -17,7 +17,7 @@ Audio content part in a realtime message optional audioData: ArrayBuffer; ``` -Defined in: [realtime/types.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L107) +Defined in: [packages/typescript/ai/src/realtime/types.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L107) Raw audio data (optional, if stored) @@ -29,7 +29,7 @@ Raw audio data (optional, if stored) optional durationMs: number; ``` -Defined in: [realtime/types.ts:109](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L109) +Defined in: [packages/typescript/ai/src/realtime/types.ts:109](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L109) Duration of the audio in milliseconds @@ -41,7 +41,7 @@ Duration of the audio in milliseconds transcript: string; ``` -Defined in: [realtime/types.ts:105](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L105) +Defined in: [packages/typescript/ai/src/realtime/types.ts:105](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L105) Transcription of the audio @@ -53,4 +53,4 @@ Transcription of the audio type: "audio"; ``` -Defined in: [realtime/types.ts:103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L103) +Defined in: [packages/typescript/ai/src/realtime/types.ts:103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L103) diff --git a/docs/reference/interfaces/RealtimeError.md b/docs/reference/interfaces/RealtimeError.md index 064290613f..7af0baa712 100644 --- a/docs/reference/interfaces/RealtimeError.md +++ b/docs/reference/interfaces/RealtimeError.md @@ -5,7 +5,7 @@ title: RealtimeError # Interface: RealtimeError -Defined in: [realtime/types.ts:290](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L290) +Defined in: [packages/typescript/ai/src/realtime/types.ts:290](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L290) Extended error with realtime-specific information @@ -21,7 +21,7 @@ Extended error with realtime-specific information code: RealtimeErrorCode; ``` -Defined in: [realtime/types.ts:291](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L291) +Defined in: [packages/typescript/ai/src/realtime/types.ts:291](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L291) *** @@ -31,7 +31,7 @@ Defined in: [realtime/types.ts:291](https://github.com/TanStack/ai/blob/main/pac optional details: unknown; ``` -Defined in: [realtime/types.ts:293](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L293) +Defined in: [packages/typescript/ai/src/realtime/types.ts:293](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L293) *** @@ -41,4 +41,4 @@ Defined in: [realtime/types.ts:293](https://github.com/TanStack/ai/blob/main/pac optional provider: string; ``` -Defined in: [realtime/types.ts:292](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L292) +Defined in: [packages/typescript/ai/src/realtime/types.ts:292](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L292) diff --git a/docs/reference/interfaces/RealtimeEventPayloads.md b/docs/reference/interfaces/RealtimeEventPayloads.md index dfc37b3b10..62d1cf199a 100644 --- a/docs/reference/interfaces/RealtimeEventPayloads.md +++ b/docs/reference/interfaces/RealtimeEventPayloads.md @@ -5,7 +5,7 @@ title: RealtimeEventPayloads # Interface: RealtimeEventPayloads -Defined in: [realtime/types.ts:251](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L251) +Defined in: [packages/typescript/ai/src/realtime/types.ts:251](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L251) Event payloads for realtime events @@ -17,7 +17,7 @@ Event payloads for realtime events audio_chunk: object; ``` -Defined in: [realtime/types.ts:259](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L259) +Defined in: [packages/typescript/ai/src/realtime/types.ts:259](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L259) #### data @@ -39,7 +39,7 @@ sampleRate: number; error: object; ``` -Defined in: [realtime/types.ts:263](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L263) +Defined in: [packages/typescript/ai/src/realtime/types.ts:263](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L263) #### error @@ -55,7 +55,7 @@ error: Error; interrupted: object; ``` -Defined in: [realtime/types.ts:262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L262) +Defined in: [packages/typescript/ai/src/realtime/types.ts:262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L262) #### messageId? @@ -71,7 +71,7 @@ optional messageId: string; message_complete: object; ``` -Defined in: [realtime/types.ts:261](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L261) +Defined in: [packages/typescript/ai/src/realtime/types.ts:261](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L261) #### message @@ -87,7 +87,7 @@ message: RealtimeMessage; mode_change: object; ``` -Defined in: [realtime/types.ts:253](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L253) +Defined in: [packages/typescript/ai/src/realtime/types.ts:253](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L253) #### mode @@ -103,7 +103,7 @@ mode: RealtimeMode; status_change: object; ``` -Defined in: [realtime/types.ts:252](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L252) +Defined in: [packages/typescript/ai/src/realtime/types.ts:252](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L252) #### status @@ -119,7 +119,7 @@ status: RealtimeStatus; tool_call: object; ``` -Defined in: [realtime/types.ts:260](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L260) +Defined in: [packages/typescript/ai/src/realtime/types.ts:260](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L260) #### input @@ -147,7 +147,7 @@ toolName: string; transcript: object; ``` -Defined in: [realtime/types.ts:254](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L254) +Defined in: [packages/typescript/ai/src/realtime/types.ts:254](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L254) #### isFinal diff --git a/docs/reference/interfaces/RealtimeImagePart.md b/docs/reference/interfaces/RealtimeImagePart.md index ee69eab28e..e223d080b3 100644 --- a/docs/reference/interfaces/RealtimeImagePart.md +++ b/docs/reference/interfaces/RealtimeImagePart.md @@ -5,7 +5,7 @@ title: RealtimeImagePart # Interface: RealtimeImagePart -Defined in: [realtime/types.ts:136](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L136) +Defined in: [packages/typescript/ai/src/realtime/types.ts:136](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L136) Image content part in a realtime message @@ -17,7 +17,7 @@ Image content part in a realtime message data: string; ``` -Defined in: [realtime/types.ts:139](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L139) +Defined in: [packages/typescript/ai/src/realtime/types.ts:139](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L139) Base64-encoded image data or a URL @@ -29,7 +29,7 @@ Base64-encoded image data or a URL mimeType: string; ``` -Defined in: [realtime/types.ts:141](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L141) +Defined in: [packages/typescript/ai/src/realtime/types.ts:141](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L141) MIME type of the image (e.g., 'image/png', 'image/jpeg') @@ -41,4 +41,4 @@ MIME type of the image (e.g., 'image/png', 'image/jpeg') type: "image"; ``` -Defined in: [realtime/types.ts:137](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L137) +Defined in: [packages/typescript/ai/src/realtime/types.ts:137](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L137) diff --git a/docs/reference/interfaces/RealtimeMessage.md b/docs/reference/interfaces/RealtimeMessage.md index 794f43e8b4..8ade323b34 100644 --- a/docs/reference/interfaces/RealtimeMessage.md +++ b/docs/reference/interfaces/RealtimeMessage.md @@ -5,7 +5,7 @@ title: RealtimeMessage # Interface: RealtimeMessage -Defined in: [realtime/types.ts:157](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L157) +Defined in: [packages/typescript/ai/src/realtime/types.ts:157](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L157) A message in a realtime conversation @@ -17,7 +17,7 @@ A message in a realtime conversation optional audioId: string; ``` -Defined in: [realtime/types.ts:169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L169) +Defined in: [packages/typescript/ai/src/realtime/types.ts:169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L169) Reference to audio buffer if stored @@ -29,7 +29,7 @@ Reference to audio buffer if stored optional durationMs: number; ``` -Defined in: [realtime/types.ts:171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L171) +Defined in: [packages/typescript/ai/src/realtime/types.ts:171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L171) Duration of the audio in milliseconds @@ -41,7 +41,7 @@ Duration of the audio in milliseconds id: string; ``` -Defined in: [realtime/types.ts:159](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L159) +Defined in: [packages/typescript/ai/src/realtime/types.ts:159](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L159) Unique message identifier @@ -53,7 +53,7 @@ Unique message identifier optional interrupted: boolean; ``` -Defined in: [realtime/types.ts:167](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L167) +Defined in: [packages/typescript/ai/src/realtime/types.ts:167](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L167) Whether this message was interrupted @@ -65,7 +65,7 @@ Whether this message was interrupted parts: RealtimeMessagePart[]; ``` -Defined in: [realtime/types.ts:165](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L165) +Defined in: [packages/typescript/ai/src/realtime/types.ts:165](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L165) Content parts of the message @@ -77,7 +77,7 @@ Content parts of the message role: "user" | "assistant"; ``` -Defined in: [realtime/types.ts:161](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L161) +Defined in: [packages/typescript/ai/src/realtime/types.ts:161](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L161) Message role @@ -89,6 +89,6 @@ Message role timestamp: number; ``` -Defined in: [realtime/types.ts:163](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L163) +Defined in: [packages/typescript/ai/src/realtime/types.ts:163](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L163) Timestamp when the message was created diff --git a/docs/reference/interfaces/RealtimeSessionConfig.md b/docs/reference/interfaces/RealtimeSessionConfig.md index 6e41a38c51..a362658ed4 100644 --- a/docs/reference/interfaces/RealtimeSessionConfig.md +++ b/docs/reference/interfaces/RealtimeSessionConfig.md @@ -5,7 +5,7 @@ title: RealtimeSessionConfig # Interface: RealtimeSessionConfig -Defined in: [realtime/types.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L30) +Defined in: [packages/typescript/ai/src/realtime/types.ts:30](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L30) Configuration for a realtime session @@ -17,7 +17,7 @@ Configuration for a realtime session optional instructions: string; ``` -Defined in: [realtime/types.ts:36](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L36) +Defined in: [packages/typescript/ai/src/realtime/types.ts:36](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L36) System instructions for the assistant @@ -29,7 +29,7 @@ System instructions for the assistant optional maxOutputTokens: number | "inf"; ``` -Defined in: [realtime/types.ts:48](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L48) +Defined in: [packages/typescript/ai/src/realtime/types.ts:48](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L48) Maximum number of tokens in a response @@ -41,7 +41,7 @@ Maximum number of tokens in a response optional model: string; ``` -Defined in: [realtime/types.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L32) +Defined in: [packages/typescript/ai/src/realtime/types.ts:32](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L32) Model to use for the session @@ -53,7 +53,7 @@ Model to use for the session optional outputModalities: ("text" | "audio")[]; ``` -Defined in: [realtime/types.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L44) +Defined in: [packages/typescript/ai/src/realtime/types.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L44) Output modalities for responses (e.g., ['audio', 'text'], ['text']) @@ -65,7 +65,7 @@ Output modalities for responses (e.g., ['audio', 'text'], ['text']) optional providerOptions: Record; ``` -Defined in: [realtime/types.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L52) +Defined in: [packages/typescript/ai/src/realtime/types.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L52) Provider-specific options @@ -74,10 +74,10 @@ Provider-specific options ### semanticEagerness? ```ts -optional semanticEagerness: "low" | "high" | "medium"; +optional semanticEagerness: "low" | "medium" | "high"; ``` -Defined in: [realtime/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L50) +Defined in: [packages/typescript/ai/src/realtime/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L50) Eagerness level for semantic VAD ('low', 'medium', 'high') @@ -89,7 +89,7 @@ Eagerness level for semantic VAD ('low', 'medium', 'high') optional temperature: number; ``` -Defined in: [realtime/types.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L46) +Defined in: [packages/typescript/ai/src/realtime/types.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L46) Temperature for generation (provider-specific range, e.g., 0.6-1.2 for OpenAI) @@ -101,7 +101,7 @@ Temperature for generation (provider-specific range, e.g., 0.6-1.2 for OpenAI) optional tools: RealtimeToolConfig[]; ``` -Defined in: [realtime/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L38) +Defined in: [packages/typescript/ai/src/realtime/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L38) Tools available in the session @@ -113,7 +113,7 @@ Tools available in the session optional vadConfig: VADConfig; ``` -Defined in: [realtime/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L42) +Defined in: [packages/typescript/ai/src/realtime/types.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L42) VAD configuration @@ -125,7 +125,7 @@ VAD configuration optional vadMode: "server" | "manual" | "semantic"; ``` -Defined in: [realtime/types.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L40) +Defined in: [packages/typescript/ai/src/realtime/types.ts:40](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L40) VAD mode @@ -137,6 +137,6 @@ VAD mode optional voice: string; ``` -Defined in: [realtime/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L34) +Defined in: [packages/typescript/ai/src/realtime/types.ts:34](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L34) Voice to use for audio output diff --git a/docs/reference/interfaces/RealtimeTextPart.md b/docs/reference/interfaces/RealtimeTextPart.md index aa5ef561a2..6577624188 100644 --- a/docs/reference/interfaces/RealtimeTextPart.md +++ b/docs/reference/interfaces/RealtimeTextPart.md @@ -5,7 +5,7 @@ title: RealtimeTextPart # Interface: RealtimeTextPart -Defined in: [realtime/types.ts:94](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L94) +Defined in: [packages/typescript/ai/src/realtime/types.ts:94](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L94) Text content part in a realtime message @@ -17,7 +17,7 @@ Text content part in a realtime message content: string; ``` -Defined in: [realtime/types.ts:96](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L96) +Defined in: [packages/typescript/ai/src/realtime/types.ts:96](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L96) *** @@ -27,4 +27,4 @@ Defined in: [realtime/types.ts:96](https://github.com/TanStack/ai/blob/main/pack type: "text"; ``` -Defined in: [realtime/types.ts:95](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L95) +Defined in: [packages/typescript/ai/src/realtime/types.ts:95](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L95) diff --git a/docs/reference/interfaces/RealtimeToken.md b/docs/reference/interfaces/RealtimeToken.md index 7577eb271e..34648c85f8 100644 --- a/docs/reference/interfaces/RealtimeToken.md +++ b/docs/reference/interfaces/RealtimeToken.md @@ -5,7 +5,7 @@ title: RealtimeToken # Interface: RealtimeToken -Defined in: [realtime/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L58) +Defined in: [packages/typescript/ai/src/realtime/types.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L58) Token returned by the server for client authentication @@ -17,7 +17,7 @@ Token returned by the server for client authentication config: RealtimeSessionConfig; ``` -Defined in: [realtime/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L66) +Defined in: [packages/typescript/ai/src/realtime/types.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L66) Session configuration embedded in the token @@ -29,7 +29,7 @@ Session configuration embedded in the token expiresAt: number; ``` -Defined in: [realtime/types.ts:64](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L64) +Defined in: [packages/typescript/ai/src/realtime/types.ts:64](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L64) Token expiration timestamp (ms since epoch) @@ -41,7 +41,7 @@ Token expiration timestamp (ms since epoch) provider: string; ``` -Defined in: [realtime/types.ts:60](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L60) +Defined in: [packages/typescript/ai/src/realtime/types.ts:60](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L60) Provider identifier @@ -53,6 +53,6 @@ Provider identifier token: string; ``` -Defined in: [realtime/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L62) +Defined in: [packages/typescript/ai/src/realtime/types.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L62) The ephemeral token value diff --git a/docs/reference/interfaces/RealtimeTokenAdapter.md b/docs/reference/interfaces/RealtimeTokenAdapter.md index 3840c53088..07501dfbfa 100644 --- a/docs/reference/interfaces/RealtimeTokenAdapter.md +++ b/docs/reference/interfaces/RealtimeTokenAdapter.md @@ -5,7 +5,7 @@ title: RealtimeTokenAdapter # Interface: RealtimeTokenAdapter -Defined in: [realtime/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L72) +Defined in: [packages/typescript/ai/src/realtime/types.ts:72](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L72) Adapter interface for generating provider-specific tokens @@ -17,7 +17,7 @@ Adapter interface for generating provider-specific tokens generateToken: () => Promise; ``` -Defined in: [realtime/types.ts:76](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L76) +Defined in: [packages/typescript/ai/src/realtime/types.ts:76](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L76) Generate an ephemeral token for client use @@ -33,6 +33,6 @@ Generate an ephemeral token for client use provider: string; ``` -Defined in: [realtime/types.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L74) +Defined in: [packages/typescript/ai/src/realtime/types.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L74) Provider identifier diff --git a/docs/reference/interfaces/RealtimeTokenOptions.md b/docs/reference/interfaces/RealtimeTokenOptions.md index 060b6d4d9f..b035a57f79 100644 --- a/docs/reference/interfaces/RealtimeTokenOptions.md +++ b/docs/reference/interfaces/RealtimeTokenOptions.md @@ -5,7 +5,7 @@ title: RealtimeTokenOptions # Interface: RealtimeTokenOptions -Defined in: [realtime/types.ts:82](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L82) +Defined in: [packages/typescript/ai/src/realtime/types.ts:82](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L82) Options for the realtimeToken function @@ -17,6 +17,6 @@ Options for the realtimeToken function adapter: RealtimeTokenAdapter; ``` -Defined in: [realtime/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L84) +Defined in: [packages/typescript/ai/src/realtime/types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L84) The token adapter to use diff --git a/docs/reference/interfaces/RealtimeToolCallPart.md b/docs/reference/interfaces/RealtimeToolCallPart.md index 999fbd27e6..82bf36b431 100644 --- a/docs/reference/interfaces/RealtimeToolCallPart.md +++ b/docs/reference/interfaces/RealtimeToolCallPart.md @@ -5,7 +5,7 @@ title: RealtimeToolCallPart # Interface: RealtimeToolCallPart -Defined in: [realtime/types.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L115) +Defined in: [packages/typescript/ai/src/realtime/types.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L115) Tool call part in a realtime message @@ -17,7 +17,7 @@ Tool call part in a realtime message arguments: string; ``` -Defined in: [realtime/types.ts:119](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L119) +Defined in: [packages/typescript/ai/src/realtime/types.ts:119](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L119) *** @@ -27,7 +27,7 @@ Defined in: [realtime/types.ts:119](https://github.com/TanStack/ai/blob/main/pac id: string; ``` -Defined in: [realtime/types.ts:117](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L117) +Defined in: [packages/typescript/ai/src/realtime/types.ts:117](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L117) *** @@ -37,7 +37,7 @@ Defined in: [realtime/types.ts:117](https://github.com/TanStack/ai/blob/main/pac optional input: unknown; ``` -Defined in: [realtime/types.ts:120](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L120) +Defined in: [packages/typescript/ai/src/realtime/types.ts:120](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L120) *** @@ -47,7 +47,7 @@ Defined in: [realtime/types.ts:120](https://github.com/TanStack/ai/blob/main/pac name: string; ``` -Defined in: [realtime/types.ts:118](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L118) +Defined in: [packages/typescript/ai/src/realtime/types.ts:118](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L118) *** @@ -57,7 +57,7 @@ Defined in: [realtime/types.ts:118](https://github.com/TanStack/ai/blob/main/pac optional output: unknown; ``` -Defined in: [realtime/types.ts:121](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L121) +Defined in: [packages/typescript/ai/src/realtime/types.ts:121](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L121) *** @@ -67,4 +67,4 @@ Defined in: [realtime/types.ts:121](https://github.com/TanStack/ai/blob/main/pac type: "tool-call"; ``` -Defined in: [realtime/types.ts:116](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L116) +Defined in: [packages/typescript/ai/src/realtime/types.ts:116](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L116) diff --git a/docs/reference/interfaces/RealtimeToolResultPart.md b/docs/reference/interfaces/RealtimeToolResultPart.md index 711a8a708c..c979d1566b 100644 --- a/docs/reference/interfaces/RealtimeToolResultPart.md +++ b/docs/reference/interfaces/RealtimeToolResultPart.md @@ -5,7 +5,7 @@ title: RealtimeToolResultPart # Interface: RealtimeToolResultPart -Defined in: [realtime/types.ts:127](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L127) +Defined in: [packages/typescript/ai/src/realtime/types.ts:127](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L127) Tool result part in a realtime message @@ -17,7 +17,7 @@ Tool result part in a realtime message content: string; ``` -Defined in: [realtime/types.ts:130](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L130) +Defined in: [packages/typescript/ai/src/realtime/types.ts:130](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L130) *** @@ -27,7 +27,7 @@ Defined in: [realtime/types.ts:130](https://github.com/TanStack/ai/blob/main/pac toolCallId: string; ``` -Defined in: [realtime/types.ts:129](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L129) +Defined in: [packages/typescript/ai/src/realtime/types.ts:129](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L129) *** @@ -37,4 +37,4 @@ Defined in: [realtime/types.ts:129](https://github.com/TanStack/ai/blob/main/pac type: "tool-result"; ``` -Defined in: [realtime/types.ts:128](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L128) +Defined in: [packages/typescript/ai/src/realtime/types.ts:128](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L128) diff --git a/docs/reference/interfaces/ReasoningEncryptedValueEvent.md b/docs/reference/interfaces/ReasoningEncryptedValueEvent.md new file mode 100644 index 0000000000..85e72381b2 --- /dev/null +++ b/docs/reference/interfaces/ReasoningEncryptedValueEvent.md @@ -0,0 +1,35 @@ +--- +id: ReasoningEncryptedValueEvent +title: ReasoningEncryptedValueEvent +--- + +# Interface: ReasoningEncryptedValueEvent + +Defined in: [packages/typescript/ai/src/types.ts:1112](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1112) + +Emitted for encrypted reasoning values. + +@ag-ui/core provides: `subtype`, `entityId`, `encryptedValue` +TanStack AI adds: `model?` + +## Extends + +- `ReasoningEncryptedValueEvent` + +## Indexable + +```ts +[k: string]: unknown +``` + +## Properties + +### model? + +```ts +optional model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1114](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1114) + +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningEndEvent.md b/docs/reference/interfaces/ReasoningEndEvent.md new file mode 100644 index 0000000000..afaa42e4b6 --- /dev/null +++ b/docs/reference/interfaces/ReasoningEndEvent.md @@ -0,0 +1,35 @@ +--- +id: ReasoningEndEvent +title: ReasoningEndEvent +--- + +# Interface: ReasoningEndEvent + +Defined in: [packages/typescript/ai/src/types.ts:1101](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1101) + +Emitted when reasoning ends for a message. + +@ag-ui/core provides: `messageId` +TanStack AI adds: `model?` + +## Extends + +- `ReasoningEndEvent` + +## Indexable + +```ts +[k: string]: unknown +``` + +## Properties + +### model? + +```ts +optional model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1103) + +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningMessageContentEvent.md b/docs/reference/interfaces/ReasoningMessageContentEvent.md new file mode 100644 index 0000000000..7a5b9186d2 --- /dev/null +++ b/docs/reference/interfaces/ReasoningMessageContentEvent.md @@ -0,0 +1,35 @@ +--- +id: ReasoningMessageContentEvent +title: ReasoningMessageContentEvent +--- + +# Interface: ReasoningMessageContentEvent + +Defined in: [packages/typescript/ai/src/types.ts:1079](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1079) + +Emitted when reasoning message content is generated. + +@ag-ui/core provides: `messageId`, `delta` +TanStack AI adds: `model?` + +## Extends + +- `ReasoningMessageContentEvent` + +## Indexable + +```ts +[k: string]: unknown +``` + +## Properties + +### model? + +```ts +optional model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1081](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1081) + +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningMessageEndEvent.md b/docs/reference/interfaces/ReasoningMessageEndEvent.md new file mode 100644 index 0000000000..c08bd16378 --- /dev/null +++ b/docs/reference/interfaces/ReasoningMessageEndEvent.md @@ -0,0 +1,35 @@ +--- +id: ReasoningMessageEndEvent +title: ReasoningMessageEndEvent +--- + +# Interface: ReasoningMessageEndEvent + +Defined in: [packages/typescript/ai/src/types.ts:1090](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1090) + +Emitted when a reasoning message ends. + +@ag-ui/core provides: `messageId` +TanStack AI adds: `model?` + +## Extends + +- `ReasoningMessageEndEvent` + +## Indexable + +```ts +[k: string]: unknown +``` + +## Properties + +### model? + +```ts +optional model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1092](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1092) + +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningMessageStartEvent.md b/docs/reference/interfaces/ReasoningMessageStartEvent.md new file mode 100644 index 0000000000..277d1377fb --- /dev/null +++ b/docs/reference/interfaces/ReasoningMessageStartEvent.md @@ -0,0 +1,35 @@ +--- +id: ReasoningMessageStartEvent +title: ReasoningMessageStartEvent +--- + +# Interface: ReasoningMessageStartEvent + +Defined in: [packages/typescript/ai/src/types.ts:1068](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1068) + +Emitted when a reasoning message starts. + +@ag-ui/core provides: `messageId`, `role` ("reasoning") +TanStack AI adds: `model?` + +## Extends + +- `ReasoningMessageStartEvent` + +## Indexable + +```ts +[k: string]: unknown +``` + +## Properties + +### model? + +```ts +optional model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1070](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1070) + +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ReasoningStartEvent.md b/docs/reference/interfaces/ReasoningStartEvent.md new file mode 100644 index 0000000000..96805bdd6a --- /dev/null +++ b/docs/reference/interfaces/ReasoningStartEvent.md @@ -0,0 +1,35 @@ +--- +id: ReasoningStartEvent +title: ReasoningStartEvent +--- + +# Interface: ReasoningStartEvent + +Defined in: [packages/typescript/ai/src/types.ts:1057](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1057) + +Emitted when reasoning starts for a message. + +@ag-ui/core provides: `messageId` +TanStack AI adds: `model?` + +## Extends + +- `ReasoningStartEvent` + +## Indexable + +```ts +[k: string]: unknown +``` + +## Properties + +### model? + +```ts +optional model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1059](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1059) + +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ResponseFormat.md b/docs/reference/interfaces/ResponseFormat.md index 5b4becc2a2..064c60c0f1 100644 --- a/docs/reference/interfaces/ResponseFormat.md +++ b/docs/reference/interfaces/ResponseFormat.md @@ -5,7 +5,7 @@ title: ResponseFormat # Interface: ResponseFormat\ -Defined in: [types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) +Defined in: [packages/typescript/ai/src/types.ts:547](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L547) Structured output format specification. @@ -33,7 +33,7 @@ TypeScript type of the expected data structure (for type safety) optional __data: TData; ``` -Defined in: [types.ts:598](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L598) +Defined in: [packages/typescript/ai/src/types.ts:625](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L625) **`Internal`** @@ -50,7 +50,7 @@ Allows the SDK to know what type to expect when parsing the response. optional json_schema: object; ``` -Defined in: [types.ts:537](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L537) +Defined in: [packages/typescript/ai/src/types.ts:564](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L564) JSON schema specification (required when type is "json_schema"). @@ -139,7 +139,7 @@ https://platform.openai.com/docs/guides/structured-outputs#strict-mode type: "json_object" | "json_schema"; ``` -Defined in: [types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) +Defined in: [packages/typescript/ai/src/types.ts:556](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L556) Type of structured output. diff --git a/docs/reference/interfaces/RunErrorEvent.md b/docs/reference/interfaces/RunErrorEvent.md index de839bcfde..54d136c77b 100644 --- a/docs/reference/interfaces/RunErrorEvent.md +++ b/docs/reference/interfaces/RunErrorEvent.md @@ -5,106 +5,58 @@ title: RunErrorEvent # Interface: RunErrorEvent -Defined in: [types.ts:797](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L797) +Defined in: [packages/typescript/ai/src/types.ts:840](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L840) Emitted when an error occurs during a run. -## Extends - -- [`BaseAGUIEvent`](BaseAGUIEvent.md) - -## Properties - -### error - -```ts -error: object; -``` - -Defined in: [types.ts:802](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L802) +@ag-ui/core provides: `message`, `code?` +TanStack AI adds: `model?`, `error?` (deprecated nested form) -Error details - -#### code? - -```ts -optional code: string; -``` - -#### message - -```ts -message: string; -``` +## Extends -*** +- `RunErrorEvent` -### model? +## Indexable ```ts -optional model: string; +[k: string]: unknown ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) - -Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** +## Properties -### rawEvent? +### ~~error?~~ ```ts -optional rawEvent: unknown; +optional error: object; ``` -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** +Defined in: [packages/typescript/ai/src/types.ts:847](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L847) -### runId? +#### ~~code?~~ ```ts -optional runId: string; +optional code: string; ``` -Defined in: [types.ts:800](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L800) - -Run identifier (if available) - -*** - -### timestamp +#### ~~message~~ ```ts -timestamp: number; +message: string; ``` -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) +#### Deprecated -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) +Use top-level `message` and `code` fields instead. +Kept for backward compatibility. *** -### type +### model? ```ts -type: "RUN_ERROR"; +optional model: string; ``` -Defined in: [types.ts:798](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L798) +Defined in: [packages/typescript/ai/src/types.ts:842](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L842) -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) +Model identifier for multi-model support diff --git a/docs/reference/interfaces/RunFinishedEvent.md b/docs/reference/interfaces/RunFinishedEvent.md index 8a87e57cbe..be612fbeb3 100644 --- a/docs/reference/interfaces/RunFinishedEvent.md +++ b/docs/reference/interfaces/RunFinishedEvent.md @@ -5,23 +5,32 @@ title: RunFinishedEvent # Interface: RunFinishedEvent -Defined in: [types.ts:780](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L780) +Defined in: [packages/typescript/ai/src/types.ts:821](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L821) Emitted when a run completes successfully. +@ag-ui/core provides: `threadId`, `runId`, `result?` +TanStack AI adds: `model?`, `finishReason?`, `usage?` + ## Extends -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +- `RunFinishedEvent` + +## Indexable + +```ts +[k: string]: unknown +``` ## Properties -### finishReason +### finishReason? ```ts -finishReason: "length" | "stop" | "content_filter" | "tool_calls" | null; +optional finishReason: "length" | "stop" | "content_filter" | "tool_calls" | null; ``` -Defined in: [types.ts:785](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L785) +Defined in: [packages/typescript/ai/src/types.ts:825](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L825) Why the generation stopped @@ -33,70 +42,10 @@ Why the generation stopped optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:823](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L823) Model identifier for multi-model support -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### runId - -```ts -runId: string; -``` - -Defined in: [types.ts:783](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L783) - -Run identifier - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### type - -```ts -type: "RUN_FINISHED"; -``` - -Defined in: [types.ts:781](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L781) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) - *** ### usage? @@ -105,7 +54,7 @@ Defined in: [types.ts:781](https://github.com/TanStack/ai/blob/main/packages/typ optional usage: object; ``` -Defined in: [types.ts:787](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L787) +Defined in: [packages/typescript/ai/src/types.ts:827](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L827) Token usage statistics diff --git a/docs/reference/interfaces/RunStartedEvent.md b/docs/reference/interfaces/RunStartedEvent.md index 490fd0fa79..d4f3289caf 100644 --- a/docs/reference/interfaces/RunStartedEvent.md +++ b/docs/reference/interfaces/RunStartedEvent.md @@ -5,95 +5,32 @@ title: RunStartedEvent # Interface: RunStartedEvent -Defined in: [types.ts:769](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L769) +Defined in: [packages/typescript/ai/src/types.ts:810](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L810) Emitted when a run starts. This is the first event in any streaming response. -## Extends - -- [`BaseAGUIEvent`](BaseAGUIEvent.md) - -## Properties - -### model? - -```ts -optional model: string; -``` - -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) - -Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from +@ag-ui/core provides: `threadId`, `runId`, `parentRunId?`, `input?` +TanStack AI adds: `model?` -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### runId - -```ts -runId: string; -``` - -Defined in: [types.ts:772](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L772) - -Unique identifier for this run - -*** - -### threadId? - -```ts -optional threadId: string; -``` - -Defined in: [types.ts:774](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L774) - -Optional thread/conversation ID +## Extends -*** +- `RunStartedEvent` -### timestamp +## Indexable ```ts -timestamp: number; +[k: string]: unknown ``` -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** +## Properties -### type +### model? ```ts -type: "RUN_STARTED"; +optional model: string; ``` -Defined in: [types.ts:770](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L770) +Defined in: [packages/typescript/ai/src/types.ts:812](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L812) -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ServerTool.md b/docs/reference/interfaces/ServerTool.md index ddf5692017..d3140ed717 100644 --- a/docs/reference/interfaces/ServerTool.md +++ b/docs/reference/interfaces/ServerTool.md @@ -5,7 +5,7 @@ title: ServerTool # Interface: ServerTool\ -Defined in: [activities/chat/tools/tool-definition.ts:13](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L13) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:13](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L13) Marker type for server-side tools @@ -35,7 +35,7 @@ Marker type for server-side tools __toolSide: "server"; ``` -Defined in: [activities/chat/tools/tool-definition.ts:18](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L18) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:18](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L18) *** @@ -45,7 +45,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:18](https://github.com/Tan description: string; ``` -Defined in: [types.ts:413](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L413) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -70,7 +70,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [types.ts:493](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L493) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -118,7 +118,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [types.ts:453](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L453) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -176,7 +176,7 @@ type({ optional lazy: boolean; ``` -Defined in: [types.ts:499](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L499) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -192,7 +192,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [types.ts:502](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L502) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -208,7 +208,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [types.ts:403](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L403) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -233,7 +233,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [types.ts:496](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L496) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -249,7 +249,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [types.ts:474](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L474) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/StateDeltaEvent.md b/docs/reference/interfaces/StateDeltaEvent.md index b64dd40bd6..0692ca7898 100644 --- a/docs/reference/interfaces/StateDeltaEvent.md +++ b/docs/reference/interfaces/StateDeltaEvent.md @@ -5,27 +5,24 @@ title: StateDeltaEvent # Interface: StateDeltaEvent -Defined in: [types.ts:935](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L935) +Defined in: [packages/typescript/ai/src/types.ts:1031](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1031) Emitted to provide an incremental state update. -## Extends +@ag-ui/core provides: `delta` (any[] - JSON Patch RFC 6902) +TanStack AI adds: `model?` -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +## Extends -## Properties +- `StateDeltaEvent` -### delta +## Indexable ```ts -delta: Record; +[k: string]: unknown ``` -Defined in: [types.ts:938](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L938) - -The state changes to apply - -*** +## Properties ### model? @@ -33,54 +30,6 @@ The state changes to apply optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:1033](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1033) Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### type - -```ts -type: "STATE_DELTA"; -``` - -Defined in: [types.ts:936](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L936) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) diff --git a/docs/reference/interfaces/StateSnapshotEvent.md b/docs/reference/interfaces/StateSnapshotEvent.md index 822d66f40d..c350f72f8c 100644 --- a/docs/reference/interfaces/StateSnapshotEvent.md +++ b/docs/reference/interfaces/StateSnapshotEvent.md @@ -5,82 +5,46 @@ title: StateSnapshotEvent # Interface: StateSnapshotEvent -Defined in: [types.ts:926](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L926) +Defined in: [packages/typescript/ai/src/types.ts:1015](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1015) Emitted to provide a full state snapshot. -## Extends - -- [`BaseAGUIEvent`](BaseAGUIEvent.md) - -## Properties - -### model? - -```ts -optional model: string; -``` - -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) - -Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** +@ag-ui/core provides: `snapshot` (any) +TanStack AI adds: `model?`, `state?` (deprecated alias for snapshot) -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) +## Extends -*** +- `StateSnapshotEvent` -### state +## Indexable ```ts -state: Record; +[k: string]: unknown ``` -Defined in: [types.ts:929](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L929) - -The complete state object - -*** +## Properties -### timestamp +### model? ```ts -timestamp: number; +optional model: string; ``` -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) +Defined in: [packages/typescript/ai/src/types.ts:1017](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1017) -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) +Model identifier for multi-model support *** -### type +### ~~state?~~ ```ts -type: "STATE_SNAPSHOT"; +optional state: Record; ``` -Defined in: [types.ts:927](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L927) +Defined in: [packages/typescript/ai/src/types.ts:1022](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1022) -#### Overrides +#### Deprecated -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) +Use `snapshot` instead (from @ag-ui/core spec). +Kept for backward compatibility. diff --git a/docs/reference/interfaces/StepFinishedEvent.md b/docs/reference/interfaces/StepFinishedEvent.md index 4e9479c73a..d62b123670 100644 --- a/docs/reference/interfaces/StepFinishedEvent.md +++ b/docs/reference/interfaces/StepFinishedEvent.md @@ -5,13 +5,22 @@ title: StepFinishedEvent # Interface: StepFinishedEvent -Defined in: [types.ts:900](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L900) +Defined in: [packages/typescript/ai/src/types.ts:978](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L978) Emitted when a thinking/reasoning step finishes. +@ag-ui/core provides: `stepName` +TanStack AI adds: `model?`, `stepId?` (deprecated alias), `delta?`, `content?` + ## Extends -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +- `StepFinishedEvent` + +## Indexable + +```ts +[k: string]: unknown +``` ## Properties @@ -21,21 +30,21 @@ Emitted when a thinking/reasoning step finishes. optional content: string; ``` -Defined in: [types.ts:907](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L907) +Defined in: [packages/typescript/ai/src/types.ts:989](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L989) -Full accumulated thinking content (optional, for debugging) +Full accumulated thinking content (TanStack AI internal) *** -### delta +### delta? ```ts -delta: string; +optional delta: string; ``` -Defined in: [types.ts:905](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L905) +Defined in: [packages/typescript/ai/src/types.ts:987](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L987) -Incremental thinking content +Incremental thinking content (TanStack AI internal) *** @@ -45,66 +54,21 @@ Incremental thinking content optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:980](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L980) Model identifier for multi-model support -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### stepId - -```ts -stepId: string; -``` - -Defined in: [types.ts:903](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L903) - -Step identifier - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - *** -### type +### ~~stepId?~~ ```ts -type: "STEP_FINISHED"; +optional stepId: string; ``` -Defined in: [types.ts:901](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L901) +Defined in: [packages/typescript/ai/src/types.ts:985](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L985) -#### Overrides +#### Deprecated -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) +Use `stepName` instead (from @ag-ui/core spec). +Kept for backward compatibility. diff --git a/docs/reference/interfaces/StepStartedEvent.md b/docs/reference/interfaces/StepStartedEvent.md index b8b8753ec3..8eda593c16 100644 --- a/docs/reference/interfaces/StepStartedEvent.md +++ b/docs/reference/interfaces/StepStartedEvent.md @@ -5,13 +5,22 @@ title: StepStartedEvent # Interface: StepStartedEvent -Defined in: [types.ts:889](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L889) +Defined in: [packages/typescript/ai/src/types.ts:960](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L960) Emitted when a thinking/reasoning step starts. +@ag-ui/core provides: `stepName` +TanStack AI adds: `model?`, `stepId?` (deprecated alias), `stepType?` + ## Extends -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +- `StepStartedEvent` + +## Indexable + +```ts +[k: string]: unknown +``` ## Properties @@ -21,41 +30,24 @@ Emitted when a thinking/reasoning step starts. optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:962](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L962) Model identifier for multi-model support -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - *** -### rawEvent? +### ~~stepId?~~ ```ts -optional rawEvent: unknown; +optional stepId: string; ``` -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) +Defined in: [packages/typescript/ai/src/types.ts:967](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L967) -Original provider event for debugging/advanced use cases +#### Deprecated -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### stepId - -```ts -stepId: string; -``` - -Defined in: [types.ts:892](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L892) - -Unique identifier for this step +Use `stepName` instead (from @ag-ui/core spec). +Kept for backward compatibility. *** @@ -65,34 +57,6 @@ Unique identifier for this step optional stepType: string; ``` -Defined in: [types.ts:894](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L894) +Defined in: [packages/typescript/ai/src/types.ts:969](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L969) Type of step (e.g., 'thinking', 'planning') - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### type - -```ts -type: "STEP_STARTED"; -``` - -Defined in: [types.ts:890](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L890) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) diff --git a/docs/reference/interfaces/StreamProcessorEvents.md b/docs/reference/interfaces/StreamProcessorEvents.md index db6632e6e6..b476a13bbd 100644 --- a/docs/reference/interfaces/StreamProcessorEvents.md +++ b/docs/reference/interfaces/StreamProcessorEvents.md @@ -5,7 +5,7 @@ title: StreamProcessorEvents # Interface: StreamProcessorEvents -Defined in: [activities/chat/stream/processor.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L56) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L56) Events emitted by the StreamProcessor @@ -17,7 +17,7 @@ Events emitted by the StreamProcessor optional onApprovalRequest: (args) => void; ``` -Defined in: [activities/chat/stream/processor.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L71) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:71](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L71) #### Parameters @@ -51,7 +51,7 @@ Defined in: [activities/chat/stream/processor.ts:71](https://github.com/TanStack optional onCustomEvent: (eventType, data, context) => void; ``` -Defined in: [activities/chat/stream/processor.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L79) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L79) #### Parameters @@ -81,7 +81,7 @@ Defined in: [activities/chat/stream/processor.ts:79](https://github.com/TanStack optional onError: (error) => void; ``` -Defined in: [activities/chat/stream/processor.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L63) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L63) #### Parameters @@ -101,7 +101,7 @@ Defined in: [activities/chat/stream/processor.ts:63](https://github.com/TanStack optional onMessagesChange: (messages) => void; ``` -Defined in: [activities/chat/stream/processor.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L58) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L58) #### Parameters @@ -121,7 +121,7 @@ Defined in: [activities/chat/stream/processor.ts:58](https://github.com/TanStack optional onStreamEnd: (message) => void; ``` -Defined in: [activities/chat/stream/processor.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L62) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:62](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L62) #### Parameters @@ -141,7 +141,7 @@ Defined in: [activities/chat/stream/processor.ts:62](https://github.com/TanStack optional onStreamStart: () => void; ``` -Defined in: [activities/chat/stream/processor.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L61) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L61) #### Returns @@ -155,7 +155,7 @@ Defined in: [activities/chat/stream/processor.ts:61](https://github.com/TanStack optional onTextUpdate: (messageId, content) => void; ``` -Defined in: [activities/chat/stream/processor.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L86) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:86](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L86) #### Parameters @@ -179,7 +179,7 @@ Defined in: [activities/chat/stream/processor.ts:86](https://github.com/TanStack optional onThinkingUpdate: (messageId, content) => void; ``` -Defined in: [activities/chat/stream/processor.ts:93](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L93) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:93](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L93) #### Parameters @@ -203,7 +203,7 @@ Defined in: [activities/chat/stream/processor.ts:93](https://github.com/TanStack optional onToolCall: (args) => void; ``` -Defined in: [activities/chat/stream/processor.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L66) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L66) #### Parameters @@ -233,7 +233,7 @@ Defined in: [activities/chat/stream/processor.ts:66](https://github.com/TanStack optional onToolCallStateChange: (messageId, toolCallId, state, args) => void; ``` -Defined in: [activities/chat/stream/processor.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L87) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L87) #### Parameters diff --git a/docs/reference/interfaces/StreamProcessorOptions.md b/docs/reference/interfaces/StreamProcessorOptions.md index c1f60c0d2b..315c408997 100644 --- a/docs/reference/interfaces/StreamProcessorOptions.md +++ b/docs/reference/interfaces/StreamProcessorOptions.md @@ -5,7 +5,7 @@ title: StreamProcessorOptions # Interface: StreamProcessorOptions -Defined in: [activities/chat/stream/processor.ts:99](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L99) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:99](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L99) Options for StreamProcessor @@ -17,7 +17,7 @@ Options for StreamProcessor optional chunkStrategy: ChunkStrategy; ``` -Defined in: [activities/chat/stream/processor.ts:100](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L100) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:100](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L100) *** @@ -27,7 +27,7 @@ Defined in: [activities/chat/stream/processor.ts:100](https://github.com/TanStac optional events: StreamProcessorEvents; ``` -Defined in: [activities/chat/stream/processor.ts:102](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L102) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:102](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L102) Event-driven handlers @@ -39,7 +39,7 @@ Event-driven handlers optional initialMessages: UIMessage[]; ``` -Defined in: [activities/chat/stream/processor.ts:109](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L109) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:109](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L109) Initial messages to populate the processor @@ -51,7 +51,7 @@ Initial messages to populate the processor optional jsonParser: object; ``` -Defined in: [activities/chat/stream/processor.ts:103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L103) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:103](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L103) #### parse() @@ -77,6 +77,6 @@ parse: (jsonString) => any; optional recording: boolean; ``` -Defined in: [activities/chat/stream/processor.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L107) +Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L107) Enable recording for replay testing diff --git a/docs/reference/interfaces/SummarizationOptions.md b/docs/reference/interfaces/SummarizationOptions.md index 7bd31c17e2..7851fefba9 100644 --- a/docs/reference/interfaces/SummarizationOptions.md +++ b/docs/reference/interfaces/SummarizationOptions.md @@ -5,7 +5,7 @@ title: SummarizationOptions # Interface: SummarizationOptions -Defined in: [types.ts:993](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L993) +Defined in: [packages/typescript/ai/src/types.ts:1169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1169) ## Properties @@ -15,7 +15,20 @@ Defined in: [types.ts:993](https://github.com/TanStack/ai/blob/main/packages/typ optional focus: string[]; ``` -Defined in: [types.ts:998](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L998) +Defined in: [packages/typescript/ai/src/types.ts:1174](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1174) + +*** + +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1179](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1179) + +Internal logger threaded from the summarize() entry point. Adapters must +call logger.request() before the SDK call and logger.errors() in catch blocks. *** @@ -25,7 +38,7 @@ Defined in: [types.ts:998](https://github.com/TanStack/ai/blob/main/packages/typ optional maxLength: number; ``` -Defined in: [types.ts:996](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L996) +Defined in: [packages/typescript/ai/src/types.ts:1172](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1172) *** @@ -35,7 +48,7 @@ Defined in: [types.ts:996](https://github.com/TanStack/ai/blob/main/packages/typ model: string; ``` -Defined in: [types.ts:994](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L994) +Defined in: [packages/typescript/ai/src/types.ts:1170](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1170) *** @@ -45,7 +58,7 @@ Defined in: [types.ts:994](https://github.com/TanStack/ai/blob/main/packages/typ optional style: "bullet-points" | "paragraph" | "concise"; ``` -Defined in: [types.ts:997](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L997) +Defined in: [packages/typescript/ai/src/types.ts:1173](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1173) *** @@ -55,4 +68,4 @@ Defined in: [types.ts:997](https://github.com/TanStack/ai/blob/main/packages/typ text: string; ``` -Defined in: [types.ts:995](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L995) +Defined in: [packages/typescript/ai/src/types.ts:1171](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1171) diff --git a/docs/reference/interfaces/SummarizationResult.md b/docs/reference/interfaces/SummarizationResult.md index eaaf93537c..87f5d7aefa 100644 --- a/docs/reference/interfaces/SummarizationResult.md +++ b/docs/reference/interfaces/SummarizationResult.md @@ -5,7 +5,7 @@ title: SummarizationResult # Interface: SummarizationResult -Defined in: [types.ts:1001](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1001) +Defined in: [packages/typescript/ai/src/types.ts:1182](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1182) ## Properties @@ -15,7 +15,7 @@ Defined in: [types.ts:1001](https://github.com/TanStack/ai/blob/main/packages/ty id: string; ``` -Defined in: [types.ts:1002](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1002) +Defined in: [packages/typescript/ai/src/types.ts:1183](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1183) *** @@ -25,7 +25,7 @@ Defined in: [types.ts:1002](https://github.com/TanStack/ai/blob/main/packages/ty model: string; ``` -Defined in: [types.ts:1003](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1003) +Defined in: [packages/typescript/ai/src/types.ts:1184](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1184) *** @@ -35,7 +35,7 @@ Defined in: [types.ts:1003](https://github.com/TanStack/ai/blob/main/packages/ty summary: string; ``` -Defined in: [types.ts:1004](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1004) +Defined in: [packages/typescript/ai/src/types.ts:1185](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1185) *** @@ -45,7 +45,7 @@ Defined in: [types.ts:1004](https://github.com/TanStack/ai/blob/main/packages/ty usage: object; ``` -Defined in: [types.ts:1005](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1005) +Defined in: [packages/typescript/ai/src/types.ts:1186](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1186) #### completionTokens diff --git a/docs/reference/interfaces/SummarizeAdapter.md b/docs/reference/interfaces/SummarizeAdapter.md index f12aa4f663..2f0eb78b81 100644 --- a/docs/reference/interfaces/SummarizeAdapter.md +++ b/docs/reference/interfaces/SummarizeAdapter.md @@ -5,7 +5,7 @@ title: SummarizeAdapter # Interface: SummarizeAdapter\ -Defined in: [activities/summarize/adapter.ts:28](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L28) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:28](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L28) Summarize adapter interface with pre-resolved generics. @@ -34,7 +34,7 @@ Generic parameters: ~types: object; ``` -Defined in: [activities/summarize/adapter.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L42) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L42) **`Internal`** @@ -54,7 +54,7 @@ providerOptions: TProviderOptions; readonly kind: "summarize"; ``` -Defined in: [activities/summarize/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L33) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L33) Discriminator for adapter kind - used by generate() to determine API shape @@ -66,7 +66,7 @@ Discriminator for adapter kind - used by generate() to determine API shape readonly model: TModel; ``` -Defined in: [activities/summarize/adapter.ts:37](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L37) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:37](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L37) The model this adapter is configured for @@ -78,7 +78,7 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [activities/summarize/adapter.ts:35](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L35) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:35](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L35) Adapter name identifier @@ -90,7 +90,7 @@ Adapter name identifier summarize: (options) => Promise; ``` -Defined in: [activities/summarize/adapter.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L49) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L49) Summarize the given text @@ -112,7 +112,7 @@ Summarize the given text optional summarizeStream: (options) => AsyncIterable; ``` -Defined in: [activities/summarize/adapter.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L56) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L56) Stream summarization of the given text. Optional - if not implemented, the activity layer will fall back to diff --git a/docs/reference/interfaces/TTSAdapter.md b/docs/reference/interfaces/TTSAdapter.md index 83a539128b..c87865cb39 100644 --- a/docs/reference/interfaces/TTSAdapter.md +++ b/docs/reference/interfaces/TTSAdapter.md @@ -5,7 +5,7 @@ title: TTSAdapter # Interface: TTSAdapter\ -Defined in: [activities/generateSpeech/adapter.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L24) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/adapter.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L24) TTS adapter interface with pre-resolved generics. @@ -34,7 +34,7 @@ Generic parameters: ~types: object; ``` -Defined in: [activities/generateSpeech/adapter.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L38) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/adapter.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L38) **`Internal`** @@ -54,7 +54,7 @@ providerOptions: TProviderOptions; generateSpeech: (options) => Promise; ``` -Defined in: [activities/generateSpeech/adapter.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L45) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/adapter.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L45) Generate speech from text @@ -76,7 +76,7 @@ Generate speech from text readonly kind: "tts"; ``` -Defined in: [activities/generateSpeech/adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L29) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L29) Discriminator for adapter kind - used to determine API shape @@ -88,7 +88,7 @@ Discriminator for adapter kind - used to determine API shape readonly model: TModel; ``` -Defined in: [activities/generateSpeech/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L33) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L33) The model this adapter is configured for @@ -100,6 +100,6 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [activities/generateSpeech/adapter.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L31) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/adapter.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L31) Adapter name identifier diff --git a/docs/reference/interfaces/TTSOptions.md b/docs/reference/interfaces/TTSOptions.md index 15693df9ac..9ccbac1c99 100644 --- a/docs/reference/interfaces/TTSOptions.md +++ b/docs/reference/interfaces/TTSOptions.md @@ -5,7 +5,7 @@ title: TTSOptions # Interface: TTSOptions\ -Defined in: [types.ts:1142](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1142) +Defined in: [packages/typescript/ai/src/types.ts:1402](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1402) Options for text-to-speech generation. These are the common options supported across providers. @@ -24,19 +24,33 @@ These are the common options supported across providers. optional format: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm"; ``` -Defined in: [types.ts:1150](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1150) +Defined in: [packages/typescript/ai/src/types.ts:1410](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1410) The output audio format *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1420](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1420) + +Internal logger threaded from the generateSpeech() entry point. Adapters +must call logger.request() before the SDK call and logger.errors() in +catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [types.ts:1144](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1144) +Defined in: [packages/typescript/ai/src/types.ts:1404](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1404) The model to use for TTS generation @@ -48,7 +62,7 @@ The model to use for TTS generation optional modelOptions: TProviderOptions; ``` -Defined in: [types.ts:1154](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1154) +Defined in: [packages/typescript/ai/src/types.ts:1414](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1414) Model-specific options for TTS generation @@ -60,7 +74,7 @@ Model-specific options for TTS generation optional speed: number; ``` -Defined in: [types.ts:1152](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1152) +Defined in: [packages/typescript/ai/src/types.ts:1412](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1412) The speed of the generated audio (0.25 to 4.0) @@ -72,7 +86,7 @@ The speed of the generated audio (0.25 to 4.0) text: string; ``` -Defined in: [types.ts:1146](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1146) +Defined in: [packages/typescript/ai/src/types.ts:1406](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1406) The text to convert to speech @@ -84,6 +98,6 @@ The text to convert to speech optional voice: string; ``` -Defined in: [types.ts:1148](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1148) +Defined in: [packages/typescript/ai/src/types.ts:1408](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1408) The voice to use for generation diff --git a/docs/reference/interfaces/TTSResult.md b/docs/reference/interfaces/TTSResult.md index 5bb5b53681..5e341381e0 100644 --- a/docs/reference/interfaces/TTSResult.md +++ b/docs/reference/interfaces/TTSResult.md @@ -5,7 +5,7 @@ title: TTSResult # Interface: TTSResult -Defined in: [types.ts:1160](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1160) +Defined in: [packages/typescript/ai/src/types.ts:1426](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1426) Result of text-to-speech generation. @@ -17,7 +17,7 @@ Result of text-to-speech generation. audio: string; ``` -Defined in: [types.ts:1166](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1166) +Defined in: [packages/typescript/ai/src/types.ts:1432](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1432) Base64-encoded audio data @@ -29,7 +29,7 @@ Base64-encoded audio data optional contentType: string; ``` -Defined in: [types.ts:1172](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1172) +Defined in: [packages/typescript/ai/src/types.ts:1438](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1438) Content type of the audio (e.g., 'audio/mp3') @@ -41,7 +41,7 @@ Content type of the audio (e.g., 'audio/mp3') optional duration: number; ``` -Defined in: [types.ts:1170](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1170) +Defined in: [packages/typescript/ai/src/types.ts:1436](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1436) Duration of the audio in seconds, if available @@ -53,7 +53,7 @@ Duration of the audio in seconds, if available format: string; ``` -Defined in: [types.ts:1168](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1168) +Defined in: [packages/typescript/ai/src/types.ts:1434](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1434) Audio format of the generated audio @@ -65,7 +65,7 @@ Audio format of the generated audio id: string; ``` -Defined in: [types.ts:1162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1162) +Defined in: [packages/typescript/ai/src/types.ts:1428](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1428) Unique identifier for the generation @@ -77,6 +77,6 @@ Unique identifier for the generation model: string; ``` -Defined in: [types.ts:1164](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1164) +Defined in: [packages/typescript/ai/src/types.ts:1430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1430) Model used for generation diff --git a/docs/reference/interfaces/TextAdapter.md b/docs/reference/interfaces/TextAdapter.md index 36757ee208..507a26e4bf 100644 --- a/docs/reference/interfaces/TextAdapter.md +++ b/docs/reference/interfaces/TextAdapter.md @@ -3,9 +3,9 @@ id: TextAdapter title: TextAdapter --- -# Interface: TextAdapter\ +# Interface: TextAdapter\ -Defined in: [activities/chat/adapter.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L52) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:58](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L58) Text adapter interface with pre-resolved generics. @@ -17,6 +17,7 @@ Generic parameters: - TProviderOptions: Provider-specific options for this model (already resolved) - TInputModalities: Supported input modalities for this model (already resolved) - TMessageMetadata: Metadata types for content parts (already resolved) +- TToolCapabilities: Tuple of tool-kind strings supported by this model, resolved from `supports.tools` ## Type Parameters @@ -36,6 +37,10 @@ Generic parameters: `TMessageMetadataByModality` *extends* [`DefaultMessageMetadataByModality`](DefaultMessageMetadataByModality.md) +### TToolCapabilities + +`TToolCapabilities` *extends* `ReadonlyArray`\<`string`\> = `ReadonlyArray`\<`string`\> + ## Properties ### ~types @@ -44,7 +49,7 @@ Generic parameters: ~types: object; ``` -Defined in: [activities/chat/adapter.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L68) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:75](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L75) **`Internal`** @@ -68,6 +73,12 @@ messageMetadataByModality: TMessageMetadataByModality; providerOptions: TProviderOptions; ``` +#### toolCapabilities + +```ts +toolCapabilities: TToolCapabilities; +``` + *** ### chatStream() @@ -76,7 +87,7 @@ providerOptions: TProviderOptions; chatStream: (options) => AsyncIterable; ``` -Defined in: [activities/chat/adapter.ts:77](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L77) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:85](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L85) Stream text completions from the model @@ -98,7 +109,7 @@ Stream text completions from the model readonly kind: "text"; ``` -Defined in: [activities/chat/adapter.ts:59](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L59) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:66](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L66) Discriminator for adapter kind @@ -110,7 +121,7 @@ Discriminator for adapter kind readonly model: TModel; ``` -Defined in: [activities/chat/adapter.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L63) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:70](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L70) The model this adapter is configured for @@ -122,7 +133,7 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [activities/chat/adapter.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L61) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L68) Provider name identifier (e.g., 'openai', 'anthropic') @@ -134,7 +145,7 @@ Provider name identifier (e.g., 'openai', 'anthropic') structuredOutput: (options) => Promise>; ``` -Defined in: [activities/chat/adapter.ts:89](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L89) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:97](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L97) Generate structured output using the provider's native structured output API. This method uses stream: false and sends the JSON schema to the provider diff --git a/docs/reference/interfaces/TextCompletionChunk.md b/docs/reference/interfaces/TextCompletionChunk.md index b6db0ff39a..d6c788d9bf 100644 --- a/docs/reference/interfaces/TextCompletionChunk.md +++ b/docs/reference/interfaces/TextCompletionChunk.md @@ -5,7 +5,7 @@ title: TextCompletionChunk # Interface: TextCompletionChunk -Defined in: [types.ts:980](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L980) +Defined in: [packages/typescript/ai/src/types.ts:1156](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1156) ## Properties @@ -15,7 +15,7 @@ Defined in: [types.ts:980](https://github.com/TanStack/ai/blob/main/packages/typ content: string; ``` -Defined in: [types.ts:983](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L983) +Defined in: [packages/typescript/ai/src/types.ts:1159](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1159) *** @@ -25,7 +25,7 @@ Defined in: [types.ts:983](https://github.com/TanStack/ai/blob/main/packages/typ optional finishReason: "length" | "stop" | "content_filter" | null; ``` -Defined in: [types.ts:985](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L985) +Defined in: [packages/typescript/ai/src/types.ts:1161](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1161) *** @@ -35,7 +35,7 @@ Defined in: [types.ts:985](https://github.com/TanStack/ai/blob/main/packages/typ id: string; ``` -Defined in: [types.ts:981](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L981) +Defined in: [packages/typescript/ai/src/types.ts:1157](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1157) *** @@ -45,7 +45,7 @@ Defined in: [types.ts:981](https://github.com/TanStack/ai/blob/main/packages/typ model: string; ``` -Defined in: [types.ts:982](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L982) +Defined in: [packages/typescript/ai/src/types.ts:1158](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1158) *** @@ -55,7 +55,7 @@ Defined in: [types.ts:982](https://github.com/TanStack/ai/blob/main/packages/typ optional role: "assistant"; ``` -Defined in: [types.ts:984](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L984) +Defined in: [packages/typescript/ai/src/types.ts:1160](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1160) *** @@ -65,7 +65,7 @@ Defined in: [types.ts:984](https://github.com/TanStack/ai/blob/main/packages/typ optional usage: object; ``` -Defined in: [types.ts:986](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L986) +Defined in: [packages/typescript/ai/src/types.ts:1162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1162) #### completionTokens diff --git a/docs/reference/interfaces/TextMessageContentEvent.md b/docs/reference/interfaces/TextMessageContentEvent.md index d09dc5573f..5e254bfca6 100644 --- a/docs/reference/interfaces/TextMessageContentEvent.md +++ b/docs/reference/interfaces/TextMessageContentEvent.md @@ -5,49 +5,34 @@ title: TextMessageContentEvent # Interface: TextMessageContentEvent -Defined in: [types.ts:822](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L822) +Defined in: [packages/typescript/ai/src/types.ts:870](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L870) Emitted when text content is generated (streaming tokens). -## Extends - -- [`BaseAGUIEvent`](BaseAGUIEvent.md) - -## Properties +@ag-ui/core provides: `messageId`, `delta` +TanStack AI adds: `model?`, `content?` (accumulated) -### content? - -```ts -optional content: string; -``` - -Defined in: [types.ts:829](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L829) - -Full accumulated content so far (optional, for debugging) +## Extends -*** +- `TextMessageContentEvent` -### delta +## Indexable ```ts -delta: string; +[k: string]: unknown ``` -Defined in: [types.ts:827](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L827) - -The incremental content token - -*** +## Properties -### messageId +### content? ```ts -messageId: string; +optional content: string; ``` -Defined in: [types.ts:825](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L825) +Defined in: [packages/typescript/ai/src/types.ts:874](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L874) -Message identifier +Full accumulated content so far (TanStack AI internal, for debugging) *** @@ -57,54 +42,6 @@ Message identifier optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:872](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L872) Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### type - -```ts -type: "TEXT_MESSAGE_CONTENT"; -``` - -Defined in: [types.ts:823](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L823) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) diff --git a/docs/reference/interfaces/TextMessageEndEvent.md b/docs/reference/interfaces/TextMessageEndEvent.md index 66e6c64c9f..1cfbed6dcd 100644 --- a/docs/reference/interfaces/TextMessageEndEvent.md +++ b/docs/reference/interfaces/TextMessageEndEvent.md @@ -5,27 +5,24 @@ title: TextMessageEndEvent # Interface: TextMessageEndEvent -Defined in: [types.ts:835](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L835) +Defined in: [packages/typescript/ai/src/types.ts:883](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L883) Emitted when a text message completes. -## Extends +@ag-ui/core provides: `messageId` +TanStack AI adds: `model?` -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +## Extends -## Properties +- `TextMessageEndEvent` -### messageId +## Indexable ```ts -messageId: string; +[k: string]: unknown ``` -Defined in: [types.ts:838](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L838) - -Message identifier - -*** +## Properties ### model? @@ -33,54 +30,6 @@ Message identifier optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:885](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L885) Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### type - -```ts -type: "TEXT_MESSAGE_END"; -``` - -Defined in: [types.ts:836](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L836) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) diff --git a/docs/reference/interfaces/TextMessageStartEvent.md b/docs/reference/interfaces/TextMessageStartEvent.md index ea46f73a4e..22fb7998e1 100644 --- a/docs/reference/interfaces/TextMessageStartEvent.md +++ b/docs/reference/interfaces/TextMessageStartEvent.md @@ -5,27 +5,24 @@ title: TextMessageStartEvent # Interface: TextMessageStartEvent -Defined in: [types.ts:811](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L811) +Defined in: [packages/typescript/ai/src/types.ts:859](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L859) Emitted when a text message starts. -## Extends +@ag-ui/core provides: `messageId`, `role?`, `name?` +TanStack AI adds: `model?` -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +## Extends -## Properties +- `TextMessageStartEvent` -### messageId +## Indexable ```ts -messageId: string; +[k: string]: unknown ``` -Defined in: [types.ts:814](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L814) - -Unique identifier for this message - -*** +## Properties ### model? @@ -33,66 +30,6 @@ Unique identifier for this message optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:861](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L861) Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### role - -```ts -role: "user" | "assistant" | "tool" | "system"; -``` - -Defined in: [types.ts:816](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L816) - -Role of the message sender - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### type - -```ts -type: "TEXT_MESSAGE_START"; -``` - -Defined in: [types.ts:812](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L812) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) diff --git a/docs/reference/interfaces/TextOptions.md b/docs/reference/interfaces/TextOptions.md index 77c882f7b1..803bdd8f04 100644 --- a/docs/reference/interfaces/TextOptions.md +++ b/docs/reference/interfaces/TextOptions.md @@ -5,7 +5,7 @@ title: TextOptions # Interface: TextOptions\ -Defined in: [types.ts:630](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L630) +Defined in: [packages/typescript/ai/src/types.ts:657](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L657) Options passed into the SDK and further piped to the AI provider. @@ -27,7 +27,7 @@ Options passed into the SDK and further piped to the AI provider. optional abortController: AbortController; ``` -Defined in: [types.ts:714](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L714) +Defined in: [packages/typescript/ai/src/types.ts:741](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L741) AbortController for request cancellation. @@ -54,7 +54,7 @@ https://developer.mozilla.org/en-US/docs/Web/API/AbortController optional agentLoopStrategy: AgentLoopStrategy; ``` -Defined in: [types.ts:638](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L638) +Defined in: [packages/typescript/ai/src/types.ts:665](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L665) *** @@ -64,20 +64,34 @@ Defined in: [types.ts:638](https://github.com/TanStack/ai/blob/main/packages/typ optional conversationId: string; ``` -Defined in: [types.ts:700](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L700) +Defined in: [packages/typescript/ai/src/types.ts:727](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L727) Conversation ID for correlating client and server-side devtools events. When provided, server-side events will be linked to the client conversation in devtools. *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:748](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L748) + +Internal logger threaded from the chat entry point. Adapter implementations +must call `logger.request()` before SDK calls, `logger.provider()` for each +chunk received, and `logger.errors()` in catch blocks. + +*** + ### maxTokens? ```ts optional maxTokens: number; ``` -Defined in: [types.ts:673](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L673) +Defined in: [packages/typescript/ai/src/types.ts:700](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L700) The maximum number of tokens to generate in the response. @@ -97,7 +111,7 @@ messages: ModelMessage< | null>[]; ``` -Defined in: [types.ts:635](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L635) +Defined in: [packages/typescript/ai/src/types.ts:662](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L662) *** @@ -107,7 +121,7 @@ Defined in: [types.ts:635](https://github.com/TanStack/ai/blob/main/packages/typ optional metadata: Record; ``` -Defined in: [types.ts:684](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L684) +Defined in: [packages/typescript/ai/src/types.ts:711](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L711) Additional metadata to attach to the request. Can be used for tracking, debugging, or passing custom information. @@ -126,7 +140,7 @@ Provider usage: model: string; ``` -Defined in: [types.ts:634](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L634) +Defined in: [packages/typescript/ai/src/types.ts:661](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L661) *** @@ -136,7 +150,7 @@ Defined in: [types.ts:634](https://github.com/TanStack/ai/blob/main/packages/typ optional modelOptions: TProviderOptionsForModel; ``` -Defined in: [types.ts:685](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L685) +Defined in: [packages/typescript/ai/src/types.ts:712](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L712) *** @@ -146,7 +160,7 @@ Defined in: [types.ts:685](https://github.com/TanStack/ai/blob/main/packages/typ optional outputSchema: SchemaInput; ``` -Defined in: [types.ts:695](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L695) +Defined in: [packages/typescript/ai/src/types.ts:722](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L722) Schema for structured output. When provided, the adapter should use the provider's native structured output API @@ -162,7 +176,21 @@ Supports any Standard JSON Schema compliant library (Zod, ArkType, Valibot, etc. optional request: Request | RequestInit; ``` -Defined in: [types.ts:686](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L686) +Defined in: [packages/typescript/ai/src/types.ts:713](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L713) + +*** + +### runId? + +```ts +optional runId: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:760](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L760) + +Run ID for AG-UI protocol run correlation. +When provided, this will be used in RunStartedEvent and RunFinishedEvent. +If not provided, a unique ID will be generated. *** @@ -172,7 +200,7 @@ Defined in: [types.ts:686](https://github.com/TanStack/ai/blob/main/packages/typ optional systemPrompts: string[]; ``` -Defined in: [types.ts:637](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L637) +Defined in: [packages/typescript/ai/src/types.ts:664](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L664) *** @@ -182,7 +210,7 @@ Defined in: [types.ts:637](https://github.com/TanStack/ai/blob/main/packages/typ optional temperature: number; ``` -Defined in: [types.ts:651](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L651) +Defined in: [packages/typescript/ai/src/types.ts:678](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L678) Controls the randomness of the output. Higher values (e.g., 0.8) make output more random, lower values (e.g., 0.2) make it more focused and deterministic. @@ -197,13 +225,26 @@ Provider usage: *** +### threadId? + +```ts +optional threadId: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) + +Thread ID for AG-UI protocol run correlation. +When provided, this will be used in RunStartedEvent and RunFinishedEvent. + +*** + ### tools? ```ts optional tools: Tool[]; ``` -Defined in: [types.ts:636](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L636) +Defined in: [packages/typescript/ai/src/types.ts:663](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L663) *** @@ -213,7 +254,7 @@ Defined in: [types.ts:636](https://github.com/TanStack/ai/blob/main/packages/typ optional topP: number; ``` -Defined in: [types.ts:664](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L664) +Defined in: [packages/typescript/ai/src/types.ts:691](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L691) Nucleus sampling parameter. An alternative to temperature sampling. The model considers the results of tokens with topP probability mass. diff --git a/docs/reference/interfaces/TextPart.md b/docs/reference/interfaces/TextPart.md index ca069c0fdb..f2d33db710 100644 --- a/docs/reference/interfaces/TextPart.md +++ b/docs/reference/interfaces/TextPart.md @@ -5,7 +5,7 @@ title: TextPart # Interface: TextPart\ -Defined in: [types.ts:278](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L278) +Defined in: [packages/typescript/ai/src/types.ts:305](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L305) Message parts - building blocks of UIMessage @@ -23,7 +23,7 @@ Message parts - building blocks of UIMessage content: string; ``` -Defined in: [types.ts:280](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L280) +Defined in: [packages/typescript/ai/src/types.ts:307](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L307) *** @@ -33,7 +33,7 @@ Defined in: [types.ts:280](https://github.com/TanStack/ai/blob/main/packages/typ optional metadata: TMetadata; ``` -Defined in: [types.ts:281](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L281) +Defined in: [packages/typescript/ai/src/types.ts:308](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L308) *** @@ -43,4 +43,4 @@ Defined in: [types.ts:281](https://github.com/TanStack/ai/blob/main/packages/typ type: "text"; ``` -Defined in: [types.ts:279](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L279) +Defined in: [packages/typescript/ai/src/types.ts:306](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L306) diff --git a/docs/reference/interfaces/ThinkingPart.md b/docs/reference/interfaces/ThinkingPart.md index 3827e60dd4..2a0eac96ed 100644 --- a/docs/reference/interfaces/ThinkingPart.md +++ b/docs/reference/interfaces/ThinkingPart.md @@ -5,7 +5,7 @@ title: ThinkingPart # Interface: ThinkingPart -Defined in: [types.ts:308](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L308) +Defined in: [packages/typescript/ai/src/types.ts:335](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L335) ## Properties @@ -15,7 +15,7 @@ Defined in: [types.ts:308](https://github.com/TanStack/ai/blob/main/packages/typ content: string; ``` -Defined in: [types.ts:310](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L310) +Defined in: [packages/typescript/ai/src/types.ts:337](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L337) *** @@ -25,4 +25,4 @@ Defined in: [types.ts:310](https://github.com/TanStack/ai/blob/main/packages/typ type: "thinking"; ``` -Defined in: [types.ts:309](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L309) +Defined in: [packages/typescript/ai/src/types.ts:336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L336) diff --git a/docs/reference/interfaces/Tool.md b/docs/reference/interfaces/Tool.md index 73f410f2c6..fa7071cb34 100644 --- a/docs/reference/interfaces/Tool.md +++ b/docs/reference/interfaces/Tool.md @@ -5,7 +5,7 @@ title: Tool # Interface: Tool\ -Defined in: [types.ts:390](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L390) +Defined in: [packages/typescript/ai/src/types.ts:417](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L417) Tool/Function definition for function calling. @@ -25,6 +25,7 @@ or plain JSON Schema objects for runtime validation and type safety. - [`ToolDefinitionInstance`](ToolDefinitionInstance.md) - [`ServerTool`](ServerTool.md) +- [`ProviderTool`](ProviderTool.md) ## Type Parameters @@ -48,7 +49,7 @@ or plain JSON Schema objects for runtime validation and type safety. description: string; ``` -Defined in: [types.ts:413](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L413) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -69,7 +70,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [types.ts:493](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L493) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -113,7 +114,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [types.ts:453](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L453) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -167,7 +168,7 @@ type({ optional lazy: boolean; ``` -Defined in: [types.ts:499](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L499) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -179,7 +180,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [types.ts:502](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L502) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -191,7 +192,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [types.ts:403](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L403) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -212,7 +213,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [types.ts:496](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L496) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -224,7 +225,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [types.ts:474](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L474) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/ToolCall.md b/docs/reference/interfaces/ToolCall.md index e3bf10ca20..9ca298739b 100644 --- a/docs/reference/interfaces/ToolCall.md +++ b/docs/reference/interfaces/ToolCall.md @@ -5,7 +5,7 @@ title: ToolCall # Interface: ToolCall -Defined in: [types.ts:87](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L87) +Defined in: [packages/typescript/ai/src/types.ts:114](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L114) ## Properties @@ -15,7 +15,7 @@ Defined in: [types.ts:87](https://github.com/TanStack/ai/blob/main/packages/type function: object; ``` -Defined in: [types.ts:90](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L90) +Defined in: [packages/typescript/ai/src/types.ts:117](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L117) #### arguments @@ -37,7 +37,7 @@ name: string; id: string; ``` -Defined in: [types.ts:88](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L88) +Defined in: [packages/typescript/ai/src/types.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L115) *** @@ -47,7 +47,7 @@ Defined in: [types.ts:88](https://github.com/TanStack/ai/blob/main/packages/type optional providerMetadata: Record; ``` -Defined in: [types.ts:95](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L95) +Defined in: [packages/typescript/ai/src/types.ts:122](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L122) Provider-specific metadata to carry through the tool call lifecycle @@ -59,4 +59,4 @@ Provider-specific metadata to carry through the tool call lifecycle type: "function"; ``` -Defined in: [types.ts:89](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L89) +Defined in: [packages/typescript/ai/src/types.ts:116](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L116) diff --git a/docs/reference/interfaces/ToolCallArgsEvent.md b/docs/reference/interfaces/ToolCallArgsEvent.md index 54760a5277..78065958cf 100644 --- a/docs/reference/interfaces/ToolCallArgsEvent.md +++ b/docs/reference/interfaces/ToolCallArgsEvent.md @@ -5,37 +5,34 @@ title: ToolCallArgsEvent # Interface: ToolCallArgsEvent -Defined in: [types.ts:861](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L861) +Defined in: [packages/typescript/ai/src/types.ts:914](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L914) Emitted when tool call arguments are streaming. -## Extends +@ag-ui/core provides: `toolCallId`, `delta` +TanStack AI adds: `model?`, `args?` (accumulated) -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +## Extends -## Properties +- `ToolCallArgsEvent` -### args? +## Indexable ```ts -optional args: string; +[k: string]: unknown ``` -Defined in: [types.ts:868](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L868) - -Full accumulated arguments so far - -*** +## Properties -### delta +### args? ```ts -delta: string; +optional args: string; ``` -Defined in: [types.ts:866](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L866) +Defined in: [packages/typescript/ai/src/types.ts:918](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L918) -Incremental JSON arguments delta +Full accumulated arguments so far (TanStack AI internal) *** @@ -45,66 +42,6 @@ Incremental JSON arguments delta optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:916](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L916) Model identifier for multi-model support - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### toolCallId - -```ts -toolCallId: string; -``` - -Defined in: [types.ts:864](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L864) - -Tool call identifier - -*** - -### type - -```ts -type: "TOOL_CALL_ARGS"; -``` - -Defined in: [types.ts:862](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L862) - -#### Overrides - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) diff --git a/docs/reference/interfaces/ToolCallEndEvent.md b/docs/reference/interfaces/ToolCallEndEvent.md index 5e5b8d3af2..151d22e12e 100644 --- a/docs/reference/interfaces/ToolCallEndEvent.md +++ b/docs/reference/interfaces/ToolCallEndEvent.md @@ -5,13 +5,22 @@ title: ToolCallEndEvent # Interface: ToolCallEndEvent -Defined in: [types.ts:874](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L874) +Defined in: [packages/typescript/ai/src/types.ts:927](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L927) Emitted when a tool call completes. +@ag-ui/core provides: `toolCallId` +TanStack AI adds: `model?`, `toolCallName?`, `toolName?` (deprecated), `input?`, `result?` + ## Extends -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +- `ToolCallEndEvent` + +## Indexable + +```ts +[k: string]: unknown +``` ## Properties @@ -21,9 +30,9 @@ Emitted when a tool call completes. optional input: unknown; ``` -Defined in: [types.ts:881](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L881) +Defined in: [packages/typescript/ai/src/types.ts:938](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L938) -Final parsed input arguments +Final parsed input arguments (TanStack AI internal) *** @@ -33,30 +42,10 @@ Final parsed input arguments optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:929](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L929) Model identifier for multi-model support -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - *** ### result? @@ -65,58 +54,33 @@ Original provider event for debugging/advanced use cases optional result: string; ``` -Defined in: [types.ts:883](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L883) - -Tool execution result (if executed) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### toolCallId - -```ts -toolCallId: string; -``` - -Defined in: [types.ts:877](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L877) +Defined in: [packages/typescript/ai/src/types.ts:940](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L940) -Tool call identifier +Tool execution result (TanStack AI internal) *** -### toolName +### toolCallName? ```ts -toolName: string; +optional toolCallName: string; ``` -Defined in: [types.ts:879](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L879) +Defined in: [packages/typescript/ai/src/types.ts:931](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L931) -Name of the tool +Name of the tool that completed *** -### type +### ~~toolName?~~ ```ts -type: "TOOL_CALL_END"; +optional toolName: string; ``` -Defined in: [types.ts:875](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L875) +Defined in: [packages/typescript/ai/src/types.ts:936](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L936) -#### Overrides +#### Deprecated -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) +Use `toolCallName` instead. +Kept for backward compatibility. diff --git a/docs/reference/interfaces/ToolCallHookContext.md b/docs/reference/interfaces/ToolCallHookContext.md index 7e4f59c5ab..11e0e650b6 100644 --- a/docs/reference/interfaces/ToolCallHookContext.md +++ b/docs/reference/interfaces/ToolCallHookContext.md @@ -5,7 +5,7 @@ title: ToolCallHookContext # Interface: ToolCallHookContext -Defined in: [activities/chat/middleware/types.ts:123](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L123) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:123](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L123) Context provided to tool call hooks (onBeforeToolCall / onAfterToolCall). @@ -17,7 +17,7 @@ Context provided to tool call hooks (onBeforeToolCall / onAfterToolCall). args: unknown; ``` -Defined in: [activities/chat/middleware/types.ts:129](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L129) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:129](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L129) Parsed arguments for the tool call @@ -31,7 +31,7 @@ tool: | undefined; ``` -Defined in: [activities/chat/middleware/types.ts:127](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L127) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:127](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L127) The resolved tool definition, if found @@ -43,7 +43,7 @@ The resolved tool definition, if found toolCall: ToolCall; ``` -Defined in: [activities/chat/middleware/types.ts:125](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L125) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:125](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L125) The tool call being executed @@ -55,7 +55,7 @@ The tool call being executed toolCallId: string; ``` -Defined in: [activities/chat/middleware/types.ts:133](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L133) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:133](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L133) ID of the tool call @@ -67,6 +67,6 @@ ID of the tool call toolName: string; ``` -Defined in: [activities/chat/middleware/types.ts:131](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L131) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:131](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L131) Name of the tool diff --git a/docs/reference/interfaces/ToolCallPart.md b/docs/reference/interfaces/ToolCallPart.md index 5da0fff510..587147737f 100644 --- a/docs/reference/interfaces/ToolCallPart.md +++ b/docs/reference/interfaces/ToolCallPart.md @@ -5,7 +5,7 @@ title: ToolCallPart # Interface: ToolCallPart -Defined in: [types.ts:284](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L284) +Defined in: [packages/typescript/ai/src/types.ts:311](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L311) ## Properties @@ -15,7 +15,7 @@ Defined in: [types.ts:284](https://github.com/TanStack/ai/blob/main/packages/typ optional approval: object; ``` -Defined in: [types.ts:291](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L291) +Defined in: [packages/typescript/ai/src/types.ts:318](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L318) Approval metadata if tool requires user approval @@ -45,7 +45,7 @@ needsApproval: boolean; arguments: string; ``` -Defined in: [types.ts:288](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L288) +Defined in: [packages/typescript/ai/src/types.ts:315](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L315) *** @@ -55,7 +55,7 @@ Defined in: [types.ts:288](https://github.com/TanStack/ai/blob/main/packages/typ id: string; ``` -Defined in: [types.ts:286](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L286) +Defined in: [packages/typescript/ai/src/types.ts:313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L313) *** @@ -65,7 +65,7 @@ Defined in: [types.ts:286](https://github.com/TanStack/ai/blob/main/packages/typ name: string; ``` -Defined in: [types.ts:287](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L287) +Defined in: [packages/typescript/ai/src/types.ts:314](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L314) *** @@ -75,7 +75,7 @@ Defined in: [types.ts:287](https://github.com/TanStack/ai/blob/main/packages/typ optional output: any; ``` -Defined in: [types.ts:297](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L297) +Defined in: [packages/typescript/ai/src/types.ts:324](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L324) Tool execution output (for client tools or after approval) @@ -87,7 +87,7 @@ Tool execution output (for client tools or after approval) state: ToolCallState; ``` -Defined in: [types.ts:289](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L289) +Defined in: [packages/typescript/ai/src/types.ts:316](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L316) *** @@ -97,4 +97,4 @@ Defined in: [types.ts:289](https://github.com/TanStack/ai/blob/main/packages/typ type: "tool-call"; ``` -Defined in: [types.ts:285](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L285) +Defined in: [packages/typescript/ai/src/types.ts:312](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L312) diff --git a/docs/reference/interfaces/ToolCallResultEvent.md b/docs/reference/interfaces/ToolCallResultEvent.md new file mode 100644 index 0000000000..d30915c7c4 --- /dev/null +++ b/docs/reference/interfaces/ToolCallResultEvent.md @@ -0,0 +1,35 @@ +--- +id: ToolCallResultEvent +title: ToolCallResultEvent +--- + +# Interface: ToolCallResultEvent + +Defined in: [packages/typescript/ai/src/types.ts:949](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L949) + +Emitted when a tool call result is available. + +@ag-ui/core provides: `messageId`, `toolCallId`, `content`, `role?` +TanStack AI adds: `model?` + +## Extends + +- `ToolCallResultEvent` + +## Indexable + +```ts +[k: string]: unknown +``` + +## Properties + +### model? + +```ts +optional model: string; +``` + +Defined in: [packages/typescript/ai/src/types.ts:951](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L951) + +Model identifier for multi-model support diff --git a/docs/reference/interfaces/ToolCallStartEvent.md b/docs/reference/interfaces/ToolCallStartEvent.md index eb1d44e979..910719f6e9 100644 --- a/docs/reference/interfaces/ToolCallStartEvent.md +++ b/docs/reference/interfaces/ToolCallStartEvent.md @@ -5,13 +5,22 @@ title: ToolCallStartEvent # Interface: ToolCallStartEvent -Defined in: [types.ts:844](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L844) +Defined in: [packages/typescript/ai/src/types.ts:894](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L894) Emitted when a tool call starts. +@ag-ui/core provides: `toolCallId`, `toolCallName`, `parentMessageId?` +TanStack AI adds: `model?`, `toolName` (deprecated alias), `index?`, `providerMetadata?` + ## Extends -- [`BaseAGUIEvent`](BaseAGUIEvent.md) +- `ToolCallStartEvent` + +## Indexable + +```ts +[k: string]: unknown +``` ## Properties @@ -21,7 +30,7 @@ Emitted when a tool call starts. optional index: number; ``` -Defined in: [types.ts:853](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L853) +Defined in: [packages/typescript/ai/src/types.ts:903](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L903) Index for parallel tool calls @@ -33,26 +42,10 @@ Index for parallel tool calls optional model: string; ``` -Defined in: [types.ts:756](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L756) +Defined in: [packages/typescript/ai/src/types.ts:896](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L896) Model identifier for multi-model support -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`model`](BaseAGUIEvent.md#model) - -*** - -### parentMessageId? - -```ts -optional parentMessageId: string; -``` - -Defined in: [types.ts:851](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L851) - -ID of the parent message that initiated this tool call - *** ### providerMetadata? @@ -61,74 +54,21 @@ ID of the parent message that initiated this tool call optional providerMetadata: Record; ``` -Defined in: [types.ts:855](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L855) +Defined in: [packages/typescript/ai/src/types.ts:905](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L905) Provider-specific metadata to carry into the ToolCall *** -### rawEvent? - -```ts -optional rawEvent: unknown; -``` - -Defined in: [types.ts:758](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L758) - -Original provider event for debugging/advanced use cases - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`rawEvent`](BaseAGUIEvent.md#rawevent) - -*** - -### timestamp - -```ts -timestamp: number; -``` - -Defined in: [types.ts:754](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L754) - -#### Inherited from - -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`timestamp`](BaseAGUIEvent.md#timestamp) - -*** - -### toolCallId - -```ts -toolCallId: string; -``` - -Defined in: [types.ts:847](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L847) - -Unique identifier for this tool call - -*** - -### toolName +### ~~toolName~~ ```ts toolName: string; ``` -Defined in: [types.ts:849](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L849) - -Name of the tool being called - -*** - -### type - -```ts -type: "TOOL_CALL_START"; -``` - -Defined in: [types.ts:845](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L845) +Defined in: [packages/typescript/ai/src/types.ts:901](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L901) -#### Overrides +#### Deprecated -[`BaseAGUIEvent`](BaseAGUIEvent.md).[`type`](BaseAGUIEvent.md#type) +Use `toolCallName` instead (from @ag-ui/core spec). +Kept for backward compatibility. diff --git a/docs/reference/interfaces/ToolConfig.md b/docs/reference/interfaces/ToolConfig.md index fdb75236a8..8536a21e8f 100644 --- a/docs/reference/interfaces/ToolConfig.md +++ b/docs/reference/interfaces/ToolConfig.md @@ -5,7 +5,7 @@ title: ToolConfig # Interface: ToolConfig -Defined in: [types.ts:505](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L505) +Defined in: [packages/typescript/ai/src/types.ts:532](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L532) ## Indexable diff --git a/docs/reference/interfaces/ToolDefinition.md b/docs/reference/interfaces/ToolDefinition.md index 638502b4af..bd1443841a 100644 --- a/docs/reference/interfaces/ToolDefinition.md +++ b/docs/reference/interfaces/ToolDefinition.md @@ -5,7 +5,7 @@ title: ToolDefinition # Interface: ToolDefinition\ -Defined in: [activities/chat/tools/tool-definition.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L107) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:107](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L107) Tool definition builder that allows creating server or client tools from a shared definition @@ -35,7 +35,7 @@ Tool definition builder that allows creating server or client tools from a share __toolSide: "definition"; ``` -Defined in: [activities/chat/tools/tool-definition.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L50) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L50) #### Inherited from @@ -49,7 +49,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:50](https://github.com/Tan client: (execute?) => ClientTool; ``` -Defined in: [activities/chat/tools/tool-definition.ts:125](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L125) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:125](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L125) Create a client-side tool with optional execute function @@ -73,7 +73,7 @@ Create a client-side tool with optional execute function description: string; ``` -Defined in: [types.ts:413](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L413) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -98,7 +98,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [types.ts:493](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L493) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -146,7 +146,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [types.ts:453](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L453) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -204,7 +204,7 @@ type({ optional lazy: boolean; ``` -Defined in: [types.ts:499](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L499) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -220,7 +220,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [types.ts:502](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L502) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -236,7 +236,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [types.ts:403](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L403) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -261,7 +261,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [types.ts:496](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L496) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -277,7 +277,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [types.ts:474](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L474) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. @@ -312,7 +312,7 @@ z.object({ server: (execute) => ServerTool; ``` -Defined in: [activities/chat/tools/tool-definition.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L115) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L115) Create a server-side tool with execute function diff --git a/docs/reference/interfaces/ToolDefinitionConfig.md b/docs/reference/interfaces/ToolDefinitionConfig.md index fd27e25812..3d2fd25e0b 100644 --- a/docs/reference/interfaces/ToolDefinitionConfig.md +++ b/docs/reference/interfaces/ToolDefinitionConfig.md @@ -5,7 +5,7 @@ title: ToolDefinitionConfig # Interface: ToolDefinitionConfig\ -Defined in: [activities/chat/tools/tool-definition.ts:90](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L90) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:90](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L90) Tool definition configuration @@ -31,7 +31,7 @@ Tool definition configuration description: string; ``` -Defined in: [activities/chat/tools/tool-definition.ts:96](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L96) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:96](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L96) *** @@ -41,7 +41,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:96](https://github.com/Tan optional inputSchema: TInput; ``` -Defined in: [activities/chat/tools/tool-definition.ts:97](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L97) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:97](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L97) *** @@ -51,7 +51,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:97](https://github.com/Tan optional lazy: boolean; ``` -Defined in: [activities/chat/tools/tool-definition.ts:100](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L100) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:100](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L100) *** @@ -61,7 +61,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:100](https://github.com/Ta optional metadata: Record; ``` -Defined in: [activities/chat/tools/tool-definition.ts:101](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L101) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:101](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L101) *** @@ -71,7 +71,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:101](https://github.com/Ta name: TName; ``` -Defined in: [activities/chat/tools/tool-definition.ts:95](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L95) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:95](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L95) *** @@ -81,7 +81,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:95](https://github.com/Tan optional needsApproval: boolean; ``` -Defined in: [activities/chat/tools/tool-definition.ts:99](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L99) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:99](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L99) *** @@ -91,4 +91,4 @@ Defined in: [activities/chat/tools/tool-definition.ts:99](https://github.com/Tan optional outputSchema: TOutput; ``` -Defined in: [activities/chat/tools/tool-definition.ts:98](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L98) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:98](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L98) diff --git a/docs/reference/interfaces/ToolDefinitionInstance.md b/docs/reference/interfaces/ToolDefinitionInstance.md index 3499e65f6b..397adaa715 100644 --- a/docs/reference/interfaces/ToolDefinitionInstance.md +++ b/docs/reference/interfaces/ToolDefinitionInstance.md @@ -5,7 +5,7 @@ title: ToolDefinitionInstance # Interface: ToolDefinitionInstance\ -Defined in: [activities/chat/tools/tool-definition.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L45) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L45) Tool definition that can be used directly or instantiated for server/client @@ -39,7 +39,7 @@ Tool definition that can be used directly or instantiated for server/client __toolSide: "definition"; ``` -Defined in: [activities/chat/tools/tool-definition.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L50) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L50) *** @@ -49,7 +49,7 @@ Defined in: [activities/chat/tools/tool-definition.ts:50](https://github.com/Tan description: string; ``` -Defined in: [types.ts:413](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L413) +Defined in: [packages/typescript/ai/src/types.ts:440](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L440) Clear description of what the tool does. @@ -74,7 +74,7 @@ Be specific about what the tool does, what parameters it needs, and what it retu optional execute: (args, context?) => any; ``` -Defined in: [types.ts:493](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L493) +Defined in: [packages/typescript/ai/src/types.ts:520](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L520) Optional function to execute when the model calls this tool. @@ -122,7 +122,7 @@ execute: async (args) => { optional inputSchema: TInput; ``` -Defined in: [types.ts:453](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L453) +Defined in: [packages/typescript/ai/src/types.ts:480](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L480) Schema describing the tool's input parameters. @@ -180,7 +180,7 @@ type({ optional lazy: boolean; ``` -Defined in: [types.ts:499](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L499) +Defined in: [packages/typescript/ai/src/types.ts:526](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L526) If true, this tool is lazy and will only be sent to the LLM after being discovered via the lazy tool discovery mechanism. Only meaningful when used with chat(). @@ -196,7 +196,7 @@ If true, this tool is lazy and will only be sent to the LLM after being discover optional metadata: Record; ``` -Defined in: [types.ts:502](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L502) +Defined in: [packages/typescript/ai/src/types.ts:529](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L529) Additional metadata for adapters or custom extensions @@ -212,7 +212,7 @@ Additional metadata for adapters or custom extensions name: TName; ``` -Defined in: [types.ts:403](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L403) +Defined in: [packages/typescript/ai/src/types.ts:430](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L430) Unique name of the tool (used by the model to call it). @@ -237,7 +237,7 @@ Must be unique within the tools array. optional needsApproval: boolean; ``` -Defined in: [types.ts:496](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L496) +Defined in: [packages/typescript/ai/src/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L523) If true, tool execution requires user approval before running. Works with both server and client tools. @@ -253,7 +253,7 @@ If true, tool execution requires user approval before running. Works with both s optional outputSchema: TOutput; ``` -Defined in: [types.ts:474](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L474) +Defined in: [packages/typescript/ai/src/types.ts:501](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L501) Optional schema for validating tool output. diff --git a/docs/reference/interfaces/ToolExecutionContext.md b/docs/reference/interfaces/ToolExecutionContext.md index 25c9911056..6b06c4eadc 100644 --- a/docs/reference/interfaces/ToolExecutionContext.md +++ b/docs/reference/interfaces/ToolExecutionContext.md @@ -5,7 +5,7 @@ title: ToolExecutionContext # Interface: ToolExecutionContext -Defined in: [types.ts:353](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L353) +Defined in: [packages/typescript/ai/src/types.ts:380](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L380) Context passed to tool execute functions, providing capabilities like emitting custom events during execution. @@ -18,7 +18,7 @@ emitting custom events during execution. emitCustomEvent: (eventName, value) => void; ``` -Defined in: [types.ts:374](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L374) +Defined in: [packages/typescript/ai/src/types.ts:401](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L401) Emit a custom event during tool execution. Events are streamed to the client in real-time as AG-UI CUSTOM events. @@ -61,6 +61,6 @@ const tool = toolDefinition({ ... }).server(async (args, context) => { optional toolCallId: string; ``` -Defined in: [types.ts:355](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L355) +Defined in: [packages/typescript/ai/src/types.ts:382](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L382) The ID of the tool call being executed diff --git a/docs/reference/interfaces/ToolPhaseCompleteInfo.md b/docs/reference/interfaces/ToolPhaseCompleteInfo.md index c83666ad97..484a26027c 100644 --- a/docs/reference/interfaces/ToolPhaseCompleteInfo.md +++ b/docs/reference/interfaces/ToolPhaseCompleteInfo.md @@ -5,7 +5,7 @@ title: ToolPhaseCompleteInfo # Interface: ToolPhaseCompleteInfo -Defined in: [activities/chat/middleware/types.ts:194](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L194) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:194](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L194) Aggregate information passed to onToolPhaseComplete after all tool calls in an iteration have been processed. @@ -18,7 +18,7 @@ in an iteration have been processed. needsApproval: object[]; ``` -Defined in: [activities/chat/middleware/types.ts:205](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L205) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:205](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L205) Tools that need user approval @@ -54,7 +54,7 @@ toolName: string; needsClientExecution: object[]; ``` -Defined in: [activities/chat/middleware/types.ts:212](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L212) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:212](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L212) Tools that need client-side execution @@ -84,7 +84,7 @@ toolName: string; results: object[]; ``` -Defined in: [activities/chat/middleware/types.ts:198](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L198) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:198](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L198) Completed tool results @@ -120,6 +120,6 @@ toolName: string; toolCalls: ToolCall[]; ``` -Defined in: [activities/chat/middleware/types.ts:196](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L196) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:196](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L196) Tool calls that were assigned to the assistant message diff --git a/docs/reference/interfaces/ToolRegistry.md b/docs/reference/interfaces/ToolRegistry.md index 78082faa45..5b048d6027 100644 --- a/docs/reference/interfaces/ToolRegistry.md +++ b/docs/reference/interfaces/ToolRegistry.md @@ -5,7 +5,7 @@ title: ToolRegistry # Interface: ToolRegistry -Defined in: [tool-registry.ts:9](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L9) +Defined in: [packages/typescript/ai/src/tool-registry.ts:9](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L9) A registry that holds tools and allows dynamic tool management. @@ -20,7 +20,7 @@ or frozen (static tool list, for backward compatibility with tools arrays). add: (tool) => void; ``` -Defined in: [tool-registry.ts:22](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L22) +Defined in: [packages/typescript/ai/src/tool-registry.ts:22](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L22) Add a tool to the registry dynamically. For frozen registries, this is a no-op. @@ -47,7 +47,7 @@ get: (name) => | undefined; ``` -Defined in: [tool-registry.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L46) +Defined in: [packages/typescript/ai/src/tool-registry.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L46) Get a tool by name. @@ -74,7 +74,7 @@ The tool if found, undefined otherwise getTools: () => readonly Tool[]; ``` -Defined in: [tool-registry.ts:14](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L14) +Defined in: [packages/typescript/ai/src/tool-registry.ts:14](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L14) Get all current tools in the registry. Called each agent loop iteration to get the latest tool list. @@ -91,7 +91,7 @@ readonly [`Tool`](Tool.md)\<[`SchemaInput`](../type-aliases/SchemaInput.md), [`S has: (name) => boolean; ``` -Defined in: [tool-registry.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L38) +Defined in: [packages/typescript/ai/src/tool-registry.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L38) Check if a tool exists in the registry. @@ -115,7 +115,7 @@ The name of the tool to check readonly isFrozen: boolean; ``` -Defined in: [tool-registry.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L52) +Defined in: [packages/typescript/ai/src/tool-registry.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L52) Whether this registry is frozen (immutable). Frozen registries don't allow add/remove operations. @@ -128,7 +128,7 @@ Frozen registries don't allow add/remove operations. remove: (name) => boolean; ``` -Defined in: [tool-registry.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L31) +Defined in: [packages/typescript/ai/src/tool-registry.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L31) Remove a tool from the registry by name. For frozen registries, this always returns false. diff --git a/docs/reference/interfaces/ToolResultPart.md b/docs/reference/interfaces/ToolResultPart.md index 96a5a1e924..6d800be694 100644 --- a/docs/reference/interfaces/ToolResultPart.md +++ b/docs/reference/interfaces/ToolResultPart.md @@ -5,7 +5,7 @@ title: ToolResultPart # Interface: ToolResultPart -Defined in: [types.ts:300](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L300) +Defined in: [packages/typescript/ai/src/types.ts:327](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L327) ## Properties @@ -15,7 +15,7 @@ Defined in: [types.ts:300](https://github.com/TanStack/ai/blob/main/packages/typ content: string; ``` -Defined in: [types.ts:303](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L303) +Defined in: [packages/typescript/ai/src/types.ts:330](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L330) *** @@ -25,7 +25,7 @@ Defined in: [types.ts:303](https://github.com/TanStack/ai/blob/main/packages/typ optional error: string; ``` -Defined in: [types.ts:305](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L305) +Defined in: [packages/typescript/ai/src/types.ts:332](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L332) *** @@ -35,7 +35,7 @@ Defined in: [types.ts:305](https://github.com/TanStack/ai/blob/main/packages/typ state: ToolResultState; ``` -Defined in: [types.ts:304](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L304) +Defined in: [packages/typescript/ai/src/types.ts:331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L331) *** @@ -45,7 +45,7 @@ Defined in: [types.ts:304](https://github.com/TanStack/ai/blob/main/packages/typ toolCallId: string; ``` -Defined in: [types.ts:302](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L302) +Defined in: [packages/typescript/ai/src/types.ts:329](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L329) *** @@ -55,4 +55,4 @@ Defined in: [types.ts:302](https://github.com/TanStack/ai/blob/main/packages/typ type: "tool-result"; ``` -Defined in: [types.ts:301](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L301) +Defined in: [packages/typescript/ai/src/types.ts:328](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L328) diff --git a/docs/reference/interfaces/TranscriptionAdapter.md b/docs/reference/interfaces/TranscriptionAdapter.md index 5da6571d77..6a27128cb5 100644 --- a/docs/reference/interfaces/TranscriptionAdapter.md +++ b/docs/reference/interfaces/TranscriptionAdapter.md @@ -5,7 +5,7 @@ title: TranscriptionAdapter # Interface: TranscriptionAdapter\ -Defined in: [activities/generateTranscription/adapter.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L24) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/adapter.ts:24](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L24) Transcription adapter interface with pre-resolved generics. @@ -34,7 +34,7 @@ Generic parameters: ~types: object; ``` -Defined in: [activities/generateTranscription/adapter.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L38) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/adapter.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L38) **`Internal`** @@ -54,7 +54,7 @@ providerOptions: TProviderOptions; readonly kind: "transcription"; ``` -Defined in: [activities/generateTranscription/adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L29) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L29) Discriminator for adapter kind - used to determine API shape @@ -66,7 +66,7 @@ Discriminator for adapter kind - used to determine API shape readonly model: TModel; ``` -Defined in: [activities/generateTranscription/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L33) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/adapter.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L33) The model this adapter is configured for @@ -78,7 +78,7 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [activities/generateTranscription/adapter.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L31) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/adapter.ts:31](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L31) Adapter name identifier @@ -90,7 +90,7 @@ Adapter name identifier transcribe: (options) => Promise; ``` -Defined in: [activities/generateTranscription/adapter.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L45) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/adapter.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L45) Transcribe audio to text diff --git a/docs/reference/interfaces/TranscriptionOptions.md b/docs/reference/interfaces/TranscriptionOptions.md index 4fb0d0e744..32c0a6f74a 100644 --- a/docs/reference/interfaces/TranscriptionOptions.md +++ b/docs/reference/interfaces/TranscriptionOptions.md @@ -5,7 +5,7 @@ title: TranscriptionOptions # Interface: TranscriptionOptions\ -Defined in: [types.ts:1183](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1183) +Defined in: [packages/typescript/ai/src/types.ts:1449](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1449) Options for audio transcription. These are the common options supported across providers. @@ -24,7 +24,7 @@ These are the common options supported across providers. audio: string | File | Blob | ArrayBuffer; ``` -Defined in: [types.ts:1189](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1189) +Defined in: [packages/typescript/ai/src/types.ts:1455](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1455) The audio data to transcribe - can be base64 string, File, Blob, or Buffer @@ -36,19 +36,33 @@ The audio data to transcribe - can be base64 string, File, Blob, or Buffer optional language: string; ``` -Defined in: [types.ts:1191](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1191) +Defined in: [packages/typescript/ai/src/types.ts:1457](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1457) The language of the audio in ISO-639-1 format (e.g., 'en') *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1469](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1469) + +Internal logger threaded from the generateTranscription() entry point. +Adapters must call logger.request() before the SDK call and logger.errors() +in catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [types.ts:1187](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1187) +Defined in: [packages/typescript/ai/src/types.ts:1453](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1453) The model to use for transcription @@ -60,7 +74,7 @@ The model to use for transcription optional modelOptions: TProviderOptions; ``` -Defined in: [types.ts:1197](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1197) +Defined in: [packages/typescript/ai/src/types.ts:1463](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1463) Model-specific options for transcription @@ -72,7 +86,7 @@ Model-specific options for transcription optional prompt: string; ``` -Defined in: [types.ts:1193](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1193) +Defined in: [packages/typescript/ai/src/types.ts:1459](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1459) An optional prompt to guide the transcription @@ -84,6 +98,6 @@ An optional prompt to guide the transcription optional responseFormat: "text" | "json" | "srt" | "verbose_json" | "vtt"; ``` -Defined in: [types.ts:1195](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1195) +Defined in: [packages/typescript/ai/src/types.ts:1461](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1461) The format of the transcription output diff --git a/docs/reference/interfaces/TranscriptionResult.md b/docs/reference/interfaces/TranscriptionResult.md index 13255bf406..338923a468 100644 --- a/docs/reference/interfaces/TranscriptionResult.md +++ b/docs/reference/interfaces/TranscriptionResult.md @@ -5,7 +5,7 @@ title: TranscriptionResult # Interface: TranscriptionResult -Defined in: [types.ts:1233](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1233) +Defined in: [packages/typescript/ai/src/types.ts:1505](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1505) Result of audio transcription. @@ -17,7 +17,7 @@ Result of audio transcription. optional duration: number; ``` -Defined in: [types.ts:1243](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1243) +Defined in: [packages/typescript/ai/src/types.ts:1515](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1515) Duration of the audio in seconds @@ -29,7 +29,7 @@ Duration of the audio in seconds id: string; ``` -Defined in: [types.ts:1235](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1235) +Defined in: [packages/typescript/ai/src/types.ts:1507](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1507) Unique identifier for the transcription @@ -41,7 +41,7 @@ Unique identifier for the transcription optional language: string; ``` -Defined in: [types.ts:1241](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1241) +Defined in: [packages/typescript/ai/src/types.ts:1513](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1513) Language detected or specified @@ -53,7 +53,7 @@ Language detected or specified model: string; ``` -Defined in: [types.ts:1237](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1237) +Defined in: [packages/typescript/ai/src/types.ts:1509](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1509) Model used for transcription @@ -65,7 +65,7 @@ Model used for transcription optional segments: TranscriptionSegment[]; ``` -Defined in: [types.ts:1245](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1245) +Defined in: [packages/typescript/ai/src/types.ts:1517](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1517) Detailed segments with timing, if available @@ -77,7 +77,7 @@ Detailed segments with timing, if available text: string; ``` -Defined in: [types.ts:1239](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1239) +Defined in: [packages/typescript/ai/src/types.ts:1511](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1511) The full transcribed text @@ -89,6 +89,6 @@ The full transcribed text optional words: TranscriptionWord[]; ``` -Defined in: [types.ts:1247](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1247) +Defined in: [packages/typescript/ai/src/types.ts:1519](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1519) Word-level timestamps, if available diff --git a/docs/reference/interfaces/TranscriptionSegment.md b/docs/reference/interfaces/TranscriptionSegment.md index 7f5788d3a8..24c0babd9b 100644 --- a/docs/reference/interfaces/TranscriptionSegment.md +++ b/docs/reference/interfaces/TranscriptionSegment.md @@ -5,7 +5,7 @@ title: TranscriptionSegment # Interface: TranscriptionSegment -Defined in: [types.ts:1203](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1203) +Defined in: [packages/typescript/ai/src/types.ts:1475](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1475) A single segment of transcribed audio with timing information. @@ -17,7 +17,7 @@ A single segment of transcribed audio with timing information. optional confidence: number; ``` -Defined in: [types.ts:1213](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1213) +Defined in: [packages/typescript/ai/src/types.ts:1485](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1485) Confidence score (0-1), if available @@ -29,7 +29,7 @@ Confidence score (0-1), if available end: number; ``` -Defined in: [types.ts:1209](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1209) +Defined in: [packages/typescript/ai/src/types.ts:1481](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1481) End time of the segment in seconds @@ -41,7 +41,7 @@ End time of the segment in seconds id: number; ``` -Defined in: [types.ts:1205](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1205) +Defined in: [packages/typescript/ai/src/types.ts:1477](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1477) Unique identifier for the segment @@ -53,7 +53,7 @@ Unique identifier for the segment optional speaker: string; ``` -Defined in: [types.ts:1215](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1215) +Defined in: [packages/typescript/ai/src/types.ts:1487](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1487) Speaker identifier, if diarization is enabled @@ -65,7 +65,7 @@ Speaker identifier, if diarization is enabled start: number; ``` -Defined in: [types.ts:1207](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1207) +Defined in: [packages/typescript/ai/src/types.ts:1479](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1479) Start time of the segment in seconds @@ -77,6 +77,6 @@ Start time of the segment in seconds text: string; ``` -Defined in: [types.ts:1211](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1211) +Defined in: [packages/typescript/ai/src/types.ts:1483](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1483) Transcribed text for this segment diff --git a/docs/reference/interfaces/TranscriptionWord.md b/docs/reference/interfaces/TranscriptionWord.md index deeca4dcb5..42160b603d 100644 --- a/docs/reference/interfaces/TranscriptionWord.md +++ b/docs/reference/interfaces/TranscriptionWord.md @@ -5,7 +5,7 @@ title: TranscriptionWord # Interface: TranscriptionWord -Defined in: [types.ts:1221](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1221) +Defined in: [packages/typescript/ai/src/types.ts:1493](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1493) A single word with timing information. @@ -17,7 +17,7 @@ A single word with timing information. end: number; ``` -Defined in: [types.ts:1227](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1227) +Defined in: [packages/typescript/ai/src/types.ts:1499](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1499) End time in seconds @@ -29,7 +29,7 @@ End time in seconds start: number; ``` -Defined in: [types.ts:1225](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1225) +Defined in: [packages/typescript/ai/src/types.ts:1497](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1497) Start time in seconds @@ -41,6 +41,6 @@ Start time in seconds word: string; ``` -Defined in: [types.ts:1223](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1223) +Defined in: [packages/typescript/ai/src/types.ts:1495](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1495) The transcribed word diff --git a/docs/reference/interfaces/UIMessage.md b/docs/reference/interfaces/UIMessage.md index 860b2e7b44..a309de54d4 100644 --- a/docs/reference/interfaces/UIMessage.md +++ b/docs/reference/interfaces/UIMessage.md @@ -5,7 +5,7 @@ title: UIMessage # Interface: UIMessage -Defined in: [types.ts:327](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L327) +Defined in: [packages/typescript/ai/src/types.ts:354](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L354) UIMessage - Domain-specific message format optimized for building chat UIs Contains parts that can be text, tool calls, or tool results @@ -18,7 +18,7 @@ Contains parts that can be text, tool calls, or tool results optional createdAt: Date; ``` -Defined in: [types.ts:331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L331) +Defined in: [packages/typescript/ai/src/types.ts:358](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L358) *** @@ -28,7 +28,7 @@ Defined in: [types.ts:331](https://github.com/TanStack/ai/blob/main/packages/typ id: string; ``` -Defined in: [types.ts:328](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L328) +Defined in: [packages/typescript/ai/src/types.ts:355](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L355) *** @@ -38,7 +38,7 @@ Defined in: [types.ts:328](https://github.com/TanStack/ai/blob/main/packages/typ parts: MessagePart[]; ``` -Defined in: [types.ts:330](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L330) +Defined in: [packages/typescript/ai/src/types.ts:357](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L357) *** @@ -48,4 +48,4 @@ Defined in: [types.ts:330](https://github.com/TanStack/ai/blob/main/packages/typ role: "user" | "assistant" | "system"; ``` -Defined in: [types.ts:329](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L329) +Defined in: [packages/typescript/ai/src/types.ts:356](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L356) diff --git a/docs/reference/interfaces/UsageInfo.md b/docs/reference/interfaces/UsageInfo.md index 9f5f1f65a0..47d64d6812 100644 --- a/docs/reference/interfaces/UsageInfo.md +++ b/docs/reference/interfaces/UsageInfo.md @@ -5,7 +5,7 @@ title: UsageInfo # Interface: UsageInfo -Defined in: [activities/chat/middleware/types.ts:227](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L227) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:227](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L227) Token usage statistics passed to the onUsage hook. Extracted from the RUN_FINISHED chunk when usage data is present. @@ -18,7 +18,7 @@ Extracted from the RUN_FINISHED chunk when usage data is present. completionTokens: number; ``` -Defined in: [activities/chat/middleware/types.ts:229](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L229) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:229](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L229) *** @@ -28,7 +28,7 @@ Defined in: [activities/chat/middleware/types.ts:229](https://github.com/TanStac promptTokens: number; ``` -Defined in: [activities/chat/middleware/types.ts:228](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L228) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:228](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L228) *** @@ -38,4 +38,4 @@ Defined in: [activities/chat/middleware/types.ts:228](https://github.com/TanStac totalTokens: number; ``` -Defined in: [activities/chat/middleware/types.ts:230](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L230) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:230](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L230) diff --git a/docs/reference/interfaces/VADConfig.md b/docs/reference/interfaces/VADConfig.md index 23be07c2dc..862e30d58e 100644 --- a/docs/reference/interfaces/VADConfig.md +++ b/docs/reference/interfaces/VADConfig.md @@ -5,7 +5,7 @@ title: VADConfig # Interface: VADConfig -Defined in: [realtime/types.ts:8](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L8) +Defined in: [packages/typescript/ai/src/realtime/types.ts:8](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L8) Voice activity detection configuration @@ -17,7 +17,7 @@ Voice activity detection configuration optional prefixPaddingMs: number; ``` -Defined in: [realtime/types.ts:12](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L12) +Defined in: [packages/typescript/ai/src/realtime/types.ts:12](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L12) Audio to include before speech detection (ms) @@ -29,7 +29,7 @@ Audio to include before speech detection (ms) optional silenceDurationMs: number; ``` -Defined in: [realtime/types.ts:14](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L14) +Defined in: [packages/typescript/ai/src/realtime/types.ts:14](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L14) Silence duration to end turn (ms) @@ -41,6 +41,6 @@ Silence duration to end turn (ms) optional threshold: number; ``` -Defined in: [realtime/types.ts:10](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L10) +Defined in: [packages/typescript/ai/src/realtime/types.ts:10](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L10) Sensitivity threshold (0.0-1.0) diff --git a/docs/reference/interfaces/VideoAdapter.md b/docs/reference/interfaces/VideoAdapter.md index 7bd62212a6..7511a530f1 100644 --- a/docs/reference/interfaces/VideoAdapter.md +++ b/docs/reference/interfaces/VideoAdapter.md @@ -5,7 +5,7 @@ title: VideoAdapter # Interface: VideoAdapter\ -Defined in: [activities/generateVideo/adapter.ts:35](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L35) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:35](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L35) **`Experimental`** @@ -48,7 +48,7 @@ Generic parameters: ~types: object; ``` -Defined in: [activities/generateVideo/adapter.ts:51](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L51) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:51](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L51) **`Internal`** @@ -80,7 +80,7 @@ providerOptions: TProviderOptions; createVideoJob: (options) => Promise; ``` -Defined in: [activities/generateVideo/adapter.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L61) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:61](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L61) **`Experimental`** @@ -105,7 +105,7 @@ Returns a job ID that can be used to poll for status and retrieve the video. getVideoStatus: (jobId) => Promise; ``` -Defined in: [activities/generateVideo/adapter.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L68) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L68) **`Experimental`** @@ -129,7 +129,7 @@ Get the current status of a video generation job. getVideoUrl: (jobId) => Promise; ``` -Defined in: [activities/generateVideo/adapter.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L74) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:74](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L74) **`Experimental`** @@ -154,7 +154,7 @@ Should only be called after status is 'completed'. readonly kind: "video"; ``` -Defined in: [activities/generateVideo/adapter.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L42) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:42](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L42) **`Experimental`** @@ -168,7 +168,7 @@ Discriminator for adapter kind - used to determine API shape readonly model: TModel; ``` -Defined in: [activities/generateVideo/adapter.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L46) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:46](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L46) **`Experimental`** @@ -182,7 +182,7 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [activities/generateVideo/adapter.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L44) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:44](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L44) **`Experimental`** diff --git a/docs/reference/interfaces/VideoGenerationOptions.md b/docs/reference/interfaces/VideoGenerationOptions.md index fba2e2bfd2..6338f0252b 100644 --- a/docs/reference/interfaces/VideoGenerationOptions.md +++ b/docs/reference/interfaces/VideoGenerationOptions.md @@ -5,7 +5,7 @@ title: VideoGenerationOptions # Interface: VideoGenerationOptions\ -Defined in: [types.ts:1076](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1076) +Defined in: [packages/typescript/ai/src/types.ts:1331](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1331) **`Experimental`** @@ -32,7 +32,7 @@ These are the common options supported across providers. optional duration: number; ``` -Defined in: [types.ts:1087](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1087) +Defined in: [packages/typescript/ai/src/types.ts:1342](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1342) **`Experimental`** @@ -40,13 +40,28 @@ Video duration in seconds *** +### logger + +```ts +logger: InternalLogger; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1349](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1349) + +**`Experimental`** + +Internal logger threaded from the generateVideo() entry point. Adapters must +call logger.request() before the SDK call and logger.errors() in catch blocks. + +*** + ### model ```ts model: string; ``` -Defined in: [types.ts:1081](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1081) +Defined in: [packages/typescript/ai/src/types.ts:1336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1336) **`Experimental`** @@ -60,7 +75,7 @@ The model to use for video generation optional modelOptions: TProviderOptions; ``` -Defined in: [types.ts:1089](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1089) +Defined in: [packages/typescript/ai/src/types.ts:1344](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1344) **`Experimental`** @@ -74,7 +89,7 @@ Model-specific options for video generation prompt: string; ``` -Defined in: [types.ts:1083](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1083) +Defined in: [packages/typescript/ai/src/types.ts:1338](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1338) **`Experimental`** @@ -88,7 +103,7 @@ Text description of the desired video optional size: TSize; ``` -Defined in: [types.ts:1085](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1085) +Defined in: [packages/typescript/ai/src/types.ts:1340](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1340) **`Experimental`** diff --git a/docs/reference/interfaces/VideoJobResult.md b/docs/reference/interfaces/VideoJobResult.md index c8a4fef076..77a7972db3 100644 --- a/docs/reference/interfaces/VideoJobResult.md +++ b/docs/reference/interfaces/VideoJobResult.md @@ -5,7 +5,7 @@ title: VideoJobResult # Interface: VideoJobResult -Defined in: [types.ts:1097](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1097) +Defined in: [packages/typescript/ai/src/types.ts:1357](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1357) **`Experimental`** @@ -21,7 +21,7 @@ Result of creating a video generation job. jobId: string; ``` -Defined in: [types.ts:1099](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1099) +Defined in: [packages/typescript/ai/src/types.ts:1359](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1359) **`Experimental`** @@ -35,7 +35,7 @@ Unique job identifier for polling status model: string; ``` -Defined in: [types.ts:1101](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1101) +Defined in: [packages/typescript/ai/src/types.ts:1361](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1361) **`Experimental`** diff --git a/docs/reference/interfaces/VideoPart.md b/docs/reference/interfaces/VideoPart.md index c07f8ae004..e2829886ed 100644 --- a/docs/reference/interfaces/VideoPart.md +++ b/docs/reference/interfaces/VideoPart.md @@ -5,7 +5,7 @@ title: VideoPart # Interface: VideoPart\ -Defined in: [types.ts:187](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L187) +Defined in: [packages/typescript/ai/src/types.ts:214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L214) Video content part for multimodal messages. @@ -25,7 +25,7 @@ Provider-specific metadata type optional metadata: TMetadata; ``` -Defined in: [types.ts:192](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L192) +Defined in: [packages/typescript/ai/src/types.ts:219](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L219) Provider-specific metadata (e.g., duration, resolution) @@ -37,7 +37,7 @@ Provider-specific metadata (e.g., duration, resolution) source: ContentPartSource; ``` -Defined in: [types.ts:190](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L190) +Defined in: [packages/typescript/ai/src/types.ts:217](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L217) Source of the video content @@ -49,4 +49,4 @@ Source of the video content type: "video"; ``` -Defined in: [types.ts:188](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L188) +Defined in: [packages/typescript/ai/src/types.ts:215](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L215) diff --git a/docs/reference/interfaces/VideoStatusResult.md b/docs/reference/interfaces/VideoStatusResult.md index 26990f4fdb..141684b63d 100644 --- a/docs/reference/interfaces/VideoStatusResult.md +++ b/docs/reference/interfaces/VideoStatusResult.md @@ -5,7 +5,7 @@ title: VideoStatusResult # Interface: VideoStatusResult -Defined in: [types.ts:1109](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1109) +Defined in: [packages/typescript/ai/src/types.ts:1369](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1369) **`Experimental`** @@ -21,7 +21,7 @@ Status of a video generation job. optional error: string; ``` -Defined in: [types.ts:1117](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1117) +Defined in: [packages/typescript/ai/src/types.ts:1377](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1377) **`Experimental`** @@ -35,7 +35,7 @@ Error message if status is 'failed' jobId: string; ``` -Defined in: [types.ts:1111](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1111) +Defined in: [packages/typescript/ai/src/types.ts:1371](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1371) **`Experimental`** @@ -49,7 +49,7 @@ Job identifier optional progress: number; ``` -Defined in: [types.ts:1115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1115) +Defined in: [packages/typescript/ai/src/types.ts:1375](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1375) **`Experimental`** @@ -63,7 +63,7 @@ Progress percentage (0-100), if available status: "pending" | "processing" | "completed" | "failed"; ``` -Defined in: [types.ts:1113](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1113) +Defined in: [packages/typescript/ai/src/types.ts:1373](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1373) **`Experimental`** diff --git a/docs/reference/interfaces/VideoUrlResult.md b/docs/reference/interfaces/VideoUrlResult.md index 1a970849e6..c151cd3747 100644 --- a/docs/reference/interfaces/VideoUrlResult.md +++ b/docs/reference/interfaces/VideoUrlResult.md @@ -5,7 +5,7 @@ title: VideoUrlResult # Interface: VideoUrlResult -Defined in: [types.ts:1125](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1125) +Defined in: [packages/typescript/ai/src/types.ts:1385](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1385) **`Experimental`** @@ -21,7 +21,7 @@ Result containing the URL to a generated video. optional expiresAt: Date; ``` -Defined in: [types.ts:1131](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1131) +Defined in: [packages/typescript/ai/src/types.ts:1391](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1391) **`Experimental`** @@ -35,7 +35,7 @@ When the URL expires, if applicable jobId: string; ``` -Defined in: [types.ts:1127](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1127) +Defined in: [packages/typescript/ai/src/types.ts:1387](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1387) **`Experimental`** @@ -49,7 +49,7 @@ Job identifier url: string; ``` -Defined in: [types.ts:1129](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1129) +Defined in: [packages/typescript/ai/src/types.ts:1389](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1389) **`Experimental`** diff --git a/docs/reference/type-aliases/AGUIEvent.md b/docs/reference/type-aliases/AGUIEvent.md index 05cae502fd..a6fd82efff 100644 --- a/docs/reference/type-aliases/AGUIEvent.md +++ b/docs/reference/type-aliases/AGUIEvent.md @@ -16,14 +16,21 @@ type AGUIEvent = | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent + | ToolCallResultEvent | StepStartedEvent | StepFinishedEvent | MessagesSnapshotEvent | StateSnapshotEvent | StateDeltaEvent - | CustomEvent; + | CustomEvent + | ReasoningStartEvent + | ReasoningMessageStartEvent + | ReasoningMessageContentEvent + | ReasoningMessageEndEvent + | ReasoningEndEvent + | ReasoningEncryptedValueEvent; ``` -Defined in: [types.ts:955](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L955) +Defined in: [packages/typescript/ai/src/types.ts:1124](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1124) Union of all AG-UI events. diff --git a/docs/reference/type-aliases/AGUIEventType.md b/docs/reference/type-aliases/AGUIEventType.md index e57edbd63a..032e2d3878 100644 --- a/docs/reference/type-aliases/AGUIEventType.md +++ b/docs/reference/type-aliases/AGUIEventType.md @@ -3,31 +3,20 @@ id: AGUIEventType title: AGUIEventType --- -# Type Alias: AGUIEventType +# ~~Type Alias: AGUIEventType~~ ```ts -type AGUIEventType = - | "RUN_STARTED" - | "RUN_FINISHED" - | "RUN_ERROR" - | "TEXT_MESSAGE_START" - | "TEXT_MESSAGE_CONTENT" - | "TEXT_MESSAGE_END" - | "TOOL_CALL_START" - | "TOOL_CALL_ARGS" - | "TOOL_CALL_END" - | "STEP_STARTED" - | "STEP_FINISHED" - | "MESSAGES_SNAPSHOT" - | "STATE_SNAPSHOT" - | "STATE_DELTA" - | "CUSTOM"; +type AGUIEventType = `${EventType}`; ``` -Defined in: [types.ts:726](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L726) +Defined in: [packages/typescript/ai/src/types.ts:779](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L779) AG-UI Protocol event types. -Based on the AG-UI specification for agent-user interaction. + +## Deprecated + +Use `EventType` enum from `@ag-ui/core` instead. This type alias +is kept for backward compatibility but will be removed in a future version. ## See diff --git a/docs/reference/type-aliases/AIAdapter.md b/docs/reference/type-aliases/AIAdapter.md index ef7f5f5c66..429e0663e7 100644 --- a/docs/reference/type-aliases/AIAdapter.md +++ b/docs/reference/type-aliases/AIAdapter.md @@ -10,11 +10,12 @@ type AIAdapter = | AnyTextAdapter | AnySummarizeAdapter | AnyImageAdapter + | AnyAudioAdapter | AnyVideoAdapter | AnyTTSAdapter | AnyTranscriptionAdapter; ``` -Defined in: [activities/index.ts:149](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/index.ts#L149) +Defined in: [packages/typescript/ai/src/activities/index.ts:169](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/index.ts#L169) Union of all adapter types that can be passed to chat() diff --git a/docs/reference/type-aliases/AgentLoopStrategy.md b/docs/reference/type-aliases/AgentLoopStrategy.md index 39d377c892..769e181aa3 100644 --- a/docs/reference/type-aliases/AgentLoopStrategy.md +++ b/docs/reference/type-aliases/AgentLoopStrategy.md @@ -9,7 +9,7 @@ title: AgentLoopStrategy type AgentLoopStrategy = (state) => boolean; ``` -Defined in: [types.ts:625](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L625) +Defined in: [packages/typescript/ai/src/types.ts:652](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L652) Strategy function that determines whether the agent loop should continue diff --git a/docs/reference/type-aliases/AnyAudioAdapter.md b/docs/reference/type-aliases/AnyAudioAdapter.md new file mode 100644 index 0000000000..040ef8a3a1 --- /dev/null +++ b/docs/reference/type-aliases/AnyAudioAdapter.md @@ -0,0 +1,15 @@ +--- +id: AnyAudioAdapter +title: AnyAudioAdapter +--- + +# Type Alias: AnyAudioAdapter + +```ts +type AnyAudioAdapter = AudioAdapter; +``` + +Defined in: [packages/typescript/ai/src/activities/generateAudio/adapter.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateAudio/adapter.ts#L54) + +An AudioAdapter with any/unknown type parameters. +Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/AnyClientTool.md b/docs/reference/type-aliases/AnyClientTool.md index ae8019f2e4..ada3199f26 100644 --- a/docs/reference/type-aliases/AnyClientTool.md +++ b/docs/reference/type-aliases/AnyClientTool.md @@ -11,6 +11,6 @@ type AnyClientTool = | ToolDefinitionInstance; ``` -Defined in: [activities/chat/tools/tool-definition.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L56) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:56](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L56) Union type for any kind of client-side tool (client tool or definition) diff --git a/docs/reference/type-aliases/AnyImageAdapter.md b/docs/reference/type-aliases/AnyImageAdapter.md index aa8a929133..5556da838a 100644 --- a/docs/reference/type-aliases/AnyImageAdapter.md +++ b/docs/reference/type-aliases/AnyImageAdapter.md @@ -9,7 +9,7 @@ title: AnyImageAdapter type AnyImageAdapter = ImageAdapter; ``` -Defined in: [activities/generateImage/adapter.ts:67](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L67) +Defined in: [packages/typescript/ai/src/activities/generateImage/adapter.ts:67](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateImage/adapter.ts#L67) An ImageAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/AnySummarizeAdapter.md b/docs/reference/type-aliases/AnySummarizeAdapter.md index 94be547fec..603c8c3053 100644 --- a/docs/reference/type-aliases/AnySummarizeAdapter.md +++ b/docs/reference/type-aliases/AnySummarizeAdapter.md @@ -9,7 +9,7 @@ title: AnySummarizeAdapter type AnySummarizeAdapter = SummarizeAdapter; ``` -Defined in: [activities/summarize/adapter.ts:65](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L65) +Defined in: [packages/typescript/ai/src/activities/summarize/adapter.ts:65](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/summarize/adapter.ts#L65) A SummarizeAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/AnyTTSAdapter.md b/docs/reference/type-aliases/AnyTTSAdapter.md index 92de11d216..a8b8081be5 100644 --- a/docs/reference/type-aliases/AnyTTSAdapter.md +++ b/docs/reference/type-aliases/AnyTTSAdapter.md @@ -9,7 +9,7 @@ title: AnyTTSAdapter type AnyTTSAdapter = TTSAdapter; ``` -Defined in: [activities/generateSpeech/adapter.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L52) +Defined in: [packages/typescript/ai/src/activities/generateSpeech/adapter.ts:52](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateSpeech/adapter.ts#L52) A TTSAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/AnyTextAdapter.md b/docs/reference/type-aliases/AnyTextAdapter.md index f855cc6d78..5420432b6b 100644 --- a/docs/reference/type-aliases/AnyTextAdapter.md +++ b/docs/reference/type-aliases/AnyTextAdapter.md @@ -6,10 +6,10 @@ title: AnyTextAdapter # Type Alias: AnyTextAdapter ```ts -type AnyTextAdapter = TextAdapter; +type AnyTextAdapter = TextAdapter; ``` -Defined in: [activities/chat/adapter.ts:98](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L98) +Defined in: [packages/typescript/ai/src/activities/chat/adapter.ts:106](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/adapter.ts#L106) A TextAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/AnyTranscriptionAdapter.md b/docs/reference/type-aliases/AnyTranscriptionAdapter.md index b533e921ae..eb0e4b865f 100644 --- a/docs/reference/type-aliases/AnyTranscriptionAdapter.md +++ b/docs/reference/type-aliases/AnyTranscriptionAdapter.md @@ -9,7 +9,7 @@ title: AnyTranscriptionAdapter type AnyTranscriptionAdapter = TranscriptionAdapter; ``` -Defined in: [activities/generateTranscription/adapter.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L54) +Defined in: [packages/typescript/ai/src/activities/generateTranscription/adapter.ts:54](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateTranscription/adapter.ts#L54) A TranscriptionAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/AnyVideoAdapter.md b/docs/reference/type-aliases/AnyVideoAdapter.md index ef6a97b234..5a546ca2d7 100644 --- a/docs/reference/type-aliases/AnyVideoAdapter.md +++ b/docs/reference/type-aliases/AnyVideoAdapter.md @@ -9,7 +9,7 @@ title: AnyVideoAdapter type AnyVideoAdapter = VideoAdapter; ``` -Defined in: [activities/generateVideo/adapter.ts:81](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L81) +Defined in: [packages/typescript/ai/src/activities/generateVideo/adapter.ts:81](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/generateVideo/adapter.ts#L81) A VideoAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/BeforeToolCallDecision.md b/docs/reference/type-aliases/BeforeToolCallDecision.md index 31d014a5a1..f087d5017b 100644 --- a/docs/reference/type-aliases/BeforeToolCallDecision.md +++ b/docs/reference/type-aliases/BeforeToolCallDecision.md @@ -24,7 +24,7 @@ type BeforeToolCallDecision = }; ``` -Defined in: [activities/chat/middleware/types.ts:143](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L143) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:143](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L143) Decision returned from onBeforeToolCall. - undefined/void: continue with normal execution diff --git a/docs/reference/type-aliases/ChatMiddlewarePhase.md b/docs/reference/type-aliases/ChatMiddlewarePhase.md index 0d72e0c38f..2ec7b3f468 100644 --- a/docs/reference/type-aliases/ChatMiddlewarePhase.md +++ b/docs/reference/type-aliases/ChatMiddlewarePhase.md @@ -9,7 +9,7 @@ title: ChatMiddlewarePhase type ChatMiddlewarePhase = "init" | "beforeModel" | "modelStream" | "beforeTools" | "afterTools"; ``` -Defined in: [activities/chat/middleware/types.ts:15](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L15) +Defined in: [packages/typescript/ai/src/activities/chat/middleware/types.ts:15](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/middleware/types.ts#L15) Phase of the chat middleware lifecycle. - 'init': Initial config transform before the chat engine starts diff --git a/docs/reference/type-aliases/ConstrainedContent.md b/docs/reference/type-aliases/ConstrainedContent.md index 26ae38f99d..0d6427edd4 100644 --- a/docs/reference/type-aliases/ConstrainedContent.md +++ b/docs/reference/type-aliases/ConstrainedContent.md @@ -12,7 +12,7 @@ type ConstrainedContent = | ContentPartForInputModalitiesTypes[]; ``` -Defined in: [types.ts:255](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L255) +Defined in: [packages/typescript/ai/src/types.ts:282](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L282) Type for message content constrained by supported modalities. When modalities is ['text', 'image'], only TextPart and ImagePart are allowed in the array. diff --git a/docs/reference/type-aliases/ConstrainedModelMessage.md b/docs/reference/type-aliases/ConstrainedModelMessage.md index c20060656e..ae9a6eec77 100644 --- a/docs/reference/type-aliases/ConstrainedModelMessage.md +++ b/docs/reference/type-aliases/ConstrainedModelMessage.md @@ -9,7 +9,7 @@ title: ConstrainedModelMessage type ConstrainedModelMessage = Omit & object; ``` -Defined in: [types.ts:343](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L343) +Defined in: [packages/typescript/ai/src/types.ts:370](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L370) A ModelMessage with content constrained to only allow content parts matching the specified input modalities. diff --git a/docs/reference/type-aliases/ContentPart.md b/docs/reference/type-aliases/ContentPart.md index 873a67b72a..a4139b2b0c 100644 --- a/docs/reference/type-aliases/ContentPart.md +++ b/docs/reference/type-aliases/ContentPart.md @@ -14,7 +14,7 @@ type ContentPart = | DocumentPart; ``` -Defined in: [types.ts:214](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L214) +Defined in: [packages/typescript/ai/src/types.ts:241](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L241) Union type for all multimodal content parts. diff --git a/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md b/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md index dd5dfb9aa6..7b707e3c76 100644 --- a/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md +++ b/docs/reference/type-aliases/ContentPartForInputModalitiesTypes.md @@ -11,7 +11,7 @@ type ContentPartForInputModalitiesTypes = Extract; ``` -Defined in: [types.ts:231](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L231) +Defined in: [packages/typescript/ai/src/types.ts:258](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L258) Helper type to filter ContentPart union to only include specific modalities. Used to constrain message content based on model capabilities. diff --git a/docs/reference/type-aliases/ContentPartSource.md b/docs/reference/type-aliases/ContentPartSource.md index 796fd88d2a..d7b5b3bc3d 100644 --- a/docs/reference/type-aliases/ContentPartSource.md +++ b/docs/reference/type-aliases/ContentPartSource.md @@ -11,7 +11,7 @@ type ContentPartSource = | ContentPartUrlSource; ``` -Defined in: [types.ts:157](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L157) +Defined in: [packages/typescript/ai/src/types.ts:184](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L184) Source specification for multimodal content. Discriminated union supporting both inline data (base64) and URL-based content. diff --git a/docs/reference/type-aliases/DebugOption.md b/docs/reference/type-aliases/DebugOption.md new file mode 100644 index 0000000000..10ea542db6 --- /dev/null +++ b/docs/reference/type-aliases/DebugOption.md @@ -0,0 +1,14 @@ +--- +id: DebugOption +title: DebugOption +--- + +# Type Alias: DebugOption + +```ts +type DebugOption = boolean | DebugConfig; +``` + +Defined in: [packages/typescript/ai/src/logger/types.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/logger/types.ts#L78) + +The shape accepted by the `debug` option on every `@tanstack/ai` activity. Pass `true` to enable all categories with the default console logger; `false` to silence everything including errors; an object for granular control. diff --git a/docs/reference/type-aliases/GeneratedAudio.md b/docs/reference/type-aliases/GeneratedAudio.md new file mode 100644 index 0000000000..1b809308d4 --- /dev/null +++ b/docs/reference/type-aliases/GeneratedAudio.md @@ -0,0 +1,32 @@ +--- +id: GeneratedAudio +title: GeneratedAudio +--- + +# Type Alias: GeneratedAudio + +```ts +type GeneratedAudio = GeneratedMediaSource & object; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1296](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1296) + +A single generated audio output + +## Type Declaration + +### contentType? + +```ts +optional contentType: string; +``` + +Content type of the audio (e.g., 'audio/wav', 'audio/mp3') + +### duration? + +```ts +optional duration: number; +``` + +Duration of the generated audio in seconds diff --git a/docs/reference/type-aliases/GeneratedImage.md b/docs/reference/type-aliases/GeneratedImage.md new file mode 100644 index 0000000000..b1b544cc83 --- /dev/null +++ b/docs/reference/type-aliases/GeneratedImage.md @@ -0,0 +1,24 @@ +--- +id: GeneratedImage +title: GeneratedImage +--- + +# Type Alias: GeneratedImage + +```ts +type GeneratedImage = GeneratedMediaSource & object; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1243](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1243) + +A single generated image + +## Type Declaration + +### revisedPrompt? + +```ts +optional revisedPrompt: string; +``` + +Revised prompt used by the model (if applicable) diff --git a/docs/reference/type-aliases/GeneratedMediaSource.md b/docs/reference/type-aliases/GeneratedMediaSource.md new file mode 100644 index 0000000000..f4b9248691 --- /dev/null +++ b/docs/reference/type-aliases/GeneratedMediaSource.md @@ -0,0 +1,69 @@ +--- +id: GeneratedMediaSource +title: GeneratedMediaSource +--- + +# Type Alias: GeneratedMediaSource + +```ts +type GeneratedMediaSource = + | { + b64Json?: never; + url: string; +} + | { + b64Json: string; + url?: never; +}; +``` + +Defined in: [packages/typescript/ai/src/types.ts:1228](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1228) + +Source of a generated media asset. Exactly one of `url` or `b64Json` is +present; the other is absent. Modeled as a mutually-exclusive union so the +type rejects `{}` and `{ url, b64Json }` together at compile time while +preserving the flat `.url` / `.b64Json` access patterns. + +## Type Declaration + +```ts +{ + b64Json?: never; + url: string; +} +``` + +### b64Json? + +```ts +optional b64Json: never; +``` + +### url + +```ts +url: string; +``` + +URL to the generated asset (may be temporary) + +```ts +{ + b64Json: string; + url?: never; +} +``` + +### b64Json + +```ts +b64Json: string; +``` + +Base64-encoded asset data + +### url? + +```ts +optional url: never; +``` diff --git a/docs/reference/type-aliases/InferSchemaType.md b/docs/reference/type-aliases/InferSchemaType.md index 10241edfe0..7e64f37345 100644 --- a/docs/reference/type-aliases/InferSchemaType.md +++ b/docs/reference/type-aliases/InferSchemaType.md @@ -9,7 +9,7 @@ title: InferSchemaType type InferSchemaType = T extends StandardJSONSchemaV1 ? TInput : unknown; ``` -Defined in: [types.ts:84](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L84) +Defined in: [packages/typescript/ai/src/types.ts:111](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L111) Infer the TypeScript type from a schema. For Standard JSON Schema compliant schemas, extracts the input type. diff --git a/docs/reference/type-aliases/InferToolInput.md b/docs/reference/type-aliases/InferToolInput.md index 2e1b864cea..54b67ab7dc 100644 --- a/docs/reference/type-aliases/InferToolInput.md +++ b/docs/reference/type-aliases/InferToolInput.md @@ -9,7 +9,7 @@ title: InferToolInput type InferToolInput = T extends object ? TInput extends StandardJSONSchemaV1 ? TInferred : TInput extends JSONSchema ? unknown : unknown : unknown; ``` -Defined in: [activities/chat/tools/tool-definition.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L68) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:68](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L68) Extract the input type from a tool (inferred from Standard JSON Schema, or `unknown` for plain JSONSchema) diff --git a/docs/reference/type-aliases/InferToolName.md b/docs/reference/type-aliases/InferToolName.md index de25b3f044..6e8080159a 100644 --- a/docs/reference/type-aliases/InferToolName.md +++ b/docs/reference/type-aliases/InferToolName.md @@ -9,7 +9,7 @@ title: InferToolName type InferToolName = T extends object ? N : never; ``` -Defined in: [activities/chat/tools/tool-definition.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L63) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:63](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L63) Extract the tool name as a literal type diff --git a/docs/reference/type-aliases/InferToolOutput.md b/docs/reference/type-aliases/InferToolOutput.md index c176862a15..a928d2f3de 100644 --- a/docs/reference/type-aliases/InferToolOutput.md +++ b/docs/reference/type-aliases/InferToolOutput.md @@ -9,7 +9,7 @@ title: InferToolOutput type InferToolOutput = T extends object ? TOutput extends StandardJSONSchemaV1 ? TInferred : TOutput extends JSONSchema ? unknown : unknown : unknown; ``` -Defined in: [activities/chat/tools/tool-definition.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L79) +Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-definition.ts:79](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-definition.ts#L79) Extract the output type from a tool (inferred from Standard JSON Schema, or `unknown` for plain JSONSchema) diff --git a/docs/reference/type-aliases/InputModalitiesTypes.md b/docs/reference/type-aliases/InputModalitiesTypes.md index 8fcfbebc8d..aaa24e2196 100644 --- a/docs/reference/type-aliases/InputModalitiesTypes.md +++ b/docs/reference/type-aliases/InputModalitiesTypes.md @@ -9,7 +9,7 @@ title: InputModalitiesTypes type InputModalitiesTypes = object; ``` -Defined in: [types.ts:334](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L334) +Defined in: [packages/typescript/ai/src/types.ts:361](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L361) ## Properties @@ -19,7 +19,7 @@ Defined in: [types.ts:334](https://github.com/TanStack/ai/blob/main/packages/typ inputModalities: ReadonlyArray; ``` -Defined in: [types.ts:335](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L335) +Defined in: [packages/typescript/ai/src/types.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L362) *** @@ -29,4 +29,4 @@ Defined in: [types.ts:335](https://github.com/TanStack/ai/blob/main/packages/typ messageMetadataByModality: DefaultMessageMetadataByModality; ``` -Defined in: [types.ts:336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L336) +Defined in: [packages/typescript/ai/src/types.ts:363](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L363) diff --git a/docs/reference/type-aliases/MessagePart.md b/docs/reference/type-aliases/MessagePart.md index fdbdef677e..fc4f902284 100644 --- a/docs/reference/type-aliases/MessagePart.md +++ b/docs/reference/type-aliases/MessagePart.md @@ -17,4 +17,4 @@ type MessagePart = | ThinkingPart; ``` -Defined in: [types.ts:313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L313) +Defined in: [packages/typescript/ai/src/types.ts:340](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L340) diff --git a/docs/reference/type-aliases/ModalitiesArrayToUnion.md b/docs/reference/type-aliases/ModalitiesArrayToUnion.md index d49959d2cb..5f9d2ee587 100644 --- a/docs/reference/type-aliases/ModalitiesArrayToUnion.md +++ b/docs/reference/type-aliases/ModalitiesArrayToUnion.md @@ -9,7 +9,7 @@ title: ModalitiesArrayToUnion type ModalitiesArrayToUnion = T[number]; ``` -Defined in: [types.ts:248](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L248) +Defined in: [packages/typescript/ai/src/types.ts:275](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L275) Helper type to convert a readonly array of modalities to a union type. e.g., readonly ['text', 'image'] -> 'text' | 'image' diff --git a/docs/reference/type-aliases/Modality.md b/docs/reference/type-aliases/Modality.md index 92d4156ee8..1a164036bf 100644 --- a/docs/reference/type-aliases/Modality.md +++ b/docs/reference/type-aliases/Modality.md @@ -9,7 +9,7 @@ title: Modality type Modality = "text" | "image" | "audio" | "video" | "document"; ``` -Defined in: [types.ts:110](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L110) +Defined in: [packages/typescript/ai/src/types.ts:137](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L137) Supported input modality types for multimodal content. - 'text': Plain text content diff --git a/docs/reference/type-aliases/RealtimeErrorCode.md b/docs/reference/type-aliases/RealtimeErrorCode.md index 1bfacec91d..e16b995201 100644 --- a/docs/reference/type-aliases/RealtimeErrorCode.md +++ b/docs/reference/type-aliases/RealtimeErrorCode.md @@ -14,6 +14,6 @@ type RealtimeErrorCode = | "UNKNOWN"; ``` -Defined in: [realtime/types.ts:280](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L280) +Defined in: [packages/typescript/ai/src/realtime/types.ts:280](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L280) Error codes for realtime errors diff --git a/docs/reference/type-aliases/RealtimeEvent.md b/docs/reference/type-aliases/RealtimeEvent.md index 4313815bd0..117084b91e 100644 --- a/docs/reference/type-aliases/RealtimeEvent.md +++ b/docs/reference/type-aliases/RealtimeEvent.md @@ -17,6 +17,6 @@ type RealtimeEvent = | "error"; ``` -Defined in: [realtime/types.ts:238](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L238) +Defined in: [packages/typescript/ai/src/realtime/types.ts:238](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L238) Events emitted by the realtime connection diff --git a/docs/reference/type-aliases/RealtimeEventHandler.md b/docs/reference/type-aliases/RealtimeEventHandler.md index 4b9c3fe843..e9d1d44e6b 100644 --- a/docs/reference/type-aliases/RealtimeEventHandler.md +++ b/docs/reference/type-aliases/RealtimeEventHandler.md @@ -9,7 +9,7 @@ title: RealtimeEventHandler type RealtimeEventHandler = (payload) => void; ``` -Defined in: [realtime/types.ts:269](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L269) +Defined in: [packages/typescript/ai/src/realtime/types.ts:269](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L269) Handler type for realtime events diff --git a/docs/reference/type-aliases/RealtimeMessagePart.md b/docs/reference/type-aliases/RealtimeMessagePart.md index 80292d7b79..a19a771a05 100644 --- a/docs/reference/type-aliases/RealtimeMessagePart.md +++ b/docs/reference/type-aliases/RealtimeMessagePart.md @@ -14,6 +14,6 @@ type RealtimeMessagePart = | RealtimeImagePart; ``` -Defined in: [realtime/types.ts:147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L147) +Defined in: [packages/typescript/ai/src/realtime/types.ts:147](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L147) Union of all realtime message parts diff --git a/docs/reference/type-aliases/RealtimeMode.md b/docs/reference/type-aliases/RealtimeMode.md index a5a26eff24..7f7c6d9178 100644 --- a/docs/reference/type-aliases/RealtimeMode.md +++ b/docs/reference/type-aliases/RealtimeMode.md @@ -9,6 +9,6 @@ title: RealtimeMode type RealtimeMode = "idle" | "listening" | "thinking" | "speaking"; ``` -Defined in: [realtime/types.ts:191](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L191) +Defined in: [packages/typescript/ai/src/realtime/types.ts:191](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L191) Current mode of the realtime session diff --git a/docs/reference/type-aliases/RealtimeStatus.md b/docs/reference/type-aliases/RealtimeStatus.md index fe34f5d353..dd4aee6d47 100644 --- a/docs/reference/type-aliases/RealtimeStatus.md +++ b/docs/reference/type-aliases/RealtimeStatus.md @@ -9,6 +9,6 @@ title: RealtimeStatus type RealtimeStatus = "idle" | "connecting" | "connected" | "reconnecting" | "error"; ``` -Defined in: [realtime/types.ts:181](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L181) +Defined in: [packages/typescript/ai/src/realtime/types.ts:181](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/realtime/types.ts#L181) Connection status of the realtime client diff --git a/docs/reference/type-aliases/SchemaInput.md b/docs/reference/type-aliases/SchemaInput.md index bd1595b71d..c496352e4b 100644 --- a/docs/reference/type-aliases/SchemaInput.md +++ b/docs/reference/type-aliases/SchemaInput.md @@ -11,7 +11,7 @@ type SchemaInput = | JSONSchema; ``` -Defined in: [types.ts:77](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L77) +Defined in: [packages/typescript/ai/src/types.ts:104](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L104) Union type for schema input - can be any Standard JSON Schema compliant schema or a plain JSONSchema object. diff --git a/docs/reference/type-aliases/StreamChunk.md b/docs/reference/type-aliases/StreamChunk.md index 4c0fb5cdb0..0fe7fe8d79 100644 --- a/docs/reference/type-aliases/StreamChunk.md +++ b/docs/reference/type-aliases/StreamChunk.md @@ -9,7 +9,7 @@ title: StreamChunk type StreamChunk = AGUIEvent; ``` -Defined in: [types.ts:976](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L976) +Defined in: [packages/typescript/ai/src/types.ts:1152](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1152) Chunk returned by the SDK during streaming chat completions. Uses the AG-UI protocol event format. diff --git a/docs/reference/type-aliases/StreamChunkType.md b/docs/reference/type-aliases/StreamChunkType.md index a11c3166d1..418daa2206 100644 --- a/docs/reference/type-aliases/StreamChunkType.md +++ b/docs/reference/type-aliases/StreamChunkType.md @@ -3,12 +3,16 @@ id: StreamChunkType title: StreamChunkType --- -# Type Alias: StreamChunkType +# ~~Type Alias: StreamChunkType~~ ```ts type StreamChunkType = AGUIEventType; ``` -Defined in: [types.ts:746](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L746) +Defined in: [packages/typescript/ai/src/types.ts:785](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L785) Stream chunk/event types (AG-UI protocol). + +## Deprecated + +Use `EventType` enum instead. diff --git a/docs/reference/type-aliases/ToolCallState.md b/docs/reference/type-aliases/ToolCallState.md index dc71a615a0..a72ff5d68b 100644 --- a/docs/reference/type-aliases/ToolCallState.md +++ b/docs/reference/type-aliases/ToolCallState.md @@ -14,6 +14,6 @@ type ToolCallState = | "approval-responded"; ``` -Defined in: [types.ts:6](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L6) +Defined in: [packages/typescript/ai/src/types.ts:33](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L33) Tool call states - track the lifecycle of a tool call diff --git a/docs/reference/type-aliases/ToolResultState.md b/docs/reference/type-aliases/ToolResultState.md index c641d4c72a..0a76173d22 100644 --- a/docs/reference/type-aliases/ToolResultState.md +++ b/docs/reference/type-aliases/ToolResultState.md @@ -9,6 +9,6 @@ title: ToolResultState type ToolResultState = "streaming" | "complete" | "error"; ``` -Defined in: [types.ts:16](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L16) +Defined in: [packages/typescript/ai/src/types.ts:43](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L43) Tool result states - track the lifecycle of a tool result diff --git a/docs/reference/variables/defaultJSONParser.md b/docs/reference/variables/defaultJSONParser.md index 0c72078d07..6f3d4f4688 100644 --- a/docs/reference/variables/defaultJSONParser.md +++ b/docs/reference/variables/defaultJSONParser.md @@ -9,6 +9,6 @@ title: defaultJSONParser const defaultJSONParser: PartialJSONParser; ``` -Defined in: [activities/chat/stream/json-parser.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L49) +Defined in: [packages/typescript/ai/src/activities/chat/stream/json-parser.ts:49](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/json-parser.ts#L49) Default parser instance diff --git a/docs/tools/client-tools.md b/docs/tools/client-tools.md index 64f572b3f1..f65cde7b6d 100644 --- a/docs/tools/client-tools.md +++ b/docs/tools/client-tools.md @@ -2,6 +2,15 @@ title: Client Tools id: client-tools order: 4 +description: "Client tools in TanStack AI run in the browser for UI updates, localStorage, and browser API access with type-safe onToolCall handling." +keywords: + - tanstack ai + - client tools + - browser tools + - ui tools + - onToolCall + - clientTools + - localStorage --- Client tools execute in the browser, enabling UI updates, local storage access, and browser API interactions. Unlike server tools, client tools don't have an `execute` function in their server definition. diff --git a/docs/tools/lazy-tool-discovery.md b/docs/tools/lazy-tool-discovery.md index 55b339a5cb..70625dfbc9 100644 --- a/docs/tools/lazy-tool-discovery.md +++ b/docs/tools/lazy-tool-discovery.md @@ -2,6 +2,15 @@ title: Lazy Tool Discovery id: lazy-tool-discovery order: 6 +description: "Reduce token cost in tool-heavy TanStack AI apps with lazy tool discovery — the LLM discovers only the tools it needs for the current task." +keywords: + - tanstack ai + - lazy tools + - tool discovery + - token optimization + - context optimization + - performance + - large tool sets --- When an application has many tools, sending all tool definitions to the LLM on every request wastes tokens and can degrade response quality. Lazy tool discovery lets the LLM selectively discover only the tools it needs for the current task. diff --git a/docs/tools/provider-tools.md b/docs/tools/provider-tools.md new file mode 100644 index 0000000000..865f266f8f --- /dev/null +++ b/docs/tools/provider-tools.md @@ -0,0 +1,93 @@ +--- +title: Provider Tools +id: provider-tools +order: 2 +--- + +Most providers expose native tools beyond user-defined function calls: web +search, code execution, computer use, hosted retrieval, and more. TanStack AI +exports each provider's native tools from a dedicated `/tools` subpath per +adapter package. + +You have an adapter already wired up. You want to give the model access to a +provider-native capability (e.g. Anthropic web search) and be sure you never +pair a tool with a model that doesn't support it. By the end of this page, +you'll have imported the factory, added it to `chat({ tools: [...] })`, and +understood the compile-time guard that will catch unsupported combinations. + +## Import + +Every adapter ships provider tools on a `/tools` subpath: + +```typescript +import { webSearchTool } from '@tanstack/ai-anthropic/tools' +import { codeInterpreterTool } from '@tanstack/ai-openai/tools' +import { googleSearchTool } from '@tanstack/ai-gemini/tools' +``` + +## Use in `chat({ tools })` + +```typescript +import { chat } from '@tanstack/ai' +import { anthropicText } from '@tanstack/ai-anthropic' +import { webSearchTool } from '@tanstack/ai-anthropic/tools' + +const stream = chat({ + adapter: anthropicText('claude-opus-4-6'), + messages: [{ role: 'user', content: "Summarize today's AI news." }], + tools: [ + webSearchTool({ + name: 'web_search', + type: 'web_search_20250305', + max_uses: 3, + }), + ], +}) +``` + +## Type-level guard + +Every provider-specific tool factory (e.g. `webSearchTool`, `computerUseTool`) +returns a `ProviderTool` brand. The adapter's +`toolCapabilities` (derived from each model's `supports.tools` list) gates +which brands are assignable to `tools`. + +Paste a `computerUseTool(...)` into a model that doesn't expose it, and +TypeScript reports an error on that array element — not on the factory call, +not at runtime. User-defined `toolDefinition()` tools stay unbranded and +always assignable. The `customTool` factories exported from `ai-anthropic` and +`ai-openai` also return a plain `Tool` (not a `ProviderTool` brand) and are +therefore universally accepted by any chat model, just like `toolDefinition()`. + +## Available tools + +| Provider | Tools | +|---|---| +| Anthropic | `webSearchTool`, `webFetchTool`, `codeExecutionTool`, `computerUseTool`, `bashTool`, `textEditorTool`, `memoryTool` — see [Anthropic adapter](../adapters/anthropic.md#provider-tools). | +| OpenAI | `webSearchTool`, `webSearchPreviewTool`, `fileSearchTool`, `imageGenerationTool`, `codeInterpreterTool`, `mcpTool`, `computerUseTool`, `localShellTool`, `shellTool`, `applyPatchTool` — see [OpenAI adapter](../adapters/openai.md#provider-tools). | +| Gemini | `codeExecutionTool`, `fileSearchTool`, `googleSearchTool`, `googleSearchRetrievalTool`, `googleMapsTool`, `urlContextTool`, `computerUseTool` — see [Gemini adapter](../adapters/gemini.md#provider-tools). | +| OpenRouter | `webSearchTool` — see [OpenRouter adapter](../adapters/openrouter.md#provider-tools). | +| Grok | function tools only (no provider-specific tools). | +| Groq | function tools only (no provider-specific tools). | + +## Which models support which tools? + +Each adapter's `supports.tools` array is the source of truth. The comparison +matrix is maintained alongside `model-meta.ts` and reflected here: + +- **Anthropic**: every current model except `claude-3-haiku` (web_search only) + and `claude-3-5-haiku` (web tools only). +- **OpenAI**: GPT-5 family and reasoning models (O-series) support the full + superset. GPT-4-series supports web/file/image/code/mcp but not + preview/shell variants. GPT-3.5 and audio-focused models: none. +- **Gemini**: 3.x Pro/Flash models support the full tool set. Lite and + image/video variants have narrower support. +- **OpenRouter**: every chat model supports `webSearchTool` via the gateway. + +For the exact per-model list, open the adapter page or read the model's +`supports.tools` array directly from `model-meta.ts`. + +## Migrating from earlier versions + +If you were using `createWebSearchTool` from `@tanstack/ai-openrouter`, see +[Migration Guide §6](../migration/migration.md#6-provider-tools-moved-to-tools-subpath). diff --git a/docs/tools/server-tools.md b/docs/tools/server-tools.md index bcae69ecf1..69bf1552d4 100644 --- a/docs/tools/server-tools.md +++ b/docs/tools/server-tools.md @@ -2,6 +2,14 @@ title: Server Tools id: server-tools order: 3 +description: "Server tools in TanStack AI execute automatically with full access to databases, APIs, and environment variables. Patterns, examples, and security." +keywords: + - tanstack ai + - server tools + - function calling + - backend tools + - tool execute + - database access --- Server tools execute automatically when called by the LLM. They have full access to server resources like databases, APIs, and environment variables. diff --git a/docs/tools/tool-approval.md b/docs/tools/tool-approval.md index 28a2347061..67c597fa41 100644 --- a/docs/tools/tool-approval.md +++ b/docs/tools/tool-approval.md @@ -2,6 +2,15 @@ title: Tool Approval Flow id: tool-approval-flow order: 5 +description: "Require user approval before executing sensitive tools in TanStack AI — approval states, deny flows, and batched approvals with needsApproval." +keywords: + - tanstack ai + - tool approval + - needsApproval + - user consent + - sensitive tools + - approval flow + - human-in-the-loop --- The tool approval flow allows you to require user approval before executing sensitive tools, giving users control over actions like sending emails, making purchases, or deleting data. Tools go through these states during approval: diff --git a/docs/tools/tool-architecture.md b/docs/tools/tool-architecture.md index 175637d26b..3e7dbf0a72 100644 --- a/docs/tools/tool-architecture.md +++ b/docs/tools/tool-architecture.md @@ -2,6 +2,15 @@ title: Tool Architecture id: tool-architecture order: 2 +description: "The architecture behind TanStack AI's tool system — server tools, client tools, call states, approval flow, and the agentic cycle." +keywords: + - tanstack ai + - tool architecture + - server tools + - client tools + - call states + - approval flow + - agentic cycle --- The TanStack AI tool system provides a powerful, flexible architecture for enabling AI agents to interact with external systems: diff --git a/docs/tools/tools.md b/docs/tools/tools.md index c0a651a957..3d4ffdd569 100644 --- a/docs/tools/tools.md +++ b/docs/tools/tools.md @@ -2,6 +2,16 @@ title: Tools id: tools order: 1 +description: "Define isomorphic AI tools in TanStack AI with toolDefinition() for type-safe server- and client-side function calling across any framework." +keywords: + - tanstack ai + - tools + - function calling + - toolDefinition + - isomorphic tools + - server tools + - client tools + - type safety --- Tools (also called "function calling") allow AI models to interact with external systems, APIs, or perform computations. TanStack AI provides an isomorphic tool system that enables type-safe, framework-agnostic tool definitions that work on both server and client. @@ -14,6 +24,9 @@ Tools enable your AI application to: - **Execute client-side operations** like updating UI or local storage - **Create hybrid tools** that execute in both server and client contexts +> Looking for provider-native tools like Anthropic web search, OpenAI code +> interpreter, or Gemini URL context? See [Provider Tools](./provider-tools.md). + ## Framework Support TanStack AI works with **any** JavaScript framework: diff --git a/examples/ts-react-chat/package.json b/examples/ts-react-chat/package.json index 3e1b9ca3b5..60cfe68369 100644 --- a/examples/ts-react-chat/package.json +++ b/examples/ts-react-chat/package.json @@ -14,6 +14,7 @@ "@tanstack/ai-anthropic": "workspace:*", "@tanstack/ai-client": "workspace:*", "@tanstack/ai-elevenlabs": "workspace:*", + "@tanstack/ai-fal": "workspace:*", "@tanstack/ai-gemini": "workspace:*", "@tanstack/ai-grok": "workspace:*", "@tanstack/ai-groq": "workspace:*", diff --git a/examples/ts-react-chat/src/components/Header.tsx b/examples/ts-react-chat/src/components/Header.tsx index 0b28cbc484..edd44fd63f 100644 --- a/examples/ts-react-chat/src/components/Header.tsx +++ b/examples/ts-react-chat/src/components/Header.tsx @@ -2,6 +2,7 @@ import { Link } from '@tanstack/react-router' import { useState } from 'react' import { + Braces, FileAudio, FileText, Guitar, @@ -9,6 +10,8 @@ import { Image, Menu, Mic, + Music, + Server, Video, X, } from 'lucide-react' @@ -99,6 +102,19 @@ export default function Header() { Text-to-Speech + setIsOpen(false)} + className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-1" + activeProps={{ + className: + 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-1', + }} + > + + Audio Generation + + setIsOpen(false)} @@ -138,6 +154,19 @@ export default function Header() { Video Generation + setIsOpen(false)} + className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-1" + activeProps={{ + className: + 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-1', + }} + > + + Structured Output (OpenRouter) + +

@@ -169,6 +198,19 @@ export default function Header() { Voice Chat (Realtime) + + setIsOpen(false)} + className="flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-2" + activeProps={{ + className: + 'flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-2', + }} + > + + Server Function Chat + diff --git a/examples/ts-react-chat/src/lib/audio-providers.ts b/examples/ts-react-chat/src/lib/audio-providers.ts new file mode 100644 index 0000000000..226aeb0024 --- /dev/null +++ b/examples/ts-react-chat/src/lib/audio-providers.ts @@ -0,0 +1,247 @@ +/** + * Shared catalog of audio-related providers shown in the example pages. + * + * Each entry lists a display label plus the provider model we exercise so + * the UI can render consistent tabs/selectors across speech, transcription, + * and audio generation flows. + */ + +export type SpeechProviderId = 'openai' | 'gemini' | 'fal' | 'grok' + +export interface SpeechProviderConfig { + id: SpeechProviderId + label: string + model: string + /** Voices the UI will surface for this provider. */ + voices: ReadonlyArray<{ id: string; label: string }> + /** Placeholder shown in the text area. */ + placeholder: string +} + +export const SPEECH_PROVIDERS: ReadonlyArray = [ + { + id: 'openai', + label: 'OpenAI TTS', + model: 'tts-1', + voices: [ + { id: 'alloy', label: 'Alloy' }, + { id: 'echo', label: 'Echo' }, + { id: 'fable', label: 'Fable' }, + { id: 'onyx', label: 'Onyx' }, + { id: 'nova', label: 'Nova' }, + { id: 'shimmer', label: 'Shimmer' }, + ], + placeholder: 'Enter text to read aloud with OpenAI TTS…', + }, + { + id: 'gemini', + label: 'Gemini TTS', + model: 'gemini-2.5-flash-preview-tts', + voices: [ + { id: 'Kore', label: 'Kore' }, + { id: 'Puck', label: 'Puck' }, + { id: 'Zephyr', label: 'Zephyr' }, + ], + placeholder: 'Enter text for Gemini speech…', + }, + { + id: 'fal', + label: 'Fal (Kokoro)', + model: 'fal-ai/kokoro/american-english', + voices: [ + { id: 'af_heart', label: 'Heart' }, + { id: 'af_sky', label: 'Sky' }, + { id: 'am_adam', label: 'Adam' }, + ], + placeholder: 'Enter text to synthesize with Fal Kokoro…', + }, + { + id: 'grok', + label: 'Grok TTS', + model: 'grok-tts', + voices: [ + { id: 'eve', label: 'Eve' }, + { id: 'ara', label: 'Ara' }, + { id: 'rex', label: 'Rex' }, + { id: 'sal', label: 'Sal' }, + { id: 'leo', label: 'Leo' }, + ], + placeholder: 'Enter text for Grok speech…', + }, +] + +export type TranscriptionProviderId = 'openai' | 'fal' | 'grok' + +export interface TranscriptionProviderConfig { + id: TranscriptionProviderId + label: string + model: string + description: string +} + +export const TRANSCRIPTION_PROVIDERS: ReadonlyArray = + [ + { + id: 'openai', + label: 'OpenAI Whisper', + model: 'whisper-1', + description: 'OpenAI Whisper transcription with optional streaming.', + }, + { + id: 'fal', + label: 'Fal Whisper', + model: 'fal-ai/whisper', + description: 'Fal-hosted Whisper with word-level timestamps.', + }, + { + id: 'grok', + label: 'Grok STT', + model: 'grok-stt', + description: 'xAI speech-to-text with word-level timestamps.', + }, + ] + +export type AudioProviderId = 'gemini-lyria' | 'fal-audio' | 'fal-sfx' + +export interface AudioProviderConfig { + id: AudioProviderId + label: string + /** Default model when the provider does not expose a chooser. */ + model: string + description: string + placeholder: string + /** Default generation length in seconds, when the provider accepts one. */ + defaultDuration?: number + /** Ready-made prompts the UI can offer as one-click suggestions. */ + samplePrompts: ReadonlyArray<{ label: string; prompt: string }> + /** + * Optional list of alternate models the UI can expose via a dropdown. + * By convention the entry matching {@link model} is listed first so it + * appears at the top of the selector, but nothing enforces that — the UI + * seeds the selection from {@link model} directly. + */ + models?: ReadonlyArray<{ id: string; label: string }> +} + +export const AUDIO_PROVIDERS: ReadonlyArray = [ + { + id: 'gemini-lyria', + label: 'Gemini Lyria', + model: 'lyria-3-clip-preview', + models: [ + { + id: 'lyria-3-clip-preview', + label: 'Lyria 3 Clip (30s MP3)', + }, + { + id: 'lyria-3-pro-preview', + label: 'Lyria 3 Pro (full-length MP3/WAV)', + }, + ], + description: 'Google Lyria 3 music generation.', + placeholder: 'Ambient piano with warm pads and soft strings', + samplePrompts: [ + { + label: 'Late-night jazz trio', + prompt: + 'A contemplative jazz trio with brushed drums, walking upright bass, and smoky piano chords.', + }, + { + label: 'Hero at dawn', + prompt: + 'An epic film score for a hero cresting a mountain at dawn: horns, choir, and taiko drums.', + }, + { + label: 'Haunted elevator', + prompt: + 'Cheerful 1950s elevator music, but subtly out of tune, like the elevator is haunted.', + }, + { + label: 'Polka funeral', + prompt: + 'A funeral dirge unexpectedly remixed as an upbeat accordion polka.', + }, + ], + }, + { + id: 'fal-audio', + label: 'Fal Audio', + model: 'fal-ai/elevenlabs/music', + models: [ + { id: 'fal-ai/elevenlabs/music', label: 'ElevenLabs Music' }, + { + id: 'fal-ai/stable-audio-25/text-to-audio', + label: 'Stable Audio 2.5', + }, + { + id: 'fal-ai/ace-step/prompt-to-audio', + label: 'ACE-Step (prompt-to-audio)', + }, + ], + description: 'Fal-hosted open music generation models.', + placeholder: 'A lo-fi hip-hop beat with vinyl crackle', + defaultDuration: 10, + samplePrompts: [ + { + label: 'Lo-fi study beat', + prompt: + 'A mellow lo-fi hip-hop beat with warm vinyl crackle, dusty Rhodes chords, and soft swing.', + }, + { + label: 'Ambient drone', + prompt: + 'A slow ambient drone with shimmering reverb, distant field recordings, and evolving pads.', + }, + { + label: 'Seagull Eurovision', + prompt: + 'A Eurovision-style power ballad performed entirely by a choir of disgruntled seagulls.', + }, + { + label: 'Hydrophobic pirate', + prompt: + 'The rousing theme song for a swashbuckling pirate who is terrified of water.', + }, + { + label: 'Death metal laundry', + prompt: + 'A death metal ballad about losing your favorite socks in the dryer, complete with guttural vocals.', + }, + ], + }, + { + id: 'fal-sfx', + label: 'Fal SFX', + model: 'fal-ai/mmaudio-v2/text-to-audio', + models: [ + { + id: 'fal-ai/mmaudio-v2/text-to-audio', + label: 'MMAudio v2 Text-to-Audio', + }, + ], + description: 'Fal-hosted text-to-SFX models for short sound effects.', + placeholder: 'Glass shattering on a tile floor', + defaultDuration: 5, + samplePrompts: [ + { + label: 'Rain on tin roof', + prompt: 'Steady rain pattering on a corrugated metal roof at night.', + }, + { + label: 'Marble hallway steps', + prompt: + 'Slow leather-soled footsteps echoing through an empty marble hallway.', + }, + { + label: 'Interrogated duck', + prompt: + 'A rubber duck being dramatically interrogated under a swinging lamp, squeaks only.', + }, + { + label: 'Cartoon banana slip', + prompt: + 'Classic cartoon banana slip: quick slide, comedic boing, and a distant crash.', + }, + ], + }, +] diff --git a/examples/ts-react-chat/src/lib/server-audio-adapters.ts b/examples/ts-react-chat/src/lib/server-audio-adapters.ts new file mode 100644 index 0000000000..77336629da --- /dev/null +++ b/examples/ts-react-chat/src/lib/server-audio-adapters.ts @@ -0,0 +1,146 @@ +/** + * Server-side adapter factories for the audio example pages. + * + * Keeping these in one place lets the HTTP routes and the TanStack Start server + * functions share the same model choices without duplicating provider wiring. + */ + +import { openaiSpeech, openaiTranscription } from '@tanstack/ai-openai' +import { geminiAudio, geminiSpeech } from '@tanstack/ai-gemini' +import { falAudio, falSpeech, falTranscription } from '@tanstack/ai-fal' +import { grokSpeech, grokTranscription } from '@tanstack/ai-grok' +import type { + AnyAudioAdapter, + AnyTranscriptionAdapter, + AnyTTSAdapter, +} from '@tanstack/ai' +import { + AUDIO_PROVIDERS, + SPEECH_PROVIDERS, + TRANSCRIPTION_PROVIDERS, + type AudioProviderId, + type SpeechProviderId, + type TranscriptionProviderId, +} from './audio-providers' + +function findConfig( + list: ReadonlyArray, + id: string, +): T { + const match = list.find((entry) => entry.id === id) + if (!match) { + throw new UnknownProviderError( + id, + list.map((entry) => entry.id), + ) + } + return match +} + +export function buildSpeechAdapter(provider: SpeechProviderId): AnyTTSAdapter { + const config = findConfig(SPEECH_PROVIDERS, provider) + switch (config.id) { + case 'openai': + return openaiSpeech(config.model as 'tts-1') + case 'gemini': + return geminiSpeech(config.model as 'gemini-2.5-flash-preview-tts') + case 'fal': + return falSpeech(config.model) + case 'grok': + return grokSpeech(config.model as 'grok-tts') + } +} + +export function buildTranscriptionAdapter( + provider: TranscriptionProviderId, +): AnyTranscriptionAdapter { + const config = findConfig(TRANSCRIPTION_PROVIDERS, provider) + switch (config.id) { + case 'openai': + return openaiTranscription(config.model as 'whisper-1') + case 'fal': + return falTranscription(config.model) + case 'grok': + return grokTranscription(config.model as 'grok-stt') + } +} + +export function buildAudioAdapter( + provider: AudioProviderId, + modelOverride?: string, +): AnyAudioAdapter { + const config = findConfig(AUDIO_PROVIDERS, provider) + const model = resolveModel(config, modelOverride) + switch (config.id) { + case 'gemini-lyria': + return geminiAudio( + model as 'lyria-3-clip-preview' | 'lyria-3-pro-preview', + ) + case 'fal-audio': + case 'fal-sfx': + return falAudio(model) + } +} + +/** + * Thrown when a caller supplies a `modelOverride` that is not present in the + * provider's allowed model list. HTTP routes map this to a 400 response so the + * user sees a clear rejection instead of silently getting output from the + * default model. + */ +export class InvalidModelOverrideError extends Error { + readonly code = 'invalid_model_override' as const + readonly providerId: string + readonly requestedModel: string + readonly allowedModels: ReadonlyArray + + constructor( + providerId: string, + requestedModel: string, + allowedModels: ReadonlyArray, + ) { + super( + `Invalid model override "${requestedModel}" for provider "${providerId}". Allowed models: ${ + allowedModels.length > 0 ? allowedModels.join(', ') : '(none)' + }`, + ) + this.name = 'InvalidModelOverrideError' + this.providerId = providerId + this.requestedModel = requestedModel + this.allowedModels = allowedModels + } +} + +/** + * Thrown when `findConfig` is called with a provider id that isn't in the + * allowed list. In practice the route-level Zod enum schema already rejects + * unknown providers before we ever reach this builder, so this is + * defense-in-depth for callers that bypass Zod validation (e.g. server-fns + * whose input schemas could drift from the provider registries). + */ +export class UnknownProviderError extends Error { + readonly code = 'unknown_provider' as const + readonly providerId: string + readonly allowedProviders: ReadonlyArray + + constructor(providerId: string, allowedProviders: ReadonlyArray) { + super( + `Unknown provider "${providerId}". Allowed providers: ${ + allowedProviders.length > 0 ? allowedProviders.join(', ') : '(none)' + }`, + ) + this.name = 'UnknownProviderError' + this.providerId = providerId + this.allowedProviders = allowedProviders + } +} + +function resolveModel( + config: (typeof AUDIO_PROVIDERS)[number], + modelOverride: string | undefined, +): string { + if (!modelOverride) return config.model + const allowedModels = config.models?.map((m) => m.id) ?? [] + if (allowedModels.includes(modelOverride)) return modelOverride + throw new InvalidModelOverrideError(config.id, modelOverride, allowedModels) +} diff --git a/examples/ts-react-chat/src/lib/server-fns.ts b/examples/ts-react-chat/src/lib/server-fns.ts index 624de8e89c..d2ae042502 100644 --- a/examples/ts-react-chat/src/lib/server-fns.ts +++ b/examples/ts-react-chat/src/lib/server-fns.ts @@ -1,6 +1,8 @@ import { createServerFn } from '@tanstack/react-start' import { z } from 'zod' import { + chat, + generateAudio, generateImage, generateSpeech, generateTranscription, @@ -11,11 +13,77 @@ import { } from '@tanstack/ai' import { openaiImage, - openaiSpeech, - openaiTranscription, openaiSummarize, + openaiText, openaiVideo, } from '@tanstack/ai-openai' +import { + InvalidModelOverrideError, + UnknownProviderError, + buildAudioAdapter, + buildSpeechAdapter, + buildTranscriptionAdapter, +} from './server-audio-adapters' +import type { UIMessage } from '@tanstack/ai' + +/** + * Server-fn error with a stable `code` property clients can switch on. + * + * TanStack Start's `createServerFn` surfaces thrown errors as a generic 500 + * without a structured payload. We can't influence the status code from here, + * so we attach a `code` field the client can read to distinguish well-known + * failure modes (invalid_model_override, unknown_provider) from truly + * unexpected errors. + */ +class ServerFnError extends Error { + readonly code: string + readonly details?: Record + + constructor( + code: string, + message: string, + details?: Record, + ) { + super(message) + this.name = 'ServerFnError' + this.code = code + this.details = details + } +} + +/** + * Translate the typed audio-adapter errors into a `ServerFnError` with a stable + * `code`. Any other error is re-thrown untouched so the framework's default + * 500 path handles it. + */ +function rethrowAudioAdapterError(err: unknown): never { + if (err instanceof InvalidModelOverrideError) { + throw new ServerFnError('invalid_model_override', err.message, { + providerId: err.providerId, + requestedModel: err.requestedModel, + allowedModels: err.allowedModels, + }) + } + if (err instanceof UnknownProviderError) { + throw new ServerFnError('unknown_provider', err.message, { + providerId: err.providerId, + allowedProviders: err.allowedProviders, + }) + } + throw err +} + +const SPEECH_PROVIDER_SCHEMA = z + .enum(['openai', 'gemini', 'fal', 'grok']) + .optional() + +const TRANSCRIPTION_PROVIDER_SCHEMA = z + .enum(['openai', 'fal', 'grok']) + .optional() + +const AUDIO_PROVIDER_SCHEMA = z + .enum(['gemini-lyria', 'fal-audio', 'fal-sfx']) + .optional() // ============================================================================= // Direct server functions (non-streaming, return the result directly) @@ -44,11 +112,21 @@ export const generateSpeechFn = createServerFn({ method: 'POST' }) text: z.string(), voice: z.string().optional(), format: z.enum(['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm']).optional(), + provider: SPEECH_PROVIDER_SCHEMA, }), ) .handler(async ({ data }) => { + // `buildSpeechAdapter` can throw `UnknownProviderError` (defense-in-depth; + // Zod should catch this first). Translate into a `ServerFnError` so + // clients can distinguish it from a generic failure via the stable `code`. + let adapter + try { + adapter = buildSpeechAdapter(data.provider ?? 'openai') + } catch (err) { + rethrowAudioAdapterError(err) + } return generateSpeech({ - adapter: openaiSpeech('tts-1'), + adapter, text: data.text, voice: data.voice, format: data.format, @@ -60,16 +138,54 @@ export const transcribeFn = createServerFn({ method: 'POST' }) z.object({ audio: z.string(), language: z.string().optional(), + provider: TRANSCRIPTION_PROVIDER_SCHEMA, }), ) .handler(async ({ data }) => { + // `buildTranscriptionAdapter` can throw `UnknownProviderError` + // (defense-in-depth; Zod should catch this first). Translate into a + // `ServerFnError` so clients can distinguish it from a generic failure + // via the stable `code`. + let adapter + try { + adapter = buildTranscriptionAdapter(data.provider ?? 'openai') + } catch (err) { + rethrowAudioAdapterError(err) + } return generateTranscription({ - adapter: openaiTranscription('whisper-1'), + adapter, audio: data.audio, language: data.language, }) }) +export const generateAudioFn = createServerFn({ method: 'POST' }) + .inputValidator( + z.object({ + prompt: z.string(), + duration: z.number().optional(), + provider: AUDIO_PROVIDER_SCHEMA, + model: z.string().optional(), + }), + ) + .handler(async ({ data }) => { + // `buildAudioAdapter` can throw `InvalidModelOverrideError` (unknown + // model id) or `UnknownProviderError` (defense-in-depth; Zod should + // catch this first). Translate both into a `ServerFnError` so clients + // can distinguish them from a generic failure via the stable `code`. + let adapter + try { + adapter = buildAudioAdapter(data.provider ?? 'gemini-lyria', data.model) + } catch (err) { + rethrowAudioAdapterError(err) + } + return generateAudio({ + adapter, + prompt: data.prompt, + duration: data.duration, + }) + }) + export const summarizeFn = createServerFn({ method: 'POST' }) .inputValidator( z.object({ @@ -164,12 +280,22 @@ export const generateSpeechStreamFn = createServerFn({ method: 'POST' }) text: z.string(), voice: z.string().optional(), format: z.enum(['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm']).optional(), + provider: SPEECH_PROVIDER_SCHEMA, }), ) .handler(({ data }) => { + // `buildSpeechAdapter` can throw `UnknownProviderError` (defense-in-depth; + // Zod should catch this first). Translate into a `ServerFnError` so + // clients can distinguish it from a generic failure via the stable `code`. + let adapter + try { + adapter = buildSpeechAdapter(data.provider ?? 'openai') + } catch (err) { + rethrowAudioAdapterError(err) + } return toServerSentEventsResponse( generateSpeech({ - adapter: openaiSpeech('tts-1'), + adapter, text: data.text, voice: data.voice, format: data.format, @@ -183,12 +309,23 @@ export const transcribeStreamFn = createServerFn({ method: 'POST' }) z.object({ audio: z.string(), language: z.string().optional(), + provider: TRANSCRIPTION_PROVIDER_SCHEMA, }), ) .handler(({ data }) => { + // `buildTranscriptionAdapter` can throw `UnknownProviderError` + // (defense-in-depth; Zod should catch this first). Translate into a + // `ServerFnError` so clients can distinguish it from a generic failure + // via the stable `code`. + let adapter + try { + adapter = buildTranscriptionAdapter(data.provider ?? 'openai') + } catch (err) { + rethrowAudioAdapterError(err) + } return toServerSentEventsResponse( generateTranscription({ - adapter: openaiTranscription('whisper-1'), + adapter, audio: data.audio, language: data.language, stream: true, @@ -235,3 +372,27 @@ export const generateVideoStreamFn = createServerFn({ method: 'POST' }) }), ) }) + +// ============================================================================= +// Chat server function (streams via SSE Response) +// Used with: stream((messages) => chatFn({ data: { messages } })) +// ============================================================================= + +export const chatFn = createServerFn({ method: 'POST' }) + .inputValidator( + (data: { messages: Array; data?: Record }) => data, + ) + .handler(({ data }) => + toServerSentEventsResponse( + chat({ + adapter: openaiText('gpt-5.2'), + // chat()'s messages option is typed as ConstrainedModelMessage[], but the + // runtime accepts UIMessage[] too (normalised via convertMessagesToModelMessages). + // Cast to bridge the gap until the public type is widened in a separate PR. + messages: data.messages as any, + systemPrompts: [ + 'You are a helpful assistant. Keep replies short and friendly.', + ], + }), + ), + ) diff --git a/examples/ts-react-chat/src/lib/use-realtime.ts b/examples/ts-react-chat/src/lib/use-realtime.ts index 848c702ca0..620c2804f0 100644 --- a/examples/ts-react-chat/src/lib/use-realtime.ts +++ b/examples/ts-react-chat/src/lib/use-realtime.ts @@ -6,9 +6,10 @@ import { elevenlabsRealtime, elevenlabsRealtimeToken, } from '@tanstack/ai-elevenlabs' +import { grokRealtime, grokRealtimeToken } from '@tanstack/ai-grok' import { realtimeClientTools } from '@/lib/realtime-tools' -type Provider = 'openai' | 'elevenlabs' +type Provider = 'openai' | 'elevenlabs' | 'grok' const getRealtimeTokenFn = createServerFn({ method: 'POST' }) .inputValidator((data: { provider: Provider; agentId?: string }) => { @@ -36,12 +37,30 @@ const getRealtimeTokenFn = createServerFn({ method: 'POST' }) }) } + if (data.provider === 'grok') { + return realtimeToken({ + adapter: grokRealtimeToken({ model: 'grok-voice-fast-1.0' }), + }) + } + throw new Error(`Unknown provider: ${data.provider}`) }) +function adapterForProvider(provider: Provider) { + switch (provider) { + case 'openai': + return openaiRealtime() + case 'elevenlabs': + return elevenlabsRealtime() + case 'grok': + return grokRealtime() + } +} + export function useRealtime({ provider, agentId, + voice, outputModalities, temperature, maxOutputTokens, @@ -49,14 +68,12 @@ export function useRealtime({ }: { provider: Provider agentId: string + voice?: string outputModalities?: Array<'audio' | 'text'> temperature?: number maxOutputTokens?: number | 'inf' semanticEagerness?: 'low' | 'medium' | 'high' }) { - const adapter = - provider === 'openai' ? openaiRealtime() : elevenlabsRealtime() - return useRealtimeChat({ getToken: () => getRealtimeTokenFn({ @@ -65,7 +82,7 @@ export function useRealtime({ ...(provider === 'elevenlabs' && agentId ? { agentId } : {}), }, }), - adapter, + adapter: adapterForProvider(provider), instructions: `You are a helpful, friendly voice assistant with access to several tools. You can: @@ -78,7 +95,7 @@ Keep your responses concise and conversational since this is a voice interface. When using tools, briefly explain what you're doing and then share the results naturally. If the user sends an image, describe what you see and answer any questions about it. Be friendly and engaging!`, - voice: 'alloy', + voice: voice ?? (provider === 'grok' ? 'eve' : 'alloy'), tools: realtimeClientTools, outputModalities, temperature, diff --git a/examples/ts-react-chat/src/routeTree.gen.ts b/examples/ts-react-chat/src/routeTree.gen.ts index 4901455277..60779cfa47 100644 --- a/examples/ts-react-chat/src/routeTree.gen.ts +++ b/examples/ts-react-chat/src/routeTree.gen.ts @@ -9,24 +9,34 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' +import { Route as ServerFnChatRouteImport } from './routes/server-fn-chat' import { Route as RealtimeRouteImport } from './routes/realtime' import { Route as ImageGenRouteImport } from './routes/image-gen' import { Route as IndexRouteImport } from './routes/index' import { Route as GenerationsVideoRouteImport } from './routes/generations.video' import { Route as GenerationsTranscriptionRouteImport } from './routes/generations.transcription' import { Route as GenerationsSummarizeRouteImport } from './routes/generations.summarize' +import { Route as GenerationsStructuredOutputRouteImport } from './routes/generations.structured-output' import { Route as GenerationsSpeechRouteImport } from './routes/generations.speech' import { Route as GenerationsImageRouteImport } from './routes/generations.image' +import { Route as GenerationsAudioRouteImport } from './routes/generations.audio' import { Route as ApiTranscribeRouteImport } from './routes/api.transcribe' import { Route as ApiTanchatRouteImport } from './routes/api.tanchat' import { Route as ApiSummarizeRouteImport } from './routes/api.summarize' +import { Route as ApiStructuredOutputRouteImport } from './routes/api.structured-output' import { Route as ApiImageGenRouteImport } from './routes/api.image-gen' import { Route as ExampleGuitarsIndexRouteImport } from './routes/example.guitars/index' import { Route as ExampleGuitarsGuitarIdRouteImport } from './routes/example.guitars/$guitarId' import { Route as ApiGenerateVideoRouteImport } from './routes/api.generate.video' import { Route as ApiGenerateSpeechRouteImport } from './routes/api.generate.speech' import { Route as ApiGenerateImageRouteImport } from './routes/api.generate.image' +import { Route as ApiGenerateAudioRouteImport } from './routes/api.generate.audio' +const ServerFnChatRoute = ServerFnChatRouteImport.update({ + id: '/server-fn-chat', + path: '/server-fn-chat', + getParentRoute: () => rootRouteImport, +} as any) const RealtimeRoute = RealtimeRouteImport.update({ id: '/realtime', path: '/realtime', @@ -58,6 +68,12 @@ const GenerationsSummarizeRoute = GenerationsSummarizeRouteImport.update({ path: '/generations/summarize', getParentRoute: () => rootRouteImport, } as any) +const GenerationsStructuredOutputRoute = + GenerationsStructuredOutputRouteImport.update({ + id: '/generations/structured-output', + path: '/generations/structured-output', + getParentRoute: () => rootRouteImport, + } as any) const GenerationsSpeechRoute = GenerationsSpeechRouteImport.update({ id: '/generations/speech', path: '/generations/speech', @@ -68,6 +84,11 @@ const GenerationsImageRoute = GenerationsImageRouteImport.update({ path: '/generations/image', getParentRoute: () => rootRouteImport, } as any) +const GenerationsAudioRoute = GenerationsAudioRouteImport.update({ + id: '/generations/audio', + path: '/generations/audio', + getParentRoute: () => rootRouteImport, +} as any) const ApiTranscribeRoute = ApiTranscribeRouteImport.update({ id: '/api/transcribe', path: '/api/transcribe', @@ -83,6 +104,11 @@ const ApiSummarizeRoute = ApiSummarizeRouteImport.update({ path: '/api/summarize', getParentRoute: () => rootRouteImport, } as any) +const ApiStructuredOutputRoute = ApiStructuredOutputRouteImport.update({ + id: '/api/structured-output', + path: '/api/structured-output', + getParentRoute: () => rootRouteImport, +} as any) const ApiImageGenRoute = ApiImageGenRouteImport.update({ id: '/api/image-gen', path: '/api/image-gen', @@ -113,20 +139,30 @@ const ApiGenerateImageRoute = ApiGenerateImageRouteImport.update({ path: '/api/generate/image', getParentRoute: () => rootRouteImport, } as any) +const ApiGenerateAudioRoute = ApiGenerateAudioRouteImport.update({ + id: '/api/generate/audio', + path: '/api/generate/audio', + getParentRoute: () => rootRouteImport, +} as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute '/image-gen': typeof ImageGenRoute '/realtime': typeof RealtimeRoute + '/server-fn-chat': typeof ServerFnChatRoute '/api/image-gen': typeof ApiImageGenRoute + '/api/structured-output': typeof ApiStructuredOutputRoute '/api/summarize': typeof ApiSummarizeRoute '/api/tanchat': typeof ApiTanchatRoute '/api/transcribe': typeof ApiTranscribeRoute + '/generations/audio': typeof GenerationsAudioRoute '/generations/image': typeof GenerationsImageRoute '/generations/speech': typeof GenerationsSpeechRoute + '/generations/structured-output': typeof GenerationsStructuredOutputRoute '/generations/summarize': typeof GenerationsSummarizeRoute '/generations/transcription': typeof GenerationsTranscriptionRoute '/generations/video': typeof GenerationsVideoRoute + '/api/generate/audio': typeof ApiGenerateAudioRoute '/api/generate/image': typeof ApiGenerateImageRoute '/api/generate/speech': typeof ApiGenerateSpeechRoute '/api/generate/video': typeof ApiGenerateVideoRoute @@ -137,15 +173,20 @@ export interface FileRoutesByTo { '/': typeof IndexRoute '/image-gen': typeof ImageGenRoute '/realtime': typeof RealtimeRoute + '/server-fn-chat': typeof ServerFnChatRoute '/api/image-gen': typeof ApiImageGenRoute + '/api/structured-output': typeof ApiStructuredOutputRoute '/api/summarize': typeof ApiSummarizeRoute '/api/tanchat': typeof ApiTanchatRoute '/api/transcribe': typeof ApiTranscribeRoute + '/generations/audio': typeof GenerationsAudioRoute '/generations/image': typeof GenerationsImageRoute '/generations/speech': typeof GenerationsSpeechRoute + '/generations/structured-output': typeof GenerationsStructuredOutputRoute '/generations/summarize': typeof GenerationsSummarizeRoute '/generations/transcription': typeof GenerationsTranscriptionRoute '/generations/video': typeof GenerationsVideoRoute + '/api/generate/audio': typeof ApiGenerateAudioRoute '/api/generate/image': typeof ApiGenerateImageRoute '/api/generate/speech': typeof ApiGenerateSpeechRoute '/api/generate/video': typeof ApiGenerateVideoRoute @@ -157,15 +198,20 @@ export interface FileRoutesById { '/': typeof IndexRoute '/image-gen': typeof ImageGenRoute '/realtime': typeof RealtimeRoute + '/server-fn-chat': typeof ServerFnChatRoute '/api/image-gen': typeof ApiImageGenRoute + '/api/structured-output': typeof ApiStructuredOutputRoute '/api/summarize': typeof ApiSummarizeRoute '/api/tanchat': typeof ApiTanchatRoute '/api/transcribe': typeof ApiTranscribeRoute + '/generations/audio': typeof GenerationsAudioRoute '/generations/image': typeof GenerationsImageRoute '/generations/speech': typeof GenerationsSpeechRoute + '/generations/structured-output': typeof GenerationsStructuredOutputRoute '/generations/summarize': typeof GenerationsSummarizeRoute '/generations/transcription': typeof GenerationsTranscriptionRoute '/generations/video': typeof GenerationsVideoRoute + '/api/generate/audio': typeof ApiGenerateAudioRoute '/api/generate/image': typeof ApiGenerateImageRoute '/api/generate/speech': typeof ApiGenerateSpeechRoute '/api/generate/video': typeof ApiGenerateVideoRoute @@ -178,15 +224,20 @@ export interface FileRouteTypes { | '/' | '/image-gen' | '/realtime' + | '/server-fn-chat' | '/api/image-gen' + | '/api/structured-output' | '/api/summarize' | '/api/tanchat' | '/api/transcribe' + | '/generations/audio' | '/generations/image' | '/generations/speech' + | '/generations/structured-output' | '/generations/summarize' | '/generations/transcription' | '/generations/video' + | '/api/generate/audio' | '/api/generate/image' | '/api/generate/speech' | '/api/generate/video' @@ -197,15 +248,20 @@ export interface FileRouteTypes { | '/' | '/image-gen' | '/realtime' + | '/server-fn-chat' | '/api/image-gen' + | '/api/structured-output' | '/api/summarize' | '/api/tanchat' | '/api/transcribe' + | '/generations/audio' | '/generations/image' | '/generations/speech' + | '/generations/structured-output' | '/generations/summarize' | '/generations/transcription' | '/generations/video' + | '/api/generate/audio' | '/api/generate/image' | '/api/generate/speech' | '/api/generate/video' @@ -216,15 +272,20 @@ export interface FileRouteTypes { | '/' | '/image-gen' | '/realtime' + | '/server-fn-chat' | '/api/image-gen' + | '/api/structured-output' | '/api/summarize' | '/api/tanchat' | '/api/transcribe' + | '/generations/audio' | '/generations/image' | '/generations/speech' + | '/generations/structured-output' | '/generations/summarize' | '/generations/transcription' | '/generations/video' + | '/api/generate/audio' | '/api/generate/image' | '/api/generate/speech' | '/api/generate/video' @@ -236,15 +297,20 @@ export interface RootRouteChildren { IndexRoute: typeof IndexRoute ImageGenRoute: typeof ImageGenRoute RealtimeRoute: typeof RealtimeRoute + ServerFnChatRoute: typeof ServerFnChatRoute ApiImageGenRoute: typeof ApiImageGenRoute + ApiStructuredOutputRoute: typeof ApiStructuredOutputRoute ApiSummarizeRoute: typeof ApiSummarizeRoute ApiTanchatRoute: typeof ApiTanchatRoute ApiTranscribeRoute: typeof ApiTranscribeRoute + GenerationsAudioRoute: typeof GenerationsAudioRoute GenerationsImageRoute: typeof GenerationsImageRoute GenerationsSpeechRoute: typeof GenerationsSpeechRoute + GenerationsStructuredOutputRoute: typeof GenerationsStructuredOutputRoute GenerationsSummarizeRoute: typeof GenerationsSummarizeRoute GenerationsTranscriptionRoute: typeof GenerationsTranscriptionRoute GenerationsVideoRoute: typeof GenerationsVideoRoute + ApiGenerateAudioRoute: typeof ApiGenerateAudioRoute ApiGenerateImageRoute: typeof ApiGenerateImageRoute ApiGenerateSpeechRoute: typeof ApiGenerateSpeechRoute ApiGenerateVideoRoute: typeof ApiGenerateVideoRoute @@ -254,6 +320,13 @@ export interface RootRouteChildren { declare module '@tanstack/react-router' { interface FileRoutesByPath { + '/server-fn-chat': { + id: '/server-fn-chat' + path: '/server-fn-chat' + fullPath: '/server-fn-chat' + preLoaderRoute: typeof ServerFnChatRouteImport + parentRoute: typeof rootRouteImport + } '/realtime': { id: '/realtime' path: '/realtime' @@ -296,6 +369,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof GenerationsSummarizeRouteImport parentRoute: typeof rootRouteImport } + '/generations/structured-output': { + id: '/generations/structured-output' + path: '/generations/structured-output' + fullPath: '/generations/structured-output' + preLoaderRoute: typeof GenerationsStructuredOutputRouteImport + parentRoute: typeof rootRouteImport + } '/generations/speech': { id: '/generations/speech' path: '/generations/speech' @@ -310,6 +390,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof GenerationsImageRouteImport parentRoute: typeof rootRouteImport } + '/generations/audio': { + id: '/generations/audio' + path: '/generations/audio' + fullPath: '/generations/audio' + preLoaderRoute: typeof GenerationsAudioRouteImport + parentRoute: typeof rootRouteImport + } '/api/transcribe': { id: '/api/transcribe' path: '/api/transcribe' @@ -331,6 +418,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof ApiSummarizeRouteImport parentRoute: typeof rootRouteImport } + '/api/structured-output': { + id: '/api/structured-output' + path: '/api/structured-output' + fullPath: '/api/structured-output' + preLoaderRoute: typeof ApiStructuredOutputRouteImport + parentRoute: typeof rootRouteImport + } '/api/image-gen': { id: '/api/image-gen' path: '/api/image-gen' @@ -373,6 +467,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof ApiGenerateImageRouteImport parentRoute: typeof rootRouteImport } + '/api/generate/audio': { + id: '/api/generate/audio' + path: '/api/generate/audio' + fullPath: '/api/generate/audio' + preLoaderRoute: typeof ApiGenerateAudioRouteImport + parentRoute: typeof rootRouteImport + } } } @@ -380,15 +481,20 @@ const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, ImageGenRoute: ImageGenRoute, RealtimeRoute: RealtimeRoute, + ServerFnChatRoute: ServerFnChatRoute, ApiImageGenRoute: ApiImageGenRoute, + ApiStructuredOutputRoute: ApiStructuredOutputRoute, ApiSummarizeRoute: ApiSummarizeRoute, ApiTanchatRoute: ApiTanchatRoute, ApiTranscribeRoute: ApiTranscribeRoute, + GenerationsAudioRoute: GenerationsAudioRoute, GenerationsImageRoute: GenerationsImageRoute, GenerationsSpeechRoute: GenerationsSpeechRoute, + GenerationsStructuredOutputRoute: GenerationsStructuredOutputRoute, GenerationsSummarizeRoute: GenerationsSummarizeRoute, GenerationsTranscriptionRoute: GenerationsTranscriptionRoute, GenerationsVideoRoute: GenerationsVideoRoute, + ApiGenerateAudioRoute: ApiGenerateAudioRoute, ApiGenerateImageRoute: ApiGenerateImageRoute, ApiGenerateSpeechRoute: ApiGenerateSpeechRoute, ApiGenerateVideoRoute: ApiGenerateVideoRoute, diff --git a/examples/ts-react-chat/src/routes/api.generate.audio.ts b/examples/ts-react-chat/src/routes/api.generate.audio.ts new file mode 100644 index 0000000000..aade04c8bf --- /dev/null +++ b/examples/ts-react-chat/src/routes/api.generate.audio.ts @@ -0,0 +1,104 @@ +import { createFileRoute } from '@tanstack/react-router' +import { generateAudio, toServerSentEventsResponse } from '@tanstack/ai' +import { z } from 'zod' +import { + InvalidModelOverrideError, + UnknownProviderError, + buildAudioAdapter, +} from '../lib/server-audio-adapters' + +const AUDIO_PROVIDER_SCHEMA = z + .enum(['gemini-lyria', 'fal-audio', 'fal-sfx']) + .optional() + +const AUDIO_BODY_SCHEMA = z.object({ + prompt: z.string().min(1), + duration: z.number().optional(), + provider: AUDIO_PROVIDER_SCHEMA, + model: z.string().optional(), +}) + +function jsonError(status: number, payload: Record) { + return new Response(JSON.stringify(payload), { + status, + headers: { 'content-type': 'application/json' }, + }) +} + +export const Route = createFileRoute('/api/generate/audio')({ + server: { + handlers: { + POST: async ({ request }) => { + let body: unknown + try { + body = await request.json() + } catch { + return jsonError(400, { + error: 'invalid_json', + message: 'Request body must be valid JSON', + }) + } + + const rawData = (body as { data?: unknown } | null)?.data + if (rawData == null) { + return jsonError(400, { + error: 'missing_data', + message: 'Request body must include a `data` field', + }) + } + + const parsed = AUDIO_BODY_SCHEMA.safeParse(rawData) + if (!parsed.success) { + return jsonError(400, { + error: 'validation_failed', + message: 'Request data failed validation', + details: z.treeifyError(parsed.error), + }) + } + + const { prompt, duration, provider, model } = parsed.data + + try { + const adapter = buildAudioAdapter(provider ?? 'gemini-lyria', model) + + const stream = generateAudio({ + adapter, + prompt, + duration, + stream: true, + }) + + return toServerSentEventsResponse(stream) + } catch (err) { + if (err instanceof InvalidModelOverrideError) { + return jsonError(400, { + error: 'invalid_model_override', + message: err.message, + provider: err.providerId, + requestedModel: err.requestedModel, + allowedModels: err.allowedModels, + }) + } + // Defense-in-depth: the Zod enum schema above should already reject + // unknown providers, but surface a typed 400 here in case that + // validation drifts or is bypassed. + if (err instanceof UnknownProviderError) { + return jsonError(400, { + error: 'unknown_provider', + message: err.message, + // Use `provider` consistently with the invalid_model_override + // branch and the request body's `provider` field. + provider: err.providerId, + allowedProviders: err.allowedProviders, + }) + } + return jsonError(500, { + error: 'generation_failed', + message: + err instanceof Error ? err.message : 'Audio generation failed', + }) + } + }, + }, + }, +}) diff --git a/examples/ts-react-chat/src/routes/api.generate.speech.ts b/examples/ts-react-chat/src/routes/api.generate.speech.ts index 47ec752271..92057ad4fa 100644 --- a/examples/ts-react-chat/src/routes/api.generate.speech.ts +++ b/examples/ts-react-chat/src/routes/api.generate.speech.ts @@ -1,23 +1,102 @@ import { createFileRoute } from '@tanstack/react-router' import { generateSpeech, toServerSentEventsResponse } from '@tanstack/ai' -import { openaiSpeech } from '@tanstack/ai-openai' +import { z } from 'zod' +import { + InvalidModelOverrideError, + UnknownProviderError, + buildSpeechAdapter, +} from '../lib/server-audio-adapters' + +const SPEECH_PROVIDER_SCHEMA = z + .enum(['openai', 'gemini', 'fal', 'grok']) + .optional() + +const SPEECH_BODY_SCHEMA = z.object({ + text: z.string().min(1), + voice: z.string().optional(), + format: z.enum(['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm']).optional(), + provider: SPEECH_PROVIDER_SCHEMA, +}) + +function jsonError(status: number, payload: Record) { + return new Response(JSON.stringify(payload), { + status, + headers: { 'content-type': 'application/json' }, + }) +} export const Route = createFileRoute('/api/generate/speech')({ server: { handlers: { POST: async ({ request }) => { - const body = await request.json() - const { text, voice, format, model } = body.data - - const stream = generateSpeech({ - adapter: openaiSpeech(model ?? 'tts-1'), - text, - voice, - format, - stream: true, - }) - - return toServerSentEventsResponse(stream) + let body: unknown + try { + body = await request.json() + } catch { + return jsonError(400, { + error: 'invalid_json', + message: 'Request body must be valid JSON', + }) + } + + const rawData = (body as { data?: unknown } | null)?.data + if (rawData == null) { + return jsonError(400, { + error: 'missing_data', + message: 'Request body must include a `data` field', + }) + } + + const parsed = SPEECH_BODY_SCHEMA.safeParse(rawData) + if (!parsed.success) { + return jsonError(400, { + error: 'validation_failed', + message: 'Request data failed validation', + details: z.treeifyError(parsed.error), + }) + } + + const { text, voice, format, provider } = parsed.data + + try { + const adapter = buildSpeechAdapter(provider ?? 'openai') + + const stream = generateSpeech({ + adapter, + text, + voice, + format, + stream: true, + }) + + return toServerSentEventsResponse(stream) + } catch (err) { + if (err instanceof InvalidModelOverrideError) { + return jsonError(400, { + error: 'invalid_model_override', + message: err.message, + provider: err.providerId, + requestedModel: err.requestedModel, + allowedModels: err.allowedModels, + }) + } + // Defense-in-depth: the Zod enum schema above should already reject + // unknown providers, but surface a typed 400 here in case that + // validation drifts or is bypassed. + if (err instanceof UnknownProviderError) { + return jsonError(400, { + error: 'unknown_provider', + message: err.message, + provider: err.providerId, + allowedProviders: err.allowedProviders, + }) + } + return jsonError(500, { + error: 'generation_failed', + message: + err instanceof Error ? err.message : 'Speech generation failed', + }) + } }, }, }, diff --git a/examples/ts-react-chat/src/routes/api.structured-output.ts b/examples/ts-react-chat/src/routes/api.structured-output.ts new file mode 100644 index 0000000000..aa1d045f25 --- /dev/null +++ b/examples/ts-react-chat/src/routes/api.structured-output.ts @@ -0,0 +1,58 @@ +import { createFileRoute } from '@tanstack/react-router' +import { chat } from '@tanstack/ai' +import { openRouterText } from '@tanstack/ai-openrouter' +import { z } from 'zod' + +const GuitarRecommendationSchema = z.object({ + title: z.string().describe('Short headline for the recommendation'), + summary: z.string().describe('One paragraph summary'), + recommendations: z + .array( + z.object({ + name: z.string(), + brand: z.string(), + type: z.enum(['acoustic', 'electric', 'bass', 'classical']), + priceRangeUsd: z.object({ min: z.number(), max: z.number() }), + reason: z.string(), + }), + ) + .min(1) + .describe('Guitar recommendations with reasons'), + nextSteps: z.array(z.string()).describe('Practical follow-up actions'), +}) + +export const Route = createFileRoute('/api/structured-output')({ + server: { + handlers: { + POST: async ({ request }) => { + const body = await request.json() + const { prompt, model } = body as { + prompt: string + model?: string + } + + try { + const result = await chat({ + adapter: openRouterText( + (model || 'openai/gpt-5.2') as 'openai/gpt-5.2', + ), + messages: [{ role: 'user', content: prompt }], + outputSchema: GuitarRecommendationSchema, + }) + + return new Response(JSON.stringify({ data: result }), { + headers: { 'Content-Type': 'application/json' }, + }) + } catch (error: unknown) { + const message = + error instanceof Error ? error.message : 'An error occurred' + console.error('[api/structured-output] Error:', error) + return new Response(JSON.stringify({ error: message }), { + status: 500, + headers: { 'Content-Type': 'application/json' }, + }) + } + }, + }, + }, +}) diff --git a/examples/ts-react-chat/src/routes/api.tanchat.ts b/examples/ts-react-chat/src/routes/api.tanchat.ts index a1eb8ee024..f571fd9c7b 100644 --- a/examples/ts-react-chat/src/routes/api.tanchat.ts +++ b/examples/ts-react-chat/src/routes/api.tanchat.ts @@ -11,8 +11,8 @@ import { anthropicText } from '@tanstack/ai-anthropic' import { geminiText } from '@tanstack/ai-gemini' import { openRouterText } from '@tanstack/ai-openrouter' import { grokText } from '@tanstack/ai-grok' -import type { AnyTextAdapter, ChatMiddleware } from '@tanstack/ai' import { groqText } from '@tanstack/ai-groq' +import type { AnyTextAdapter, ChatMiddleware } from '@tanstack/ai' import { addToCartToolDef, addToWishListToolDef, @@ -146,8 +146,6 @@ export const Route = createFileRoute('/api/tanchat')({ createChatOptions({ adapter: openRouterText('openai/gpt-5.1'), modelOptions: { - models: ['openai/chatgpt-4o-latest'], - route: 'fallback', reasoning: { effort: 'medium', }, diff --git a/examples/ts-react-chat/src/routes/api.transcribe.ts b/examples/ts-react-chat/src/routes/api.transcribe.ts index 56f9c7aeb7..e6131ad328 100644 --- a/examples/ts-react-chat/src/routes/api.transcribe.ts +++ b/examples/ts-react-chat/src/routes/api.transcribe.ts @@ -1,22 +1,100 @@ import { createFileRoute } from '@tanstack/react-router' import { generateTranscription, toServerSentEventsResponse } from '@tanstack/ai' -import { openaiTranscription } from '@tanstack/ai-openai' +import { z } from 'zod' +import { + InvalidModelOverrideError, + UnknownProviderError, + buildTranscriptionAdapter, +} from '../lib/server-audio-adapters' + +const TRANSCRIPTION_PROVIDER_SCHEMA = z + .enum(['openai', 'fal', 'grok']) + .optional() + +const TRANSCRIBE_BODY_SCHEMA = z.object({ + audio: z.string().min(1), + language: z.string().optional(), + provider: TRANSCRIPTION_PROVIDER_SCHEMA, +}) + +function jsonError(status: number, payload: Record) { + return new Response(JSON.stringify(payload), { + status, + headers: { 'content-type': 'application/json' }, + }) +} export const Route = createFileRoute('/api/transcribe')({ server: { handlers: { POST: async ({ request }) => { - const body = await request.json() - const { audio, language, model } = body.data + let body: unknown + try { + body = await request.json() + } catch { + return jsonError(400, { + error: 'invalid_json', + message: 'Request body must be valid JSON', + }) + } + + const rawData = (body as { data?: unknown } | null)?.data + if (rawData == null) { + return jsonError(400, { + error: 'missing_data', + message: 'Request body must include a `data` field', + }) + } + + const parsed = TRANSCRIBE_BODY_SCHEMA.safeParse(rawData) + if (!parsed.success) { + return jsonError(400, { + error: 'validation_failed', + message: 'Request data failed validation', + details: z.treeifyError(parsed.error), + }) + } + + const { audio, language, provider } = parsed.data + + try { + const adapter = buildTranscriptionAdapter(provider ?? 'openai') - const stream = generateTranscription({ - adapter: openaiTranscription(model ?? 'whisper-1'), - audio, - language, - stream: true, - }) + const stream = generateTranscription({ + adapter, + audio, + language, + stream: true, + }) - return toServerSentEventsResponse(stream) + return toServerSentEventsResponse(stream) + } catch (err) { + if (err instanceof InvalidModelOverrideError) { + return jsonError(400, { + error: 'invalid_model_override', + message: err.message, + provider: err.providerId, + requestedModel: err.requestedModel, + allowedModels: err.allowedModels, + }) + } + // Defense-in-depth: the Zod enum schema above should already reject + // unknown providers, but surface a typed 400 here in case that + // validation drifts or is bypassed. + if (err instanceof UnknownProviderError) { + return jsonError(400, { + error: 'unknown_provider', + message: err.message, + provider: err.providerId, + allowedProviders: err.allowedProviders, + }) + } + return jsonError(500, { + error: 'transcription_failed', + message: + err instanceof Error ? err.message : 'Transcription failed', + }) + } }, }, }, diff --git a/examples/ts-react-chat/src/routes/generations.audio.tsx b/examples/ts-react-chat/src/routes/generations.audio.tsx new file mode 100644 index 0000000000..757278e73b --- /dev/null +++ b/examples/ts-react-chat/src/routes/generations.audio.tsx @@ -0,0 +1,359 @@ +import { useEffect, useMemo, useRef, useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useGenerateAudio } from '@tanstack/ai-react' +import type { UseGenerateAudioReturn } from '@tanstack/ai-react' +import { fetchServerSentEvents } from '@tanstack/ai-client' +import type { AudioGenerationResult } from '@tanstack/ai' +import { generateAudioFn } from '../lib/server-fns' +import { + AUDIO_PROVIDERS, + type AudioProviderConfig, + type AudioProviderId, +} from '../lib/audio-providers' + +type Mode = 'hooks' | 'server-fn' + +interface AudioOutput { + url: string + contentType?: string + duration?: number + model: string +} + +/** + * Map an AudioGenerationResult to the UI-friendly shape. Returns `null` + * when the result has neither `url` nor `b64Json` — per the `onResult` + * contract, a `null` return tells the hook to keep the previous result + * and the real failure is surfaced via `onError` / the hook's error state. + */ +function toAudioOutput(raw: AudioGenerationResult): AudioOutput | null { + const { audio } = raw + if (audio.url) { + return { + url: audio.url, + contentType: audio.contentType, + duration: audio.duration, + model: raw.model, + } + } + if (audio.b64Json) { + const binary = atob(audio.b64Json) + const bytes = new Uint8Array(binary.length) + for (let i = 0; i < binary.length; i++) { + bytes[i] = binary.charCodeAt(i) + } + const blob = new Blob([bytes], { + type: audio.contentType ?? 'audio/mpeg', + }) + return { + url: URL.createObjectURL(blob), + contentType: audio.contentType, + duration: audio.duration, + model: raw.model, + } + } + // Don't throw — that bypasses the hook's error plumbing. Return null so + // the hook keeps the previous result unchanged; callers can rely on the + // `error` state (populated via `onError`) if they want to surface this. + return null +} + +function AudioGenerationForm({ + mode, + config, +}: { + mode: Mode + config: AudioProviderConfig +}) { + const [prompt, setPrompt] = useState('') + const [duration, setDuration] = useState( + config.defaultDuration, + ) + const [selectedModel, setSelectedModel] = useState(config.model) + + const hookOptions = useMemo(() => { + if (mode === 'hooks') { + return { + connection: fetchServerSentEvents('/api/generate/audio'), + body: { provider: config.id, model: selectedModel }, + onResult: toAudioOutput, + } + } + return { + fetcher: (input: { prompt: string; duration?: number }) => + generateAudioFn({ + data: { ...input, provider: config.id, model: selectedModel }, + }), + onResult: toAudioOutput, + } + }, [mode, config.id, selectedModel]) + + const hookReturn = useGenerateAudio(hookOptions) + + return ( + + ) +} + +function AudioGenerationUI({ + config, + prompt, + setPrompt, + duration, + setDuration, + selectedModel, + setSelectedModel, + generate, + result, + isLoading, + error, + reset, +}: UseGenerateAudioReturn & { + config: AudioProviderConfig + prompt: string + setPrompt: (v: string) => void + duration: number | undefined + setDuration: (v: number | undefined) => void + selectedModel: string + setSelectedModel: (v: string) => void +}) { + const handleGenerate = () => { + if (!prompt.trim()) return + generate({ prompt: prompt.trim(), duration }) + } + + // Track the last object URL we created so we can revoke it when the + // result changes, reset is invoked, or the component unmounts. + const lastBlobUrlRef = useRef(null) + useEffect(() => { + const current = result?.url + // Only track blob: URLs — remote URLs returned directly by providers + // are not ours to revoke. + if (current && current.startsWith('blob:')) { + if (lastBlobUrlRef.current && lastBlobUrlRef.current !== current) { + URL.revokeObjectURL(lastBlobUrlRef.current) + } + lastBlobUrlRef.current = current + } else if (!current && lastBlobUrlRef.current) { + URL.revokeObjectURL(lastBlobUrlRef.current) + lastBlobUrlRef.current = null + } + }, [result?.url]) + useEffect(() => { + return () => { + if (lastBlobUrlRef.current) { + URL.revokeObjectURL(lastBlobUrlRef.current) + lastBlobUrlRef.current = null + } + } + }, []) + + return ( +

+
+ {config.models && config.models.length > 1 ? ( +
+ + +
+ ) : ( +

+ Model: {config.model} +

+ )} +

{config.description}

+
+ +
+ +