ai 6.0.0-beta.56 → 6.0.0-beta.58
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 +12 -0
 - package/README.md +4 -4
 - package/dist/index.d.mts +29 -18
 - package/dist/index.d.ts +29 -18
 - package/dist/index.js +7 -6
 - package/dist/index.js.map +1 -1
 - package/dist/index.mjs +6 -5
 - package/dist/index.mjs.map +1 -1
 - package/dist/internal/index.js +1 -1
 - package/dist/internal/index.mjs +1 -1
 - package/package.json +1 -1
 
    
        package/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,17 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # ai
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## 6.0.0-beta.58
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ### Patch Changes
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - a417a34: feat(agent): introduce version property
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ## 6.0.0-beta.57
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ### Patch Changes
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            - 61f7b0f: chore(agent): rename BasicAgent to ToolLoopAgent
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       3 
15 
     | 
    
         
             
            ## 6.0.0-beta.56
         
     | 
| 
       4 
16 
     | 
    
         | 
| 
       5 
17 
     | 
    
         
             
            ### Patch Changes
         
     | 
    
        package/README.md
    CHANGED
    
    | 
         @@ -69,9 +69,9 @@ const { object } = await generateObject({ 
     | 
|
| 
       69 
69 
     | 
    
         
             
            ### Agents
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
            ```ts
         
     | 
| 
       72 
     | 
    
         
            -
            import {  
     | 
| 
      
 72 
     | 
    
         
            +
            import { ToolLoopAgent } from 'ai';
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
            const sandboxAgent = new  
     | 
| 
      
 74 
     | 
    
         
            +
            const sandboxAgent = new ToolLoopAgent({
         
     | 
| 
       75 
75 
     | 
    
         
             
              model: 'openai/gpt-5-codex',
         
     | 
| 
       76 
76 
     | 
    
         
             
              system: 'You are an agent with access to a shell environment.',
         
     | 
| 
       77 
77 
     | 
    
         
             
              tools: {
         
     | 
| 
         @@ -101,9 +101,9 @@ npm install @ai-sdk/react 
     | 
|
| 
       101 
101 
     | 
    
         | 
| 
       102 
102 
     | 
    
         
             
            ```ts
         
     | 
| 
       103 
103 
     | 
    
         
             
            import { openai } from '@ai-sdk/openai';
         
     | 
| 
       104 
     | 
    
         
            -
            import {  
     | 
| 
      
 104 
     | 
    
         
            +
            import { ToolLoopAgent, InferAgentUIMessage } from 'ai';
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
            export const imageGenerationAgent = new  
     | 
| 
      
 106 
     | 
    
         
            +
            export const imageGenerationAgent = new ToolLoopAgent({
         
     | 
| 
       107 
107 
     | 
    
         
             
              model: openai('gpt-5'),
         
     | 
| 
       108 
108 
     | 
    
         
             
              tools: {
         
     | 
| 
       109 
109 
     | 
    
         
             
                image_generation: openai.tools.imageGeneration({
         
     | 
    
        package/dist/index.d.mts
    CHANGED
    
    | 
         @@ -2375,18 +2375,26 @@ type TextStreamPart<TOOLS extends ToolSet> = { 
     | 
|
| 
       2375 
2375 
     | 
    
         
             
            };
         
     | 
| 
       2376 
2376 
     | 
    
         | 
| 
       2377 
2377 
     | 
    
         
             
            /**
         
     | 
| 
       2378 
     | 
    
         
            -
             * An  
     | 
| 
       2379 
     | 
    
         
            -
             *  
     | 
| 
      
 2378 
     | 
    
         
            +
             * An Agent receives a prompt (text or messages) and generates or streams an output
         
     | 
| 
      
 2379 
     | 
    
         
            +
             * that consists of steps, tool calls, data parts, etc.
         
     | 
| 
      
 2380 
     | 
    
         
            +
             *
         
     | 
| 
      
 2381 
     | 
    
         
            +
             * You can implement your own Agent by implementing the `Agent` interface,
         
     | 
| 
      
 2382 
     | 
    
         
            +
             * or use the `ToolLoopAgent` class.
         
     | 
| 
       2380 
2383 
     | 
    
         
             
             */
         
     | 
| 
       2381 
2384 
     | 
    
         
             
            interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> {
         
     | 
| 
      
 2385 
     | 
    
         
            +
                /**
         
     | 
| 
      
 2386 
     | 
    
         
            +
                 * The specification version of the agent interface. This will enable
         
     | 
| 
      
 2387 
     | 
    
         
            +
                 * us to evolve the agent interface and retain backwards compatibility.
         
     | 
| 
      
 2388 
     | 
    
         
            +
                 */
         
     | 
| 
      
 2389 
     | 
    
         
            +
                readonly version: 'agent-v1';
         
     | 
| 
       2382 
2390 
     | 
    
         
             
                /**
         
     | 
| 
       2383 
2391 
     | 
    
         
             
                 * The id of the agent.
         
     | 
| 
       2384 
2392 
     | 
    
         
             
                 */
         
     | 
| 
       2385 
     | 
    
         
            -
                id: string | undefined;
         
     | 
| 
      
 2393 
     | 
    
         
            +
                readonly id: string | undefined;
         
     | 
| 
       2386 
2394 
     | 
    
         
             
                /**
         
     | 
| 
       2387 
2395 
     | 
    
         
             
                 * The tools that the agent can use.
         
     | 
| 
       2388 
2396 
     | 
    
         
             
                 */
         
     | 
| 
       2389 
     | 
    
         
            -
                tools: TOOLS;
         
     | 
| 
      
 2397 
     | 
    
         
            +
                readonly tools: TOOLS;
         
     | 
| 
       2390 
2398 
     | 
    
         
             
                /**
         
     | 
| 
       2391 
2399 
     | 
    
         
             
                 * Generates an output from the agent (non-streaming).
         
     | 
| 
       2392 
2400 
     | 
    
         
             
                 */
         
     | 
| 
         @@ -2408,7 +2416,7 @@ Callback that is set using the `onFinish` option. 
     | 
|
| 
       2408 
2416 
     | 
    
         | 
| 
       2409 
2417 
     | 
    
         
             
            @param event - The event that is passed to the callback.
         
     | 
| 
       2410 
2418 
     | 
    
         
             
             */
         
     | 
| 
       2411 
     | 
    
         
            -
            type  
     | 
| 
      
 2419 
     | 
    
         
            +
            type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
         
     | 
| 
       2412 
2420 
     | 
    
         
             
                /**
         
     | 
| 
       2413 
2421 
     | 
    
         
             
            Details for all steps.
         
     | 
| 
       2414 
2422 
     | 
    
         
             
               */
         
     | 
| 
         @@ -2424,12 +2432,12 @@ Callback that is set using the `onStepFinish` option. 
     | 
|
| 
       2424 
2432 
     | 
    
         | 
| 
       2425 
2433 
     | 
    
         
             
            @param stepResult - The result of the step.
         
     | 
| 
       2426 
2434 
     | 
    
         
             
             */
         
     | 
| 
       2427 
     | 
    
         
            -
            type  
     | 
| 
      
 2435 
     | 
    
         
            +
            type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
         
     | 
| 
       2428 
2436 
     | 
    
         | 
| 
       2429 
2437 
     | 
    
         
             
            /**
         
     | 
| 
       2430 
2438 
     | 
    
         
             
             * Configuration options for an agent.
         
     | 
| 
       2431 
2439 
     | 
    
         
             
             */
         
     | 
| 
       2432 
     | 
    
         
            -
            type  
     | 
| 
      
 2440 
     | 
    
         
            +
            type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
         
     | 
| 
       2433 
2441 
     | 
    
         
             
                /**
         
     | 
| 
       2434 
2442 
     | 
    
         
             
                 * The id of the agent.
         
     | 
| 
       2435 
2443 
     | 
    
         
             
                 */
         
     | 
| 
         @@ -2485,11 +2493,11 @@ type BasicAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTI 
     | 
|
| 
       2485 
2493 
     | 
    
         
             
                /**
         
     | 
| 
       2486 
2494 
     | 
    
         
             
                 * Callback that is called when each step (LLM call) is finished, including intermediate steps.
         
     | 
| 
       2487 
2495 
     | 
    
         
             
                 */
         
     | 
| 
       2488 
     | 
    
         
            -
                onStepFinish?:  
     | 
| 
      
 2496 
     | 
    
         
            +
                onStepFinish?: ToolLoopAgentOnStepFinishCallback<NoInfer<TOOLS>>;
         
     | 
| 
       2489 
2497 
     | 
    
         
             
                /**
         
     | 
| 
       2490 
2498 
     | 
    
         
             
                 * Callback that is called when all steps are finished and the response is complete.
         
     | 
| 
       2491 
2499 
     | 
    
         
             
                 */
         
     | 
| 
       2492 
     | 
    
         
            -
                onFinish?:  
     | 
| 
      
 2500 
     | 
    
         
            +
                onFinish?: ToolLoopAgentOnFinishCallback<NoInfer<TOOLS>>;
         
     | 
| 
       2493 
2501 
     | 
    
         
             
                /**
         
     | 
| 
       2494 
2502 
     | 
    
         
             
              Additional provider-specific options. They are passed through
         
     | 
| 
       2495 
2503 
     | 
    
         
             
              to the provider from the AI SDK and enable provider-specific
         
     | 
| 
         @@ -2507,17 +2515,20 @@ type BasicAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTI 
     | 
|
| 
       2507 
2515 
     | 
    
         
             
            };
         
     | 
| 
       2508 
2516 
     | 
    
         | 
| 
       2509 
2517 
     | 
    
         
             
            /**
         
     | 
| 
       2510 
     | 
    
         
            -
             *  
     | 
| 
       2511 
     | 
    
         
            -
             * and  
     | 
| 
       2512 
     | 
    
         
            -
             *
         
     | 
| 
       2513 
     | 
    
         
            -
             * It handles the agent loop for you, allowing the LLM to call tools multiple times in
         
     | 
| 
       2514 
     | 
    
         
            -
             * sequence to accomplish complex tasks.
         
     | 
| 
      
 2518 
     | 
    
         
            +
             * A tool loop agent is an agent that runs tools in a loop. In each step,
         
     | 
| 
      
 2519 
     | 
    
         
            +
             * it calls the LLM, and if there are tool calls, it executes the tools
         
     | 
| 
      
 2520 
     | 
    
         
            +
             * and calls the LLM again in a new step with the tool results.
         
     | 
| 
       2515 
2521 
     | 
    
         
             
             *
         
     | 
| 
       2516 
     | 
    
         
            -
             *  
     | 
| 
      
 2522 
     | 
    
         
            +
             * The loop continues until:
         
     | 
| 
      
 2523 
     | 
    
         
            +
             * - A finish reasoning other than tool-calls is returned, or
         
     | 
| 
      
 2524 
     | 
    
         
            +
             * - A tool that is invoked does not have an execute function, or
         
     | 
| 
      
 2525 
     | 
    
         
            +
             * - A tool call needs approval, or
         
     | 
| 
      
 2526 
     | 
    
         
            +
             * - A stop condition is met (default stop condition is stepCountIs(20))
         
     | 
| 
       2517 
2527 
     | 
    
         
             
             */
         
     | 
| 
       2518 
     | 
    
         
            -
            declare class  
     | 
| 
      
 2528 
     | 
    
         
            +
            declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
         
     | 
| 
      
 2529 
     | 
    
         
            +
                readonly version = "agent-v1";
         
     | 
| 
       2519 
2530 
     | 
    
         
             
                private readonly settings;
         
     | 
| 
       2520 
     | 
    
         
            -
                constructor(settings:  
     | 
| 
      
 2531 
     | 
    
         
            +
                constructor(settings: ToolLoopAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
         
     | 
| 
       2521 
2532 
     | 
    
         
             
                /**
         
     | 
| 
       2522 
2533 
     | 
    
         
             
                 * The id of the agent.
         
     | 
| 
       2523 
2534 
     | 
    
         
             
                 */
         
     | 
| 
         @@ -4906,4 +4917,4 @@ declare global { 
     | 
|
| 
       4906 
4917 
     | 
    
         
             
                var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
         
     | 
| 
       4907 
4918 
     | 
    
         
             
            }
         
     | 
| 
       4908 
4919 
     | 
    
         | 
| 
       4909 
     | 
    
         
            -
            export { AbstractChat, Agent, AsyncIterableStream,  
     | 
| 
      
 4920 
     | 
    
         
            +
            export { AbstractChat, Agent, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
         
     | 
    
        package/dist/index.d.ts
    CHANGED
    
    | 
         @@ -2375,18 +2375,26 @@ type TextStreamPart<TOOLS extends ToolSet> = { 
     | 
|
| 
       2375 
2375 
     | 
    
         
             
            };
         
     | 
| 
       2376 
2376 
     | 
    
         | 
| 
       2377 
2377 
     | 
    
         
             
            /**
         
     | 
| 
       2378 
     | 
    
         
            -
             * An  
     | 
| 
       2379 
     | 
    
         
            -
             *  
     | 
| 
      
 2378 
     | 
    
         
            +
             * An Agent receives a prompt (text or messages) and generates or streams an output
         
     | 
| 
      
 2379 
     | 
    
         
            +
             * that consists of steps, tool calls, data parts, etc.
         
     | 
| 
      
 2380 
     | 
    
         
            +
             *
         
     | 
| 
      
 2381 
     | 
    
         
            +
             * You can implement your own Agent by implementing the `Agent` interface,
         
     | 
| 
      
 2382 
     | 
    
         
            +
             * or use the `ToolLoopAgent` class.
         
     | 
| 
       2380 
2383 
     | 
    
         
             
             */
         
     | 
| 
       2381 
2384 
     | 
    
         
             
            interface Agent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> {
         
     | 
| 
      
 2385 
     | 
    
         
            +
                /**
         
     | 
| 
      
 2386 
     | 
    
         
            +
                 * The specification version of the agent interface. This will enable
         
     | 
| 
      
 2387 
     | 
    
         
            +
                 * us to evolve the agent interface and retain backwards compatibility.
         
     | 
| 
      
 2388 
     | 
    
         
            +
                 */
         
     | 
| 
      
 2389 
     | 
    
         
            +
                readonly version: 'agent-v1';
         
     | 
| 
       2382 
2390 
     | 
    
         
             
                /**
         
     | 
| 
       2383 
2391 
     | 
    
         
             
                 * The id of the agent.
         
     | 
| 
       2384 
2392 
     | 
    
         
             
                 */
         
     | 
| 
       2385 
     | 
    
         
            -
                id: string | undefined;
         
     | 
| 
      
 2393 
     | 
    
         
            +
                readonly id: string | undefined;
         
     | 
| 
       2386 
2394 
     | 
    
         
             
                /**
         
     | 
| 
       2387 
2395 
     | 
    
         
             
                 * The tools that the agent can use.
         
     | 
| 
       2388 
2396 
     | 
    
         
             
                 */
         
     | 
| 
       2389 
     | 
    
         
            -
                tools: TOOLS;
         
     | 
| 
      
 2397 
     | 
    
         
            +
                readonly tools: TOOLS;
         
     | 
| 
       2390 
2398 
     | 
    
         
             
                /**
         
     | 
| 
       2391 
2399 
     | 
    
         
             
                 * Generates an output from the agent (non-streaming).
         
     | 
| 
       2392 
2400 
     | 
    
         
             
                 */
         
     | 
| 
         @@ -2408,7 +2416,7 @@ Callback that is set using the `onFinish` option. 
     | 
|
| 
       2408 
2416 
     | 
    
         | 
| 
       2409 
2417 
     | 
    
         
             
            @param event - The event that is passed to the callback.
         
     | 
| 
       2410 
2418 
     | 
    
         
             
             */
         
     | 
| 
       2411 
     | 
    
         
            -
            type  
     | 
| 
      
 2419 
     | 
    
         
            +
            type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
         
     | 
| 
       2412 
2420 
     | 
    
         
             
                /**
         
     | 
| 
       2413 
2421 
     | 
    
         
             
            Details for all steps.
         
     | 
| 
       2414 
2422 
     | 
    
         
             
               */
         
     | 
| 
         @@ -2424,12 +2432,12 @@ Callback that is set using the `onStepFinish` option. 
     | 
|
| 
       2424 
2432 
     | 
    
         | 
| 
       2425 
2433 
     | 
    
         
             
            @param stepResult - The result of the step.
         
     | 
| 
       2426 
2434 
     | 
    
         
             
             */
         
     | 
| 
       2427 
     | 
    
         
            -
            type  
     | 
| 
      
 2435 
     | 
    
         
            +
            type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
         
     | 
| 
       2428 
2436 
     | 
    
         | 
| 
       2429 
2437 
     | 
    
         
             
            /**
         
     | 
| 
       2430 
2438 
     | 
    
         
             
             * Configuration options for an agent.
         
     | 
| 
       2431 
2439 
     | 
    
         
             
             */
         
     | 
| 
       2432 
     | 
    
         
            -
            type  
     | 
| 
      
 2440 
     | 
    
         
            +
            type ToolLoopAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> = CallSettings & {
         
     | 
| 
       2433 
2441 
     | 
    
         
             
                /**
         
     | 
| 
       2434 
2442 
     | 
    
         
             
                 * The id of the agent.
         
     | 
| 
       2435 
2443 
     | 
    
         
             
                 */
         
     | 
| 
         @@ -2485,11 +2493,11 @@ type BasicAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTI 
     | 
|
| 
       2485 
2493 
     | 
    
         
             
                /**
         
     | 
| 
       2486 
2494 
     | 
    
         
             
                 * Callback that is called when each step (LLM call) is finished, including intermediate steps.
         
     | 
| 
       2487 
2495 
     | 
    
         
             
                 */
         
     | 
| 
       2488 
     | 
    
         
            -
                onStepFinish?:  
     | 
| 
      
 2496 
     | 
    
         
            +
                onStepFinish?: ToolLoopAgentOnStepFinishCallback<NoInfer<TOOLS>>;
         
     | 
| 
       2489 
2497 
     | 
    
         
             
                /**
         
     | 
| 
       2490 
2498 
     | 
    
         
             
                 * Callback that is called when all steps are finished and the response is complete.
         
     | 
| 
       2491 
2499 
     | 
    
         
             
                 */
         
     | 
| 
       2492 
     | 
    
         
            -
                onFinish?:  
     | 
| 
      
 2500 
     | 
    
         
            +
                onFinish?: ToolLoopAgentOnFinishCallback<NoInfer<TOOLS>>;
         
     | 
| 
       2493 
2501 
     | 
    
         
             
                /**
         
     | 
| 
       2494 
2502 
     | 
    
         
             
              Additional provider-specific options. They are passed through
         
     | 
| 
       2495 
2503 
     | 
    
         
             
              to the provider from the AI SDK and enable provider-specific
         
     | 
| 
         @@ -2507,17 +2515,20 @@ type BasicAgentSettings<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTI 
     | 
|
| 
       2507 
2515 
     | 
    
         
             
            };
         
     | 
| 
       2508 
2516 
     | 
    
         | 
| 
       2509 
2517 
     | 
    
         
             
            /**
         
     | 
| 
       2510 
     | 
    
         
            -
             *  
     | 
| 
       2511 
     | 
    
         
            -
             * and  
     | 
| 
       2512 
     | 
    
         
            -
             *
         
     | 
| 
       2513 
     | 
    
         
            -
             * It handles the agent loop for you, allowing the LLM to call tools multiple times in
         
     | 
| 
       2514 
     | 
    
         
            -
             * sequence to accomplish complex tasks.
         
     | 
| 
      
 2518 
     | 
    
         
            +
             * A tool loop agent is an agent that runs tools in a loop. In each step,
         
     | 
| 
      
 2519 
     | 
    
         
            +
             * it calls the LLM, and if there are tool calls, it executes the tools
         
     | 
| 
      
 2520 
     | 
    
         
            +
             * and calls the LLM again in a new step with the tool results.
         
     | 
| 
       2515 
2521 
     | 
    
         
             
             *
         
     | 
| 
       2516 
     | 
    
         
            -
             *  
     | 
| 
      
 2522 
     | 
    
         
            +
             * The loop continues until:
         
     | 
| 
      
 2523 
     | 
    
         
            +
             * - A finish reasoning other than tool-calls is returned, or
         
     | 
| 
      
 2524 
     | 
    
         
            +
             * - A tool that is invoked does not have an execute function, or
         
     | 
| 
      
 2525 
     | 
    
         
            +
             * - A tool call needs approval, or
         
     | 
| 
      
 2526 
     | 
    
         
            +
             * - A stop condition is met (default stop condition is stepCountIs(20))
         
     | 
| 
       2517 
2527 
     | 
    
         
             
             */
         
     | 
| 
       2518 
     | 
    
         
            -
            declare class  
     | 
| 
      
 2528 
     | 
    
         
            +
            declare class ToolLoopAgent<TOOLS extends ToolSet = {}, OUTPUT = never, OUTPUT_PARTIAL = never> implements Agent<TOOLS, OUTPUT, OUTPUT_PARTIAL> {
         
     | 
| 
      
 2529 
     | 
    
         
            +
                readonly version = "agent-v1";
         
     | 
| 
       2519 
2530 
     | 
    
         
             
                private readonly settings;
         
     | 
| 
       2520 
     | 
    
         
            -
                constructor(settings:  
     | 
| 
      
 2531 
     | 
    
         
            +
                constructor(settings: ToolLoopAgentSettings<TOOLS, OUTPUT, OUTPUT_PARTIAL>);
         
     | 
| 
       2521 
2532 
     | 
    
         
             
                /**
         
     | 
| 
       2522 
2533 
     | 
    
         
             
                 * The id of the agent.
         
     | 
| 
       2523 
2534 
     | 
    
         
             
                 */
         
     | 
| 
         @@ -4906,4 +4917,4 @@ declare global { 
     | 
|
| 
       4906 
4917 
     | 
    
         
             
                var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
         
     | 
| 
       4907 
4918 
     | 
    
         
             
            }
         
     | 
| 
       4908 
4919 
     | 
    
         | 
| 
       4909 
     | 
    
         
            -
            export { AbstractChat, Agent, AsyncIterableStream,  
     | 
| 
      
 4920 
     | 
    
         
            +
            export { AbstractChat, Agent, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
         
     | 
    
        package/dist/index.js
    CHANGED
    
    | 
         @@ -23,11 +23,10 @@ __export(src_exports, { 
     | 
|
| 
       23 
23 
     | 
    
         
             
              AISDKError: () => import_provider18.AISDKError,
         
     | 
| 
       24 
24 
     | 
    
         
             
              APICallError: () => import_provider18.APICallError,
         
     | 
| 
       25 
25 
     | 
    
         
             
              AbstractChat: () => AbstractChat,
         
     | 
| 
       26 
     | 
    
         
            -
              BasicAgent: () => BasicAgent,
         
     | 
| 
       27 
26 
     | 
    
         
             
              DefaultChatTransport: () => DefaultChatTransport,
         
     | 
| 
       28 
27 
     | 
    
         
             
              DownloadError: () => DownloadError,
         
     | 
| 
       29 
28 
     | 
    
         
             
              EmptyResponseBodyError: () => import_provider18.EmptyResponseBodyError,
         
     | 
| 
       30 
     | 
    
         
            -
              Experimental_Agent: () =>  
     | 
| 
      
 29 
     | 
    
         
            +
              Experimental_Agent: () => ToolLoopAgent,
         
     | 
| 
       31 
30 
     | 
    
         
             
              HttpChatTransport: () => HttpChatTransport,
         
     | 
| 
       32 
31 
     | 
    
         
             
              InvalidArgumentError: () => InvalidArgumentError,
         
     | 
| 
       33 
32 
     | 
    
         
             
              InvalidDataContentError: () => InvalidDataContentError,
         
     | 
| 
         @@ -57,6 +56,7 @@ __export(src_exports, { 
     | 
|
| 
       57 
56 
     | 
    
         
             
              TextStreamChatTransport: () => TextStreamChatTransport,
         
     | 
| 
       58 
57 
     | 
    
         
             
              TooManyEmbeddingValuesForCallError: () => import_provider18.TooManyEmbeddingValuesForCallError,
         
     | 
| 
       59 
58 
     | 
    
         
             
              ToolCallRepairError: () => ToolCallRepairError,
         
     | 
| 
      
 59 
     | 
    
         
            +
              ToolLoopAgent: () => ToolLoopAgent,
         
     | 
| 
       60 
60 
     | 
    
         
             
              TypeValidationError: () => import_provider18.TypeValidationError,
         
     | 
| 
       61 
61 
     | 
    
         
             
              UI_MESSAGE_STREAM_HEADERS: () => UI_MESSAGE_STREAM_HEADERS,
         
     | 
| 
       62 
62 
     | 
    
         
             
              UnsupportedFunctionalityError: () => import_provider18.UnsupportedFunctionalityError,
         
     | 
| 
         @@ -870,7 +870,7 @@ function detectMediaType({ 
     | 
|
| 
       870 
870 
     | 
    
         
             
            var import_provider_utils2 = require("@ai-sdk/provider-utils");
         
     | 
| 
       871 
871 
     | 
    
         | 
| 
       872 
872 
     | 
    
         
             
            // src/version.ts
         
     | 
| 
       873 
     | 
    
         
            -
            var VERSION = true ? "6.0.0-beta. 
     | 
| 
      
 873 
     | 
    
         
            +
            var VERSION = true ? "6.0.0-beta.58" : "0.0.0-test";
         
     | 
| 
       874 
874 
     | 
    
         | 
| 
       875 
875 
     | 
    
         
             
            // src/util/download/download.ts
         
     | 
| 
       876 
876 
     | 
    
         
             
            var download = async ({ url }) => {
         
     | 
| 
         @@ -6525,9 +6525,10 @@ function convertToModelMessages(messages, options) { 
     | 
|
| 
       6525 
6525 
     | 
    
         
             
            }
         
     | 
| 
       6526 
6526 
     | 
    
         
             
            var convertToCoreMessages = convertToModelMessages;
         
     | 
| 
       6527 
6527 
     | 
    
         | 
| 
       6528 
     | 
    
         
            -
            // src/agent/ 
     | 
| 
       6529 
     | 
    
         
            -
            var  
     | 
| 
      
 6528 
     | 
    
         
            +
            // src/agent/tool-loop-agent.ts
         
     | 
| 
      
 6529 
     | 
    
         
            +
            var ToolLoopAgent = class {
         
     | 
| 
       6530 
6530 
     | 
    
         
             
              constructor(settings) {
         
     | 
| 
      
 6531 
     | 
    
         
            +
                this.version = "agent-v1";
         
     | 
| 
       6531 
6532 
     | 
    
         
             
                this.settings = settings;
         
     | 
| 
       6532 
6533 
     | 
    
         
             
              }
         
     | 
| 
       6533 
6534 
     | 
    
         
             
              /**
         
     | 
| 
         @@ -11193,7 +11194,6 @@ function readUIMessageStream({ 
     | 
|
| 
       11193 
11194 
     | 
    
         
             
              AISDKError,
         
     | 
| 
       11194 
11195 
     | 
    
         
             
              APICallError,
         
     | 
| 
       11195 
11196 
     | 
    
         
             
              AbstractChat,
         
     | 
| 
       11196 
     | 
    
         
            -
              BasicAgent,
         
     | 
| 
       11197 
11197 
     | 
    
         
             
              DefaultChatTransport,
         
     | 
| 
       11198 
11198 
     | 
    
         
             
              DownloadError,
         
     | 
| 
       11199 
11199 
     | 
    
         
             
              EmptyResponseBodyError,
         
     | 
| 
         @@ -11227,6 +11227,7 @@ function readUIMessageStream({ 
     | 
|
| 
       11227 
11227 
     | 
    
         
             
              TextStreamChatTransport,
         
     | 
| 
       11228 
11228 
     | 
    
         
             
              TooManyEmbeddingValuesForCallError,
         
     | 
| 
       11229 
11229 
     | 
    
         
             
              ToolCallRepairError,
         
     | 
| 
      
 11230 
     | 
    
         
            +
              ToolLoopAgent,
         
     | 
| 
       11230 
11231 
     | 
    
         
             
              TypeValidationError,
         
     | 
| 
       11231 
11232 
     | 
    
         
             
              UI_MESSAGE_STREAM_HEADERS,
         
     | 
| 
       11232 
11233 
     | 
    
         
             
              UnsupportedFunctionalityError,
         
     |