Typed control-plane message contracts: RequestEnvelope, ResponseEnvelope, EventEnvelope
Project description
nodus-protocol
Typed control-plane message contracts for Nodus AI systems.
Defines the wire format for request/response/event envelopes exchanged
between Nodus components (gateway, agents, channels). JSON codec with a
_type discriminator for safe deserialization. No required external
dependencies — pure stdlib.
Status: v0.1.0 — prepared, not yet published.
Install
pip install nodus-protocol
What it provides
| Component | Purpose |
|---|---|
RequestEnvelope |
Inbound request: id, method, params |
ResponseEnvelope |
Response: id, ok, result or error |
EventEnvelope |
Server-pushed event: event_type, payload, timestamp |
encode(envelope) |
Serialize to JSON string with _type discriminator |
decode(raw) |
Deserialize JSON string to typed envelope |
PROTOCOL_VERSION |
Current version string ("1.0") |
is_compatible(v) |
Check interoperability with another version |
Quick start
from nodus_protocol import RequestEnvelope, ResponseEnvelope, encode, decode
req = RequestEnvelope(id="req-001", method="agent.run", params={"objective": "hello"})
wire = encode(req)
# '{"_type": "request", "id": "req-001", "method": "agent.run", ...}'
decoded = decode(wire)
assert isinstance(decoded, RequestEnvelope)
assert decoded.method == "agent.run"
resp = ResponseEnvelope(id="req-001", ok=True, result={"run_id": "run-abc"})
Envelopes
RequestEnvelope — id (str), method (str), params (dict | None)
ResponseEnvelope — id (str), ok (bool), result (any | None), error (str | None)
EventEnvelope — event_type (str), payload (dict | None), timestamp (float, auto-set UTC epoch)
Codec
from nodus_protocol import encode, decode
wire = encode(envelope) # JSON str with "_type" discriminator
envelope = decode(wire) # RequestEnvelope | ResponseEnvelope | EventEnvelope
decode routes on _type. Raises ValueError on unknown type or malformed JSON.
Versioning
from nodus_protocol import PROTOCOL_VERSION, is_compatible
print(PROTOCOL_VERSION) # "1.0"
is_compatible("1.0") # True
is_compatible("1.1") # True (minor compatible)
is_compatible("2.0") # False (major mismatch)
Design
- No required dependencies. Pure stdlib (
json,dataclasses,datetime). _typediscriminator. Every encoded envelope includes_typesodecodecan reconstruct the correct class without out-of-band schema info.
Development
pip install -e ".[dev]"
pytest tests/ -q
License
MIT — see LICENSE.
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 nodus_protocol-0.1.0.tar.gz.
File metadata
- Download URL: nodus_protocol-0.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acceffa3f156785dc9f4f20a2ee54e52814245bf769323918c853c026132206e
|
|
| MD5 |
2baad3cdbe3fa4e23b991e1038660bbd
|
|
| BLAKE2b-256 |
9c30b2f3e1c3f0cbc3e6050b5a0079ee725c427a106150c84132a25c6f732d3b
|
File details
Details for the file nodus_protocol-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nodus_protocol-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f9a2b3f42b36413086c872dc8405b6fb37479b37b6e3ce3d2f01e0b771e2172
|
|
| MD5 |
cc23ed3ff017b3e392932bf57d7c1b0b
|
|
| BLAKE2b-256 |
39c965499db8c1254c420e57a4a4c9a88f7040ec2bdba86a70ef9434824dcdce
|