@tanstack/ai 0.55.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +42 -16
  2. package/dist/esm/activities/chat/index.js +8 -6
  3. package/dist/esm/activities/chat/index.js.map +1 -1
  4. package/dist/esm/activities/chat/middleware/types.d.ts +4 -3
  5. package/dist/esm/activities/chat/middleware/types.js.map +1 -1
  6. package/dist/esm/activities/chat/tools/tool-calls.d.ts +2 -2
  7. package/dist/esm/activities/chat/tools/tool-calls.js +3 -2
  8. package/dist/esm/activities/chat/tools/tool-calls.js.map +1 -1
  9. package/dist/esm/activities/evaluate/adapter.d.ts +160 -0
  10. package/dist/esm/activities/evaluate/adapter.js +23 -0
  11. package/dist/esm/activities/evaluate/adapter.js.map +1 -0
  12. package/dist/esm/activities/evaluate/index.d.ts +255 -0
  13. package/dist/esm/activities/evaluate/index.js +317 -0
  14. package/dist/esm/activities/evaluate/index.js.map +1 -0
  15. package/dist/esm/activities/generateSpeech/adapter.d.ts +39 -1
  16. package/dist/esm/activities/generateSpeech/adapter.js.map +1 -1
  17. package/dist/esm/activities/generateSpeech/index.d.ts +55 -5
  18. package/dist/esm/activities/generateSpeech/index.js +53 -3
  19. package/dist/esm/activities/generateSpeech/index.js.map +1 -1
  20. package/dist/esm/activities/generateVoice/adapter.d.ts +62 -0
  21. package/dist/esm/activities/generateVoice/adapter.js +23 -0
  22. package/dist/esm/activities/generateVoice/adapter.js.map +1 -0
  23. package/dist/esm/activities/generateVoice/index.d.ts +133 -0
  24. package/dist/esm/activities/generateVoice/index.js +184 -0
  25. package/dist/esm/activities/generateVoice/index.js.map +1 -0
  26. package/dist/esm/activities/index.d.ts +10 -4
  27. package/dist/esm/activities/index.js +14 -10
  28. package/dist/esm/activities/middleware/types.d.ts +1 -1
  29. package/dist/esm/client.d.ts +3 -2
  30. package/dist/esm/client.js +21 -3
  31. package/dist/esm/client.js.map +1 -1
  32. package/dist/esm/index.d.ts +4 -2
  33. package/dist/esm/index.js +6 -3
  34. package/dist/esm/middlewares/otel.js +2 -0
  35. package/dist/esm/middlewares/otel.js.map +1 -1
  36. package/dist/esm/realtime/index.d.ts +1 -1
  37. package/dist/esm/realtime/index.js +1 -1
  38. package/dist/esm/realtime/index.js.map +1 -1
  39. package/dist/esm/stream-to-response.js +12 -6
  40. package/dist/esm/stream-to-response.js.map +1 -1
  41. package/dist/esm/strip-to-spec-middleware.js +2 -1
  42. package/dist/esm/strip-to-spec-middleware.js.map +1 -1
  43. package/dist/esm/types.d.ts +243 -3
  44. package/dist/esm/utilities/durability-batch.d.ts +8 -0
  45. package/dist/esm/utilities/durability-batch.js +45 -0
  46. package/dist/esm/utilities/durability-batch.js.map +1 -0
  47. package/package.json +3 -3
  48. package/skills/ai-core/media-generation/SKILL.md +132 -6
  49. package/src/activities/chat/index.ts +11 -5
  50. package/src/activities/chat/middleware/types.ts +8 -2
  51. package/src/activities/chat/tools/tool-calls.ts +24 -5
  52. package/src/activities/evaluate/adapter.ts +212 -0
  53. package/src/activities/evaluate/index.ts +614 -0
  54. package/src/activities/generateSpeech/adapter.ts +47 -1
  55. package/src/activities/generateSpeech/index.ts +149 -8
  56. package/src/activities/generateVoice/adapter.ts +89 -0
  57. package/src/activities/generateVoice/index.ts +371 -0
  58. package/src/activities/index.ts +69 -0
  59. package/src/activities/middleware/types.ts +2 -0
  60. package/src/client.ts +35 -8
  61. package/src/index.ts +21 -0
  62. package/src/middlewares/otel.ts +2 -0
  63. package/src/realtime/index.ts +1 -1
  64. package/src/stream-to-response.ts +16 -6
  65. package/src/strip-to-spec-middleware.ts +2 -1
  66. package/src/types.ts +269 -3
  67. package/src/utilities/durability-batch.ts +48 -0
