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.The bare provider mounts only the on-demand context, which feeds
useGatewayActions, useGatewayNodeOutput, and useGatewayRpc. The live
collection hooks (useGatewayRun, useGatewayRuns, …) also need a
SyncProvider. Use createGatewayReactRoot
to mount both at once.SmithersGatewayProvider.ts · Tests SmithersGatewayProvider.test.ts · See also SyncProvider
createGatewayReactRoot
Mount a full custom UI in one call. Builds a client, aGatewayCollections
registry, and renders your element inside both the gateway provider and a
SyncProvider, so every hook on this page works. 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"). 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
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. by run).
See
GatewayAsyncState.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.
See
GatewayAsyncState.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
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 for a single RPC by name, with optimistic updates, rollback, and invalidate-on-success. Wires the runner toregistry.rpc(method, vars).
The RPC method to call.
onMutate / onSuccess / onError callbacks and invalidate keys. See
useSyncMutation.{ mutate, mutateSafe, status, isLoading, data, error, reset }. See
useSyncMutation.useGatewayMutation.ts · See also useSyncMutation
Declarative Sync SDK
The lower layer the typed hooks are built on: aGatewayCollections registry of
TanStack DB collections plus generic query / mutation / subscription hooks keyed
by an arbitrary SyncKey. Use it for resources the typed hooks do not cover.
SyncProvider
Wrap a subtree with aGatewayCollections registry so descendants can call
useSyncQuery, useSyncMutation, useSyncSubscription, and the live typed
hooks against the same collections.
The registry, usually from
createGatewayCollections.SyncProvider.ts · See also createGatewayReactRoot
createGatewayCollections
Build the registry: one collection per gateway resource over an instrumented transport, plus the generic query/stream collections the sync hooks resolve on demand.createGatewayReactRoot calls this for you.
The registry. Owns
runs / run / approvals / … collections plus rpc,
invalidate, query, stream, connect, and reset. Handed to
SyncProvider.createGatewayCollections.ts · Tests sync.test.ts
useSyncQuery
Declarative fetch over the registry. Concurrent components with the samekey
share one collection and one in-flight fetch.
Cache key; identical keys multiplex onto one collection.
Runs on subscribe and on
refetch.Skip subscribe + fetch.
Treat cached data as fresh for this long.
{ data, error, status, isLoading, isRefreshing, refetch }, where status is
"idle" | "loading" | "success" | "error".useSyncQuery.ts · Tests sync.test.ts
useSyncMutation
Mutation with optimistic updates and invalidate-on-success.runner performs
the write; onMutate may stage an optimistic value and return a rollback
context for onError.
Performs the write, typically
registry.rpc(method, vars).useSyncMutation.ts · Tests sync.test.ts
useSyncSubscription
Subscribe to a streaming source through a bounded collection. Returns the rolling buffer of frames; older frames drop off the front pastmaxFrames. N
components on the same key share one upstream socket.
Cache key; identical keys multiplex onto one socket.
The stream scope (e.g. a run-event channel).
Stream params.
Drop the subscription when false.
Bounded buffer size.
{ frames, last, dropped }: the bounded buffer, its newest frame, and the
count dropped off the front.useSyncSubscription.ts · Tests sync.test.ts
Type exports
These types are exported from the same subpath for typing your own components.Options for
createGatewayCollections.The registry handed to
SyncProvider.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.