Skip to main content

miadi-stateloom-engine

The Python implementation of the stateloom state machine engine: SMDF parser, validator (V001–V014), hierarchical runtime, and the smcg code generator.

Renamed from smcraft. The distribution is now miadi-stateloom-engine and the import package is stateloom (was smcraft), matching the @miadi/stateloom-engine npm twin and the rest of the @miadi/stateloom* family. The smcg command keeps its name. Generated Python now emits from stateloom.runtime import ….

Install

pip install miadi-stateloom-engine

Generate code from a definition

smcg machine.smdf.json -o output/ -l python -v

The pipeline is: .smdf.json → parser → EnrichedModel (lookup maps) → validator (V001–V014) → generator → a state enum, a base state class, leaf state classes, a context class and feeder classes. Generated code imports its runtime from this package rather than inlining it.

Use it as a library

from stateloom.parser import StateMachineParser
from stateloom.codegen import generate_python

parser = StateMachineParser()
model = parser.parse_file("machine.smdf.json")   # wrapped or bare JSON, both work
errors = parser.validate(model)
if not errors:
    generate_python("machine.smdf.json", "output/machine.py")

The parser accepts both shapes a .smdf.json is written in: the bare {settings, events, state} of hand-authored files, and the {"stateMachine": {…}} that smcx, the MCP server and the hub persist.

Running a machine

from stateloom.runtime import Context, State, StateKind, ObserverConsole

Context (sync) and ContextAsync (queued, background-processed) drive the machine; TransitionHelper resolves the lowest common ancestor for hierarchical transitions; observers (ObserverNull, ObserverConsole, ObserverLogger) hook entry, exit, transition and timer events.

Part of the stateloom stack

package registry role
@miadi/stateloom-engine npm the TypeScript twin of this package
@miadi/stateloom-protocol npm patch ops, diff/apply, layout, export naming
@miadi/stateloom-client npm socket.io client
@miadi/stateloom npm the socket.io hub
@miadi/stateloom-react npm React 19 binding
@miadi/stateloom-cli npm smcx
@miadi/stateloom-mcp npm the MCP server agents design through
@miadi/stateloom-skills npm installable agent skills
miadi-stateloom-engine PyPI this package

Source and full documentation: https://github.com/jgwill/smcraft

License

MIT © Guillaume Isabelle

Release files for miadi-stateloom-engine 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miadi-stateloom-engine 0.2.1
File Size Uploaded
miadi_stateloom_engine-0.2.1.tar.gz 21.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for miadi-stateloom-engine 0.2.1
File Interpreter ABI Platform
miadi_stateloom_engine-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.0 kB

Release files / miadi_stateloom_engine-0.2.1.tar.gz

Download URL miadi_stateloom_engine-0.2.1.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1485e0e3f0f9fc8b06dcfb9f0222a0bd2d6c206001ff2e1fff1f29ffdd00548e
BLAKE2b-256 checksum
How to use checksums
4ca657abfe59378ef3a63a6b9b59a24dded822b8cc54b83d6cf52010f06bcf5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / miadi_stateloom_engine-0.2.1-py3-none-any.whl

Download URL miadi_stateloom_engine-0.2.1-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa7f1f91e89192480c0678956c7239b3ac06b79e58799cd39d9069afab76f56c
BLAKE2b-256 checksum
How to use checksums
c5e028c5aabb243a5693461142eb113b5d66e8d92f9b9da883422cb291883730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page