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.5.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.5-py3-none-win_amd64.whl (11.7 MB view details)

Uploaded Python 3Windows x86-64

a2al-0.2.5-py3-none-manylinux2014_x86_64.whl (6.0 MB view details)

Uploaded Python 3

a2al-0.2.5-py3-none-manylinux2014_aarch64.whl (5.6 MB view details)

Uploaded Python 3

a2al-0.2.5-py3-none-macosx_11_0_x86_64.whl (5.6 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

a2al-0.2.5-py3-none-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: a2al-0.2.5.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.5.tar.gz
Algorithm Hash digest
SHA256 af42129717854ec789afe55668eff0e5188ecd6cb53dadbce53db9fe4bbc1d2c
MD5 53712a34e04ed1c7289ea20f61e01375
BLAKE2b-256 1694f1dc74f303b1f19bd8e8aa9fb2e3b4b5b99c30397a8c1447e529e22f6bc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.5-py3-none-win_amd64.whl
  • Upload date:
  • Size: 11.7 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.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9d08b0b35cd63d631e63b4fd45b1d21a0b7e6971926dd5db533614b7cc03efab
MD5 6b5374eb0f07afd1d4453e7b88da6773
BLAKE2b-256 a28a29d7b5a515907039176281dd61c80ce7981eb043fdce0cfceb23b8da5319

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2al-0.2.5-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3230010110fe99a7fb9274b6d0cd31f7295d842a6c3bb9c1eb2d1c26c941ef3c
MD5 ad392d330f60b2b0edeca9d82f15bf01
BLAKE2b-256 65a0bebd166535519f75211271ea48f75c96beea64910602103a3d3f9250864a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2al-0.2.5-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 67c0c84c37d4cb44a5beeab9ea60bb94b8bdf497fcc781eeffe3ce00b4c6bda5
MD5 c81981d76a7bb1cb78adcc175d7c4b35
BLAKE2b-256 713cb8dd567af0cfd4b6b2824e5b65d1f6c5980fee9c2a68799e6e9fa9ea459a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.5-py3-none-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 5.6 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.5-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f7dfa326b7383822ddf44e18fc1e3fb47426e917e276fceba9bb8e5b82dfff18
MD5 b783438d5c9e395c03a35e8fc9d2189d
BLAKE2b-256 229830f6d4431ccf22b20db776b8b0e10128a8b92511ac8581d60efd46242236

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.5-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 5.6 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.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d5bfd6a43f47a46355d6ea16e2b6669fde42492712052f19e15ca72735f93e28
MD5 8b63fb1c409b35ce241a3f1fa734ddce
BLAKE2b-256 125b2e0feb9e703a824887a81f7f35d4b695406a237a9ee579410b4ca30e1442

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