/** * TaskManager — Main orchestrator for scheduled and self-running tasks. * * Manages the full task lifecycle: create, schedule, execute, pause, resume, delete. * Auto-selects TaskStore and TaskBackend based on config. * * Usage: * const neurolink = new NeuroLink({ tasks: { backend: "bullmq" } }); * await neurolink.tasks.create({ name: "monitor", prompt: "...", schedule: { type: "interval", every: 60000 } }); */ import { type NeuroLinkExecutable, type Task, type TaskDefinition, type TaskManagerConfig, type TaskRunResult, type TaskStatus } from "../types/index.js"; export declare class TaskManager { private neurolink; private config; private store; private backend; private executor; private initialized; private initPromise; /** In-memory callback registry (not serializable to store) */ private callbacks; /** Emitter reference — set by NeuroLink on integration */ private emitter?; constructor(neurolink: NeuroLinkExecutable, config?: TaskManagerConfig); /** Set the event emitter (called by NeuroLink during integration) */ setEmitter(emitter: { emit(event: string, ...args: unknown[]): boolean; }): void; private ensureInitialized; private doInitialize; private getStore; private getBackend; private getExecutor; create(definition: TaskDefinition): Promise; get(taskId: string): Promise; list(filter?: { status?: TaskStatus; }): Promise; update(taskId: string, updates: Partial): Promise; /** Run a task immediately (outside of its schedule) */ run(taskId: string): Promise; pause(taskId: string): Promise; resume(taskId: string): Promise; delete(taskId: string): Promise; runs(taskId: string, options?: { limit?: number; status?: string; }): Promise; shutdown(): Promise; /** Check if the backend is healthy */ isHealthy(): Promise; private restoreScheduledTask; private rollbackTaskUpdate; /** * Called by the backend on each scheduled tick. * Executes the task, updates state, fires callbacks/events. */ private onTaskTick; /** * Re-schedule all active tasks from store. * Called on initialization to handle process restarts. */ private rescheduleActiveTasks; private emit; }