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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

miraasdk-0.2.0.tar.gz (48.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

miraasdk-0.2.0-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file miraasdk-0.2.0.tar.gz.

File metadata

  • Download URL: miraasdk-0.2.0.tar.gz
  • Upload date:
  • Size: 48.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for miraasdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 83cab2b6a8abd53b13ff5aba22e4fa76cac8f4db1ac8935050ab72be78282193
MD5 4c5e94524f20f006fc4a67f2cb3fc0bc
BLAKE2b-256 9856ffeb2b98ab5b87540a14e7d18370c7454d50c44f4b55b73f0e9cb5034bf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for miraasdk-0.2.0.tar.gz:

Publisher: release.yml on ieepirzy/mira-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file miraasdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: miraasdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for miraasdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0f201219bd9b51ae11bdc3d13bb1dcc29833fc6fa0009dbb2e7a5897a23953e
MD5 fb5260e00becf4eb85f1e8f635bc0ec1
BLAKE2b-256 351e2ac4eb9c7ef8ad35d5e84c8dc128ff40007e57b01f3255b0fa27220a19f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for miraasdk-0.2.0-py3-none-any.whl:

Publisher: release.yml on ieepirzy/mira-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.1

2 files

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