/** * UnifiedTaskManager, central task lifecycle management for all subsystem * task kinds (exec, agent, acp, scheduler, daemon, mcp, plugin, integration). * * Responsibilities: * - Create tasks with type-safe params * - Enforce lifecycle state machine transitions * - Track parent/child relationships * - Emit TaskEvents via RuntimeEventBus at each transition * - Update RuntimeState.tasks domain via Zustand store * - Track per-kind concurrency * - Support retry policies */ import { GoodVibesSdkError } from '@pellux/goodvibes-errors'; import type { RuntimeStore } from '../store/index.js'; import type { RuntimeEventBus } from '../events/index.js'; import type { RuntimeTask, TaskKind, TaskLifecycleState } from '../store/domains/tasks.js'; import type { TaskManager, TaskCreateParams, TaskUpdateParams, TaskCancelParams, TaskFailParams } from './types.js'; import type { FeatureFlagReader } from '../feature-flags/index.js'; /** Thrown when a requested task lifecycle transition is not permitted. */ export declare class TaskTransitionError extends GoodVibesSdkError { readonly code: 'TASK_TRANSITION_ERROR'; readonly taskId: string; readonly from: TaskLifecycleState; readonly to: TaskLifecycleState; constructor(taskId: string, from: TaskLifecycleState, to: TaskLifecycleState); } /** Thrown when a task ID cannot be found in the registry. */ export declare class TaskNotFoundError extends GoodVibesSdkError { readonly code: 'TASK_NOT_FOUND'; readonly taskId: string; constructor(taskId: string); } /** Thrown when cancellation is attempted on a non-cancellable task. */ export declare class TaskNotCancellableError extends GoodVibesSdkError { readonly code: 'TASK_NOT_CANCELLABLE'; readonly taskId: string; constructor(taskId: string); } /** * UnifiedTaskManager, implements TaskManager using a TaskRegistry for * in-memory lookup and a Zustand store + RuntimeEventBus for persistence * and event emission. */ export declare class UnifiedTaskManager implements TaskManager { private readonly _registry; private readonly _store; private readonly _dispatch; private readonly _bus; /** Session ID for emitter context. */ private readonly _sessionId; private readonly _featureFlags; /** * @param store - The Zustand runtime store to dispatch state updates to. * @param bus - The RuntimeEventBus to emit task lifecycle events on. * @param sessionId - The current session identifier for emitter context. */ constructor(store: RuntimeStore, bus: RuntimeEventBus, sessionId: string, featureFlags?: FeatureFlagReader); private _isEnabled; private _requireEnabled; createTask(params: TaskCreateParams): RuntimeTask; startTask(taskId: string): RuntimeTask; blockTask(taskId: string, reason: string): RuntimeTask; completeTask(taskId: string, result?: unknown): RuntimeTask; failTask(taskId: string, params: TaskFailParams): RuntimeTask; cancelTask(taskId: string, params?: TaskCancelParams): RuntimeTask; updateTask(taskId: string, params: TaskUpdateParams): RuntimeTask; getTask(taskId: string): RuntimeTask | undefined; getTasksByKind(kind: TaskKind): RuntimeTask[]; getRunningTasks(): RuntimeTask[]; getRunningCount(kind: TaskKind): number; getChildTasks(parentTaskId: string): RuntimeTask[]; getTaskStatus(taskId: string): TaskLifecycleState | undefined; retryTask(taskId: string): RuntimeTask; /** * Returns a task or throws TaskNotFoundError. */ private _requireTask; /** * Validates a transition is permitted; throws TaskTransitionError otherwise. */ private _requireTransition; /** * Applies a state transition to a task, updates registry and store. */ private _applyTransition; /** * Adds a child task ID to a parent task's childTaskIds array. */ private _patchChildIds; /** * Constructs a minimal EmitterContext for a given task. */ private _makeCtx; /** * Dispatches TASK_CREATED state update to the Zustand store. */ private _dispatchCreated; /** * Syncs an updated task to the Zustand store, adjusting status index arrays. */ private _syncTaskToStore; } //# sourceMappingURL=manager.d.ts.map