Expand description
Shell commands that were moved out of the foreground and run on in the background.
Every shell command starts in the foreground. One is demoted when it has not exited by the
time a declared lifecycle.shell_grace_secs elapses, or when the call waiting on it is
abandoned or its task is canceled: the turn gets a work id and carries on, the command keeps
running on an OS thread of its own, and its output is written to a log in the session’s
records directory as it is read. With no shell_grace_secs a command is never demoted on a
clock.
The work id is an address. [DetachedRegistry] keeps every demoted command of the session,
running or finished, and the runtime-provided background-command tool
(crate::background_command), offered when shell_grace_secs is set, reads its state,
waits for it or stops it by that id. When a
command finishes, the runtime also enqueues a task on this capsule with
crate::origin::TaskOrigin::Completion carrying the exit code and the log’s path, unless
the agent already read the exit through the tool.
Constants§
- WORK_
ID_ PREFIX - Prefix on every work id. Distinct from
tsk_/ctx_/ses_so a reader oftrace.jsonlcan tell at a glance which id space a value belongs to.
Functions§
- new_
work_ id - A fresh work id, matching
^wrk_[0-9a-f]+$.