tasks.ts 1.3 KB

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