- Name
contentType- Kind
- property
- Type
string- Requirement
- optional
DocsAPI referenceUI machinescomposer
composer machine
The public state machine contract for @grassroot/ui-machines/composer. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/composer
Package
Service example
composer.tsts
import { createService } from "@grassroot/statechart";import { composerMachine } from "@grassroot/ui-machines/composer"; const service = createService(composerMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();15 of 15
Exports
ComposerAttachmentRefts
type ComposerAttachmentRef = { readonly id: string; readonly type: string; readonly name?: string; readonly contentType?: string;};Name
Kind
Type
Requirement
contentTypeproperty
stringoptional
idproperty
stringrequired
nameproperty
stringoptional
typeproperty
stringrequired
- Name
id- Kind
- property
- Type
string- Requirement
- required
- Name
name- Kind
- property
- Type
string- Requirement
- optional
- Name
type- Kind
- property
- Type
string- Requirement
- required
ComposerCommand
typeComposerCommandts
type ComposerCommand = CommandObject & ({ readonly type: "SEND"; readonly text: string; readonly attachments: readonly ComposerAttachmentRef[]; readonly quote?: JsonValue; readonly runConfig?: ComposerRunConfig; readonly role: ComposerRole; readonly mode: ComposerMode; readonly parentId?: string | null; readonly sourceId?: string | null; readonly steer: boolean;} | { readonly type: "CANCEL_RUN";} | { readonly type: "EXIT_EDIT";});ComposerContext
typeComposerContextts
type ComposerContext = { readonly text: string; readonly mode: ComposerMode; readonly isSendDisabled: boolean; readonly queueEnabled: boolean; readonly quote?: JsonValue; readonly attachments: readonly ComposerAttachmentRef[]; readonly runConfig?: ComposerRunConfig; readonly role: ComposerRole; readonly editingMessageId?: string; readonly parentId?: string | null; readonly sourceId?: string | null;};Name
Kind
Type
Requirement
attachmentsproperty
readonly ComposerAttachmentRef[]required
editingMessageIdproperty
stringoptional
isSendDisabledproperty
booleanrequired
modeproperty
ComposerModerequired
parentIdproperty
string | nulloptional
queueEnabledproperty
booleanrequired
quoteproperty
JsonValueoptional
roleproperty
ComposerRolerequired
runConfigproperty
ComposerRunConfigoptional
sourceIdproperty
string | nulloptional
textproperty
stringrequired
- Name
attachments- Kind
- property
- Type
readonly ComposerAttachmentRef[]- Requirement
- required
- Name
editingMessageId- Kind
- property
- Type
string- Requirement
- optional
- Name
isSendDisabled- Kind
- property
- Type
boolean- Requirement
- required
- Name
mode- Kind
- property
- Type
ComposerMode- Requirement
- required
- Name
parentId- Kind
- property
- Type
string | null- Requirement
- optional
- Name
queueEnabled- Kind
- property
- Type
boolean- Requirement
- required
- Name
quote- Kind
- property
- Type
JsonValue- Requirement
- optional
- Name
role- Kind
- property
- Type
ComposerRole- Requirement
- required
- Name
runConfig- Kind
- property
- Type
ComposerRunConfig- Requirement
- optional
- Name
sourceId- Kind
- property
- Type
string | null- Requirement
- optional
- Name
text- Kind
- property
- Type
string- Requirement
- required
ComposerDiagnosticCodes
valueComposerDiagnosticCodests
export declare const ComposerDiagnosticCodes: readonly DiagnosticCatalogueEntry[];ComposerEvent
typeComposerEventts
type ComposerEvent = { readonly type: "SET_TEXT"; readonly text: string;} | { readonly type: "SET_QUOTE"; readonly quote?: JsonValue;} | { readonly type: "BEGIN_EDIT"; readonly messageId: string; readonly text: string; readonly parentId?: string | null; readonly sourceId?: string | null;} | { readonly type: "END_EDIT";} | { readonly type: "SEND"; readonly steer?: boolean;} | { readonly type: "RUN_SETTLED";} | { readonly type: "RUN_CANCELLED";} | { readonly type: "CANCEL";} | { readonly type: "SET_SEND_DISABLED"; readonly disabled: boolean;} | { readonly type: "SET_QUEUE_ENABLED"; readonly enabled: boolean;} | { readonly type: "RESET";};ComposerInput
typeComposerInputts
type ComposerInput = { readonly text?: string; readonly defaultText?: string; readonly mode?: ComposerMode; readonly defaultMode?: ComposerMode; readonly isSendDisabled?: boolean; readonly queueEnabled?: boolean; readonly canEdit?: boolean; readonly parentId?: string | null; readonly sourceId?: string | null; readonly quote?: JsonValue; readonly attachments?: readonly ComposerAttachmentRef[]; readonly runConfig?: ComposerRunConfig; readonly role?: ComposerRole;};Name
Kind
Type
Requirement
attachmentsproperty
readonly ComposerAttachmentRef[]optional
canEditproperty
booleanoptional
defaultModeproperty
ComposerModeoptional
defaultTextproperty
stringoptional
isSendDisabledproperty
booleanoptional
modeproperty
ComposerModeoptional
parentIdproperty
string | nulloptional
queueEnabledproperty
booleanoptional
quoteproperty
JsonValueoptional
roleproperty
ComposerRoleoptional
runConfigproperty
ComposerRunConfigoptional
sourceIdproperty
string | nulloptional
textproperty
stringoptional
- Name
attachments- Kind
- property
- Type
readonly ComposerAttachmentRef[]- Requirement
- optional
- Name
canEdit- Kind
- property
- Type
boolean- Requirement
- optional
- Name
defaultMode- Kind
- property
- Type
ComposerMode- Requirement
- optional
- Name
defaultText- Kind
- property
- Type
string- Requirement
- optional
- Name
isSendDisabled- Kind
- property
- Type
boolean- Requirement
- optional
- Name
mode- Kind
- property
- Type
ComposerMode- Requirement
- optional
- Name
parentId- Kind
- property
- Type
string | null- Requirement
- optional
- Name
queueEnabled- Kind
- property
- Type
boolean- Requirement
- optional
- Name
quote- Kind
- property
- Type
JsonValue- Requirement
- optional
- Name
role- Kind
- property
- Type
ComposerRole- Requirement
- optional
- Name
runConfig- Kind
- property
- Type
ComposerRunConfig- Requirement
- optional
- Name
sourceId- Kind
- property
- Type
string | null- Requirement
- optional
- Name
text- Kind
- property
- Type
string- Requirement
- optional
composerMachine
valuecomposerMachinets
export declare const composerMachine: ComposerMachine;ComposerMachine
typeComposerMachinets
type ComposerMachine = Machine<ComposerInput, ComposerStateValue, ComposerContext, ComposerEvent, ComposerCommand>;ComposerMode
typeComposerModets
type ComposerMode = "new" | "edit";composerReplaySequence
valuecomposerReplaySequencets
export declare const composerReplaySequence: readonly ComposerEvent[];ComposerRole
typeComposerRolets
type ComposerRole = "user" | "assistant" | "system";ComposerRunConfig
typeComposerRunConfigts
type ComposerRunConfig = Readonly<Record<string, JsonValue>>;composerSelectors
valuecomposerSelectorsts
export declare const composerSelectors: { isEmpty: (snapshot: ComposerSnapshot) => boolean; isEditing: (snapshot: ComposerSnapshot) => boolean; canSend: (snapshot: ComposerSnapshot) => boolean; canCancel: (snapshot: ComposerSnapshot) => boolean; text: (snapshot: ComposerSnapshot) => string; mode: (snapshot: ComposerSnapshot) => ComposerMode; quote: (snapshot: ComposerSnapshot) => unknown;};Name
Kind
Type
Requirement
canCancelproperty
(snapshot: ComposerSnapshot) => booleanrequired
canSendproperty
(snapshot: ComposerSnapshot) => booleanrequired
isEditingproperty
(snapshot: ComposerSnapshot) => booleanrequired
isEmptyproperty
(snapshot: ComposerSnapshot) => booleanrequired
modeproperty
(snapshot: ComposerSnapshot) => ComposerModerequired
quoteproperty
(snapshot: ComposerSnapshot) => unknownrequired
textproperty
(snapshot: ComposerSnapshot) => stringrequired
- Name
canCancel- Kind
- property
- Type
(snapshot: ComposerSnapshot) => boolean- Requirement
- required
- Name
canSend- Kind
- property
- Type
(snapshot: ComposerSnapshot) => boolean- Requirement
- required
- Name
isEditing- Kind
- property
- Type
(snapshot: ComposerSnapshot) => boolean- Requirement
- required
- Name
isEmpty- Kind
- property
- Type
(snapshot: ComposerSnapshot) => boolean- Requirement
- required
- Name
mode- Kind
- property
- Type
(snapshot: ComposerSnapshot) => ComposerMode- Requirement
- required
- Name
quote- Kind
- property
- Type
(snapshot: ComposerSnapshot) => unknown- Requirement
- required
- Name
text- Kind
- property
- Type
(snapshot: ComposerSnapshot) => string- Requirement
- required
ComposerSnapshot
typeComposerSnapshotts
type ComposerSnapshot = Snapshot<ComposerStateValue, ComposerContext>;ComposerStateValue
typeComposerStateValuets
type ComposerStateValue = "empty" | "drafting" | "submitting" | "blocked";