import type { UIMessage } from '../_types/@internal_ai-sdk-v4/dist/index.js'; import type { StandardSchemaWithJSON } from '@mastra/schema-compat/schema'; import type { JSONSchema7 } from 'json-schema'; import type { MastraPrimitives } from '../action/index.js'; import { MastraBase } from '../base.js'; import type { MastraBrowser } from '../browser/browser.js'; import { AgentChannels } from '../channels/agent-channels.js'; import type { MastraScorers, MastraScorer } from '../evals/index.js'; import { MastraLLMV1 } from '../llm/model/index.js'; import type { GenerateObjectResult, GenerateTextResult, StreamObjectResult, StreamTextResult } from '../llm/model/base.types.js'; import { MastraLLMVNext } from '../llm/model/model.loop.js'; import type { MastraLanguageModel, MastraLegacyLanguageModel, MastraModelConfig } from '../llm/model/shared.types.js'; import type { Mastra } from '../mastra/index.js'; import type { MastraMemory } from '../memory/memory.js'; import type { DefinitionSource, TracingProperties, ObservabilityContext } from '../observability/index.js'; import type { InputProcessorOrWorkflow, OutputProcessorOrWorkflow, ProcessorWorkflow, Processor } from '../processors/index.js'; import { RequestContext } from '../request-context/index.js'; import type { InferStandardSchemaOutput } from '../schema/index.js'; import type { MastraAgentNetworkStream } from '../stream/index.js'; import type { FullOutput, MastraModelOutput } from '../stream/base/output.js'; import type { DynamicArgument } from '../types/index.js'; import type { MastraVoice } from '../voice/index.js'; import type { AnyWorkflow } from '../workflows/index.js'; import type { AnyWorkspace } from '../workspace/index.js'; import type { AgentExecutionOptions, AgentExecutionOptionsBase, MultiPrimitiveExecutionOptions, NetworkOptions } from './agent.types.js'; import type { MessageInput, MessageListInput, UIMessageWithMetadata } from './message-list/index.js'; import type { AgentConfig, AgentGenerateOptions, AgentStreamOptions, ToolsInput, AgentModelManagerConfig, AgentInstructions, PublicStructuredOutputOptions, ModelWithRetries, ZodSchema } from './types.js'; export type MastraLLM = MastraLLMV1 | MastraLLMVNext; type ModelFallbacks = { id: string; model: DynamicArgument; maxRetries: number; enabled: boolean; }[]; /** * The Agent class is the foundation for creating AI agents in Mastra. It provides methods for generating responses, * streaming interactions, managing memory, and handling voice capabilities. * * @example * ```typescript * import { Agent } from '@mastra/core/agent'; * import { Memory } from '@mastra/memory'; * * const agent = new Agent({ * id: 'my-agent', * name: 'My Agent', * instructions: 'You are a helpful assistant', * model: 'openai/gpt-5', * tools: { * calculator: calculatorTool, * }, * memory: new Memory(), * }); * ``` */ export declare class Agent | unknown = unknown> extends MastraBase { #private; id: TAgentId; name: string; source?: DefinitionSource; model: DynamicArgument | ModelFallbacks; maxRetries?: number; private _agentNetworkAppend; /** * Creates a new Agent instance with the specified configuration. * * @example * ```typescript * import { Agent } from '@mastra/core/agent'; * import { Memory } from '@mastra/memory'; * * const agent = new Agent({ * id: 'weatherAgent', * name: 'Weather Agent', * instructions: 'You help users with weather information', * model: 'openai/gpt-5', * tools: { getWeather }, * memory: new Memory(), * maxRetries: 2, * }); * ``` */ constructor(config: AgentConfig); getMastraInstance(): Mastra>, Record, Record>, Record, import("../logger").IMastraLogger, Record>, Record>, Record>, Record>, Record> | undefined; /** * Returns the AgentChannels instance that manages all channel adapters. * Returns null if no channels are configured. */ getChannels(): AgentChannels | null; /** * Returns the browser instance for this agent, if configured. * Browser tools are automatically added at execution time via `convertTools()`. * This getter is primarily used by server-side code to access browser features * like screencast streaming and input injection. */ get browser(): MastraBrowser | undefined; /** * Sets or updates the browser instance for this agent. * This allows hot-swapping browser configuration without recreating the agent. * Browser tools will be automatically updated on the next execution. * * @param browser - The new browser instance, or undefined to disable browser tools */ setBrowser(browser: MastraBrowser | undefined): void; /** * Returns true if this agent was configured with its own browser instance. * Used by Harness to avoid overwriting agent-level browser configuration. */ hasOwnBrowser(): boolean; /** * Gets the skills processors to add to input processors when workspace has skills. * @internal */ private getSkillsProcessors; /** * Gets the workspace-instructions processors to add when the workspace has a * filesystem or sandbox (i.e. something to describe). * @internal */ private getWorkspaceInstructionsProcessors; /** * Returns the agents configured for this agent, resolving function-based agents if necessary. * Used in multi-agent collaboration scenarios where this agent can delegate to other agents. * * @example * ```typescript * const agents = await agent.listAgents(); * console.log(Object.keys(agents)); // ['agent1', 'agent2'] * ``` */ listAgents({ requestContext }?: { requestContext?: RequestContext; }): Record> | Promise>>; /** * Creates and returns a ProcessorRunner with resolved input/output processors. * @internal */ private getProcessorRunner; /** * Combines multiple processors into a single workflow. * Each processor becomes a step in the workflow, chained together. * If there's only one item and it's already a workflow, returns it as-is. * @internal */ private combineProcessorsIntoWorkflow; /** * Resolves and returns output processors from agent configuration. * All processors are combined into a single workflow for consistency. * @internal */ private listResolvedOutputProcessors; /** * Resolves and returns input processors from agent configuration. * All processors are combined into a single workflow for consistency. * @internal */ private listResolvedInputProcessors; /** * Returns the input processors for this agent, resolving function-based processors if necessary. */ listInputProcessors(requestContext?: RequestContext): Promise; /** * Returns the output processors for this agent, resolving function-based processors if necessary. */ listOutputProcessors(requestContext?: RequestContext): Promise; /** * Resolves a processor by its ID from both input and output processors. * This method resolves dynamic processor functions and includes memory-derived processors. * Returns the processor if found, null otherwise. * * @example * ```typescript * const omProcessor = await agent.resolveProcessorById('observational-memory'); * if (omProcessor) { * // Observational memory is configured * } * ``` */ resolveProcessorById(processorId: TId, requestContext?: RequestContext): Promise | null>; /** * Returns only the user-configured input processors, excluding memory-derived processors. * Useful for scenarios where memory processors should not be applied (e.g., network routing agents). * * Unlike `listInputProcessors()` which includes both memory and configured processors, * this method returns only what was explicitly configured via the `inputProcessors` option. */ listConfiguredInputProcessors(requestContext?: RequestContext): Promise; /** * Returns only the user-configured output processors, excluding memory-derived processors. * Useful for scenarios where memory processors should not be applied (e.g., network routing agents). * * Unlike `listOutputProcessors()` which includes both memory and configured processors, * this method returns only what was explicitly configured via the `outputProcessors` option. */ listConfiguredOutputProcessors(requestContext?: RequestContext): Promise; /** * Returns the IDs of the raw configured input, output, and error processors, * without combining them into workflows. Used by the editor to clone * agent processor configuration to storage. */ getConfiguredProcessorIds(requestContext?: RequestContext): Promise<{ inputProcessorIds: string[]; outputProcessorIds: string[]; errorProcessorIds: string[]; }>; /** * Returns configured processor workflows for registration with Mastra. * This excludes memory-derived processors to avoid triggering memory factory functions. * @internal */ getConfiguredProcessorWorkflows(): Promise; /** * Returns whether this agent has its own memory configured. * * @example * ```typescript * if (agent.hasOwnMemory()) { * const memory = await agent.getMemory(); * } * ``` */ hasOwnMemory(): boolean; /** * Gets the memory instance for this agent, resolving function-based memory if necessary. * The memory system enables conversation persistence, semantic recall, and working memory. * * @example * ```typescript * const memory = await agent.getMemory(); * if (memory) { * // Memory is configured * } * ``` */ getMemory({ requestContext }?: { requestContext?: RequestContext; }): Promise; /** * Checks if this agent has its own workspace configured. * * @example * ```typescript * if (agent.hasOwnWorkspace()) { * const workspace = await agent.getWorkspace(); * } * ``` */ hasOwnWorkspace(): boolean; /** * Gets the workspace instance for this agent, resolving function-based workspace if necessary. * The workspace provides filesystem and sandbox capabilities for file operations and code execution. * * @example * ```typescript * const workspace = await agent.getWorkspace(); * if (workspace) { * await workspace.writeFile('/data.json', JSON.stringify(data)); * const result = await workspace.executeCode('console.log("Hello")'); * } * ``` */ getWorkspace({ requestContext, }?: { requestContext?: RequestContext; }): Promise; get voice(): MastraVoice; /** * Gets the request context schema for this agent. * Returns the Zod schema used to validate request context values, or undefined if not set. */ get requestContextSchema(): StandardSchemaWithJSON | undefined; /** * Gets the workflows configured for this agent, resolving function-based workflows if necessary. * Workflows are step-based execution flows that can be triggered by the agent. * * @example * ```typescript * const workflows = await agent.listWorkflows(); * const workflow = workflows['myWorkflow']; * ``` */ listWorkflows({ requestContext, }?: { requestContext?: RequestContext; }): Promise>; listScorers({ requestContext, }?: { requestContext?: RequestContext; }): Promise; /** * Gets the voice instance for this agent with tools and instructions configured. * The voice instance enables text-to-speech and speech-to-text capabilities. * * @example * ```typescript * const voice = await agent.getVoice(); * const audioStream = await voice.speak('Hello world'); * ``` */ getVoice({ requestContext }?: { requestContext?: RequestContext; }): Promise>; /** * Gets the instructions for this agent, resolving function-based instructions if necessary. * Instructions define the agent's behavior and capabilities. * * @example * ```typescript * const instructions = await agent.getInstructions(); * console.log(instructions); // 'You are a helpful assistant' * ``` */ getInstructions({ requestContext }?: { requestContext?: RequestContext; }): AgentInstructions | Promise; /** * Returns the description of the agent. * * @example * ```typescript * const description = agent.getDescription(); * console.log(description); // 'A helpful weather assistant' * ``` */ getDescription(): string; /** * Gets the legacy handler instance, initializing it lazily if needed. * @internal */ private getLegacyHandler; /** * Gets the default generate options for the legacy generate method. * These options are used as defaults when calling `generateLegacy()` without explicit options. * * @example * ```typescript * const options = await agent.getDefaultGenerateOptionsLegacy(); * console.log(options.maxSteps); // 5 * ``` */ getDefaultGenerateOptionsLegacy({ requestContext, }?: { requestContext?: RequestContext; }): AgentGenerateOptions | Promise; /** * Gets the default stream options for the legacy stream method. * These options are used as defaults when calling `streamLegacy()` without explicit options. * * @example * ```typescript * const options = await agent.getDefaultStreamOptionsLegacy(); * console.log(options.temperature); // 0.7 * ``` */ getDefaultStreamOptionsLegacy({ requestContext, }?: { requestContext?: RequestContext; }): AgentStreamOptions | Promise; /** * Gets the default options for this agent, resolving function-based options if necessary. * These options are used as defaults when calling `stream()` or `generate()` without explicit options. * * @example * ```typescript * const options = await agent.getDefaultStreamOptions(); * console.log(options.maxSteps); // 5 * ``` */ getDefaultOptions({ requestContext }?: { requestContext?: RequestContext; }): AgentExecutionOptions | Promise>; /** * Gets the default NetworkOptions for this agent, resolving function-based options if necessary. * These options are used as defaults when calling `network()` without explicit options. * * @returns NetworkOptions containing maxSteps, completion (CompletionConfig), and other network settings * * @example * ```typescript * const options = await agent.getDefaultNetworkOptions(); * console.log(options.maxSteps); // 20 * console.log(options.completion?.scorers); // [testsScorer, buildScorer] * ``` */ getDefaultNetworkOptions({ requestContext }?: { requestContext?: RequestContext; }): NetworkOptions | Promise; /** * Gets the tools configured for this agent, resolving function-based tools if necessary. * Tools extend the agent's capabilities, allowing it to perform specific actions or access external systems. * * Note: Browser tools are NOT included here. They are added at execution time via `convertTools()`. * * @example * ```typescript * const tools = await agent.listTools(); * console.log(Object.keys(tools)); // ['calculator', 'weather', ...] * ``` */ listTools({ requestContext }?: { requestContext?: RequestContext; }): TTools | Promise; /** * Gets or creates an LLM instance based on the provided or configured model. * The LLM wraps the language model with additional capabilities like error handling. * * @example * ```typescript * const llm = await agent.getLLM(); * // Use with custom model * const customLlm = await agent.getLLM({ model: 'openai/gpt-5' }); * ``` */ getLLM({ requestContext, model, }?: { requestContext?: RequestContext; model?: DynamicArgument; }): MastraLLM | Promise; /** * Resolves a model configuration to a LanguageModel instance * @param modelConfig The model configuration (magic string, config object, or LanguageModel) * @returns A LanguageModel instance * @internal */ private resolveModelConfig; /** * Type guard to check if an array is already normalized to ModelFallbacks. * Used to optimize and avoid double normalization. * @internal */ private isModelFallbacks; /** * Normalizes model arrays into the internal fallback shape. * @internal */ private normalizeModelFallbacks; /** * Ensures a model can participate in prepared multi-model execution. * @internal */ private assertSupportsPreparedModels; /** * Resolves model configuration that may be a dynamic function returning a single model or array of models. * Supports DynamicArgument for both MastraModelConfig and ModelWithRetries[]. * Normalizes fallback arrays while preserving single-model semantics. * * @internal */ private resolveModelSelection; /** * Gets the model instance, resolving it if it's a function or model configuration. * When the agent has multiple models configured, returns the first enabled model. * * @example * ```typescript * const model = await agent.getModel(); * // Get with custom model config * const customModel = await agent.getModel({ * modelConfig: 'openai/gpt-5' * }); * ``` */ getModel({ requestContext, modelConfig, }?: { requestContext?: RequestContext; modelConfig?: DynamicArgument | ModelFallbacks; }): MastraLanguageModel | MastraLegacyLanguageModel | Promise; /** * Gets the list of configured models if the agent has multiple models, otherwise returns null. * Used for model fallback and load balancing scenarios. * * @example * ```typescript * const models = await agent.getModelList(); * if (models) { * console.log(models.map(m => m.id)); * } * ``` */ getModelList(requestContext?: RequestContext): Promise | null>; /** * Updates the agent's instructions. * @internal */ __updateInstructions(newInstructions: DynamicArgument): void; /** * Updates the agent's model configuration. * @internal */ __updateModel({ model }: { model: DynamicArgument | ModelFallbacks; }): void; /** * Resets the agent's model to the original model set during construction. * Clones arrays to prevent reordering mutations from affecting the original snapshot. * @internal */ __resetToOriginalModel(): void; /** * Returns a snapshot of the raw field values that may be overridden by stored config. * Used by the editor to save/restore code defaults externally. * @internal */ __getOverridableFields(): { instructions: DynamicArgument; model: DynamicArgument | ModelFallbacks; tools: DynamicArgument; workspace: DynamicArgument; }; reorderModels(modelIds: string[]): void; updateModelInModelList({ id, model, enabled, maxRetries, }: { id: string; model?: DynamicArgument; enabled?: boolean; maxRetries?: number; }): void; /** * Registers logger primitives with the agent. * @internal */ __registerPrimitives(p: MastraPrimitives): void; /** * Registers the Mastra instance with the agent. * @internal */ __registerMastra(mastra: Mastra): void; /** * Set the concrete tools for the agent * @param tools * @internal */ __setTools(tools: DynamicArgument): void; /** * Create a lightweight clone of this agent that can be independently mutated * without affecting the original instance. Used by the editor to apply * version overrides without mutating the singleton agent. * @internal */ __fork(): Agent; generateTitleFromUserMessage({ message, requestContext, model, instructions, ...rest }: { message: string | MessageInput; requestContext?: RequestContext; model?: DynamicArgument; instructions?: DynamicArgument; } & Partial): Promise; getMostRecentUserMessage(messages: Array): UIMessage | UIMessageWithMetadata | undefined; genTitle(userMessage: string | MessageInput | undefined, requestContext: RequestContext, observabilityContext: ObservabilityContext, model?: DynamicArgument, instructions?: DynamicArgument): Promise; __setMemory(memory: DynamicArgument): void; __setWorkspace(workspace: DynamicArgument): void; /** * Retrieves and converts memory tools to CoreTool format. * @internal */ private listMemoryTools; /** * Lists workspace tools if a workspace is configured. * @internal */ private listWorkspaceTools; /** * Returns tools provided by the agent's channels (e.g. discord_send_message). * @internal */ private listChannelTools; /** * Returns skill tools (skill, skill_search, skill_read) when the workspace * has skills configured. These are added at the Agent level (like workspace * tools) rather than inside a processor, so they persist across turns and * survive serialization across tool-approval pauses. * @internal */ private listSkillTools; /** * Lists browser tools if a browser is configured. * @internal */ private listBrowserTools; /** * Executes input processors on the message list before LLM processing. * @internal */ private __runInputProcessors; /** * Runs processInputStep phase on input processors. * Used by legacy path to execute per-step input processing (e.g., Observational Memory) * that would otherwise only run in the v5 agentic loop. * @internal */ private __runProcessInputStep; /** * Executes output processors on the message list after LLM processing. * @internal */ private __runOutputProcessors; /** * Fetches remembered messages from memory for the current thread. * @internal */ private getMemoryMessages; /** * Retrieves and converts assigned tools to CoreTool format. * @internal */ private listAssignedTools; /** * Retrieves and converts toolset tools to CoreTool format. * @internal */ private listToolsets; /** * Retrieves and converts client-side tools to CoreTool format. * @internal */ private listClientTools; /** * Strips tool parts from messages. * * When a supervisor delegates to a sub-agent, the parent's conversation * history may include tool_call parts for its own delegation tools * (agent-* and workflow-*) and other tools. The sub-agent doesn't have these tools, * so sending references to them causes model providers to reject or * mishandle the request. * * This function removes those parts while preserving all other * conversation context (user messages, assistant text, etc.). * @internal */ private stripParentToolParts; /** * Retrieves and converts agent tools to CoreTool format. * @internal */ private listAgentTools; /** * Retrieves and converts workflow tools to CoreTool format. * @internal */ private listWorkflowTools; /** * Assembles all tools from various sources into a unified CoreTool dictionary. * @internal */ private convertTools; /** * Formats and validates tool names to comply with naming restrictions. * @internal */ private formatTools; /** * Adds response messages from a step to the MessageList and schedules persistence. * This is used for incremental saving: after each agent step, messages are added to a save queue * and a debounced save operation is triggered to avoid redundant writes. * * @param result - The step result containing response messages. * @param messageList - The MessageList instance for the current thread. * @param threadId - The thread ID. * @param memoryConfig - The memory configuration for saving. * @param runId - (Optional) The run ID for logging. * @internal */ private saveStepMessages; /** * Resolves scorer name references to actual scorer instances from Mastra. * @internal */ private resolveOverrideScorerReferences; /** * Resolves and prepares model configurations for the LLM. * @internal */ private prepareModels; /** * Executes a network loop where multiple agents can collaborate to handle messages. * The routing agent delegates tasks to appropriate sub-agents based on the conversation. * * @experimental * * @example * ```typescript * const result = await agent.network('Find the weather in Tokyo and plan an activity', { * memory: { * thread: 'user-123', * resource: 'my-app' * }, * maxSteps: 10 * }); * * for await (const chunk of result.stream) { * console.log(chunk); * } * ``` */ network(messages: MessageListInput, options?: MultiPrimitiveExecutionOptions): Promise>; network(messages: MessageListInput, options?: MultiPrimitiveExecutionOptions): Promise>; /** * Resumes a suspended network loop where multiple agents can collaborate to handle messages. * The routing agent delegates tasks to appropriate sub-agents based on the conversation. * * @experimental * * @example * ```typescript * const result = await agent.resumeNetwork({ approved: true }, { * runId: 'previous-run-id', * memory: { * thread: 'user-123', * resource: 'my-app' * }, * maxSteps: 10 * }); * * for await (const chunk of result.stream) { * console.log(chunk); * } * ``` */ resumeNetwork(resumeData: any, options: Omit & { runId: string; }): Promise>; /** * Approves a pending network tool call and resumes execution. * Used when `tool.requireApproval` is enabled to allow the agent to proceed with a tool call. * * @example * ```typescript * const stream = await agent.approveNetworkToolCall({ * runId: 'pending-run-id' * }); * * for await (const chunk of stream) { * console.log(chunk); * } * ``` */ approveNetworkToolCall(options: Omit & { runId: string; }): Promise>; /** * Declines a pending network tool call and resumes execution. * Used when `tool.requireApproval` is enabled to allow the agent to proceed with a tool call. * * @example * ```typescript * const stream = await agent.declineNetworkToolCall({ * runId: 'pending-run-id' * }); * * for await (const chunk of stream) { * console.log(chunk); * } * ``` */ declineNetworkToolCall(options: Omit & { runId: string; }): Promise>; generate, T extends InferStandardSchemaOutput = InferStandardSchemaOutput>(messages: MessageListInput, options: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; } & { model?: DynamicArgument; }): Promise>; generate(messages: MessageListInput, options: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; } & { model?: DynamicArgument; }): Promise>; generate(messages: MessageListInput, options: AgentExecutionOptionsBase & { structuredOutput?: never; } & { model?: DynamicArgument; }): Promise>; generate(messages: MessageListInput): Promise>; stream, T extends InferStandardSchemaOutput = InferStandardSchemaOutput>(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; } & { model?: DynamicArgument; }): Promise>; stream(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; } & { model?: DynamicArgument; }): Promise>; stream(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase & { structuredOutput?: never; } & { model?: DynamicArgument; }): Promise>; stream(messages: MessageListInput): Promise>; /** * Resumes a previously suspended stream execution. * Used to continue execution after a suspension point (e.g., tool approval, workflow suspend). * * @example * ```typescript * // Resume after suspension * const stream = await agent.resumeStream( * { approved: true }, * { runId: 'previous-run-id' } * ); * ``` */ resumeStream, T extends InferStandardSchemaOutput = InferStandardSchemaOutput>(resumeData: any, streamOptions: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; toolCallId?: string; } & { model?: DynamicArgument; }): Promise>; resumeStream(resumeData: any, streamOptions: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; toolCallId?: string; } & { model?: DynamicArgument; }): Promise>; resumeStream(resumeData: any, streamOptions: AgentExecutionOptionsBase & { structuredOutput?: never; toolCallId?: string; } & { model?: DynamicArgument; }): Promise>; /** * Resumes a previously suspended generate execution. * Used to continue execution after a suspension point (e.g., tool approval, workflow suspend). * * @example * ```typescript * // Resume after suspension * const stream = await agent.resumeGenerate( * { approved: true }, * { runId: 'previous-run-id' } * ); * ``` */ resumeGenerate, T extends InferStandardSchemaOutput = InferStandardSchemaOutput>(resumeData: any, options: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; toolCallId?: string; } & { model?: DynamicArgument; }): Promise>; resumeGenerate(resumeData: any, options: AgentExecutionOptionsBase & { structuredOutput: PublicStructuredOutputOptions; toolCallId?: string; } & { model?: DynamicArgument; }): Promise>; resumeGenerate(resumeData: any, options: AgentExecutionOptionsBase & { structuredOutput?: never; toolCallId?: string; } & { model?: DynamicArgument; }): Promise>; /** * Approves a pending tool call and resumes execution. * Used when `requireToolApproval` is enabled to allow the agent to proceed with a tool call. * * @example * ```typescript * const stream = await agent.approveToolCall({ * runId: 'pending-run-id' * }); * * for await (const chunk of stream) { * console.log(chunk); * } * ``` */ approveToolCall(options: AgentExecutionOptions & { runId: string; toolCallId?: string; }): Promise>; /** * Declines a pending tool call and resumes execution. * Used when `requireToolApproval` is enabled to prevent the agent from executing a tool call. * * @example * ```typescript * const stream = await agent.declineToolCall({ * runId: 'pending-run-id' * }); * * for await (const chunk of stream) { * console.log(chunk); * } * ``` */ declineToolCall(options: AgentExecutionOptions & { runId: string; toolCallId?: string; }): Promise>; /** * Approves a pending tool call and returns the complete result (non-streaming). * Used when `requireToolApproval` is enabled with generate() to allow the agent to proceed. * * @example * ```typescript * const output = await agent.generate('Find user', { requireToolApproval: true }); * if (output.finishReason === 'suspended') { * const result = await agent.approveToolCallGenerate({ * runId: output.runId, * toolCallId: output.suspendPayload.toolCallId * }); * console.log(result.text); * } * ``` */ approveToolCallGenerate(options: AgentExecutionOptions & { runId: string; toolCallId?: string; }): Promise['getFullOutput']>>>; /** * Declines a pending tool call and returns the complete result (non-streaming). * Used when `requireToolApproval` is enabled with generate() to prevent tool execution. * * @example * ```typescript * const output = await agent.generate('Find user', { requireToolApproval: true }); * if (output.finishReason === 'suspended') { * const result = await agent.declineToolCallGenerate({ * runId: output.runId, * toolCallId: output.suspendPayload.toolCallId * }); * console.log(result.text); * } * ``` */ declineToolCallGenerate(options: AgentExecutionOptions & { runId: string; toolCallId?: string; }): Promise['getFullOutput']>>>; /** * Legacy implementation of generate method using AI SDK v4 models. * Use this method if you need to continue using AI SDK v4 models. * * @example * ```typescript * const result = await agent.generateLegacy('What is 2+2?'); * console.log(result.text); * ``` */ generateLegacy(messages: MessageListInput, args?: AgentGenerateOptions & { output?: never; experimental_output?: never; model?: DynamicArgument; }): Promise>; generateLegacy(messages: MessageListInput, args?: AgentGenerateOptions & { output?: OUTPUT; experimental_output?: never; model?: DynamicArgument; }): Promise>; generateLegacy(messages: MessageListInput, args?: AgentGenerateOptions & { output?: never; experimental_output?: EXPERIMENTAL_OUTPUT; model?: DynamicArgument; }): Promise>; /** * Legacy implementation of stream method using AI SDK v4 models. * Use this method if you need to continue using AI SDK v4 models. * * @example * ```typescript * const result = await agent.streamLegacy('Tell me a story'); * for await (const chunk of result.textStream) { * process.stdout.write(chunk); * } * ``` */ streamLegacy(messages: MessageListInput, args?: AgentStreamOptions & { output?: never; experimental_output?: never; model?: DynamicArgument; }): Promise>; streamLegacy(messages: MessageListInput, args?: AgentStreamOptions & { output?: OUTPUT; experimental_output?: never; model?: DynamicArgument; }): Promise & TracingProperties>; streamLegacy(messages: MessageListInput, args?: AgentStreamOptions & { output?: never; experimental_output?: EXPERIMENTAL_OUTPUT; model?: DynamicArgument; }): Promise & { partialObjectStream: StreamTextResult['experimental_partialOutputStream']; }>; /** * Resolves the configuration for title generation. * @internal */ resolveTitleGenerationConfig(generateTitleConfig: boolean | { model?: DynamicArgument; instructions?: DynamicArgument; minMessages?: number; } | undefined): { shouldGenerate: boolean; model?: DynamicArgument; instructions?: DynamicArgument; minMessages?: number; }; /** * Resolves title generation instructions, handling both static strings and dynamic functions * @internal */ resolveTitleInstructions(requestContext: RequestContext, instructions?: DynamicArgument): Promise; } export {}; //# sourceMappingURL=agent.d.ts.map