SmithersGatewayClient, a set of live data hooks that
read a run (or runs, approvals, crons, scores, …) over TanStack DB collections,
and action hooks that launch, approve, and cancel. Most hooks return the same
GatewayAsyncState shape, so once you know one you know
them all.
Everything on this page lives at the subpath
smithers-orchestrator/gateway-react,
not on the bare smithers-orchestrator facade. Import from the subpath or
the build fails.createGatewayReactRoot instead. It wires
both contexts (on-demand hooks and the live collections) in one call.
GatewayAsyncState
The return shape shared by the live data hooks.data is undefined until the
first payload lands; loading is true only while there is no data yet and a
fetch is in flight; refetch() forces a re-pull.
GatewayAsyncState.ts · See also Custom workflow UI
Provider & root
SmithersGatewayProvider
Holds oneSmithersGatewayClient in context for every hook below. Pass a ready
client, or options and it constructs one. The client is memoized on
baseUrl/token so an inline options literal does not trigger a reconnect
storm.
A pre-built client. Takes precedence over
options. See the
Gateway Client reference.Client config (
baseUrl, token, …) used to construct a client when none is
passed.Optional local or multiplayer collection mode. When omitted, local mode uses
the client’s base URL.
The provider mounts both the raw
SmithersGatewayClient context and the
TanStack DB collection provider. The live hooks and action hooks all work inside
this one provider.SmithersGatewayProvider.ts · Tests SmithersGatewayProvider.test.ts
createGatewayReactRoot
Mount a full custom UI in one call. Builds a client, mountsSmithersGatewayProvider, creates the TanStack DB collection registry, and
renders your element. This is what a gateway-served ui entry uses.
The app root to render.
Client options plus
rootId (the DOM element id to mount into; default
"root") and optional mode. Throws if the element is not found.The client it created, for imperative use outside React.
createGatewayReactRoot.ts · See also Custom UI
useSmithersGateway
Read the rawSmithersGatewayClient from context. Throws if called outside a
provider. The escape hatch for client methods the hooks do not wrap.
useSmithersGateway.ts · See also Gateway Client
SmithersCollectionsProvider
Advanced provider for supplying a customWorkspaceMode, SmithersDataClient,
or QueryClient. Most apps get this automatically from
SmithersGatewayProvider.
Local mode uses the Gateway REST API and SSE invalidation. Multiplayer mode
uses Electric shapes for reads and the domain API for writes.
Pre-built data client. Takes precedence over
mode.TanStack Query client. A default client is created when omitted.
SmithersCollectionsProvider.ts
useSmithersCollections
Read the TanStack DB collection registry and data client from context. Use this for customuseLiveQuery reads.
useSmithersCollections.ts · See also Sync
useGatewayConnectionStatus
The link’s connection lifecycle, derived from real transport traffic: RPC resolves and stream frames mark itonline, transport errors mark it offline,
auth failures mark it unauthorized.
Current connection state.
Shorthand for
status === "online".Epoch ms of the first failure in the current offline streak, when offline.
useGatewayConnectionStatus.ts · Tests sync.test.ts
Data hooks
Each hook reads one gateway resource as a live TanStack DB collection. They share theGatewayAsyncState return shape unless noted,
and may be called unconditionally: pass undefined (or an empty runId) and
the hook resolves to an empty, stable state.
useGatewayRun
Live single-run record. Seeds fromgetRun, then each lifecycle frame upserts
the row without a whole-tree refetch.
The run to read.
undefined yields an empty state.See
GatewayAsyncState. data is the run record.useGatewayRun.ts · Tests gateway-react.test.ts
useGatewayRunEvents
Live, bounded run-event buffer (resilient stream withafterSeq resume).
Heartbeats are surfaced separately and never enter events; the array is capped
to maxEvents, most-recent wins. Returns its own shape, not GatewayAsyncState.
Drop events at or before this sequence number.
Cap on the retained event buffer.
Ordered, capped run events (heartbeats excluded).
The most recent heartbeat frame, surfaced apart from
events.Set when the stream fails (offline / unauthorized).
True while the stream is live.
useGatewayRunEvents.ts · See also Event types
useGatewayRuns
Live run list. Seeds fromlistRuns, re-pulls on invalidate.
Optional filters (status, workflow, paging). Defaults to all runs.
See
GatewayAsyncState. data is the run summaries.useGatewayRuns.ts · Tests gateway-react.test.ts
useGatewayWorkflows
Live registered-workflow list (listWorkflows).
Optional
filter.See
GatewayAsyncState.useGatewayWorkflows.ts
useGatewayApprovals
Live pending-approval list (listApprovals). Re-pulls when a run reaches
waiting-approval or after a submitApproval.
Optional filters, e.g.
{ filter: { runId } } to scope to one run.See
GatewayAsyncState. data IS the array of pending
gates (ListApprovalsResponse = GatewayApprovalSummary[]); there is no
data.approvals wrapper. Each gate is
{ runId, nodeId, iteration, requestTitle?, requestSummary?, workflowKey?, requestedAtMs }
(the title is requestTitle, not title). Pass nodeId + iteration straight
into submitApproval.useGatewayApprovals.ts · See also useGatewayActions
useGatewayCrons
Live cron-schedule list (cronList). Includes enabled and disabled rows;
re-pulls after a cronCreate / cronDelete / cronRun.
See
GatewayAsyncState.useGatewayCrons.ts
useGatewayMemoryFacts
Live cross-run memory facts (listMemoryFacts). Pass a namespace to scope;
omit it for every namespace. Read-only on the wire, so query-only.
Optional namespace filter.
See
GatewayAsyncState. refetch works; there is no
write RPC.useGatewayMemoryFacts.ts
useGatewayNodeOutput
On-demand output of one node (getNodeOutput). Built on
useGatewayRpc; disabled until both ids are set.
Loop iteration to read. Pass
0 for a normal (non-looping) task.See
GatewayAsyncState. data is a
{ status: "produced" | "pending" | "failed", row, schema, partial? } envelope;
the task’s output object is under data.row, not data itself. Destructure
defensively (some code paths hand you the row directly), the way .smithers/ui/vcs.tsx
does:useGatewayNodeOutput.ts
useGatewayScores
Live scorer/eval results for one run (listScores). Pass nodeId to scope to
one node. An empty runId resolves to a stable empty collection. Read-only, so
query-only.
The run to score. Empty string yields an empty state.
Optional node scope.
See
GatewayAsyncState.useGatewayScores.ts
useGatewayTickets
Live work docs (tickets, plans, specs, proposals) vialistTickets. Tombstones
are filtered server-side, so every row is renderable. Pass a kind to scope.
Optional
kind and other filters.See
GatewayAsyncState.useGatewayTickets.ts
useGatewayPrompts
Live registered-prompt list (listPrompts, walked from .smithers/prompts/).
Read-only on the wire, so query-only; takes no arguments.
See
GatewayAsyncState.useGatewayPrompts.ts
useGatewayRpc
The generic escape hatch: call any gateway RPC by name and get its typed payload back inGatewayAsyncState. The typed hooks above wrap this; reach for it when
no dedicated hook exists. Disable with enabled: false; a disabled or
key-changed query clears stale data instead of surfacing it.
The RPC method name.
Typed params for that method.
Skip the request when false.
Re-fetch trigger. Defaults to the serialized
params.See
GatewayAsyncState.useGatewayRpc.ts · See also Gateway Client
useDelegationChain
Folded delegation-chain state for one run: the read model behind thedelegation-chain workflow UI. Enumerates every
physical dc:* node from the live run tree, fetches each node’s durable output
row once (re-checked when that node finishes or fails), folds the rows through
the pure foldDelegation reducer, and returns the graph plus the delegation
actions. Malformed or unknown rows surface in errors instead of throwing.
The run to fold.
undefined (or an empty string) yields an empty graph.Nodes keyed by logical id (status, version history, gates, attention
rollups), edges, the current phase, pending question forms, the refined
prompt, the predicted-vs-actual budget rollup, and run scores.
True until the run tree and the first output sweep have hydrated.
Fold issues (ignored rows) plus any tree/event/output fetch errors.
foldDelegation,
parseDelegationNodeId, delegationTableForNodeId) together with the
DelegationGraph and Dc*Row types, for tests and non-React consumers.
Source useDelegationChain.ts · See also <DelegationChain>
Action hooks
useGatewayActions
Bound, memoized mutation methods off the client. Call them to drive a run: launch, resume, cancel, hijack, rewind, approve/deny, signal, and manage crons. Each takes the matching RPC params and returns a promise.useGatewayActions.ts · See also Gateway Client
useGatewayMutation
Typed mutation helper for supported domain writes. It calls the same domain API asuseGatewayActions, then invalidates the collection registry.
One of the supported domain mutations:
launchRun, resumeRun, cancelRun,
hijackRun, rewindRun, submitApproval, submitSignal, cronCreate,
cronDelete, cronRun, createTicket, updateTicket, or deleteTicket.Reserved for compatibility. Successful mutations invalidate the collection
registry.
{ mutate, mutateSafe, isLoading, error }.useGatewayMutation.ts · See also useGatewayActions
Type exports
These types are exported from the same subpath for typing your own components.{ client, collections, queryClient } from
useSmithersCollections.Connection state used by
useGatewayConnectionStatus.index.ts · Tests gateway-react.test.ts
This is the UI side of the control plane. For the underlying transport and its imperative methods, see the Gateway Client reference; to embed a UI in a gateway-served workflow, see Custom UI and the Custom workflow UI guide.