diff --git a/v3/@claude-flow/cli/src/services/worker-queue.ts b/v3/@claude-flow/cli/src/services/worker-queue.ts index f009c0f050..1a6c42702e 100644 --- a/v3/@claude-flow/cli/src/services/worker-queue.ts +++ b/v3/@claude-flow/cli/src/services/worker-queue.ts @@ -312,8 +312,23 @@ export class WorkerQueue extends EventEmitter { timeoutMs?: number; } ): Promise { - const taskId = `task-${Date.now()}-${randomUUID().slice(0, 8)}`; + // Initialize if needed + if (!this.initialized) { + await this.initialize(); + } + + // Validate worker type + if (!workerType || typeof workerType !== 'string') { + throw new Error('Invalid worker type'); + } + + // Validate priority const priority = options?.priority || 'normal'; + if (!['critical', 'high', 'normal', 'low'].includes(priority)) { + throw new Error(`Invalid priority: ${priority}`); + } + + const taskId = `task-${Date.now()}-${randomUUID().slice(0, 8)}`; const task: QueueTask = { id: taskId,