Expand description
What a headless serverβs registered external host asks of srv besides vouching for a connection: whether the workspace is in use, a graceful shutdown, and the notice that it is going to stop.
These are host routes, never RPCs: an RPC is a command an agent can call, and these must not be. Every
agent on the machine holds the instance key, so the key does not open them. Each call is signed by the
registered host (external_host::Host::check_call), for this workspace, over its operation and
arguments, and answers 404 when no host is registered, so a desktop or a plain headless srv has none of
these routes.
POST /api/v1/host/activity:{ busy, agentsWorking, lastOutputAt, keepRunning };keepRunningis the last thing an agent asked for (app_api::workspace_stop), for the host to honour or not. A turn counts only while its pane has written output in the last ten minutes (ACTIVE_WINDOW_MS), so a hung turn cannot keep a workspace up for ever; a pane process that wrote that recently counts as busy too.POST /api/v1/host/shutdown: srvβs own graceful teardown (the one SIGTERM runs: interrupt turns, save final state) and the answer when it is done, within the deadline given.POST /api/v1/host/notice: the stop time and why, as the fixed reason idsperson,timer,creditandcap, never text: srv builds the phrase the page and the agents are shown, so nothing a person or an agent wrote can cross.stopAtandreasonboth null cancel it.
StructsΒ§
- Activity π
- Activity
Request π - Held π
- The notice srv holds, what an agent has asked for since, and a counter that tells a reminder task whether it is still the current one.
- Keep
Running π - What an agent has asked for: the stop pushed back by
minutes, recorded as the agent that asked. - Notice
Request π - Seen π
- What one paneβs controller says, for the activity answer.
- Shutdown
Request π - Stop π
- A notice as srv holds it: the stop time and why.
EnumsΒ§
- Keep
Refusal π - Why a keep-running request was refused.
- Notice π
- What the host sent, checked: a stop, or its cancelling.
- Plan π
- What to do with a notice, given the one held.
- Reason π
- Why a workspace is going to stop: the only reasons srv will say, as ids.
ConstantsΒ§
- ACTIVE_
WINDOW_ πMS - A turn or a pane process counts as working only if it wrote output this recently.
- CANCEL_
NOTE π - The note when a stop is cancelled.
- MAX_
AHEAD_ πMS - The furthest ahead a stop may be set.
- MAX_
DEADLINE_ πSECS - The longest graceful shutdown a caller may ask for.
- MAX_
KEEP_ πMINUTES - The most an agent may ask to push a stop back at a time.
- NOTE_
KEY π - The held-note key: a newer stop notice replaces an older one still waiting for an agentβs next turn.
- REMIND_
BEFORE_ πMS - The last reminder to the agents, this long before the stop.
- SKEW_MS π
- How far in the past a stop time may be before it is refused (clock skew between host and srv).
StaticsΒ§
- HELD π
FunctionsΒ§
- apply π
- Hold the notice, show it, tell the agents, and remind them a minute before; or take it back.
- ask_
keep_ πrunning - An agent asks to push the stop back (
Held::ask_keep_running). - clock π
HH:MM UTCof a unix-ms time.- current π
- The stop srv holds now, and what an agent has asked for since.
- current_
ms π - handle_
activity π POST /api/v1/host/activity.- handle_
notice π POST /api/v1/host/notice.- handle_
shutdown π POST /api/v1/host/shutdown: srvβs graceful teardown, and the answer once it is done (done: falsewhen the deadline came first, with the teardown still running). Calling it again is harmless: what is closed is gone.- held π
- not_
registered π - parse_
notice π - The notice in a request, or why it is refused. A stop needs both a time and a reason id; neither cancels.
idleMinutesgoes withtimerand with nothing else. - plan π
- publish π
- refused π
- remind_
later π - A minute before the stop, if it is still the stop that is held, the agents are reminded.
- remind_
note π - The last reminder, sent a minute before.
- running_
panes π - stop_
note π - The note every agent is given when a stop is set.
- summarize π
- The workspaceβs activity from its running panes. A turn that has been silent for
ACTIVE_WINDOW_MSis not working (the guard against a stuck turn); a pane that wrote output within it is busy even with no turn. - tell_
agents π - text_of π