ShellJobManager
Category: Agent
Source: shell_job_manager.dart
Enums
JobStatus
| Value | Description |
|---|---|
running | |
failed |
Classes
sealed JobEvent
JobStarted
Constructor
JobStarted(this.id, this.command)Properties
| Property | Type | Description |
|---|---|---|
id | int | |
command | String |
JobExited
Constructor
JobExited(this.id, this.exitCode)Properties
| Property | Type | Description |
|---|---|---|
id | int | |
exitCode | int |
JobError
Constructor
JobError(this.id, this.error)Properties
| Property | Type | Description |
|---|---|---|
id | int | |
error | Object |
ShellJob
Constructor
ShellJob({
required this.id,
required this.command,
required this.startTime,
required this.handle,
required this.output,
this.traceSpan,
})Properties
| Property | Type | Description |
|---|---|---|
id | int | |
command | String | |
startTime | DateTime | |
handle | RunningCommandHandle | |
output | LineRingBuffer | Interleaved stdout and stderr output, capped by the ring buffer limits. |
status | JobStatus | |
exitCode | int? | |
traceSpan | ObservabilitySpan? |
ShellJobManager
Manages the lifecycle of background shell jobs.
Each job's output is captured into a [LineRingBuffer] and status transitions are broadcast as [JobEvent]s, so the UI can update in real time without polling.
Constructor
ShellJobManager(this.executor, {this._obs})Properties
| Property | Type | Description |
|---|---|---|
executor | CommandExecutor | |
events | Stream<JobEvent> get | |
jobs | List<ShellJob> get | All known jobs (running, exited, and killed), sorted by ID (oldest first). |
events | Stream<JobEvent> get | |
jobs | List<ShellJob> get | All known jobs (running, exited, and killed), sorted by ID (oldest first). |
Methods
Future<ShellJob> start(String command)
Starts [command] as a background job and begins capturing its output.
Returns immediately with the [ShellJob] handle. Output from both stdout and stderr is fed into the job's [LineRingBuffer], and a [JobStarted] event is emitted on [events].
ShellJob? getJob(int id)
Future<void> kill(int id)
Sends SIGTERM to the job with the given [id].
No-op if the job doesn't exist or has already exited.
Future<void> shutdown()
Tears down the manager, stopping all running jobs.
Sends SIGTERM first and waits briefly for graceful exit, then follows up with SIGKILL for any stubborn processes. The [events] stream is closed after cleanup, so no further events will be emitted.