- Name
reason- Kind
- property
- Type
RunActionReason- Requirement
- required
DocsAPI referenceUI machinesrun
run machine
The public state machine contract for @grassroot/ui-machines/run. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/run
Package
Service example
run.tsts
import { createService } from "@grassroot/statechart";import { runMachine } from "@grassroot/ui-machines/run"; const service = createService(runMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();12 of 12
Exports
RunAction
typeRunActionts
type RunAction = { readonly reason: RunActionReason;};Name
Kind
Type
Requirement
reasonproperty
RunActionReasonrequired
RunActionReason
typeRunActionReasonts
type RunActionReason = "tool-calls" | "interrupt" | "approval" | "external-input";RunCommand
typeRunCommandts
type RunCommand = never;RunContext
typeRunContextts
type RunContext = { readonly runId?: string; readonly attempt: number; readonly error?: unknown; readonly cancelReason?: string; readonly action?: RunAction;};Name
Kind
Type
Requirement
actionproperty
RunActionoptional
attemptproperty
numberrequired
cancelReasonproperty
stringoptional
errorproperty
unknownoptional
runIdproperty
stringoptional
- Name
action- Kind
- property
- Type
RunAction- Requirement
- optional
- Name
attempt- Kind
- property
- Type
number- Requirement
- required
- Name
cancelReason- Kind
- property
- Type
string- Requirement
- optional
- Name
error- Kind
- property
- Type
unknown- Requirement
- optional
- Name
runId- Kind
- property
- Type
string- Requirement
- optional
RunDiagnosticCodes
valueRunDiagnosticCodests
export declare const RunDiagnosticCodes: readonly DiagnosticCatalogueEntry[];RunEvent
typeRunEventts
type RunEvent = { readonly type: "SUBMIT"; readonly runId?: string;} | { readonly type: "DELTA"; readonly delta?: unknown;} | { readonly type: "SETTLED";} | { readonly type: "CANCEL"; readonly reason?: string;} | { readonly type: "FAILED"; readonly error?: unknown;} | { readonly type: "REQUIRES_ACTION"; readonly reason: RunActionReason;} | { readonly type: "RETRY";} | { readonly type: "RESUME";};RunInput
typeInputs that identify the run without carrying its streamed message body.
RunInputts
type RunInput = { readonly runId?: string;};Name
Kind
Type
Requirement
runIdproperty
stringoptional
- Name
runId- Kind
- property
- Type
string- Requirement
- optional
runMachine
valuerunMachinets
export declare const runMachine: Machine<RunInput, RunValue, RunContext, RunEvent, RunCommand>;runReplaySequence
valuerunReplaySequencets
export declare const runReplaySequence: readonly RunEvent[];runSelectors
valuerunSelectorsts
export declare const runSelectors: { isActive(snapshot: RunSnapshot): boolean; isTerminal(snapshot: RunSnapshot): boolean; canCancel(snapshot: RunSnapshot): boolean; canRetry(snapshot: RunSnapshot): boolean; requiresAction(snapshot: RunSnapshot): boolean;};Name
Kind
Type
Requirement
canCancelmethod
(snapshot: RunSnapshot) => booleanrequired
canRetrymethod
(snapshot: RunSnapshot) => booleanrequired
isActivemethod
(snapshot: RunSnapshot) => booleanrequired
isTerminalmethod
(snapshot: RunSnapshot) => booleanrequired
requiresActionmethod
(snapshot: RunSnapshot) => booleanrequired
- Name
canCancel- Kind
- method
- Type
(snapshot: RunSnapshot) => boolean- Requirement
- required
- Name
canRetry- Kind
- method
- Type
(snapshot: RunSnapshot) => boolean- Requirement
- required
- Name
isActive- Kind
- method
- Type
(snapshot: RunSnapshot) => boolean- Requirement
- required
- Name
isTerminal- Kind
- method
- Type
(snapshot: RunSnapshot) => boolean- Requirement
- required
- Name
requiresAction- Kind
- method
- Type
(snapshot: RunSnapshot) => boolean- Requirement
- required
RunSnapshot
typeRunSnapshotts
type RunSnapshot = Snapshot<RunValue, RunContext>;RunValue
typeRunValuets
type RunValue = "idle" | "submitted" | "streaming" | "settled" | "cancelled" | "failed" | "requires-action";