import type { Mastra } from '..'; import type { AgentBackgroundConfig } from '../background-tasks/index.js'; import type { MastraLegacyLanguageModel } from '../llm/model/shared.types.js'; import type { MastraLanguageModel, MastraMemory } from '../memory/index.js'; import type { RequestContext } from '../request-context/index.js'; import type { ChunkType, FullOutput, MastraModelOutput } from '../stream/index.js'; import type { DynamicArgument } from '../types/index.js'; import type { MessageListInput } from './message-list/index.js'; import type { AgentInstructions, MastraDBMessage, MessageList } from './types.js'; /** * Minimal interface for objects that can be used as subagents in the `agents` field. * `Agent` already satisfies this interface. Implement this to create lighter-weight * subagents without the full Agent class. */ export type SubAgentToolResult = { payload: { toolName: string; toolCallId: string; result?: unknown; args?: unknown; isError?: boolean; }; }; export type SubAgentGenerateResult = Pick & { response: { dbMessages?: MastraDBMessage[]; }; toolResults?: SubAgentToolResult[]; suspendPayload?: unknown; resumeSchema?: unknown; usage?: FullOutput['usage']; }; export type SubAgentStreamResult = { fullStream: ReadableStream; text: Promise; usage?: Promise; messageList: MessageList; toolResults?: SubAgentToolResult[] | Promise; runId: string; }; export interface SubAgent | unknown = unknown> { /** Unique identifier for this subagent */ readonly id: TId; /** Human-readable name used in logs and error details */ readonly name?: string; /** Human-readable description used for the generated tool description */ getDescription(): string; /** Returns the model instance used to select the execution path. */ getModel(opts?: { requestContext?: RequestContext; }): MastraLanguageModel | MastraLegacyLanguageModel | Promise; /** Whether this subagent has its own memory configured */ hasOwnMemory(): boolean; /** Inject parent memory into this subagent when it does not have its own */ __setMemory(memory: DynamicArgument): void; /** Returns the memory instance, if configured */ getMemory(opts?: { requestContext?: RequestContext; }): Promise | MastraMemory | undefined; /** Returns the system prompt / instructions */ getInstructions(opts?: { requestContext?: RequestContext; }): AgentInstructions | Promise; /** Execute a prompt and return the full result */ generate(messages: MessageListInput, options?: any): Promise; /** Stream a prompt execution */ stream(messages: MessageListInput, options?: any): Promise; /** Resume a previously suspended generate execution */ resumeGenerate(resumeData: any, options?: any): Promise; /** Resume a previously suspended stream execution */ resumeStream(resumeData: any, options?: any): Promise; /** * Execute a prompt using a legacy v1 model * @deprecated Use generate instead */ generateLegacy?(messages: MessageListInput, options?: any): Promise; /** * Stream a prompt execution using a legacy v1 model * @deprecated Use stream instead */ streamLegacy?(messages: MessageListInput, options?: any): Promise; /** Register a Mastra instance on implementations that need it */ __registerMastra?(mastra: Mastra): void; /** Returns background task configuration, if configured */ getBackgroundTasksConfig?(): AgentBackgroundConfig | undefined; } export declare function isAgentCompatible(input: unknown): input is SubAgent; //# sourceMappingURL=subagent.d.ts.map