guards.ts
tasks/LocalShellTask/guards.ts
42
Lines
1552
Bytes
3
Exports
3
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 shell-safety, tasks-background-jobs. It contains 42 lines, 3 detected imports, and 3 detected exports.
Important relationships
Detected exports
BashTaskKindLocalShellTaskStateisLocalShellTask
Keywords
taskshellcommandagentidmonitorlocal_bashlocalshelltasktaskstatebasebashtaskkindbashlocalshelltaskstate
Detected imports
../../Task.js../../types/ids.js../../utils/ShellCommand.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
// Pure type + type guard for LocalShellTask state.
// Extracted from LocalShellTask.tsx so non-React consumers (stopTask.ts via
// print.ts) don't pull React/ink into the module graph.
import type { TaskStateBase } from '../../Task.js'
import type { AgentId } from '../../types/ids.js'
import type { ShellCommand } from '../../utils/ShellCommand.js'
export type BashTaskKind = 'bash' | 'monitor'
export type LocalShellTaskState = TaskStateBase & {
type: 'local_bash' // Keep as 'local_bash' for backward compatibility with persisted session state
command: string
result?: {
code: number
interrupted: boolean
}
completionStatusSentInAttachment: boolean
shellCommand: ShellCommand | null
unregisterCleanup?: () => void
cleanupTimeoutId?: NodeJS.Timeout
// Track what we last reported for computing deltas (total lines from TaskOutput)
lastReportedTotalLines: number
// Whether the task has been backgrounded (false = foreground running, true = backgrounded)
isBackgrounded: boolean
// Agent that spawned this task. Used to kill orphaned bash tasks when the
// agent exits (see killShellTasksForAgent). Undefined = main thread.
agentId?: AgentId
// UI display variant. 'monitor' → shows description instead of command,
// 'Monitor details' dialog title, distinct status bar pill.
kind?: BashTaskKind
}
export function isLocalShellTask(task: unknown): task is LocalShellTaskState {
return (
typeof task === 'object' &&
task !== null &&
'type' in task &&
task.type === 'local_bash'
)
}