import type { WritableStream } from 'node:stream/web'; import type { UIMessage } from '../_types/@internal_ai-sdk-v4/dist/index.js'; import type { JSONSchema7 } from 'json-schema'; import type { MastraLLMV1 } from '../llm/model/index.js'; import type { GenerateObjectResult, GenerateTextResult, StreamObjectResult, StreamTextResult } from '../llm/model/base.types.js'; import type { MastraModelConfig } from '../llm/model/shared.types.js'; import type { Mastra } from '../mastra/index.js'; import type { MastraMemory } from '../memory/memory.js'; import type { MemoryConfigInternal } from '../memory/types.js'; import type { TracingProperties, ObservabilityContext } from '../observability/index.js'; import type { InputProcessorOrWorkflow, OutputProcessorOrWorkflow } from '../processors/index.js'; import { RequestContext } from '../request-context/index.js'; import type { ChunkType } from '../stream/types.js'; import type { CoreTool } from '../tools/types.js'; import type { DynamicArgument } from '../types/index.js'; import { MessageList } from './message-list/index.js'; import type { MastraDBMessage, MessageListInput, UIMessageWithMetadata } from './message-list/index.js'; import type { ZodSchema, AgentGenerateOptions, AgentStreamOptions, AgentInstructions, ToolsetsInput, ToolsInput, AgentMethodType } from './types.js'; /** * Interface for accessing Agent methods needed by the legacy handler. * This allows the legacy handler to work with Agent without directly accessing private members. */ export interface AgentLegacyCapabilities { /** Logger instance */ logger: { debug: (message: string, meta?: any) => void; error: (message: string, meta?: any) => void; warn: (message: string, meta?: any) => void; }; /** Agent name for logging */ name: string; /** Agent ID */ id: string; /** Mastra instance for generating IDs */ mastra?: Mastra; /** Get default generate options for legacy */ getDefaultGenerateOptionsLegacy(options: { requestContext?: RequestContext; }): AgentGenerateOptions | Promise; /** Get default stream options for legacy */ getDefaultStreamOptionsLegacy(options: { requestContext?: RequestContext; }): AgentStreamOptions | Promise; /** Check if agent has own memory */ hasOwnMemory(): boolean; /** Get instructions */ getInstructions(options: { requestContext: RequestContext; }): Promise; /** Get the agent's LLM instance, optionally using a request-scoped model override */ getLLM(options: { requestContext: RequestContext; model?: DynamicArgument; }): Promise; /** Get memory instance */ getMemory(options: { requestContext: RequestContext; }): Promise; /** Get memory messages (deprecated - use input processors) */ getMemoryMessages(args: { resourceId?: string; threadId: string; vectorMessageSearch: string; memoryConfig?: MemoryConfigInternal; requestContext: RequestContext; }): Promise<{ messages: MastraDBMessage[]; }>; /** Convert tools for LLM */ convertTools(args: { toolsets?: ToolsetsInput; clientTools?: ToolsInput; threadId?: string; resourceId?: string; runId?: string; requestContext: RequestContext; writableStream?: WritableStream; methodType: AgentMethodType; memoryConfig?: MemoryConfigInternal; } & ObservabilityContext): Promise>; /** Run input processors */ __runInputProcessors(args: { requestContext: RequestContext; messageList: MessageList; inputProcessorOverrides?: InputProcessorOrWorkflow[]; } & ObservabilityContext): Promise<{ messageList: MessageList; tripwire?: { reason: string; retry?: boolean; metadata?: unknown; processorId?: string; }; }>; /** Run processInputStep phase on input processors (for legacy path compatibility) */ __runProcessInputStep(args: Partial & { requestContext: RequestContext; messageList: MessageList; stepNumber?: number; }): Promise<{ messageList: MessageList; tripwire?: { reason: string; retry?: boolean; metadata?: unknown; processorId?: string; }; }>; /** Get most recent user message */ getMostRecentUserMessage(messages: Array): UIMessage | UIMessageWithMetadata | undefined; /** Generate title for thread */ genTitle(userMessage: UIMessage | UIMessageWithMetadata, requestContext: RequestContext, observabilityContext: ObservabilityContext, titleModel?: DynamicArgument, titleInstructions?: DynamicArgument): Promise; /** Resolve title generation config */ resolveTitleGenerationConfig(generateTitleConfig: boolean | { model?: DynamicArgument; instructions?: DynamicArgument; minMessages?: number; } | undefined): { shouldGenerate: boolean; model?: DynamicArgument; instructions?: DynamicArgument; minMessages?: number; }; /** Save step messages */ saveStepMessages(args: { result: any; messageList: MessageList; runId: string; }): Promise; /** Convert instructions to string */ convertInstructionsToString(instructions: AgentInstructions): string; /** Options for tracing policy */ tracingPolicy?: any; /** Resolved version ID from stored config */ resolvedVersionId?: string; /** Agent network append flag */ _agentNetworkAppend?: boolean; /** List resolved output processors */ listResolvedOutputProcessors(requestContext?: RequestContext): Promise; /** Run output processors */ __runOutputProcessors(args: { requestContext: RequestContext; messageList: MessageList; outputProcessorOverrides?: OutputProcessorOrWorkflow[]; } & ObservabilityContext): Promise<{ messageList: MessageList; tripwire?: { reason: string; retry?: boolean; metadata?: unknown; processorId?: string; }; }>; /** Run scorers */ runScorers(args: { messageList: MessageList; runId: string; requestContext: RequestContext; structuredOutput?: boolean; overrideScorers?: Record; threadId?: string; resourceId?: string; } & ObservabilityContext): Promise; } /** * Handler class for legacy Agent functionality (v1 models). * Encapsulates all legacy-specific streaming and generation logic. */ export declare class AgentLegacyHandler { private capabilities; constructor(capabilities: AgentLegacyCapabilities); /** * Prepares message list and tools before LLM execution and handles memory persistence after. * This is the legacy version that only works with v1 models. * @internal */ private __primitive; /** * Prepares options and handlers for LLM text/object generation or streaming. * This is the legacy version that only works with v1 models. * @internal */ private prepareLLMOptions; /** * Legacy implementation of generate method using AI SDK v4 models. * Use this method if you need to continue using AI SDK v4 models. */ generateLegacy(messages: MessageListInput, generateOptions?: AgentGenerateOptions): Promise : GenerateObjectResult>; /** * Legacy implementation of stream method using AI SDK v4 models. * Use this method if you need to continue using AI SDK v4 models. */ streamLegacy(messages: MessageListInput, streamOptions?: AgentStreamOptions): Promise | (StreamObjectResult & TracingProperties)>; } //# sourceMappingURL=agent-legacy.d.ts.map