用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/dvcrn/openclaw-skills-marketplace --skill smart-router-skill命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | smart-router-skill |
| description | Smart Router Skill |
智能路由器是一个先进的模型调度系统,它超越了简单的关键词匹配,使用多维度分析来为每个消息选择最合适的模型。系统包含成本优化、自动模型扫描和性能监控功能。
# 1. 复制技能文件到OpenClaw技能目录
cp -r smart-router-skill /opt/homebrew/lib/node_modules/openclaw/skills/
# 2. 更新OpenClaw配置以启用技能
openclaw config patch --json '{"skills":{"entries":{"smart-router":{"enabled":true}}}}'
# 3. 重启OpenClaw
openclaw gateway restart
export OPENROUTER_API_KEY="your-openrouter-api-key"
export DEEPSEEK_API_KEY="your-deepseek-api-key"
cd /Users/nora/.openclaw/users/main/workspace
node enhanced-intent-router.js init
./test-integration.sh
node update-openclaw-config.js update
openclaw gateway restart
// 使用智能路由器路由消息
const { SmartIntentRouter } = require('./enhanced-intent-router.js');
const router = new SmartIntentRouter();
await router.initialize();
const decision = router.analyzeMessage("帮我写一个Python函数");
console.log(decision);
// 输出: { agentId: 'code-agent', model: '4sapi-anthropic/claude-sonnet-4-5-20250929', ... }
# 初始化路由器
node enhanced-intent-router.js init
# 分析消息路由
node enhanced-intent-router.js analyze "你的消息"
# 运行测试用例
node enhanced-intent-router.js test
# 查看性能指标
node enhanced-intent-router.js stats
# 生成详细报告
node enhanced-intent-router.js report
系统自动集成到OpenClaw,无需手动调用。所有消息都会经过智能路由器处理。
{
"routingRules": {
"priority": [
{
"name": "代码相关任务",
"conditions": {
"keywords": ["代码", "编程", "Python", "Java"],
"minLength": 10,
"maxLength": 5000
},
"agent": "code-agent",
"model": "4sapi-anthropic/claude-sonnet-4-5-20250929",
"priority": 100
}
],
"fallback": {
"agent": "free-agent",
要添加新的路由规则:
smart-router-config.jsonroutingRules.priority 数组中添加新规则系统包含以下自动化定时任务:
| 任务名称 | 时间 | 描述 |
|---|---|---|
| OpenRouter扫描 | 每天 6:00 | 扫描免费模型并更新配置 |
| 每日性能报告 | 每天 0:00 | 生成路由性能报告 |
| 每周成本分析 | 每周一 9:00 | 分析成本优化效果 |
| 配置备份 | 每天 23:30 | 备份配置和日志 |
| 规则优化检查 | 每天 12:00 | 检查并优化路由规则 |
class SmartIntentRouter {
// 初始化路由器
async initialize()
// 分析消息并返回路由决策
analyzeMessage(message, context)
// 获取性能指标
getMetrics()
// 生成详细报告
generateReport()
}
{
agentId: 'code-agent', // 目标代理ID
model: 'model-id', // 选择的模型
reasoning: false, // 是否启用推理模式
ruleName: '规则名称', // 匹配的规则名称
confidence: 0.95, // 置信度 (0-1)
reason: '匹配原因', // 路由原因
features: { ... }, // 消息特征分析
costOptimized: true // 是否成本优化
}
# 检查系统状态
node smart-router-maintenance.js health
# 运行每日维护
node smart-router-maintenance.js daily
# 运行每周维护
node smart-router-maintenance.js weekly
# 创建备份
node smart-router-maintenance.js backup
# 清理旧备份(保留30天)
node smart-router-maintenance.js clean-backups
# 检查配置文件
node enhanced-intent-router.js init
# 查看详细错误
OPENCLAW_DEBUG=1 node enhanced-intent-router.js init
# 检查API密钥
echo $OPENROUTER_API_KEY
# 手动运行扫描器
node openrouter-scanner.js
系统使用智能缓存减少重复计算。默认缓存TTL为3600秒,可根据使用情况调整:
{
"performanceSettings": {
"cacheEnabled": true,
"cacheTTL": 3600,
"maxResponseTime": 30000
}
}
enhanced-intent-router.js 中添加新功能可以扩展 analyzeMessage 方法添加自定义分析逻辑:
class CustomRouter extends SmartIntentRouter {
analyzeMessage(message, context) {
// 自定义分析逻辑
const features = this.extractCustomFeatures(message);
// 调用父类方法
return super.analyzeMessage(message, { ...context, customFeatures: features });
}
}
如有问题或建议:
技能作者:OpenClaw AI
最后更新:2026-02-15
许可证:MIT
状态:生产就绪 ✅