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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3

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

Uploaded Python 3

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

Uploaded Python 3macOS 11.0+ x86-64

a2al-0.2.4-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.4.tar.gz.

File metadata

  • Download URL: a2al-0.2.4.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.4.tar.gz
Algorithm Hash digest
SHA256 df3a907ccb6fc00235c3efc56f56c52c2c756c265832be10a84127e535414f38
MD5 5abd9221b1953103d3b34343ea69d602
BLAKE2b-256 9c2b12f5ef7046db5327a8c2eb383de3346067f5bd82f67d1ad026cd989ded9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.4-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.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 efc2100478e8ac0b437676dfc1fdd99a5980e2f2d592cb786a03dbd2dc5aae88
MD5 84fa54ecdf646cca1a22476b418458e5
BLAKE2b-256 b233c43cdcd847906fbf4f770bbe42474bb0c2e28e639f4bdf92dfc3d7ab97ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2al-0.2.4-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe2e83f137bf26cd30c523059eafa07ff0c511ee5364ff5ec60c0bee59523bbf
MD5 426ba52cb65e3ad9e8f2f22d6689abdd
BLAKE2b-256 bd2305a0d4ff879121f51e638bdfc379570715c497be64fbc85cab7ccb76626e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for a2al-0.2.4-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 84906c8146abd6a9024f3c562755682f6dae92eb31a292936e4c1ae671667a31
MD5 905653dc1f6cc602ee008cb918911e63
BLAKE2b-256 dc3cae98e220be039fb2986990a51fb89f3ab272855b5361da6e9fac2ab55239

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.4-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.4-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 0875153d84544380b770c8d0c3286b5ec312e1453395c1daf28e5cfa004bb010
MD5 302cba189a19f2433e235ff18f6be9e6
BLAKE2b-256 fbb89bff605b3409db64a4f5d0eaea18dd31cf24962a3083ea01294176ee6300

See more details on using hashes here.

File details

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

File metadata

  • Download URL: a2al-0.2.4-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.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1ec58e8bd517f0ba9cae6b1b5092158a52fcd874d604d7d39d09c7968ddd9111
MD5 0858f3675f62ccd2daed96352023c26e
BLAKE2b-256 cf462d7cace725bc41772cc430876e77795e636c50a5937e4b186dfe081f6091

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