SSE adapter for Muscles streaming events
Project description
Muscles SSE
Server-Sent Events adapter for Muscles streaming use cases.
This package should provide progress, logs, notifications, and AI output streams over SSE while keeping the underlying workflow in the Muscles application model.
Related Repositories
muscles- coreStreamResult,StreamEvent, actions and dispatcher.muscles-asgi- HTTP runtime that can expose SSE responses.muscles-ai- AI/RAG actions that may produce streaming output.muscles-jsonrpc- sibling protocol projection over actions.muscles-benchmarks- streaming regression checks.
Concept Guardrails
- SSE streams must be backed by Muscles actions/events/jobs, not ad hoc handlers.
- The adapter must preserve shared rules/security and request context.
- Stream events must have typed names and payload schemas.
- SSE should be the simple default for one-way streaming before WebSocket is introduced.
- The package must be usable from ASGI without forcing unrelated runtime choices.
Current Stage (Issue #1)
Implemented SSE transport projection over Muscles action execution:
- action dispatch path:
dispatcher.execute(action, payload, transport="sse"); - application facade:
SseAdapter.from_application(app)backed by coreActionDispatcher; - stream normalization delegates to core
stream_events()/StreamResult; - typed events:
progress,log,result,error; - wire formatting:
id,event,retry,data; SseResponsewith SSE headers and status;- configurable interval heartbeat with bounded backpressure;
- safe source close on stream completion/disconnect;
- structured core action error mapping: not found, validation, permission, execution.
This keeps SSE as a thin delivery layer. Business logic stays in Muscles actions.
Interval heartbeat
SSE serializes core StreamEvent items from StreamResult. Business events
come from muscles.core; this package owns the SSE wire format and transport
heartbeat, backpressure, and disconnect behavior.
adapter = SseAdapter(
dispatcher,
heartbeat_event="heartbeat",
heartbeat_interval_seconds=15,
)
When the action stream is quiet longer than the configured interval, the transport emits a heartbeat event:
event: heartbeat
data: {"ok": true}
User events keep their existing SSE format. Closing the response stream stops
the heartbeat worker and closes the underlying source when it supports
close(). Backpressure is preserved with a bounded one-item queue. Long-
blocking sources should implement a cooperative close() that unblocks the
active next() call.
Run tests
python -m pytest -q
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file muscles_sse-1.0.2.tar.gz.
File metadata
- Download URL: muscles_sse-1.0.2.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fba5078ead80aca89826bc9c0093a53cccb76b0aaf80d6220b1e1aead7eeb359
|
|
| MD5 |
d46b4849571a241d93239c99d1fd025e
|
|
| BLAKE2b-256 |
0cb4d53c1f74e8fa43f122cbd321eb08663d5862d8b0d139c600845754fa51e7
|
Provenance
The following attestation bundles were made for muscles_sse-1.0.2.tar.gz:
Publisher:
release.yml on butkoden/muscles-sse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muscles_sse-1.0.2.tar.gz -
Subject digest:
fba5078ead80aca89826bc9c0093a53cccb76b0aaf80d6220b1e1aead7eeb359 - Sigstore transparency entry: 2261501547
- Sigstore integration time:
-
Permalink:
butkoden/muscles-sse@fc803eaaf30da2051d462d9e5fbed5e425d7a43c -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/butkoden
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fc803eaaf30da2051d462d9e5fbed5e425d7a43c -
Trigger Event:
release
-
Statement type:
File details
Details for the file muscles_sse-1.0.2-py3-none-any.whl.
File metadata
- Download URL: muscles_sse-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce7771a22d8f30a7eedb45245514853c3d01e26da8f3635186cb6a64c2d5c669
|
|
| MD5 |
e276631cad8cb468c5ed2acb78172df4
|
|
| BLAKE2b-256 |
47db78938a225079e40dfbe38d0f8d6df22897c74a0be3589a8086ce2a951e51
|
Provenance
The following attestation bundles were made for muscles_sse-1.0.2-py3-none-any.whl:
Publisher:
release.yml on butkoden/muscles-sse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muscles_sse-1.0.2-py3-none-any.whl -
Subject digest:
ce7771a22d8f30a7eedb45245514853c3d01e26da8f3635186cb6a64c2d5c669 - Sigstore transparency entry: 2261501584
- Sigstore integration time:
-
Permalink:
butkoden/muscles-sse@fc803eaaf30da2051d462d9e5fbed5e425d7a43c -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/butkoden
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fc803eaaf30da2051d462d9e5fbed5e425d7a43c -
Trigger Event:
release
-
Statement type: