import { TaskState, TaskStatus } from '../types.js'; export { TERMINAL_STATUSES } from '../types.js'; /** * Check if a session is still active. */ export declare function isSessionActive(task: TaskState): boolean; declare class TaskManager { private tasks; private cleanupInterval; private healthCheckInterval; private rateLimitTimer; private currentCwd; private persistTimeout; private persistDebounceMs; private outputPersistDebounceMs; private lastPersistTrigger; private lastPersistTime; private retryCallback; private executeCallback; private statusChangeCallback; private outputCallback; private taskCreatedCallback; private taskDeletedCallback; constructor(); /** * Set the current workspace and load persisted tasks * Also triggers auto-retry for rate-limited tasks */ setCwd(cwd: string): void; /** * Register a callback to be called when a rate-limited task should be retried * Callback should return the new task ID */ onRetry(callback: (task: TaskState) => Promise): void; /** * Register a callback to execute a waiting task when dependencies are satisfied */ onExecute(callback: (task: TaskState) => Promise): void; onStatusChange(callback: (task: TaskState, previousStatus: TaskStatus) => void): void; onOutput(callback: (taskId: string, line: string) => void): void; onTaskCreated(callback: (task: TaskState) => void): void; onTaskDeleted(callback: (taskId: string) => void): void; /** * Process waiting tasks and start those with satisfied dependencies */ private processWaitingTasks; /** * Validate dependencies for a new task * Returns error message if invalid, null if valid */ validateDependencies(dependsOn: string[], newTaskId?: string): string | null; /** * Get dependency status info for a task */ getDependencyStatus(taskId: string): { satisfied: boolean; missing: string[]; failed: string[]; pending: string[]; } | null; /** * Force start a waiting task, bypassing failed/missing dependencies */ forceStartTask(taskId: string): Promise<{ success: boolean; taskId?: string; bypassedDeps?: string[]; error?: string; }>; /** * Process rate-limited tasks and trigger retries for those ready */ private processRateLimitedTasks; /** * Schedule the next rate-limit retry check based on earliest nextRetryTime. */ private scheduleRateLimitCheck; /** * Get all rate-limited tasks */ getRateLimitedTasks(): TaskState[]; /** * Expedite all rate-limited tasks by moving their next retry time up. * Called after recovery so stalled tasks benefit. * Tasks are staggered to avoid thundering herd. */ expediteRateLimitedTasks(baseDelayMs?: number): void; /** * Clear all tasks from memory (used by clear_tasks tool) * Clears all tasks from memory and aborts running sessions. */ clearAllTasks(): Promise; /** * Manually trigger retry of a rate-limited task * Returns the new task ID on success */ triggerManualRetry(taskId: string): Promise<{ success: boolean; newTaskId?: string; error?: string; }>; /** * Persist tasks to disk (debounced with max-wait). * Under rapid state changes (100 tasks producing output), the trailing-edge * debounce could defer indefinitely. The max-wait ensures persistence happens * at least every MAX_PERSIST_DELAY_MS regardless of incoming change rate. */ private schedulePersist; /** * Persist tasks immediately (async — non-blocking). */ private persistNow; private startCleanup; /** * Start periodic health check for running sessions * Monitors for stalled sessions and enforces hard timeouts. */ private startHealthCheck; /** * Check all RUNNING tasks to verify their sessions are healthy * Checks all RUNNING tasks for health: heartbeat, hard timeout, and stalls. */ private checkSessionHealth; private cleanup; createTask(prompt: string, cwd?: string, model?: string, options?: { autonomous?: boolean; isResume?: boolean; retryInfo?: import('../types.js').RetryInfo; dependsOn?: string[]; labels?: string[]; provider?: import('../types.js').Provider; fallbackAttempted?: boolean; switchAttempted?: boolean; timeout?: number; }): TaskState; getTask(id: string): TaskState | null; updateTask(id: string, updates: Partial): TaskState | null; /** * Write to output file only — skips in-memory array and callbacks. * Use for verbose debug data (reasoning, internal events) that should be * available in the file for debugging but not waste tokens in MCP resources. */ appendOutputFileOnly(id: string, line: string): void; appendOutput(id: string, line: string): void; getAllTasks(statusFilter?: TaskStatus): TaskState[]; cancelTask(id: string): { success: boolean; alreadyDead?: boolean; error?: string; }; shutdown(): Promise; } export declare const taskManager: TaskManager; //# sourceMappingURL=task-manager.d.ts.map