@tanstack/ai 0.14.0 → 0.16.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/adapter.d.ts +6 -3
- package/dist/esm/activities/chat/adapter.js.map +1 -1
- package/dist/esm/activities/chat/index.js +61 -9
- package/dist/esm/activities/chat/index.js.map +1 -1
- package/dist/esm/activities/chat/messages.js +26 -3
- package/dist/esm/activities/chat/messages.js.map +1 -1
- package/dist/esm/activities/chat/stream/message-updaters.d.ts +4 -2
- package/dist/esm/activities/chat/stream/message-updaters.js +10 -4
- package/dist/esm/activities/chat/stream/message-updaters.js.map +1 -1
- package/dist/esm/activities/chat/stream/processor.d.ts +21 -5
- package/dist/esm/activities/chat/stream/processor.js +119 -19
- package/dist/esm/activities/chat/stream/processor.js.map +1 -1
- package/dist/esm/activities/chat/stream/types.d.ts +9 -1
- package/dist/esm/activities/chat/tools/tool-calls.js +3 -4
- package/dist/esm/activities/chat/tools/tool-calls.js.map +1 -1
- package/dist/esm/middlewares/otel.d.ts +75 -0
- package/dist/esm/middlewares/otel.js +624 -0
- package/dist/esm/middlewares/otel.js.map +1 -0
- package/dist/esm/types.d.ts +23 -7
- package/package.json +15 -2
- package/src/activities/chat/adapter.ts +8 -2
- package/src/activities/chat/index.ts +74 -11
- package/src/activities/chat/messages.ts +29 -1
- package/src/activities/chat/stream/message-updaters.ts +18 -3
- package/src/activities/chat/stream/processor.ts +152 -17
- package/src/activities/chat/stream/types.ts +9 -1
- package/src/activities/chat/tools/tool-calls.ts +4 -4
- package/src/middlewares/index.ts +5 -0
- package/src/middlewares/otel.ts +861 -0
- package/src/types.ts +20 -7
package/src/types.ts
CHANGED
|
@@ -111,15 +111,17 @@ export type SchemaInput = StandardJSONSchemaV1<any, any> | JSONSchema
|
|
|
111
111
|
export type InferSchemaType<T> =
|
|
112
112
|
T extends StandardJSONSchemaV1<infer TInput, unknown> ? TInput : unknown
|
|
113
113
|
|
|
114
|
-
export interface ToolCall {
|
|
114
|
+
export interface ToolCall<TMetadata = unknown> {
|
|
115
115
|
id: string
|
|
116
116
|
type: 'function'
|
|
117
117
|
function: {
|
|
118
118
|
name: string
|
|
119
119
|
arguments: string // JSON string
|
|
120
120
|
}
|
|
121
|
-
/** Provider-specific metadata to carry through the tool call lifecycle
|
|
122
|
-
|
|
121
|
+
/** Provider-specific metadata to carry through the tool call lifecycle.
|
|
122
|
+
* Typed per-adapter via `TToolCallMetadata`. For example,
|
|
123
|
+
* `@tanstack/ai-gemini` sets this to `{ thoughtSignature?: string }`. */
|
|
124
|
+
metadata?: TMetadata
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
// ============================================================================
|
|
@@ -297,6 +299,7 @@ export interface ModelMessage<
|
|
|
297
299
|
name?: string
|
|
298
300
|
toolCalls?: Array<ToolCall>
|
|
299
301
|
toolCallId?: string
|
|
302
|
+
thinking?: Array<{ content: string; signature?: string }>
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
/**
|
|
@@ -308,7 +311,7 @@ export interface TextPart<TMetadata = unknown> {
|
|
|
308
311
|
metadata?: TMetadata
|
|
309
312
|
}
|
|
310
313
|
|
|
311
|
-
export interface ToolCallPart {
|
|
314
|
+
export interface ToolCallPart<TMetadata = unknown> {
|
|
312
315
|
type: 'tool-call'
|
|
313
316
|
id: string
|
|
314
317
|
name: string
|
|
@@ -322,6 +325,9 @@ export interface ToolCallPart {
|
|
|
322
325
|
}
|
|
323
326
|
/** Tool execution output (for client tools or after approval) */
|
|
324
327
|
output?: any
|
|
328
|
+
/** Provider-specific metadata that round-trips with the tool call.
|
|
329
|
+
* Typed per-adapter via `TToolCallMetadata`. */
|
|
330
|
+
metadata?: TMetadata
|
|
325
331
|
}
|
|
326
332
|
|
|
327
333
|
export interface ToolResultPart {
|
|
@@ -335,6 +341,8 @@ export interface ToolResultPart {
|
|
|
335
341
|
export interface ThinkingPart {
|
|
336
342
|
type: 'thinking'
|
|
337
343
|
content: string
|
|
344
|
+
stepId?: string
|
|
345
|
+
signature?: string
|
|
338
346
|
}
|
|
339
347
|
|
|
340
348
|
export type MessagePart =
|
|
@@ -889,7 +897,7 @@ export interface TextMessageEndEvent extends AGUITextMessageEndEvent {
|
|
|
889
897
|
* Emitted when a tool call starts.
|
|
890
898
|
*
|
|
891
899
|
* @ag-ui/core provides: `toolCallId`, `toolCallName`, `parentMessageId?`
|
|
892
|
-
* TanStack AI adds: `model?`, `toolName` (deprecated alias), `index?`, `
|
|
900
|
+
* TanStack AI adds: `model?`, `toolName` (deprecated alias), `index?`, `metadata?`
|
|
893
901
|
*/
|
|
894
902
|
export interface ToolCallStartEvent extends AGUIToolCallStartEvent {
|
|
895
903
|
/** Model identifier for multi-model support */
|
|
@@ -901,8 +909,11 @@ export interface ToolCallStartEvent extends AGUIToolCallStartEvent {
|
|
|
901
909
|
toolName: string
|
|
902
910
|
/** Index for parallel tool calls */
|
|
903
911
|
index?: number
|
|
904
|
-
/** Provider-specific metadata to carry into the ToolCall
|
|
905
|
-
|
|
912
|
+
/** Provider-specific metadata to carry into the ToolCall.
|
|
913
|
+
* Untyped at the event layer because events flow through a discriminated
|
|
914
|
+
* union that does not survive generics; adapters cast it to their typed
|
|
915
|
+
* `TToolCallMetadata` shape when emitting. */
|
|
916
|
+
metadata?: Record<string, unknown>
|
|
906
917
|
}
|
|
907
918
|
|
|
908
919
|
/**
|
|
@@ -987,6 +998,8 @@ export interface StepFinishedEvent extends AGUIStepFinishedEvent {
|
|
|
987
998
|
delta?: string
|
|
988
999
|
/** Full accumulated thinking content (TanStack AI internal) */
|
|
989
1000
|
content?: string
|
|
1001
|
+
/** Provider signature for the thinking block */
|
|
1002
|
+
signature?: string
|
|
990
1003
|
}
|
|
991
1004
|
|
|
992
1005
|
/**
|