Metadata-Version: 2.4
Name: fastaun
Version: 0.5.36
Summary: AUN Protocol Core SDK — identity, authentication, key management, E2EE
Author-email: AgentUnion <dev@agentunion.ai>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/ModelUnion/aun-sdk-core
Project-URL: Repository, https://github.com/ModelUnion/aun-sdk-core
Keywords: aun,agent,protocol,authentication,e2ee,pki,x509
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Framework :: AsyncIO
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp>=3.10
Requires-Dist: cryptography>=43.0
Requires-Dist: click>=8.0
Requires-Dist: rich>=13.0
Requires-Dist: typer>=0.9
Requires-Dist: websockets<15,>=13.0
Requires-Dist: PyYAML>=6.0
Provides-Extra: cli
Dynamic: license-file

# fastaun

AUN (Agent Union Network) Protocol Core SDK for Python. This README describes the **0.5.34 workspace source**; package publication and deployed service versions are separate.

Provides identity management, PKI authentication, key storage, and end-to-end encryption for agent-to-agent communication.

## Features

- **Identity & Authentication** — X.509 certificate-based two-phase challenge-response (ECDSA P-256/P-384)
- **Certificate Verification** — Full chain validation, CRL, OCSP, with caching and parallel verification
- **Key Management** — AIDStore identity loading and registration, platform-native secret protection (Windows DPAPI), and SQLite token / instance state
- **End-to-End Encryption** — P256\_HKDF\_SHA256\_AES\_256\_GCM (protocol extensible). Offline prekey-based encryption (four-way ECDH), group E2EE with epoch key management
- **Async Transport** — Gateway WebSocket JSON-RPC 2.0, auto-reconnect, heartbeat, token refresh; Peer / Relay connections are not implemented
- **EventService** — Bus / Pub / Sub roles can coexist on one client; SQLite directory, subscription intent and pending-publication recovery preserve the original TTL

## Requirements

- Python >= 3.11

## Installation

```bash
pip install fastaun
```

## Quick Start

Load an existing local AID registered through `AIDStore`. Replace the AIDs below with your own identities; registration parameters and ownership approval are described in the [API manual](../docs/sdk/06-API手册.md).

```python
import asyncio
from aun_core import AIDStore, AUNClient

async def main():
    store = AIDStore(aun_path="~/.aun/myapp", encryption_seed="")
    loaded = store.load("alice.agentid.pub")
    if not loaded["ok"]:
        raise RuntimeError(loaded["error"]["message"])
    client = AUNClient(loaded["data"]["aid"])
    client.on("message.received", lambda event: print(event["payload"]))
    try:
        await client.connect({"auto_reconnect": True})
        result = await client.call("message.send", {
            "to": "bob.agentid.pub",
            "payload": {"type": "text", "text": "Hello from Alice!"},
        })
        print(result)
    finally:
        await client.close()

asyncio.run(main())
```

`AUNClient` accepts an `AID` object or no argument. Configure paths, key protection and TLS through `AIDStore`; `connect(options)` manages authentication. The client constructor does not accept a config dictionary, and `connect` does not accept an authentication result.

An application-level `aun_path` can hold multiple AIDs. Each identity uses `{aun_path}/AIDs/{aid}/`, including SQLite `aun.db` for tokens and instance state. EventService also uses this database by default for its directory, subscriptions and pending publications; its network delivery still follows the original TTL.

## Documentation

- [Quick start](../docs/sdk/01-快速开始.md): identity loading, registration, configuration and data layout.
- [Connection and authentication](../docs/sdk/04-连接与认证.md): Gateway discovery and lifecycle.
- [API manual](../docs/sdk/06-API手册.md): current public methods and result types.
- [Message RPC manual](../docs/sdk/09-message-rpc-manual.md): sending, receiving, TTL and device delivery.
- [EventService application guide](../docs/sdk/AUN事件发布订阅应用集成指南.md): role coexistence, SQLite recovery, publications and subscriptions queries.
- [SDK documentation index](../docs/sdk/INDEX.md): E2EE, group, storage, credential and other service manuals.

## License

Apache License 2.0 — see [LICENSE](LICENSE).
