ai 6.0.0-beta.49 → 6.0.0-beta.51

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.0-beta.51
4
+
5
+ ### Patch Changes
6
+
7
+ - 5e313e3: fix(agent): do not allow static tools when tools is empty
8
+
9
+ ## 6.0.0-beta.50
10
+
11
+ ### Patch Changes
12
+
13
+ - 4812235: fix(ai): add missing export for `LoadSettingError`
14
+ - 81d4308: feat: provider-executed dynamic tools
15
+ - Updated dependencies [81d4308]
16
+ - @ai-sdk/provider@3.0.0-beta.7
17
+ - @ai-sdk/gateway@2.0.0-beta.32
18
+ - @ai-sdk/provider-utils@4.0.0-beta.18
19
+
3
20
  ## 6.0.0-beta.49
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModel
4
4
  export { AssistantContent, AssistantModelMessage, DataContent, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
5
5
  import * as _ai_sdk_provider from '@ai-sdk/provider';
6
6
  import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV2, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
7
- export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
7
+ export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
8
8
  import { ServerResponse } from 'node:http';
9
9
  import { AttributeValue, Tracer } from '@opentelemetry/api';
10
10
  import { ServerResponse as ServerResponse$1 } from 'http';
@@ -1580,18 +1580,23 @@ type asUITool<TOOL extends UITool | Tool> = TOOL extends Tool ? InferUITool<TOOL
1580
1580
  * UI components for the tool.
1581
1581
  */
1582
1582
  type UIToolInvocation<TOOL extends UITool | Tool> = {
1583
+ /**
1584
+ * ID of the tool call.
1585
+ */
1583
1586
  toolCallId: string;
1587
+ /**
1588
+ * Whether the tool call was executed by the provider.
1589
+ */
1590
+ providerExecuted?: boolean;
1584
1591
  } & ({
1585
1592
  state: 'input-streaming';
1586
1593
  input: DeepPartial<asUITool<TOOL>['input']> | undefined;
1587
- providerExecuted?: boolean;
1588
1594
  output?: never;
1589
1595
  errorText?: never;
1590
1596
  approval?: never;
1591
1597
  } | {
1592
1598
  state: 'input-available';
1593
1599
  input: asUITool<TOOL>['input'];
1594
- providerExecuted?: boolean;
1595
1600
  output?: never;
1596
1601
  errorText?: never;
1597
1602
  callProviderMetadata?: ProviderMetadata;
@@ -1599,7 +1604,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1599
1604
  } | {
1600
1605
  state: 'approval-requested';
1601
1606
  input: asUITool<TOOL>['input'];
1602
- providerExecuted?: boolean;
1603
1607
  output?: never;
1604
1608
  errorText?: never;
1605
1609
  callProviderMetadata?: ProviderMetadata;
@@ -1611,7 +1615,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1611
1615
  } | {
1612
1616
  state: 'approval-responded';
1613
1617
  input: asUITool<TOOL>['input'];
1614
- providerExecuted?: boolean;
1615
1618
  output?: never;
1616
1619
  errorText?: never;
1617
1620
  callProviderMetadata?: ProviderMetadata;
@@ -1625,7 +1628,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1625
1628
  input: asUITool<TOOL>['input'];
1626
1629
  output: asUITool<TOOL>['output'];
1627
1630
  errorText?: never;
1628
- providerExecuted?: boolean;
1629
1631
  callProviderMetadata?: ProviderMetadata;
1630
1632
  preliminary?: boolean;
1631
1633
  approval?: {
@@ -1639,7 +1641,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1639
1641
  rawInput?: unknown;
1640
1642
  output?: never;
1641
1643
  errorText: string;
1642
- providerExecuted?: boolean;
1643
1644
  callProviderMetadata?: ProviderMetadata;
1644
1645
  approval?: {
1645
1646
  id: string;
@@ -1649,7 +1650,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1649
1650
  } | {
1650
1651
  state: 'output-denied';
1651
1652
  input: asUITool<TOOL>['input'];
1652
- providerExecuted?: boolean;
1653
1653
  output?: never;
1654
1654
  errorText?: never;
1655
1655
  callProviderMetadata?: ProviderMetadata;
@@ -1666,8 +1666,18 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1666
1666
  }>;
1667
1667
  type DynamicToolUIPart = {
1668
1668
  type: 'dynamic-tool';
1669
+ /**
1670
+ * Name of the tool that is being called.
1671
+ */
1669
1672
  toolName: string;
1673
+ /**
1674
+ * ID of the tool call.
1675
+ */
1670
1676
  toolCallId: string;
1677
+ /**
1678
+ * Whether the tool call was executed by the provider.
1679
+ */
1680
+ providerExecuted?: boolean;
1671
1681
  } & ({
1672
1682
  state: 'input-streaming';
1673
1683
  input: unknown | undefined;
@@ -2364,7 +2374,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2364
2374
  * An agent is a reusable component that that has tools and that
2365
2375
  * can generate or stream content.
2366
2376
  */
2367
- interface Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> {
2377
+ interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> {
2368
2378
  /**
2369
2379
  * The id of the agent.
2370
2380
  */
@@ -2394,7 +2404,7 @@ Callback that is set using the `onFinish` option.
2394
2404
 
2395
2405
  @param event - The event that is passed to the callback.
2396
2406
  */
2397
- type BasicAgentOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
2407
+ type BasicAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
2398
2408
  /**
2399
2409
  Details for all steps.
2400
2410
  */
@@ -2410,12 +2420,12 @@ Callback that is set using the `onStepFinish` option.
2410
2420
 
2411
2421
  @param stepResult - The result of the step.
2412
2422
  */
2413
- type BasicAgentOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
2423
+ type BasicAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
2414
2424
 
2415
2425
  /**
2416
2426
  * Configuration options for an agent.
2417
2427
  */
2418
- type BasicAgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
2428
+ type BasicAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
2419
2429
  /**
2420
2430
  * The id of the agent.
2421
2431
  */
@@ -2501,7 +2511,7 @@ type BasicAgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL =
2501
2511
  *
2502
2512
  * Define agents once and use them across your application.
2503
2513
  */
2504
- declare class BasicAgent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
2514
+ declare class BasicAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
2505
2515
  private readonly settings;
2506
2516
  constructor(settings: BasicAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
2507
2517
  /**
@@ -2760,6 +2770,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
2760
2770
  id: string;
2761
2771
  toolName: string;
2762
2772
  providerMetadata?: ProviderMetadata;
2773
+ dynamic?: boolean;
2763
2774
  } | {
2764
2775
  type: 'tool-input-delta';
2765
2776
  id: string;
@@ -4601,12 +4612,14 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
4601
4612
  declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
4602
4613
 
4603
4614
  /**
4604
- Converts an array of messages from useChat into an array of CoreMessages that can be used
4605
- with the AI core functions (e.g. `streamText`).
4615
+ Converts an array of UI messages from useChat into an array of ModelMessages that can be used
4616
+ with the AI functions (e.g. `streamText`, `generateText`).
4606
4617
 
4607
- @param messages - The messages to convert.
4618
+ @param messages - The UI messages to convert.
4608
4619
  @param options.tools - The tools to use.
4609
4620
  @param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
4621
+
4622
+ @returns An array of ModelMessages.
4610
4623
  */
4611
4624
  declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
4612
4625
  tools?: ToolSet;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModel
4
4
  export { AssistantContent, AssistantModelMessage, DataContent, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
5
5
  import * as _ai_sdk_provider from '@ai-sdk/provider';
6
6
  import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV2, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
7
- export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
7
+ export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
8
8
  import { ServerResponse } from 'node:http';
9
9
  import { AttributeValue, Tracer } from '@opentelemetry/api';
10
10
  import { ServerResponse as ServerResponse$1 } from 'http';
@@ -1580,18 +1580,23 @@ type asUITool<TOOL extends UITool | Tool> = TOOL extends Tool ? InferUITool<TOOL
1580
1580
  * UI components for the tool.
1581
1581
  */
1582
1582
  type UIToolInvocation<TOOL extends UITool | Tool> = {
1583
+ /**
1584
+ * ID of the tool call.
1585
+ */
1583
1586
  toolCallId: string;
1587
+ /**
1588
+ * Whether the tool call was executed by the provider.
1589
+ */
1590
+ providerExecuted?: boolean;
1584
1591
  } & ({
1585
1592
  state: 'input-streaming';
1586
1593
  input: DeepPartial<asUITool<TOOL>['input']> | undefined;
1587
- providerExecuted?: boolean;
1588
1594
  output?: never;
1589
1595
  errorText?: never;
1590
1596
  approval?: never;
1591
1597
  } | {
1592
1598
  state: 'input-available';
1593
1599
  input: asUITool<TOOL>['input'];
1594
- providerExecuted?: boolean;
1595
1600
  output?: never;
1596
1601
  errorText?: never;
1597
1602
  callProviderMetadata?: ProviderMetadata;
@@ -1599,7 +1604,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1599
1604
  } | {
1600
1605
  state: 'approval-requested';
1601
1606
  input: asUITool<TOOL>['input'];
1602
- providerExecuted?: boolean;
1603
1607
  output?: never;
1604
1608
  errorText?: never;
1605
1609
  callProviderMetadata?: ProviderMetadata;
@@ -1611,7 +1615,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1611
1615
  } | {
1612
1616
  state: 'approval-responded';
1613
1617
  input: asUITool<TOOL>['input'];
1614
- providerExecuted?: boolean;
1615
1618
  output?: never;
1616
1619
  errorText?: never;
1617
1620
  callProviderMetadata?: ProviderMetadata;
@@ -1625,7 +1628,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1625
1628
  input: asUITool<TOOL>['input'];
1626
1629
  output: asUITool<TOOL>['output'];
1627
1630
  errorText?: never;
1628
- providerExecuted?: boolean;
1629
1631
  callProviderMetadata?: ProviderMetadata;
1630
1632
  preliminary?: boolean;
1631
1633
  approval?: {
@@ -1639,7 +1641,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1639
1641
  rawInput?: unknown;
1640
1642
  output?: never;
1641
1643
  errorText: string;
1642
- providerExecuted?: boolean;
1643
1644
  callProviderMetadata?: ProviderMetadata;
1644
1645
  approval?: {
1645
1646
  id: string;
@@ -1649,7 +1650,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1649
1650
  } | {
1650
1651
  state: 'output-denied';
1651
1652
  input: asUITool<TOOL>['input'];
1652
- providerExecuted?: boolean;
1653
1653
  output?: never;
1654
1654
  errorText?: never;
1655
1655
  callProviderMetadata?: ProviderMetadata;
@@ -1666,8 +1666,18 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1666
1666
  }>;
1667
1667
  type DynamicToolUIPart = {
1668
1668
  type: 'dynamic-tool';
1669
+ /**
1670
+ * Name of the tool that is being called.
1671
+ */
1669
1672
  toolName: string;
1673
+ /**
1674
+ * ID of the tool call.
1675
+ */
1670
1676
  toolCallId: string;
1677
+ /**
1678
+ * Whether the tool call was executed by the provider.
1679
+ */
1680
+ providerExecuted?: boolean;
1671
1681
  } & ({
1672
1682
  state: 'input-streaming';
1673
1683
  input: unknown | undefined;
@@ -2364,7 +2374,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2364
2374
  * An agent is a reusable component that that has tools and that
2365
2375
  * can generate or stream content.
2366
2376
  */
2367
- interface Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> {
2377
+ interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> {
2368
2378
  /**
2369
2379
  * The id of the agent.
2370
2380
  */
@@ -2394,7 +2404,7 @@ Callback that is set using the `onFinish` option.
2394
2404
 
2395
2405
  @param event - The event that is passed to the callback.
2396
2406
  */
2397
- type BasicAgentOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
2407
+ type BasicAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
2398
2408
  /**
2399
2409
  Details for all steps.
2400
2410
  */
@@ -2410,12 +2420,12 @@ Callback that is set using the `onStepFinish` option.
2410
2420
 
2411
2421
  @param stepResult - The result of the step.
2412
2422
  */
2413
- type BasicAgentOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
2423
+ type BasicAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
2414
2424
 
2415
2425
  /**
2416
2426
  * Configuration options for an agent.
2417
2427
  */
2418
- type BasicAgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
2428
+ type BasicAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
2419
2429
  /**
2420
2430
  * The id of the agent.
2421
2431
  */
@@ -2501,7 +2511,7 @@ type BasicAgentSettings<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL =
2501
2511
  *
2502
2512
  * Define agents once and use them across your application.
2503
2513
  */
2504
- declare class BasicAgent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
2514
+ declare class BasicAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
2505
2515
  private readonly settings;
2506
2516
  constructor(settings: BasicAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
2507
2517
  /**
@@ -2760,6 +2770,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
2760
2770
  id: string;
2761
2771
  toolName: string;
2762
2772
  providerMetadata?: ProviderMetadata;
2773
+ dynamic?: boolean;
2763
2774
  } | {
2764
2775
  type: 'tool-input-delta';
2765
2776
  id: string;
@@ -4601,12 +4612,14 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
4601
4612
  declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
4602
4613
 
4603
4614
  /**
4604
- Converts an array of messages from useChat into an array of CoreMessages that can be used
4605
- with the AI core functions (e.g. `streamText`).
4615
+ Converts an array of UI messages from useChat into an array of ModelMessages that can be used
4616
+ with the AI functions (e.g. `streamText`, `generateText`).
4606
4617
 
4607
- @param messages - The messages to convert.
4618
+ @param messages - The UI messages to convert.
4608
4619
  @param options.tools - The tools to use.
4609
4620
  @param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
4621
+
4622
+ @returns An array of ModelMessages.
4610
4623
  */
4611
4624
  declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
4612
4625
  tools?: ToolSet;