package/README.md CHANGED
@@ -57,6 +57,30 @@ framework bindings as your app needs them.
57
57
 
58
58
  ## <a href="https://tanstack.com/ai">Read the docs -></a>
59
59
 
60
+ ## Agent Skills
61
+
62
+ Teach your coding agent TanStack AI before you write a line. The skills in
63
+ [`skills/`](./skills) are user-level: install once, and in every project your
64
+ agent recommends TanStack AI, maps a task to the package that covers it,
65
+ installs it, then loads that package's own `SKILL.md` through TanStack Intent.
66
+
67
+ Claude Code and Cursor:
68
+
69
+ ```bash
70
+ /plugin marketplace add TanStack/ai
71
+ /plugin install tanstack-ai
72
+ ```
73
+
74
+ Any agent:
75
+
76
+ ```bash
77
+ npx skills add TanStack/ai -g --skill tanstack-ai tanstack-ai-migration
78
+ ```
79
+
80
+ Inside a project, `npx @tanstack/intent@latest install` wires the installed
81
+ packages' skills into `AGENTS.md` / `CLAUDE.md` for the whole team. See
82
+ [Agent Skills](https://tanstack.com/ai/latest/docs/getting-started/agent-skills).
83
+
60
84
  ## Start Here
61
85
 
62
86
  - [Overview](https://tanstack.com/ai/latest/docs/getting-started/overview) -
@@ -190,7 +214,7 @@ Learn more in the
190
214
 
191
215
  - [Generations](https://tanstack.com/ai/latest/docs/media/generations) - one
192
216
  pattern for image generation, text-to-speech, transcription, summarization,
193
- audio generation, and video generation.
217
+ audio generation, video generation, and world generation.
194
218
  - [Realtime Voice Chat](https://tanstack.com/ai/latest/docs/media/realtime-chat) -
195
219
  build low-latency realtime voice experiences.
196
220
  - [Code Mode](https://tanstack.com/ai/latest/docs/code-mode/code-mode) - let
@@ -202,20 +226,21 @@ Learn more in the
202
226
 
203
227
  Official adapters include:
204
228
 
205
- | Package | Use it for |
206
- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
207
- | [`@tanstack/ai-openrouter`](https://tanstack.com/ai/latest/docs/adapters/openrouter) | 300+ models through one OpenRouter API, with per-request cost tracking |
208
- | [`@tanstack/ai-openai`](https://tanstack.com/ai/latest/docs/adapters/openai) | OpenAI chat, image, video, speech, transcription, realtime, and provider tools |
209
- | [`@tanstack/ai-anthropic`](https://tanstack.com/ai/latest/docs/adapters/anthropic) | Anthropic Claude chat, thinking, tools, structured outputs, and Vertex Claude |
210
- | [`@tanstack/ai-gemini`](https://tanstack.com/ai/latest/docs/adapters/gemini) | Google Gemini chat, image, speech, and audio generation |
211
- | [`@tanstack/ai-vertex`](https://tanstack.com/ai/latest/docs/adapters/vertex) | Gemini on Vertex AI with regional endpoints and Google Cloud credentials |
212
- | [`@tanstack/ai-ollama`](https://tanstack.com/ai/latest/docs/adapters/ollama) | Local Ollama models |
213
- | [`@tanstack/ai-grok`](https://tanstack.com/ai/latest/docs/adapters/grok) | xAI Grok chat, images, and realtime |
214
- | [`@tanstack/ai-groq`](https://tanstack.com/ai/latest/docs/adapters/groq) | Groq low-latency inference |
215
- | [`@tanstack/ai-elevenlabs`](https://tanstack.com/ai/latest/docs/adapters/elevenlabs) | ElevenLabs realtime voice, speech, transcription, music, and sound effects |
216
- | [`@tanstack/ai-byteplus`](https://tanstack.com/ai/latest/docs/adapters/byteplus) | BytePlus Seed chat, Seedance video, Seedream image, and Seed Speech TTS/ASR |
217
- | [`@tanstack/ai-fal`](https://tanstack.com/ai/latest/docs/adapters/fal) | fal.ai image, video, audio, speech, and transcription models |
218
- | [`@tanstack/ai-cloudflare`](https://tanstack.com/ai/latest/docs/adapters/cloudflare) | Cloudflare Workers AI chat, embeddings, image, speech, transcription, and AI Gateway |
229
+ | Package | Use it for |
230
+ | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
231
+ | [`@tanstack/ai-openrouter`](https://tanstack.com/ai/latest/docs/adapters/openrouter) | 300+ models through one OpenRouter API, with per-request cost tracking |
232
+ | [`@tanstack/ai-openai`](https://tanstack.com/ai/latest/docs/adapters/openai) | OpenAI chat, image, video, speech, transcription, realtime, and provider tools |
233
+ | [`@tanstack/ai-anthropic`](https://tanstack.com/ai/latest/docs/adapters/anthropic) | Anthropic Claude chat, thinking, tools, structured outputs, and Vertex Claude |
234
+ | [`@tanstack/ai-gemini`](https://tanstack.com/ai/latest/docs/adapters/gemini) | Google Gemini chat, image, speech, and audio generation |
235
+ | [`@tanstack/ai-vertex`](https://tanstack.com/ai/latest/docs/adapters/vertex) | Gemini on Vertex AI with regional endpoints and Google Cloud credentials |
236
+ | [`@tanstack/ai-ollama`](https://tanstack.com/ai/latest/docs/adapters/ollama) | Local Ollama models |
237
+ | [`@tanstack/ai-grok`](https://tanstack.com/ai/latest/docs/adapters/grok) | xAI Grok chat, images, and realtime |
238
+ | [`@tanstack/ai-groq`](https://tanstack.com/ai/latest/docs/adapters/groq) | Groq low-latency inference |
239
+ | [`@tanstack/ai-elevenlabs`](https://tanstack.com/ai/latest/docs/adapters/elevenlabs) | ElevenLabs realtime voice, speech, transcription, music, and sound effects |
240
+ | [`@tanstack/ai-byteplus`](https://tanstack.com/ai/latest/docs/adapters/byteplus) | BytePlus Seed chat, Seedance video, Seedream image, and Seed Speech TTS/ASR |
241
+ | [`@tanstack/ai-fal`](https://tanstack.com/ai/latest/docs/adapters/fal) | fal.ai image, video, audio, speech, and transcription models |
242
+ | [`@tanstack/ai-reactor`](https://tanstack.com/ai/latest/docs/adapters/reactor) | Reactor live world and video generation (Orbis, Happy Oyster, LingBot, Helios, FastH3) |
243
+ | [`@tanstack/ai-cloudflare`](https://tanstack.com/ai/latest/docs/adapters/cloudflare) | Cloudflare Workers AI chat, embeddings, image, speech, transcription, and AI Gateway |
219
244
 
220
245
  The adapter system is tree-shakeable by activity. Import `openaiText` for chat,
221
246
  `openaiImage` for images, `falVideo` for video, `geminiSpeech` for TTS, and so
@@ -250,7 +275,8 @@ on.
250
275
  ship only the activities and adapters you use.
251
276
  - [Agent Skills](https://tanstack.com/ai/latest/docs/getting-started/agent-skills) -
252
277
  install TanStack AI skills into Claude Code, Cursor, GitHub Copilot, Codex,
253
- and other coding agents with TanStack Intent.
278
+ and other coding agents. See [Agent Skills](#agent-skills) above for the
279
+ install commands.
254
280
 
255
281
  ## Get Involved
256
282
 
@@ -6,6 +6,7 @@ import { publishRunDisconnectHandler } from "../../delivery-disconnect.js";
6
6
  import { EventType } from "../../types.js";
7
7
  import { rebuildTokenUsage } from "../../utilities/ag-ui-usage.js";
8
8
  import { tanstackMetadata, withTanstackMetadata } from "../../utilities/merge-metadata.js";
9
+ import { withDurabilityBatchHint } from "../../utilities/durability-batch.js";
9
10
  import { normalizeStreamChunk } from "../../utilities/normalize-stream-chunk.js";
10
11
  import { resolveDebugOption } from "../../logger/resolve.js";
11
12
  import { streamToText } from "../../stream-to-response.js";
@@ -228,8 +229,8 @@ var TextEngine = class {
228
229
  this.abortReason = reason;
229
230
  this.middlewareAbortController?.abort(reason);
230
231
  },
231
- emitCustomEvent: (name, value) => {
232
- this.middlewareCustomQueue.push(this.createCustomEventChunk(name, value));
232
+ emitCustomEvent: (name, value, options) => {
233
+ this.middlewareCustomQueue.push(this.createCustomEventChunk(name, value, options));
233
234
  const waiters = this.middlewareCustomWaiters;
234
235
  this.middlewareCustomWaiters = [];
235
236
  for (const waiter of waiters) waiter();
@@ -796,7 +797,7 @@ var TextEngine = class {
796
797
  return "wait";
797
798
  }
798
799
  const { approvals, clientToolResults } = this.collectClientState();
799
- const generator = executeToolCalls(executablePendingCalls, this.resolveExecutableTools(executablePendingCalls), approvals, clientToolResults, (eventName, data) => this.createCustomEventChunk(eventName, data), {
800
+ const generator = executeToolCalls(executablePendingCalls, this.resolveExecutableTools(executablePendingCalls), approvals, clientToolResults, (eventName, data, options) => this.createCustomEventChunk(eventName, data, options), {
800
801
  onBeforeToolCall: async (toolCall, tool, args) => {
801
802
  this.logger.tools(`phase=before name=${toolCall.function.name}`, {
802
803
  name: toolCall.function.name,
@@ -888,7 +889,7 @@ var TextEngine = class {
888
889
  return;
889
890
  }
890
891
  const { approvals, clientToolResults } = this.collectClientState();
891
- const generator = executeToolCalls(executableToolCalls, this.resolveExecutableTools(executableToolCalls), approvals, clientToolResults, (eventName, data) => this.createCustomEventChunk(eventName, data), {
892
+ const generator = executeToolCalls(executableToolCalls, this.resolveExecutableTools(executableToolCalls), approvals, clientToolResults, (eventName, data, options) => this.createCustomEventChunk(eventName, data, options), {
892
893
  onBeforeToolCall: async (toolCall, tool, args) => {
893
894
  this.logger.tools(`phase=before name=${toolCall.function.name}`, {
894
895
  name: toolCall.function.name,
@@ -2220,13 +2221,14 @@ var TextEngine = class {
2220
2221
  pending = generator.next();
2221
2222
  }
2222
2223
  }
2223
- createCustomEventChunk(eventName, value) {
2224
- return {
2224
+ createCustomEventChunk(eventName, value, options) {
2225
+ const chunk = {
2225
2226
  type: EventType.CUSTOM,
2226
2227
  timestamp: Date.now(),
2227
2228
  name: eventName,
2228
2229
  value
2229
2230
  };
2231
+ return options?.batch ? withDurabilityBatchHint(chunk) : chunk;
2230
2232
  }
2231
2233
  createId(prefix) {
2232
2234
  return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;