tasks.ts
tasks.ts
40
Lines
1355
Bytes
2
Exports
6
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with tasks-background-jobs. It contains 40 lines, 6 detected imports, and 2 detected exports.
Important relationships
Detected exports
getAllTasksgetTaskByType
Keywords
taskstasklocalworkflowtaskmonitormcptaskdreamtasklocalagenttasklocalshelltaskremoteagenttaskfeaturetasktype
Detected imports
bun:bundle./Task.js./tasks/DreamTask/DreamTask.js./tasks/LocalAgentTask/LocalAgentTask.js./tasks/LocalShellTask/LocalShellTask.js./tasks/RemoteAgentTask/RemoteAgentTask.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { feature } from 'bun:bundle'
import type { Task, TaskType } from './Task.js'
import { DreamTask } from './tasks/DreamTask/DreamTask.js'
import { LocalAgentTask } from './tasks/LocalAgentTask/LocalAgentTask.js'
import { LocalShellTask } from './tasks/LocalShellTask/LocalShellTask.js'
import { RemoteAgentTask } from './tasks/RemoteAgentTask/RemoteAgentTask.js'
/* eslint-disable @typescript-eslint/no-require-imports */
const LocalWorkflowTask: Task | null = feature('WORKFLOW_SCRIPTS')
? require('./tasks/LocalWorkflowTask/LocalWorkflowTask.js').LocalWorkflowTask
: null
const MonitorMcpTask: Task | null = feature('MONITOR_TOOL')
? require('./tasks/MonitorMcpTask/MonitorMcpTask.js').MonitorMcpTask
: null
/* eslint-enable @typescript-eslint/no-require-imports */
/**
* Get all tasks.
* Mirrors the pattern from tools.ts
* Note: Returns array inline to avoid circular dependency issues with top-level const
*/
export function getAllTasks(): Task[] {
const tasks: Task[] = [
LocalShellTask,
LocalAgentTask,
RemoteAgentTask,
DreamTask,
]
if (LocalWorkflowTask) tasks.push(LocalWorkflowTask)
if (MonitorMcpTask) tasks.push(MonitorMcpTask)
return tasks
}
/**
* Get a task by its type.
*/
export function getTaskByType(type: TaskType): Task | undefined {
return getAllTasks().find(t => t.type === type)
}