{"_id":"@aiwaretop/claw-router","_rev":"3-ec7ec9e0eb4ad2e31930595d0690da22","name":"@aiwaretop/claw-router","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@aiwaretop/claw-router","version":"1.0.0","keywords":["openclaw","plugin","model-routing","ai","llm","smart-routing","complexity-analysis"],"author":{"name":"aiwaretop"},"license":"MIT","_id":"@aiwaretop/claw-router@1.0.0","maintainers":[{"name":"aiwarelife","email":"aiwarelife@gmail.com"}],"homepage":"https://github.com/HackSing/claw-router#readme","bugs":{"url":"https://github.com/HackSing/claw-router/issues"},"dist":{"shasum":"debbdaa1fdea8ee3d93f5829338a856c15076d52","tarball":"https://registry.npmjs.org/@aiwaretop/claw-router/-/claw-router-1.0.0.tgz","fileCount":13,"integrity":"sha512-jtyXGtrGXQix39VpB/+AyVFYz849UAcimyPwMnvR0uiowaooPeZawOh+4NjboeaGaVj139ITojUVq538H163nQ==","signatures":[{"sig":"MEQCIBtU+zM/K65ZGpdWvWuENlooXtsdDlKZ+GXnJk4mDtXpAiAQ+F7TTj7h7LcdQIQnCxVeTAcSfsUSFvFtEhJY7q7pew==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":73103},"main":"index.ts","gitHead":"23e97085708222d2792b9882c380d118ea02b300","scripts":{"test":"npx tsx --test test/*.test.ts","test:verbose":"npx tsx --test test/*.test.ts 2>&1"},"_npmUser":{"name":"aiwarelife","email":"aiwarelife@gmail.com"},"repository":{"url":"git+https://github.com/HackSing/claw-router.git","type":"git"},"_npmVersion":"11.5.2","description":"Intelligent model routing plugin for OpenClaw — routes messages to optimal AI models based on 8-dimension complexity scoring","directories":{},"_nodeVersion":"22.18.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/claw-router_1.0.0_1770986375268_0.23252491330173686","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@aiwaretop/claw-router","version":"1.0.4","keywords":["openclaw","plugin","model-routing","ai","llm","smart-routing","complexity-analysis"],"author":{"name":"aiwaretop"},"license":"MIT","_id":"@aiwaretop/claw-router@1.0.4","maintainers":[{"name":"aiwarelife","email":"aiwarelife@gmail.com"}],"homepage":"https://github.com/HackSing/claw-router#readme","bugs":{"url":"https://github.com/HackSing/claw-router/issues"},"dist":{"shasum":"45558d2b64decba75c6180869ba81fb99465dfbc","tarball":"https://registry.npmjs.org/@aiwaretop/claw-router/-/claw-router-1.0.4.tgz","fileCount":13,"integrity":"sha512-Ap70b+R3W2qBt17vEEizTT4WNQxiaFOCdKKCrcW46N6+LXDCfxT1NQI/ZowCQ6GMzEhxND75msX6EZAO1kSQJA==","signatures":[{"sig":"MEYCIQCyr8W84YBxU9wQ2KPPZBysZKtlpshQ6EbzwT1VDmU5KQIhAJwMTrq2YSy0UEYuYYiB2jfZ1LgGLCsTF+hPouOSb6AL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":76179},"main":"index.ts","gitHead":"f688cda402d5643b4f6a9344a7dd8c2b58e551b3","scripts":{"test":"npx tsx --test test/*.test.ts","test:verbose":"npx tsx --test test/*.test.ts 2>&1"},"_npmUser":{"name":"aiwarelife","email":"aiwarelife@gmail.com"},"repository":{"url":"git+https://github.com/HackSing/claw-router.git","type":"git"},"_npmVersion":"11.7.0","description":"Intelligent model routing plugin for OpenClaw — routes messages to optimal AI models based on 8-dimension complexity scoring","directories":{},"_nodeVersion":"22.18.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","typescript":"^5.4.0"},"_npmOperationalInternal":{"tmp":"tmp/claw-router_1.0.4_1771052698815_0.37361620853895805","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@aiwaretop/claw-router","version":"1.0.5","description":"Intelligent model routing plugin for OpenClaw — routes messages to optimal AI models based on 8-dimension complexity scoring","main":"index.ts","author":{"name":"aiwaretop"},"license":"AIWare Community License","repository":{"type":"git","url":"git+https://github.com/HackSing/claw-router.git"},"keywords":["openclaw","plugin","model-routing","ai","llm","smart-routing","complexity-analysis"],"scripts":{"test":"npx tsx --test test/*.test.ts","test:verbose":"npx tsx --test test/*.test.ts 2>&1"},"devDependencies":{"tsx":"^4.21.0","typescript":"^5.4.0"},"gitHead":"1b7560a2a5d3e34dfc75c37e07c888d95b456f5d","_id":"@aiwaretop/claw-router@1.0.5","bugs":{"url":"https://github.com/HackSing/claw-router/issues"},"homepage":"https://github.com/HackSing/claw-router#readme","_nodeVersion":"22.18.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-7gBgG9vzRH9G3u1GTpCPv6rWjvj/+G8I9Fj271uWrkXhWYBLUQxWLdD9jX6ZqR1wF4Gwb1IAfE/6D3L82jfScw==","shasum":"48b9b174a1651cd5ddc5fc5a8bb128eecbcbe7b7","tarball":"https://registry.npmjs.org/@aiwaretop/claw-router/-/claw-router-1.0.5.tgz","fileCount":13,"unpackedSize":77888,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDH0YvEVxwvIvcmtceMjJ+dAP32x0qPnNIfK08FV2YgMQIhAPjVwudJCXPzLCA3Z3JtwQMdj9zl3zen7Hw02zfwxboV"}]},"_npmUser":{"name":"aiwarelife","email":"aiwarelife@gmail.com"},"directories":{},"maintainers":[{"name":"aiwarelife","email":"aiwarelife@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/claw-router_1.0.5_1771054029521_0.7656033096406156"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-13T12:39:35.151Z","modified":"2026-02-14T07:27:09.789Z","1.0.0":"2026-02-13T12:39:35.429Z","1.0.4":"2026-02-14T07:04:58.994Z","1.0.5":"2026-02-14T07:27:09.662Z"},"bugs":{"url":"https://github.com/HackSing/claw-router/issues"},"author":{"name":"aiwaretop"},"license":"AIWare Community License","homepage":"https://github.com/HackSing/claw-router#readme","keywords":["openclaw","plugin","model-routing","ai","llm","smart-routing","complexity-analysis"],"repository":{"type":"git","url":"git+https://github.com/HackSing/claw-router.git"},"description":"Intelligent model routing plugin for OpenClaw — routes messages to optimal AI models based on 8-dimension complexity scoring","maintainers":[{"name":"aiwarelife","email":"aiwarelife@gmail.com"}],"readme":"# 🔀 @aiwaretop/claw-router\r\n\r\n> **[OpenClaw](https://openclaw.app) 智能模型路由插件** — 根据消息复杂度自动选择最佳模型。\r\n\r\n[![AIWare Community License](https://img.shields.io/badge/license-AIWare%20Community%20License-blue.svg)](LICENSE)\r\n[![OpenClaw Plugin](https://img.shields.io/badge/OpenClaw-plugin-purple.svg)](https://openclaw.app)\r\n\r\n[English](README.md) | **中文**\r\n\r\n---\r\n\r\n## 为什么需要它？\r\n\r\n不是每条消息都需要最强的模型。\"你好\" 用快速便宜的模型就够了，而\"设计一个分布式系统\" 则需要顶级模型来处理。**Claw Router** 自动帮你做这个决策 — 纯本地计算，< 1ms，零 API 调用。\r\n\r\n```\r\n用户: \"你好\"           → TRIVIAL  → doubao-seed-code    （快速、便宜）\r\n用户: \"写个爬虫\"        → COMPLEX  → gpt-5.3-codex-high （强力）\r\n用户: \"设计分布式架构\"    → EXPERT   → claude-opus-4      （最强）\r\n```\r\n\r\n---\r\n\r\n## 架构图\r\n\r\n```\r\n┌─────────────────────────────────────────────────────────┐\r\n│                      用户消息                            │\r\n└──────────────────────┬──────────────────────────────────┘\r\n                       │\r\n                       ▼\r\n              ┌────────────────┐\r\n              │   硬规则检查    │ ◄── 短消息？3+代码块？\r\n              │  (< 0.01 ms)   │     \"系统设计\"？\r\n              └───────┬────────┘\r\n                      │ 无匹配\r\n                      ▼\r\n     ┌────────────────────────────────────┐\r\n     │       8 维评分引擎                   │\r\n     │                                     │\r\n     │  推理深度(0.20)  代码技术(0.18)       │\r\n     │  任务步骤(0.15)  领域专业(0.12)       │\r\n     │  输出复杂(0.10)  创意要求(0.10)       │\r\n     │  上下文(0.08)    消息长度(0.07)       │\r\n     └───────────────────┬────────────────┘\r\n                         │\r\n                         ▼\r\n              ┌──────────────────┐\r\n              │ Sigmoid 校准      │\r\n              │   Σ(wᵢ·sᵢ) → σ   │\r\n              └────────┬─────────┘\r\n                       │\r\n                       ▼\r\n     ┌─────────────────────────────────────┐\r\n     │           Tier 映射                  │\r\n     │  [0.00,0.15) → TRIVIAL（极简）        │\r\n     │  [0.15,0.35) → SIMPLE（简单）         │\r\n     │  [0.35,0.55) → MODERATE（中等）       │\r\n     │  [0.55,0.75) → COMPLEX（复杂）        │\r\n     │  [0.75,1.00] → EXPERT（专家）         │\r\n     └─────────────────┬───────────────────┘\r\n                       │\r\n                       ▼\r\n              ┌────────────────┐\r\n              │  选择模型       │ → 主模型 / 备用模型\r\n              └────────────────┘\r\n```\r\n\r\n---\r\n\r\n## 快速开始\r\n\r\n### 1. 安装\r\n\r\n```bash\r\ncd ~/.openclaw\r\nnpm install @aiwaretop/claw-router\r\n```\r\n\r\n### 2. 启用插件\r\n\r\n在 OpenClaw 配置中添加（`~/.openclaw/openclaw.json`）：\r\n\r\n```json\r\n{\r\n  \"plugins\": {\r\n    \"enabled\": true,\r\n    \"allow\": [\"claw-router\"],\r\n    \"entries\": {\r\n      \"claw-router\": {\r\n        \"enabled\": true\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### 3. 配置（可选）\r\n\r\n**重要：** 插件配置必须放在 `config` 字段下：\r\n\r\n```json\r\n{\r\n  \"plugins\": {\r\n    \"entries\": {\r\n      \"claw-router\": {\r\n        \"enabled\": true,\r\n        \"config\": {\r\n          \"tiers\": {\r\n            \"TRIVIAL\":  { \"primary\": \"volcengine/doubao-seed-code\" },\r\n            \"SIMPLE\":   { \"primary\": \"volcengine/doubao-seed-code\" },\r\n            \"MODERATE\": { \"primary\": \"api-proxy-gpt/gpt-5.3-codex-high\" },\r\n            \"COMPLEX\":  { \"primary\": \"api-proxy-gpt/gpt-5.3-codex-high\" },\r\n            \"EXPERT\":   { \"primary\": \"api-proxy-claude/claude-opus-4-6\" }\r\n          },\r\n          \"logging\": true\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\n## 功能\r\n\r\n### 🎯 Agent 工具：`smart_route`\r\n\r\nAgent 可以调用此工具获取路由建议：\r\n\r\n```\r\n工具: smart_route\r\n输入: { \"message\": \"帮我设计一个分布式缓存系统\" }\r\n输出: {\r\n  \"tier\": \"EXPERT\",\r\n  \"model\": \"api-proxy-claude/claude-opus-4-6\",\r\n  \"score\": 0.8234,\r\n  \"dimensions\": { \"reasoning\": 0.5, \"codeTech\": 0.65, ... }\r\n}\r\n```\r\n\r\n### 💬 自动回复命令：`/route`\r\n\r\n在聊天中输入 `/route` 查看路由状态和统计数据。\r\n\r\n### 🖥️ CLI 命令\r\n\r\n```bash\r\n# 查看路由状态\r\nopenclaw route status\r\n\r\n# 测试消息路由\r\nopenclaw route test \"请帮我写一个排序算法\"\r\n```\r\n\r\n### 🔌 Gateway RPC\r\n\r\n```javascript\r\nawait rpc('route.decide', { message: '...' });\r\nawait rpc('route.stats');\r\n```\r\n\r\n---\r\n\r\n## 配置参考\r\n\r\n| 配置项 | 类型 | 默认值 | 说明 |\r\n|--------|------|--------|------|\r\n| `tiers` | `Record<Tier, { primary, fallback? }>` | 全部 `\"default\"` | 每个 Tier 对应的模型 |\r\n| `thresholds` | `[n, n, n, n]` | `[0.15, 0.35, 0.55, 0.75]` | Tier 分界阈值 |\r\n| `scoring.weights` | `Record<Dimension, number>` | 见下表 | 覆盖维度权重 |\r\n| `logging` | `boolean` | `false` | 启用详细路由日志 |\r\n\r\n### 默认权重\r\n\r\n| 维度 | 键名 | 权重 |\r\n|------|------|------|\r\n| 推理深度 | `reasoning` | 0.20 |\r\n| 代码/技术 | `codeTech` | 0.18 |\r\n| 任务步骤 | `taskSteps` | 0.15 |\r\n| 领域专业度 | `domainExpert` | 0.12 |\r\n| 输出复杂度 | `outputComplex` | 0.10 |\r\n| 创意要求 | `creativity` | 0.10 |\r\n| 上下文依赖 | `contextDepend` | 0.08 |\r\n| 消息长度 | `messageLength` | 0.07 |\r\n\r\n### 硬规则（优先级高于评分）\r\n\r\n| 条件 | 结果 |\r\n|------|------|\r\n| 消息 ≤ 5 字符且无技术词 | → TRIVIAL |\r\n| 3+ 个代码块 (```) | → COMPLEX |\r\n| 包含\"系统设计\"\"架构设计\"\"从零搭建\" | → EXPERT |\r\n\r\n---\r\n\r\n## 评分原理\r\n\r\n1. **关键词匹配** — 每个维度有中英文关键词库。匹配使用 soft-max 累积：`score = 1 - ∏(1 - wᵢ)`，自然趋近于 1.0。\r\n\r\n2. **长度评分** — 字符数到 0-1 的分段线性映射。\r\n\r\n3. **加权求和** — `rawSum = Σ(维度分数 × 权重)`\r\n\r\n4. **Sigmoid 校准** — `calibrated = σ(rawSum)`，参数 `k=4, midpoint=0.5`\r\n\r\n5. **Tier 映射** — 校准后的分数通过阈值映射到对应 Tier。\r\n\r\n---\r\n\r\n## 开发\r\n\r\n```bash\r\ngit clone https://github.com/HackSing/claw-router.git\r\ncd claw-router\r\nnpm install\r\nnpm test\r\n```\r\n\r\n---\r\n\r\n## 许可证\r\n\r\n[AIWare Community License](LICENSE) © aiwaretop\r\n","readmeFilename":"README.zh-CN.md"}