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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3

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

Uploaded Python 3

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

Uploaded Python 3macOS 11.0+ x86-64

a2al-0.2.2-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.2.tar.gz.

File metadata

  • Download URL: a2al-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 f97dd4a4b28f13db91cb8d06c369c6f6f915f90d798763b4d2b9e426bcc645a6
MD5 5dc8104a5ae2eb98f427f115fb39b248
BLAKE2b-256 e0221e93a1397f941fa702894c1cb376ab77e0e9e72afa42c88d3993e26d9b1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.2-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.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c8116d66c9aaa58f9455a9e45eaeee62c29746c86d6a9d1ea347e5bb4d14355b
MD5 0cb4800aa608e6cc9285c324a6b74ea9
BLAKE2b-256 c43e35e5025e4cd7da769464b5fb1874723e1b6b3a9562dbfa598e6162475633

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2al-0.2.2-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87e082bc4568fbd4f6146c7a03a9f442643b6565a45ac26760b7e709b0dd2d77
MD5 7be24f2ad9c22f0272adba9b72b5ecb6
BLAKE2b-256 baf62ac689124336e0108d915897811204d9c1180934b42564a68f289455456a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2al-0.2.2-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ea648d10440936eb9f2f23af63fef29dc899aa17903ea83bac4a5edb2bac48ac
MD5 8900defeacd2c541af3bb7753ecc5ff2
BLAKE2b-256 501b71a353437c7f9a38aeda5f216001531193ba78e7df86d59b27e4b422c940

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.2-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.2-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 9935c1c57f0217731c896bc1f7b444c05877439aaf39f3c56eef9f0f484dd82d
MD5 87742085c7b412774e4c153a5d27905a
BLAKE2b-256 48be84510745f953f476dcf7d7a96637c6cbcf2c157e5d922b59fd3ef5615356

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.2-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.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db42da8142eac0561a4df0beb887f1e9c701e5076f374f1652b8e2d64602b115
MD5 99eda337002bd3863dc52519aadca1cd
BLAKE2b-256 21d67d002323841c67bcc12632d8679c5e86798a811efd67f6ba820b6bc112ec

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