@ai-sdk/xai
Advanced tools
+6
-0
| # @ai-sdk/xai | ||
| ## 3.0.54 | ||
| ### Patch Changes | ||
| - 902e93b: Add support for `response.function_call_arguments.delta` and `response.function_call_arguments.done` streaming events in the xAI Responses API provider. Previously, xAI Grok models using function tools would fail with `AI_TypeValidationError` because these standard Responses API events were missing from the Zod schema and stream handler. | ||
| ## 3.0.53 | ||
@@ -4,0 +10,0 @@ |
+3
-3
| { | ||
| "name": "@ai-sdk/xai", | ||
| "version": "3.0.53", | ||
| "version": "3.0.54", | ||
| "license": "Apache-2.0", | ||
@@ -32,5 +32,5 @@ "sideEffects": false, | ||
| "dependencies": { | ||
| "@ai-sdk/openai-compatible": "2.0.29", | ||
| "@ai-sdk/provider": "3.0.8", | ||
| "@ai-sdk/provider-utils": "4.0.14", | ||
| "@ai-sdk/openai-compatible": "2.0.29" | ||
| "@ai-sdk/provider-utils": "4.0.14" | ||
| }, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
@@ -463,3 +463,16 @@ import { z } from 'zod/v4'; | ||
| }), | ||
| // Function call arguments streaming events (standard function tools) | ||
| z.object({ | ||
| type: z.literal('response.function_call_arguments.delta'), | ||
| item_id: z.string(), | ||
| output_index: z.number(), | ||
| delta: z.string(), | ||
| }), | ||
| z.object({ | ||
| type: z.literal('response.function_call_arguments.done'), | ||
| item_id: z.string(), | ||
| output_index: z.number(), | ||
| arguments: z.string(), | ||
| }), | ||
| z.object({ | ||
| type: z.literal('response.mcp_call.in_progress'), | ||
@@ -466,0 +479,0 @@ item_id: z.string(), |
@@ -453,2 +453,9 @@ import { | ||
| // Track ongoing function calls by output_index so we can stream | ||
| // arguments via response.function_call_arguments.delta events. | ||
| const ongoingToolCalls: Record< | ||
| number, | ||
| { toolName: string; toolCallId: string } | undefined | ||
| > = {}; | ||
| const activeReasoning: Record< | ||
@@ -651,2 +658,20 @@ string, | ||
| // Function call arguments streaming (standard function tools) | ||
| if (event.type === 'response.function_call_arguments.delta') { | ||
| const toolCall = ongoingToolCalls[event.output_index]; | ||
| if (toolCall != null) { | ||
| controller.enqueue({ | ||
| type: 'tool-input-delta', | ||
| id: toolCall.toolCallId, | ||
| delta: event.delta, | ||
| }); | ||
| } | ||
| return; | ||
| } | ||
| if (event.type === 'response.function_call_arguments.done') { | ||
| // Arguments are fully received; output_item.done will | ||
| // emit tool-input-end and tool-call with the final arguments. | ||
| return; | ||
| } | ||
| if ( | ||
@@ -872,4 +897,9 @@ event.type === 'response.output_item.added' || | ||
| } else if (part.type === 'function_call') { | ||
| if (!seenToolCalls.has(part.call_id)) { | ||
| seenToolCalls.add(part.call_id); | ||
| if (event.type === 'response.output_item.added') { | ||
| // Track the call so function_call_arguments.delta events | ||
| // can stream the arguments incrementally. | ||
| ongoingToolCalls[event.output_index] = { | ||
| toolName: part.name, | ||
| toolCallId: part.call_id, | ||
| }; | ||
@@ -881,10 +911,6 @@ controller.enqueue({ | ||
| }); | ||
| } else if (event.type === 'response.output_item.done') { | ||
| ongoingToolCalls[event.output_index] = undefined; | ||
| controller.enqueue({ | ||
| type: 'tool-input-delta', | ||
| id: part.call_id, | ||
| delta: part.arguments, | ||
| }); | ||
| controller.enqueue({ | ||
| type: 'tool-input-end', | ||
@@ -891,0 +917,0 @@ id: part.call_id, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
731273
1.2%9339
1.02%