diff --git a/.changeset/multimodal-tool-results.md b/.changeset/multimodal-tool-results.md deleted file mode 100644 index 7ec5e49d7..000000000 --- a/.changeset/multimodal-tool-results.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -'@tanstack/ai': minor -'@tanstack/ai-client': minor -'@tanstack/openai-base': minor -'@tanstack/ai-anthropic': minor -'@tanstack/ai-gemini': minor ---- - -feat: support multimodal (image) tool results - -Tools may now return an `Array` (e.g. a text part plus an image part) and have it transmitted to the model as structured multimodal tool output instead of a `JSON.stringify`'d blob. This unblocks use cases like returning a screenshot from a tool so the model can see it (issue #363). - -- Detection is structural and opt-in by shape: a tool that returns a non-empty array whose every element is a valid `ContentPart` is passed through unchanged; strings and all other return values are serialized exactly as before, so there are no breaking changes. -- The OpenAI Responses, Anthropic, and Google Gemini adapters convert the content parts into their native multimodal tool-output formats (`function_call_output.output`, `tool_result` content blocks, and `functionResponse.parts` respectively). Providers on the Chat Completions path (Groq, Ollama, Grok, OpenRouter chat) fall back to stringifying, which their APIs require. -- AG-UI stream events (`TOOL_CALL_RESULT.content`, `TOOL_CALL_END.result`) remain string-only per the spec; the multimodal array travels on the tool message itself. diff --git a/.changeset/runerror-raw-event.md b/.changeset/runerror-raw-event.md deleted file mode 100644 index fb7667492..000000000 --- a/.changeset/runerror-raw-event.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -'@tanstack/ai': minor -'@tanstack/openai-base': minor -'@tanstack/ai-openrouter': minor -'@tanstack/ai-anthropic': minor -'@tanstack/ai-gemini': minor ---- - -Populate AG-UI `rawEvent` on `RUN_ERROR` events with the provider's structured error body. - -Previously, when a streaming chat call failed the `RUN_ERROR` event carried only an -opaque `{ message, code }` headline (e.g. `"Provider returned error"`), and no adapter -populated AG-UI's purpose-built `rawEvent` field — so the upstream provider detail was -unrecoverable. - -Adapters now forward the provider's **structured error body** (e.g. an SDK `APIError`'s -parsed `.error` response body, or OpenRouter's mid-stream `chunk.error`) as `rawEvent` -on the `RUN_ERROR` event. The new `toRunErrorRawEvent` helper extracts only known -provider-body fields — never the raw SDK exception object, which can carry request -metadata such as auth headers. The `{ message, code }` contract of `toRunErrorPayload` -is unchanged. - -The error surfaced to consumers via the `ChatClient` / `useChat` `error` (and the -`onError` callback) now also carries `code` and `rawEvent` when present, so the upstream -cause is recoverable in application code. - -> Note: the OpenRouter SDK parses each in-band stream chunk's `error` through a strict -> schema (`{ code, message }`), so provider `metadata` survives only on pre-stream HTTP -> errors (rate-limit / overload / BYOK rejection), whose typed error class exposes the -> full body via `.error`. diff --git a/.changeset/typed-runtime-context.md b/.changeset/typed-runtime-context.md deleted file mode 100644 index 8874df49d..000000000 --- a/.changeset/typed-runtime-context.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -'@tanstack/ai': minor -'@tanstack/ai-client': minor -'@tanstack/ai-react': minor -'@tanstack/ai-preact': minor -'@tanstack/ai-solid': minor -'@tanstack/ai-svelte': minor -'@tanstack/ai-vue': minor -'@tanstack/ai-code-mode': minor -'@tanstack/ai-code-mode-skills': minor ---- - -Add typed runtime context for tools and middleware. - -Tools and middleware can now declare the runtime context shape they require, and -`chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer -the merged requirement and type-check the `context` option you pass against it. - -```typescript -type AppContext = { userId: string; db: Db } - -const listNotes = toolDefinition({ - name: 'list_notes' /* ... */, -}).server((_input, ctx) => - ctx.context.db.notes.findMany({ userId: ctx.context.userId }), -) - -chat({ - adapter, - messages, - tools: [listNotes], - context: { userId, db }, // required and type-checked because listNotes declares AppContext -}) -``` - -Runtime context is request-local application state for tool and middleware -implementations (authenticated users, database clients, tenancy, feature flags, -loggers, browser services). It is never sent to the model and is distinct from -the AG-UI `RunAgentInput.context` protocol field. - -Untyped tools and middleware continue to receive `unknown` context and do not -force a `context` option. Client tools receive client-local context via -`ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data -to the server and map it into server context explicitly. See the new Runtime -Context guide for details. - -Behavior change: tool output validation now also runs when a tool returns -`undefined` or `null`. Previously these values bypassed `outputSchema` -validation entirely; now the schema decides whether they are valid, so a tool -whose schema forbids `undefined`/`null` surfaces a validation error -(`output-error`) instead of silently passing. Tools whose schema permits -`null`/`undefined` (e.g. nullable or void outputs) are unaffected. diff --git a/packages/ai-anthropic/CHANGELOG.md b/packages/ai-anthropic/CHANGELOG.md index 4c0c7987c..ffd7cf6e6 100644 --- a/packages/ai-anthropic/CHANGELOG.md +++ b/packages/ai-anthropic/CHANGELOG.md @@ -1,5 +1,44 @@ # @tanstack/ai-anthropic +## 0.12.0 + +### Minor Changes + +- [#666](https://github.com/TanStack/ai/pull/666) [`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b) - feat: support multimodal (image) tool results + + Tools may now return an `Array` (e.g. a text part plus an image part) and have it transmitted to the model as structured multimodal tool output instead of a `JSON.stringify`'d blob. This unblocks use cases like returning a screenshot from a tool so the model can see it (issue [#363](https://github.com/TanStack/ai/issues/363)). + - Detection is structural and opt-in by shape: a tool that returns a non-empty array whose every element is a valid `ContentPart` is passed through unchanged; strings and all other return values are serialized exactly as before, so there are no breaking changes. + - The OpenAI Responses, Anthropic, and Google Gemini adapters convert the content parts into their native multimodal tool-output formats (`function_call_output.output`, `tool_result` content blocks, and `functionResponse.parts` respectively). Providers on the Chat Completions path (Groq, Ollama, Grok, OpenRouter chat) fall back to stringifying, which their APIs require. + - AG-UI stream events (`TOOL_CALL_RESULT.content`, `TOOL_CALL_END.result`) remain string-only per the spec; the multimodal array travels on the tool message itself. + +- [#673](https://github.com/TanStack/ai/pull/673) [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915) - Populate AG-UI `rawEvent` on `RUN_ERROR` events with the provider's structured error body. + + Previously, when a streaming chat call failed the `RUN_ERROR` event carried only an + opaque `{ message, code }` headline (e.g. `"Provider returned error"`), and no adapter + populated AG-UI's purpose-built `rawEvent` field — so the upstream provider detail was + unrecoverable. + + Adapters now forward the provider's **structured error body** (e.g. an SDK `APIError`'s + parsed `.error` response body, or OpenRouter's mid-stream `chunk.error`) as `rawEvent` + on the `RUN_ERROR` event. The new `toRunErrorRawEvent` helper extracts only known + provider-body fields — never the raw SDK exception object, which can carry request + metadata such as auth headers. The `{ message, code }` contract of `toRunErrorPayload` + is unchanged. + + The error surfaced to consumers via the `ChatClient` / `useChat` `error` (and the + `onError` callback) now also carries `code` and `rawEvent` when present, so the upstream + cause is recoverable in application code. + + > Note: the OpenRouter SDK parses each in-band stream chunk's `error` through a strict + > schema (`{ code, message }`), so provider `metadata` survives only on pre-stream HTTP + > errors (rate-limit / overload / BYOK rejection), whose typed error class exposes the + > full body via `.error`. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.11.2 ### Patch Changes diff --git a/packages/ai-anthropic/package.json b/packages/ai-anthropic/package.json index 03ef2cd3a..7fb6a5f2d 100644 --- a/packages/ai-anthropic/package.json +++ b/packages/ai-anthropic/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-anthropic", - "version": "0.11.2", + "version": "0.12.0", "description": "Anthropic Claude adapter for TanStack AI chat, tool calling, thinking, and structured outputs.", "author": "", "license": "MIT", diff --git a/packages/ai-client/CHANGELOG.md b/packages/ai-client/CHANGELOG.md index 5f18797dd..804650591 100644 --- a/packages/ai-client/CHANGELOG.md +++ b/packages/ai-client/CHANGELOG.md @@ -1,5 +1,63 @@ # @tanstack/ai-client +## 0.15.0 + +### Minor Changes + +- [#666](https://github.com/TanStack/ai/pull/666) [`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b) - feat: support multimodal (image) tool results + + Tools may now return an `Array` (e.g. a text part plus an image part) and have it transmitted to the model as structured multimodal tool output instead of a `JSON.stringify`'d blob. This unblocks use cases like returning a screenshot from a tool so the model can see it (issue [#363](https://github.com/TanStack/ai/issues/363)). + - Detection is structural and opt-in by shape: a tool that returns a non-empty array whose every element is a valid `ContentPart` is passed through unchanged; strings and all other return values are serialized exactly as before, so there are no breaking changes. + - The OpenAI Responses, Anthropic, and Google Gemini adapters convert the content parts into their native multimodal tool-output formats (`function_call_output.output`, `tool_result` content blocks, and `functionResponse.parts` respectively). Providers on the Chat Completions path (Groq, Ollama, Grok, OpenRouter chat) fall back to stringifying, which their APIs require. + - AG-UI stream events (`TOOL_CALL_RESULT.content`, `TOOL_CALL_END.result`) remain string-only per the spec; the multimodal array travels on the tool message itself. + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-event-client@0.4.3 + ## 0.14.1 ### Patch Changes diff --git a/packages/ai-client/package.json b/packages/ai-client/package.json index 2a2b3dbe6..3a5b2cd5f 100644 --- a/packages/ai-client/package.json +++ b/packages/ai-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-client", - "version": "0.14.1", + "version": "0.15.0", "description": "Framework-agnostic headless client for TanStack AI chat, realtime sessions, streaming transports, and media generations.", "author": "", "license": "MIT", diff --git a/packages/ai-code-mode-skills/CHANGELOG.md b/packages/ai-code-mode-skills/CHANGELOG.md index 05a4a9100..e2ea091e5 100644 --- a/packages/ai-code-mode-skills/CHANGELOG.md +++ b/packages/ai-code-mode-skills/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-code-mode-skills +## 0.2.0 + +### Minor Changes + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-code-mode@0.2.0 + ## 0.1.24 ### Patch Changes diff --git a/packages/ai-code-mode-skills/package.json b/packages/ai-code-mode-skills/package.json index cf7f51df4..2885733c8 100644 --- a/packages/ai-code-mode-skills/package.json +++ b/packages/ai-code-mode-skills/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-code-mode-skills", - "version": "0.1.24", + "version": "0.2.0", "description": "Persistent runtime skill library for TanStack AI Code Mode agents and sandboxed tool orchestration.", "author": "", "license": "MIT", diff --git a/packages/ai-code-mode/CHANGELOG.md b/packages/ai-code-mode/CHANGELOG.md index 66de18475..96ec210c3 100644 --- a/packages/ai-code-mode/CHANGELOG.md +++ b/packages/ai-code-mode/CHANGELOG.md @@ -1,5 +1,55 @@ # @tanstack/ai-code-mode +## 0.2.0 + +### Minor Changes + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.1.24 ### Patch Changes diff --git a/packages/ai-code-mode/package.json b/packages/ai-code-mode/package.json index c3feda3e3..47226f5b5 100644 --- a/packages/ai-code-mode/package.json +++ b/packages/ai-code-mode/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-code-mode", - "version": "0.1.24", + "version": "0.2.0", "description": "Secure TypeScript Code Mode for TanStack AI agents to execute sandboxed tool orchestration programs.", "author": "", "license": "MIT", diff --git a/packages/ai-devtools/CHANGELOG.md b/packages/ai-devtools/CHANGELOG.md index 829b5ada8..d4c4cabb6 100644 --- a/packages/ai-devtools/CHANGELOG.md +++ b/packages/ai-devtools/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-devtools-core +## 0.4.3 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-event-client@0.4.3 + ## 0.4.2 ### Patch Changes diff --git a/packages/ai-devtools/package.json b/packages/ai-devtools/package.json index dc339b063..7f819007e 100644 --- a/packages/ai-devtools/package.json +++ b/packages/ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-devtools-core", - "version": "0.4.2", + "version": "0.4.3", "description": "Core TanStack AI Devtools plugin for inspecting chat messages, tool calls, streams, and errors.", "author": "", "license": "MIT", diff --git a/packages/ai-elevenlabs/CHANGELOG.md b/packages/ai-elevenlabs/CHANGELOG.md index e43744fc6..aa24cda44 100644 --- a/packages/ai-elevenlabs/CHANGELOG.md +++ b/packages/ai-elevenlabs/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-elevenlabs +## 0.2.15 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-client@0.15.0 + ## 0.2.14 ### Patch Changes diff --git a/packages/ai-elevenlabs/package.json b/packages/ai-elevenlabs/package.json index ab8157ff9..0b365cb39 100644 --- a/packages/ai-elevenlabs/package.json +++ b/packages/ai-elevenlabs/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-elevenlabs", - "version": "0.2.14", + "version": "0.2.15", "description": "ElevenLabs adapter for TanStack AI realtime voice, text-to-speech, transcription, music, and sound effects.", "author": "", "license": "MIT", diff --git a/packages/ai-event-client/CHANGELOG.md b/packages/ai-event-client/CHANGELOG.md index 2f1a55a7b..0bc712135 100644 --- a/packages/ai-event-client/CHANGELOG.md +++ b/packages/ai-event-client/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-event-client +## 0.4.3 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.4.2 ### Patch Changes diff --git a/packages/ai-event-client/package.json b/packages/ai-event-client/package.json index ede48d991..74c5bef99 100644 --- a/packages/ai-event-client/package.json +++ b/packages/ai-event-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-event-client", - "version": "0.4.2", + "version": "0.4.3", "description": "Typed event client for TanStack AI devtools, observability, and streamed runtime events.", "author": "", "license": "MIT", diff --git a/packages/ai-fal/CHANGELOG.md b/packages/ai-fal/CHANGELOG.md index ed869fa9b..69c33ad3e 100644 --- a/packages/ai-fal/CHANGELOG.md +++ b/packages/ai-fal/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-fal +## 0.7.18 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.7.17 ### Patch Changes diff --git a/packages/ai-fal/package.json b/packages/ai-fal/package.json index 2dd43e288..6872bb094 100644 --- a/packages/ai-fal/package.json +++ b/packages/ai-fal/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-fal", - "version": "0.7.17", + "version": "0.7.18", "description": "fal.ai adapter for TanStack AI image, video, audio, speech, and transcription generation.", "author": "", "license": "MIT", diff --git a/packages/ai-gemini/CHANGELOG.md b/packages/ai-gemini/CHANGELOG.md index 4d81a13b0..bba966d47 100644 --- a/packages/ai-gemini/CHANGELOG.md +++ b/packages/ai-gemini/CHANGELOG.md @@ -1,5 +1,44 @@ # @tanstack/ai-gemini +## 0.13.0 + +### Minor Changes + +- [#666](https://github.com/TanStack/ai/pull/666) [`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b) - feat: support multimodal (image) tool results + + Tools may now return an `Array` (e.g. a text part plus an image part) and have it transmitted to the model as structured multimodal tool output instead of a `JSON.stringify`'d blob. This unblocks use cases like returning a screenshot from a tool so the model can see it (issue [#363](https://github.com/TanStack/ai/issues/363)). + - Detection is structural and opt-in by shape: a tool that returns a non-empty array whose every element is a valid `ContentPart` is passed through unchanged; strings and all other return values are serialized exactly as before, so there are no breaking changes. + - The OpenAI Responses, Anthropic, and Google Gemini adapters convert the content parts into their native multimodal tool-output formats (`function_call_output.output`, `tool_result` content blocks, and `functionResponse.parts` respectively). Providers on the Chat Completions path (Groq, Ollama, Grok, OpenRouter chat) fall back to stringifying, which their APIs require. + - AG-UI stream events (`TOOL_CALL_RESULT.content`, `TOOL_CALL_END.result`) remain string-only per the spec; the multimodal array travels on the tool message itself. + +- [#673](https://github.com/TanStack/ai/pull/673) [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915) - Populate AG-UI `rawEvent` on `RUN_ERROR` events with the provider's structured error body. + + Previously, when a streaming chat call failed the `RUN_ERROR` event carried only an + opaque `{ message, code }` headline (e.g. `"Provider returned error"`), and no adapter + populated AG-UI's purpose-built `rawEvent` field — so the upstream provider detail was + unrecoverable. + + Adapters now forward the provider's **structured error body** (e.g. an SDK `APIError`'s + parsed `.error` response body, or OpenRouter's mid-stream `chunk.error`) as `rawEvent` + on the `RUN_ERROR` event. The new `toRunErrorRawEvent` helper extracts only known + provider-body fields — never the raw SDK exception object, which can carry request + metadata such as auth headers. The `{ message, code }` contract of `toRunErrorPayload` + is unchanged. + + The error surfaced to consumers via the `ChatClient` / `useChat` `error` (and the + `onError` callback) now also carries `code` and `rawEvent` when present, so the upstream + cause is recoverable in application code. + + > Note: the OpenRouter SDK parses each in-band stream chunk's `error` through a strict + > schema (`{ code, message }`), so provider `metadata` survives only on pre-stream HTTP + > errors (rate-limit / overload / BYOK rejection), whose typed error class exposes the + > full body via `.error`. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.12.1 ### Patch Changes diff --git a/packages/ai-gemini/package.json b/packages/ai-gemini/package.json index d68a116b6..39d0cc491 100644 --- a/packages/ai-gemini/package.json +++ b/packages/ai-gemini/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-gemini", - "version": "0.12.1", + "version": "0.13.0", "description": "Google Gemini adapter for TanStack AI chat, images, speech, audio generation, and structured outputs.", "author": "", "license": "MIT", diff --git a/packages/ai-grok/CHANGELOG.md b/packages/ai-grok/CHANGELOG.md index 0d0dca3f9..da9eb9dd6 100644 --- a/packages/ai-grok/CHANGELOG.md +++ b/packages/ai-grok/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-grok +## 0.9.2 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/openai-base@0.5.0 + ## 0.9.1 ### Patch Changes diff --git a/packages/ai-grok/package.json b/packages/ai-grok/package.json index 02a40deff..d6d72f478 100644 --- a/packages/ai-grok/package.json +++ b/packages/ai-grok/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-grok", - "version": "0.9.1", + "version": "0.9.2", "description": "xAI Grok adapter for TanStack AI chat, image generation, realtime, and structured outputs.", "author": "", "license": "MIT", diff --git a/packages/ai-groq/CHANGELOG.md b/packages/ai-groq/CHANGELOG.md index e7a16ea58..747bd0875 100644 --- a/packages/ai-groq/CHANGELOG.md +++ b/packages/ai-groq/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-groq +## 0.2.9 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/openai-base@0.5.0 + ## 0.2.8 ### Patch Changes diff --git a/packages/ai-groq/package.json b/packages/ai-groq/package.json index 686cbc103..03e41ad98 100644 --- a/packages/ai-groq/package.json +++ b/packages/ai-groq/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-groq", - "version": "0.2.8", + "version": "0.2.9", "type": "module", "description": "Groq adapter for TanStack AI low-latency chat, tool calling, and structured outputs.", "author": "", diff --git a/packages/ai-isolate-cloudflare/CHANGELOG.md b/packages/ai-isolate-cloudflare/CHANGELOG.md index 3d11d4a2b..2a4e0dab2 100644 --- a/packages/ai-isolate-cloudflare/CHANGELOG.md +++ b/packages/ai-isolate-cloudflare/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-isolate-cloudflare +## 0.2.16 + +### Patch Changes + +- Updated dependencies [[`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai-code-mode@0.2.0 + ## 0.2.15 ### Patch Changes diff --git a/packages/ai-isolate-cloudflare/package.json b/packages/ai-isolate-cloudflare/package.json index 6f02c96c8..905a4f25a 100644 --- a/packages/ai-isolate-cloudflare/package.json +++ b/packages/ai-isolate-cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-isolate-cloudflare", - "version": "0.2.15", + "version": "0.2.16", "description": "Cloudflare Workers sandbox driver for TanStack AI Code Mode TypeScript execution at the edge.", "author": "", "license": "MIT", diff --git a/packages/ai-isolate-node/CHANGELOG.md b/packages/ai-isolate-node/CHANGELOG.md index df3ed39cc..14ddb59c2 100644 --- a/packages/ai-isolate-node/CHANGELOG.md +++ b/packages/ai-isolate-node/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-isolate-node +## 0.1.25 + +### Patch Changes + +- Updated dependencies [[`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai-code-mode@0.2.0 + ## 0.1.24 ### Patch Changes diff --git a/packages/ai-isolate-node/package.json b/packages/ai-isolate-node/package.json index fe63d4782..658f6f095 100644 --- a/packages/ai-isolate-node/package.json +++ b/packages/ai-isolate-node/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-isolate-node", - "version": "0.1.24", + "version": "0.1.25", "description": "Node.js isolated-vm sandbox driver for TanStack AI Code Mode TypeScript execution.", "author": "", "license": "MIT", diff --git a/packages/ai-isolate-quickjs/CHANGELOG.md b/packages/ai-isolate-quickjs/CHANGELOG.md index f78f9c665..6fc94b56c 100644 --- a/packages/ai-isolate-quickjs/CHANGELOG.md +++ b/packages/ai-isolate-quickjs/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-isolate-quickjs +## 0.1.25 + +### Patch Changes + +- Updated dependencies [[`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai-code-mode@0.2.0 + ## 0.1.24 ### Patch Changes diff --git a/packages/ai-isolate-quickjs/package.json b/packages/ai-isolate-quickjs/package.json index 7e459b49a..556471ad8 100644 --- a/packages/ai-isolate-quickjs/package.json +++ b/packages/ai-isolate-quickjs/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-isolate-quickjs", - "version": "0.1.24", + "version": "0.1.25", "description": "QuickJS WASM sandbox driver for TanStack AI Code Mode TypeScript execution across runtimes.", "author": "", "license": "MIT", diff --git a/packages/ai-ollama/CHANGELOG.md b/packages/ai-ollama/CHANGELOG.md index fa50962cb..99e9a3460 100644 --- a/packages/ai-ollama/CHANGELOG.md +++ b/packages/ai-ollama/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-ollama +## 0.6.24 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.6.23 ### Patch Changes diff --git a/packages/ai-ollama/package.json b/packages/ai-ollama/package.json index 7cff85219..46f7884f7 100644 --- a/packages/ai-ollama/package.json +++ b/packages/ai-ollama/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-ollama", - "version": "0.6.23", + "version": "0.6.24", "description": "Ollama adapter for TanStack AI local LLM chat, tool calling, and structured outputs.", "author": "", "license": "MIT", diff --git a/packages/ai-openai/CHANGELOG.md b/packages/ai-openai/CHANGELOG.md index e31ad493e..294d031d8 100644 --- a/packages/ai-openai/CHANGELOG.md +++ b/packages/ai-openai/CHANGELOG.md @@ -1,5 +1,14 @@ # @tanstack/ai-openai +## 0.10.5 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-client@0.15.0 + - @tanstack/openai-base@0.5.0 + ## 0.10.4 ### Patch Changes diff --git a/packages/ai-openai/package.json b/packages/ai-openai/package.json index cf0deccfd..765f7e6f3 100644 --- a/packages/ai-openai/package.json +++ b/packages/ai-openai/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-openai", - "version": "0.10.4", + "version": "0.10.5", "description": "OpenAI adapter for TanStack AI chat, tools, images, video, speech, transcription, realtime, and structured outputs.", "author": "", "license": "MIT", diff --git a/packages/ai-openrouter/CHANGELOG.md b/packages/ai-openrouter/CHANGELOG.md index 6a54795be..3b7ff7bd6 100644 --- a/packages/ai-openrouter/CHANGELOG.md +++ b/packages/ai-openrouter/CHANGELOG.md @@ -1,5 +1,37 @@ # @tanstack/ai-openrouter +## 0.11.0 + +### Minor Changes + +- [#673](https://github.com/TanStack/ai/pull/673) [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915) - Populate AG-UI `rawEvent` on `RUN_ERROR` events with the provider's structured error body. + + Previously, when a streaming chat call failed the `RUN_ERROR` event carried only an + opaque `{ message, code }` headline (e.g. `"Provider returned error"`), and no adapter + populated AG-UI's purpose-built `rawEvent` field — so the upstream provider detail was + unrecoverable. + + Adapters now forward the provider's **structured error body** (e.g. an SDK `APIError`'s + parsed `.error` response body, or OpenRouter's mid-stream `chunk.error`) as `rawEvent` + on the `RUN_ERROR` event. The new `toRunErrorRawEvent` helper extracts only known + provider-body fields — never the raw SDK exception object, which can carry request + metadata such as auth headers. The `{ message, code }` contract of `toRunErrorPayload` + is unchanged. + + The error surfaced to consumers via the `ChatClient` / `useChat` `error` (and the + `onError` callback) now also carries `code` and `rawEvent` when present, so the upstream + cause is recoverable in application code. + + > Note: the OpenRouter SDK parses each in-band stream chunk's `error` through a strict + > schema (`{ code, message }`), so provider `metadata` survives only on pre-stream HTTP + > errors (rate-limit / overload / BYOK rejection), whose typed error class exposes the + > full body via `.error`. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.10.0 ### Minor Changes diff --git a/packages/ai-openrouter/package.json b/packages/ai-openrouter/package.json index 17c6f8d6d..3b2035805 100644 --- a/packages/ai-openrouter/package.json +++ b/packages/ai-openrouter/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-openrouter", - "version": "0.10.0", + "version": "0.11.0", "description": "TanStack AI adapter for OpenRouter chat, provider tools, structured outputs, and access to hundreds of LLMs.", "author": "", "license": "MIT", diff --git a/packages/ai-preact/CHANGELOG.md b/packages/ai-preact/CHANGELOG.md index 4d9e7ffc1..fea3e0e6b 100644 --- a/packages/ai-preact/CHANGELOG.md +++ b/packages/ai-preact/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-preact +## 0.8.0 + +### Minor Changes + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-client@0.15.0 + ## 0.7.1 ### Patch Changes diff --git a/packages/ai-preact/package.json b/packages/ai-preact/package.json index 30ffc1b6e..2c981eb4f 100644 --- a/packages/ai-preact/package.json +++ b/packages/ai-preact/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-preact", - "version": "0.7.1", + "version": "0.8.0", "description": "Preact hooks for TanStack AI streaming chat and typed messages.", "author": "", "license": "MIT", diff --git a/packages/ai-react-ui/CHANGELOG.md b/packages/ai-react-ui/CHANGELOG.md index 69718a7db..c1b8cdcd4 100644 --- a/packages/ai-react-ui/CHANGELOG.md +++ b/packages/ai-react-ui/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-react-ui +## 0.8.5 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai-client@0.15.0 + - @tanstack/ai-react@0.14.0 + ## 0.8.4 ### Patch Changes diff --git a/packages/ai-react-ui/package.json b/packages/ai-react-ui/package.json index 1839fe28e..a8fa11fee 100644 --- a/packages/ai-react-ui/package.json +++ b/packages/ai-react-ui/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-react-ui", - "version": "0.8.4", + "version": "0.8.5", "description": "Headless React components for building TanStack AI chat interfaces with streamed message parts.", "module": "./dist/esm/index.js", "types": "./dist/esm/index.d.ts", diff --git a/packages/ai-react/CHANGELOG.md b/packages/ai-react/CHANGELOG.md index 626ee64b6..be72f617d 100644 --- a/packages/ai-react/CHANGELOG.md +++ b/packages/ai-react/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-react +## 0.14.0 + +### Minor Changes + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-client@0.15.0 + ## 0.13.1 ### Patch Changes diff --git a/packages/ai-react/package.json b/packages/ai-react/package.json index 470670479..560291dce 100644 --- a/packages/ai-react/package.json +++ b/packages/ai-react/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-react", - "version": "0.13.1", + "version": "0.14.0", "description": "React hooks for TanStack AI streaming chat, realtime voice, structured outputs, and media generation.", "author": "", "license": "MIT", diff --git a/packages/ai-solid-ui/CHANGELOG.md b/packages/ai-solid-ui/CHANGELOG.md index d5213424a..92b89f0a9 100644 --- a/packages/ai-solid-ui/CHANGELOG.md +++ b/packages/ai-solid-ui/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/ai-solid-ui +## 0.7.5 + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai-client@0.15.0 + - @tanstack/ai-solid@0.12.0 + ## 0.7.4 ### Patch Changes diff --git a/packages/ai-solid-ui/package.json b/packages/ai-solid-ui/package.json index 2b0f348d7..992460414 100644 --- a/packages/ai-solid-ui/package.json +++ b/packages/ai-solid-ui/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-solid-ui", - "version": "0.7.4", + "version": "0.7.5", "description": "Headless Solid components for building TanStack AI chat interfaces with streamed message parts.", "module": "./src/index.ts", "types": "./src/index.ts", diff --git a/packages/ai-solid/CHANGELOG.md b/packages/ai-solid/CHANGELOG.md index f33b8df7d..d766d0c2c 100644 --- a/packages/ai-solid/CHANGELOG.md +++ b/packages/ai-solid/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-solid +## 0.12.0 + +### Minor Changes + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-client@0.15.0 + ## 0.11.1 ### Patch Changes diff --git a/packages/ai-solid/package.json b/packages/ai-solid/package.json index c6c167fdf..63d767fcf 100644 --- a/packages/ai-solid/package.json +++ b/packages/ai-solid/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-solid", - "version": "0.11.1", + "version": "0.12.0", "description": "Solid hooks for TanStack AI streaming chat, structured outputs, and media generation.", "author": "", "license": "MIT", diff --git a/packages/ai-svelte/CHANGELOG.md b/packages/ai-svelte/CHANGELOG.md index fa72408df..f082f989c 100644 --- a/packages/ai-svelte/CHANGELOG.md +++ b/packages/ai-svelte/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-svelte +## 0.12.0 + +### Minor Changes + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-client@0.15.0 + ## 0.11.1 ### Patch Changes diff --git a/packages/ai-svelte/package.json b/packages/ai-svelte/package.json index 39937a479..af13d917c 100644 --- a/packages/ai-svelte/package.json +++ b/packages/ai-svelte/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-svelte", - "version": "0.11.1", + "version": "0.12.0", "description": "Svelte 5 bindings for TanStack AI streaming chat, structured outputs, and media generation.", "author": "", "license": "MIT", diff --git a/packages/ai-vue-ui/CHANGELOG.md b/packages/ai-vue-ui/CHANGELOG.md index eed89e8a0..6a29f5026 100644 --- a/packages/ai-vue-ui/CHANGELOG.md +++ b/packages/ai-vue-ui/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/ai-vue-ui +## 0.2.9 + +### Patch Changes + +- Updated dependencies [[`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai-vue@0.12.0 + ## 0.2.8 ### Patch Changes diff --git a/packages/ai-vue-ui/package.json b/packages/ai-vue-ui/package.json index 07a57319a..0a42474ea 100644 --- a/packages/ai-vue-ui/package.json +++ b/packages/ai-vue-ui/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-vue-ui", - "version": "0.2.8", + "version": "0.2.9", "description": "Headless Vue components for building TanStack AI chat interfaces with streamed message parts.", "module": "./src/index.ts", "types": "./src/index.ts", diff --git a/packages/ai-vue/CHANGELOG.md b/packages/ai-vue/CHANGELOG.md index 2d39be12f..555be436f 100644 --- a/packages/ai-vue/CHANGELOG.md +++ b/packages/ai-vue/CHANGELOG.md @@ -1,5 +1,56 @@ # @tanstack/ai-vue +## 0.12.0 + +### Minor Changes + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + - @tanstack/ai-client@0.15.0 + ## 0.11.1 ### Patch Changes diff --git a/packages/ai-vue/package.json b/packages/ai-vue/package.json index 29fea3dc9..0eac65c63 100644 --- a/packages/ai-vue/package.json +++ b/packages/ai-vue/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai-vue", - "version": "0.11.1", + "version": "0.12.0", "description": "Vue composables for TanStack AI streaming chat, structured outputs, and media generation.", "author": "", "license": "MIT", diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 07eac29ab..cbf6a4e39 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -1,5 +1,85 @@ # @tanstack/ai +## 0.24.0 + +### Minor Changes + +- [#666](https://github.com/TanStack/ai/pull/666) [`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b) - feat: support multimodal (image) tool results + + Tools may now return an `Array` (e.g. a text part plus an image part) and have it transmitted to the model as structured multimodal tool output instead of a `JSON.stringify`'d blob. This unblocks use cases like returning a screenshot from a tool so the model can see it (issue [#363](https://github.com/TanStack/ai/issues/363)). + - Detection is structural and opt-in by shape: a tool that returns a non-empty array whose every element is a valid `ContentPart` is passed through unchanged; strings and all other return values are serialized exactly as before, so there are no breaking changes. + - The OpenAI Responses, Anthropic, and Google Gemini adapters convert the content parts into their native multimodal tool-output formats (`function_call_output.output`, `tool_result` content blocks, and `functionResponse.parts` respectively). Providers on the Chat Completions path (Groq, Ollama, Grok, OpenRouter chat) fall back to stringifying, which their APIs require. + - AG-UI stream events (`TOOL_CALL_RESULT.content`, `TOOL_CALL_END.result`) remain string-only per the spec; the multimodal array travels on the tool message itself. + +- [#673](https://github.com/TanStack/ai/pull/673) [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915) - Populate AG-UI `rawEvent` on `RUN_ERROR` events with the provider's structured error body. + + Previously, when a streaming chat call failed the `RUN_ERROR` event carried only an + opaque `{ message, code }` headline (e.g. `"Provider returned error"`), and no adapter + populated AG-UI's purpose-built `rawEvent` field — so the upstream provider detail was + unrecoverable. + + Adapters now forward the provider's **structured error body** (e.g. an SDK `APIError`'s + parsed `.error` response body, or OpenRouter's mid-stream `chunk.error`) as `rawEvent` + on the `RUN_ERROR` event. The new `toRunErrorRawEvent` helper extracts only known + provider-body fields — never the raw SDK exception object, which can carry request + metadata such as auth headers. The `{ message, code }` contract of `toRunErrorPayload` + is unchanged. + + The error surfaced to consumers via the `ChatClient` / `useChat` `error` (and the + `onError` callback) now also carries `code` and `rawEvent` when present, so the upstream + cause is recoverable in application code. + + > Note: the OpenRouter SDK parses each in-band stream chunk's `error` through a strict + > schema (`{ code, message }`), so provider `metadata` survives only on pre-stream HTTP + > errors (rate-limit / overload / BYOK rejection), whose typed error class exposes the + > full body via `.error`. + +- [#628](https://github.com/TanStack/ai/pull/628) [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919) - Add typed runtime context for tools and middleware. + + Tools and middleware can now declare the runtime context shape they require, and + `chat()`, `ChatClient`, and the framework `useChat` / `createChat` hooks infer + the merged requirement and type-check the `context` option you pass against it. + + ```typescript + type AppContext = { userId: string; db: Db } + + const listNotes = toolDefinition({ + name: 'list_notes' /* ... */, + }).server((_input, ctx) => + ctx.context.db.notes.findMany({ userId: ctx.context.userId }), + ) + + chat({ + adapter, + messages, + tools: [listNotes], + context: { userId, db }, // required and type-checked because listNotes declares AppContext + }) + ``` + + Runtime context is request-local application state for tool and middleware + implementations (authenticated users, database clients, tenancy, feature flags, + loggers, browser services). It is never sent to the model and is distinct from + the AG-UI `RunAgentInput.context` protocol field. + + Untyped tools and middleware continue to receive `unknown` context and do not + force a `context` option. Client tools receive client-local context via + `ChatClient` / `useChat`; use `forwardedProps` to hand serializable client data + to the server and map it into server context explicitly. See the new Runtime + Context guide for details. + + Behavior change: tool output validation now also runs when a tool returns + `undefined` or `null`. Previously these values bypassed `outputSchema` + validation entirely; now the schema decides whether they are valid, so a tool + whose schema forbids `undefined`/`null` surfaces a validation error + (`output-error`) instead of silently passing. Tools whose schema permits + `null`/`undefined` (e.g. nullable or void outputs) are unaffected. + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-event-client@0.4.3 + ## 0.23.1 ### Patch Changes diff --git a/packages/ai/package.json b/packages/ai/package.json index c8b719103..4fce58ee0 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/ai", - "version": "0.23.1", + "version": "0.24.0", "description": "Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/openai-base/CHANGELOG.md b/packages/openai-base/CHANGELOG.md index bd398c95c..0bcfc7090 100644 --- a/packages/openai-base/CHANGELOG.md +++ b/packages/openai-base/CHANGELOG.md @@ -1,5 +1,44 @@ # @tanstack/openai-base +## 0.5.0 + +### Minor Changes + +- [#666](https://github.com/TanStack/ai/pull/666) [`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b) - feat: support multimodal (image) tool results + + Tools may now return an `Array` (e.g. a text part plus an image part) and have it transmitted to the model as structured multimodal tool output instead of a `JSON.stringify`'d blob. This unblocks use cases like returning a screenshot from a tool so the model can see it (issue [#363](https://github.com/TanStack/ai/issues/363)). + - Detection is structural and opt-in by shape: a tool that returns a non-empty array whose every element is a valid `ContentPart` is passed through unchanged; strings and all other return values are serialized exactly as before, so there are no breaking changes. + - The OpenAI Responses, Anthropic, and Google Gemini adapters convert the content parts into their native multimodal tool-output formats (`function_call_output.output`, `tool_result` content blocks, and `functionResponse.parts` respectively). Providers on the Chat Completions path (Groq, Ollama, Grok, OpenRouter chat) fall back to stringifying, which their APIs require. + - AG-UI stream events (`TOOL_CALL_RESULT.content`, `TOOL_CALL_END.result`) remain string-only per the spec; the multimodal array travels on the tool message itself. + +- [#673](https://github.com/TanStack/ai/pull/673) [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915) - Populate AG-UI `rawEvent` on `RUN_ERROR` events with the provider's structured error body. + + Previously, when a streaming chat call failed the `RUN_ERROR` event carried only an + opaque `{ message, code }` headline (e.g. `"Provider returned error"`), and no adapter + populated AG-UI's purpose-built `rawEvent` field — so the upstream provider detail was + unrecoverable. + + Adapters now forward the provider's **structured error body** (e.g. an SDK `APIError`'s + parsed `.error` response body, or OpenRouter's mid-stream `chunk.error`) as `rawEvent` + on the `RUN_ERROR` event. The new `toRunErrorRawEvent` helper extracts only known + provider-body fields — never the raw SDK exception object, which can carry request + metadata such as auth headers. The `{ message, code }` contract of `toRunErrorPayload` + is unchanged. + + The error surfaced to consumers via the `ChatClient` / `useChat` `error` (and the + `onError` callback) now also carries `code` and `rawEvent` when present, so the upstream + cause is recoverable in application code. + + > Note: the OpenRouter SDK parses each in-band stream chunk's `error` through a strict + > schema (`{ code, message }`), so provider `metadata` survives only on pre-stream HTTP + > errors (rate-limit / overload / BYOK rejection), whose typed error class exposes the + > full body via `.error`. + +### Patch Changes + +- Updated dependencies [[`c1ae8b9`](https://github.com/TanStack/ai/commit/c1ae8b94c83d70508975568eb4fc9b45f1af540b), [`a452ae8`](https://github.com/TanStack/ai/commit/a452ae8bcda8abfdc6309983976ed0fbf6df1915), [`8036b50`](https://github.com/TanStack/ai/commit/8036b5054330a180023c6e3225b8d2735a43a919)]: + - @tanstack/ai@0.24.0 + ## 0.4.1 ### Patch Changes diff --git a/packages/openai-base/package.json b/packages/openai-base/package.json index 43af5479b..74fc9af20 100644 --- a/packages/openai-base/package.json +++ b/packages/openai-base/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/openai-base", - "version": "0.4.1", + "version": "0.5.0", "description": "Shared OpenAI SDK base adapters for TanStack AI providers using Chat Completions and Responses APIs.", "author": "", "license": "MIT", diff --git a/packages/preact-ai-devtools/CHANGELOG.md b/packages/preact-ai-devtools/CHANGELOG.md index e30f477bb..935ce05e8 100644 --- a/packages/preact-ai-devtools/CHANGELOG.md +++ b/packages/preact-ai-devtools/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/preact-ai-devtools +## 0.1.46 + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-devtools-core@0.4.3 + ## 0.1.45 ### Patch Changes diff --git a/packages/preact-ai-devtools/package.json b/packages/preact-ai-devtools/package.json index 3543a64ed..5cc753428 100644 --- a/packages/preact-ai-devtools/package.json +++ b/packages/preact-ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/preact-ai-devtools", - "version": "0.1.45", + "version": "0.1.46", "description": "Preact Devtools plugin for inspecting TanStack AI chat messages, tool calls, streams, and errors.", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/react-ai-devtools/CHANGELOG.md b/packages/react-ai-devtools/CHANGELOG.md index 490ee7d19..a357a7f3c 100644 --- a/packages/react-ai-devtools/CHANGELOG.md +++ b/packages/react-ai-devtools/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/react-ai-devtools +## 0.2.46 + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-devtools-core@0.4.3 + ## 0.2.45 ### Patch Changes diff --git a/packages/react-ai-devtools/package.json b/packages/react-ai-devtools/package.json index d1081db0c..079d22ce4 100644 --- a/packages/react-ai-devtools/package.json +++ b/packages/react-ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-ai-devtools", - "version": "0.2.45", + "version": "0.2.46", "description": "React Devtools plugin for inspecting TanStack AI chat messages, tool calls, streams, and errors.", "author": "tannerlinsley", "license": "MIT", diff --git a/packages/solid-ai-devtools/CHANGELOG.md b/packages/solid-ai-devtools/CHANGELOG.md index b2bf63fa5..6068dca62 100644 --- a/packages/solid-ai-devtools/CHANGELOG.md +++ b/packages/solid-ai-devtools/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/solid-ai-devtools +## 0.2.46 + +### Patch Changes + +- Updated dependencies []: + - @tanstack/ai-devtools-core@0.4.3 + ## 0.2.45 ### Patch Changes diff --git a/packages/solid-ai-devtools/package.json b/packages/solid-ai-devtools/package.json index 471dbb86c..daad83392 100644 --- a/packages/solid-ai-devtools/package.json +++ b/packages/solid-ai-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-ai-devtools", - "version": "0.2.45", + "version": "0.2.46", "description": "Solid Devtools plugin for inspecting TanStack AI chat messages, tool calls, streams, and errors.", "author": "", "license": "MIT",