UNPKG

@mastra/core

Version:
2,011 lines • 93.1 kB
import type { UIMessage } from '../_types/@internal_ai-sdk-v4@0.0.98/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 type { ActorSignal } from '../auth/ee/index.js';
import type { AgentBackgroundConfig } from '../background-tasks/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 type { PubSub } from '../events/pubsub.js';
import type { Knowledge } from '../knowledge/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 { ProviderOptions } from '../llm/model/provider-options.js';
import type { MastraLanguageModel, MastraLegacyLanguageModel, MastraModelConfig, WidenedMastraModelConfig } from '../llm/model/shared.types.js';
import type { Mastra } from '../mastra/index.js';
import type { MastraMemory } from '../memory/memory.js';
import type { MemoryConfig } from '../memory/types.js';
import type { NotificationDeliveryPolicyInput } from '../notifications/delivery-policy.js';
import type { NotificationDeliveryDecision, SendNotificationSignalInput } from '../notifications/types.js';
import type { DefinitionSource, TracingProperties, ObservabilityContext, TracingPolicy } from '../observability/index.js';
import type { ErrorProcessorOrWorkflow, InputProcessorOrWorkflow, LLMRequestProcessorOrWorkflow, OutputProcessorOrWorkflow, ProcessorWorkflow, Processor } from '../processors/index.js';
import { RequestContext } from '../request-context/index.js';
import type { DeclaredAgentSchedule } from '../schedules/define.js';
import type { InferStandardSchemaOutput } from '../schema/index.js';
import type { SignalProvider } from '../signals/signal-provider.js';
import type { GoalObjectiveRecord } from '../storage/domains/thread-state/base.js';
import type { ChunkType, MastraAgentNetworkStream, MastraOnFinishCallback } from '../stream/index.js';
import type { FullOutput, MastraModelOutput } from '../stream/base/output.js';
import type { CoreTool, ToolHooks, ToolPayloadTransformPolicy } from '../tools/types.js';
import type { DynamicArgument } from '../types/index.js';
import type { IMastraVoice } from '../voice/index.js';
import type { OutputWriter, WorkflowRunStatus } from '../workflows/types.js';
import type { AnyWorkflow } from '../workflows/workflow.js';
import type { AnyWorkspace } from '../workspace/index.js';
import type { Skill, SkillMetadata } from '../workspace/skills/types.js';
import type { AgentExecutionOptions, AgentExecutionOptionsBase, PublicAgentExecutionOptions, MultiPrimitiveExecutionOptions, NetworkOptions, DelegationConfig } from './agent.types.js';
import type { DurableAgentListActiveRunsOptions, DurableAgentListActiveRunsResult, DurableAgentRecoverActiveRunsOptions, DurableAgentRecoverActiveRunsResult, DurableAgentRecoverOptions, DurableAgentStreamOptions, DurableAgentStreamResult } from './durable/durable-agent.js';
import type { AgentSuspendedEventData, DurableAgentStepFinishResult } from './durable/types.js';
import { MessageList } from './message-list/index.js';
import type { MessageInput, MessageListInput, UIMessageWithMetadata, MastraDBMessage } from './message-list/index.js';
import type { PendingSignalListener, AgentSignalInput, CreatedAgentSignal } from './signals.js';
import { AgentStreamBus } from './streams/bus.js';
import type { AgentRunRecord } from './streams/run-records.js';
import type { SubAgent } from './subagent.js';
import type { ActiveThreadRun } from './thread-stream-runtime.js';
import type { AgentClaimThreadPeerOptions, AgentAbortThreadOptions, AgentConfig, AgentUpdateThreadPeerOptions, AgentDurableOption, AgentGenerateOptions, AgentNotificationConfig, GoalConfig, AgentStreamOptions, ToolsetsInput, ToolsInput, AgentModelManagerConfig, AgentEditorConfig, AgentInstructions, AgentMessageInput, AgentMethodType, AgentSignal, AgentStateSignalInput, AgentSubscribeToThreadOptions, AgentThreadIdentityOptions, AgentThreadPeerAdvertisement, AgentThreadSubscription, DiscoverAgentThreadPeersOptions, CancelQueuedAgentMessagesOptions, CancelQueuedAgentMessagesResult, AgentThreadEventListener, SubscribeAgentThreadEventsOptions, PublicStructuredOutputOptions, QueueAgentMessageOptions, QueueAgentMessageResult, QueueAgentSignalOptions, QueueAgentSignalResult, SendAgentMessageOptions, SendAgentMessageResult, SendAgentNotificationSignalOptions, SendAgentNotificationSignalResult, SendAgentSignalOptions, SendAgentSignalResult, SendAgentStateSignalOptions, SendAgentStateSignalResult, SendAgentStreamResumeOptions, SendAgentStreamResumeResult, ModelFallbackSettings, ModelWithRetries, ZodSchema } from './types.js';
export type MastraLLM = MastraLLMV1 | MastraLLMVNext;
/**
 * How long a resume claim may go without a sign of life before a later resume treats it as
 * abandoned by a process that died, and takes the suspension over: a `pending` claim (claimed but
 * not started) since it was claimed, a `running` claim (on stores with run fencing) since its
 * lease was last renewed.
 */
export declare const AGENT_RESUME_CLAIM_STALE_MS = 60000;
type ModelFallbacks = {
    id: string;
    model: DynamicArgument<WidenedMastraModelConfig>;
    maxRetries: number;
    maxRetriesConfigured: boolean;
    enabled: boolean;
    modelSettings?: DynamicArgument<ModelFallbackSettings>;
    providerOptions?: DynamicArgument<ProviderOptions>;
    headers?: DynamicArgument<Record<string, string>>;
}[];
type AgentSnapshotMemoryInfo = {
    threadId?: string;
    resourceId?: string;
};
/**
 * A suspended tool call inside a suspended agent run — either waiting on a
 * tool-call approval (`requireApproval` / `requireToolApproval`) or on resume
 * data for a tool that called `suspend()`.
 */
export interface AgentRunToolCall {
    toolCallId?: string;
    toolName?: string;
    /** Arguments the model supplied for the tool call (approval suspensions only). */
    args?: unknown;
    /** True when the run is waiting on a tool-call approval. */
    requiresApproval: boolean;
    /** The tool-defined suspend payload when the tool itself called `suspend()`. */
    suspendPayload?: unknown;
}
/**
 * Statuses of agent runs discoverable via {@link Agent.listSuspendedRuns}.
 *
 * Agent run snapshots are only persisted while a run is waiting on input and
 * are deleted when the run reaches a terminal state, so `'suspended'` is the
 * only status discoverable from storage today.
 */
export type AgentRunStatus = Extract<WorkflowRunStatus, 'suspended'>;
/**
 * Filters for {@link Agent.listSuspendedRuns}. Mirrors the `listWorkflowRuns`
 * filter contract, plus the agent-level `threadId` filter.
 */
export interface AgentListSuspendedRunsOptions {
    /** Only return runs that belong to this memory thread. */
    threadId?: string;
    /** Only return runs that belong to this memory resource. */
    resourceId?: string;
    /** Only return runs created at or after this date. */
    fromDate?: Date;
    /** Only return runs created at or before this date. */
    toDate?: Date;
    /**
     * Number of items per page. Pagination is applied when both `perPage` and
     * `page` are provided; otherwise all matching runs are returned.
     */
    perPage?: number;
    /** Zero-indexed page number. */
    page?: number;
}
/**
 * An agent run discovered from workflow snapshot storage.
 */
export interface AgentRun {
    /** Run ID accepted by `resumeStream()`, `approveToolCall()`, and `declineToolCall()`. */
    runId: string;
    status: AgentRunStatus;
    threadId?: string;
    resourceId?: string;
    /** When the run's snapshot was last persisted (i.e. when it suspended). */
    suspendedAt: Date;
    /** Suspended tool calls awaiting approval or resume data. */
    toolCalls: AgentRunToolCall[];
}
export interface AgentListSuspendedRunsResult {
    runs: AgentRun[];
    /** Total number of matching runs, before pagination. */
    total: number;
}
/**
 * Creates an AI agent that generates and streams responses, with optional tools,
 * memory, and voice capabilities.
 *
 * Configure resumable streams with `durable`. For checkpoint-backed durable
 * execution, explicitly wrap the agent with `createDurableAgent`.
 *
 * @example
 * `yourModel` is your configured model.
 * ```typescript
 * import { Agent } from '@mastra/core/agent';
 *
 * const agent = new Agent({
 *   id: 'assistant',
 *   name: 'Assistant',
 *   instructions: 'You are a helpful assistant.',
 *   model: yourModel,
 * });
 * ```
 *
 * @see For documentation bundled with your installed package, locate
 * `@mastra/core/package.json` with your project's resolver or package-manager
 * tooling, then read `dist/docs/SKILL.md` from that package root and follow its
 * reference links. Use package-manager tools for virtual or archived packages.
 *
 * @see [Agent documentation](https://mastra.ai/docs/agents/overview)
 * if packaged docs are unavailable.
 */
export declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TOutput = undefined, 
/**
 * Defaults to `any` (not `unknown`) so agents that declare a `requestContextSchema`
 * remain assignable to the bare `Agent` type. `TRequestContext` is invariant on
 * `Agent` (it appears in both parameter and return positions via `DynamicArgument`
 * / private fields), so a schema-narrowed agent is not assignable to
 * `Agent<..., unknown>` — which broke generic helpers typed as `(agent: Agent) => ...`.
 *
 * Construction without a schema still infers a concrete context from
 * `requestContextSchema` when present; the `any` default only affects the
 * unparameterized `Agent` alias used for "any agent" acceptors.
 */
TRequestContext extends Record<string, any> | unknown = any, TEditor extends AgentEditorConfig | undefined = AgentEditorConfig | undefined> extends MastraBase implements SubAgent<TAgentId, TRequestContext> {
    #private;
    id: TAgentId;
    name: string;
    source?: DefinitionSource;
    model: DynamicArgument<MastraModelConfig | ModelWithRetries[], TRequestContext> | 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<TAgentId, TTools, TOutput, TRequestContext, TEditor>);
    getMastraInstance(): Mastra<Record<string, Agent<any, ToolsInput, undefined, any, AgentEditorConfig | undefined>>, Record<string, AnyWorkflow>, Record<string, import("../vector").MastraVector<any>>, Record<string, import("../tts").MastraTTS>, import("../_types/@internal_core@0.1.4/dist/logger/index.js").IMastraLogger, Record<string, import("../mcp").MCPServerBase<any>>, Record<string, MastraScorer<any, any, any, any>>, Record<string, import("../tools").ToolAction<any, any, any, any, any, any, unknown>>, Record<string, Processor<any, unknown>>, Record<string, MastraMemory>, Record<string, import("../channels").ChannelProvider>, Record<string, import("../classifier").Classifier<any>>, Record<string, Knowledge>> | undefined;
    /** @internal */
    __inheritMastraForFork(mastra: Mastra): void;
    /** @internal */
    __getNotificationConfig(): AgentNotificationConfig | undefined;
    getPubSub(): PubSub | undefined;
    hasOwnPubSub(): boolean;
    /**
     * Returns the background tasks configuration for this agent.
     */
    getBackgroundTasksConfig(): AgentBackgroundConfig | undefined;
    /**
     * Returns the agent-level tool payload transform policy, if any.
     * Used by durable execution to mirror the non-durable layer's
     * per-call → agent → mastra merge order.
     */
    getToolPayloadTransform(): ToolPayloadTransformPolicy | undefined;
    /**
     * Returns the agent's native goal configuration, if any. Read by the loop's
     * goal step to resolve effective settings (judge model, max runs, prompt).
     * @internal
     */
    __getGoalConfig(): GoalConfig | undefined;
    /**
     * Whether `maxRetries` was explicitly configured on this agent. Durable
     * preparation serializes this alongside `maxRetries` so the llm-execution
     * step's retry ladder can apply the same precedence as the in-process loop:
     * an explicitly configured agent value (including 0) beats call-time
     * `modelSettings.maxRetries`; otherwise the call-time value wins.
     * @internal
     */
    __getMaxRetriesConfigured(): boolean;
    /**
     * The agent-level `maxProcessorRetries`. Durable preparation uses it as the
     * default when the call doesn't pass one, matching the in-process loop.
     * @internal
     */
    __getMaxProcessorRetries(): number | undefined;
    /**
     * Returns a closure that drains pending signals for a given run from the
     * shared `AgentThreadStreamRuntime`. Used by `prepareForDurableExecution` to
     * store the drain function on the in-process `RunRegistryEntry`.
     * @internal
     */
    __getDrainPendingSignals(): (runId: string, scope?: 'pending' | 'pre-run') => CreatedAgentSignal[];
    /**
     * Returns a closure that queues a signal on a durable run through
     * `sendSignal`, so the run's drain delivers it to the next model request.
     * @internal
     */
    __getEnqueuePendingSignal(): (target: {
        runId: string;
        resourceId?: string;
        threadId?: string;
    }, signalInput: AgentSignalInput) => Promise<CreatedAgentSignal>;
    /** @internal */
    __getSubscribePendingSignals(): (runId: string, listener: PendingSignalListener) => () => void;
    /** @internal Read one JSON-safe request-context value captured in a suspended run snapshot. */
    __getSuspendedRunRequestContextValue({ runId, key }: {
        runId: string;
        key: string;
    }): Promise<unknown>;
    /**
     * Registers the agent the shared `AgentThreadStreamRuntime` calls back into
     * for this agent's signal, message, and subscription APIs. The runtime starts
     * idle threads with `agent.stream()`, so the agent it addresses decides the
     * execution path. `DurableAgent` subclasses `Agent`, so `this` is already the
     * durable entry point. The Inngest wrapper is a Proxy over a plain object that
     * forwards these methods to the wrapped agent; without this hook a signal that
     * wakes an idle thread would run through the wrapped agent's in-process
     * `stream()` instead of the durable one.
     * @internal
     */
    __setThreadRuntimeAgent(agent: Agent<any, any, any, any>): void;
    /**
     * Returns the uncombined processors suitable for `processLLMRequest`: the input processors plus the
     * resolved error-phase processors, so an error-lane `ProviderHistoryCompat` also gets its prompt rules.
     * Combined (workflow-wrapped) processors skip `processLLMRequest`; this
     * method returns them individually so the `ProcessorRunner` can invoke
     * each processor's `processLLMRequest` method.
     * @internal — used by `DurableAgent` preparation to populate the registry.
     */
    __listLLMRequestProcessors(requestContext?: RequestContext, errorProcessorOverrides?: ErrorProcessorOrWorkflow[]): Promise<LLMRequestProcessorOrWorkflow[]>;
    /**
     * Set the durable objective for a thread. The objective is judged in the
     * execution loop until complete or the run budget is exhausted. Requires a
     * memory-backed thread and a Mastra storage instance; no-ops otherwise.
     *
     * Only the optional fields explicitly provided are persisted into the
     * objective record; unset fields fall back to the agent's `goal` config at
     * evaluation time. A judge model (here or in `goal.judge`) is required for the
     * goal to do anything.
     */
    setObjective(objective: string, options: {
        threadId: string;
        resourceId?: string;
        judgeModelId?: string;
        maxRuns?: number;
        prompt?: string;
        id?: string;
        activeDurationMs?: number;
    }): Promise<GoalObjectiveRecord | undefined>;
    /**
     * Read the current objective record for a thread, or `undefined` when none is
     * set (or the agent has no storage).
     */
    getObjective(options: {
        threadId: string;
    }): Promise<GoalObjectiveRecord | undefined>;
    /**
     * Drop the objective for a thread.
     */
    clearObjective(options: {
        threadId: string;
    }): Promise<void>;
    /**
     * Partially update the options of the active objective. Only provided fields
     * are persisted into the record (so the precedence over agent config is
     * remembered in thread state). No-ops when no objective is set.
     *
     * `pausedReason` lasts for one pause: it's cleared when the goal leaves
     * paused, or when a goal moves into paused from another status without a new
     * reason. A supplied reason replaces the stored one.
     */
    updateObjectiveOptions(options: {
        threadId: string;
        judgeModelId?: string;
        maxRuns?: number;
        prompt?: string;
        status?: GoalObjectiveRecord['status'];
        pausedReason?: string;
    }): Promise<GoalObjectiveRecord | undefined>;
    /**
     * Returns the statically-configured sub-agents without executing dynamic
     * resolvers. Used by Mastra at registration time to detect whether background
     * tasks should be auto-enabled. Returns undefined when sub-agents are
     * configured via a function (those get resolved per-request).
     * @internal
     */
    __getStaticAgents(): Record<string, SubAgent> | undefined;
    /**
     * True when this agent has any sub-agent registry configured — either a
     * static record with entries OR a dynamic (function-based) resolver.
     * Used by Mastra at registration time to decide whether to auto-enable
     * background tasks; we can't know what a function resolver will return
     * at request time, so we enable defensively.
     * @internal
     */
    __hasSubAgentsConfigured(): boolean;
    /**
     * Disables background task dispatch for this agent. Every tool call will run
     * synchronously in the agentic loop, regardless of the agent's or tools'
     * background configuration.
     *
     * Useful when this agent is invoked as a sub-agent and the parent has wrapped
     * the entire sub-agent invocation as a background task — you don't want the
     * sub-agent's own tools to also dispatch separate background tasks inside it.
     */
    disableBackgroundTasks(): void;
    /**
     * Re-enables background task dispatch after it has been disabled.
     */
    enableBackgroundTasks(): void;
    /**
     * Inspects a sub-agent (a child agent invoked as a tool) and derives a
     * ToolBackgroundConfig if any of its tools are background-eligible OR if the
     * sub-agent itself has a background tasks config that enables tools.
     *
     * Returns undefined when no background dispatch is warranted, so the parent
     * runs the sub-agent synchronously.
     *
     * @internal
     */
    private deriveSubAgentBackgroundConfig;
    /**
     * Returns the AgentChannels instance that manages all channel adapters.
     * Returns null if no channels are configured.
     */
    getChannels(): AgentChannels | null;
    /**
     * Returns the signal providers connected to this agent.
     */
    listSignalProviders(): SignalProvider[];
    /**
     * Sets the AgentChannels instance for this agent.
     * Used by ChannelProvider implementations to inject the channels they create.
     * @internal
     */
    setChannels(agentChannels: AgentChannels): void;
    /**
     * 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;
    /**
     * The `durable` option this agent was constructed with, if any.
     *
     * Controls resumable streams only. See {@link AgentDurableOption}.
     */
    get durable(): AgentDurableOption | undefined;
    /**
     * The resumable stream layer runs of this agent publish on, or `undefined`
     * when streams are off. See {@link AgentConfig.durable}.
     *
     * @internal
     */
    __getStreamBus(force?: boolean): AgentStreamBus | undefined;
    /** Whether run frames are published by workers on Mastra's shared log. @internal */
    __usesSharedRunLog(): boolean;
    /** Whether this class executes through the plain Agent publisher. @internal */
    protected __ownsPlainStreamPublisher(): boolean;
    /**
     * Whether runs of this agent can be followed from another reader with
     * `observe()` (or the server's observe route): true when its runs publish
     * on a stream topic, which is the case for durable agents and for agents
     * with streams on. See {@link AgentConfig.durable}.
     */
    hasResumableStreams(): boolean;
    /**
     * Owner of a run executing in this process, or undefined. DurableAgent
     * overrides this with its run registry.
     * @internal
     */
    __getRunOwner(runId: string): {
        resourceId?: string;
        threadId?: string;
    } | undefined;
    /**
     * The shared ownership record of a published run (see
     * `streams/run-records.ts`), from any process sharing this agent's record
     * cache: running, suspended, or finished and still replayable. Undefined when
     * the run is unknown, expired, or streams are off. Rejects when the record
     * cache cannot be read, so the server refuses instead of guessing.
     * @internal Used by the server's observe and run abort routes.
     */
    __getRunRecord(runId: string): Promise<AgentRunRecord | undefined>;
    /**
     * Owner of a published run executing in this process, or undefined when the
     * run is not running here. Lets the server authorize run-scoped aborts for
     * agents without durable run storage.
     * @internal
     */
    __getPublishedRunOwner(runId: string): {
        resourceId?: string;
        threadId?: string;
    } | undefined;
    /**
     * Ask whichever process runs `runId` to abort it, over the run's control
     * topic. Best-effort: a failed publish is logged, and a request nobody hears
     * is a no-op, like aborting a finished run.
     */
    protected requestRemoteAbort(runId: string, bus?: AgentStreamBus | undefined): Promise<void>;
    /**
     * 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 AgentController to avoid overwriting agent-level browser configuration.
     */
    hasOwnBrowser(): boolean;
    /**
     * Resolves the combined WorkspaceSkills from agent-level skills and/or workspace skills.
     * Agent-level skills win on name conflicts when both are present.
     * @internal
     */
    private resolveSkills;
    /**
     * Gets the skills processors to add to input processors when skills are configured.
     * Supports both agent-level skills and workspace 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<string, SubAgent<string, TRequestContext>> | Promise<Record<string, SubAgent<string, TRequestContext>>>;
    /**
     * Resolves a run's error processors once: the list the error lane runs (call-time `overrides`,
     * otherwise the configured list merged with the defaults, plus the memory's error processors
     * either way) and whether the caller
     * configured any themselves. A dynamic `errorProcessors` function is invoked at most once, so
     * the request lane, the error lane and the retry-cap warning all see the same instances.
     * @internal
     */
    __resolveRunErrorProcessors(requestContext: RequestContext, overrides?: ErrorProcessorOrWorkflow[]): Promise<{
        errorProcessors: ErrorProcessorOrWorkflow[];
        hasConfiguredErrorProcessors: boolean;
    }>;
    /**
     * 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 input processors from agent configuration in execution order.
     * @internal
     */
    private resolveInputProcessors;
    /**
     * Resolves and returns input processors from agent configuration.
     * All processors are combined into a single workflow for consistency.
     * @internal
     */
    private listResolvedInputProcessors;
    /**
     * Resolves and returns input processors for the provider-boundary LLM request hook.
     * These processors stay uncombined because processLLMRequest runs after conversion to model prompt format.
     *
     * Error-phase processors are included, so a `ProviderHistoryCompat` placed only in `errorProcessors`
     * still receives `processLLMRequest`. Processors without that method are inert here, and processor
     * workflows are skipped because `runProcessLLMRequest` skips them too.
     * @internal
     */
    private listResolvedLLMRequestProcessors;
    /**
     * Returns the input processors for this agent, resolving function-based processors if necessary.
     */
    listInputProcessors(requestContext?: RequestContext): Promise<InputProcessorOrWorkflow[]>;
    /**
     * Returns the output processors for this agent, resolving function-based processors if necessary.
     */
    listOutputProcessors(requestContext?: RequestContext): Promise<OutputProcessorOrWorkflow[]>;
    /**
     * Returns the error processors for this agent: your configured list plus whichever shared
     * stability defaults it does not already name. A configured processor whose id matches a default
     * means that default is not added again. Each added default is placed at the position its id gives
     * it, so the defaults keep their relative order even when you name only one of them — the two
     * processors that repair a request stay ahead of the retry processor, which would otherwise resend
     * a request they could have fixed. An empty configured list resolves to the defaults; with
     * `errorProcessorDefaults: false` only the configured list is returned.
     */
    listErrorProcessors(requestContext?: RequestContext): Promise<ErrorProcessorOrWorkflow[]>;
    /**
     * 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<TId extends string = string>(processorId: TId, requestContext?: RequestContext): Promise<Processor<TId> | 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<InputProcessorOrWorkflow[]>;
    /**
     * 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<OutputProcessorOrWorkflow[]>;
    /**
     * Returns the IDs of the raw configured error processors, without combining
     * them into workflows and without the framework defaults. Unlike
     * `getConfiguredProcessorIds` this resolves only the error lane, so a
     * rejecting input or output processor resolver cannot block the caller.
     */
    getConfiguredErrorProcessorIds(requestContext?: RequestContext): Promise<string[]>;
    /**
     * 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<ProcessorWorkflow[]>;
    hasOwnMemory(): boolean;
    /**
     * Whether the agent's memory is a fixed instance, so it resolves to the same
     * store on every call. Function memory and memory inherited from a delegating
     * agent depend on the request context, which a resume may not repeat.
     * @internal
     */
    __hasFixedMemory(): 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<MastraMemory | undefined>;
    /**
     * Checks if this agent has its own workspace configured.
     *
     * @example
     * ```typescript
     * if (agent.hasOwnWorkspace()) {
     *   const workspace = await agent.getWorkspace();
     * }
     * ```
     */
    hasOwnWorkspace(): boolean;
    /**
     * The Knowledge attached to this agent, resolving a registered key through Mastra.
     * @experimental
     */
    getKnowledge(): Knowledge | undefined;
    /**
     * 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<AnyWorkspace | undefined>;
    /**
     * Programmatically invoke a skill by name.
     *
     * Loads the full skill instructions and returns them, or returns the skill
     * object directly. This is the programmatic equivalent of the `skill` tool
     * that the LLM calls — useful in workflows and custom pipelines.
     *
     * @param skillName - Name or path of the skill to invoke
     * @param options - Optional request context for dynamic skill resolution
     * @returns The full Skill object with instructions, or null if not found
     *
     * @example
     * ```typescript
     * // In a workflow step
     * const skill = await agent.getSkill('code-review');
     * if (skill) {
     *   console.log(skill.instructions); // Full skill instructions
     *   console.log(skill.references);   // Available reference files
     * }
     * ```
     */
    getSkill(skillName: string, options?: {
        requestContext?: RequestContext;
    }): Promise<Skill | null>;
    /**
     * List all skills available to this agent (from both agent-level and workspace).
     *
     * @param options - Optional request context for dynamic skill resolution
     * @returns Array of skill metadata (name, description, path)
     *
     * @example
     * ```typescript
     * const skills = await agent.listSkills();
     * for (const skill of skills) {
     *   console.log(`${skill.name}: ${skill.description}`);
     * }
     * ```
     */
    listSkills(options?: {
        requestContext?: RequestContext;
    }): Promise<SkillMetadata[]>;
    get voice(): IMastraVoice<unknown, unknown, import("../_types/@internal_voice@0.0.47/dist/index.js").ToolsInput, import("../_types/@internal_voice@0.0.47/dist/index.js").VoiceEventMap, unknown>;
    /**
     * 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<TRequestContext> | 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<Record<string, AnyWorkflow>>;
    /**
     * Applies the agent's `scopes` option to a run's incoming scopes and returns the run's scopes:
     * the incoming ones when the option is unset, the incoming ones plus the static list, or what
     * the function returns for them. `scopes` defaults to none.
     */
    getScopes({ requestContext, scopes, }?: {
        requestContext?: RequestContext;
        scopes?: string[];
    }): Promise<string[]>;
    listScorers({ requestContext, }?: {
        requestContext?: RequestContext;
    }): Promise<MastraScorers>;
    /**
     * Gets the voice instance for this agent with tools and instructions configured.
     * The voice instance enables text-to-speech and speech-to-text capabilities.
     *
     * When `voice` is configured as a resolver (`({ requestContext }) => new SomeVoice(...)`),
     * each call resolves a fresh, session-owned instance. The resolver is responsible for
     * configuring its own tools/instructions/request context, so this method does not mutate
     * the resolved instance. The caller owns the lifecycle (e.g. `disconnect()`) of that instance.
     *
     * A static voice instance is shared across calls and is configured with the current
     * tools/instructions on each call (appropriate for one-shot TTS).
     *
     * @example
     * ```typescript
     * const voice = await agent.getVoice();
     * const audioStream = await voice.speak('Hello world');
     * ```
     */
    getVoice({ requestContext }?: {
        requestContext?: RequestContext;
    }): Promise<IMastraVoice<unknown, unknown, import("../_types/@internal_voice@0.0.47/dist/index.js").ToolsInput, import("../_types/@internal_voice@0.0.47/dist/index.js").VoiceEventMap, unknown>>;
    /**
     * 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<AgentInstructions>;
    private getMcpServerGuidance;
    /**
     * Returns the description of the agent.
     *
     * @example
     * ```typescript
     * const description = agent.getDescription();
     * console.log(description); // 'A helpful weather assistant'
     * ```
     */
    getDescription(): string;
    /**
     * Attach the schedules declared under `agents/<id>/schedules/`. Called by
     * `assembleAgentFromFsEntry` during file-based agent assembly.
     *
     * @internal — not part of the public agent API.
     */
    __setDeclaredSchedules(schedules: DeclaredAgentSchedule[]): void;
    /**
     * Returns the schedules declared by this agent's `schedules/` directory, in
     * stable (path-sorted) order. Mastra syncs these into schedule storage at
     * boot; see `registerDeclarativeSchedules`.
     */
    getDeclaredSchedules(): DeclaredAgentSchedule[];
    /**
     * Returns the tracing policy configured at agent construction time.
     *
     * Exposed so out-of-process consumers (e.g. the durable agent runner) can
     * forward the same policy onto AGENT_RUN spans without reaching into private
     * fields.
     */
    getTracingPolicy(): TracingPolicy | undefined;
    /**
     * Gets the metadata for this agent, resolving function-based metadata if necessary.
     * Metadata is a classification bag for clients and is never read by the agent runtime.
     *
     * @example
     * ```typescript
     * const metadata = await agent.getMetadata();
     * console.log(metadata?.type); // 'support'
     * ```
     */
    getMetadata({ requestContext }?: {
        requestContext?: RequestContext;
    }): Record<string, unknown> | undefined | Promise<Record<string, unknown> | undefined>;
    /**
     * 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<AgentGenerateOptions>;
    /**
     * 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<AgentStreamOptions>;
    /** @internal Validate context-independent timeout settings without invoking dynamic defaults. */
    __validateStaticModelTimeoutSettings(modelSettings?: AgentExecutionOptions<TOutput>['modelSettings']): void;
    /**
     * 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;
    }): PublicAgentExecutionOptions<TOutput> | Promise<PublicAgentExecutionOptions<TOutput>>;
    /**
     * 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<NetworkOptions>;
    /**
     * 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, resolveWebSearch, }?: {
        requestContext?: RequestContext;
        resolveWebSearch?: boolean;
    }): Promise<TTools>;
    /**
     * 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<MastraModelConfig, TRequestContext>;
    }): MastraLLM | Promise<MastraLLM>;
    /**
     * 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;
    /**
     * Builds a single normalized fallback entry from a user-supplied `ModelWithRetries`.
     * Shared by the constructor and `normalizeModelFallbacks` to keep the mapping in one place.
     * @internal
     */
    private static toFallbackEntry;
    /**
     * 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;
    private resolveModelFromSelection;
    /**
     * 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<MastraModelConfig | ModelWithRetries[], TRequestContext> | ModelFallbacks;
    }): MastraLanguageModel | MastraLegacyLanguageModel | Promise<MastraLanguageModel | MastraLegacyLanguageModel>;
    /**
     * 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<Array<AgentModelManagerConfig> | null>;
    /** @internal */
    __getModelAndModelList({ requestContext, model: modelOverride, }?: {
        requestContext?: RequestContext;
        /** Per-call model override (`stream(msgs, { model })`). */
        model?: Parameters<Agent['resolveModelSelection']>[0];
    }): Promise<{
        model: MastraLanguageModel | MastraLegacyLanguageModel;
        modelList: Array<AgentModelManagerConfig> | null;
        fallbackTimeouts: Array<ModelFallbackSettings['timeout'] | undefined>;
    }>;
    /**
     * Updates the agent's instructions.
     * @internal
     */
    __updateInstructions(newInstructions: DynamicArgument<AgentInstructions, any>): void;
    /**
     * Updates the agent's model configuration.
     * @internal
     */
    __updateModel({ model }: {
        model: DynamicArgument<MastraModelConfig, TRequestContext> | 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 the editor ownership config for this agent.
     * @internal
     */
    __getEditorConfig(): AgentEditorConfig | undefined;
    /**
     * 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<import("../llm").SystemMessage, TRequestContext>;
        model: ModelFallbacks | DynamicArgument<ModelWithRetries[] | MastraModelConfig, TRequestContext>;
        tools: DynamicArgument<TTools, TRequestContext>;
        workspace: DynamicArgument<AnyWorkspace | undefined, TRequestContext>;
    };
    /**
     * Reorders a static model list. Returns false when `model` is not an array (including
     * function-valued models, whose selection is resolved per request and cannot be edited in place).
     */
    reorderModels(modelIds: string[]): boolean;
    updateModelInModelList({ id, model, enabled, maxRetries, }: {
        id: string;
        model?: DynamicArgument<MastraModelConfig>;
        enabled?: boolean;
        maxRetries?: number;
    }): boolean;
    /**
     * Returns the logger registered with the agent.
     * @internal
     */
    __getLogger(): import("../_types/@internal_core@0.1.4/dist/logger/index.js").IMastraLogger;
    /**
     * 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<TTools, any>): 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<TAgentId, TTools, TOutput, TRequestContext>;
    /**
     * Mark this agent as a stored-version fork so execution does not attempt
     * to resolve a version override for it again.
     * @internal
     */
    __markStoredVersionApplied(): void;
    /**
     * Whether this agent is a stored-version fork produced by
     * `Mastra.resolveVersionedAgent()`. Subclasses that implement their own
     * resume paths (e.g. DurableAgent) use this to skip re-pinning a version
     * that the caller already resolved explicitly.
     * @internal
     */
    __isStoredVersionApplied(): boolean;
    /**
     * Extract plain text lines from a single message's parts array.
     * Modeled after observational memory's formatObserverMessage — switches on
     * part type, emits role-prefixed text, and drops all metadata.
     */
    private formatMessagePartsForTitle;
    /**
     * Format an array of UI messages into plain text for title generation.
     * Like observational memory's formatMessagesForObserver — loops over messages,
     * formats each one's parts with role context, and joins the results.
     */
    formatMessagesForTitle(messages: Array<{
        role: string;
        content?: string;
        parts?: Array<{
            type: string;
            [key: string]: any;
        }>;
    }>): string;
    generateTitleFromUserMessage({ message, messages, requestContext, model, instructions, ...rest }: {
        message?: string | MessageInput;
        messages?: Array<{
            role: string;
            content?: string;
            parts?: Array<{
                type: string;
                [key: string]: any;
            }>;
        }>;
        requestContext?: RequestContext;
        model?: DynamicArgument<MastraModelConfig, TRequestContext>;
        instructions?: DynamicArgument<string>;
    } & Partial<ObservabilityContext>): Promise<string | undefined>;
    getMostRecentUserMessage(messages: Array<UIMessage | UIMessageWithMetadata>): UIMessage | UIMessageWithMetadata | undefined;
    /**
     * Restrict UI messages to those that belong to the given thread. Memory can
     * load messages from other threads of the same resource into the message list
     * (resource-scoped recall); those must not influence the generated title.
     */
    filterUiMessagesByThread<T extends {
        id: string;
    }>(messageList: MessageList, threadId: string, uiMessages: T[]): T[];
    genTitle(userMessage: string | MessageInput | undefined, requestContext: RequestContext, observabilityContext: ObservabilityContext, model?: DynamicArgument<MastraModelConfig, TRequestContext>, instructions?: DynamicArgument<string>, uiMessages?: Array<{
        role: string;
        content?: string;
        parts?: Array<{
            type: string;
            [key: string]: any;
        }>;
    }>): Promise<string | undefined>;
    __setMemory(memory: DynamicArgument<MastraMemory, TRequestContext>): void;
    __setPubSub(pubsub: PubSub): void;
    __setWorkspace(workspace: DynamicArgument<AnyWorkspace | undefined, TRequestContext>): void;
    /**
     * Retrieves and converts memory tools to CoreTool format.
     * @internal
     */
    private listMemoryTools;
    /**
     * Lists the tools of the attached Knowledge, if any.
     * @internal
     */
    private listKnowledgeTools;
    /**
     * Lists workspace tools if a workspace is configured.
     * @internal
     */
    private listWorkspaceTools;
    /**
     * 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;
    /**
     * Returns tools that input processors loaded into their own state.
     * These tools need to be available before a resumed approval call enters toolCallStep.
     * Otherwise the resumed workflow bypasses processInputStep and loses dynamic executors.
     * @internal
     */
    private listInputProcessorLoadedTools;
    /**
     * 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.
     *
     * Provider-executed tool results are stripped too. When a provider runs a tool
     * itself (OpenAI hosted tool search, Anthropic server tools) AI SDK v5 places the
     * tool_result part in the *same assistant message* as its tool_call, so removing only
     * the call leaves an orphaned result that providers reject — "No tool call found for
     * tool search output with call_id ...". Client-executed results live in `role: 'tool'`
     * messages instead and are already dropped below.
     *
     * This function removes those parts while preserving all other
     * conversation context (user messages, assistant text, etc.).
     *
     * Reasoning parts are removed from assistant messages too. The parent's
     * reasoning is replayable only as part of the parent's own unmodified
     * responses: once tool calls and tool messages are removed,
     * `@ai-sdk/anthropic` merges the now-adjacent assistant steps into one
     * message, and Anthropic rejects any signed thinking (`signature` /
     * `redactedData`) in it as a modified thinking block (#29276). The forwarded
     * context never ends in a tool-use continuation, so no provider requires
     * thinking blocks in it.
     * @internal
     */
    private stripParentToolParts;
    private getSubAgentToolSchemas;
    /**
     * Retrieves and converts agent tools to CoreTool format.
     * @internal
     */
    private listAgentTools;
    /**
     * Retrieves and converts workflow tools to CoreTool format.
     * @internal
     */
    private listWorkflowTools;
    /**
     * Get tools for execution.
     *
     * This method assembles all tools from various sources (assigned tools, memory tools,
     * toolsets, client tools, agent tools, workflow tools) into a unified CoreTool dictionary.
     *
     * This is useful for durable execution where tools need to be reconstructed from
     * serialized state rather than stored in a registry.
     *
     * @param options - Options for tool assembly
     * @returns A record of tool names to CoreTool instances
     */
    getToolsForExecution(options: {
        toolsets?: ToolsetsInput;
        clientTools?: ToolsInput;
        threadId?: string;
        resourceId?: string;
        runId?: string;
        requestContext?: RequestContext;
        outputWriter?: OutputWriter;
        memoryConfig?: MemoryConfig;
        autoResumeSuspendedTools?: boolean;
        hooks?: ToolHooks;
        delegation?: DelegationConfig;
        methodType?: AgentMethodType;
        backgroundTaskEnabled?: boolean;
        backgroundTaskPolicy?: AgentExecutionOptionsBase<any>['backgroundTaskPolicy'];
        model?: MastraLanguageModel | MastraLegacyLanguageModel;
        /** @internal In-flight run messages, so recovery can restore processor-loaded tools. */
        runMessages?: MastraDBMessage[];
    }): Promise<Record<string, CoreTool>>;
    /**
     * Assembles all tools from various sources into a unified CoreTool dictionary.
     * @internal
     */
    private convertTools;
    /**
     * Returns the agent's statically-configured tool hooks, if any.
     *
     * @internal Used by dataset experiments to compose item-level tool mocks with
     * the user's configured `beforeToolCall`/`afterToolCall` hooks. Run-level hooks
     * override these via {@link resolveToolHooks}, so callers that need to preserve
     * the configured hooks must read and compose them explicitly.
     */
    getConfiguredToolHooks(): ToolHooks | undefined;
    private resolveToolHooks;
    private wrapToolsWithHooks;
    private wrapToolWithHooks;
    /**
     * Formats and validates tool names to comply with naming restrictions.
     * @internal
     */
    private formatTools;
    /**
     * Resolves scorer name references to actual scorer instances from Mastra.
     * @internal
     */
    private resolveOverrideScorerReferences;
    /**
     * Resolves and prepares model configurations for the LLM.
     * @internal
     */
    private prepareModels;
    /** @internal */
    private resolveFallbackDynamic;
    /**
     * Enforce agent-level FGA (`agents:execute`) before running the agent.
     * `protected` so durable/evented subclasses can enforce the same gate before
     * their workflow-based execution (they override the public entry points and
     * would otherwise bypass it).
     */
    protected requireAgentExecutionFGA({ requestContext, memory, runId, snapshotMemoryInfo, actor, }: {
        requestContext?: RequestContext;
        memory?: AgentExecutionOptionsBase<any>['memory'];
        runId?: string;
        snapshotMemoryInfo?: AgentSnapshotMemoryInfo;
        actor?: ActorSignal;
    }): Promise<void>;
    /**
     * 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<undefined>): Promise<MastraAgentNetworkStream<undefined>>;
    network<OUTPUT extends {}>(messages: MessageListInput, options?: MultiPrimitiveExecutionOptions<OUTPUT>): Promise<MastraAgentNetworkStream<OUTPUT>>;
    /**
     * 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<MultiPrimitiveExecutionOptions, 'runId'> & {
        runId: string;
    }): Promise<MastraAgentNetworkStream<undefined>>;
    /**
     * 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<MultiPrimitiveExecutionOptions, 'runId'> & {
        runId: string;
    }): Promise<MastraAgentNetworkStream<undefined>>;
    /**
     * 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<MultiPrimitiveExecutionOptions, 'runId'> & {
        runId: string;
        reason?: string;
    }): Promise<MastraAgentNetworkStream<undefined>>;
    generate<OUTPUT extends StandardSchemaWithJSON<any, any>, T extends InferStandardSchemaOutput<OUTPUT> = InferStandardSchemaOutput<OUTPUT>>(messages: MessageListInput, options: AgentExecutionOptionsBase<T> & {
        structuredOutput: PublicStructuredOutputOptions<T>;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<FullOutput<T>>;
    generate<OUTPUT extends {}>(messages: MessageListInput, options: AgentExecutionOptionsBase<OUTPUT> & {
        structuredOutput: PublicStructuredOutputOptions<OUTPUT>;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<FullOutput<OUTPUT>>;
    generate(messages: MessageListInput, options: AgentExecutionOptionsBase<unknown> & {
        structuredOutput?: never;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<FullOutput<TOutput>>;
    generate<OUTPUT = TOutput>(messages: MessageListInput): Promise<FullOutput<OUTPUT>>;
    subscribeToThread<OUTPUT = TOutput>(options: AgentSubscribeToThreadOptions & {
        withRunStatus: true;
        withInitialHistory: true | {
            perPage?: number;
        };
    }): Promise<AgentThreadSubscription<OUTPUT, true, true>>;
    subscribeToThread<OUTPUT = TOutput>(options: AgentSubscribeToThreadOptions & {
        withRunStatus: true;
        withInitialHistory?: false;
    }): Promise<AgentThreadSubscription<OUTPUT, false, true>>;
    subscribeToThread<OUTPUT = TOutput>(options: AgentSubscribeToThreadOptions & {
        withRunStatus: true;
    }): Promise<AgentThreadSubscription<OUTPUT, boolean, true>>;
    subscribeToThread<OUTPUT = TOutput>(options: AgentSubscribeToThreadOptions & {
        withRunStatus?: false;
        withInitialHistory: true | {
            perPage?: number;
        };
    }): Promise<AgentThreadSubscription<OUTPUT, true>>;
    subscribeToThread<OUTPUT = TOutput>(options: AgentSubscribeToThreadOptions & {
        withRunStatus?: false;
        withInitialHistory?: false;
    }): Promise<AgentThreadSubscription<OUTPUT>>;
    subscribeToThread<OUTPUT = TOutput>(options: AgentSubscribeToThreadOptions & {
        withRunStatus?: false;
    }): Promise<AgentThreadSubscription<OUTPUT, boolean>>;
    subscribeToThread<OUTPUT = TOutput>(options: AgentSubscribeToThreadOptions): Promise<AgentThreadSubscription<OUTPUT, boolean, boolean>>;
    claimThreadOwnership<OUTPUT = TOutput>(options: {
        resourceId: string;
        threadId: string;
        streamOptions?: AgentExecutionOptions<OUTPUT> | (() => AgentExecutionOptions<OUTPUT> | Promise<AgentExecutionOptions<OUTPUT>>);
        peer?: false | AgentClaimThreadPeerOptions;
        /**
         * Called when another process asks to claim this thread. Return `true` to
         * transfer the claim to that requester when leasing is available, or release
         * it on lease-less transports.
         */
        yieldOwnership?: () => boolean;
        /** Called after this claim has been transferred or released for the requester. */
        onOwnershipYielded?: () => void;
        /** Called when lease renewal proves that another live owner has taken this claim. */
        onOwnershipLost?: () => void;
    }): Promise<{
        claimed: boolean;
        unsubscribe: () => void;
    }>;
    updateThreadPeerAdvertisement(options: {
        resourceId: string;
        threadId: string;
        peer: AgentUpdateThreadPeerOptions;
    }): boolean;
    discoverThreadPeers(options?: DiscoverAgentThreadPeersOptions): Promise<AgentThreadPeerAdvertisement[]>;
    getActiveThreadRunId(options: AgentThreadIdentityOptions): string | undefined;
    listActiveThreadRuns(): ActiveThreadRun[];
    /**
     * Lists suspended agent runs from workflow snapshot storage — runs waiting on
     * a tool-call approval (`requireApproval` / `requireToolApproval`) or on a
     * tool that called `suspend()`.
     *
     * Unlike {@link getActiveThreadRunId}, which only knows about runs started by the
     * current process, this is backed by storage: it works after a server restart and
     * across multiple server instances. Pass the returned `runId` to `resumeStream()`,
     * `approveToolCall()`, or `declineToolCall()`.
     *
     * Results are scoped to runs started by this agent: snapshots persist the owning
     * agent's id, and runs whose snapshots carry a different id are skipped. Filter by
     * `threadId`/`resourceId` to scope results to a conversation.
     *
     * Storage pagination is offset-based, so concurrent changes or rows with tied sort
     * values can make a multi-page discovery reflect the storage adapter's ordering
     * rather than a transactional snapshot.
     *
     * @example
     * ```typescript
     * const { runs } = await agent.listSuspendedRuns({ threadId, resourceId });
     * if (runs[0]) {
     *   await agent.approveToolCall({ runId: runs[0].runId });
     * }
     * ```
     */
    listSuspendedRuns(options?: AgentListSuspendedRunsOptions): Promise<AgentListSuspendedRunsResult>;
    /** @internal Allows server adapters to detect thread-wide cancellation and clear-on-abort support. */
    get __supportsThreadSignalCancellation(): boolean;
    /**
     * @internal Whether a finished background task is already handled by an
     * `untilIdle` stream: one is open for the thread and will report it, or the
     * caller stopped the stream that was waiting for it.
     */
    __untilIdleHandlesBackgroundTask(threadId: string, resourceId: string, taskId: string): boolean;
    /**
     * @internal Tells the agent that a deferred background task on a thread has
     * finished and its result is now on the tool call. An open `untilIdle` stream
     * for the thread already reports it with its own follow-up turn, and a caller
     * that stopped the stream waiting for the task doesn't want a reply, so this
     * does nothing then. It also does nothing when the background task config
     * sets `notifyAgentOnFinish: false`. Otherwise it sends a signal to the thread: an active run gets
     * it on its next step, and an idle thread wakes so the agent can report the
     * outcome. The signal names the tool call, never the result: the result is
     * already in the thread, and tool output may hold data that must not be
     * copied into a prompt.
     */
    __notifyBackgroundTaskFinished(params: {
        threadId: string;
        resourceId: string;
        taskId: string;
        toolCallId: string;
        toolName: string;
        status: 'completed' | 'failed';
        /** The dispatching run's request context, so a woken run resolves model, instructions and memory as it did. */
        requestContext?: RequestContext;
    }): Promise<void>;
    abortThreadStream(options: AgentAbortThreadOptions): boolean;
    /** @internal Abort the thread's run even when another process executes it, reporting whether one was asked to stop. */
    __abortThreadStreamAcrossProcesses(options: AgentAbortThreadOptions): Promise<boolean>;
    abortRunStream(runId: string): boolean;
    /** Abort `runId` if this process executes it or holds it parked. */
    protected __abortLocalRun(runId: string): boolean;
    /**
     * Abort `runId` wherever it executes and report whether that was confirmed:
     * true when this process aborted it, or when the executing process answered
     * the request on the run's control topic; false when nobody answered in
     * time (the run finished, is parked elsewhere, or the transport dropped the
     * request). Rejects when the request cannot be published.
     * @internal Used by the server's run abort route.
     */
    __abortRunAcknowledged(runId: string): Promise<boolean>;
    sendMessage<OUTPUT = TOutput>(message: AgentMessageInput, target: SendAgentMessageOptions<OUTPUT>): SendAgentMessageResult<OUTPUT>;
    queueMessage<OUTPUT = TOutput>(message: AgentMessageInput, target: QueueAgentMessageOptions<OUTPUT>): QueueAgentMessageResult<OUTPUT>;
    /**
     * Queues a typed signal to start a new run after the active thread run completes, or wakes
     * the thread immediately when it is idle. Shares the queue used by `queueMessage()`.
     */
    queueSignal<OUTPUT = TOutput>(signal: AgentSignal, target: QueueAgentSignalOptions<OUTPUT>): QueueAgentSignalResult<OUTPUT>;
    cancelQueuedMessages(target: CancelQueuedAgentMessagesOptions): CancelQueuedAgentMessagesResult;
    subscribeThreadEvents(scope: SubscribeAgentThreadEventsOptions, listener: AgentThreadEventListener): () => void;
    sendStateSignal<OUTPUT = TOutput>(state: AgentStateSignalInput, target: SendAgentStateSignalOptions<OUTPUT>): Promise<SendAgentStateSignalResult<OUTPUT>>;
    /**
     * Run this agent's notification delivery policy for a record. Called at
     * receipt time by `sendNotificationSignal` and again at delivery time by the
     * notification dispatch workflow, so a deferred delivery can carry
     * freshly-resolved decision fields (e.g. `streamOptions` with the request
     * context a woken idle thread needs to resolve a model).
     */
    resolveNotificationDeliveryDecision(input: NotificationDeliveryPolicyInput): Promise<NotificationDeliveryDecision>;
    sendNotificationSignal<OUTPUT = TOutput>(notification: SendNotificationSignalInput, target: SendAgentNotificationSignalOptions<OUTPUT>): Promise<SendAgentNotificationSignalResult<OUTPUT>>;
    sendNotificationSignal<OUTPUT = TOutput>(notification: SendNotificationSignalInput[], target: SendAgentNotificationSignalOptions<OUTPUT>): Promise<SendAgentNotificationSignalResult<OUTPUT>[]>;
    sendSignal<OUTPUT = TOutput>(signal: AgentSignal, target: SendAgentSignalOptions<OUTPUT>): SendAgentSignalResult<OUTPUT>;
    stream<OUTPUT extends StandardSchemaWithJSON<any, any>, T extends InferStandardSchemaOutput<OUTPUT> = InferStandardSchemaOutput<OUTPUT>>(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<T> & {
        structuredOutput: PublicStructuredOutputOptions<T>;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<T>>;
    stream<OUTPUT extends {}>(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<OUTPUT> & {
        structuredOutput: PublicStructuredOutputOptions<OUTPUT>;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<OUTPUT>>;
    stream(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<unknown> & {
        structuredOutput?: never;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<TOutput>>;
    stream(messages: MessageListInput): Promise<MastraModelOutput<TOutput>>;
    /**
     * @deprecated Use `stream(messages, { untilIdle: true })` instead.
     *
     * Streams the agent's response and keeps the stream open until all
     * background tasks dispatched during this turn (and any triggered by
     * follow-up turns) complete. When a background task finishes, its tool
     * result is injected into memory by the tool-call-step's `onResult` hook,
     * and this method re-enters the agentic loop via `agent.stream([], ...)`
     * so the LLM can process the result immediately — without waiting for a
     * new user message.
     *
     * Invariants:
     * - Only one inner LLM stream runs at a time (a completion arriving
     *   mid-turn is queued and processed after the current turn ends).
     * - When there are no running background tasks and no queued completions,
     *   the outer stream closes.
     * - If the agent has no memory configured, this falls through to a plain
     *   `stream()` call since continuation requires memory.
     *
     * Return shape: `streamUntilIdle` returns a `MastraModelOutput` that looks
     * like the one from `stream()` — *only* `fullStream` spans the initial
     * turn **and** any auto-continuations. Aggregate properties (`text`,
     * `toolCalls`, `toolResults`, `finishReason`, `messageList`,
     * `getFullOutput()`) still resolve against the **first turn's** internal
     * buffer. If you need an aggregate view across continuations, consume
     * `fullStream` yourself and accumulate — or follow up with `agent.generate`
     * once the stream closes.
     *
     * @example
     * ```typescript
     * const stream = await agent.streamUntilIdle('Research solana for me', {
     *   memory: { thread: 't1', resource: 'u1' },
     * });
     *
     * for await (const chunk of stream.fullStream) {
     *   // chunks from the initial turn AND any continuation turns
     *   // triggered by background task completions flow through here
     * }
     * ```
     */
    streamUntilIdle<OUTPUT extends StandardSchemaWithJSON<any, any>, T extends InferStandardSchemaOutput<OUTPUT> = InferStandardSchemaOutput<OUTPUT>>(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<T> & {
        structuredOutput: PublicStructuredOutputOptions<T>;
        maxIdleMs?: number;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<T>>;
    streamUntilIdle<OUTPUT extends {}>(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<OUTPUT> & {
        structuredOutput: PublicStructuredOutputOptions<OUTPUT>;
        maxIdleMs?: number;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<OUTPUT>>;
    streamUntilIdle(messages: MessageListInput, streamOptions: AgentExecutionOptionsBase<unknown> & {
        structuredOutput?: never;
        maxIdleMs?: number;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<TOutput>>;
    streamUntilIdle(messages: MessageListInput): Promise<MastraModelOutput<TOutput>>;
    /**
     * @deprecated Use `resumeStream(resumeData, { untilIdle: true, ... })` instead.
     *
     * Resume-flavored counterpart to {@link streamUntilIdle}. Resumes a
     * previously suspended stream identified by `streamOptions.runId`, then
     * keeps the outer stream open across any continuations that background
     * task completions trigger — same idle-loop semantics as `streamUntilIdle`.
     *
     * Use this when (a) the suspended run produced a background task whose
     * completion should drive a follow-up turn, or (b) a tool dispatched as a
     * background task from inside the resume itself needs the outer stream to
     * stay open until it finishes.
     *
     * @example
     * ```typescript
     * const stream = await agent.resumeStreamUntilIdle(
     *   { approved: true },
     *   { runId: 'previous-run-id', memory: { thread: 't1', resource: 'u1' } },
     * );
     *
     * for await (const chunk of stream.fullStream) {
     *   // chunks from the resumed turn AND any continuation turns
     * }
     * ```
     */
    resumeStreamUntilIdle<OUTPUT extends StandardSchemaWithJSON<any, any>, T extends InferStandardSchemaOutput<OUTPUT> = InferStandardSchemaOutput<OUTPUT>>(resumeData: any, streamOptions: AgentExecutionOptionsBase<T> & {
        structuredOutput: PublicStructuredOutputOptions<T>;
        toolCallId?: string;
        /** Close the outer stream after this many ms of idleness. Default: 5 minutes. */
        maxIdleMs?: number;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<T>>;
    resumeStreamUntilIdle<OUTPUT extends {}>(resumeData: any, streamOptions: AgentExecutionOptionsBase<OUTPUT> & {
        structuredOutput: PublicStructuredOutputOptions<OUTPUT>;
        toolCallId?: string;
        maxIdleMs?: number;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<OUTPUT>>;
    resumeStreamUntilIdle(resumeData: any, streamOptions: AgentExecutionOptionsBase<unknown> & {
        structuredOutput?: never;
        toolCallId?: string;
        maxIdleMs?: number;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<TOutput>>;
    /**
     * 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<OUTPUT extends StandardSchemaWithJSON<any, any>, T extends InferStandardSchemaOutput<OUTPUT> = InferStandardSchemaOutput<OUTPUT>>(resumeData: any, streamOptions: AgentExecutionOptionsBase<T> & {
        structuredOutput: PublicStructuredOutputOptions<T>;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<T>>;
    resumeStream<OUTPUT extends {}>(resumeData: any, streamOptions: AgentExecutionOptionsBase<OUTPUT> & {
        structuredOutput: PublicStructuredOutputOptions<OUTPUT>;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<OUTPUT>>;
    resumeStream(resumeData: any, streamOptions: AgentExecutionOptionsBase<unknown> & {
        structuredOutput?: never;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<TOutput>>;
    /**
     * 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<OUTPUT extends StandardSchemaWithJSON<any, any>, T extends InferStandardSchemaOutput<OUTPUT> = InferStandardSchemaOutput<OUTPUT>>(resumeData: any, options: AgentExecutionOptionsBase<T> & {
        structuredOutput: PublicStructuredOutputOptions<T>;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<FullOutput<T>>;
    resumeGenerate<OUTPUT extends {}>(resumeData: any, options: AgentExecutionOptionsBase<OUTPUT> & {
        structuredOutput: PublicStructuredOutputOptions<OUTPUT>;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<FullOutput<OUTPUT>>;
    resumeGenerate(resumeData: any, options: AgentExecutionOptionsBase<unknown> & {
        structuredOutput?: never;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<FullOutput<TOutput>>;
    /**
     * Finishes a resume whose process died before the run finished, with the approval decision or
     * resume data that resume persisted when it claimed the run. Use it when `approveToolCall()`,
     * `declineToolCall()`, or `resumeStream()` was called but the process handling it stopped, and
     * the decision is no longer at hand.
     *
     * The claim must be abandoned: claimed and not started for `AGENT_RESUME_CLAIM_STALE_MS`, or, on
     * storage with run fencing, started and no longer renewed for that long. Rejects with
     * `AGENT_RESUME_ALREADY_CLAIMED` before then, and with `AGENT_RESUME_NOTHING_TO_RECOVER` when no
     * resume has claimed the run. The resumed tool call runs again, and abandonment is judged by age,
     * so a stalled claimant may still be running it.
     *
     * @example
     * ```typescript
     * const stream = await agent.recoverResume({ runId: 'claimed-run-id' });
     * ```
     */
    recoverResume<OUTPUT = TOutput>(options: AgentExecutionOptionsBase<any> & {
        runId: string;
        structuredOutput?: PublicStructuredOutputOptions<any>;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<OUTPUT>>;
    /**
     * 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<OUTPUT = undefined>(options: AgentExecutionOptions<OUTPUT> & {
        runId: string;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<OUTPUT>>;
    sendStreamResume<OUTPUT = undefined>(options: SendAgentStreamResumeOptions<OUTPUT>): Promise<SendAgentStreamResumeResult>;
    sendToolApproval<OUTPUT = undefined>(options: AgentExecutionOptions<OUTPUT> & {
        threadId: string;
        resourceId: string;
        toolCallId?: string;
        approved: boolean;
        resumeData?: unknown;
        declineContext?: {
            reason?: string;
            message?: string;
        };
        messages?: MessageListInput;
        streamOptions?: AgentExecutionOptions<OUTPUT>;
    }): Promise<{
        accepted: true;
        runId: string;
        toolCallId?: string;
    }>;
    /**
     * 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',
     *   reason: 'The user does not want to share their location'
     * });
     *
     * for await (const chunk of stream) {
     *   console.log(chunk);
     * }
     * ```
     *
     * @param options.reason - Optional explanation for the decline. It is persisted on the
     * tool invocation's `approval.reason` and surfaced to the model in place of the default
     * "Tool call was not approved by the user" message.
     */
    declineToolCall<OUTPUT = undefined>(options: AgentExecutionOptions<OUTPUT> & {
        runId: string;
        toolCallId?: string;
        reason?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<MastraModelOutput<OUTPUT>>;
    /**
     * 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<OUTPUT = undefined>(options: AgentExecutionOptions<OUTPUT> & {
        runId: string;
        toolCallId?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<Awaited<ReturnType<MastraModelOutput<OUTPUT>['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,
     *     reason: 'Budget approval is required first'
     *   });
     *   console.log(result.text);
     * }
     * ```
     *
     * @param options.reason - Optional explanation for the decline, persisted on the tool
     * invocation's `approval.reason` and surfaced to the model.
     */
    declineToolCallGenerate<OUTPUT = undefined>(options: AgentExecutionOptions<OUTPUT> & {
        runId: string;
        toolCallId?: string;
        reason?: string;
    } & {
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<Awaited<ReturnType<MastraModelOutput<OUTPUT>['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<undefined, undefined> & {
        output?: never;
        experimental_output?: never;
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<GenerateTextResult<any, undefined>>;
    generateLegacy<OUTPUT extends ZodSchema | JSONSchema7>(messages: MessageListInput, args?: AgentGenerateOptions<OUTPUT, undefined> & {
        output?: OUTPUT;
        experimental_output?: never;
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<GenerateObjectResult<OUTPUT>>;
    generateLegacy<EXPERIMENTAL_OUTPUT extends ZodSchema | JSONSchema7>(messages: MessageListInput, args?: AgentGenerateOptions<undefined, EXPERIMENTAL_OUTPUT> & {
        output?: never;
        experimental_output?: EXPERIMENTAL_OUTPUT;
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<GenerateTextResult<any, EXPERIMENTAL_OUTPUT>>;
    /**
     * 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<OUTPUT extends ZodSchema | JSONSchema7 | undefined = undefined, EXPERIMENTAL_OUTPUT extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: MessageListInput, args?: AgentStreamOptions<OUTPUT, EXPERIMENTAL_OUTPUT> & {
        output?: never;
        experimental_output?: never;
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<StreamTextResult<any, OUTPUT>>;
    streamLegacy<OUTPUT extends ZodSchema | JSONSchema7 | undefined = undefined, EXPERIMENTAL_OUTPUT extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: MessageListInput, args?: AgentStreamOptions<OUTPUT, EXPERIMENTAL_OUTPUT> & {
        output?: OUTPUT;
        experimental_output?: never;
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<StreamObjectResult<OUTPUT extends ZodSchema | JSONSchema7 ? OUTPUT : never> & TracingProperties>;
    streamLegacy<OUTPUT extends ZodSchema | JSONSchema7 | undefined = undefined, EXPERIMENTAL_OUTPUT extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: MessageListInput, args?: AgentStreamOptions<OUTPUT, EXPERIMENTAL_OUTPUT> & {
        output?: never;
        experimental_output?: EXPERIMENTAL_OUTPUT;
        model?: DynamicArgument<MastraModelConfig>;
    }): Promise<StreamTextResult<any, EXPERIMENTAL_OUTPUT> & {
        partialObjectStream: StreamTextResult<any, EXPERIMENTAL_OUTPUT>['experimental_partialOutputStream'];
    }>;
    /**
     * Resolves the configuration for title generation.
     * @internal
     */
    resolveTitleGenerationConfig(generateTitleConfig: boolean | {
        model?: DynamicArgument<MastraModelConfig, TRequestContext>;
        instructions?: DynamicArgument<string>;
        minMessages?: number;
        emitEvent?: boolean;
    } | undefined): {
        shouldGenerate: boolean;
        model?: DynamicArgument<MastraModelConfig, TRequestContext>;
        instructions?: DynamicArgument<string>;
        minMessages?: number;
        emitEvent?: boolean;
    };
    /**
     * Resolves title generation instructions, handling both static strings and dynamic functions
     * @internal
     */
    resolveTitleInstructions(requestContext: RequestContext, instructions?: DynamicArgument<string>): Promise<string>;
    /** Resume a suspended durable run. Requires createDurableAgent() or DurableAgent. */
    resume(runId: string, resumeData: unknown, options?: DurableAgentStreamOptions<TOutput>): Promise<DurableAgentStreamResult<TOutput>>;
    /** Recover a persisted durable run in a fresh process. Requires createDurableAgent() or DurableAgent. */
    recover(runId: string, options?: DurableAgentRecoverOptions<TOutput>): Promise<DurableAgentStreamResult<TOutput>>;
    /** List active durable runs. Requires createDurableAgent() or DurableAgent. */
    listActiveRuns(options?: DurableAgentListActiveRunsOptions): Promise<DurableAgentListActiveRunsResult>;
    /** Bulk-recover active durable runs. Requires createDurableAgent() or DurableAgent. */
    recoverActiveRuns(options?: DurableAgentRecoverActiveRunsOptions): Promise<DurableAgentRecoverActiveRunsResult>;
    /** Observe a resumable run without driving it. */
    observe(runId: string, options?: {
        /**
         * Inclusive, zero-based PubSub event index. It counts all cached run-topic events, including
         * lifecycle events, not chunks. Each chunk carries its event's index as `chunk.index`: to resume
         * after a dropped connection, pass the `index + 1` of the last chunk that has an index. Omit it to replay all available cached events. Transports
         * without numeric offsets live-tail instead. Skipping earlier text deltas produces partial text
         * and may make structured output fail to parse; beyond retained history, an offset also skips
         * lower-index live events on numeric-offset transports. See
         * https://mastra.ai/reference/agents/durable-agent#observerunid-options.
         */
        offset?: number;
        onChunk?: (chunk: ChunkType<TOutput>) => void | Promise<void>;
        onStepFinish?: (result: DurableAgentStepFinishResult) => void | Promise<void>;
        onFinish?: MastraOnFinishCallback<TOutput>;
        onError?: ({ error }: {
            error: Error | string;
        }) => void | Promise<void>;
        onSuspended?: (data: AgentSuspendedEventData) => void | Promise<void>;
    }): Promise<Omit<DurableAgentStreamResult<TOutput>, 'runId'> & {
        runId: string;
        detach: () => void;
    }>;
    /** Prepare a durable execution without starting it. Requires createDurableAgent() or DurableAgent. */
    prepare(messages: MessageListInput, options?: AgentExecutionOptions<TOutput>): Promise<unknown>;
}
export {};
//# sourceMappingURL=agent.d.ts.map