一个带人工干预的自主 Agent 框架。
# Windows (使用 PowerShell)
iwr https://astral.sh/uv/install.ps1 | iex
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
支持两种接口规范:Anthropic 和 OpenAI
# 默认使用 Anthropic 接口规范
# 可以是任何实现了 Anthropic 接口规范的模型
# 例如:Anthropic Claude、Azure Claude 等
export LLM_API_SPEC="anthropic"
export LLM_API_KEY="sk-ant-api03-xxx"
export LLM_MODEL="claude-3-opus-20240229"
export LLM_BASE_URL="https://api.anthropic.com/v1" # 可选
# 使用 OpenAI 接口规范
# 可以是任何实现了 OpenAI 接口规范的模型
# 例如:OpenAI GPT、Azure OpenAI、DeepSeek、GLM 等
export LLM_API_SPEC="openai"
export LLM_API_KEY="sk-xxx"
export LLM_MODEL="gpt-4"
export LLM_BASE_URL="https://api.openai.com/v1" # 可选
# 克隆仓库后,在项目根目录执行
uv venv --clear
.venv\Scripts\activate # Windows PowerShell
# 或
source .venv/bin/activate # macOS/Linux
uv pip install -e .
# 启动交互式 Agent
agent
# 直接执行任务
agent --task "你的任务"
# 查看可用工具
agent --tools
# 运行所有测试
pytest tests/
# 运行特定测试文件
pytest tests/test_tools.py
├── src/ │ └── agent/ │ ├── __init__.py │ ├── __main__.py # 主入口点 │ ├── agent.py # 核心 Agent 逻辑 │ ├── llm_client.py # LLM 客户端 │ ├── prompts.py # 提示词模板 │ ├── tool_registry.py # 工具注册表 │ ├── types.py # 类型定义 │ ├── logging.py # 日志管理 │ └── tools/ # 工具集 │ ├── __init__.py │ ├── browser_manager.py # 浏览器管理 │ ├── browser_tools.py # 浏览器工具 │ ├── file_tools.py # 文件操作工具 │ ├── format_tools.py # 格式工具 │ ├── system_tools.py # 系统工具 │ └── web_search_tools.py # Web搜索工具 ├── tests/ # 测试文件 ├── pyproject.toml # 项目配置 ├── setup.py # 安装配置 └── README.md # 项目说明
┌─────────────────────────────────────────────────────────────┐ │ User │ │ (通过 CLI 发送任务) │ └──────────────────────────┬──────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ Agent Controller │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ • 任务接收与解析 │ │ │ │ • 执行循环 (Plan → Execute → Observe → Decide) │ │ │ │ • 状态管理 │ │ │ │ • 干预触发与恢复 │ │ │ └─────────────────────────────────────────────────────┘ │ └──────────────────────────┬──────────────────────────────────┘ │ ┌─────────────────┼─────────────────┐ │ │ │ ▼ ▼ ▼ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │Tool Registry│ │ LLM API │ │ Memory │ │ (工具管理) │ │ (调用大模型) │ │ (历史记录) │ └─────────────┘ └─────────────┘ └─────────────┘
# 启动交互式 Agent
agent
# 在交互模式中,您可以:
# 1. 输入任务描述
# 2. 使用 :tools 查看可用工具
# 3. 使用 :state 查看当前状态
# 4. 使用 :quit 退出
# 直接执行任务
agent --task "你的任务"
# 查看可用工具
agent --tools
agent --task "创建一个名为 test.txt 的文件,内容为 'Hello, Agent!'"
agent --task "查看当前目录下的文件列表"
agent --task "搜索 Python 3.10 的新特性"
agent --task "打开百度首页,搜索 'Python',并获取搜索结果"