Skip to main content

Module runtime

Module runtime 

Source
Expand description

Long-running auto-update task + one-shot CLI helpers.

After the WS migration the runtime owns just two background tasks: the WebSocket session (ws::session::spawn_ws_session, which subsumes heartbeats, claim/accept/complete, fail, and log shipping) and the auto-updater (spawn_auto_updater). Per-tick helpers from the old polling loops are gone.

Structs§

CurrentJob
Job in flight right now. Populated by the WS session before dispatch, cleared once the job finishes (success or failure).
HeartbeatStatus
LoopSchedule
Schedule for the auto-updater loop. The WS session has its own SessionSchedule (see ws::session).
RecentJob
One finished job, retained in the recent-jobs ring for the UI.
RegisterArgs
Bundle of flags from studio-worker register.
WorkerObservers
Bundle of in-process observation slots the WS session writes to and the optional native UI reads from. Default gives empty slots so existing (headless) call sites stay one-liners. Cheap to clone — every field is an Arc.

Enums§

AutoUpdateDecision
What the auto-updater decided this tick.
HeartbeatOutcome
Result of the most recent heartbeat the WS session sent.
JobOutcome
Outcome a finished job ended with. Failures carry the human reason (already surfaced to logs + Sentry).

Constants§

AUTO_UPDATE_TICK
HEARTBEAT_INTERVAL
Default WS heartbeat interval, re-exported here so the native UI (and any other downstream readers) get a stable constant without reaching into ws::session.
PROMPT_PREVIEW_CHARS
Prompt previews stored in CurrentJob / RecentJob are clipped to this many chars so the in-memory state stays bounded even when LLM prompts are huge.
RECENT_JOBS_CAP
Maximum number of finished jobs kept in WorkerObservers::recent_jobs. Older entries fall off the back of the ring.

Functions§

auto_update_tick
build_capabilities
check_update
ensure_registered
Loop auto_register::tick on a 30s cadence until worker_id + auth_token are populated (Approved) or the operator rejects.
format_check_outcome
format_status
is_unsupported_kind
log_startup_banner
Emit a one-shot startup banner so operators can confirm which config the worker actually loaded. Without this the only thing in journalctl -u studio-worker on a healthy boot is whatever the loops happen to log on their first tick.
prompt_for
push_log
record_recent_job
register
Persist registration metadata for the next launch. No HTTP — the auto-register orchestration inside run / ui is the only thing that talks to the studio.
run
run_loops
Spawn the WS session + auto-updater, wait for them. Pulled out of run so tests can drive with a different schedule.
set_enabled
set_threshold
show_config
spawn_auto_updater
status
truncate_prompt