meadows-client
Client-side Socket.IO transport for MEADOWS: connect, reconnect, JWT handshake. No domain logic — shared by
meadows-botand future non-browser clients.
What this package contains
client.py—MeadowClientwrappingsocketio.AsyncClient- JWT handshake on
/chatnamespace connect - Auto-reconnect (delegated to socketio)
send_message()constructs a valid protocolMessagebefore emittingon(event, handler)for user-registered handlersemit(event, data)escape hatch for non-message eventsregister_label_subscription()/unregister_label_subscription()for label routingon_label_assigned()callback registration for subscription matchescall_rpc()— async RPC via labels (send request, await response)
- JWT handshake on
Install
cd meadows-client
uv pip install -e .
Test
uv run pytest -q
Usage
Pre-signed JWT (recommended)
from meadows.client import MeadowClient
from meadows.protocol import EventName, JWTRole, build_claims
client = MeadowClient(
server_url="http://localhost:8080",
claims=build_claims(name="alice", role=JWTRole.USER),
token="<pre-signed-jwt>",
)
client.on(EventName.MESSAGE, lambda data: print("got:", data))
await client.connect()
await client.send_message(content="hello world", group_id="general")
Generate a token with inv user-jwt or inv bot-jwt on the server.
Raw signing key (local dev / TUI only)
client = MeadowClient(
server_url="http://localhost:8080",
claims=build_claims(name="alice", role=JWTRole.USER),
jwt_secret=b"<shared key bytes>",
)
Protocol contract
This client never sends a frame that violates meadows.protocol. The
send_message() method constructs a valid Message envelope before
emitting, so the server-side chokepoint never sees an invalid frame from us.
Label subscriptions
# Subscribe to labels matching a JSON Logic predicate
client.register_label_subscription(
"sentiment-alerts",
{"regex_match": [{"var": "label"}, "^sentiment$"]},
scope="global",
deliver="label_only",
)
# Handle matched labels
client.on_label_assigned("sentiment-alerts")(lambda data: print(data))
Subscriptions are replayed on reconnect.
RPC via labels
# Send an RPC request and await the response (async)
result = await client.call_rpc("service:math", "add 2 3", origin="bot-math-svc")
call_rpc creates an RPC_REQUEST message, routes it via label subscriptions, and resolves when the matching RPC_RESPONSE arrives. Raises asyncio.TimeoutError on timeout.
API
async def call_rpc(
self,
service_label: str, # Label to route to (e.g. "service:math")
content: str, # Request payload
*,
origin: str | None = None, # Label origin (defaults to caller identity)
semver: str = "1.0.0", # Label semver
timeout: float = 30.0, # Seconds before TimeoutError
group_id: str = "general", # Group for persistence
) -> str # Response content
Metadata
Release files for meadows-client 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| meadows_client-0.1.0.tar.gz | 88.7 kB | Without provenance | Details for meadows_client-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| meadows_client-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for meadows_client-0.1.0-py3-none-any.whl |
Total release size: 97.2 kB
Release files / meadows_client-0.1.0.tar.gz
| Download URL | meadows_client-0.1.0.tar.gz |
|---|---|
| Size | 88.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a72f119ed1ce66f70958173ad4c05c05be3792c19a6248ca621b1012b1f62a4
|
|
BLAKE2b-256 checksum How to use checksums |
fb217af0fa7a256f0939a5fdefa4b2b93d1e9c14fef8196fb885cea545bb6ca1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / meadows_client-0.1.0-py3-none-any.whl
| Download URL | meadows_client-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9eb90d9ca09caf5925f4c87f2bf5f3c412978bbd32593ec75c7b75c9b75d794
|
|
BLAKE2b-256 checksum How to use checksums |
2ed7563ca02d83feb5f69272d7120e7cf42b309299b5d751f957e0d35b7d49c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for meadows-client 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.