/** * Subagent Tool - Use agents as tools for other agents * * Enables the agent-as-tool pattern where one agent can invoke * another agent as part of its tool execution. * * @example * ```typescript * import { Agent, SubagentTool, createSubagentTool } from 'praisonai'; * * const researcher = new Agent({ * name: 'Researcher', * instructions: 'Research topics thoroughly' * }); * * const writer = new Agent({ * name: 'Writer', * instructions: 'Write articles based on input', * tools: [createSubagentTool(researcher, { * name: 'research', * description: 'Research a topic before writing' * })] * }); * ``` */ /** * Configuration for subagent tool */ export interface SubagentToolConfig { /** Tool name (defaults to agent name) */ name?: string; /** Tool description */ description?: string; /** Prompt template for the subagent (use {{input}} for placeholder) */ promptTemplate?: string; /** Transform input before sending to subagent */ inputTransform?: (input: any) => string; /** Transform output from subagent */ outputTransform?: (output: any) => any; /** Timeout for subagent execution in ms */ timeout?: number; /** Additional context to pass to subagent */ context?: Record; /** Whether to include parent conversation history */ includeHistory?: boolean; } /** * Schema for subagent tool parameters */ export interface SubagentToolSchema { type: 'object'; properties: { input: { type: 'string'; description: string; }; }; required: ['input']; } /** * SubagentTool - Wraps an agent to be used as a tool */ export declare class SubagentTool { readonly id: string; readonly name: string; readonly description: string; private agent; private config; constructor(agent: any, config?: SubagentToolConfig); /** * Get the tool schema for AI SDK */ getSchema(): SubagentToolSchema; /** * Execute the subagent */ execute(params: { input: string; }): Promise; /** * Execute agent with timeout */ private executeWithTimeout; /** * Invoke the wrapped agent */ private invokeAgent; /** * Convert to AI SDK tool format */ toAISDKTool(): any; /** * Convert to callable function tool format */ toFunctionTool(): (...args: any[]) => Promise; } /** * Create a subagent tool from an agent * * @example * ```typescript * const researchTool = createSubagentTool(researchAgent, { * name: 'deep_research', * description: 'Perform deep research on a topic' * }); * * const writer = new Agent({ * tools: [researchTool] * }); * ``` */ export declare function createSubagentTool(agent: any, config?: SubagentToolConfig): SubagentTool; /** * Create multiple subagent tools from a list of agents */ export declare function createSubagentTools(agents: any[], configs?: SubagentToolConfig[]): SubagentTool[]; /** * Agent delegation helper - create a delegator agent that routes to subagents */ export interface DelegatorConfig { /** Name of the delegator agent */ name?: string; /** Instructions for the delegator */ instructions?: string; /** Subagents to delegate to */ subagents: any[]; /** LLM to use for routing decisions */ llm?: string; } export declare function createDelegator(config: DelegatorConfig): any; export default SubagentTool;