/** * TodoWrite tool: let the main agent maintain a visible todo list for the * current task. * * hoocode already has all the infrastructure this needs — the task store models * `{ title, status }` items with a per-turn lifecycle, and the TUI task panel * renders them. The only missing piece was a tool the model can call; this is * that thin adapter over `taskStore`. * * Semantics mirror Claude Code's TodoWrite: each call sends the FULL list and * REPLACES the previous one. Because the store is incremental (numeric ids), we * reconcile the incoming list against the existing main-agent tasks by position: * update items that are still there, create new ones, and drop the tail that was * removed. Reconciling (rather than clear-and-recreate) keeps ids stable so the * panel does not flicker and in-progress rows stay put. * * It is an optional, opt-in tool (enabled via the `enableTodoWrite` setting) and * is never registered inside a spawned subagent, so a subagent's todos cannot * leak into the parent's "main" task group. */ import { type ToolDefinition } from "../extensions/types.js"; import { type TaskStatus } from "../task-store.js"; export interface TodoWriteDetails { total: number; pending: number; inProgress: number; completed: number; } /** * Settle plan items the model left pinned at `in_progress` when a request ends. * * TodoWrite is bookkeeping the model performs by hand, and even strong models * routinely drop the final call that flips the last item to completed. Nothing * else writes main-plan rows, so without this the panel would keep claiming the * work is in flight until the next user message triggers `taskStore.reset()`. * The request is over, so the row is wrong either way — settle it to the honest * outcome instead of leaving it lying. * * Scope is deliberately narrow: * - Only `in_progress` main-plan items. `pending` rows are left alone: "never * started" is already an accurate reading of an item the model skipped. * - Only main-plan items. Subagent- and MCP-sourced rows settle through their * own lifecycles (subagent.ts, mcp-loader.ts) and must not be second-guessed * here. * - Nothing settles while any delegated task is still pending/in_progress: a * subagent outliving the parent's agent_end is still working the plan, so its * plan item is genuinely in progress. * * Returns the number of tasks settled. */ export declare function settleDanglingMainTasks(outcome: Extract): number; /** Create the TodoWrite tool definition. Registered as a customTool when enabled. */ export declare function createTodoWriteToolDefinition(): ToolDefinition; //# sourceMappingURL=todo.d.ts.map