Skip to content

Latest commit

 

History

36 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

大秦官僚系统 · Qin Dynasty Agent System

以秦制为骨,以 AI 为魂——一套仿古风多智能体协作开发框架。


系统架构

用户(飞书 / 终端 / Web UI)
          ↓
┌─────── 三公层 · OpenClaw ────────────────┐
│   丞相(Router)→ 太尉 → 御史大夫         │  ← 策略层:意图理解、任务编排、质量审查
└──────────────┬───────────────────────────┘
               ↓  dispatch.py
┌─────── 九卿层 · AgentScope ──────────────┐
│   少府   廷尉   太仆   …(可扩展)        │  ← 执行层:工具调用、实际执行
└──────────────────────────────────────────┘
角色 代号 职责 框架
丞相 main 接收指令、路由派发 OpenClaw
少府 file_agent 文件读写、目录管理 AgentScope
廷尉 debug_agent 代码审查、报错分析 AgentScope
太仆 devops_agent 终端命令、部署运维 AgentScope

目录结构

Qin_Dynasty/
├── server.py              # Web UI 服务器(FastAPI + WebSocket)
├── TODO.md                # 建设路线图
├── ui/
│   └── index.html         # 朝堂 Web UI(我的世界像素风)
└── agents/
    ├── config.json        # 统一配置(API Key、模型)
    ├── dispatch.py        # 桥接脚本:解析丞相 JSON → 调用九卿
    ├── chat.py            # 终端对话入口(OpenClaw 停服时使用)
    ├── zaixiang/          # 丞相 OpenClaw 工作区
    │   ├── SOUL.md        # 丞相系统提示(路由规则 + JSON 规范)
    │   ├── IDENTITY.md    # 身份设定
    │   └── skills/        # 技能配置
    ├── shaofu/            # 少府 OpenClaw 工作区
    ├── tingwei/           # 廷尉 OpenClaw 工作区
    ├── taipu/             # 太仆 OpenClaw 工作区
    └── workers/           # AgentScope 九卿执行脚本
        ├── _config.py     # 配置加载(config.json 优先 > 环境变量)
        ├── _tools.py      # 自定义工具(run_shell / read_file / write_file)
        ├── shaofu.py      # 少府 ReActAgent
        ├── tingwei.py     # 廷尉 ReActAgent
        └── taipu.py       # 太仆 ReActAgent

快速启动

1. 配置 API Key

编辑 agents/config.json

{
  "dashscope": {
    "api_key": "your-api-key",
    "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
    "default_model": "qwen3.5-plus"
  }
}

2. 启动 Web UI

/home/Qin_Dynasty/server.py
# 访问 http://localhost:8888

3. 终端对话(无需 OpenClaw)

/home/Qin_Dynasty/agents/chat.py

4. 直接调用九卿

# 调用太仆执行 shell 命令
/home/Qin_Dynasty/agents/dispatch.py --agent devops_agent --instruction "查看磁盘使用情况"

# 传入完整 JSON
/home/Qin_Dynasty/agents/dispatch.py '{"task_id":"QIN-001","target_agent":"file_agent","action_type":"read_file","payload":{"instruction":"读取 /etc/hostname"}}'

消息协议

丞相路由时输出标准 JSON:

{
  "task_id": "QIN-YYYYMMDD-NNN",
  "target_agent": "file_agent | debug_agent | devops_agent | direct_reply",
  "action_type": "read_file | write_file | debug_code | run_command | reply",
  "payload": {
    "instruction": "对九卿的完整指令",
    "context": {},
    "priority": "urgent | normal | low"
  },
  "zaixiang_note": "丞相对陛下的简要说明"
}

依赖环境

  • Python 3.11(/root/miniconda3/envs/pytorch
  • agentscope >= 1.0.16
  • fastapi, uvicorn
  • OpenClaw(飞书集成,可选)

路线图

详见 TODO.md

已完成: 丞相路由 · 三大九卿 · dispatch 桥接 · Web UI · 终端对话工具 进行中: 飞书全链路验证 · 错误处理 · 任务日志 规划中: 太尉(编排)· 御史大夫(审查)· 更多九卿扩展

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages