← Back to Plugins
Tools

Wechat Agent Router V2

hei-ying By hei-ying 👁 134 views ▲ 0 votes

WeChat OpenClaw Plugin with intelligent routing to Claude CLI and Codex CLI

GitHub

Install

npm install -g

Configuration Example

plugins:
  entries:
    wechat-agent-router:
      enabled: true
      config:
        router:
          parser:
            type: "hybrid"  # rule | llm | hybrid
            confidenceThreshold: 0.7
          strategy:
            selectionMode: "balanced"  # confidence | cost | speed | balanced
        backends:
          claude:
            enabled: true
            mode: "auto"
          codex:
            enabled: true
            sandbox: true

README

# 微信智能路由Agent CLI插件

基于微信OpenClaw插件开发的智能路由Agent CLI插件,支持根据自然语言描述自动选择后端Agent CLI。

## 特性

- ✅ 完整保留微信OpenClaw插件功能(QR登录、消息同步、媒体传输)
- 🤖 智能路由模块,自动选择Claude CLI或Codex CLI
- 📝 自然语言意图解析(规则+LLM混合)
- 🔧 可扩展的后端适配器架构
- ⚡ 流式响应支持
- 📊 路由决策统计与反馈

## 架构

```
┌─────────────┐     ┌──────────────────────────────────────────┐     ┌─────────────┐
│  微信用户    │────▶│  WeChat Agent Router Plugin              │────▶│ Claude CLI  │
└─────────────┘     │                                          │     └─────────────┘
                    │  ┌─────────────┐  ┌─────────────┐       │     ┌─────────────┐
                    │  │ WeChat Core │─▶│   Router    │───────┼────▶│ Codex CLI   │
                    │  │  (QR/消息)   │  │  Controller │       │     └─────────────┘
                    │  └─────────────┘  └──────┬──────┘       │     ┌─────────────┐
                    │                          │              │────▶│ 其他CLI...   │
                    │                   ┌──────▼──────┐       │     └─────────────┘
                    │                   │Intent Parser│       │
                    │                   │(Rule+LLM)   │       │
                    │                   └─────────────┘       │
                    └──────────────────────────────────────────┘
```

## 安装

```bash
# 1. 安装插件
openclaw plugins install "@tencent-weixin/openclaw-weixin-agent-router"

# 2. 启用插件
openclaw config set plugins.entries.wechat-agent-router.enabled true

# 3. 确保后端CLI已安装
npm install -g @anthropic-ai/claude-cli
npm install -g openai-codex

# 4. QR登录
openclaw channels login --channel wechat-agent-router

# 5. 重启网关
openclaw gateway restart
```

## 配置

编辑 `~/.openclaw/config.yaml`:

```yaml
plugins:
  entries:
    wechat-agent-router:
      enabled: true
      config:
        router:
          parser:
            type: "hybrid"  # rule | llm | hybrid
            confidenceThreshold: 0.7
          strategy:
            selectionMode: "balanced"  # confidence | cost | speed | balanced
        backends:
          claude:
            enabled: true
            mode: "auto"
          codex:
            enabled: true
            sandbox: true
```

## 路由规则

插件会根据以下规则自动选择后端:

| 用户意图 | 选择后端 | 原因 |
|---------|---------|------|
| 代码生成 | Codex | 快速、专注于代码 |
| 代码审查 | Claude | 深入分析能力 |
| 调试排错 | Claude | 更强的推理能力 |
| 架构设计 | Claude | 复杂系统设计 |
| 文档生成 | Claude | 高质量文档输出 |
| 一般对话 | Claude | 通用能力强 |

## 显式指定后端

用户可以在消息中显式指定后端:

```
@claude 帮我设计一个微服务架构
@codex 写一个Python爬虫
```

## 开发

### 项目结构

```
wechat-agent-router/
├── src/
│   ├── core/           # 微信核心功能
│   ├── router/         # 路由控制器
│   ├── parsers/        # 意图解析器
│   ├── backends/       # CLI适配器
│   └── types/          # 类型定义
├── config/             # 配置文件
└── docs/               # 文档
```

### 添加新的CLI后端

```typescript
import { BaseCLIAdapter, BackendConfig } from './types/backend';

class MyCLIAdapter extends BaseCLIAdapter {
  readonly type = 'my-cli';
  readonly capabilities = [...];
  
  async execute(command: string, options: ExecutionOptions): Promise<ExecutionResult> {
    // 实现执行逻辑
  }
}

// 注册适配器
adapterFactory.registerAdapter('my-cli', MyCLIAdapter);
```

## License

MIT
tools

Comments

Sign in to leave a comment

Loading comments...