import type { ThreadRecord, ThreadStatus } from '../../core/types/thread-types.js'; export declare function isTerminalStatus(status: ThreadStatus): boolean; /** Tree identity: a thread's root is its metadata.rootThreadId, falling back to itself. */ export declare function getRootThreadId(t: ThreadRecord): string; /** All threads belonging to the tree rooted at rootId (root included). threads.json is * fully in-memory and small, so a full scan is fine. */ export declare function getTreeThreads(rootId: string): ThreadRecord[]; export interface TreeSummary { nodeCount: number; totalCostUsd: number; byStatus: Record; } export declare function summarizeTree(rootId: string): TreeSummary; export type SpawnGuardResult = { ok: true; } | { ok: false; reason: string; }; /** Resource guards evaluated before spawning a child thread under `parent`. * Three checks: width (children per thread), tree node count, and budget * (each ancestor's contract.budgetUsd against its subtree's actual cost, * plus a global per-tree cost ceiling). A failed guard should lead the agent * to escalate ([ABORT]) or re-plan — not to retry the spawn. */ export declare function checkSpawnGuards(parent: ThreadRecord | null): SpawnGuardResult; /** Record a freshly spawned child on its parent: always into childThreadIds (width/rework * counter); into waitingOn only when the parent intends to suspend on it (wait=true). */ export declare function registerChildSpawn(parentThreadId: string, childThreadId: string, wait: boolean): Promise; export interface ThreadTreeNode { threadId: string; status: ThreadStatus; templateName: string | null; activeAgent: string | null; costUsd: number; depth: number; createdAt: string; children: ThreadTreeNode[]; /** Present on root nodes only. */ rollup?: TreeSummary & { maxDepth: number; }; } /** Group the given threads into nested trees by metadata.parentThreadId. * Nodes whose parent is outside the set become roots. Root nodes carry a rollup. */ export declare function buildThreadTree(threads: ThreadRecord[]): ThreadTreeNode[];