/** * SubAgent tool: spawn independent cortex-based sub-agents for delegated work. * * Supports foreground (blocking) and background (async) execution modes. * Each sub-agent is an independent CortexAgent with its own message array * and empty context slots. * * The SubAgent tool is ALWAYS excluded from child agents to prevent * recursive spawning. * * References: * - docs/cortex/tools/sub-agent.md * - docs/cortex/plans/phase-4-sub-agents-and-skills.md */ import { Type, type Static } from 'typebox'; export declare const SubAgentParams: Type.TObject<{ instructions: Type.TString; tools: Type.TOptional>; systemPrompt: Type.TOptional; maxTurns: Type.TOptional; maxCost: Type.TOptional; background: Type.TOptional; }>; export type SubAgentParamsType = Static; export interface SubAgentDetails { taskId: string; background: boolean; status: string; durationMs: number | null; turns: number | null; cost: number | null; /** Model ID used by the sub-agent (inherited from parent). */ modelId?: string; } /** * Configuration passed to the SubAgent tool factory. * The CortexAgent provides all of these at tool registration time. */ export interface SubAgentToolConfig { /** * Spawn a sub-agent and run it. Returns the result when complete. * The factory function handles CortexAgent creation, budget guard * inheritance, tool filtering, and lifecycle management. */ spawnSubAgent: (params: SubAgentParamsType) => Promise<{ taskId: string; output: string; status: string; usage: { turns: number; cost: number; durationMs: number; }; }>; /** * Spawn a background sub-agent. Returns the task ID immediately. */ spawnBackgroundSubAgent: (params: SubAgentParamsType) => Promise<{ taskId: string; }>; /** * Check if another sub-agent can be spawned (concurrency limit). */ canSpawn: () => boolean; /** * Optional consumer gate consulted in addition to the concurrency limit * (e.g. budget or policy). Returns whether a spawn is allowed and, if not, * a reason to surface to the model. Defaults to allowed when omitted. */ checkConsumerSpawn?: () => { allowed: boolean; reason?: string; }; /** * Get concurrency info for error messages. */ getConcurrencyInfo: () => { active: number; limit: number; }; /** * Get the model ID for the child agent. * Child agents inherit the parent's primary model. */ getModelId: () => string; } export declare const SUB_AGENT_TOOL_NAME = "SubAgent"; /** * Create the SubAgent tool. * * Returns a Cortex-native tool. CortexAgent adapts it to pi-agent-core's * execute signature when synchronizing the tool inventory. */ export declare function createSubAgentTool(config: SubAgentToolConfig): { name: string; description: string; parameters: typeof SubAgentParams; execute: (args: unknown) => Promise; }; //# sourceMappingURL=sub-agent.d.ts.map