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.7.tar.gz (22.2 kB 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.7-py3-none-manylinux_2_34_x86_64.manylinux_2_35_x86_64.whl (22.9 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64manylinux: glibc 2.35+ x86-64

pilotprotocol-1.13.7-py3-none-manylinux_2_34_aarch64.manylinux_2_35_aarch64.whl (20.7 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64manylinux: glibc 2.35+ ARM64

pilotprotocol-1.13.7-py3-none-macosx_11_0_x86_64.whl (23.5 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

pilotprotocol-1.13.7-py3-none-macosx_11_0_arm64.whl (21.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pilotprotocol-1.13.7.tar.gz
Algorithm Hash digest
SHA256 06effe6423d89607a493d1a10846e8ad71307a37e59f04c9a4f9028e4ca0162a
MD5 16821e0772f6e752a05535e62d379df2
BLAKE2b-256 23dec21dde3cd5dc23cbb830651bb9c217736db6b3e604b079a076320fd305db

See more details on using hashes here.

File details

Details for the file pilotprotocol-1.13.7-py3-none-manylinux_2_34_x86_64.manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pilotprotocol-1.13.7-py3-none-manylinux_2_34_x86_64.manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 6cc3c8477c37f0e995edfa3b2afe23a6a282be507b7cf59f2bc4855d1bbd281f
MD5 064f56813270a125347fc2f8f4fd4734
BLAKE2b-256 f7ea3dbdf7c7fe4816d8d7e14fe7f53200789cb87160a8a328654703683728ed

See more details on using hashes here.

File details

Details for the file pilotprotocol-1.13.7-py3-none-manylinux_2_34_aarch64.manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for pilotprotocol-1.13.7-py3-none-manylinux_2_34_aarch64.manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 b4c556d2fb804f41061b578894226db6e17f191359e05f866cff4d827082cb8f
MD5 13dc4a3d891fcf0693e421092d34cdcc
BLAKE2b-256 98e07813d3e7bfb5fe2231d4d167f976b467211421b5a71883d3284876c00a37

See more details on using hashes here.

File details

Details for the file pilotprotocol-1.13.7-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for pilotprotocol-1.13.7-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f79f861eb64178b8a0503ae863fd9cfe061b0fbfc49a5bbf49d556c1b93a9d65
MD5 3cd61ff8f39562b2c9ad86a28e7897f0
BLAKE2b-256 e184fb41dc2535a51d9a28692fdb64dd0881ecceeeec6f41cbe9f9f1dbbc85aa

See more details on using hashes here.

File details

Details for the file pilotprotocol-1.13.7-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pilotprotocol-1.13.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18d70fc0f0cfdf05821f69ecf728f583252ac3fa5fd7352d10c356f24bbc59c0
MD5 4e76370b949982250b78595019ac315f
BLAKE2b-256 0caa3884631d49ca2e6080c3b8699720d79c30588918997778ef43d34c8542f9

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