miraasdk
Client SDK for agent processes in the Mira ecosystem (MiraRun/MiraGen). Ships two deliberately separated faces (see docs/architecture.md for why they must never share a process):
miraasdk.telemetry— run-scoped OTLP telemetry export, correlated with the run/routine/agent identity a Mira-orchestrated process already has. For embedding in any ordinary service.miraasdk.driver— a standalone, privileged, read-only infrastructure observer: bounded Docker discovery (list/inspect/logs/stats), host metrics with OpenTelemetry semantic-convention names, poll-based container death/OOM detection with post-mortem log tails, and a report loop (mira-driver) that publishes to MiraRun's reported-target endpoint (ADR-022) and/or movingfirm-admin's infra collector.
Install
pip install miraasdk # telemetry only
pip install 'miraasdk[driver]' # + the driver toolkit (httpx)
Quickstart
from miraasdk import MiraTelemetry
telemetry = MiraTelemetry(
endpoint="https://mira.example/otlp/v1/traces",
run_id=run_id,
routine_id=routine_id,
routine_revision_id=routine_revision_id,
agent_id=agent_id,
token=run_credential, # same run-scoped credential used for MCP auth
)
with telemetry.span("resource.query", **{"mira.resource.uri": target_uri}):
... # do the thing; exceptions are recorded on the span and re-raised
telemetry.shutdown() # once, at process exit
The driver as a process
MIRA_DRIVER_TARGET_REFERENCE=vps1 \
MIRA_DRIVER_ADMIN_COLLECTOR_URL=http://10.8.0.4:6767/api/ops/infra/collector \
MIRA_DRIVER_ADMIN_COLLECTOR_TOKEN=... \
mira-driver
Configuration is env vars only, documented in miraasdk/driver/process.py. The reference deployment — a read-only Docker socket proxy plus the driver, as one Compose stack — lives in deploy/; the production runbook for registering it as a Portainer git-backed stack is docs/deployment.md. As designed, the socket proxy is the single privileged component, and it doubles as MiraRun's direct-pull endpoint on WireGuard-reachable hosts. As a library, the same pieces compose explicitly: DriverRunner(DockerDriver(...), [MirarunReportSink(...), AdminCollectorSink(...)], ...).
Design
- Non-blocking by construction. Spans are queued and exported on a background thread (
BatchSpanProcessor); this module never wires a synchronous exporter. A telemetry backend being down must not fail or stall the operation that emitted the span. - Identity set once.
run_id/agent_id/routine_id/routine_revision_id/service.*/deployment.environmentare OTel resource attributes — set once at construction, present on every span this instance emits. Attaching them per-span instead is the mistake that breaks filtering and aggregation once there's a real backend behind the endpoint. - OTLP, not a vendor SDK.
endpointis a plain OTLP/HTTP traces endpoint. This package has no opinion on what's behind it — an OTel Collector, a vendor backend, or a bare receiver during development. export_statsfor observability, not a promise of completeness. It counts export batches that reached the exporter and failed — the actionable half of "did my telemetry get out." Queue-overflow drops (a producer outpacing the export thread) are logged by OpenTelemetry's ownopentelemetry.sdk.trace.exportlogger, not duplicated here.
Development
pip install -e ".[dev]"
pytest
Releasing
Publishing to PyPI happens on GitHub Release (Trusted Publishing / OIDC — no token stored in this repo). Bump version in pyproject.toml, merge, then cut a GitHub Release; .github/workflows/release.yml builds and publishes.
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 miraasdk-0.1.1.tar.gz.
File metadata
- Download URL: miraasdk-0.1.1.tar.gz
- Upload date:
- Size: 52.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5e57fcd236833c117daaec7fa83afff6c859211e369ca536f75438beeaeb9bc
|
|
| MD5 |
822969c57be92c118024c9fba3bdfe22
|
|
| BLAKE2b-256 |
160b91f082596a387ae4f42b14c6cda85a62fd4d01da1d8e8ae59af78fb2b109
|
Provenance
The following attestation bundles were made for miraasdk-0.1.1.tar.gz:
Publisher:
release.yml on ieepirzy/mira-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miraasdk-0.1.1.tar.gz -
Subject digest:
c5e57fcd236833c117daaec7fa83afff6c859211e369ca536f75438beeaeb9bc - Sigstore transparency entry: 2486068739
- Sigstore integration time:
-
Permalink:
ieepirzy/mira-sdk@f13d2758309f026557b2976c6a51979a42cb9b35 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ieepirzy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f13d2758309f026557b2976c6a51979a42cb9b35 -
Trigger Event:
release
-
Statement type:
File details
Details for the file miraasdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: miraasdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 35.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0bd17221672f99de77f16a7481418ab6872f3a4f91166c97caeb20cf5a7db2f
|
|
| MD5 |
11bae6c071a57d0ff2eddfd1b1740000
|
|
| BLAKE2b-256 |
e840675904a0196a588d367d985b51ad92e2a08621d010469955e0ec2df6ea33
|
Provenance
The following attestation bundles were made for miraasdk-0.1.1-py3-none-any.whl:
Publisher:
release.yml on ieepirzy/mira-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miraasdk-0.1.1-py3-none-any.whl -
Subject digest:
b0bd17221672f99de77f16a7481418ab6872f3a4f91166c97caeb20cf5a7db2f - Sigstore transparency entry: 2486068893
- Sigstore integration time:
-
Permalink:
ieepirzy/mira-sdk@f13d2758309f026557b2976c6a51979a42cb9b35 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ieepirzy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f13d2758309f026557b2976c6a51979a42cb9b35 -
Trigger Event:
release
-
Statement type: