ai 6.0.0-beta.62 → 6.0.0-beta.64

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,17 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.0-beta.64
4
+
5
+ ### Patch Changes
6
+
7
+ - 2d28066: chore(agent): limit agent call parameters
8
+
9
+ ## 6.0.0-beta.63
10
+
11
+ ### Patch Changes
12
+
13
+ - a7da2b6: feat(agent): change output generics
14
+
3
15
  ## 6.0.0-beta.62
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createGateway, gateway } from '@ai-sdk/gateway';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
- import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, ModelMessage, FlexibleSchema, InferSchema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
3
+ import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, FlexibleSchema, InferSchema, ModelMessage, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
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';
@@ -637,6 +637,61 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
637
637
  readonly experimental_output: OUTPUT;
638
638
  }
639
639
 
640
+ /**
641
+ Create a type from an object with all keys and nested keys set to optional.
642
+ The helper supports normal objects and schemas (which are resolved automatically).
643
+ It always recurses into arrays.
644
+
645
+ Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
646
+ */
647
+ type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
648
+ type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
649
+ type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
650
+ type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
651
+ type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
652
+ type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
653
+ type PartialObject<ObjectType extends object> = {
654
+ [KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
655
+ };
656
+
657
+ interface Output<OUTPUT = any, PARTIAL = any> {
658
+ readonly type: 'object' | 'text';
659
+ responseFormat: PromiseLike<LanguageModelV3CallOptions['responseFormat']>;
660
+ parsePartial(options: {
661
+ text: string;
662
+ }): Promise<{
663
+ partial: PARTIAL;
664
+ } | undefined>;
665
+ parseOutput(options: {
666
+ text: string;
667
+ }, context: {
668
+ response: LanguageModelResponseMetadata;
669
+ usage: LanguageModelUsage;
670
+ finishReason: FinishReason;
671
+ }): Promise<OUTPUT>;
672
+ }
673
+ declare const text: () => Output<string, string>;
674
+ declare const object: <OUTPUT>({ schema: inputSchema, }: {
675
+ schema: FlexibleSchema<OUTPUT>;
676
+ }) => Output<OUTPUT, DeepPartial<OUTPUT>>;
677
+ type InferGenerateOutput<OUTPUT extends Output> = OUTPUT extends Output<infer T, any> ? T : never;
678
+ type InferStreamOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer P> ? P : never;
679
+
680
+ type output_InferGenerateOutput<OUTPUT extends Output> = InferGenerateOutput<OUTPUT>;
681
+ type output_InferStreamOutput<OUTPUT extends Output> = InferStreamOutput<OUTPUT>;
682
+ type output_Output<OUTPUT = any, PARTIAL = any> = Output<OUTPUT, PARTIAL>;
683
+ declare const output_object: typeof object;
684
+ declare const output_text: typeof text;
685
+ declare namespace output {
686
+ export {
687
+ output_InferGenerateOutput as InferGenerateOutput,
688
+ output_InferStreamOutput as InferStreamOutput,
689
+ output_Output as Output,
690
+ output_object as object,
691
+ output_text as text,
692
+ };
693
+ }
694
+
640
695
  type CallSettings = {
641
696
  /**
642
697
  Maximum number of tokens to generate.
@@ -806,55 +861,6 @@ type DownloadFunction = (options: Array<{
806
861
  mediaType: string | undefined;
807
862
  } | null>>;
808
863
 
809
- /**
810
- Create a type from an object with all keys and nested keys set to optional.
811
- The helper supports normal objects and schemas (which are resolved automatically).
812
- It always recurses into arrays.
813
-
814
- Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
815
- */
816
- type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
817
- type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
818
- type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
819
- type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
820
- type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
821
- type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
822
- type PartialObject<ObjectType extends object> = {
823
- [KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
824
- };
825
-
826
- interface Output<OUTPUT, PARTIAL> {
827
- readonly type: 'object' | 'text';
828
- responseFormat: PromiseLike<LanguageModelV3CallOptions['responseFormat']>;
829
- parsePartial(options: {
830
- text: string;
831
- }): Promise<{
832
- partial: PARTIAL;
833
- } | undefined>;
834
- parseOutput(options: {
835
- text: string;
836
- }, context: {
837
- response: LanguageModelResponseMetadata;
838
- usage: LanguageModelUsage;
839
- finishReason: FinishReason;
840
- }): Promise<OUTPUT>;
841
- }
842
- declare const text: () => Output<string, string>;
843
- declare const object: <OUTPUT>({ schema: inputSchema, }: {
844
- schema: FlexibleSchema<OUTPUT>;
845
- }) => Output<OUTPUT, DeepPartial<OUTPUT>>;
846
-
847
- type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
848
- declare const output_object: typeof object;
849
- declare const output_text: typeof text;
850
- declare namespace output {
851
- export {
852
- output_Output as Output,
853
- output_object as object,
854
- output_text as text,
855
- };
856
- }
857
-
858
864
  /**
859
865
  Function that you can use to provide different settings for a step.
860
866
 
@@ -2374,6 +2380,33 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2374
2380
  rawValue: unknown;
2375
2381
  };
2376
2382
 
2383
+ type AgentCallParameters = {
2384
+ /**
2385
+ * A prompt. It can be either a text prompt or a list of messages.
2386
+ *
2387
+ * You can either use `prompt` or `messages` but not both.
2388
+ */
2389
+ prompt: string | Array<ModelMessage>;
2390
+ /**
2391
+ * A list of messages.
2392
+ *
2393
+ * You can either use `prompt` or `messages` but not both.
2394
+ */
2395
+ messages?: never;
2396
+ } | {
2397
+ /**
2398
+ * A list of messages.
2399
+ *
2400
+ * You can either use `prompt` or `messages` but not both.
2401
+ */
2402
+ messages: Array<ModelMessage>;
2403
+ /**
2404
+ * A prompt. It can be either a text prompt or a list of messages.
2405
+ *
2406
+ * You can either use `prompt` or `messages` but not both.
2407
+ */
2408
+ prompt?: never;
2409
+ };
2377
2410
  /**
2378
2411
  * An Agent receives a prompt (text or messages) and generates or streams an output
2379
2412
  * that consists of steps, tool calls, data parts, etc.
@@ -2381,7 +2414,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2381
2414
  * You can implement your own Agent by implementing the `Agent` interface,
2382
2415
  * or use the `ToolLoopAgent` class.
2383
2416
  */
2384
- interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> {
2417
+ interface Agent<TOOLS extends ToolSet = {}, OUTPUT extends Output = never> {
2385
2418
  /**
2386
2419
  * The specification version of the agent interface. This will enable
2387
2420
  * us to evolve the agent interface and retain backwards compatibility.
@@ -2398,11 +2431,11 @@ interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = nev
2398
2431
  /**
2399
2432
  * Generates an output from the agent (non-streaming).
2400
2433
  */
2401
- generate(options: Prompt): PromiseLike<GenerateTextResult<TOOLS, OUTPUT>>;
2434
+ generate(options: AgentCallParameters): PromiseLike<GenerateTextResult<TOOLS, InferGenerateOutput<OUTPUT>>>;
2402
2435
  /**
2403
2436
  * Streams an output from the agent (streaming).
2404
2437
  */
2405
- stream(options: Prompt): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
2438
+ stream(options: AgentCallParameters): StreamTextResult<TOOLS, InferStreamOutput<OUTPUT>>;
2406
2439
  }
2407
2440
 
2408
2441
  /**
@@ -2431,7 +2464,7 @@ type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult
2431
2464
  /**
2432
2465
  * Configuration options for an agent.
2433
2466
  */
2434
- type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
2467
+ type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT extends Output = never> = CallSettings & {
2435
2468
  /**
2436
2469
  * The id of the agent.
2437
2470
  */
@@ -2471,7 +2504,7 @@ type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PA
2471
2504
  /**
2472
2505
  Optional specification for parsing structured outputs from the LLM response.
2473
2506
  */
2474
- experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
2507
+ experimental_output?: OUTPUT;
2475
2508
  /**
2476
2509
  * @deprecated Use `prepareStep` instead.
2477
2510
  */
@@ -2519,10 +2552,10 @@ type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PA
2519
2552
  * - A tool call needs approval, or
2520
2553
  * - A stop condition is met (default stop condition is stepCountIs(20))
2521
2554
  */
2522
- declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
2555
+ declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT extends Output = never> implements Agent<TOOLS, OUTPUT> {
2523
2556
  readonly version = "agent-v1";
2524
2557
  private readonly settings;
2525
- constructor(settings: ToolLoopAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
2558
+ constructor(settings: ToolLoopAgentSettings<TOOLS, OUTPUT>);
2526
2559
  /**
2527
2560
  * The id of the agent.
2528
2561
  */
@@ -2534,17 +2567,17 @@ declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_P
2534
2567
  /**
2535
2568
  * Generates an output from the agent (non-streaming).
2536
2569
  */
2537
- generate(options: Prompt): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2570
+ generate(options: AgentCallParameters): Promise<GenerateTextResult<TOOLS, InferGenerateOutput<OUTPUT>>>;
2538
2571
  /**
2539
2572
  * Streams an output from the agent (streaming).
2540
2573
  */
2541
- stream(options: Prompt): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
2574
+ stream(options: AgentCallParameters): StreamTextResult<TOOLS, InferStreamOutput<OUTPUT>>;
2542
2575
  }
2543
2576
 
2544
2577
  /**
2545
2578
  * Infer the type of the tools of an agent.
2546
2579
  */
2547
- type InferAgentTools<AGENT> = AGENT extends Agent<infer TOOLS, any, any> ? TOOLS : never;
2580
+ type InferAgentTools<AGENT> = AGENT extends Agent<infer TOOLS, never> ? TOOLS : never;
2548
2581
 
2549
2582
  /**
2550
2583
  * Infer the UI message type of an agent.
@@ -2559,8 +2592,8 @@ type InferAgentUIMessage<AGENT> = UIMessage<never, never, InferUITools<InferAgen
2559
2592
  *
2560
2593
  * @returns The response object.
2561
2594
  */
2562
- declare function createAgentUIStreamResponse<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never>({ headers, status, statusText, consumeSseStream, ...options }: {
2563
- agent: Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL>;
2595
+ declare function createAgentUIStreamResponse<TOOLS extends ToolSet = {}, OUTPUT extends Output = never>({ headers, status, statusText, consumeSseStream, ...options }: {
2596
+ agent: Agent<TOOLS, OUTPUT>;
2564
2597
  messages: unknown[];
2565
2598
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<never, never, InferUITools<TOOLS>>>): Promise<Response>;
2566
2599
 
@@ -3212,8 +3245,8 @@ declare const UI_MESSAGE_STREAM_HEADERS: {
3212
3245
  *
3213
3246
  * @returns The UI message stream.
3214
3247
  */
3215
- declare function createAgentUIStream<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never>({ agent, messages, ...uiMessageStreamOptions }: {
3216
- agent: Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL>;
3248
+ declare function createAgentUIStream<TOOLS extends ToolSet = {}, OUTPUT extends Output = never>({ agent, messages, ...uiMessageStreamOptions }: {
3249
+ agent: Agent<TOOLS, OUTPUT>;
3217
3250
  messages: unknown[];
3218
3251
  } & UIMessageStreamOptions<UIMessage<never, never, InferUITools<TOOLS>>>): Promise<AsyncIterableStream<InferUIMessageChunk<UIMessage<never, never, InferUITools<TOOLS>>>>>;
3219
3252
 
@@ -3223,9 +3256,9 @@ declare function createAgentUIStream<TOOLS extends ToolSet = {}, OUTPUT = never,
3223
3256
  * @param agent - The agent to run.
3224
3257
  * @param messages - The input UI messages.
3225
3258
  */
3226
- declare function pipeAgentUIStreamToResponse<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never>({ response, headers, status, statusText, consumeSseStream, ...options }: {
3259
+ declare function pipeAgentUIStreamToResponse<TOOLS extends ToolSet = {}, OUTPUT extends Output = never>({ response, headers, status, statusText, consumeSseStream, ...options }: {
3227
3260
  response: ServerResponse;
3228
- agent: Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL>;
3261
+ agent: Agent<TOOLS, OUTPUT>;
3229
3262
  messages: unknown[];
3230
3263
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<never, never, InferUITools<TOOLS>>>): Promise<void>;
3231
3264
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createGateway, gateway } from '@ai-sdk/gateway';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
- import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, ModelMessage, FlexibleSchema, InferSchema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
3
+ import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, FlexibleSchema, InferSchema, ModelMessage, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
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';
@@ -637,6 +637,61 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
637
637
  readonly experimental_output: OUTPUT;
638
638
  }
639
639
 
640
+ /**
641
+ Create a type from an object with all keys and nested keys set to optional.
642
+ The helper supports normal objects and schemas (which are resolved automatically).
643
+ It always recurses into arrays.
644
+
645
+ Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
646
+ */
647
+ type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
648
+ type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
649
+ type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
650
+ type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
651
+ type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
652
+ type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
653
+ type PartialObject<ObjectType extends object> = {
654
+ [KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
655
+ };
656
+
657
+ interface Output<OUTPUT = any, PARTIAL = any> {
658
+ readonly type: 'object' | 'text';
659
+ responseFormat: PromiseLike<LanguageModelV3CallOptions['responseFormat']>;
660
+ parsePartial(options: {
661
+ text: string;
662
+ }): Promise<{
663
+ partial: PARTIAL;
664
+ } | undefined>;
665
+ parseOutput(options: {
666
+ text: string;
667
+ }, context: {
668
+ response: LanguageModelResponseMetadata;
669
+ usage: LanguageModelUsage;
670
+ finishReason: FinishReason;
671
+ }): Promise<OUTPUT>;
672
+ }
673
+ declare const text: () => Output<string, string>;
674
+ declare const object: <OUTPUT>({ schema: inputSchema, }: {
675
+ schema: FlexibleSchema<OUTPUT>;
676
+ }) => Output<OUTPUT, DeepPartial<OUTPUT>>;
677
+ type InferGenerateOutput<OUTPUT extends Output> = OUTPUT extends Output<infer T, any> ? T : never;
678
+ type InferStreamOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer P> ? P : never;
679
+
680
+ type output_InferGenerateOutput<OUTPUT extends Output> = InferGenerateOutput<OUTPUT>;
681
+ type output_InferStreamOutput<OUTPUT extends Output> = InferStreamOutput<OUTPUT>;
682
+ type output_Output<OUTPUT = any, PARTIAL = any> = Output<OUTPUT, PARTIAL>;
683
+ declare const output_object: typeof object;
684
+ declare const output_text: typeof text;
685
+ declare namespace output {
686
+ export {
687
+ output_InferGenerateOutput as InferGenerateOutput,
688
+ output_InferStreamOutput as InferStreamOutput,
689
+ output_Output as Output,
690
+ output_object as object,
691
+ output_text as text,
692
+ };
693
+ }
694
+
640
695
  type CallSettings = {
641
696
  /**
642
697
  Maximum number of tokens to generate.
@@ -806,55 +861,6 @@ type DownloadFunction = (options: Array<{
806
861
  mediaType: string | undefined;
807
862
  } | null>>;
808
863
 
809
- /**
810
- Create a type from an object with all keys and nested keys set to optional.
811
- The helper supports normal objects and schemas (which are resolved automatically).
812
- It always recurses into arrays.
813
-
814
- Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
815
- */
816
- type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
817
- type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
818
- type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
819
- type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
820
- type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
821
- type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
822
- type PartialObject<ObjectType extends object> = {
823
- [KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
824
- };
825
-
826
- interface Output<OUTPUT, PARTIAL> {
827
- readonly type: 'object' | 'text';
828
- responseFormat: PromiseLike<LanguageModelV3CallOptions['responseFormat']>;
829
- parsePartial(options: {
830
- text: string;
831
- }): Promise<{
832
- partial: PARTIAL;
833
- } | undefined>;
834
- parseOutput(options: {
835
- text: string;
836
- }, context: {
837
- response: LanguageModelResponseMetadata;
838
- usage: LanguageModelUsage;
839
- finishReason: FinishReason;
840
- }): Promise<OUTPUT>;
841
- }
842
- declare const text: () => Output<string, string>;
843
- declare const object: <OUTPUT>({ schema: inputSchema, }: {
844
- schema: FlexibleSchema<OUTPUT>;
845
- }) => Output<OUTPUT, DeepPartial<OUTPUT>>;
846
-
847
- type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
848
- declare const output_object: typeof object;
849
- declare const output_text: typeof text;
850
- declare namespace output {
851
- export {
852
- output_Output as Output,
853
- output_object as object,
854
- output_text as text,
855
- };
856
- }
857
-
858
864
  /**
859
865
  Function that you can use to provide different settings for a step.
860
866
 
@@ -2374,6 +2380,33 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2374
2380
  rawValue: unknown;
2375
2381
  };
2376
2382
 
2383
+ type AgentCallParameters = {
2384
+ /**
2385
+ * A prompt. It can be either a text prompt or a list of messages.
2386
+ *
2387
+ * You can either use `prompt` or `messages` but not both.
2388
+ */
2389
+ prompt: string | Array<ModelMessage>;
2390
+ /**
2391
+ * A list of messages.
2392
+ *
2393
+ * You can either use `prompt` or `messages` but not both.
2394
+ */
2395
+ messages?: never;
2396
+ } | {
2397
+ /**
2398
+ * A list of messages.
2399
+ *
2400
+ * You can either use `prompt` or `messages` but not both.
2401
+ */
2402
+ messages: Array<ModelMessage>;
2403
+ /**
2404
+ * A prompt. It can be either a text prompt or a list of messages.
2405
+ *
2406
+ * You can either use `prompt` or `messages` but not both.
2407
+ */
2408
+ prompt?: never;
2409
+ };
2377
2410
  /**
2378
2411
  * An Agent receives a prompt (text or messages) and generates or streams an output
2379
2412
  * that consists of steps, tool calls, data parts, etc.
@@ -2381,7 +2414,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2381
2414
  * You can implement your own Agent by implementing the `Agent` interface,
2382
2415
  * or use the `ToolLoopAgent` class.
2383
2416
  */
2384
- interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> {
2417
+ interface Agent<TOOLS extends ToolSet = {}, OUTPUT extends Output = never> {
2385
2418
  /**
2386
2419
  * The specification version of the agent interface. This will enable
2387
2420
  * us to evolve the agent interface and retain backwards compatibility.
@@ -2398,11 +2431,11 @@ interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = nev
2398
2431
  /**
2399
2432
  * Generates an output from the agent (non-streaming).
2400
2433
  */
2401
- generate(options: Prompt): PromiseLike<GenerateTextResult<TOOLS, OUTPUT>>;
2434
+ generate(options: AgentCallParameters): PromiseLike<GenerateTextResult<TOOLS, InferGenerateOutput<OUTPUT>>>;
2402
2435
  /**
2403
2436
  * Streams an output from the agent (streaming).
2404
2437
  */
2405
- stream(options: Prompt): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
2438
+ stream(options: AgentCallParameters): StreamTextResult<TOOLS, InferStreamOutput<OUTPUT>>;
2406
2439
  }
2407
2440
 
2408
2441
  /**
@@ -2431,7 +2464,7 @@ type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult
2431
2464
  /**
2432
2465
  * Configuration options for an agent.
2433
2466
  */
2434
- type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
2467
+ type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT extends Output = never> = CallSettings & {
2435
2468
  /**
2436
2469
  * The id of the agent.
2437
2470
  */
@@ -2471,7 +2504,7 @@ type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PA
2471
2504
  /**
2472
2505
  Optional specification for parsing structured outputs from the LLM response.
2473
2506
  */
2474
- experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
2507
+ experimental_output?: OUTPUT;
2475
2508
  /**
2476
2509
  * @deprecated Use `prepareStep` instead.
2477
2510
  */
@@ -2519,10 +2552,10 @@ type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PA
2519
2552
  * - A tool call needs approval, or
2520
2553
  * - A stop condition is met (default stop condition is stepCountIs(20))
2521
2554
  */
2522
- declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
2555
+ declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT extends Output = never> implements Agent<TOOLS, OUTPUT> {
2523
2556
  readonly version = "agent-v1";
2524
2557
  private readonly settings;
2525
- constructor(settings: ToolLoopAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
2558
+ constructor(settings: ToolLoopAgentSettings<TOOLS, OUTPUT>);
2526
2559
  /**
2527
2560
  * The id of the agent.
2528
2561
  */
@@ -2534,17 +2567,17 @@ declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_P
2534
2567
  /**
2535
2568
  * Generates an output from the agent (non-streaming).
2536
2569
  */
2537
- generate(options: Prompt): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2570
+ generate(options: AgentCallParameters): Promise<GenerateTextResult<TOOLS, InferGenerateOutput<OUTPUT>>>;
2538
2571
  /**
2539
2572
  * Streams an output from the agent (streaming).
2540
2573
  */
2541
- stream(options: Prompt): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
2574
+ stream(options: AgentCallParameters): StreamTextResult<TOOLS, InferStreamOutput<OUTPUT>>;
2542
2575
  }
2543
2576
 
2544
2577
  /**
2545
2578
  * Infer the type of the tools of an agent.
2546
2579
  */
2547
- type InferAgentTools<AGENT> = AGENT extends Agent<infer TOOLS, any, any> ? TOOLS : never;
2580
+ type InferAgentTools<AGENT> = AGENT extends Agent<infer TOOLS, never> ? TOOLS : never;
2548
2581
 
2549
2582
  /**
2550
2583
  * Infer the UI message type of an agent.
@@ -2559,8 +2592,8 @@ type InferAgentUIMessage<AGENT> = UIMessage<never, never, InferUITools<InferAgen
2559
2592
  *
2560
2593
  * @returns The response object.
2561
2594
  */
2562
- declare function createAgentUIStreamResponse<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never>({ headers, status, statusText, consumeSseStream, ...options }: {
2563
- agent: Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL>;
2595
+ declare function createAgentUIStreamResponse<TOOLS extends ToolSet = {}, OUTPUT extends Output = never>({ headers, status, statusText, consumeSseStream, ...options }: {
2596
+ agent: Agent<TOOLS, OUTPUT>;
2564
2597
  messages: unknown[];
2565
2598
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<never, never, InferUITools<TOOLS>>>): Promise<Response>;
2566
2599
 
@@ -3212,8 +3245,8 @@ declare const UI_MESSAGE_STREAM_HEADERS: {
3212
3245
  *
3213
3246
  * @returns The UI message stream.
3214
3247
  */
3215
- declare function createAgentUIStream<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never>({ agent, messages, ...uiMessageStreamOptions }: {
3216
- agent: Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL>;
3248
+ declare function createAgentUIStream<TOOLS extends ToolSet = {}, OUTPUT extends Output = never>({ agent, messages, ...uiMessageStreamOptions }: {
3249
+ agent: Agent<TOOLS, OUTPUT>;
3217
3250
  messages: unknown[];
3218
3251
  } & UIMessageStreamOptions<UIMessage<never, never, InferUITools<TOOLS>>>): Promise<AsyncIterableStream<InferUIMessageChunk<UIMessage<never, never, InferUITools<TOOLS>>>>>;
3219
3252
 
@@ -3223,9 +3256,9 @@ declare function createAgentUIStream<TOOLS extends ToolSet = {}, OUTPUT = never,
3223
3256
  * @param agent - The agent to run.
3224
3257
  * @param messages - The input UI messages.
3225
3258
  */
3226
- declare function pipeAgentUIStreamToResponse<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never>({ response, headers, status, statusText, consumeSseStream, ...options }: {
3259
+ declare function pipeAgentUIStreamToResponse<TOOLS extends ToolSet = {}, OUTPUT extends Output = never>({ response, headers, status, statusText, consumeSseStream, ...options }: {
3227
3260
  response: ServerResponse;
3228
- agent: Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL>;
3261
+ agent: Agent<TOOLS, OUTPUT>;
3229
3262
  messages: unknown[];
3230
3263
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<never, never, InferUITools<TOOLS>>>): Promise<void>;
3231
3264
 
package/dist/index.js CHANGED
@@ -873,7 +873,7 @@ function detectMediaType({
873
873
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
874
874
 
875
875
  // src/version.ts
876
- var VERSION = true ? "6.0.0-beta.62" : "0.0.0-test";
876
+ var VERSION = true ? "6.0.0-beta.64" : "0.0.0-test";
877
877
 
878
878
  // src/util/download/download.ts
879
879
  var download = async ({ url }) => {