/** * Task tool: delegate a focused task to a specialized subagent. * * Mirrors the Claude Code `Task` tool. The parent agent decides *when* to * delegate based on each agent's `description` (there is no deterministic gate) * and selects *which* agent via `subagent_type`. The chosen agent runs in a * fresh, isolated child process (SubagentPool) and only its final answer is * returned to the parent. * * Enabled by default (the `enableSubagent` setting defaults to true); disable * with `enableSubagent: false`. The `--enable-subagents` flag still force-enables * it. Nesting is bounded by the tree-wide depth cap (maxSubagentDepth, default 2: * a spawned subagent may itself delegate one more level, and depth-2 grandchildren * cannot). See buildSessionOptions in main.ts. */ import { type AgentDefinition } from "../agent-frontmatter.js"; import type { ToolDefinition } from "../extensions/types.js"; export { summarizeAgentDescription } from "../agent-registry.js"; /** System prompt appendix for the main session when the Task tool is enabled. * Instructs the parent agent on when and how to delegate effectively. The * available agents themselves are listed once, authoritatively, in the * `` block the system prompt emits whenever the Task tool is * active (see agent-session `_rebuildSystemPrompt`); this appendix references * that list rather than re-rendering the roster and paying for it twice. */ /** * Build the main-session subagent instructions appended to the system prompt. * * The prose lives in `templates/prompts/task-*.md` and reaches here through the * build-time embed. It is the largest block of always-on text hoocode emits * (~600 tok/turn once the Task tool is on) and it had no interpolation beyond * the single background slot, so keeping it as a TypeScript string constant * bought nothing and made it awkward to edit as the prose it is. * * The detailed background/barrier guidance (the two heaviest bullets) is only * emitted when the project actually has background-capable agents; otherwise a * single concise line covers the per-call `background: true` escape hatch. This * keeps the always-on cost down for the common case where nothing runs in the * background. `cwd` is used only to detect those agents. */ export declare function buildTaskMainPrompt(cwd?: string): string; export interface TaskToolDetails { subagent_type: string; ok: boolean; error?: string; taskId: number; /** Pool-level task id usable for resume/polling. */ poolTaskId?: string; /** True when dispatched as a non-blocking background task. */ background?: boolean; } export interface TaskOutputDetails { /** The handle queried, when a specific task was named. */ task_id?: string; /** running | done | collected | failed | stalled | timeout | cancelled | list | empty | unknown */ status: string; ok: boolean; /** Number of subagents still running, included on roster/list responses. */ outstanding?: number; } /** Create the Task tool definition. Registered as a customTool when enabled. */ export declare function createTaskToolDefinition(cwd?: string): ToolDefinition; /** * For a `fork: true` agent, fork the parent's session so the subagent inherits the * full parent conversation (and its prompt cache) instead of starting fresh. Returns * the forked session file to dispatch the child with, or undefined to fall back to a * fresh session (non-fork agent, no parent session, or an empty/invalid source). */ export declare function resolveForkSessionFile(def: Pick, parentSessionPath: string | undefined, cwd: string): string | undefined; /** * TaskOutput tool: check on background subagents and pull their results. * * Background `Task` calls don't push their body into the conversation — they * leave it in the inbox and post a compact notification. TaskOutput is how the * model pulls a body, checks liveness, or waits. It never throws on a valid * handle (an error tool result would only confuse the loop): it reports status * instead. Modes: `list` (roster), a `task_id` to read/check one, and `wait` to * block until one task — or all outstanding tasks — finish. */ export declare function createTaskOutputToolDefinition(): ToolDefinition; //# sourceMappingURL=subagent.d.ts.map