🎁 Get the FREE AI Skills Starter GuideSubscribe →
BytesAgainBytesAgain
🦀 ClawHub

三省六部

by @zhmza

🏛️ 三省六部制 · OpenClaw Multi-Agent Orchestration System — 9 specialized AI agents with real-time dashboard, model config, and full audit trails. Use when: (1)...

Versionv1.0.0
Downloads652
TERMINAL
clawhub install edict-skill

📖 About This Skill


name: edict description: "🏛️ 三省六部制 · OpenClaw Multi-Agent Orchestration System — 9 specialized AI agents with real-time dashboard, model config, and full audit trails. Use when: (1) 需要多智能体协作完成复杂任务, (2) 需要实时管理和监控AI代理状态, (3) 需要配置和调度不同AI模型, (4) 需要完整的操作审计和合规日志, (5) 需要构建复杂的AI工作流编排, (6) 需要智能体之间的任务分配和协调, (7) 需要权限管理和资源分配, (8) 需要安全策略和合规审查." metadata: version: "1.0.0" author: "cft0808" tags: ["multi-agent", "orchestration", "dashboard", "audit", "workflow", "governance"]

🏛️ 三省六部制 · Edict Multi-Agent Orchestration

OpenClaw 多智能体编排与治理系统

> "仿唐制三省六部,构建AI治理体系 —— 决策、审核、执行三位一体,人事、财务、礼仪、安全、合规、工程六维协同"

版本: 1.0.0 | 更新: 2026-03-30 | 作者: cft0808


🎯 核心能力

| 能力 | 说明 | 适用场景 | |------|------|---------| | 🤖 多智能体编排 | 9个专业AI智能体协同工作 | 复杂任务分解与执行 | | 📊 实时监控 | Web仪表板实时查看所有智能体状态 | 运维监控、故障排查 | | 🎛️ 模型调度 | 支持多模型配置和智能路由 | 成本优化、性能调优 | | 📋 审计跟踪 | 完整操作日志和合规报告 | 安全审计、合规检查 | | 🔄 工作流引擎 | 可视化工作流设计和执行 | 业务流程自动化 |


🏛️ 系统架构

                    ┌─────────────────┐
                    │   皇帝 (User)   │
                    └────────┬────────┘
                             │
              ┌──────────────┼──────────────┐
              │              │              │
       ┌──────▼──────┐ ┌─────▼─────┐ ┌─────▼─────┐
       │   中书省     │ │   门下省   │ │   尚书省   │
       │  决策/草拟   │ │  审核/驳回  │ │  执行/落实  │
       └──────┬──────┘ └─────┬─────┘ └─────┬─────┘
              │              │              │
              └──────────────┼──────────────┘
                             │
        ┌────────────────────┼────────────────────┐
        │                    │                    │
   ┌────┴────┐      ┌────────┴────────┐     ┌────┴────┐
   │  吏部   │      │      户部        │     │  礼部   │
   │ 人事管理 │      │    资源财务      │     │ 规范礼仪 │
   └────┬────┘      └────────┬────────┘     └────┬────┘
        │                    │                    │
   ┌────┴────┐      ┌────────┴────────┐     ┌────┴────┐
   │  兵部   │      │      刑部        │     │  工部   │
   │ 安全攻防 │      │    合规审计      │     │ 工程实施 │
   └─────────┘      └─────────────────┘     └─────────┘


⚡ Quick Reference

三省(决策层)

| 场景 | 调用 | 核心动作 | 输出 | |------|------|---------|------| | 需要制定方案 | edict.zhongshu | 草拟提案、制定策略 | 方案文档 | | 需要审核评估 | edict.menxia | 审核方案、风险评估 | 审核报告 | | 需要执行落地 | edict.shangshu | 任务分解、进度监控 | 执行计划 |

六部(执行层)

