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

12 exports
View source packages/ui-machines/src/run/index.ts

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();

Exports

RunAction

type
DeclarationView source
RunActionts
type RunAction = {
readonly reason: RunActionReason;
};
Name
Kind
Type
Requirement
reason
property
RunActionReason
required
Name
reason
Kind
property
Type
RunActionReason
Requirement
required
DeclarationView source
RunActionReasonts
type RunActionReason = "tool-calls" | "interrupt" | "approval" | "external-input";

RunCommand

type
DeclarationView source
RunCommandts
type RunCommand = never;

RunContext

type
DeclarationView source
RunContextts
type RunContext = {
readonly runId?: string;
readonly attempt: number;
readonly error?: unknown;
readonly cancelReason?: string;
readonly action?: RunAction;
};
Name
Kind
Type
Requirement
action
property
RunAction
optional
attempt
property
number
required
cancelReason
property
string
optional
error
property
unknown
optional
runId
property
string
optional
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
DeclarationView source
RunDiagnosticCodests
export declare const RunDiagnosticCodes: readonly DiagnosticCatalogueEntry[];

RunEvent

type
DeclarationView source
RunEventts
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

type

Inputs that identify the run without carrying its streamed message body.

DeclarationView source
RunInputts
type RunInput = {
readonly runId?: string;
};
Name
Kind
Type
Requirement
runId
property
string
optional
Name
runId
Kind
property
Type
string
Requirement
optional

runMachine

value
DeclarationView source
runMachinets
export declare const runMachine: Machine<RunInput, RunValue, RunContext, RunEvent, RunCommand>;
DeclarationView source
runReplaySequencets
export declare const runReplaySequence: readonly RunEvent[];

runSelectors

value
DeclarationView source
runSelectorsts
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
canCancel
method
(snapshot: RunSnapshot) => boolean
required
canRetry
method
(snapshot: RunSnapshot) => boolean
required
isActive
method
(snapshot: RunSnapshot) => boolean
required
isTerminal
method
(snapshot: RunSnapshot) => boolean
required
requiresAction
method
(snapshot: RunSnapshot) => boolean
required
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
DeclarationView source
RunSnapshotts
type RunSnapshot = Snapshot<RunValue, RunContext>;

RunValue

type
DeclarationView source
RunValuets
type RunValue = "idle" | "submitted" | "streaming" | "settled" | "cancelled" | "failed" | "requires-action";