/** * TaskStore — single authoritative source for task state. * * Module-level singleton that replaces the old task-manager.ts. * Uses explicit state machine, ring buffer for output, and * deterministic cleanup on terminal transitions. */ import type { ChildProcess } from 'child_process'; import { type TaskState, type TaskRecord, type TaskSummary, type CreateTaskOptions } from './types.js'; export declare class TaskStore { private readonly tasks; private readonly maxTasks; private readonly maxOutputLines; constructor(maxTasks?: number, maxOutputLines?: number); /** * Create a new task. Returns the task record. * Task starts in 'created' state. */ createTask(opts: CreateTaskOptions): Promise; /** * Transition a task to a new state. * Returns true on success, false if the transition is invalid. * * On terminal transitions, runs the cleanup procedure. */ transitionTo(id: string, newState: TaskState, options?: { error?: string; metadata?: Record; }): Promise; /** * Set the process reference and PID on a task. */ setProcess(id: string, proc: ChildProcess): void; /** * Get the process reference for a task. */ getProcess(id: string): ChildProcess | undefined; /** * Append an output line to a task's ring buffer and output file. */ appendOutput(id: string, line: string): Promise; /** * Get a task by ID. */ getTask(id: string): TaskRecord | undefined; /** * Get all tasks. */ getAllTasks(): TaskRecord[]; /** * Get task counts by state. */ getTaskCounts(): Record; /** * Convert a TaskRecord to a TaskSummary (for external APIs). * Maps the new state field to the legacy 'status' field. */ toSummary(task: TaskRecord): TaskSummary; /** * Cancel a single running task. * Returns true if the task was successfully cancelled. */ cancelTask(id: string): Promise; /** * Cancel all running tasks (for shutdown). * Returns the number of tasks cancelled. */ cancelAll(): Promise; /** * Get stall warning for a running task. */ getStallWarning(task: TaskRecord): string | null; /** * Reset all state (for testing only). */ resetForTesting(): void; /** * Cleanup procedure for terminal transitions. */ private cleanupTerminal; /** * Generate a collision-free task ID. */ private generateUniqueId; /** * Evict oldest terminal tasks if at capacity. */ private evictIfNeeded; } export declare const taskStore: TaskStore; //# sourceMappingURL=store.d.ts.map