Skip to main content

Python client for a2al: spawn a2ald and call its REST API (health, agents, resolve, fetch, tunnel, …)

Project description

a2al (Python)

Python client for A2AL — decentralized agent networking. Spawns a local a2ald daemon as a sidecar and exposes a typed REST helper covering the full API surface: identity, publish, discover, resolve, fetch, and multiplexed persistent tunnels.

Full API: doc/api-reference.md

Installation

pip install a2al

Pre-built a2ald binaries are bundled inside platform wheels:

Platform Architecture
Linux x86_64, arm64
macOS x86_64, arm64
Windows x86_64

On unsupported platforms, install a2ald manually and set A2ALD_PATH to the executable path.

Quick Start

from a2al import Daemon, Client

with Daemon() as d:
    c = Client(d.api_base, token=d.api_token)

    # 1 — Check daemon health
    print(c.health())

    # 2 — Send an HTTP request to a remote agent (encrypted QUIC, no local port needed)
    result = c.fetch(
        remote_aid,
        method="GET",
        path="/.well-known/agent.json",
    )
    # result = {"status": 200, "headers": {...}, "body": "<base64>", "truncated": False}

    # 3 — Open a persistent tunnel (multiple concurrent TCP connections)
    tunnel = c.tunnel_open(remote_aid)
    local_addr = tunnel["listen"]   # e.g. "127.0.0.1:58320"
    tunnel_id  = tunnel["id"]       # e.g. "tun_abc123"

    # ... connect your application to local_addr ...

    c.tunnel_close(tunnel_id)

Client API

Method REST endpoint Description
health() GET /health Daemon liveness check
resolve(aid) POST /resolve/{aid} Look up a remote agent's endpoints
connect(aid, *, local_aid) POST /connect/{aid} One-shot tunnel — single TCP session, closes automatically
fetch(aid, *, method, path, headers, body_base64, local_aid) POST /fetch/{aid} HTTP request over QUIC; returns {status, headers, body(base64), truncated}
tunnel_open(aid, *, local_aid, idle_timeout_sec) POST /tunnel/{aid} Persistent tunnel — accepts many concurrent connections; returns {id, listen}
tunnel_close(id) DELETE /tunnel/{id} Close a persistent tunnel
tunnel_list() GET /tunnel List active persistent tunnels
tunnel_status(id) GET /tunnel/{id} Status of one tunnel
agents_list() GET /agents List locally registered agents
identity_generate() POST /identity/generate Create a new Ed25519 AID
agent_register(payload) POST /agents Register a generated identity
agent_publish(aid) POST /agents/{aid}/publish Announce agent to the Tangled Network

Daemon Context Manager

Daemon() starts a2ald as a subprocess and stops it when the with block exits.

from a2al import Daemon, Client

# Default: auto-locate a2ald binary, random API port, temp data dir
with Daemon() as d:
    c = Client(d.api_base, token=d.api_token)
    ...

# Custom binary path and extra daemon flags
with Daemon(
    a2ald_exe="/usr/local/bin/a2ald",
    extra_args=["--data-dir", "/var/lib/a2al", "--fallback-host", "1.2.3.4"],
) as d:
    c = Client(d.api_base, token=d.api_token)
    ...

Environment Variables

Variable Description
A2ALD_PATH Override path to the a2ald executable
A2AL_API_TOKEN Bearer token when the daemon enforces authentication

Requirements

  • Python 3.10+
  • No third-party dependencies (standard library only)

Links

License

MPL-2.0

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

a2al-0.2.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distributions

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

a2al-0.2.1-py3-none-win_amd64.whl (12.0 MB view details)

Uploaded Python 3Windows x86-64

a2al-0.2.1-py3-none-manylinux2014_x86_64.whl (5.9 MB view details)

Uploaded Python 3

a2al-0.2.1-py3-none-manylinux2014_aarch64.whl (5.5 MB view details)

Uploaded Python 3

a2al-0.2.1-py3-none-macosx_11_0_x86_64.whl (6.0 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

a2al-0.2.1-py3-none-macosx_11_0_arm64.whl (6.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file a2al-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for a2al-0.2.1.tar.gz
Algorithm Hash digest
SHA256 77881fae7911837e1b1811bc1da577f34587700a5918c4e23e2640794e21c693
MD5 5f2a4c7f9694d0d46a0d3b013d0c5bbb
BLAKE2b-256 d1bc15b5115206059dda71a348310506646089895353479fb5f694b689b3f905

See more details on using hashes here.

File details

Details for the file a2al-0.2.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: a2al-0.2.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 12.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for a2al-0.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c55c4000d23905d5d90a7a66b929f1157fa31316b1c5e0124e4c6a72e63dd9e6
MD5 2428c0718fa9db3f8b7de0a23661694f
BLAKE2b-256 4e90e75927ec412ca54b901e389f46e31ae3a1cb876f33bb6d403fd66d2beeab

See more details on using hashes here.

File details

Details for the file a2al-0.2.1-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for a2al-0.2.1-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e261f3edd74dfe79675aec43d30faea0586dec0dfac611a98545da0ffa32805
MD5 c86a773d8315bc1fffc516147b808584
BLAKE2b-256 6787a93cfed4ecf4440a5e037ae7d22a6b952b8eca37f73757d9fc1c80576c52

See more details on using hashes here.

File details

Details for the file a2al-0.2.1-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for a2al-0.2.1-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1216aa916c04d9daa275b30d7e525a1371ce4c7f659b031da21d93dd8d56daa8
MD5 3c39ebaa53c261b658e1757918d42c30
BLAKE2b-256 dee1e0cefb8f26eb73043c17a1a94132a6fbe5e1dfd51678df88686a25c95fe1

See more details on using hashes here.

File details

Details for the file a2al-0.2.1-py3-none-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: a2al-0.2.1-py3-none-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: Python 3, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for a2al-0.2.1-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 ded422c5a52df33a21acfbe96c5aeeec51becf625202261358c9649f78336129
MD5 eab9a1ee6b7418b1c5f8cb668e53bc4e
BLAKE2b-256 21a85e79eef938d209ed3dd37a62e24a9cf43a95b20e2ad94af791808d433a7e

See more details on using hashes here.

File details

Details for the file a2al-0.2.1-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: a2al-0.2.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for a2al-0.2.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 409cc6ff86c1f8f1644d4c28c9cd367c06ce468a734ad120a67c191a7c5bcfe6
MD5 8836f0ababa573328fc886724f373fb8
BLAKE2b-256 14e154aeff024feca19431088c21cc83c42da34603e48a43cb5678e7aca5d9fb

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