πŸ“„ File detail

tasks/types.ts

🧩 .tsπŸ“ 47 linesπŸ’Ύ 1,691 bytesπŸ“ text
← Back to All Files

🎯 Use case

This module is a β€œtypes.ts” task implementation β€” concrete work units the task runner schedules and monitors. On the API surface it exposes TaskState, BackgroundTaskState, and isBackgroundTask β€” mainly types, interfaces, or factory objects. It composes internal code from DreamTask, InProcessTeammateTask, LocalAgentTask, LocalShellTask, and LocalWorkflowTask (relative imports). What the file header says: Union of all concrete task state types Use this for components that need to work with any task type.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

Union of all concrete task state types Use this for components that need to work with any task type

πŸ“€ Exports (heuristic)

  • TaskState
  • BackgroundTaskState
  • isBackgroundTask

πŸ–₯️ Source preview

// Union of all concrete task state types
// Use this for components that need to work with any task type

import type { DreamTaskState } from './DreamTask/DreamTask.js'
import type { InProcessTeammateTaskState } from './InProcessTeammateTask/types.js'
import type { LocalAgentTaskState } from './LocalAgentTask/LocalAgentTask.js'
import type { LocalShellTaskState } from './LocalShellTask/guards.js'
import type { LocalWorkflowTaskState } from './LocalWorkflowTask/LocalWorkflowTask.js'
import type { MonitorMcpTaskState } from './MonitorMcpTask/MonitorMcpTask.js'
import type { RemoteAgentTaskState } from './RemoteAgentTask/RemoteAgentTask.js'

export type TaskState =
  | LocalShellTaskState
  | LocalAgentTaskState
  | RemoteAgentTaskState
  | InProcessTeammateTaskState
  | LocalWorkflowTaskState
  | MonitorMcpTaskState
  | DreamTaskState

// Task types that can appear in the background tasks indicator
export type BackgroundTaskState =
  | LocalShellTaskState
  | LocalAgentTaskState
  | RemoteAgentTaskState
  | InProcessTeammateTaskState
  | LocalWorkflowTaskState
  | MonitorMcpTaskState
  | DreamTaskState

/**
 * Check if a task should be shown in the background tasks indicator.
 * A task is considered a background task if:
 * 1. It is running or pending
 * 2. It has been explicitly backgrounded (not a foreground task)
 */
export function isBackgroundTask(task: TaskState): task is BackgroundTaskState {
  if (task.status !== 'running' && task.status !== 'pending') {
    return false
  }
  // Foreground tasks (isBackgrounded === false) are not yet "background tasks"
  if ('isBackgrounded' in task && task.isBackgrounded === false) {
    return false
  }
  return true
}