{"record":{"id":"d135755c9f91b790","repo":"ruvnet/ruflo","slug":"unknown-worker-type-type","errorCode":null,"errorMessage":"Unknown worker type: ${type}","messagePattern":"Unknown worker type: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/worker-daemon.ts","lineNumber":2015,"sourceCode":"  /**\n   * Local preload worker\n   */\n  private async runPreloadWorkerLocal(): Promise<unknown> {\n    return {\n      timestamp: new Date().toISOString(),\n      mode: 'local',\n      resourcesPreloaded: 0,\n      cacheStatus: 'active',\n    };\n  }\n\n  /**\n   * Manually trigger a worker\n   */\n  async triggerWorker(type: WorkerType): Promise<WorkerResult> {\n    const workerConfig = this.config.workers.find(w => w.type === type);\n    if (!workerConfig) {\n      throw new Error(`Unknown worker type: ${type}`);\n    }\n    // #2251 — wait for headless probe to settle before running. Without\n    // this, on-demand `daemon trigger -w <worker>` races the constructor's\n    // fire-and-forget init and ALWAYS falls through to local mode even\n    // when `claude` is on PATH and scheduled fires of the same worker\n    // use headless correctly. Scheduled fires already wait long enough\n    // (timer + offset) that this is a no-op for them.\n    await this.headlessInitPromise;\n    // #2661 root-fix — an explicit manual trigger bypasses the repository-\n    // supervisor gate (still budget/dedup-gated) — see runWorkerLogic()'s\n    // doc comment.\n    return this.executeWorker(workerConfig, { manualTrigger: true });\n  }\n\n  /**\n   * Enable/disable a worker\n   */\n  setWorkerEnabled(type: WorkerType, enabled: boolean): void {","sourceCodeStart":1997,"sourceCodeEnd":2033,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/services/worker-daemon.ts#L1997-L2033","documentation":"Thrown by WorkerDaemon.triggerWorker(type) when the given type has no entry in this.config.workers. config.workers is the daemon's built-in worker table (ultralearn, optimize, consolidate, predict, audit, map, preload, deepdive, document, refactor, benchmark, testgaps — plus backup/harness in the WorkerType union), so the type must be both a valid WorkerType AND present/enabled in the daemon's config. Note the trigger itself also awaits headlessInitPromise and bypasses the repository-supervisor gate (#2661), so the failure happens before any of that.","triggerScenarios":"Calling daemon.triggerWorker('someType') or `claude-flow daemon trigger -w <type>` with a type not in the 12/14 built-in workers (typo like 'optimze', or a custom type the daemon was never configured with); passing a WorkerType union value such as 'backup' or 'harness' that is not in the default workers table.","commonSituations":"CLI users running `daemon trigger -w <name>` with a misspelled worker name; scripts assuming every WorkerType union member is triggerable; forks that extend WorkerType but forget to add a WorkerConfig entry; config filters that removed a worker from this.config.workers while a scheduler still references it.","solutions":["Use one of the configured worker types: ultralearn, optimize, consolidate, predict, audit, map, preload, deepdive, document, refactor, benchmark, testgaps","List the daemon's actual workers (`daemon status` or the workers config) before triggering programmatically","If you need a custom worker type, add a matching WorkerConfig entry to the daemon config so config.workers.find() succeeds","Check for typos in the -w flag value — the error echoes the exact type it could not find"],"exampleFix":"// before\nawait daemon.triggerWorker('optimze' as WorkerType); // typo -> Unknown worker type: optimze\n\n// after\nawait daemon.triggerWorker('optimize');","handlingStrategy":"type-guard","validationCode":"const daemon = getDaemon(projectRoot);\nconst configured = daemon.config.workers.map(w => w.type);\nif (!configured.includes(requestedType)) {\n  throw new Error(`Worker '${requestedType}' not configured. Available: ${configured.join(', ')}`);\n}\nawait daemon.triggerWorker(requestedType as WorkerType);","typeGuard":"import type { WorkerType } from './services/worker-daemon.js';\n\nconst DAEMON_WORKER_TYPES = [\n  'ultralearn', 'optimize', 'consolidate', 'predict', 'audit', 'map',\n  'preload', 'deepdive', 'document', 'refactor', 'benchmark', 'testgaps',\n  'backup', 'harness',\n] as const satisfies readonly WorkerType[];\n\nfunction isDaemonWorkerType(value: unknown): value is WorkerType {\n  return typeof value === 'string' && (DAEMON_WORKER_TYPES as readonly string[]).includes(value);\n}","tryCatchPattern":"try {\n  await daemon.triggerWorker(type);\n} catch (e) {\n  if (/^Unknown worker type:/.test(String(e?.message))) {\n    // surface the configured list instead of the raw error\n    const available = daemon.config.workers.map(w => w.type).join(', ');\n    throw new Error(`Unknown worker type '${type}'. Configured workers: ${available}`);\n  }\n  throw e;\n}","preventionTips":["Drive worker selection from the daemon's config.workers list rather than a hand-maintained string","Validate CLI input against the WorkerType union before invoking triggerWorker","Remember the WorkerType union is wider than the default 12 configured workers — union membership alone is not enough"],"tags":["worker","daemon","enum","validation","background-workers"],"backgroundTag":"invalid-enum-value","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}