/** * Reusable spawn_agent tool for delegating tasks to sub-agents. */ import { type AgentConfig, type AgentEvent, type AgentHooks, type AgentResult, type AgentTool, type AgentToolContext, type BasicLogger, type HookErrorMode, type ITelemetryService, type ToolApprovalRequest, type ToolApprovalResult, type ToolPolicy } from "@cline/shared"; import { z } from "zod"; import { type DelegatedAgentConfigProvider } from "./delegated-agent"; type AgentExtension = NonNullable[number]; type AgentFinishReason = AgentResult["finishReason"]; export declare const SpawnAgentInputSchema: z.ZodObject<{ systemPrompt: z.ZodString; task: z.ZodString; }, z.core.$strip>; export type SpawnAgentInput = z.infer; export interface SpawnAgentOutput { text: string; iterations: number; finishReason: AgentFinishReason; usage: { inputTokens: number; outputTokens: number; }; } export interface SubAgentStartContext { subAgentId: string; conversationId: string; parentAgentId: string; input: SpawnAgentInput; } export interface SubAgentEndContext { subAgentId: string; conversationId: string; parentAgentId: string; input: SpawnAgentInput; result?: SpawnAgentOutput; agentResult?: AgentResult; error?: Error; } export interface SpawnAgentToolConfig { configProvider: DelegatedAgentConfigProvider; defaultMaxIterations?: number; subAgentTools?: AgentTool[]; createSubAgentTools?: (input: SpawnAgentInput, context: AgentToolContext) => AgentTool[] | Promise; onSubAgentEvent?: (event: AgentEvent) => void; /** * Lifecycle hooks forwarded to spawned sub-agent runs. */ hooks?: AgentHooks; /** * Extension list forwarded to spawned sub-agent runs. */ extensions?: AgentExtension[]; /** * Error handling mode for forwarded lifecycle hooks. */ hookErrorMode?: HookErrorMode; /** * Called after a sub-agent instance is created and before it starts running. * Errors are ignored so lifecycle observers cannot break task execution. */ onSubAgentStart?: (context: SubAgentStartContext) => void | Promise; /** * Called once a sub-agent run finishes (success or error). * Errors are ignored so lifecycle observers cannot break task execution. */ onSubAgentEnd?: (context: SubAgentEndContext) => void | Promise; /** * Optional per-tool policy for spawned sub-agents. */ toolPolicies?: Record; /** * Optional approval callback for spawned sub-agent tool calls. */ requestToolApproval?: (request: ToolApprovalRequest) => Promise | ToolApprovalResult; /** * Optional logger forwarded to spawned sub-agent runs. */ logger?: BasicLogger; telemetry?: ITelemetryService; } /** * Create a spawn_agent tool that can run a delegated task with a focused sub-agent. */ export declare function createSpawnAgentTool(config: SpawnAgentToolConfig): AgentTool; export {};