/** * BackgroundManager — lifecycle management for background agent tasks. * * Each task transitions: pending → running → completed | error | cancelled. * Tasks are persisted to SQLite so they survive plugin restarts. * The manager itself does NOT spawn sessions — that's the Spawner's job. */ import type { Database } from '../sqlite'; import type { BackgroundTaskStatus } from '../../constants/background'; export interface BackgroundTask { id: string; /** Agent that requested the spawn. */ parentAgent: string; /** Agent to run in the background session. */ targetAgent: string; /** The prompt to send. */ prompt: string; /** Optional additional context. */ context?: string; /** Session ID once spawned (null while pending). */ sessionId: string | null; /** Current lifecycle state. */ status: BackgroundTaskStatus; /** Model identifier used for concurrency accounting. */ model: string; /** Short summary or last output snippet. */ summary: string; /** When the task was created. */ createdAt: number; /** When the task last changed state or output. */ updatedAt: number; /** Error message if status === 'error'. */ error?: string; } export declare class BackgroundManager { private readonly db; private stmts; constructor(db: Database); private bootstrap; /** Enqueue a new task in pending state. Returns the task. */ enqueue(params: { id: string; parentAgent: string; targetAgent: string; prompt: string; context?: string; model: string; }): BackgroundTask; /** Transition a task to running with a session ID. */ markRunning(id: string, sessionId: string): void; /** Transition a task to completed with optional summary. */ markCompleted(id: string, summary?: string): void; /** Transition a task to error. */ markError(id: string, error: string): void; /** Cancel a task. */ cancel(id: string): boolean; /** Update a task's summary (for polling output snapshots). */ updateSummary(id: string, summary: string): void; getById(id: string): BackgroundTask | null; getByStatus(status: BackgroundTaskStatus): BackgroundTask[]; getAll(limit?: number): BackgroundTask[]; countRunning(): number; countRunningForModel(model: string): number; countPending(): number; } //# sourceMappingURL=manager.d.ts.map