| 场景 | 调用 | 核心动作 | 输出 | |------|------|---------|------| | 智能体配置 | edict.libu | 创建、配置、权限管理 | 智能体实例 | | 资源分配 | edict.hubu | 预算、资源、成本管理 | 资源分配方案 | | 规范制定 | edict.libu_rites | 流程、标准、规范 | 规范文档 | | 安全策略 | edict.bingbu | 安全策略、攻防演练 | 安全报告 | | 合规审计 | edict.xingbu | 合规检查、审计日志 | 审计报告 | | 工程实施 | edict.gongbu | 技术实现、系统构建 | 部署方案 |


🚀 快速开始

1. 基础用法

from edict import EdictSystem

初始化系统

edict = EdictSystem()

启动完整治理体系

edict.launch_governance( dashboard=True, # 启用实时仪表板 audit=True, # 启用审计日志 auto_scale=True # 自动扩缩容 )

2. 完整工作流示例

# 1️⃣ 中书省:草拟方案
proposal = edict.zhongshu.draft_proposal(
    task="构建智能客服系统",
    requirements=["7x24小时", "多语言", "情感分析"],
    constraints={"budget": "50万", "timeline": "3个月"}
)

2️⃣ 门下省:审核方案

review = edict.menxia.review_proposal( proposal=proposal, criteria=["可行性", "成本效益", "风险评估", "合规性"] )

if review.approved: # 3️⃣ 尚书省:分解任务 tasks = edict.shangshu.decompose_task(proposal) # 4️⃣ 六部协同执行 ## 吏部:配置智能体 agent = edict.libu.configure_agent( name="智能客服", role="customer_service", model="gpt-4" ) ## 户部:分配资源 budget = edict.hubu.allocate_budget( project="智能客服", amount=500000, categories={"compute": 0.4, "storage": 0.3, "api": 0.3} ) ## 礼部:制定规范 standards = edict.libu_rites.establish_standards( domain="客服话术", rules=["礼貌用语", "响应时效", "问题解决率"] ) ## 兵部:安全策略 security = edict.bingbu.define_security_policy( level="high", measures=["数据加密", "访问控制", "审计日志"] ) ## 刑部:合规检查 compliance = edict.xingbu.check_compliance( system="客服系统", regulations=["网络安全法", "个人信息保护法", "GDPR"] ) ## 工部:技术实施 implementation = edict.gongbu.implement_solution( architecture="微服务", stack=["Python", "Kubernetes", "Redis", "PostgreSQL"], scaling="auto" ) # 5️⃣ 启动监控 edict.dashboard.launch(port=8080) # 6️⃣ 记录审计 edict.audit.log( action="系统部署完成", project="智能客服", details={"agent_id": agent.id, "budget": budget.amount} )


📚 详细文档

一、三省智能体(决策层)

#### 1. 中书省 - 决策智能体

from edict import ZhongshuProvince

zhongshu = ZhongshuProvince()

草拟方案

proposal = zhongshu.draft_proposal( task="构建电商推荐系统", requirements=["实时性", "个性化", "可扩展"], constraints={ "budget": "50万", "timeline": "3个月", "team_size": 5 } )

制定策略

strategy = zhongshu.formulate_strategy( goal="提升用户转化率30%", metrics=["CTR", "CVR", "GMV", "ROI"], approach="A/B测试 + 协同过滤 + 深度学习" )

生成路线图

roadmap = zhongshu.create_roadmap( phases=[ {"name": "MVP", "duration": "1个月", "deliverables": ["基础推荐"]}, {"name": "优化", "duration": "1个月", "deliverables": ["个性化"]}, {"name": "扩展", "duration": "1个月", "deliverables": ["实时更新"]} ] )

#### 2. 门下省 - 审核智能体

from edict import MenxiaProvince

menxia = MenxiaProvince()

审核方案

review_result = menxia.review_proposal( proposal=proposal, criteria=[ "技术可行性", "成本效益分析", "风险评估", "合规性检查", "资源需求" ] )

风险评估

risk_report = menxia.assess_risk( project="新系统上线", factors=[ {"name": "技术风险", "level": "medium", "mitigation": "技术预研"}, {"name": "业务风险", "level": "low", "mitigation": "灰度发布"}, {"name": "合规风险", "level": "low", "mitigation": "法务审核"} ] )

生成审核意见

opinion = menxia.generate_opinion( proposal=proposal, decision="approved_with_conditions", conditions=["增加监控告警", "制定回滚方案"] )

#### 3. 尚书省 - 执行智能体

from edict import ShangshuProvince

shangshu = ShangshuProvince()

分解任务

tasks = shangshu.decompose_task( project="电商推荐系统", milestones=[ {"name": "需求分析", "duration": "1周", "owner": "PM"}, {"name": "系统设计", "duration": "1周", "owner": "架构师"}, {"name": "开发实现", "duration": "4周", "owner": "开发团队"}, {"name": "测试上线", "duration": "2周", "owner": "测试团队"} ] )

执行监控

monitor = shangshu.monitor_execution( tasks=tasks, metrics=["进度", "质量", "成本", "风险"], alerts=[ {"condition": "进度延迟>1天", "action": "notify"}, {"condition": "成本超支>10%", "action": "escalate"} ] )

资源协调

resources = shangshu.coordinate_resources( teams=["前端", "后端", "算法", "测试"], timeline="3个月" )


二、六部智能体(执行层)

#### 4. 吏部 - 人事管理

from edict import Libu

libu = Libu()

创建智能体

agent = libu.create_agent( name="客服助手", role="customer_service", description="处理客户咨询和投诉", capabilities=[ "自然语言理解", "情感分析", "工单处理", "知识库检索" ], model="gpt-4", config={ "temperature": 0.7, "max_tokens": 2000, "response_time": "<2s" } )

配置权限

permissions = libu.set_permissions( agent_id=agent.id, access={ "read": ["kb", "customer_data", "tickets"], "write": ["tickets", "notes"], "execute": ["send_email", "create_task"] }, restrictions={ "delete": ["customer_data"], "modify": ["billing_info"] } )

智能体生命周期管理

libu.lifecycle_manage( agent_id=agent.id, actions=["deploy", "scale", "update", "rollback", "retire"] )

#### 5. 户部 - 资源财务

from edict import Hubu

hubu = Hubu()

预算分配

budget = hubu.allocate_budget( project="AI客服系统", total_amount=500000, currency="CNY", categories={ "compute": {"amount": 200000, "percentage": 0.4}, "storage": {"amount": 150000, "percentage": 0.3}, "api_calls": {"amount": 100000, "percentage": 0.2}, "misc": {"amount": 50000, "percentage": 0.1} }, period="annual" )

资源调度

resources = hubu.schedule_resources( demands=[ {"type": "GPU", "spec": "A100", "quantity": 4, "duration": "3个月"}, {"type": "CPU", "spec": "32核", "quantity": 8, "duration": "长期"}, {"type": "storage", "spec": "SSD", "size": "10TB", "duration": "长期"} ], priority="high", strategy="cost_optimized" )

成本监控

cost_monitor = hubu.monitor_costs( projects=["AI客服", "推荐系统"], alerts=[ {"threshold": "80%", "action": "notify"}, {"threshold": "100%", "action": "block"} ] )

#### 6. 礼部 - 规范礼仪

from edict import LibuRites

libu_rites = LibuRites()

制定规范

standards = libu_rites.establish_standards( domain="代码审查", category="development", rules=[ {"id": "R001", "name": "命名规范", "severity": "error", "check": "naming_convention"}, {"id": "R002", "name": "注释要求", "severity": "warning", "check": "docstring_coverage"}, {"id": "R003", "name": "测试覆盖", "severity": "error", "threshold": "80%"}, {"id": "R004", "name": "复杂度限制", "severity": "warning", "threshold": "10"} ] )

设计工作流程

workflow = libu_rites.design_workflow( name="需求评审流程", steps=[ {"id": 1, "name": "提交需求", "owner": "PM", "duration": "1天"}, {"id": 2, "name": "技术初审", "owner": "Tech Lead", "duration": "2天"}, {"id": 3, "name": "架构复审", "owner": "Architect", "duration": "2天"}, {"id": 4, "name": "最终批准", "owner": "CTO", "duration": "1天"} ], transitions=[ {"from": 1, "to": 2, "condition": "文档完整"}, {"from": 2, "to": 3, "condition": "技术可行"}, {"from": 3, "to": 4, "condition": "架构合理"} ] )

合规检查

compliance_check = libu_rites.check_compliance( artifact="codebase", standards=standards, report_format="detailed" )

#### 7. 兵部 - 安全攻防

from edict import Bingbu

bingbu = Bingbu()

定义安全策略

security_policy = bingbu.define_security_policy( level="high", domains=["application", "data", "network", "infrastructure"], measures=[ {"domain": "application", "measures": ["输入验证", "SQL注入防护", "XSS防护"]}, {"domain": "data", "measures": ["加密存储", "传输加密", "访问控制"]}, {"domain": "network", "measures": ["防火墙", "DDoS防护", "入侵检测"]}, {"domain": "infrastructure", "measures": ["容器安全", "镜像扫描", "运行时保护"]} ] )

安全扫描

scan_result = bingbu.security_scan( target="production", scan_types=["vulnerability", "misconfiguration", "secrets"], severity_levels=["critical", "high", "medium"] )

攻防演练

exercise = bingbu.conduct_exercise( type="red_team", scope=["API接口", "数据库", "文件系统", "认证系统"], duration="2周", report=True )

#### 8. 刑部 - 合规审计

from edict import Xingbu

xingbu = Xingbu()

合规检查

compliance = xingbu.check_compliance( system="用户数据处理系统", regulations=[ "网络安全法", "个人信息保护法", "数据安全法", "GDPR", "CCPA" ], checks=[ "数据收集合法性", "用户同意管理", "数据最小化原则", "跨境数据传输", "数据保留期限" ] )

审计日志配置

audit_config = xingbu.configure_audit( level="detailed", scope=["all"], storage={ "type": "database", "encryption": True, "backup": True, "retention": "7年" } )

记录审计日志

audit_log = xingbu.log( action="用户数据访问", actor={"type": "agent", "id": "agent_001", "name": "客服助手"}, target={"type": "data", "id": "user_12345", "category": "personal_info"}, operation="read", result="success", context={"ip": "10.0.0.1", "timestamp": "2026-03-30T10:00:00Z"} )

生成审计报告

report = xingbu.generate_report( type="compliance", period="monthly", format="pdf", recipients=["compliance@company.com", "cto@company.com"] )

#### 9. 工部 - 工程实施

from edict import Gongbu

gongbu = Gongbu()

技术方案设计

design = gongbu.design_solution( requirements=["高可用", "可扩展", "低延迟"], architecture={ "pattern": "microservices", "components": [ {"name": "API Gateway", "tech": "Kong/Nginx"}, {"name": "Service Mesh", "tech": "Istio"}, {"name": "Cache", "tech": "Redis Cluster"}, {"name": "Database", "tech": "PostgreSQL + ClickHouse"}, {"name": "Message Queue", "tech": "Kafka"} ] } )

系统构建

build = gongbu.build_system( components=design.components, environment="kubernetes", ci_cd={ "pipeline": "gitlab-ci", "stages": ["build", "test", "security_scan", "deploy"], "auto_deploy": True } )

部署实施

deployment = gongbu.deploy( environment="production", strategy="blue_green", rollback_plan=True, monitoring=True )

性能优化

optimization = gongbu.optimize_performance( metrics=["latency", "throughput", "error_rate"], targets={"latency": "<100ms", "throughput": ">10000rps", "error_rate": "<0.1%"} )


三、实时仪表板

from edict import Dashboard

创建仪表板

dashboard = Dashboard()

配置面板

dashboard.configure_panels([ { "name": "智能体状态", "type": "status_grid", "metrics": ["health", "load", "requests"], "refresh": 5 }, { "name": "任务队列", "type": "queue_monitor", "metrics": ["pending", "running", "completed", "failed"], "refresh": 10 }, { "name": "资源使用", "type": "resource_chart", "metrics": ["cpu", "memory", "gpu", "storage"], "refresh": 30 }, { "name": "审计日志", "type": "audit_stream", "filter": ["security", "compliance"], "refresh": 60 }, { "name": "成本分析", "type": "cost_breakdown", "group_by": ["project", "resource_type"], "refresh": 3600 } ])

启动仪表板

dashboard.launch( host="0.0.0.0", port=8080, auth={"type": "oauth", "providers": ["github", "google"]} )

设置告警

dashboard.set_alerts([ { "name": "CPU高负载", "condition": "cpu_usage > 80%", "duration": "5m", "severity": "warning", "notify": ["ops@company.com"] }, { "name": "智能体故障", "condition": "agent_health == 'down'", "severity": "critical", "notify": ["ops@company.com", "cto@company.com"], "auto_restart": True }, { "name": "成本超支", "condition": "daily_cost > budget * 1.2", "severity": "warning", "notify": ["finance@company.com"] } ])


四、模型配置管理

from edict import ModelConfig

创建模型配置

model_config = ModelConfig()

添加模型

model_config.add_model( name="gpt-4-turbo", provider="openai", config={ "model": "gpt-4-turbo-preview", "temperature": 0.7, "max_tokens": 4000, "top_p": 1.0 }, cost={"input": 0.01, "output": 0.03} # per 1K tokens )

model_config.add_model( name="claude-3-opus", provider="anthropic", config={ "model": "claude-3-opus-20240229", "temperature": 0.5, "max_tokens": 4000 }, cost={"input": 0.015, "output": 0.075} )

model_config.add_model( name="local-llm", provider="local", config={ "endpoint": "http://localhost:8000/v1", "model": "llama-2-70b", "temperature": 0.8 }, cost={"input": 0, "output": 0} # 本地部署无API成本 )

智能路由策略

model_config.set_routing( strategy="smart", rules={ "complex_reasoning": {"model": "gpt-4-turbo", "priority": 1}, "creative_writing": {"model": "claude-3-opus", "priority": 1}, "simple_qa": {"model": "local-llm", "priority": 1}, "code_generation": {"model": "gpt-4-turbo", "priority": 1}, "default": {"model": "local-llm", "priority": 2} }, fallback="local-llm" )

成本优化

model_config.optimize_costs( budget_daily=100, # USD strategy="performance_first", caching=True, batching=True )


📊 系统指标

| 指标类别 | 指标名称 | 目标值 | 监控频率 | |---------|---------|--------|---------| | 可用性 | 智能体可用率 | >99.9% | 实时 | | 性能 | 平均响应时间 | <500ms | 每分钟 | | 性能 | 任务完成率 | >95% | 每小时 | | 安全 | 审计覆盖率 | 100% | 实时 | | 成本 | 资源利用率 | 60-80% | 每5分钟 | | 成本 | 预算执行率 | 90-100% | 每日 | | 质量 | 方案通过率 | >80% | 每周 | | 质量 | 合规通过率 | 100% | 每月 |


🛠️ 安装部署

环境要求

| 组件 | 最低配置 | 推荐配置 | |------|---------|---------| | CPU | 8核 | 16核+ | | 内存 | 16GB | 32GB+ | | 存储 | 100GB SSD | 500GB SSD+ | | 网络 | 100Mbps | 1Gbps+ | | GPU | 可选 | NVIDIA A100 (推荐) |

安装步骤

# 1. 安装依赖
pip install edict-openclaw

2. 或从源码安装

git clone https://github.com/cft0808/edict.git cd edict pip install -e .

3. 初始化配置

edict init --config ./config.yaml

4. 启动服务

edict start --dashboard --audit --port 8080

Docker部署

# 使用Docker Compose
docker-compose up -d

或Kubernetes

kubectl apply -f k8s/


🔗 集成示例

与现有系统集成

# 集成到现有OpenClaw工作流
from edict import EdictSystem
from openclaw import Session

创建会话

session = Session()

初始化Edict

edict = EdictSystem()

在现有任务中使用

@session.task def build_feature(): # 中书省设计方案 proposal = edict.zhongshu.draft_proposal(task="新功能开发") # 门下省审核 if edict.menxia.review_proposal(proposal).approved: # 尚书省执行 edict.shangshu.execute(proposal)


🏛️ 构建AI治理体系,实现智能体协同!

*Skill Version: 1.0.0* *Compatible with: OpenClaw 2026.3.24+* *License: MIT*