@jigging/sley
v0.0.3
Published
Structured graph runtime for Python and TypeScript.
Readme
Sley turns tangled workflow logic into code your team can scan and change with confidence. Every possible path stays visible, the final state comes back directly, and your application remains ordinary Python or TypeScript.
Write ordinary functions, connect the paths they may take, and run the graph. Branching, fan-out, joins, retries, and nested workflows stay visible without handing your application to a framework.
Example: a release with two outcomes
The following program is a complete Sley graph. Low-risk work publishes now; high-risk work waits for review. Both allowed paths sit side by side, and the caller gets the resulting status directly.
Python
import asyncio
from sley import Flow, node
@node
def decide(context):
action = "needs_review" if context.state["risk"] == "high" else "ready"
context.emit(action)
@node
def publish(context):
context.state["status"] = "published"
@node
def review(context):
context.state["status"] = "waiting for review"
decide.link(publish, "ready")
decide.link(review, "needs_review")
release = Flow(decide)
for risk in ("low", "high"):
state = asyncio.run(release.run({"risk": risk}))
print(f"{risk}: {state['status']}")TypeScript
import { Flow, node } from '@jigging/sley'
interface State {
risk: 'low' | 'high'
status?: string
}
const decide = node<State>((context) => {
const action = context.state.risk === 'high' ? 'needs_review' : 'ready'
context.emit(action)
})
const publish = node<State>((context) => {
context.state.status = 'published'
})
const review = node<State>((context) => {
context.state.status = 'waiting for review'
})
decide.link(publish, 'ready')
decide.link(review, 'needs_review')
const release = new Flow(decide)
for (const risk of ['low', 'high'] as const) {
const state = await release.run({ risk })
console.log(`${risk}: ${state.status}`)
}Both programs print:
low: published
high: waiting for reviewThe decision stays inside decide; the allowed outcomes stay in its two links;
the caller gets the final status from run(). No hidden handoff or terminal
lookup is required.
Small by design
- A node is one ordinary synchronous or asynchronous function.
- A link makes one allowed next step visible.
emit()chooses one or more paths.- A Flow waits for those paths and
run()returns their final shared state.
Use Sley when branching and synchronization have made a workflow's shape hard
to see. Keep ordinary calls, conditions, loops, asyncio.gather, or
Promise.all while they still explain the workflow clearly.
Install
pip install sleynpm install @jigging/sleyPython requires version 3.13 or newer. Package and runtime details live in the Python and TypeScript references.
Start learning
The Quickstart takes one file from installation to visible output. The Learn path then evolves that same release workflow from a linear graph through routing, branch data, fan-out, joins, nested boundaries, failure evidence, and advanced graph design.
Sley evolved through PocketFlow and Caskada. The lineage records what changed and which tradeoffs remain intentional.
License
Sley is licensed under the Mozilla Public License 2.0.
