Skip to main content

mira-sdk

CI PyPI version Python versions

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):

  • mira_sdk.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.
  • mira_sdk.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 mira-sdk            # telemetry only
pip install 'mira-sdk[driver]'  # + the driver toolkit (httpx)

Quickstart

from mira_sdk 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 mira_sdk/driver/process.py. The reference deployment — a read-only Docker socket proxy plus the driver, as one Compose stack — lives in deploy/; 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.environment are 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. endpoint is 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_stats for 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 own opentelemetry.sdk.trace.export logger, 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.

Metadata

Release files for miraasdk 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miraasdk 0.2.0
File Size Uploaded Provenance
miraasdk-0.2.0.tar.gz 48.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for miraasdk 0.2.0
File Interpreter ABI Platform
miraasdk-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 83.5 kB

Release files / miraasdk-0.2.0.tar.gz

Download URL miraasdk-0.2.0.tar.gz
Size 48.8 kB
Tags Source
SHA-256 checksum
How to use checksums
83cab2b6a8abd53b13ff5aba22e4fa76cac8f4db1ac8935050ab72be78282193
BLAKE2b-256 checksum
How to use checksums
9856ffeb2b98ab5b87540a14e7d18370c7454d50c44f4b55b73f0e9cb5034bf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / miraasdk-0.2.0-py3-none-any.whl

Download URL miraasdk-0.2.0-py3-none-any.whl
Size 34.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0f201219bd9b51ae11bdc3d13bb1dcc29833fc6fa0009dbb2e7a5897a23953e
BLAKE2b-256 checksum
How to use checksums
351e2ac4eb9c7ef8ad35d5e84c8dc128ff40007e57b01f3255b0fa27220a19f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Security for miraasdk 0.2.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for miraasdk-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page