Skip to main content

Module tasks

Module tasks 

Source
Expand description

Background tasks: a run that outlives the prompt (#225).

/bg <prompt> starts the same run eclipse run would — same workspace, same config, same profile, same tool policy — in a detached process with its own session id, and returns to the composer at once. Two verbs read one registry: /tasks lists it, and eclipse doctor looks at it for entries whose process is gone.

The registry is one directory: <state>/tasks/, one <session>.json per task, written by the parent when it spawns (state starting, with the child’s pid) and by the child at start and after each turn. Beside it sits <session>.log — the child’s own stdout and stderr, which is where a failure explains itself without the registry having to guess.

The state is read through the pid, not trusted from the file. A process that was killed writes no final line, so a file that says running beside a pid that is gone is died: the honest answer, and the one that stops a stale entry from claiming to be alive all day. The pid is paired with the kernel’s start time for that process so a recycled pid cannot make an old entry look alive again.

Structs§

Registry
The registry: one directory, one file per task.
Task
One background run.
Tracker
A task’s entry, kept up to date by the process doing the work.

Enums§

State
Where a task is.

Constants§

BG
The word that starts a background run.
DIR
The directory, under the state directory, that holds the registry.
TASKS
The word that lists them.

Functions§

bg_prompt
The prompt behind a /bg line, or None when the line is not one.
bg_refusal
Why /bg is not a thing on surface.
describe_event
The one place a child turns an AgentEvent into the row’s last line.