ai 5.0.0-alpha.10 → 5.0.0-alpha.12

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.
@@ -368,7 +368,7 @@ type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'requ
368
368
  };
369
369
 
370
370
  type ToolParameters<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
371
- interface ToolExecutionOptions {
371
+ interface ToolCallOptions {
372
372
  /**
373
373
  * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
374
374
  */
@@ -412,11 +412,30 @@ If not provided, the tool will not be executed automatically.
412
412
  @args is the input of the tool call.
413
413
  @options.abortSignal is a signal that can be used to abort the tool call.
414
414
  */
415
- execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolExecutionOptions) => PromiseLike<RESULT>;
415
+ execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolCallOptions) => PromiseLike<RESULT>;
416
416
  /**
417
417
  Optional conversion function that maps the tool result to multi-part tool content for LLMs.
418
418
  */
419
419
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
420
+ /**
421
+ * Optional function that is called when the argument streaming starts.
422
+ * Only called when the tool is used in a streaming context.
423
+ */
424
+ onArgsStreamingStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
425
+ /**
426
+ * Optional function that is called when an argument streaming delta is available.
427
+ * Only called when the tool is used in a streaming context.
428
+ */
429
+ onArgsStreamingDelta?: (options: {
430
+ argsTextDelta: string;
431
+ } & ToolCallOptions) => void | PromiseLike<void>;
432
+ /**
433
+ * Optional function that is called when a tool call can be started,
434
+ * even if the execute function is not provided.
435
+ */
436
+ onArgsAvailable?: (options: {
437
+ args: [PARAMETERS] extends [never] ? undefined : PARAMETERS;
438
+ } & ToolCallOptions) => void | PromiseLike<void>;
420
439
  }> & ({
421
440
  /**
422
441
  Function tool.
@@ -437,7 +456,7 @@ The arguments for configuring the tool. Must match the expected arguments define
437
456
  args: Record<string, unknown>;
438
457
  });
439
458
 
440
- type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute'>>;
459
+ type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onArgsAvailable' | 'onArgsStreamingStart' | 'onArgsStreamingDelta'>>;
441
460
 
442
461
  declare function prepareToolsAndToolChoice<TOOLS extends ToolSet>({ tools, toolChoice, activeTools, }: {
443
462
  tools: TOOLS | undefined;
@@ -368,7 +368,7 @@ type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'requ
368
368
  };
369
369
 
370
370
  type ToolParameters<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
371
- interface ToolExecutionOptions {
371
+ interface ToolCallOptions {
372
372
  /**
373
373
  * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
374
374
  */
@@ -412,11 +412,30 @@ If not provided, the tool will not be executed automatically.
412
412
  @args is the input of the tool call.
413
413
  @options.abortSignal is a signal that can be used to abort the tool call.
414
414
  */
415
- execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolExecutionOptions) => PromiseLike<RESULT>;
415
+ execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolCallOptions) => PromiseLike<RESULT>;
416
416
  /**
417
417
  Optional conversion function that maps the tool result to multi-part tool content for LLMs.
418
418
  */
419
419
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
420
+ /**
421
+ * Optional function that is called when the argument streaming starts.
422
+ * Only called when the tool is used in a streaming context.
423
+ */
424
+ onArgsStreamingStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
425
+ /**
426
+ * Optional function that is called when an argument streaming delta is available.
427
+ * Only called when the tool is used in a streaming context.
428
+ */
429
+ onArgsStreamingDelta?: (options: {
430
+ argsTextDelta: string;
431
+ } & ToolCallOptions) => void | PromiseLike<void>;
432
+ /**
433
+ * Optional function that is called when a tool call can be started,
434
+ * even if the execute function is not provided.
435
+ */
436
+ onArgsAvailable?: (options: {
437
+ args: [PARAMETERS] extends [never] ? undefined : PARAMETERS;
438
+ } & ToolCallOptions) => void | PromiseLike<void>;
420
439
  }> & ({
421
440
  /**
422
441
  Function tool.
@@ -437,7 +456,7 @@ The arguments for configuring the tool. Must match the expected arguments define
437
456
  args: Record<string, unknown>;
438
457
  });
439
458
 
440
- type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute'>>;
459
+ type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onArgsAvailable' | 'onArgsStreamingStart' | 'onArgsStreamingDelta'>>;
441
460
 
442
461
  declare function prepareToolsAndToolChoice<TOOLS extends ToolSet>({ tools, toolChoice, activeTools, }: {
443
462
  tools: TOOLS | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "5.0.0-alpha.10",
3
+ "version": "5.0.0-alpha.12",
4
4
  "description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -42,9 +42,9 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@opentelemetry/api": "1.9.0",
45
- "@ai-sdk/gateway": "1.0.0-alpha.10",
46
- "@ai-sdk/provider": "2.0.0-alpha.10",
47
- "@ai-sdk/provider-utils": "3.0.0-alpha.10"
45
+ "@ai-sdk/gateway": "1.0.0-alpha.12",
46
+ "@ai-sdk/provider": "2.0.0-alpha.12",
47
+ "@ai-sdk/provider-utils": "3.0.0-alpha.12"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/json-schema": "7.0.15",