@tanstack/ai 0.53.0 → 0.55.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.
- package/README.md +14 -13
- package/dist/esm/activities/chat/index.js +22 -4
- package/dist/esm/activities/chat/index.js.map +1 -1
- package/dist/esm/activities/chat/messages.d.ts +21 -1
- package/dist/esm/activities/chat/messages.js +50 -1
- package/dist/esm/activities/chat/messages.js.map +1 -1
- package/dist/esm/activities/chat/stream/processor.d.ts +17 -0
- package/dist/esm/activities/chat/stream/processor.js +27 -0
- package/dist/esm/activities/chat/stream/processor.js.map +1 -1
- package/dist/esm/activities/generateLiveVideo/adapter.d.ts +69 -0
- package/dist/esm/activities/generateLiveVideo/adapter.js +23 -0
- package/dist/esm/activities/generateLiveVideo/adapter.js.map +1 -0
- package/dist/esm/activities/generateLiveVideo/index.d.ts +99 -0
- package/dist/esm/activities/generateLiveVideo/index.js +162 -0
- package/dist/esm/activities/generateLiveVideo/index.js.map +1 -0
- package/dist/esm/activities/generateVideo/index.js +3 -1
- package/dist/esm/activities/generateVideo/index.js.map +1 -1
- package/dist/esm/activities/generateWorld/adapter.d.ts +69 -0
- package/dist/esm/activities/generateWorld/adapter.js +23 -0
- package/dist/esm/activities/generateWorld/adapter.js.map +1 -0
- package/dist/esm/activities/generateWorld/index.d.ts +99 -0
- package/dist/esm/activities/generateWorld/index.js +162 -0
- package/dist/esm/activities/generateWorld/index.js.map +1 -0
- package/dist/esm/activities/index.d.ts +8 -2
- package/dist/esm/activities/index.js +11 -7
- package/dist/esm/activities/middleware/types.d.ts +1 -1
- package/dist/esm/client.d.ts +4 -2
- package/dist/esm/client.js +3 -1
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +3 -1
- package/dist/esm/middlewares/otel.js +3 -1
- package/dist/esm/middlewares/otel.js.map +1 -1
- package/dist/esm/types.d.ts +112 -0
- package/package.json +3 -3
- package/skills/ai-core/adapter-configuration/SKILL.md +91 -43
- package/skills/ai-core/adapter-configuration/references/anthropic-adapter.md +39 -21
- package/skills/ai-core/adapter-configuration/references/byteplus-adapter.md +5 -0
- package/skills/ai-core/adapter-configuration/references/gemini-adapter.md +14 -6
- package/skills/ai-core/adapter-configuration/references/grok-adapter.md +33 -25
- package/skills/ai-core/adapter-configuration/references/groq-adapter.md +7 -2
- package/skills/ai-core/adapter-configuration/references/ollama-adapter.md +25 -12
- package/skills/ai-core/adapter-configuration/references/openai-adapter.md +19 -9
- package/skills/ai-core/adapter-configuration/references/openrouter-adapter.md +34 -21
- package/skills/ai-core/ag-ui-protocol/SKILL.md +16 -10
- package/skills/ai-core/chat-experience/SKILL.md +228 -108
- package/skills/ai-core/client-persistence/SKILL.md +21 -9
- package/skills/ai-core/custom-backend-integration/SKILL.md +86 -52
- package/skills/ai-core/debug-logging/SKILL.md +100 -18
- package/skills/ai-core/locks/SKILL.md +35 -7
- package/skills/ai-core/media-generation/SKILL.md +136 -61
- package/skills/ai-core/middleware/SKILL.md +174 -69
- package/skills/ai-core/structured-outputs/SKILL.md +98 -49
- package/skills/ai-core/tool-calling/SKILL.md +245 -158
- package/src/activities/chat/index.ts +29 -7
- package/src/activities/chat/messages.ts +60 -0
- package/src/activities/chat/stream/processor.ts +31 -0
- package/src/activities/generateLiveVideo/adapter.ts +99 -0
- package/src/activities/generateLiveVideo/index.ts +339 -0
- package/src/activities/generateVideo/index.ts +3 -4
- package/src/activities/generateWorld/adapter.ts +96 -0
- package/src/activities/generateWorld/index.ts +339 -0
- package/src/activities/index.ts +44 -0
- package/src/activities/middleware/types.ts +2 -0
- package/src/client.ts +8 -0
- package/src/index.ts +8 -0
- package/src/middlewares/otel.ts +2 -0
- package/src/types.ts +128 -0
package/README.md
CHANGED
|
@@ -202,19 +202,20 @@ Learn more in the
|
|
|
202
202
|
|
|
203
203
|
Official adapters include:
|
|
204
204
|
|
|
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
|
|
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 |
|
|
218
219
|
|
|
219
220
|
The adapter system is tree-shakeable by activity. Import `openaiText` for chat,
|
|
220
221
|
`openaiImage` for images, `falVideo` for video, `geminiSpeech` for TTS, and so
|
|
@@ -18,7 +18,7 @@ import { INTERRUPT_PAYLOAD_METADATA_KEY, createInterruptBinding, rehydrateInterr
|
|
|
18
18
|
import { readGenericInterruptContinuation } from "../../generic-interrupt-continuation.js";
|
|
19
19
|
import { normalizeToolResult } from "../../utilities/tool-result.js";
|
|
20
20
|
import { isProviderExecutedToolCall } from "../../utilities/provider-executed.js";
|
|
21
|
-
import { convertMessagesToModelMessages, generateMessageId, modelMessagesToUIMessages, safeJsonStringify } from "./messages.js";
|
|
21
|
+
import { appendUiResourceToModelMessages, convertMessagesToModelMessages, generateMessageId, modelMessagesToUIMessages, safeJsonStringify, uiResourcePartFromCustomValue } from "./messages.js";
|
|
22
22
|
import { uiMessagesToWire } from "../../utilities/ag-ui-wire.js";
|
|
23
23
|
import { restorePublicUsage } from "../../utilities/restore-inbound-chunk.js";
|
|
24
24
|
import { LazyToolManager } from "./tools/lazy-tool-manager.js";
|
|
@@ -361,14 +361,16 @@ var TextEngine = class {
|
|
|
361
361
|
if (this.shouldExecuteToolPhase()) {
|
|
362
362
|
this.deferredToolCallRunFinishedChunks.push(...this.deferredModelRunFinishedChunks);
|
|
363
363
|
this.deferredModelRunFinishedChunks = [];
|
|
364
|
-
} else yield* this.flushDeferredModelRunFinishedChunks();
|
|
364
|
+
} else if (!this.finalStructuredOutput?.nativeCombined) yield* this.flushDeferredModelRunFinishedChunks();
|
|
365
365
|
} else yield* this.processToolCalls();
|
|
366
366
|
this.endCycle();
|
|
367
367
|
} while (yield* this.runWhileYielding(this.shouldContinue()));
|
|
368
368
|
this.logger.agentLoop("run finished", { finishReason: this.lastFinishReason });
|
|
369
369
|
if (this.finalStructuredOutput && this.toolPhase !== "wait" && !this.isCancelled() && !this.finalizationError && !this.earlyTermination) {
|
|
370
|
-
if (this.finalStructuredOutput.nativeCombined === true)
|
|
371
|
-
|
|
370
|
+
if (this.finalStructuredOutput.nativeCombined === true) {
|
|
371
|
+
yield* this.harvestCombinedStructuredOutput();
|
|
372
|
+
if (!this.finalizationError && !this.isCancelled()) yield* this.flushDeferredModelRunFinishedChunks();
|
|
373
|
+
} else yield* this.runStructuredFinalization();
|
|
372
374
|
}
|
|
373
375
|
if (!this.terminalHookCalled && this.toolPhase !== "wait" && !this.isCancelled()) {
|
|
374
376
|
if (this.finalizationError) {
|
|
@@ -1205,6 +1207,21 @@ var TextEngine = class {
|
|
|
1205
1207
|
}
|
|
1206
1208
|
};
|
|
1207
1209
|
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Record a `ui-resource` CUSTOM chunk on the assistant ModelMessage owning
|
|
1212
|
+
* its `toolCallId` so the resource survives later MESSAGES_SNAPSHOT chunks
|
|
1213
|
+
* (e.g. the interrupt snapshot emitted when the run pauses on a client
|
|
1214
|
+
* tool). Mirrors the anchor-preserving approach used for
|
|
1215
|
+
* `toolCallMetadata` (#867). See #1397.
|
|
1216
|
+
*/
|
|
1217
|
+
recordEmittedUiResource(value) {
|
|
1218
|
+
const part = uiResourcePartFromCustomValue(value);
|
|
1219
|
+
if (!part) return;
|
|
1220
|
+
const next = appendUiResourceToModelMessages(this.messages, part);
|
|
1221
|
+
if (next === this.messages) return;
|
|
1222
|
+
this.messages = next;
|
|
1223
|
+
this.middlewareCtx.messages = this.messages;
|
|
1224
|
+
}
|
|
1208
1225
|
buildMessagesSnapshotChunk() {
|
|
1209
1226
|
const withIds = this.messages.map((message, index) => ({
|
|
1210
1227
|
...message,
|
|
@@ -2118,6 +2135,7 @@ var TextEngine = class {
|
|
|
2118
2135
|
if (this.hasPublicRunStarted) continue;
|
|
2119
2136
|
this.hasPublicRunStarted = true;
|
|
2120
2137
|
}
|
|
2138
|
+
if (spec.type === EventType.CUSTOM && spec.name === "ui-resource") this.recordEmittedUiResource(spec.value);
|
|
2121
2139
|
yield spec;
|
|
2122
2140
|
this.middlewareCtx.chunkIndex++;
|
|
2123
2141
|
}
|