@tanstack/ai 0.39.0 → 0.40.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/dist/esm/activities/chat/index.d.ts +2 -2
- package/dist/esm/activities/chat/index.js +24 -3
- package/dist/esm/activities/chat/index.js.map +1 -1
- package/dist/esm/activities/chat/middleware/compose.d.ts +2 -2
- package/dist/esm/activities/chat/middleware/compose.js.map +1 -1
- package/dist/esm/activities/chat/middleware/index.d.ts +1 -1
- package/dist/esm/activities/chat/middleware/sandbox-runtime.d.ts +7 -2
- package/dist/esm/activities/chat/middleware/sandbox-runtime.js.map +1 -1
- package/dist/esm/activities/chat/middleware/types.d.ts +16 -4
- package/dist/esm/activities/chat/stream/processor.d.ts +18 -0
- package/dist/esm/activities/chat/stream/processor.js +86 -4
- package/dist/esm/activities/chat/stream/processor.js.map +1 -1
- package/dist/esm/activities/generateTranscription/index.d.ts +2 -2
- package/dist/esm/activities/generateTranscription/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +137 -2
- package/dist/esm/utilities/provider-executed.d.ts +18 -0
- package/dist/esm/utilities/provider-executed.js +15 -0
- package/dist/esm/utilities/provider-executed.js.map +1 -0
- package/package.json +1 -1
- package/skills/ai-core/adapter-configuration/SKILL.md +10 -0
- package/skills/ai-core/adapter-configuration/references/anthropic-adapter.md +43 -12
- package/skills/ai-core/ag-ui-protocol/SKILL.md +59 -0
- package/skills/ai-core/media-generation/SKILL.md +9 -4
- package/skills/ai-core/middleware/SKILL.md +91 -0
- package/src/activities/chat/index.ts +34 -6
- package/src/activities/chat/middleware/compose.ts +2 -2
- package/src/activities/chat/middleware/index.ts +1 -0
- package/src/activities/chat/middleware/sandbox-runtime.ts +4 -2
- package/src/activities/chat/middleware/types.ts +17 -4
- package/src/activities/chat/stream/processor.ts +141 -3
- package/src/activities/generateTranscription/index.ts +6 -2
- package/src/index.ts +6 -0
- package/src/types.ts +130 -2
- package/src/utilities/provider-executed.ts +32 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyTextAdapter } from './adapter.js';
|
|
2
|
-
import { AnyTool, ConstrainedModelMessage, InferSchemaType, LazyToolsConfig, ModelMessage, SchemaInput,
|
|
2
|
+
import { AnyTool, ChatStream, ConstrainedModelMessage, InferSchemaType, LazyToolsConfig, ModelMessage, SchemaInput, StructuredOutputStream, TextOptions, UIMessage } from '../../types.js';
|
|
3
3
|
import { AnyChatMiddleware, ChatMiddleware } from './middleware/types.js';
|
|
4
4
|
import { CheckCoverage } from './middleware/builder.js';
|
|
5
5
|
import { SystemPrompt } from '../../system-prompts.js';
|
|
@@ -203,7 +203,7 @@ export declare function createChatOptions<TAdapter extends AnyTextAdapter, TSche
|
|
|
203
203
|
* Without this, plain `chat({ outputSchema })` would type as a stream while
|
|
204
204
|
* the runtime returns a Promise — see issue #526.
|
|
205
205
|
*/
|
|
206
|
-
export type TextActivityResult<TSchema extends SchemaInput | undefined, TStream extends boolean = boolean> = TSchema extends SchemaInput ? [TStream] extends [true] ? StructuredOutputStream<InferSchemaType<TSchema>> : Promise<InferSchemaType<TSchema>> : [TStream] extends [false] ? Promise<string> :
|
|
206
|
+
export type TextActivityResult<TSchema extends SchemaInput | undefined, TStream extends boolean = boolean> = TSchema extends SchemaInput ? [TStream] extends [true] ? StructuredOutputStream<InferSchemaType<TSchema>> : Promise<InferSchemaType<TSchema>> : [TStream] extends [false] ? Promise<string> : ChatStream;
|
|
207
207
|
/**
|
|
208
208
|
* Text activity - handles agentic text generation, one-shot text generation, and agentic structured output.
|
|
209
209
|
*
|
|
@@ -4,6 +4,7 @@ import { stripToSpecMiddleware } from "../../strip-to-spec-middleware.js";
|
|
|
4
4
|
import { streamToText } from "../../stream-to-response.js";
|
|
5
5
|
import { resolveDebugOption } from "../../logger/resolve.js";
|
|
6
6
|
import { normalizeToolResult } from "../../utilities/tool-result.js";
|
|
7
|
+
import { isProviderExecutedToolCall } from "../../utilities/provider-executed.js";
|
|
7
8
|
import { LazyToolManager } from "./tools/lazy-tool-manager.js";
|
|
8
9
|
import { ToolCallManager, MiddlewareAbortError, executeToolCalls } from "./tools/tool-calls.js";
|
|
9
10
|
import { convertSchemaForStructuredOutput, isStandardSchema, parseWithStandardSchema, convertSchemaToJsonSchema } from "./tools/schema-converter.js";
|
|
@@ -190,10 +191,27 @@ class TextEngine {
|
|
|
190
191
|
provideSandboxRuntime(this.middlewareCtx, {
|
|
191
192
|
logger: this.logger,
|
|
192
193
|
emit: (event) => {
|
|
193
|
-
this.logger.sandbox(`file ${event.type} ${event.path}`, {
|
|
194
|
-
|
|
194
|
+
this.logger.sandbox(`file ${event.type} ${event.path}`, {
|
|
195
|
+
event: {
|
|
196
|
+
type: event.type,
|
|
197
|
+
path: event.path,
|
|
198
|
+
timestamp: event.timestamp
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
void this.middlewareRunner.runSandboxFile(this.middlewareCtx, event).catch((err) => {
|
|
202
|
+
this.logger.errors("sandbox file hook failed", { error: err });
|
|
203
|
+
});
|
|
195
204
|
this.sandboxFileQueue.push(
|
|
196
|
-
this.createCustomEventChunk("sandbox.file", {
|
|
205
|
+
this.createCustomEventChunk("sandbox.file", {
|
|
206
|
+
type: event.type,
|
|
207
|
+
path: event.path,
|
|
208
|
+
timestamp: event.timestamp
|
|
209
|
+
})
|
|
210
|
+
);
|
|
211
|
+
},
|
|
212
|
+
emitFileDiff: (value) => {
|
|
213
|
+
this.sandboxFileQueue.push(
|
|
214
|
+
this.createCustomEventChunk("sandbox.file.diff", value)
|
|
197
215
|
);
|
|
198
216
|
}
|
|
199
217
|
});
|
|
@@ -1014,6 +1032,9 @@ class TextEngine {
|
|
|
1014
1032
|
for (const message of this.messages) {
|
|
1015
1033
|
if (message.role === "assistant" && message.toolCalls) {
|
|
1016
1034
|
for (const toolCall of message.toolCalls) {
|
|
1035
|
+
if (isProviderExecutedToolCall(toolCall)) {
|
|
1036
|
+
continue;
|
|
1037
|
+
}
|
|
1017
1038
|
if (!completedToolIds.has(toolCall.id)) {
|
|
1018
1039
|
pending.push(toolCall);
|
|
1019
1040
|
}
|