import { ensureQueueDir } from './storage';
import { resumeInterruptedJobs } from './engine';
import './handlers';

export { enqueue, cancelJob } from './engine';
export { readJob, listAllJobs } from './storage';
export { registerHandler } from './handler-registry';
export { PermanentError } from './types';
export type {
  Job,
  JobStep,
  JobStatus,
  JobProgress,
  StepContext,
  JobHandler,
  JobHandlerStep,
  EnqueueParams,
} from './types';

export async function initQueue() {
  await ensureQueueDir();
  await resumeInterruptedJobs();
  console.log('[queue] Initialized');
}
