@flow-state-dev/react
Interfaces
ApprovalRendererProps
Props for the built-in approval card.
When onApprove/onReject are supplied, they replace the built-in resume call — useful when a parent useSuspensions hook manages the resume and its state.
Properties
isResolved?
isResolved?: boolean;
When true, the card collapses to a read-only receipt.
item
item: SuspensionItem;
The suspension item to render an approval card for.
onApprove?
onApprove?: (data?) => void | Promise<unknown>;
Optional override for the approve action.
Parameters
data?
unknown
Returns
void | Promise<unknown>
onReject?
onReject?: (data?) => void | Promise<unknown>;
Optional override for the reject action.
Parameters
data?
unknown
Returns
void | Promise<unknown>
resolution?
resolution?: SuspensionStatus;
How the suspension was resolved, when known — drives the receipt label.
DraftSend
What useDraftSend returns.
Properties
canSend
canSend: boolean;
true when the box holds text, or a file that isn't refused.
failure
failure: string | undefined;
Why the last send failed, or undefined. The text and files stay in the box, for a Retry.
sending
sending: boolean;
true while a send runs. A second submit meanwhile does nothing.
setText
setText: (text) => void;
Sets the box's text, storing it as the draft.
Parameters
text
string
Returns
void
submit
submit: (send) => Promise<void>;
Send the box's text and files through send. A box with nothing to send sends nothing. Never throws.
Parameters
send
Returns
Promise<void>
text
text: string;
The box's text.
DraftSendAttachments
The box's files, as its attachment strip holds them: only what a send reads.
R is the strip's refusal line, handed back to consume as it was read.
Type Parameters
R
R = unknown
Properties
consume
consume: (ids, shown) => void;
After a send landed: removes the files in ids that went, and the refusal lines in shown.
Parameters
ids
string[]
shown
R[]
Returns
void
files
files: readonly object[];
The files in the box. A "refused" one is shown, never sent.
refusals
refusals: R[];
The refusal lines on screen.
settle
settle: () => Promise<FileContent[]>;
Waits for the uploads in flight, then resolves to the uploaded files' references.
Returns
Promise<FileContent[]>
ResolveSuspensionArgs
Arguments for resolveSuspension. markStart/markEnd toggle the
caller's in-flight set; setError is the error slot setter. resolve is the
session's streaming answer (SessionView.answerSuspension) — the resolution
streams the continuation back into session.items.
Properties
action
action: ResumeAction;
data?
data?: unknown;
item
item: Pick<SuspensionItem, "suspensionId" | "requestId">;
markEnd
markEnd: (id) => void;
Parameters
id
string
Returns
void
markStart
markStart: (id) => void;
Parameters
id
string
Returns
void
resolve
resolve: (args) => Promise<void>;
Parameters
args
action
ResumeAction
data?
unknown
requestId
string
suspensionId
string
Returns
Promise<void>
setError
setError: (error) => void;
Parameters
error
Error | null
Returns
void
SchemaField
A single renderable field derived from a flat object resumeSchema.
Properties
description?
description?: string;
Optional helper text from the schema's description.
key
key: string;
Property key in the form value object.
kind
kind: SuspensionValueKind;
The control kind to render.
label
label: string;
Human label — the schema's title if present, else the key.
options?
options?: string[];
Option values for enum / enum-multi fields.
required
required: boolean;
Whether the schema marks this property required.
Submit
What useSubmit returns.
Type Parameters
A
A extends unknown[]
Properties
busy
busy: boolean;
true while the action runs. Bind it to the controls' disabled, so a second click can't send it twice.
error
error: string | undefined;
The last refusal's message, or undefined. Cleared when the action runs again.
submit
submit: (event, ...args) => Promise<void>;
Runs the action. Pass the form event, if any, to prevent its default; never throws. A call while one runs does nothing.
Parameters
event
FormEvent<Element> | undefined
args
...A
Returns
Promise<void>
SuspensionFormRendererProps
Props shared by the three bounded default renderers.
Properties
isResolved?
isResolved?: boolean;
When true, the card collapses to a read-only receipt.
item
item: SuspensionItem;
The suspension item to render an input for.
resolution?
resolution?: SuspensionStatus;
How the suspension was resolved, when known — drives the receipt label.
SuspensionView
A single suspension folded with its resolution (if any). status/pending
reflect whether a matching suspension_resume item has arrived; isResolving
reflects an in-flight approve/reject call for this specific suspension.
Properties
allow
allow: ResumeAction[];
The resolution actions this suspension permits (from item.allow). A layout
reads it to decide which controls to show — e.g. a Skip button appears iff it
includes "skip". Falls back to binary ["approve", "reject"] for older
suspensions persisted before allow existed.
isResolving
isResolving: boolean;
True while a resolve call for this suspension is in flight.
item
item: SuspensionItem;
The suspension item itself.
pending
pending: boolean;
True when no matching suspension_resume item exists yet.
resolvedBy?
resolvedBy?: string;
resumeData?
resumeData?: unknown;
The resolution payload, once resolved (from the suspension_resume item).
status
status: SuspensionStatus;
"pending" until a matching suspension_resume item appears; then its resolution.
UseSuspensionFormOptions
Options for useSuspensionForm.
Properties
isResolved?
isResolved?: boolean;
Whether a matching suspension_resume item has already arrived.
resolution?
resolution?: SuspensionStatus;
How the suspension resolved, when known — drives the receipt outcome.
UseSuspensionFormResult
Return value of useSuspensionForm.
Properties
canSkip
canSkip: boolean;
Whether a Skip control should render (the suspension permits skip).
canSubmit
canSubmit: boolean;
True when the value validates and no resume is in flight or done.
error
error: string | null;
Last resume error message, or null.
errors
errors: Record<string, string>;
Path-keyed validation errors (field key, or "value" for a scalar).
fields
fields: SchemaField[];
Fields derived from a flat object schema (empty for scalar/enum kinds).
isResolving
isResolving: boolean;
True while a submit/skip resume is in flight.
kind
kind: SuspensionValueKind;
The value kind this suspension expects (drives which control to render).
options?
options?: string[];
Options for a top-level enum / enum-multi selection.
outcome
outcome: ApprovalOutcome;
Icon + label for the resolved receipt.
resolution?
resolution?: SuspensionStatus;
The resolved status when known.
resolved
resolved: boolean;
True once resolved (by this hook or an external isResolved).
setField
setField: (key, next) => void;
Set one property of an object-shaped value (no-op for scalar kinds).
Parameters
key
string
next
unknown
Returns
void
setValue
setValue: (next) => void;
Replace the whole form value.
Parameters
next
unknown
Returns
void
skip
skip: () => Promise<void>;
Resolve with action:"skip" (no payload).
Returns
Promise<void>
submit
submit: () => Promise<void>;
Validate, then resolve with action:"submit" and the coerced payload.
Returns
Promise<void>
value
value: unknown;
Current form value: an object for kind:"object", else a scalar/array.
UseSuspensionsOptions
Narrowing options for useSuspensions.
Properties
reasons?
reasons?: SuspensionReason[];
Restrict to specific reasons (e.g. ["user_approval"]). Default: all reasons.
requestId?
requestId?: string;
Restrict to a single request's suspensions. Default: all in session.items.
UseSuspensionsResult
Reactive suspension view plus approve/reject actions returned by useSuspensions.
Properties
approve
approve: (suspensionId, data?) => Promise<void>;
Approve a suspension and stream its continuation back into session.items.
Thin wrapper over resolve with action: "approve".
Parameters
suspensionId
string
data?
unknown
Returns
Promise<void>
error
error: Error | null;
Most-recent failed approve/reject error (also rethrown by the call). Single-slot: concurrent resolves of different ids overwrite each other.
pending
pending: SuspensionView[];
Convenience filter: only pending suspensions.
reject
reject: (suspensionId, data?) => Promise<void>;
Reject a suspension. Same streaming semantics as approve.
Parameters
suspensionId
string
data?
unknown
Returns
Promise<void>
resolve
resolve: (suspensionId, args) => Promise<void>;
Resolve a suspension with any permitted action, streaming its continuation
back into session.items. This is the general resolver — submit carries a
typed payload (a question answer, a form, a selection); skip declines an
optional step; approve/reject keep their binary meaning. Resolves once the
resume has been dispatched; rejects if the resume call fails.
Parameters
suspensionId
string
args
action
ResumeAction
data?
unknown
Returns
Promise<void>
suspensions
suspensions: SuspensionView[];
All suspensions (pending + resolved) matching the options, in stream order.
Type Aliases
ActivityItem
type ActivityItem = ToolOutputItem | ReasoningItem;
What an agent does between the things it says: a tool call, or the thinking
that goes with one. A run of these in one turn is one steps line.
ApprovalOption
type ApprovalOption = object;
One more way to say yes that a stop offers beside the plain approve: the label a card shows, and the data the approve sends with it.
Properties
data?
data?: unknown;
label
label: string;
ApprovalOutcome
type ApprovalOutcome = object;
Presentation-neutral descriptor for a resolved suspension: icon glyph + label.
Properties
icon
icon: string;
label
label: string;
BlockComponentType
type BlockComponentType = ComponentType<any>;
Component shape accepted in renderer maps.
Uses any because TypeScript's function parameter contravariance prevents
ComponentType<{ item: MessageItem }> from being assignable to
ComponentType<{ item: OutputItem }>. The runtime contract is that
ItemRenderer passes { item } with the correct item type for each slot.
Consumers narrow the type in their component signature.
ClientDataScopeSubscribeOptions
type ClientDataScopeSubscribeOptions =
| string[]
| Record<string, ZodSchemaLike | true>;
Client data subscription options for one scope.
ClientDataSubscribeOptions
type ClientDataSubscribeOptions = object;
Client data subscription options grouped by scope.
Properties
org?
org?: ClientDataScopeSubscribeOptions;
session?
session?: ClientDataScopeSubscribeOptions;
user?
user?: ClientDataScopeSubscribeOptions;
ClientDataValues
type ClientDataValues<TOptions> = (TOptions extends object ? object : object) & (TOptions extends object ? object : object) & (TOptions extends object ? object : object);
Inferred client data value shape returned by useClientData.
Type Parameters
TOptions
TOptions extends ClientDataSubscribeOptions
CollectionActions
type CollectionActions = object;
Mutation actions available on the collection, shaped by declared permissions. Methods always exist; the server returns 403 when a permission is missing.
Properties
create
create: (options) => Promise<{
topic: string;
}>;
Parameters
options
content?
string
topic
string
Returns
Promise<{
topic: string;
}>
delete
delete: (options) => Promise<void>;
Parameters
options
topic
string
Returns
Promise<void>
update
update: (options) => Promise<void>;
Parameters
options
content
string
topic
string
Returns
Promise<void>
CollectionListOptions
type CollectionListOptions = object;
Options accepted by list() and the convenience list hook.
Properties
cursor?
cursor?: string;
Opaque pagination cursor from a prior page's nextCursor.
limit?
limit?: number;
topicPrefix?
topicPrefix?: string;
ContainerItemsResult
type ContainerItemsResult<TState> = object;
Type Parameters
TState
TState = Record<string, unknown>
Properties
dataByKey
dataByKey: Map<string, Record<string, unknown>>;
Latest value of each keyed data item the container owns, by key.
items
items: OutputItem[];
All items owned by this container scope, sorted chronologically.
state
state: TState | undefined;
The value of the latest owned data item whose dataType is the
container's component key, or undefined if there is none.
ConversationLinesOptions
type ConversationLinesOptions = object;
How conversationLines filters before it reads lines.
Properties
deduplicateByKey?
deduplicateByKey?: boolean;
Default true: a keyed data item shows only its latest snapshot, at that snapshot's place.
renderers?
renderers?: RendererRegistry;
The registry in use: items a container with a registered renderer owns are left to that renderer, and a data item with no renderer here is no line.
showSubAgents?
showSubAgents?: boolean;
Default false: items with history: false (a sub-agent's) and trace items stay out.
DraftSendFn
type DraftSendFn = (line, files) => Promise<unknown>;
Where a box's line goes: resolves once the line has landed, rejects with why it didn't.
Parameters
line
string
files
FileContent[]
Returns
Promise<unknown>
FlowCardinality
type FlowCardinality = "singleton" | "collection";
How many registered instances a flow definition supports.
"singleton"(default) — one instance per kind. Itsidis itskind, so the addresses an application already uses (/api/flows/<kind>/…,fsdev run <kind>) keep resolving unchanged."collection"— several named copies of one definition. Every instance must be created with an explicitid, and that id is the only address it answers to; the bare kind never selects a member, even when only one is registered.
Declared on the definition only. It is the flow's identity policy, not a per-instance choice: a hand-built singleton of a collection kind would turn the bare kind into an accidental address for the whole collection.
FlowContextValue
type FlowContextValue = object;
Shared context value used by React hooks.
Properties
apiPath?
apiPath?: string;
baseUrl?
baseUrl?: string;
clients?
clients?: ClientCache;
The clients this provider's hooks share, by transport, so hooks with the same user and transport hold one client (and so one push socket). Owned by the provider; absent outside one.
fetcher?
fetcher?: ClientFetch;
flowKind?
flowKind?: string;
renderers?
renderers?: RendererRegistry;
sessionId?
sessionId?: string;
userId?
userId?: string;
FlowNavigatorLeaf
type FlowNavigatorLeaf = object;
The address a session list is read for: a singleton kind, or one instance of a collection kind. Only a leaf is ever read; a collection's kind row is not one.
Properties
address
readonly address: string;
The flow address — a kind for a singleton, an instance id for a collection member.
cardinality
readonly cardinality: FlowCardinality;
kind
readonly kind: string;
FlowNavigatorLeafState
type FlowNavigatorLeafState = FlowNavigatorLeaf & object;
A leaf, plus the state of its session list — what a slot is handed.
Type Declaration
error
readonly error: string | null;
isLoading
readonly isLoading: boolean;
refresh
readonly refresh: () => void;
Re-read this leaf's sessions. Safe to call from a host affordance.
Returns
void
sessions
readonly sessions: readonly SessionSummary[];
FlowNavigatorProps
type FlowNavigatorProps = object;
Properties
client?
readonly client?: FlowNavigatorClient;
The host's own client, so every read carries the host's transport and
its user. Without one, the navigator uses the nearest FlowProvider's
user, baseUrl and fetcher.
Pass a STABLE reference — one held in a context or a useMemo, not an
object literal built during render. The reads are fenced on the client
they were made through, which is what makes a rebuilt client discard the
previous backend's rows; a fresh object every render reads as a rebuilt
client every render.
includeDispatchRuns?
readonly includeDispatchRuns?: boolean;
Also list the sessions a dispatcher ran work in, drawn one level under the session that started each one.
Off by default, matching the server: a host that does not ask lists the sessions a person started, exactly as before. A tool that inspects a running server asks; a product surface showing someone their own conversations usually does not.
onSelectSession
readonly onSelectSession: (sessionId, leaf) => void;
Called with the picked session and the leaf it was listed under.
Parameters
sessionId
string
leaf
Returns
void
sections
readonly sections: readonly FlowNavigatorSection[];
A label and a set of kind names, per section. Never a depth.
selectedSessionId?
readonly selectedSessionId?: string;
The session to mark as current. Selection is the host's to keep.
slots?
readonly slots?: FlowNavigatorSlots;
FlowNavigatorRow
type FlowNavigatorRow =
| {
cardinality: FlowNavigatorLeaf["cardinality"];
isOpen: boolean;
kind: string;
type: "kind";
}
| {
instance: FlowListEntry;
isOpen: boolean;
kind: string;
type: "instance";
}
| {
dispatchRun?: {
parentInView: boolean;
parentSessionId: string;
};
isSelected: boolean;
leaf: FlowNavigatorLeaf;
session: SessionSummary;
type: "session";
};
Which row a slot is being asked to fill.
Union Members
Type Literal
{
cardinality: FlowNavigatorLeaf["cardinality"];
isOpen: boolean;
kind: string;
type: "kind";
}
Type Literal
{
instance: FlowListEntry;
isOpen: boolean;
kind: string;
type: "instance";
}
Type Literal
{
dispatchRun?: {
parentInView: boolean;
parentSessionId: string;
};
isSelected: boolean;
leaf: FlowNavigatorLeaf;
session: SessionSummary;
type: "session";
}
dispatchRun?
readonly dispatchRun?: object;
Present when a dispatcher started this session rather than a person.
parentSessionId is the session it was started from, and
parentInView says whether that session is one of the rows on screen
— a run whose parent is not in the listing is drawn at the left margin
and still carries its provenance.
dispatchRun.parentInView
readonly parentInView: boolean;
dispatchRun.parentSessionId
readonly parentSessionId: string;
isSelected
readonly isSelected: boolean;
leaf
readonly leaf: FlowNavigatorLeaf;
session
readonly session: SessionSummary;
type
readonly type: "session";
FlowNavigatorSection
type FlowNavigatorSection = object;
A label and the kind names it covers. There is nothing else in a section, and deliberately so — a section says which kinds, never how deep they go.
kinds is omitted by a host that cannot name them. An app filtering on the
kinds it ships writes them down; a general inspector is pointed at whatever
server is running and learns the kind names by asking, so requiring the list
would make it read the flow list itself purely to hand the answer back —
one-read-per-host lost to a workaround rather than to a bug.
Absent and empty are NOT the same. kinds: [] is a filter that was named
and excludes everything; omitting it is a host that never had one. A host
deriving its filter starts with an empty array, and collapsing the two would
show it the whole server for the frame before its own list arrives.
Properties
kinds?
readonly kinds?: readonly string[];
label
readonly label: string;
FlowNavigatorSlots
type FlowNavigatorSlots = object;
The parts of the rail that belong to the host rather than to the component.
Every slot is optional and the navigator renders without any of them. They exist so a host's own affordances — copying an instance id, starting a session, refreshing a list — live in the host that wants them instead of being a reason to keep a second navigator.
Properties
emptySection?
readonly emptySection?: (section) => ReactNode;
What a section covering no registered kind says.
Parameters
section
Returns
ReactNode
leafDetail?
readonly leafDetail?: (leaf) => ReactNode;
What an open leaf shows about itself, on its own lines directly under the
leaf's row and above its sessions, starting at the leaf's label column.
Handed the same state as leafToolbar, and mounted and unmounted with the
leaf the same way. It is always shown while the leaf is open, and it wraps
to the rail's width: for detail and forms that don't fit on a row.
Parameters
leaf
Returns
ReactNode
leafToolbar?
readonly leafToolbar?: (leaf) => ReactNode;
An open leaf's actions, drawn on that leaf's own row after rowTrailing's
content and revealed the same way. Mounted when the leaf opens, unmounted
when it closes. It shares one line with the row's label, so give it icon
buttons with an aria-label, not text.
Parameters
leaf
Returns
ReactNode
rowTrailing?
readonly rowTrailing?: (row) => ReactNode;
At the end of any row. Shown while the row is pointed at, has focus inside it or is selected, and always on a screen with no hover; hidden content keeps its space and stays reachable with Tab.
Parameters
row
Returns
ReactNode
sectionHeader?
readonly sectionHeader?: (section) => ReactNode;
Beside a section's label.
Parameters
section
Returns
ReactNode
FlowProviderProps
type FlowProviderProps = object;
Props for the canonical FlowProvider component.
Properties
apiPath?
apiPath?: string;
Where the server mounts the flow API, after baseUrl. Default
"/api/flows". Set it to the server's mount when that differs, such as
the Node host's basePath. A nested provider inherits its parent's.
baseUrl?
baseUrl?: string;
children
children: ReactNode;
fetcher?
fetcher?: ClientFetch;
The fetch every hook's calls and streams go through, such as the engine's
createInProcessFetch(flowState) for an engine in this process, or a
wrapper that adds credentials. Default: the global fetch. A nested
provider inherits its parent's.
flowKind?
flowKind?: string;
renderers?
renderers?: RendererRegistry;
sessionId?
sessionId?: string;
userId?
userId?: string;
FollowedRequest
type FollowedRequest = Pick<SessionRequestSummary, "id" | "status" | "startedAtMs" | "completedAtMs" | "failedAtMs">;
The request a view shows last, as SessionView.followedRequest reports it: the fields of a request summary its status needs.
HarnessLineSendOptions
type HarnessLineSendOptions = object;
Options for one line, HarnessLinesView.send's second argument.
Properties
attachments?
attachments?: FileContent[];
The line's files, each as upload returned it, in the order attached.
HarnessLinesView
type HarnessLinesView<TOutcome> = object;
What useHarnessLines returns.
Type Parameters
TOutcome
TOutcome extends string = HarnessLineOutcome
Properties
send
send: (prompt, options?) => Promise<TOutcome>;
Send one line, after every line sent before it has its answer. Resolves
with where it went; a line that waits resolves once it is listed in
waiting, and rejects if its turn could not be sent. attachments are
the line's files, as upload returned them; a line with files never
steers, so it runs as a turn of its own.
Parameters
prompt
string
options?
Returns
Promise<TOutcome>
waiting
waiting: readonly HarnessWaitingLine[];
The lines waiting for the running turn, oldest first, until each one's turn is followed. At most one is on the server; the rest wait in the page and are sent in order, so a reload or a closed tab loses those. Moving the view to another session sends the held ones to the session left.
HarnessWaitingLine
type HarnessWaitingLine = object;
A line waiting for the running turn, in HarnessLinesView.waiting.
Properties
key
key: string;
Stable while the line waits: a key for a list.
text?
text?: string;
The line as typed. Absent for a turn this page didn't send, such as one a reload found waiting.
InterruptKeyEvent
type InterruptKeyEvent = object;
The parts of a keystroke the gesture reads: a React or a DOM KeyboardEvent both fit.
Properties
ctrlKey
ctrlKey: boolean;
defaultPrevented?
defaultPrevented?: boolean;
isComposing?
isComposing?: boolean;
key
key: string;
keyCode?
keyCode?: number;
metaKey
metaKey: boolean;
nativeEvent?
nativeEvent?: object;
defaultPrevented?
defaultPrevented?: boolean;
isComposing?
isComposing?: boolean;
preventDefault?
preventDefault?: () => void;
Returns
void
repeat?
repeat?: boolean;
An auto-repeat from a held key.
target?
target?: EventTarget | null;
InterruptKeyResult
type InterruptKeyResult = "interrupt" | "armed" | null;
What one keystroke came to: stop now, show the "press Esc again" hint, or nothing.
InterruptKeysOptions
type InterruptKeysOptions = object;
Properties
windowMs?
windowMs?: number;
How long a first Esc stays armed. Defaults to INTERRUPT_WINDOW_MS.
ItemLine
type ItemLine =
| {
id: string;
item: MessageItem;
kind: "user";
requestId: string;
}
| {
id: string;
incomplete?: true;
item: MessageItem;
kind: "assistant";
requestId: string;
streaming?: true;
}
| {
ended?: true;
id: string;
items: ActivityItem[];
kind: "steps";
requestId: string;
}
| {
id: string;
item: ErrorItem;
kind: "failed";
requestId: string;
retryable: boolean;
}
| {
id: string;
kind: "stopped";
requestId: string;
}
| {
id: string;
item: SuspensionItem;
kind: "suspension";
requestId: string;
resolution?: SuspensionStatus;
}
| {
id: string;
item: DataItem;
kind: "data";
requestId: string;
}
| {
id: string;
item: OutputItem;
kind: "item";
requestId: string;
};
One line of a conversation screen. Every line names the turn (requestId)
it belongs to and has an id that stays the same as it changes, for a key.
Union Members
Type Literal
{
id: string;
item: MessageItem;
kind: "user";
requestId: string;
}
What the user said.
Type Literal
{
id: string;
incomplete?: true;
item: MessageItem;
kind: "assistant";
requestId: string;
streaming?: true;
}
What the agent said: streaming while it is still being written, incomplete when its turn failed or was stopped first.
Type Literal
{
ended?: true;
id: string;
items: ActivityItem[];
kind: "steps";
requestId: string;
}
One turn's tool calls and the thinking between them, one after another. ended once its turn is over: a call still running there never finished.
Type Literal
{
id: string;
item: ErrorItem;
kind: "failed";
requestId: string;
retryable: boolean;
}
A turn that failed, from its error item. retryable when Retry is offered: it is the newest turn that drew a line, and one the engine runs again.
Type Literal
{
id: string;
kind: "stopped";
requestId: string;
}
A turn that was stopped (it ended aborted), after its last line.
Type Literal
{
id: string;
item: SuspensionItem;
kind: "suspension";
requestId: string;
resolution?: SuspensionStatus;
}
A turn that waits on the user, with how it was answered once it was.
Type Literal
{
id: string;
item: DataItem;
kind: "data";
requestId: string;
}
A data item, drawn by the renderer registered for its dataType.
Type Literal
{
id: string;
item: OutputItem;
kind: "item";
requestId: string;
}
Any other item (a status, a container, a source), drawn by the registry.
ItemRendererProps
type ItemRendererProps = object;
Props for rendering one output item.
Properties
isResolved?
isResolved?: boolean;
For a suspension item rendered inline via the built-in ApprovalRenderer
fallback: whether a matching suspension_resume item has already arrived.
ItemsRenderer computes this from the full item list; when true the default
card collapses to a receipt. Ignored for non-suspension items and for custom
or suppressed renderers.
item
item: OutputItem;
line?
line?: ItemLine;
The conversation line this item is drawn for (ItemLine), when it
is drawn as one: a registered renderer receives it beside item, to read
what the model decided (a failed line's retryable, an assistant line's
streaming or incomplete).
resolution?
resolution?: SuspensionStatus;
For a resolved suspension item: how it was resolved (from the matching
suspension_resume item), so the collapsed receipt shows the real outcome.
Ignored for non-suspension items.
ItemsRendererProps
type ItemsRendererProps = object;
Props for rendering a conversation: its lines, or its items.
Properties
deduplicateByKey?
deduplicateByKey?: boolean;
With items: when true (default), data items that carry a stable key
are deduplicated: only the latest snapshot per key is rendered, replacing
earlier ones in-place. Set to false to render all snapshots.
items?
items?: OutputItem[];
The items to draw when no lines are given: read as conversationLines(items), with no turns.
lines?
lines?: readonly ItemLine[];
The lines to draw, from conversationLines, computed where the
items and turns change. Given these, items and the filters are ignored.
live?
live?: boolean;
The stream is still open after the last of these lines. The steps
renderer is then told, as live, which steps line is the trailing one:
the agent's working that no message has yet ended.
showSubAgents?
showSubAgents?: boolean;
With items: when true, items with history: false visibility
(sub-agent output) are rendered inline with the rest of the stream.
Default: false — those items are filtered out of the default
conversation view. The data still flows through useSession().items;
use a custom renderer (e.g., a per-agent panel) to surface it explicitly.
toolGroupRenderer?
toolGroupRenderer?: ComponentType<{
items: ActivityItem[];
line: Extract<ItemLine, {
kind: "steps";
}>;
live?: boolean;
}>;
Draws a steps line (one turn's tool calls and the thinking between
them) as one unit: it receives the line's items, in order, and the line
itself (ended once its turn is over). Without it,
each of a steps line's items renders through the registry on its own.
JumpToLatest
type JumpToLatest = object;
Properties
atEnd
atEnd: boolean;
Whether the reader is at the end of the content. false when there is more below: show the jump-to-latest button.
jump
jump: () => void;
To the end of the content, smoothly. What the jump-to-latest button calls.
Returns
void
mine
mine: (key) => SentLineMark;
Mark an element as one of the person's own lines. key names the line and
stays the same while it is redrawn, such as its entry id:
<div {...feed.mine(line.id)}>.
Parameters
key
string
Returns
ref
ref: (node) => void;
Attach to the scrolling element.
Parameters
node
HTMLElement | null
Returns
void
sent
sent: () => void;
The person sent a line: when their line lands, it rises to near the top of the feed, with space kept below it for the reply. Call it as the line goes out, or after it is drawn (an effect on a send counter): either way the line marked with JumpToLatest.mine that the feed had not shown yet is the one that rises.
Returns
void
JumpToLatestOptions
type JumpToLatestOptions = object;
Properties
resetKey?
resetKey?: string | null;
What the feed shows, such as a session id. When it changes, a feed that
starts at the end opens at the end again, instantly, whatever the reader
had scrolled to in the last one. Replacing the scrolling element with the
same key leaves the reader where they were. Either way, the space kept
under the last conversation's line, and a send still waiting for its line,
do not carry over. A key that arrives where there was none (null) after
the person sent is the conversation that send created: the line still
rises, or keeps its rise.
startAtEnd?
startAtEnd?: boolean;
Open at the end (the default). false opens where the element starts, such
as a feed with a lead above its turns.
LineTurn
type LineTurn = object;
One turn of the conversation, as the model reads it: its request id, its
status, and whether the engine runs it again for the caller (core's
SessionTurn.retryable, which the engine sets with the retry route's own rule).
Properties
id
readonly id: string;
retryable?
readonly retryable?: boolean;
status
readonly status: string;
RendererRegistry
type RendererRegistry = object;
Canonical renderer registry shape.
- Class-based item types (
message,reasoning, etc.) are resolved directly. data(bydataType) andcontainer(bycomponent) use a keyed map.componentholds the renderers a suspension names withrender.component.- Pass
falseto explicitly suppress rendering for a type.
Properties
block_trace?
block_trace?: BlockComponentType | false;
component?
component?: Record<string, BlockComponentType | false>;
Renderers a suspension item names with render.component, for a schema
richer than the built-in cards handle. Not an item type.
container?
container?: Record<string, BlockComponentType | false>;
data?
data?: Record<string, BlockComponentType | false>;
Renderers for data items, keyed by dataType: how a dataType gets
drawn, generative UI included. A data item with no renderer here renders
nothing.
error?
error?: BlockComponentType | false;
message?
message?: BlockComponentType | false;
reasoning?
reasoning?: BlockComponentType | false;
source?
source?: BlockComponentType | false;
status?
status?: BlockComponentType | false;
stopped?
stopped?: BlockComponentType | false;
Renderer for a stopped conversation line: a turn the user stopped,
drawn after its last line. Not an item type: it receives { line }.
When unset, a plain "Stopped" line renders; false draws none.
suspension?
suspension?: BlockComponentType | false;
Custom renderer for type === "suspension" items. Pass false to suppress
inline rendering (for headless layouts that use useSuspensions + a modal/sidebar).
When unset, <ApprovalRenderer> renders as the built-in fallback.
tool_output?
tool_output?: BlockComponentType | false;
RequestStreamFilter
type RequestStreamFilter = object;
Type-based filter for request stream items. Items failing the predicate never
reach the store (gated at the binder's itemFilter seam).
Properties
itemTypes?
itemTypes?: string[];
RequestStreamSource
type RequestStreamSource =
| {
lastEventId?: string;
requestId: string;
startingAfter?: number;
}
| {
response: Response;
};
Where the hook gets its stream. { requestId } opens a GET-by-id stream;
{ response } consumes a pre-fetched POST Response (inline streaming).
SendKeyEvent
type SendKeyEvent = object;
The parts of a keystroke the shortcut reads: a React or a DOM KeyboardEvent both fit.
Properties
ctrlKey
ctrlKey: boolean;
isComposing?
isComposing?: boolean;
key
key: string;
keyCode?
keyCode?: number;
metaKey
metaKey: boolean;
nativeEvent?
nativeEvent?: object;
isComposing?
isComposing?: boolean;
shiftKey
shiftKey: boolean;
SendKeyOptions
type SendKeyOptions = object;
Properties
enterSends?
enterSends?: boolean;
Plain Enter sends too, as in a chat composer. Off by default: Enter is a new line.
SentLineMark
type SentLineMark = object;
What JumpToLatest.mine returns: spread it on the element that is the person's line.
Properties
data-sent-line
"data-sent-line": string;
SessionChildSessionsOptions
type SessionChildSessionsOptions = object;
Background-work list configuration for useSession.
Properties
limit?
limit?: number;
Rows each read asks for, newest first. Omitted by default, which lets the server apply its own page size.
Set it when a conversation runs more background work than that page holds — the list is all-time history, not just what is currently running, so it grows with everything the conversation has ever started, and anything past one page is not reachable from the hook.
The server caps this and rejects a larger value with a 400, which surfaces
as childSessionsStale rather than rows. The cap defaults to 100 and is
raised with maxChildSessionListLimit on the server, so a value above what
the deployment permits is a misconfiguration on the app's side, not a
silent truncation.
SessionItemsOptions
type SessionItemsOptions =
| boolean
| {
includeTransient?: boolean;
itemTypes?: string[];
};
Items subscription configuration for useSession.
SessionList
type SessionList = object;
What useSessionList returns.
Properties
error
readonly error: string | null;
Why the last read failed, or null.
isLoading
readonly isLoading: boolean;
refresh
readonly refresh: () => void;
Read again now.
Returns
void
sessions
readonly sessions: readonly SessionSummary[];
The sessions, newest first as the server lists them.
SessionListClient
type SessionListClient = object & Partial<Pick<Client, "subscribe">>;
The client a session list reads through: the listing, and subscribe to
stay live. Pass a stable reference; the read is fenced on it.
Type Declaration
sessions
readonly sessions: Pick<SessionsApi, "list">;
SessionRefreshOptions
type SessionRefreshOptions = object;
Options for SessionView.refresh.
Properties
items?
items?: boolean;
false re-reads the session's state, detail and background work, and no
item history: one state read, whatever the history's length. The items on
screen stay as they are. Default true: the whole view.
SessionRowState
type SessionRowState = object;
A row's state, by its latest request's status: what the user reads, and whether it needs them.
Properties
label
readonly label: string;
What the user reads: "Running", "Waiting on you", …
mark
readonly mark: string;
A one-character mark, since the package ships no icon set.
needsYou
readonly needsYou: boolean;
The session needs its user: waiting on them, lost to a restart, failed, or cut short.
status
readonly status: RequestStatus;
SessionView
type SessionView = object;
Reactive session view returned by useSession.
Properties
abortRequest
abortRequest: () => Promise<void>;
Abort the currently in-flight request. No-op if nothing is in flight.
Returns
Promise<void>
answerSuspension
answerSuspension: (args) => Promise<void>;
Answer a pending stop (approve, reject, submit or skip) and stream the
continuation back into this session's items. A user's stop
(ctx.suspendForUser, or a raw user_approval / user_input) is
answered through the client's answer, whatever started its run, a
task's or a webhook's included; a developer's own ctx.suspend with a
custom reason through resume. The reason is read off the suspension
item in items; a stop not there is answered as a user's.
The POST carries Accept: text/event-stream, so the continuation streams
from the POST response on the same instance that handled it: the output
after the stop renders live, with no page refresh, even on serverless
(where a separate GET reconnect couldn't reach the in-flight
continuation). Falls back to a GET re-attach and a snapshot refresh when
the server returns a 202 instead of SSE.
requestId is the stopped request's id (carried on the suspension item).
The continuation re-enters that same id, so its items merge into the
existing stream rather than creating a new request. Who answered is the
signed-in caller, set by the server.
Parameters
args
action
ResumeAction
data?
unknown
requestId
string
suspensionId
string
Returns
Promise<void>
canSendAction
readonly canSendAction: boolean;
True when the session can accept a new sendAction call (not blocked by an in-flight request).
childSessions
readonly childSessions: ReadonlyArray<ChildSessionSummary>;
Background work running under this session — one entry per body of work, not per attempt, and finished work stays listed. Empty for a session that never launched any.
Separate from items on purpose: background work is not part of the
conversation, and nothing here is folded into the transcript. An app that
wants "here's what came back" to appear in the chat writes that itself.
Current as of the last thing the user did: re-read on mount, at the start
of every action, and whenever the app calls refresh(). With live: true
it is also re-read whenever a run starts or finishes, and an unfinished
run older than the page stays listed until it finishes.
One page of the most recent entries, newest first, sized by the server
unless the app names a page with childSessions: { limit }. This is
all-time history rather than only what is running now, so it grows with
everything the conversation has ever started; past one page the oldest
finished work falls off the end and is not reachable from here.
A row's status is absent until its work has run anything, and "active"
means only not finished. Without live, the list may be stale: never
render "active" as "running", "working" or "thinking", and never treat
it as proof a worker is alive. With live: true the list is re-read as
runs start and finish, so "active" may read as "working", which clears
when the run ends; a paused or stopped run reads the same.
childSessionsStale
readonly childSessionsStale: boolean;
True when the most recent attempt to re-read childSessions failed. The
rows already read are kept rather than cleared, so this is the difference
between "this is the current list" and "this is the last list we could
get" — without it a job that has since failed renders as still running.
Cleared by the next successful read.
With live: true, also true while the session stream, having named the
runs, is not following the session: once a reconnect has failed, until a
connection names the runs again, and for good once the stream is refused
or the session is gone. The rows are kept either way.
continueRequest
continueRequest: (requestId) => Promise<void>;
Continue a crash-interrupted request under its OWN id and stream
the re-entry's items back into this session's items. Unlike
resumeLatestRequest (which re-dispatches the session's most recent
request via /retry under a NEW id), this targets a specific requestId
— the caller resolves which interrupted request to continue, this does
not assume "latest".
POSTs inline with Accept: text/event-stream so the continuation streams
from the same POST response on the instance that handled it (mirrors
answerSuspension's inline-streaming rationale — essential on
serverless). If the server instead returns a 202 (no inline streaming
support), the continuation has already been accepted server-side — this
does NOT re-POST /continue (the record has left interrupted, so a
second POST would 409/race). It cancels the unused body and reconnects
via a GET stream instead.
Parameters
requestId
string
Returns
Promise<void>
detail
readonly detail: SessionDetail | null;
dismissRequest
dismissRequest: (requestId?) => Promise<void>;
Dismiss a stuck request without requiring a live SSE connection. Sends the abort signal to the server, closes any local stream handle, injects a synthetic abort item so the user sees the prior request was stopped, and refreshes the latest server snapshot.
The target id is resolved in this order: explicit argument →
captured-on-error id → active stream id → latestRequest.id. No-op
(with a console warning) if no id can be resolved.
Parameters
requestId?
string
Returns
Promise<void>
error
readonly error: Error | null;
flowKind
readonly flowKind: string;
followedRequest
readonly followedRequest: FollowedRequest | null;
The request the view shows last: the one the newest item in items
belongs to, so a request sent beside it that adds no items, such as a
steered line, doesn't take its place. null until items holds one, and
always with items: false.
While its stream runs, status comes from the stream. When it ends, or
once it is shown after a reload, its record is read: from the
latestRequest read when it is the newest request, else with one status
read (GET /:flowKind/requests/:requestId/status).
followRequest
followRequest: (requestId) => boolean;
Follow a request of this session that was sent without the hook: stream
its items into items, from the start, and make it the request
abortRequest stops. The stream followed now is closed. Followed again
after its stream dropped, it picks up after the last event the view had,
so state changes already applied are not applied twice. Returns false
and follows nothing for a request the person stopped or dismissed: it is
not picked back up, even while the server still lists it as running.
For a request sent beside the one the page follows, so the page stays on that one until it ends: a turn that waits for the running turn, say, sent through the client and followed once the running turn is over. Sends nothing.
Parameters
requestId
string
Returns
boolean
getItemsByAgent
getItemsByAgent: (agentName) => OutputItem[];
Returns items stamped with the given agentName. Useful for rendering per-agent panels.
Parameters
agentName
string
Returns
OutputItem[]
getItemsByVisibility
getItemsByVisibility: (predicate) => OutputItem[];
Returns items matching the given visibility predicate.
Parameters
predicate
Partial<ItemVisibility>
Returns
OutputItem[]
getOwnedItems
getOwnedItems: (ownedBy) => OutputItem[];
Returns items owned by a container scope (items where ownedBy === blockInstanceId).
Parameters
ownedBy
string
Returns
OutputItem[]
isFinishing
readonly isFinishing: boolean;
True when the main execution chain has completed but background work tasks are still running.
isLoading
readonly isLoading: boolean;
True while this session's snapshot is being read. Starts true on the first paint when a session id is given, so a transcript can hide itself instead of flashing empty.
isStreaming
readonly isStreaming: boolean;
isStuck
readonly isStuck: boolean;
True when the SSE stream has gone silent for longer than
stuckThresholdMs while a request is (or was) in flight. Surfaces a
"connection lost" affordance when the stream drops without producing
a terminal event. Cleared on the next terminal status, successful
dismiss, or new sendAction.
items
readonly items: OutputItem[];
latestRequest
readonly latestRequest: SessionRequestSummary | null;
Most recent request on this session, regardless of status. null until
the first list fetch resolves or when the session has no requests yet.
Refreshed on mount and whenever an SSE stream reaches a terminal state.
orgId?
readonly orgId?: string;
Org id the session is bound to, mirrored from detail.orgId once the
session record has loaded. undefined for unbound sessions.
refresh
refresh: (options?) => Promise<void>;
Re-read the view: the snapshot with its whole item history, and the
background work. refresh({ items: false }) re-reads state, detail and
background work only, and leaves the items as they are; use it when only
state changed, such as after a request sent beside the one the view
follows. A state read never rewinds state a newer read already set.
The hook re-reads state itself after a stop and when a request it follows ends without completing; a completed request gets the full read, which settles its items.
Parameters
options?
Returns
Promise<void>
resourceChanges
readonly resourceChanges: ReadonlyArray<ResourceChangeNotice>;
Mid-stream resource_change notices, in arrival order. Independent of the
items filter — these are surfaced even when transients are filtered out
of items, so subscribers (e.g., useResourceCollection) can react to
in-flight resource mutations without setting includeTransient: true on
the caller's useSession call.
resumeLatestRequest
resumeLatestRequest: () => Promise<void>;
Re-dispatch the most recent request and attach to the new stream.
No-op when there is no latest request, or when its status is not one
that the server will retry (interrupted or failed).
Returns
Promise<void>
sendAction
sendAction: (action, input, options?) => Promise<ExecuteActionResponse>;
Send an action on this session. userMessage shows the person's line at
once, before the server's copy arrives. attachments are the message's
files, as upload returned them, sent beside the input: the line shown
at once holds them after the text, as the server's will.
Parameters
action
string
input
unknown
options?
attachments?
FileContent[]
metadata?
Record<string, unknown>
userMessage?
string
Returns
Promise<ExecuteActionResponse>
sessionId?
readonly sessionId?: string;
snapshot
readonly snapshot: SessionStateSnapshotResponse | null;
statusMessage
readonly statusMessage: string;
Request-scoped status slot — the most recent value passed to
ctx.emit.status() during the in-flight request. Empty string when no
block has emitted a status yet (or when a block explicitly cleared it).
Resets to "" when the request terminates.
subscribeAudioDelta
subscribeAudioDelta: (handler) => () => void;
Subscribe to streaming TTS audio chunks. Chunks are live-only
and not retained in session item state — the durable representation is
the eventual OutputAudioContent snapshot delivered via items. The
returned function unsubscribes. Used by useVoice for gapless playback;
external consumers can attach a custom handler when implementing their
own player.
Parameters
handler
(event) => void
Returns
() => void
userId
readonly userId: string;
SuspensionResolver
type SuspensionResolver = (args) => Promise<void>;
Streaming suspension resolver. Matches the shape of
SessionView.answerSuspension so an app can pass it through verbatim. The
action spans the full resolution vocabulary — submit/skip resolve the
non-binary shapes (a question answer, a form, a selection, an optional step).
Parameters
args
action
ResumeAction
data?
unknown
requestId
string
suspensionId
string
Returns
Promise<void>
SuspensionResolverProviderProps
type SuspensionResolverProviderProps = object;
Props for SuspensionResolverProvider.
Properties
children
children: ReactNode;
resolve
resolve: SuspensionResolver;
The session-bound streaming resolver, typically session.answerSuspension.
SuspensionShape
type SuspensionShape = "approval" | "question" | "selection" | "form";
The default card a suspension dispatches to.
SuspensionValueKind
type SuspensionValueKind = "object" | "string" | "number" | "boolean" | "enum" | "enum-multi";
The value shapes the bounded renderers understand.
UseActionOptions
type UseActionOptions = object;
Options for useAction.
Properties
action
action: string;
baseUrl?
baseUrl?: string;
flowKind?
flowKind?: string;
result?
result?: boolean;
When true, execute resolves to what the action answered
(request.result(): status, plus output, outputNotRecorded or
error), and loading holds until the request settles. An unmount stops
the wait, never the run. Without it, execute resolves when the server
accepts the send.
userId?
userId?: string;
UseActionResult
type UseActionResult<TResolved> = object;
Return type for useAction. TResolved is what execute resolves to: the
send's acceptance, or with result: true the request's result.
Type Parameters
TResolved
TResolved = ExecuteActionResponse
Properties
error?
readonly error?: Error;
execute
execute: (input, sessionId) => Promise<TResolved>;
Send the action in sessionId. Required: every send names its session.
For a one-shot send, pass oneOffSessionId() from
@flow-state-dev/core/helpers.
Parameters
input
unknown
sessionId
string
Returns
Promise<TResolved>
loading
readonly loading: boolean;
UseApprovalOptions
type UseApprovalOptions = object;
Options for useApproval.
Properties
isResolved?
isResolved?: boolean;
Whether a matching suspension_resume item has already arrived. Drives the
resolved/receipt state on reload or when resolved elsewhere. Renderers that
see the full stream supply this (the built-in card via the renderer
pipeline; the ui card via session-items context).
onApprove?
onApprove?: (data?) => void | Promise<unknown>;
Override the approve resume call (caller owns the transport + its state).
Parameters
data?
unknown
Returns
void | Promise<unknown>
onReject?
onReject?: (data?) => void | Promise<unknown>;
Override the reject resume call (caller owns the transport + its state).
Parameters
data?
unknown
Returns
void | Promise<unknown>
resolution?
resolution?: SuspensionStatus;
How the suspension was resolved, when known — drives the receipt outcome.
UseApprovalResult
type UseApprovalResult = object;
Return value of useApproval.
Properties
approve
approve: () => void;
Approve the suspension. No-op while resolving or already resolved. Takes no argument, so it can be a click handler as it is.
Returns
void
approveWith
approveWith: (data) => void;
Approve, sending data with the yes (an ApprovalOption's data,
say). The same guards as approve.
Parameters
data
unknown
Returns
void
canApprove
canApprove: boolean;
Whether the approve action is currently available.
canReject
canReject: boolean;
Whether the reject action is currently available.
error
error: string | null;
Last resume error message, or null.
isResolving
isResolving: boolean;
True while a resume call is in flight.
outcome
outcome: ApprovalOutcome;
Icon + label for the resolved receipt.
pendingAction
pendingAction: "approve" | "reject" | null;
The action currently in flight, or null. Each label can show its own progress.
reject
reject: () => void;
Reject the suspension. No-op while resolving or already resolved.
Returns
void
rejectWith
rejectWith: (data) => void;
Reject, sending data with the no (a note, say). The same guards as reject.
Parameters
data
unknown
Returns
void
resolved
resolved: boolean;
True once resolved (by this hook or an external isResolved).
resolvedStatus
resolvedStatus: SuspensionStatus | undefined;
The resolved status when known (local action wins, else resolution).
UseCollectionResourceResult
type UseCollectionResourceResult<TClient> = object;
TClient is the collection's projected per-item client-data type;
pass it via the hook generic, e.g.
useCollectionResource<ClientDataOf<typeof memos>>(...). Defaults to
unknown so existing untyped call sites are unchanged.
Type Parameters
TClient
TClient = unknown
Properties
error
error: Error | undefined;
isLoading
isLoading: boolean;
item
item: CollectionResourceHandle<TClient> | null;
refetch
refetch: () => void;
Returns
void
UseFlowOptions
type UseFlowOptions = object;
Options for the useFlow hook.
Properties
autoCreateSession?
autoCreateSession?: boolean;
autoSelectSession?
autoSelectSession?: boolean;
When true (the default), the mount fetch selects the most-recent
session if none is active yet. Pass false when the consumer drives
selection itself (e.g. keying the active session off input metadata) so
the hook doesn't auto-load a session the consumer didn't ask for.
baseUrl?
baseUrl?: string;
flowKind?
flowKind?: string;
userId?
userId?: string;
UseFlowResult
type UseFlowResult = object;
Return type for the useFlow hook.
Properties
activeSessionId?
readonly activeSessionId?: string;
createSession
createSession: (metadata?) => Promise<SessionDetail>;
Parameters
metadata?
Record<string, unknown>
Returns
Promise<SessionDetail>
ensureSession
ensureSession: (metadata?) => Promise<SessionDetail>;
Parameters
metadata?
Record<string, unknown>
Returns
Promise<SessionDetail>
flowKind?
readonly flowKind?: string;
flows
readonly flows: FlowListEntry[];
isLoading
readonly isLoading: boolean;
True on the first paint and while the flow/session list is being read.
refreshSessions
refreshSessions: () => Promise<void>;
Re-fetch the session list (e.g. after metadata changes).
Returns
Promise<void>
selectSession
selectSession: (sessionId) => void;
Set the active session, or pass undefined to clear it (no session
shown).
Parameters
sessionId
string | undefined
Returns
void
sessions
readonly sessions: SessionSummary[];
userId
readonly userId: string;
UseHarnessLinesOptions
type UseHarnessLinesOptions<TOutcome> = object;
Options for useHarnessLines.
Type Parameters
TOutcome
TOutcome extends string = HarnessLineOutcome
Properties
input?
input?: (line) => unknown;
The turn action's input for a line, read when the line is sent. Default
{ prompt: line }.
Parameters
line
string
Returns
unknown
sendOne?
sendOne?: (prompt, running, sender) => Promise<TOutcome>;
How one line is sent. Default the client's sendHarnessLine.
Parameters
prompt
string
running
boolean
sender
HarnessLineSender
Returns
Promise<TOutcome>
steerAction?
steerAction?: string;
The flow's steer action (core's harnessSteering). Default "steer".
turnAction?
turnAction?: string;
The flow's turn action. Declare it concurrency: "defer". Default "turn".
UseInterruptKeysOptions
type UseInterruptKeysOptions = InterruptKeysOptions & object;
Type Declaration
enabled
enabled: boolean;
Whether there is anything to stop. Off, every key is left alone and the gesture disarms.
onInterrupt
onInterrupt: () => void;
Called once per completed gesture.
Returns
void
target?
target?: "document";
"document": the hook listens on the document itself, so the keys work
wherever focus is. It listens in the bubble phase, after any
capture-phase dismisser has had the chance to spend an Esc. Leave it out
to attach the returned onKeyDown to a scope of your own.
UseRequestStreamOptions
type UseRequestStreamOptions = object;
Options for useRequestStream.
Properties
baseUrl?
baseUrl?: string;
client?
client?: Pick<Client, "flow">;
The client to stream through, for a host that holds its own (its user,
origin and fetcher). Pass a stable reference. Default: the provider's
client.
enabled?
enabled?: boolean;
false opens nothing, and a { requestId } source needs no flow or id. Default true.
filter?
filter?: RequestStreamFilter;
flowKind?
flowKind?: string;
flush?
flush?: "raf" | "immediate";
Snapshot flush policy. "raf" (default) coalesces; "immediate" flushes synchronously.
includeTrace?
includeTrace?: boolean;
Append ?include=trace to the stream URL. Only meaningful for a { requestId } source.
onSessionMetadataChanged?
onSessionMetadataChanged?: () => void;
Returns
void
reconnect?
reconnect?: boolean;
Open a { requestId } stream again when it drops while the request is in
progress: the client's request(id).stream({ reconnect: true }), which
backs off, resumes after the last event and ends on a 401, 403 or 404.
Default false.
reconnectToken?
reconnectToken?: number;
Bump to force a fresh re-subscribe for the same request id (e.g. resuming a suspended run under its original id).
source
source: RequestStreamSource;
UseRequestStreamResult
type UseRequestStreamResult = object;
Return type for useRequestStream.
Properties
blockOutputs
readonly blockOutputs: BlockTraceItem[];
close
close: () => void;
Returns
void
completedAt?
readonly completedAt?: number;
When the request ended, in ms: the time of the status event that ended it
(completed, failed, aborted, incomplete or interrupted).
undefined while it runs or waits (suspended). A screen that follows
one request by id, rather than a session's latest turn, reads its end
time here: no session read names it.
currentStatus?
readonly currentStatus?: StatusItem;
isFinishing
readonly isFinishing: boolean;
True when the main execution chain has completed but background work tasks are still running.
isStreaming
readonly isStreaming: boolean;
items
readonly items: OutputItem[];
lastEventId?
readonly lastEventId?: string;
messages
readonly messages: MessageItem[];
startedAt?
readonly startedAt?: number;
The request-created event's time, when the stream includes it.
status
readonly status: RequestStatus;
UseResourceCollectionListResult
type UseResourceCollectionListResult<TClient> = object;
TClient is the collection's projected per-item client-data type;
pass it via the hook generic, e.g.
useResourceCollectionList<ClientDataOf<typeof memos>>(...). Defaults to
unknown so existing untyped call sites are unchanged.
Type Parameters
TClient
TClient = unknown
Properties
error
error: Error | undefined;
hasMore
hasMore: boolean;
True when another page can be loaded via loadMore (an opaque cursor remains).
isLoading
isLoading: boolean;
items
items: CollectionResourceHandle<TClient>[];
Items accumulated across loadMore calls.
loadMore
loadMore: () => void;
Append the next page; no-op when there's nothing more to load.
Returns
void
refetch
refetch: () => void;
Re-fetch the first page from scratch.
Returns
void
UseResourceCollectionResult
type UseResourceCollectionResult<TClient> = object;
Return type for useResourceCollection.
TClient is the collection's projected per-item client-data type;
pass it via the hook generic, e.g.
useResourceCollection<ClientDataOf<typeof memos>>(...). Defaults to unknown
so existing untyped call sites are unchanged.
Type Parameters
TClient
TClient = unknown
Properties
actions
actions: CollectionActions;
Mutation actions (create/update/delete content).
count
count: number | undefined;
Total item count from the snapshot, when the collection is client-visible.
get
get: (topic) => Promise<CollectionResourceState | null>;
Fetch a single item by topic. Returns null if not present.
Parameters
topic
string
Returns
Promise<CollectionResourceState | null>
list
list: (options?) => Promise<CollectionListPage>;
Fetch a paginated page of items. Cached by normalized query. A list kept
from before a session, ref or client change still reads, uncached, for the
identity it was made for.
Parameters
options?
Returns
Promise<CollectionListPage>
live
live:
| Record<string, {
clientData?: unknown;
deleted?: boolean;
}>
| undefined;
Per-topic live overlay from the snapshot, populated for
client.live: true collections. A created/updated entry carries
clientData; a deleted entry is a tombstone (deleted: true). The
convenience hooks apply this over their fetched items so list/item reads
reflect mid-stream mutations without a refetch.
prefetched
prefetched: CollectionResourceHandle<TClient>[] | undefined;
Items inlined in the snapshot when prefetchWindow > 0, wrapped as handles.
query
query: (options) => Promise<CollectionListPage>;
Alias for list(); reads more naturally when a topicPrefix is the focus.
Parameters
options
Returns
Promise<CollectionListPage>
refetch
refetch: () => void;
Clear the per-instance page cache and re-trigger active subscribers.
Returns
void
wrap
wrap: (raw) => CollectionResourceHandle<TClient>;
Wraps a raw { topic, clientData? } page item from list() as a
CollectionResourceHandle with the lazy fetchContent() ergonomic.
Reuses the hook's resource client; the convenience hooks
(useResourceCollectionList / useCollectionResource) share this
to avoid constructing redundant clients.
Parameters
raw
clientData?
unknown
content?
string
topic
string
Returns
CollectionResourceHandle<TClient>
UseResourceContentResult
type UseResourceContentResult = object;
Return type for useResourceContent — content fetched eagerly.
Properties
clientData
clientData: unknown;
Client data derived from the resource's state.
content
content: string | null;
The rendered content string, or null if not yet loaded or unavailable.
isLoading
isLoading: boolean;
True while the content fetch is in progress.
refetch
refetch: () => void;
Re-fetch the content.
Returns
void
UseResourceManifestResult
type UseResourceManifestResult = object;
Properties
error
error: Error | undefined;
isLoading
isLoading: boolean;
manifest
manifest: ResourceManifest | undefined;
UseResourceResult
type UseResourceResult<TDef> = TDef extends object ? TDef extends object ? ResourceValue<CollectionSnapshotEntry> : ResourceValue<ClientValue<TDef>> : TDef extends object ? UseScopeCollectionResult<ClientValue<TDef>> : UseScopeResourceResult<ClientValue<TDef>>;
What useResource(def) returns for def.
Type Parameters
TDef
TDef
UseScopeCollectionResult
type UseScopeCollectionResult<TValue> = ResourceValue<ScopeEntry<TValue>[]> & ScopeRead & object;
A user or org collection: its first page of entries (every entry, with all; the newest page, with newest), and writes by entry.
Type Parameters
TValue
TValue
Type Declaration
delete
delete: (entry) => Promise<{
version: number;
}>;
Parameters
entry
string
Returns
Promise<{
version: number;
}>
hasOlder
hasOlder: boolean;
Whether loadOlder can fetch another page. False unless the read asked for newest.
loadOlder
loadOlder: () => void;
Fetch the next older page into value. No-op when hasOlder is false.
Returns
void
set
set: (entry, value) => Promise<{
version: number;
}>;
Parameters
entry
string
value
TValue
Returns
Promise<{
version: number;
}>
update
update: (entry, updater) => Promise<{
version: number;
}>;
updater gets null for an entry that is absent.
Parameters
entry
string
updater
(value) => TValue
Returns
Promise<{
version: number;
}>
UseScopeResourceResult
type UseScopeResourceResult<TValue> = ResourceValue<TValue> & ScopeRead & object;
A single user or org resource: its value, and its writes.
Type Parameters
TValue
TValue
Type Declaration
set
set: (value) => Promise<{
version: number;
}>;
Store value at the version read; rejects with stale_version if another write landed first.
Parameters
value
TValue
Returns
Promise<{
version: number;
}>
update
update: (updater) => Promise<{
version: number;
}>;
Apply updater to the stored value, re-applying it on a stale version (three times at most).
Parameters
updater
(value) => TValue
Returns
Promise<{
version: number;
}>
UseSessionFeedOptions
type UseSessionFeedOptions = object;
Options for useSessionFeed.
Properties
client?
client?: Pick<Client, "sessions">;
The client to follow the session through, for a host that holds its own
(its user, origin and fetcher). Pass a stable reference. Default: the
provider's client.
includeTransient?
includeTransient?: boolean;
Keep transient items too. Default false.
itemTypes?
itemTypes?: readonly string[];
Keep only these item types. Default: every type.
UseSessionFeedResult
type UseSessionFeedResult = object;
What useSessionFeed shows of one session now.
Properties
error
error: Error | null;
The last history read's failure, while it is read again and after the feed gave up; null once a read lands.
hasEarlier
hasEarlier: boolean;
The session holds items older than items[0]: call loadEarlier.
items
items: readonly OutputItem[] | undefined;
The newest history items and every item kept since, in display order; undefined until the history read lands.
runs
runs: readonly SessionRun[] | null;
The session's unfinished runs as the stream last named them; null until it has.
sessionId
sessionId: string;
The session the feed follows.
state
state: SessionConnectionStatus;
How far items and runs can be trusted.
Methods
followResponse()
followResponse(response): void;
Keep a send's streamed response (send(..., { stream: true })): its items as they are written.
Parameters
response
Response
Returns
void
loadEarlier()
loadEarlier(): Promise<void>;
Add the page of history before items[0].
Returns
Promise<void>
UseSessionHookOptions
type UseSessionHookOptions = object;
Options for useSession.
Properties
autoResume?
autoResume?: boolean;
When true, on mount the hook checks if the session has an in-progress request and re-attaches to its stream using cursor-based continuation. Default: false.
baseUrl?
baseUrl?: string;
childSessions?
childSessions?: SessionChildSessionsOptions;
flowKind?
flowKind?: string;
items?
items?: SessionItemsOptions;
live?
live?: boolean;
When true, the view also hears requests it didn't send: another tab,
another person, an agent answering in the same session. The hook opens one
stream for the session after its first snapshot, and each finished item
any request keeps joins items about a second later, in the order a
reload shows. childSessions is re-read whenever a run under the session
starts or finishes, and keeps an unfinished run the page lacks.
The stream holds a connection open while the view is mounted, and the
server reads the session about once a second for it. Leave it off for a
view only one person writes to: the request stream already carries
everything there. A server without the stream, or one that refuses it,
leaves the view as it is without live, with no error. Once the stream
has named the runs, losing it (a reconnect that fails, a refusal, the
session gone) keeps the rows and raises childSessionsStale.
A live view also hears changes other sessions make to the scopes it reads: its session's resources, and its user's and organization's state and resources. On a notice it reads state again without its item history, and passes a resource change to the resource hooks, which read again as they do for the view's own. A change this view's own request made is skipped: its own stream already carried it. On a host that can't push, the view reads its state every few seconds instead. Default: false.
stuckThresholdMs?
stuckThresholdMs?: number;
Threshold in milliseconds before the in-flight request is treated as
stuck. The watchdog tracks the most recent SSE event or heartbeat and
trips when the gap exceeds this value while a request is in flight (or
was, before an onError). Should be ≥ 2× the server's wire heartbeat
to avoid false positives during long pauses (e.g. an LLM thinking).
Default: 30000 (30 seconds).
userId?
userId?: string;
UseSessionListOptions
type UseSessionListOptions = object;
Options for useSessionList.
Properties
client?
readonly client?: SessionListClient;
The client to read and subscribe through. Default: the provider's.
enabled?
readonly enabled?: boolean;
false reads nothing and holds nothing. Default true.
flowId?
readonly flowId?: string;
List one flow instance's sessions: narrower than flowKind for a collection flow.
flowKind?
readonly flowKind?: string;
List this flow kind's sessions.
includeDispatchRuns?
readonly includeDispatchRuns?: boolean;
Also list the sessions a dispatcher ran work in. Off by default.
includeStatus?
readonly includeStatus?: boolean;
Ask the server for each row's requestStatus. Default true.
UseSubscriptionOptions
type UseSubscriptionOptions = object;
Options for useSubscription.
Properties
client?
client?: Pick<Client, "subscribe">;
The client to subscribe through, for a host that holds its own (its own
user, origin and fetcher, so the socket carries its credential). Pass a
stable reference. Default: the provider's client.
enabled?
enabled?: boolean;
false subscribes nothing. Default true.
pollIntervalMs?
pollIntervalMs?: number;
Read at this pace wherever push can miss a change: the host has no push, the socket is down, or its bus doesn't cross processes. Omit for no timer: the read then runs on a notice, a connect and a reconnect.
UseViewOptions
type UseViewOptions = ViewCallOptions & object;
Options for useView.
Type Declaration
client?
client?: ViewWatchClient;
The client to watch through, for a host that holds its own. Pass a stable reference.
enabled?
enabled?: boolean;
false watches nothing. Default true.
pollIntervalMs?
pollIntervalMs?: number | null;
The timer where push can miss a change. Default 3 s; null for none.
UseViewResult
type UseViewResult<TValue> = object;
What useView returns.
Type Parameters
TValue
TValue
Properties
failure?
failure?: ViewReadFailure;
Why the last read failed, while stale; absent otherwise.
stale
stale: boolean;
true while the last read failed.
value
value: TValue | undefined;
The view's answer, or undefined before the first lands.
Methods
refresh()
refresh(): void;
Read the view again now (a Retry, a refresh key), for every screen sharing the read. Nothing while disabled.
Returns
void
UseVoiceOptions
type UseVoiceOptions = object;
Properties
action
action: string;
Action name to dispatch with transcribed text.
apiPath?
apiPath?: string;
Where the server mounts the flow API. Default "/api/flows".
autoPlayTTS?
autoPlayTTS?: boolean;
Auto-play TTS audio from assistant messages. Default: true
baseUrl?
baseUrl?: string;
Base URL for the transcription endpoint.
buildInput?
buildInput?: (text) => unknown;
Transform transcribed text into action input. Default: { message: text }
Parameters
text
string
Returns
unknown
language?
language?: string;
Language for SpeechRecognition. Default: "en-US"
VoiceState
type VoiceState = object;
Properties
interimTranscript
readonly interimTranscript: string;
Live interim transcript from browser SpeechRecognition.
isAvailable
readonly isAvailable: boolean;
Whether voice APIs are available in this browser.
isListening
readonly isListening: boolean;
Microphone is actively recording.
isProcessing
readonly isProcessing: boolean;
Server transcription is in progress.
isSpeaking
readonly isSpeaking: boolean;
TTS audio is currently playing.
Methods
startListening()
startListening(): Promise<void>;
Start recording / listening.
Returns
Promise<void>
stopListening()
stopListening(): Promise<void>;
Stop recording, transcribe, and send action.
Returns
Promise<void>
stopSpeaking()
stopSpeaking(): void;
Stop TTS playback.
Returns
void
ZodSchemaLike
type ZodSchemaLike = object;
Structural schema contract accepted for typed clientData inference.
Properties
_output?
_output?: unknown;
parse?
parse?: (input) => unknown;
Parameters
input
unknown
Returns
unknown
Functions
ApprovalRenderer()
function ApprovalRenderer(props): ReactNode;
Built-in minimal default for type === "suspension" items. Renders the
message and plain Approve / Reject buttons while pending; a one-line receipt
once resolved. Logic is delegated to useApproval.
Parameters
props
Returns
ReactNode
approveOptionsOf()
function approveOptionsOf(item): ApprovalOption[];
The extra yeses a suspension offers, read off its data.approveOptions
(each { label, data? }). Entries that aren't one are left out, and a stop
that lists none offers only the plain approve.
Parameters
item
Pick<SuspensionItem, "data">
Returns
clearDraft()
function clearDraft(
namespace,
id,
sent?
): void;
Drop the stored draft for id, leaving any box's in-memory text alone: for a
send the server took while the box may already hold newer text. With sent,
the stored draft is dropped only if it is still that text (surrounding
whitespace aside), so a send that
settles after the box was closed and reopened keeps what was typed since.
Parameters
namespace
string
id
string | undefined
sent?
string
Returns
void
conversationLines()
function conversationLines(
items,
turns?,
options?
): ItemLine[];
A conversation's items and turns as the lines a screen draws. turns is
optional: with none, no line is stopped, no failed line offers Retry, and a
message still being written reads as streaming. See the file's header.
Parameters
items
readonly OutputItem[]
The session's items, in the order they were written.
turns?
readonly LineTurn[]
The session's turns, any order: each one's id, status and retryable.
options?
The filters, and the registry whose container renderers own their items.
Returns
ItemLine[]
createInterruptKeys()
function createInterruptKeys(options?): object;
The gesture as a small state machine. Feed it every keydown in the scope
that can stop; it answers "interrupt" when the press completes a stop,
"armed" on a first Esc, and null for a key that is not its own.
Parameters
options?
Returns
object
press()
press(event, now?): InterruptKeyResult;
Parameters
event
now?
number
Returns
reset()
reset(): void;
Returns
void
FlowNavigator()
function FlowNavigator(props): ReactNode;
The rail. One mount, one flow-list read, one scroll container.
Parameters
props
Returns
ReactNode
FlowProvider()
function FlowProvider(props): ReactNode;
Canonical React context provider for flow defaults and renderers.
Parameters
props
Returns
ReactNode
interruptChordLabel()
function interruptChordLabel(): string;
The stop chord as this platform writes it, for a hint or a button title:
⌘. on Apple platforms, Ctrl+. elsewhere and when there is no browser.
Returns
string
isSendKey()
function isSendKey(event, options?): boolean;
Whether event asks the box to send. Call preventDefault() and send when
it does; leave the keystroke alone when it doesn't.
Parameters
event
options?
Returns
boolean
isTypingTarget()
function isTypingTarget(target): boolean;
Whether a key pressed on target is typing: in a text field, a text area, a
select or editable text. A page-wide shortcut that is a printable key (/,
?, [) leaves such a key to the field.
Parameters
target
EventTarget | null
Returns
boolean
ItemRenderer()
function ItemRenderer(props): ReactNode;
Renders one output item as a React node.
Non-client types (context, state_change, resource_change) return null. All other types resolve through the renderer registry, then built-in fallbacks, then a JSON dev fallback.
Parameters
props
Returns
ReactNode
ItemsRenderer()
function ItemsRenderer(props): ReactNode[];
Renders a conversation's lines in the order given.
Each line draws through the renderer registry: a message, an error, a
suspension or a data item by its own slot, as ItemRenderer resolves it,
with the line handed to a registered renderer beside the item (line), so
it can read what the model decided (a failed line's retryable, an
assistant line's streaming). A steps line draws through
toolGroupRenderer, else item by item; a stopped line through the
registry's stopped slot, else a plain "Stopped".
Given items and no lines, it draws conversationLines(items).
Parameters
props
Returns
ReactNode[]
QuestionRenderer()
function QuestionRenderer(props): ReactNode;
Free-text clarifying-question card.
Parameters
props
Returns
ReactNode
readDraft()
function readDraft(namespace, id): string;
The stored draft for id, or "": for code that runs after its box closed.
Parameters
namespace
string
id
string | undefined
Returns
string
resolveApprovalOutcome()
function resolveApprovalOutcome(status): ApprovalOutcome;
Map a resolved suspension status to its receipt descriptor. undefined (the
card knows it resolved but not how) collapses to a neutral "Resolved" receipt.
Returns only icon + label — colour/tone is the renderer's concern.
Parameters
status
SuspensionStatus | undefined
Returns
resolveSuspension()
function resolveSuspension(args): Promise<void>;
The shared body of approve/reject. Marks in-flight, streams the resolution
through the session's answer (so the continuation renders live), captures any
error into setError, and rethrows so callers can branch on success.
In-flight is always cleared in finally. Exported for direct unit testing.
Parameters
args
Returns
Promise<void>
saveDraft()
function saveDraft(
namespace,
id,
text
): void;
Store text as the draft for id ("" drops it), whether or not a box for it is open: for a
send that settles after its box closed. A box already open for id keeps what it shows.
Parameters
namespace
string
id
string | undefined
text
string
Returns
void
SchemaFormRenderer()
function SchemaFormRenderer(props): ReactNode;
Flat schema-driven form card.
Parameters
props
Returns
ReactNode
SelectionRenderer()
function SelectionRenderer(props): ReactNode;
Single- or multi-select card driven by an enum resumeSchema.
Parameters
props
Returns
ReactNode
sessionAge()
function sessionAge(updatedAt, now): string;
How long ago updatedAt was, short: now, 4m, 3h, 2d, 5w.
Parameters
updatedAt
number
now
number
Returns
string
sessionLabel()
function sessionLabel(session): string;
What a session line reads: its title, else the label its flow gave it, else
an engine-minted or derived id shortened to its prefix and its last six
characters (sess_…3df102), else the id whole. The tail is kept rather
than the head because ids minted months apart share their first digits.
Parameters
session
Pick<SessionSummary, "id" | "title" | "label">
Returns
string
sessionRowState()
function sessionRowState(session): SessionRowState | null;
The row's state, or null for a session with nothing to say: no request
yet, a finished one, one its user stopped, or a listing not asked for
status.
Parameters
session
Pick<SessionSummary, "requestStatus" | "requestWaitsForUser">
Returns
SessionRowState | null
SuspensionResolverProvider()
function SuspensionResolverProvider(props): ReactNode;
Provides a session's streaming suspension resolver to the inline default
approval card. Wrap the subtree that renders session.items.
Parameters
props
SuspensionResolverProviderProps
Returns
ReactNode
suspensionShape()
function suspensionShape(item): SuspensionShape;
Pick the default card shape for a suspension from its reason, allow, and
resumeSchema. Shared by react's built-in ItemRenderer dispatch, the
polished UI dispatcher and the server's read of a user's pending
suspensions, so they never diverge:
user_approval→ approval.user_inputwhose permitted actions don't includesubmit→ approval. This covers a legacy record persisted beforeallowexisted (the resume route treats a missingallowas binary approve/reject) and an explicitly binaryuser_inputgate — rendering a submit-only card for either would show a button the server 409s.- otherwise
user_input→ form (flat object) / selection (enum) / question (everything else, including a schema richer than the bounded set). Pure.
Parameters
item
allow?
ResumeAction[]
reason
string
resumeSchema?
Record<string, unknown>
Returns
useAction()
Call Signature
function useAction(options): UseActionResult<RequestResult>;
Low-level escape-hatch hook for executing a single named action. With
result: true, execute resolves to what the action answered.
Parameters
options
UseActionOptions & object
Returns
UseActionResult<RequestResult>
Call Signature
function useAction(options): UseActionResult<ExecuteActionResponse>;
Low-level escape-hatch hook for executing a single named action. With
result: true, execute resolves to what the action answered.
Parameters
options
UseActionOptions & object
Returns
UseActionResult<ExecuteActionResponse>
Call Signature
function useAction(options):
| UseActionResult<RequestResult>
| UseActionResult<ExecuteActionResponse>;
Low-level escape-hatch hook for executing a single named action. With
result: true, execute resolves to what the action answered.
Parameters
options
Returns
| UseActionResult<RequestResult>
| UseActionResult<ExecuteActionResponse>
useApproval()
function useApproval(item, options?): UseApprovalResult;
Drive a suspension approval. Reads FlowContext for resume credentials and the nearest SuspensionResolverProvider for streaming resolution. Returns callbacks plus the in-flight / resolved / outcome state a card needs to render.
Parameters
item
SuspensionItem
options?
Returns
useClientData()
function useClientData<TOptions>(session, options): ClientDataValues<TOptions>;
Reads scope-grouped clientData values from the current session snapshot.
Type Parameters
TOptions
TOptions extends ClientDataSubscribeOptions
Parameters
session
options
TOptions
Returns
ClientDataValues<TOptions>
useCollectionResource()
function useCollectionResource<TClient>(
session,
ref,
topic
): UseCollectionResourceResult<TClient>;
Type Parameters
TClient
TClient = unknown
Parameters
session
ref
string
topic
string
Returns
UseCollectionResourceResult<TClient>
useContainerItems()
function useContainerItems<TState>(containerItem, source): ContainerItemsResult<TState>;
Returns the container's state, owned items, and per-key data map for a given container item.
Accepts either a SessionView (uses indexed O(1) lookups) or a raw items
array (filters by ownedBy — works with any items source such as a context
provider).
Type Parameters
TState
TState = Record<string, unknown>
Parameters
containerItem
ContainerItem
The ContainerItem emitted by a sequencer/router with container config.
source
SessionView | OutputItem[]
SessionView from useSession, or an OutputItem[] to filter.
Returns
ContainerItemsResult<TState>
useDraft()
function useDraft(namespace, id): [string, (text) => void];
The unsent text for one box, restored from storage when it opens. The setter
stores as it sets; setting "" drops the stored draft. A setter kept from an
earlier id (a slow send that settles after the box moved on) stores under
that id and leaves the shown draft alone. A setter called after the box
unmounted does nothing: the box opened next owns the stored draft, so clear
a send that settles late with clearDraft and its sent text.
Parameters
namespace
string
id
string | undefined
Returns
[string, (text) => void]
useDraftSend()
function useDraftSend<R>(
namespace,
id,
attachments?
): DraftSend;
A message box's text and its send, for the box at namespace/id (see
useDraft). A send that lands clears the box, unless something else
was typed while it ran; one that fails keeps the text and holds why in
failure.
With attachments, the send waits for the box's uploads and carries their
references; the files leave the box only once it lands. A box with files and
no text sends too. A file added while a send waits stays for the next one.
Type Parameters
R
R
Parameters
namespace
string
id
string
attachments?
Returns
useFlow()
function useFlow(options?): UseFlowResult;
Reactive hook for listing flows/sessions and managing session lifecycle.
Parameters
options?
Returns
useFlowContext()
function useFlowContext(): FlowContextValue;
Reads flow defaults from the nearest FlowProvider.
Returns
useHarnessLines()
function useHarnessLines<TOutcome>(session, options?): HarnessLinesView<TOutcome>;
Send a harness session's lines, in the order typed, while the session view stays on the running turn.
While a turn this hook sent still waits, no line steers: one taken into the running turn would reach the agent ahead of the waiting one.
Type Parameters
TOutcome
TOutcome extends string = HarnessLineOutcome
Parameters
session
The session's view, from useSession.
options?
UseHarnessLinesOptions<TOutcome>
Returns
HarnessLinesView<TOutcome>
useInterruptKeys()
function useInterruptKeys(options): object;
createInterruptKeys as a hook. Attach onKeyDown to the scope that
can stop (a frame's onKeyDown, or a document listener); armed is true
while a first Esc waits for its second, for the "press Esc again" hint, and
clears itself when the window runs out.
Parameters
options
Returns
object
armed
armed: boolean;
onKeyDown
onKeyDown: (event) => void;
Parameters
event
Returns
void
useJumpToLatest()
function useJumpToLatest(options?): JumpToLatest;
Keep the scrolling element ref is attached to where the reader put it,
bring the person's own line near its top, and offer the way to its end. See
the module header for the rule.
Parameters
options?
Returns
useRequestStream()
function useRequestStream(options): UseRequestStreamResult;
Low-level escape-hatch hook for subscribing to one request stream.
Parameters
options
Returns
useResource()
function useResource<TDef>(def, options?): UseResourceResult<TDef>;
Read one resource or collection and keep it current. At user or org scope it
needs no session; at session scope pass { session }, or { sessionId }
where the screen has no useSession view.
Type Parameters
TDef
TDef extends ScopeResourceDef
Parameters
def
TDef
options?
all?
boolean
At user or org scope, a collection's value is every one of its entries,
page after page (listAll()), not its first page. Ignored for a single
resource and at session scope. When newest is also set, this is the
read: a screen asks for one of the two.
client?
Pick<Client, "resource" | "subscribe"> & object
At user or org scope, or at session scope by sessionId, the client to
read (and at user or org scope write) through, for a host that holds its
own (its user, origin and fetcher). Pass a stable reference. Default:
the provider's client.
key?
string
At session scope, the name the session's flow declares the resource
under (its key in the snapshot), when it is not the definition's ref,
pattern or the pattern's static prefix. A definition with no ref
needs it. At user or org scope, the resource's key, as client.resource's.
newest?
boolean
At user or org scope, a collection's value is its newest page (by each
entry's at), and loadOlder() fetches the next older page. A notice
that names entries merges those entries in. Ignored for a single
resource, at session scope, and when all is set.
pollIntervalMs?
number
At user or org scope, or by sessionId, how often to read where push can miss a change, in ms. Default: the client's live-read pace.
session?
sessionId?
string | null
At session scope, the session to read the resource of, where the screen
has no useSession view (one that follows the session with
useSessionFeed): its state is read without its items, again on that
session's notice for the resource, and on the client's timer wherever
push can miss a change. Ignored with session, and at user or org scope.
topicPrefix?
string
With all or newest, only the entries whose storage key starts with
this, and only change notices that may touch them are heard: a project's
workstreams hear only their own project.
Returns
UseResourceResult<TDef>
useResourceCollection()
function useResourceCollection<TClient>(session, ref): UseResourceCollectionResult<TClient>;
Type Parameters
TClient
TClient = unknown
Parameters
session
ref
string
Returns
UseResourceCollectionResult<TClient>
useResourceCollectionList()
function useResourceCollectionList<TClient>(
session,
ref,
options?
): UseResourceCollectionListResult<TClient>;
Type Parameters
TClient
TClient = unknown
Parameters
session
ref
string
options?
limit?
number
topicPrefix?
string
Returns
UseResourceCollectionListResult<TClient>
useResourceContent()
function useResourceContent(session, ref): UseResourceContentResult;
Reads a single resource's clientData and immediately fetches its content. Content is refetched when the session snapshot changes.
Parameters
session
ref
string
Returns
useResourceManifest()
function useResourceManifest(session): UseResourceManifestResult;
Parameters
session
Returns
useSession()
function useSession(sessionId, options?): SessionView;
Parameters
sessionId
string | undefined
options?
Returns
useSessionFeed()
function useSessionFeed(sessionId, options?): UseSessionFeedResult | undefined;
Follow session sessionId live. null or undefined follows nothing and
returns undefined, as it does until the feed for this session is open.
Parameters
sessionId
string | null | undefined
options?
Returns
UseSessionFeedResult | undefined
useSessionList()
function useSessionList(options): SessionList;
A flow's sessions, live. Name the flow by flowKind, or by flowId for
one instance of a collection flow.
Parameters
options
Returns
useSubmit()
function useSubmit<A>(action): Submit<A>;
A form's submit, or a button's, that runs action, holding the controls while
it runs and keeping a refusal to show instead of throwing. Show error next
to the controls, so a refused call never looks like it worked.
Type Parameters
A
A extends unknown[]
Parameters
action
(...args) => Promise<void>
Returns
Submit<A>
useSubscription()
function useSubscription(
topics,
read,
options?
): void;
Run read when something under topics changes. read may return a
promise; the next read waits for it. Its signal aborts when this
subscription ends.
Parameters
topics
readonly WireTopic[]
read
(notice, signal) => unknown
options?
Returns
void
useSuspensionForm()
function useSuspensionForm(item, options?): UseSuspensionFormResult;
Drive a non-binary suspension (question / form / selection). Reads the
suspension's resumeSchema for field derivation and allow for which actions
are permitted, and resolves through the streaming resolver (or the recovery
client fallback). When the schema is richer than a flat object of scalars/enums
the fields list is empty — render a custom component instead.
Parameters
item
SuspensionItem
options?
Returns
useSuspensionResolver()
function useSuspensionResolver(): SuspensionResolver | null;
Reads the streaming suspension resolver from the nearest provider, or null
when none is mounted (the default card then uses its self-contained fallback).
Returns
SuspensionResolver | null
useSuspensions()
function useSuspensions(session, options?): UseSuspensionsResult;
Derives suspension state from session.items and returns approve/reject
actions. Derivation is a useMemo over the live stream; resolution
goes through session.answerSuspension.
Parameters
session
options?
Returns
useView()
function useView<TRef>(
ref,
input?,
options?
): UseViewResult<ViewValueOf<TRef>>;
Watch the view ref names, with input. See the file header.
Type Parameters
TRef
TRef extends ViewRef
Parameters
ref
TRef
input?
ViewInputOf<TRef>
options?
Returns
UseViewResult<ViewValueOf<TRef>>
useVoice()
function useVoice(session, options): VoiceState;
Hook that adds voice interaction to a session. Provides STT input (hybrid browser + server) and TTS output (auto-play audio content).