Skip to main content

miraasdk

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

  • 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.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.1.1.tar.gz (52.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.1.1-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

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

Hashes for miraasdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c5e57fcd236833c117daaec7fa83afff6c859211e369ca536f75438beeaeb9bc
MD5 822969c57be92c118024c9fba3bdfe22
BLAKE2b-256 160b91f082596a387ae4f42b14c6cda85a62fd4d01da1d8e8ae59af78fb2b109

See more details on using hashes here.

Provenance

The following attestation bundles were made for miraasdk-0.1.1.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.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

Hashes for miraasdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0bd17221672f99de77f16a7481418ab6872f3a4f91166c97caeb20cf5a7db2f
MD5 11bae6c071a57d0ff2eddfd1b1740000
BLAKE2b-256 e840675904a0196a588d367d985b51ad92e2a08621d010469955e0ec2df6ea33

See more details on using hashes here.

Provenance

The following attestation bundles were made for miraasdk-0.1.1-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

0.2.0

2 files

This release

0.1.1 This release

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