Skip to main content

MindWire for Python

Build products with the same agent runtime used by MindWire's TypeScript and Go SDKs. This initial Python SDK connects to an existing local or remote runtime over HTTP and server-sent events. It includes synchronous and asynchronous clients, turns, streaming, run snapshots, cancellation, interaction responses and conversation handoffs. The low-level request() method exposes the rest of the shared API.

Requires Python 3.10 or newer. Licensed under Apache-2.0.

Install

Once the first release is published:

pip install mindwire

For development from this repository:

python -m pip install -e './packages/python[dev]'

Connect and run

Start or connect to a MindWire runtime and authenticate its agent. Set MINDWIRE_BASE_URL and MINDWIRE_TOKEN in your application environment. A local runtime usually listens on http://127.0.0.1:8790; use its configured bearer token. Use HTTPS for connections across the network.

import os
from mindwire import Mindwire

with Mindwire(
    base_url=os.environ["MINDWIRE_BASE_URL"],
    token=os.environ["MINDWIRE_TOKEN"],
    agent="codex",
) as mw:
    run = mw.turn(
        chat_id="launch",
        message="Read brief.md and write a launch plan.",
        cwd="/workspace/product",  # A directory on the runtime's computer.
    )
    for event in run:
        if event["type"] == "text":
            print(event.get("text", ""), end="", flush=True)
    outcome = run.wait()
    print(outcome["run"]["status"])

run.wait() consumes the stream and checks the final run record. Calling it after iteration replays the stream internally to collect its result. It raises RunFailedError for errors, cancellation, or a stream ending before a terminal status. Pass throw_on_error=False to inspect that outcome yourself.

The Python SDK does not install, launch or provision the runtime in this release. Local, Docker, SSH and cloud environments work when you provide a reachable runtime URL and token. Harness authentication and capability support are owned by the runtime; the SDK does not sign in to an agent on your behalf.

Async applications

import asyncio
import os
from mindwire import AsyncMindwire

async def main():
    async with AsyncMindwire(
        base_url=os.environ["MINDWIRE_BASE_URL"],
        token=os.environ["MINDWIRE_TOKEN"],
        agent="claude-code",
    ) as mw:
        run = await mw.turn(chat_id="research", message="Summarize this project.")
        async for event in run:
            if event["type"] == "text":
                print(event.get("text", ""), end="", flush=True)
        await run.wait()

asyncio.run(main())

Runs and streams

  • mw.turn(...) starts a turn. Supply request_id and retain it when retrying an unacknowledged creation request on runtimes supporting turnRequestVersion.
  • mw.run(run_id) and mw.latest_run(chat_id) reattach to existing work.
  • run.snapshot() reads current output and its cursor; run.stream(after=snapshot["sequence"]) follows newer events on runtimes that advertise cursor support.
  • run.cancel() stops execution. Closing a client or event stream only closes observation; the runtime continues admitted work while it remains running.
  • run.respond({...}) answers a supported interaction using the shared API payload.
  • mw.turn(..., mode="resolve", resolve={"maxIterations": 5}) runs bounded continuation when the selected harness supports it.

To stop reading early, explicitly close the stream using contextlib.closing (sync) or contextlib.aclosing (async). For example:

from contextlib import closing

with closing(run.stream()) as stream:
    for event in stream:
        if event["type"] == "interaction":
            break

Unary requests have a configurable timeout (timeout=120.0, in seconds). SSE streams have no read timeout so an agent can continue working through idle periods. The client does not automatically retry turns or reconnect interrupted streams.

Shared API and handoffs

mw.request(method, path, json=..., params=...) returns the parsed response body. It accepts runtime API paths, not arbitrary URLs. All payloads, response objects, turn options and event fields retain the shared API's camelCase field names. Python method parameters use snake_case.

bots = mw.request("GET", "/bots")
config = mw.request("GET", "/config", params={"agent": "codex"})
preview = mw.preview_handoff("launch")
handoff = mw.handoff("launch", {
    "newChatId": "launch-review",
    "requestId": "launch-review-001",
    "targetAgentId": "saved-claude-profile-id",
    "task": "Review the plan and identify missing steps.",
})
review_run = mw.run(handoff["run"]["id"])

Handoffs require a compatible runtime, an eligible source conversation and a saved destination agent profile. Use preview to inspect the context before submission; see the handoff guide for field semantics.

APIError preserves status, method, path and the server's body. ConnectionError and TimeoutError identify transport failures. All inherit from MindwireError. Errors do not expose the configured bearer token.

Development and releases

cd packages/python
python -m pytest
ruff check src tests
mypy src
python -m build
python -m twine check --strict dist/*

The Python package has its own version, initially 0.1.0. The runtime and TypeScript package keep their existing release cycle. See RELEASING.md for PyPI setup and publishing.

Metadata

Release files for mindwire 0.1.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 mindwire 0.1.0
File Size Uploaded Provenance Actions
mindwire-0.1.0.tar.gz 17.2 kB With provenance Details for mindwire-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 32.1 kB

Release files / mindwire-0.1.0.tar.gz

Download URL mindwire-0.1.0.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1a7d4959541cb66b484a5e21acc658d2f8a9687d12d730fdbad9bc2560e4940c
BLAKE2b-256 checksum
How to use checksums
75a64289039108908bd7c2fe60d2e8be5b5bb4cd868cc81d2cd73189059d6fbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Release files / mindwire-0.1.0-py3-none-any.whl

Download URL mindwire-0.1.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64e75ac620b4f70e296e52db4f28f29e4c122765b7c5fcb75a57b0dfb2a880ee
BLAKE2b-256 checksum
How to use checksums
64f2824c19f91b27d9724be59d73af86a525dd4054fa466649966da48c955ad8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Security for mindwire 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mindwire-0.1.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 Nov 9, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.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