Skip to main content

ArkClaw Invoke SDK — a2a protocol client for any a2a-compliant agent runtime.

Project description

ArkClaw Invoke SDK

License Python a2a

English | 简体中文

Python client for a2a v0.3, the open JSON-RPC protocol for invoking remote agents.

The SDK is framework-neutral: it implements the wire protocol and nothing else. Any runtime that exposes an a2a endpoint (OpenClaw, VeADK, LangGraph, Pydantic AI, or a custom server) works without adapter code.

Installation

pip install arkclaw-sdk

Optional extras:

pip install "arkclaw-sdk[cli]"     # arkclaw command-line tool
pip install "arkclaw-sdk[otel]"    # OpenTelemetry tracing
pip install "arkclaw-sdk[all]"     # both

Requires Python 3.10 or later. Wire types are Pydantic v2 models; HTTP is handled by httpx.

Usage

import asyncio
from arkclaw import AsyncClient, APIKeyCredential

async def main() -> None:
    async with AsyncClient(
        endpoint="https://my-agent.example.com/a2a/jsonrpc",
        credentials=APIKeyCredential(api_key="ark-..."),
    ) as client:
        result = await client.invoke("Hello, agent!")
        print(result.text)

asyncio.run(main())

A synchronous Client exposes the same interface for code that cannot use asyncio. It shares the async implementation internally and also works when called from inside an already-running event loop.

Streaming

invoke_stream consumes the server's Server-Sent Events stream and yields typed events (Message, Task, TaskStatusUpdateEvent, TaskArtifactUpdateEvent):

async for event in client.invoke_stream("Summarize this repository"):
    ...

Responses and streaming events are validated against the a2a v0.3 wire format; arkclaw test-agent (below) runs the same checks against any endpoint.

Authentication

Credential Grant
APIKeyCredential static API key
OAuthJWTCredential caller-managed bearer token
ClientCredentials OAuth 2.0 client credentials (RFC 6749 §4.4)
AgentKitIdentityCredential OAuth 2.0 with refresh-token grant (RFC 6749 §6)

DefaultCredentialChain resolves credentials from environment variables, following the precedence model familiar from boto3.

For end-user (three-legged) login, arkclaw.auth.AuthorizationCodeFlow implements the OAuth 2.0 authorization-code flow with PKCE (RFC 6749 §4.1, RFC 7636) for integration into a BFF or web backend.

Retries and timeouts

Retry behaviour is configured with RetryConfig. 429, 5xx and network errors are retried with exponential backoff and jitter; authentication and other 4xx errors are not. For streaming, only connection establishment is retried: an open stream is never replayed, so the server cannot receive duplicate tasks.

TimeoutConfig maps to httpx's four timeout phases (connect, read, write, pool) and provides long_running() and disabled() factories.

Tracing

With the otel extra installed, spans follow the OpenTelemetry GenAI semantic conventions. Message content is not recorded unless explicitly enabled via environment variable.

Command-line tool

Installed with the [cli] extra:

arkclaw test-agent <endpoint>    run the a2a v0.3 compliance checks
arkclaw chat <endpoint>          interactive streaming chat
arkclaw login                    browser-based OAuth login (PKCE)
arkclaw whoami                   show the cached identity
arkclaw logout                   remove a cached profile
arkclaw config show|set|unset    manage ~/.arkclaw/credentials profiles
arkclaw version                  print the SDK version

Credentials resolve in order: the --api-key flag, the ARKCLAW_API_KEY environment variable, then the named profile in ~/.arkclaw/credentials.

Documentation

The documentation site is built from docs/ with mkdocs build --strict.

Development

pip install -e ".[dev]"

pytest
ruff check src/ tests/
mypy --strict src/arkclaw
pyright src/arkclaw
mkdocs build --strict

License

Apache 2.0. See LICENSE.

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

arkclaw_sdk-0.1.1.tar.gz (112.0 kB view details)

Uploaded Source

Built Distribution

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

arkclaw_sdk-0.1.1-py3-none-any.whl (71.0 kB view details)

Uploaded Python 3

File details

Details for the file arkclaw_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: arkclaw_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 112.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for arkclaw_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 597f2916a47e279cfb3df5d7a89dc10aab35bfd1890e057b2b65894579aeb0c3
MD5 dfa8f772c0f2f3471f564a5b584b0152
BLAKE2b-256 b97d4006ecebf7cdd062e96847ca858d6ad55c95f5239ca7fb6cd777bd5503b1

See more details on using hashes here.

File details

Details for the file arkclaw_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for arkclaw_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23338b810a1cad66e73bcd25887ec5c69b3021bd21059e63c3e9fd80b971b18f
MD5 1214c4b2dd90596556e050c1033c20e1
BLAKE2b-256 8fef491c7f978d1d283adace472ee43e6fe0a0586b727213aea51175c3dd4ba2

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