HTTP/SSE client for the long-lived gateway daemon.
Interactive channels call this facade instead of gateway.state directly. It
discover-or-starts the one daemon for the current DB, then speaks the same
HTTP/SSE API every other client uses. This is the thin-client half of the
gateway-daemon plan: token refresh, turn execution, and live streaming happen
in ONE process.
HTTP/SSE client for the long-lived gateway daemon. Interactive channels call this facade instead of `gateway.state` directly. It discover-or-starts the one daemon for the current DB, then speaks the same HTTP/SSE API every other client uses. This is the thin-client half of the gateway-daemon plan: token refresh, turn execution, and live streaming happen in ONE process.
(add-filesystem-root! sid path)Add path as an extra filesystem root for sid IN THE DAEMON, returning the
refreshed session-workspace-info. The daemon owns the session's DB, so the
new root is what every channel reads back (fixing the local-only mutation that
never reached the running session).
Add `path` as an extra filesystem root for `sid` IN THE DAEMON, returning the refreshed `session-workspace-info`. The daemon owns the session's DB, so the new root is what every channel reads back (fixing the local-only mutation that never reached the running session).
(assign-group! sid gid)Assign a session to a group (nil clears / ungroups). Returns the soul.
Assign a session to a group (nil clears / ungroups). Returns the soul.
(change-root! sid path)Repoint sid's PRIMARY filesystem root to path IN THE DAEMON, returning the
refreshed session-workspace-info (whose :id is the newly pinned workspace).
Repoint `sid`'s PRIMARY filesystem root to `path` IN THE DAEMON, returning the refreshed `session-workspace-info` (whose `:id` is the newly pinned workspace).
(ensure-gateway!)Return a fresh daemon registry entry for the current DB, auto-starting the
detached gateway if needed. :memory is a programmer error for this client;
headless one-shots stay in-process and should not call here.
Return a fresh daemon registry entry for the current DB, auto-starting the detached gateway if needed. `:memory` is a programmer error for this client; headless one-shots stay in-process and should not call here.
(ensure-gateway-serving! path)Like ensure-gateway!, but tries to GUARANTEE the returned daemon actually
serves path. When ensure-gateway! attaches to an already-running daemon
that 404s on path (started from a classpath missing the extension that owns
it), respawn a fresh daemon from THIS process — whose classpath, by
construction, carries the route. This is what lets vis channels web
self-heal instead of parking on a /ui that 404s.
The respawn is NON-DESTRUCTIVE. A blind POST /v1/admin/stop is refcount-blind: it would abort every in-flight turn and kill every session's background resources. So we force-restart the stale daemon ONLY when it is idle — no OTHER clients and no running turn. Otherwise we leave it untouched and surface a clear error. A transport blip on the probe (not a real 404) never triggers a restart. Returns the entry.
Like [[ensure-gateway!]], but tries to GUARANTEE the returned daemon actually serves `path`. When [[ensure-gateway!]] attaches to an already-running daemon that 404s on `path` (started from a classpath missing the extension that owns it), respawn a fresh daemon from THIS process — whose classpath, by construction, carries the route. This is what lets `vis channels web` self-heal instead of parking on a `/ui` that 404s. The respawn is NON-DESTRUCTIVE. A blind POST /v1/admin/stop is refcount-blind: it would abort every in-flight turn and kill every session's background resources. So we force-restart the stale daemon ONLY when it is idle — no OTHER clients and no running turn. Otherwise we leave it untouched and surface a clear error. A transport blip on the probe (not a real 404) never triggers a restart. Returns the entry.
(list-groups)(list-groups {:keys [channel owner archived?]})GET /v1/groups. opts: :channel (keyword/string, :all ⇒ every group),
:owner (string), :archived? (bool). Returns the :groups vector.
GET /v1/groups. `opts`: :channel (keyword/string, :all ⇒ every group), :owner (string), :archived? (bool). Returns the :groups vector.
(reconcile-running-turns!)Clients do not sweep. Only the daemon may reconcile its own startup orphans.
Clients do not sweep. Only the daemon may reconcile its own startup orphans.
(release-session! sid)Release a session VIEW when the owning channel exits: tell the daemon to stop the session's background resources (shell_bg children, REPLs) and drop its live runtime, then release the process-level client lease. This is NOT a per-session delete (the transcript stays resumable) and never sends daemon shutdown; the daemon stops itself only when refcount AND running-turn-count hit zero. Best-effort and never daemon-spawning — if no fresh daemon is registered there is nothing to release against.
Release a session VIEW when the owning channel exits: tell the daemon to stop the session's background resources (shell_bg children, REPLs) and drop its live runtime, then release the process-level client lease. This is NOT a per-session delete (the transcript stays resumable) and never sends daemon shutdown; the daemon stops itself only when refcount AND running-turn-count hit zero. Best-effort and never daemon-spawning — if no fresh daemon is registered there is nothing to release against.
(remove-filesystem-root! sid path)Remove path from sid's extra filesystem roots IN THE DAEMON, returning the
refreshed session-workspace-info.
Remove `path` from `sid`'s extra filesystem roots IN THE DAEMON, returning the refreshed `session-workspace-info`.
(sse-event-action event wanted-turn-id)Pure classifier for one parsed SSE event while blocking on wanted-turn-id.
Returns [action event']:
:terminal — the wanted turn reached a terminal event (return event')
:forward — hand to on-event (own-turn progress OR a sibling turn's
queue-mirror event — see wire/queue-mirror-event-types),
then keep reading
:skip — another turn's non-queue event, drop it.
A turn.queued.deleted for the WANTED turn is terminal too: the queued
record was pulled back into an editor before it ever ran, so a cancelled
terminal is synthesized instead of blocking on a turn that never starts.
Pure classifier for one parsed SSE event while blocking on `wanted-turn-id`.
Returns `[action event']`:
:terminal — the wanted turn reached a terminal event (return `event'`)
:forward — hand to on-event (own-turn progress OR a sibling turn's
queue-mirror event — see `wire/queue-mirror-event-types`),
then keep reading
:skip — another turn's non-queue event, drop it.
A `turn.queued.deleted` for the WANTED turn is terminal too: the queued
record was pulled back into an editor before it ever ran, so a cancelled
terminal is synthesized instead of blocking on a turn that never starts.(subscribe! sid sub-id sink cursor)Remote equivalent of gateway.state/subscribe!: start a background SSE reader
that replays cursor then calls sink for every live event. Returns an empty
replay vector because the gateway's SSE endpoint itself handles replay before
live delivery.
Remote equivalent of gateway.state/subscribe!: start a background SSE reader that replays `cursor` then calls `sink` for every live event. Returns an empty replay vector because the gateway's SSE endpoint itself handles replay before live delivery.
(turn-trace sid tid)Canonical wire iterations of ONE persisted turn (nil when the id is unknown to the daemon).
Canonical wire iterations of ONE persisted turn (nil when the id is unknown to the daemon).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |