Metadata-Version: 2.1
Name: pya2a
Version: 0.1.0
Summary: A2A SDK - Agent to Agent Protocol Python SDK
Home-page: https://github.com/jeff_kit/a2a
Author: jeff_kit
Author-email: bbmyth@gmail.com
Requires-Python: >=3.8,<3.14
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: server
Requires-Dist: cryptography (>=40.0.0,<42.0.0)
Requires-Dist: httpx (>=0.23.0,<1.0.0)
Requires-Dist: httpx-sse (>=0.3.1,<1.0.0)
Requires-Dist: jwcrypto (>=1.4.2,<2.0.0)
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
Requires-Dist: pyjwt (>=2.6.0,<3.0.0)
Requires-Dist: starlette (>=0.27.0,<1.0.0) ; extra == "server"
Requires-Dist: typing-extensions (>=4.5.0,<5.0.0)
Project-URL: Documentation, https://github.com/jeff_kit/a2a#readme
Project-URL: Repository, https://github.com/jeff_kit/a2a
Description-Content-Type: text/markdown

# A2A SDK

Agent to Agent Protocol Python SDK - 支持 Python 3.8-3.13 的工具库

## 安装

使用 pip 安装：

```bash
pip install a2a
```

## 功能特点

- 实现 Agent to Agent Protocol 的客户端和服务端
- 支持任务发送、获取、取消等操作
- 支持推送通知配置
- 支持流式响应
- 兼容 Python 3.8-3.13

## 使用示例

### 客户端示例

```python
import asyncio
from a2a.client import A2AClient
from a2a.types import Message, TextPart

async def main():
    client = A2AClient(url="http://example.com/agent")
    
    # 创建任务
    task_response = await client.send_task({
        "id": "task-123",
        "message": Message(
            role="user",
            parts=[TextPart(text="你好，这是一个测试")]
        )
    })
    
    print(f"任务创建成功: {task_response.result.id}")
    
    # 获取任务
    task = await client.get_task({"id": "task-123"})
    print(f"任务状态: {task.result.status.state}")

if __name__ == "__main__":
    asyncio.run(main())
```

### 流式响应示例

```python
import asyncio
from a2a.client import A2AClient
from a2a.types import Message, TextPart

async def main():
    client = A2AClient(url="http://example.com/agent")
    
    # 发送流式任务请求
    async for response in client.send_task_streaming({
        "id": "task-123",
        "message": Message(
            role="user",
            parts=[TextPart(text="请生成一个长文本")]
        )
    }):
        if response.result:
            print(response.result)

if __name__ == "__main__":
    asyncio.run(main())
```

## 开发设置

1. 克隆仓库：

```bash
git clone https://github.com/your-username/a2a.git
cd a2a
```

2. 安装 Poetry（如果尚未安装）：

```bash
curl -sSL https://install.python-poetry.org | python3 -
```

3. 安装依赖：

```bash
poetry install
```

4. 激活虚拟环境：

```bash
poetry shell
```

## 测试

使用 pytest 运行测试：

```bash
poetry run pytest
```

## 贡献指南

欢迎提交 Pull Requests！请确保提交前：

1. 更新测试以反映您的更改
2. 更新文档
3. 您的代码通过所有测试
4. 使用 Black 格式化代码
5. 使用 Ruff 进行代码检查

## 许可证

MIT

