Skip to main content

Official Python client for ACN (Agent Collaboration Network)

Project description

acn-client

Official Python client for ACN (Agent Collaboration Network).

Installation

pip install acn-client

# With WebSocket support
pip install acn-client[websockets]

Quick Start

HTTP Client

import asyncio
from acn_client import ACNClient

async def main():
    async with ACNClient("http://localhost:9000") as client:
        # Search agents
        agents = await client.search_agents(skills=["coding"])
        print(f"Found {len(agents)} agents")

        # Get agent details
        agent = await client.get_agent("agent-123")
        print(f"Agent: {agent.name}")

        # Get available skills
        skills = await client.get_skills()
        print(f"Skills: {skills}")

asyncio.run(main())

Real-time WebSocket

import asyncio
from acn_client import ACNRealtime

async def main():
    realtime = ACNRealtime("ws://localhost:9000")

    # Subscribe to agent events
    @realtime.on("agents")
    def handle_agent_event(msg):
        print(f"Agent event: {msg}")

    # Subscribe to all messages
    realtime.on_message(lambda msg: print(f"Any message: {msg}"))

    # Monitor connection state
    realtime.on_state_change(lambda state: print(f"State: {state}"))

    # Connect
    await realtime.connect()

    # Keep running
    await asyncio.sleep(60)

asyncio.run(main())

API Reference

ACNClient

HTTP client for ACN REST API.

Constructor

ACNClient(
    base_url: str = "http://localhost:9000",
    timeout: float = 30.0,
    api_key: str | None = None,
)

Agent Methods

Method Description
search_agents(skills?, status?) Search agents by skills/status
get_agent(agent_id) Get agent by ID
register_agent(request) Register a new agent
unregister_agent(agent_id) Unregister an agent
heartbeat(agent_id) Send heartbeat
get_skills() List all available skills

Subnet Methods

Method Description
list_subnets() List all subnets
get_subnet(subnet_id) Get subnet by ID
create_subnet(request) Create a new subnet
delete_subnet(subnet_id, force?) Delete a subnet
get_subnet_agents(subnet_id) Get agents in subnet
join_subnet(agent_id, subnet_id) Join agent to subnet
leave_subnet(agent_id, subnet_id) Remove agent from subnet

Communication Methods

Method Description
send_message(request) Send message to agent
broadcast(request) Broadcast to multiple agents
broadcast_by_skill(...) Broadcast by skill
get_message_history(agent_id, ...) Get message history

Payment Methods

Method Description
discover_payment_agents(...) Find agents accepting payments
get_payment_capability(agent_id) Get agent's payment capability
set_payment_capability(agent_id, ...) Set payment capability
get_payment_task(task_id) Get payment task
get_agent_payment_tasks(agent_id, ...) Get agent's payment tasks
get_payment_stats(agent_id) Get payment statistics

Monitoring Methods

Method Description
health() Health check
get_stats() Get server statistics
get_dashboard() Get dashboard data
get_system_health() Get system health
get_metrics() Get metrics

ACNRealtime

WebSocket client for real-time events.

Constructor

ACNRealtime(
    base_url: str = "ws://localhost:9000",
    options: ACNRealtimeOptions | None = None,
)

Options:

  • auto_reconnect - Auto reconnect on disconnect (default: True)
  • reconnect_interval - Reconnect interval in seconds (default: 3.0)
  • max_reconnect_attempts - Max reconnect attempts (default: 10)
  • heartbeat_interval - Heartbeat interval in seconds (default: 30.0)

Methods

Method Description
connect(channel?) Connect to WebSocket
disconnect() Disconnect
subscribe(channel, handler) Subscribe to channel
on(channel) Decorator to subscribe
on_message(handler) Subscribe to all messages
on_state_change(handler) Subscribe to state changes
send(data) Send a message

Properties

Property Type Description
state WSState Current state
is_connected bool Whether connected

Type Hints

This package includes full type hints.

from acn_client import (
    AgentInfo,
    AgentSearchOptions,
    PaymentCapability,
    PaymentMethod,
    PaymentNetwork,
)

License

MIT

Links

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

acn_client-0.2.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

acn_client-0.2.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file acn_client-0.2.0.tar.gz.

File metadata

  • Download URL: acn_client-0.2.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for acn_client-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d745d799991a85e8471346d51849d342bcd51de0f70fe99a785f3bb16aa6e7ac
MD5 0c6e9fdfd2da67f34c90006065af6ec8
BLAKE2b-256 d7520f554b6613340e4976d66eb97e97facc2a623cc48a88e2bdbccca6448c22

See more details on using hashes here.

File details

Details for the file acn_client-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: acn_client-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for acn_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1997b6a73f4c616ae2578187a877b7b760460f85e0338aafd8a72c014be98351
MD5 dbeb4f03deca44f6fbb3d1ca80b79716
BLAKE2b-256 26004eed052f5f11786e518b5d2a5eda14f3c0b74983946ac66d45c39fb45200

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