Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The machine file

This page lists each key of a machine file, *.smllm.yaml, as the JSON Schema that smllm info schema prints describes it. Each section is one object of the file, named by its path from the top of the file, in the order that you meet them. In a path, <STATE> stands for the name of a state, <EVENT> for the name of an event, <PARAM> for the name of a param, and [] for an item of a list. Actions, guards, and transitions, which several keys take, have sections of their own. A key without yes under Required can be left out.

The machine

KeyTypeRequiredDescription
idstringyesThe machine’s id, unique within the config: letters, digits, _, and -.
descriptionstringThe machine’s description, which the idle list shows.
initialstringyesThe state in which a new instance starts.
metaobjectyessmllm’s data for the machine.
statesmap of objectsyesThe machine’s states. smllm does not support nested states.

meta

smllm’s data for the machine.

KeyTypeRequiredDescription
smllmintegeryesThe smllm format version, which is 1.
instanceobjectWhat the machine calls an instance, and the instance’s ref.
eventsmap of objectsThe machine’s events, each declared once. A built-in event can set only its description.
sharedActionslist of objectsActions added to the entry or exit actions of several states.

states.<STATE>

One state.

KeyTypeRequiredDescription
descriptionstringThe state’s description.
typeatomic or finalThe state’s type. A final state completes the instance. atomic: An ordinary state, the default. final: A state that completes the instance.
metaobjectsmllm’s data for the state.
entryaction, or a list of themThe actions that run when the state is entered. Without a prompt among them, smllm shows the prompt file enter-<STATE>.md, if it exists. The action setRef can be written as its bare name.
exitaction, or a list of themThe actions that run when the state is left. The action setRef can be written as its bare name.
onmap of (transition, or a list of them)The transitions for each event. A transition can be written as the name of its target state.
alwaystransition, or a list of themTransitions without an event. smllm leaves a state with always at once. A transition can be written as the name of its target state.
invokeobject, or a list of themThe host’s work while an instance is in this state. The state handles an event of source: host, through which the host fires the work’s result.

meta.instance

KeyTypeRequiredDescription
kindstringThe word for an instance in the text that smllm writes, such as issue. The default is instance.
refobjectThe instance’s ref: its id outside smllm, such as an issue number.

meta.events.<EVENT>

KeyTypeRequiredDescription
descriptionstringThe event’s guidance for the agent, unless a transition gives its own.
paramsobjectThe event’s params: a JSON Schema object of string and JSON properties.
sourceagent or hostWho fires the event: agent, the default, or host. Only the host that embeds the engine fires a host event, and the agent never sees it.

meta.sharedActions[]

One meta.sharedActions entry.

KeyTypeRequiredDescription
stateslist of stringsyesThe states that the actions are added to.
positionbefore or afteryesWhether the actions run before or after the state’s own entry or exit actions. before: Before the state’s own actions. after: After the state’s own actions.
entryaction, or a list of themActions added to each state’s entry. The action setRef can be written as its bare name.
exitaction, or a list of themActions added to each state’s exit. The action setRef can be written as its bare name.

states.<STATE>.meta

smllm’s data for a state.

KeyTypeRequiredDescription
entryPointbooleanWhether the agent can enter this state directly from idle. Default: false.
fallbackbooleanWhether the unmatched event enters this state. At most one state of a machine can be the fallback. Default: false.
paramDescriptionsmap of map of stringsPrompts for params in this state, by event and then by param.

Actions

These keys take actions: states.<STATE>.entry, states.<STATE>.exit, meta.sharedActions[].entry, meta.sharedActions[].exit, <transition>.actions.

An action, written as {type, params}.

type: prompt

Shows text to the agent.

It needs params, an object with these keys:

KeyTypeRequiredDescription
textstringThe text itself.
filestringA file of text, relative to the machine file, which smllm reads each time it shows the prompt.

type: command

Runs a command.

It needs params, an object with these keys:

KeyTypeRequiredDescription
runstring or list of stringsyesA string that a shell runs, or a list of a program and its arguments, run without a shell. String: A string that sh -c runs, or cmd /C on Windows. List of strings: A program and its arguments, run without a shell.
timeoutSecsintegerThe time limit in seconds. The default is 60.
cwdstringThe working directory, relative to the machine file. The default is the session’s working directory.

type: setRef

Sets the instance’s ref from the event’s ref param.

It takes no params.

Transitions

These keys take transitions: states.<STATE>.on.<EVENT>, states.<STATE>.always.

A transition object.

KeyTypeRequiredDescription
targetstringThe target state. A transition without a target stays in the state without re-entering it.
guardguardA condition that must pass for the transition to be taken.
actionsaction, or a list of themThe actions that run when the transition is taken. The action setRef can be written as its bare name.
reenterbooleanWhether a transition to its own state leaves and re-enters it, as in XState.
descriptionstringGuidance for the event in this state.

states.<STATE>.invoke

The host’s work while an instance is in its state: XState’s invoke, with only src and input. The host runs the work and fires its result as an event of source: host.

KeyTypeRequiredDescription
srcstringyesThe name of the work, by which the host finds its code.
inputobjectFixed values that the host passes to the work.

meta.instance.ref

KeyTypeRequiredDescription
paramstringThe name of the ref’s param, which enter and setRef use. The default is ref.
descriptionstringThe prompt that asks for the ref.
patternstringA pattern that the ref must match, in the syntax of a param’s pattern.

meta.events.<EVENT>.params

A subset of a JSON Schema of type: object.

KeyTypeRequiredDescription
typestringyesAlways object.
propertiesmap of objectsThe params, by name.
requiredlist of stringsThe names of the required params.

Guards

These keys take guards: <transition>.guard.

A guard, written as {type, params}.

type: command

Passes when the command exits with status 0.

It needs params, an object with these keys:

KeyTypeRequiredDescription
runstring or list of stringsyesA string that a shell runs, or a list of a program and its arguments, run without a shell. String: A string that sh -c runs, or cmd /C on Windows. List of strings: A program and its arguments, run without a shell.
timeoutSecsintegerThe time limit in seconds. The default is 60.
cwdstringThe working directory, relative to the machine file. The default is the session’s working directory.

type: visits

Passes when state has been entered at least atLeast times.

It needs params, an object with these keys:

KeyTypeRequiredDescription
statestringyesThe state whose entries are counted.
atLeastintegeryesThe least number of entries, counting the current one.

meta.events.<EVENT>.params.properties.<PARAM>

One param’s schema.

KeyTypeRequiredDescription
typestring or jsonstring, the default, or json, for a param that takes any JSON value.
descriptionstringThe prompt for the param.
enumlist of stringsThe allowed values of a string param.
patternstringA pattern that a string param’s value must match, in Rust regex syntax: the common subset of JSON Schema’s ECMA-262 patterns, without lookaround or backreferences. In smllm, \d, \w, and \s match Unicode, and in a JavaScript host they match only ASCII. To match ASCII digits in both, write [0-9].
schemastring or objectThe JSON Schema of a json param’s value, draft-07 or 2020-12: a path relative to the machine file, or the schema itself as a map. String: A JSON file, relative to the machine file. The path can lead outside the machine’s folder. Object: The schema itself.