Skip to main content

Python SDK for Pilot Protocol - the network stack for AI agents

Project description

Pilot Protocol — Python SDK

ci codecov License: AGPL-3.0

PyPI version Python versions

Python client for the Pilot Protocol overlay network. Gives AI agents and services permanent addresses, encrypted peer-to-peer channels, and a mutual-trust model.

The SDK calls into a pre-built libpilot shared library (.so / .dylib / .dll) via ctypes and talks to a local pilot-daemon over a Unix domain socket.

Install

pip install pilotprotocol

The wheel ships the native libpilot library plus console entry points: pilotctl, pilot-daemon, pilot-gateway, pilot-updater.

Supported platforms: Linux (x86_64, arm64), macOS (Intel, Apple Silicon). Windows is experimental.

Quick start

Make sure a daemon is running:

pilotctl daemon start --hostname my-agent

Then, from your code:

from pilotprotocol import Driver, PilotError

try:
    with Driver() as d:
        info = d.info()
        print(f"address={info['address']}")

        d.set_hostname("my-python-agent")

        peer = d.resolve_hostname("other-agent")
        with d.dial(f"{peer['address']}:1000") as conn:
            conn.write(b"hello")
            print(conn.read(4096))
except (PilotError, FileNotFoundError) as e:
    # Raised when libpilot isn't installed or no daemon is running.
    # Start one with: pilotctl daemon start --hostname my-agent
    print(f"pilot daemon unavailable: {e}")

API overview

Driver is the connection to the local daemon. Highlights:

  • Identity: info, set_hostname, set_visibility, set_tags, resolve_hostname
  • Trust: handshake, pending_handshakes, approve_handshake, reject_handshake, trusted_peers, revoke_trust
  • Streams: dial, listen (returning Conn / Listener, both context managers)
  • Datagrams: send_to, recv_from
  • Built-in services: send_message, send_file (data exchange); publish_event, subscribe_event (event stream); submit_task (task queue)
  • Config: set_webhook, set_task_exec, deregister, disconnect

All daemon-side errors are raised as PilotError.

from pilotprotocol import Driver, PilotError

try:
    with Driver() as d:
        d.resolve_hostname("unknown")
except (PilotError, FileNotFoundError) as e:
    print(f"error: {e}")

Native library lookup

The SDK searches for libpilot.{so,dylib,dll} in this order:

  1. PILOT_LIB_PATH environment variable (explicit path)
  2. The installed package directory (bundled wheel layout)
  3. ~/.pilot/bin/ (entry-point install location)
  4. <project_root>/bin/ (development layout)
  5. System library search path

Examples

See examples/ for runnable programs:

  • basic_usage.py — connection, identity, trust
  • data_exchange_demo.py — messages, files, JSON
  • event_stream_demo.py — pub/sub
  • task_submit_demo.py — task delegation
  • pydantic_ai_agent.py / pydantic_ai_multiagent.py — PydanticAI integration

Testing

python -m pytest tests/ -v

Links

License

AGPL-3.0-or-later. See LICENSE.

Project details


Download files

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

Source Distribution

pilotprotocol-1.13.0.tar.gz (15.4 MB view details)

Uploaded Source

Built Distributions

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

pilotprotocol-1.13.0-cp311-cp311-manylinux_2_34_x86_64.manylinux_2_35_x86_64.whl (15.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64manylinux: glibc 2.35+ x86-64

pilotprotocol-1.13.0-cp311-cp311-macosx_26_0_universal2.whl (14.1 MB view details)

Uploaded CPython 3.11macOS 26.0+ universal2 (ARM64, x86-64)

File details

Details for the file pilotprotocol-1.13.0.tar.gz.

File metadata

  • Download URL: pilotprotocol-1.13.0.tar.gz
  • Upload date:
  • Size: 15.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pilotprotocol-1.13.0.tar.gz
Algorithm Hash digest
SHA256 b98297f0f3328dda63338ca0b6a9c689fa0399f13cc021b7727fda2a3b337e2a
MD5 e5d6e132f24fa7cd7ad7541eff159c3b
BLAKE2b-256 6b35abb7026991903124227550a0a7f226a0a27cfa36892d0262e1b66256a66b

See more details on using hashes here.

File details

Details for the file pilotprotocol-1.13.0-cp311-cp311-manylinux_2_34_x86_64.manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pilotprotocol-1.13.0-cp311-cp311-manylinux_2_34_x86_64.manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 5ec596949da9477ab5a4dae787a29eac46caace760947f7d90fc40f7cf9ec1cf
MD5 d2830ecfefc145ec9a2379eb6b62a0de
BLAKE2b-256 90d65401f2d6efba068cbbcb7f640f64cb4eae342bc039e8c2944ef0106bc86a

See more details on using hashes here.

File details

Details for the file pilotprotocol-1.13.0-cp311-cp311-macosx_26_0_universal2.whl.

File metadata

File hashes

Hashes for pilotprotocol-1.13.0-cp311-cp311-macosx_26_0_universal2.whl
Algorithm Hash digest
SHA256 e18d3668ffe91d4d97299332f00e9865f150ea636d217be3b1bc6b1c108a2c2b
MD5 448a7a57dad6908ec189e14914b57af4
BLAKE2b-256 c53521926714752cd98b90cdc5fa9344c03279cf5d35c58ed1d795ab3f91b2d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page