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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

miadi_stateloom_engine-0.2.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

miadi_stateloom_engine-0.2.1-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file miadi_stateloom_engine-0.2.1.tar.gz.

File metadata

  • Download URL: miadi_stateloom_engine-0.2.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for miadi_stateloom_engine-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1485e0e3f0f9fc8b06dcfb9f0222a0bd2d6c206001ff2e1fff1f29ffdd00548e
MD5 287032e8d363fb984f621787c6f705f9
BLAKE2b-256 4ca657abfe59378ef3a63a6b9b59a24dded822b8cc54b83d6cf52010f06bcf5a

See more details on using hashes here.

File details

Details for the file miadi_stateloom_engine-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for miadi_stateloom_engine-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa7f1f91e89192480c0678956c7239b3ac06b79e58799cd39d9069afab76f56c
MD5 68efea216f8de94662e734d905c55528
BLAKE2b-256 c5e028c5aabb243a5693461142eb113b5d66e8d92f9b9da883422cb291883730

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page