Expand description
The stderr line protocol agentmux-srv uses to talk to whichever process
supervises it — the launcher in packaged builds and task dev
(crates/launcher/src/srv_spawner.rs), or the CEF host in
task dev:standalone (crates/cef/src/sidecar.rs).
srv formats these lines; both supervisors parse them. Putting the
vocabulary here means one definition instead of three string literals that
have to stay byte-identical by convention (the “keep in sync” pattern
docs/reports/REPORT_DRY_AND_MODULARITY_AUDIT_2026_09_06.md §2 counts 334
instances of).
Every line is single-line and prefix-tagged. In startup order:
AGENTMUXSRV-MIGRATING migrations:<n>— in-process migrations are about to run; supervisors extend their ESTART deadline. A new version’s first start printsAGENTMUXSRV-MIGRATING copying-previous-version:<v>before copying the previous version’s databases (migrations/carry_forward.rs); supervisors match the prefix only (migrating_line,is_migrating_line).AGENTMUXSRV-MIGRATION-BEGIN id:<id> description:<text>/AGENTMUXSRV-MIGRATION-END id:<id> duration_ms:<n>— one pending migration is starting / has finished, inside theAGENTMUXSRV-MIGRATINGwindow above. Before these existed, a slow migration was invisible past the initial count — the splash showed a bare, silently-running “Backend startup” clock with no indication anything unusual (a multi-minute migration) was happening inside it. Seedocs/reports/REPORT_SPLASH_SCREEN_ARCHITECTURE_RETHINK_2026_09_14.md§2.1. Only the launcher supervisor turns these into splash sub-rows (against the already-openbackendstage — a migration is not a separate top-level stage, it happens entirely inside that one); the CEF-host sidecar has no splash to report to and simply logs them like any other stderr line, same as it already did for the unparsed line before this existed.AGENTMUXSRV-STEP-BEGIN id:<id> label:<text>/AGENTMUXSRV-STEP-END id:<id> duration_ms:<n>[ status:error]— one data-preparation step besides a migration: copying the previous version’s data, a snapshot, waiting for another AgentMux’s migrations, the backup. Written by srv’s startup and byagentmux-srv migrate --prepare; the launcher shows each as a sub-row ofbackend, like a migration.AGENTMUXSRV-NEEDS-PREPARE reason:<text>— srv was started by a supervisor that prepares data (SUPERVISOR_PREPARES_ENV) and found data that needs preparing (a previous version to copy forward, or pending migrations); it exitsNEEDS_PREPARE_EXITbefore writing anything, and the supervisor runsagentmux-srv migrate --prepare, then starts it again.AGENTMUXSRV-MIGRATION-FAILED error:<text>— a migration failed and srv is about to exit 1 without emitting ESTART. Added by Phase 1 ofdocs/specs/SPEC_MIGRATION_SYSTEM_HARDENING_2026_08_03.md; before it, a failed migration was awarn!and srv booted anyway against a store in an unknown state.AGENTMUXSRV-ESTART ws:<addr> web:<addr> version:<v> buildtime:<t> instance:<id> pending_migrations:<n>— ready (Estart).AGENTMUXSRV-EVENT:<json>— a startup event for the launcher to log (parse_event_line).AGENTMUXSRV-UPGRADE version:<v> [approved:<how>:<id>] launcher:<path>(a portable) or… installer:<path>(asetup.exeinstall; the digest issha256:<hex>before it). The optionalapproved:token says who approved the restart; the launcher skips it. Any time after ESTART: the user chose “Upgrade & restart” and<path>is the launcher, or the installer, of a release srv downloaded and verified. The launcher checks it again, asks the user itself, and restarts into it (crates/launcher/src/upgrade_restart.rs).
Structs§
- Estart
- The fields of an
ESTART_PREFIXline. Endpoints arehost:port. - Migration
Begin - A parsed
MIGRATION_BEGIN_PREFIXline. - Migration
End - A parsed
MIGRATION_END_PREFIXline. - Step
Begin - A parsed
STEP_BEGIN_PREFIXline. Ids are code-chosen, without spaces. - StepEnd
- A parsed
STEP_END_PREFIXline. - Upgrade
Request - A parsed
UPGRADE_PREFIXline: upgrade toversionthroughtarget.
Enums§
- Declined
- Why the restart question ended without a restart: the second line of
UPGRADE_DECLINED_FILE(the first is the version). srv says it in words to the user and to the agents that asked. - Upgrade
Target - What an upgrade restarts into.
Constants§
- DATA_
DIR_ HELD_ EXIT - srv’s exit code when another srv already holds this data folder’s
srv.lock: one srv per set of databases (desktop app,agentmux start/run, a service). A refusal that does not clear until that server is closed, so a supervisor must not start it again by itself; the launcher shows the person a plain sentence instead of a failed start (task #49109). - ESTART_
PREFIX - Prefix of the line srv writes when it is ready to serve.
- EVENT_
PREFIX - Prefix of a startup event line; the rest of the line is its JSON.
- INSTALL_
RESULT_ FILE - Where the Linux launcher leaves why a
.deb/.rpmupgrade didn’t happen, inupdates/<version>/of the data folder: JSON{"version": "<v>", "error": "<one line>"}. Left when the password was refused or unavailable, the file failed its checks, or the install failed (the waiter that restarts the old version writes it). srv shows it in the version panel. - MIGRATING_
PREFIX - Prefix of the line srv writes before slow work that precedes ESTART (migrations, copying the previous version’s data); supervisors extend their ESTART deadline when they see it.
- MIGRATION_
BEGIN_ PREFIX - Prefix of the line srv writes to stderr just before applying one pending migration.
- MIGRATION_
END_ PREFIX - Prefix of the line srv writes to stderr just after one migration applies
successfully. (No
-ENDline is written on failure —up()returningErrgoes straight toAGENTMUXSRV-MIGRATION-FAILEDand srv exits.) - MIGRATION_
FAILED_ PREFIX - Prefix of the line srv writes to stderr immediately before exiting 1
because
run_pending_migrationsfailed. Supervisors match on this to fail fast with the real reason instead of waiting out the ESTART timeout. - NEEDS_
PREPARE_ EXIT - srv’s exit code after an
AGENTMUXSRV-NEEDS-PREPAREline. - NEEDS_
PREPARE_ PREFIX - Prefix of the line srv writes, under
SUPERVISOR_PREPARES_ENV, before exiting because its data needsmigrate --prepare. - SHARED_
FOLDER_ HELD_ EXIT - srv’s exit code (and
migrate’s) when another AgentMux of a different version holds the shared folder and this version’s data needs preparing first: a refusal that does not clear until that AgentMux is closed, so a supervisor must not start it again by itself. - SHARED_
FOLDER_ HELD_ PREFIX - Prefix of the line srv writes just before exiting
SHARED_FOLDER_HELD_EXIT. - STEP_
BEGIN_ PREFIX - Prefix of the line srv writes when a data-preparation step starts.
- STEP_
END_ PREFIX - Prefix of the line srv writes when that step ends.
- SUPERVISOR_
PREPARES_ ENV - Set to
1by a supervisor that runsagentmux-srv migrate --prepareitself (the launcher). srv then never copies, snapshots or migrates at boot: it checks read-only and exitsNEEDS_PREPARE_EXITwhen the data needs it. Without it (headless srv,task dev:standalone) srv prepares in-process. - UPGRADE_
DECLINED_ FILE - What the launcher leaves in
updates/of the data folder when the user answered No to the restart question, or the question lapsed: the version it asked about. srv reads it to stop saying “Restarting” (the launcher has no other way to tell it), so the user can start the upgrade again at once. - UPGRADE_
PREFIX - Prefix of the line srv writes when the user chose “Upgrade & restart”.
Functions§
- declined_
text - The contents of
UPGRADE_DECLINED_FILE: the version, then why. - estart_
line - is_
migrating_ line - migrating_
line AGENTMUXSRV-MIGRATING <what>:<detail>, e.g.migrations:3.- migration_
begin_ line - Migration ids (
m.id(), e.g."0020_agent_color_backfill") are a fixed, engineer-chosen identifier format with no spaces — never free text — so splittingid:<id> description:<text>on the first space is safe and exact, unlikedescriptionitself which is flattened viaone_line. - migration_
end_ line - migration_
failed_ line - Format the failure line srv emits. The error text is flattened to a single line (the protocol is line-delimited; a multi-line SQLite error would otherwise split into one tagged line and several untagged ones).
- needs_
prepare_ line - parse_
declined - The version and the reason a
UPGRADE_DECLINED_FILEholds. A file with only a version (an older launcher’s) has no reason. - parse_
estart_ line - Parse an
ESTART_PREFIXline;Nonefor any other line. A missing field reads as empty (or 0), as both supervisors always read it. - parse_
event_ line - The JSON of an
EVENT_PREFIXline;Nonefor any other line. - parse_
migration_ begin_ line - Parse a
MIGRATION_BEGIN_PREFIXline.Nonefor any other line, or a begin line missing theid:field it cannot be meaningfully split without. - parse_
migration_ end_ line - Parse a
MIGRATION_END_PREFIXline.Nonefor any other line, a malformed one, or a non-numeric/missingduration_ms:field. - parse_
migration_ failed_ line - Parse a stderr line. Returns the error message if this is a
MIGRATION_FAILED_PREFIXline,Nonefor any other line. Tolerates a missingerror:field and never returns an empty message, so callers can put the result straight into a user-facing dialog. - parse_
needs_ prepare_ line - The reason of a
NEEDS_PREPARE_PREFIXline;Nonefor any other line. - parse_
shared_ folder_ held_ line - The owner and the reason of a
SHARED_FOLDER_HELD_PREFIXline;Nonefor any other line. - parse_
step_ begin_ line - parse_
step_ end_ line - parse_
upgrade_ line - Parse an
UPGRADE_PREFIXline.Nonefor any other line, or one missing a field (an installer needs its 64-hex-digitsha256:). Aconfirmed:1token afterversion:setsUpgradeRequest::confirmed(any other value of it does not); anapproved:<how>:<id>token is skipped. - shared_
folder_ held_ line AGENTMUXSRV-SHARED-FOLDER-HELD owner:<who> reason:<why the data needs preparing>.- step_
begin_ line - step_
end_ line - upgrade_
line - The path goes last: it can hold spaces.
confirmedaddsconfirmed:1after the version: the restart is already decided, so the launcher asks nothing more (UpgradeRequest::confirmed).