tasks.ts
1 import { feature } from 'bun:bundle' 2 import type { Task, TaskType } from './Task.js' 3 import { DreamTask } from './tasks/DreamTask/DreamTask.js' 4 import { LocalAgentTask } from './tasks/LocalAgentTask/LocalAgentTask.js' 5 import { LocalShellTask } from './tasks/LocalShellTask/LocalShellTask.js' 6 import { RemoteAgentTask } from './tasks/RemoteAgentTask/RemoteAgentTask.js' 7 8 /* eslint-disable @typescript-eslint/no-require-imports */ 9 const LocalWorkflowTask: Task | null = feature('WORKFLOW_SCRIPTS') 10 ? require('./tasks/LocalWorkflowTask/LocalWorkflowTask.js').LocalWorkflowTask 11 : null 12 const MonitorMcpTask: Task | null = feature('MONITOR_TOOL') 13 ? require('./tasks/MonitorMcpTask/MonitorMcpTask.js').MonitorMcpTask 14 : null 15 /* eslint-enable @typescript-eslint/no-require-imports */ 16 17 /** 18 * Get all tasks. 19 * Mirrors the pattern from tools.ts 20 * Note: Returns array inline to avoid circular dependency issues with top-level const 21 */ 22 export function getAllTasks(): Task[] { 23 const tasks: Task[] = [ 24 LocalShellTask, 25 LocalAgentTask, 26 RemoteAgentTask, 27 DreamTask, 28 ] 29 if (LocalWorkflowTask) tasks.push(LocalWorkflowTask) 30 if (MonitorMcpTask) tasks.push(MonitorMcpTask) 31 return tasks 32 } 33 34 /** 35 * Get a task by its type. 36 */ 37 export function getTaskByType(type: TaskType): Task | undefined { 38 return getAllTasks().find(t => t.type === type) 39 }