feat: integrate with Clawdbot for auto-routing and model provider#220
feat: integrate with Clawdbot for auto-routing and model provider#220johnlanni wants to merge 4 commits into
Conversation
…nsole API - Remove Console API calls from SKILL.md - Add configureAutoRouting function to modify model-router.yaml directly - Wait for container to generate config files before modification - Use sed to inject auto-routing configuration into model-router.internal.yaml - Backup original config file before modification - Remove unused ai-gateway-with-autorouting.sh script
- Use docker exec to modify model-router.internal.yaml inside container - Remove container restart requirement - Use docker cp for safer file modification (copy out, modify, copy back) - Trigger configuration reload by touching the file - Higress hot-reloads config from /data/wasmplugins/ automatically - Add example Python implementation for skill
Plugin fixes (index.ts): - Fix double prefix issue: check if modelId already starts with 'higress/' - Fix spinner reuse: create separate spinner (spin2) for fetching models - Add .trim() to autoRoutingDefaultModel input Plugin manifest fix (clawdbot.plugin.json): - Remove duplicate configSchema to avoid inconsistency with emptyPluginConfigSchema() Shell script fixes (get-ai-gateway.sh): - Add loadSavedConfig() to read ENABLE_AUTO_ROUTING from config on restart - Use awk instead of sed for cross-platform compatibility (macOS/Linux) - Add docker exec touch to trigger hot-reload without container restart - Create generic installFiles() to reduce duplication - Simplify user instructions in outputWelcomeMessage() - Save AUTO_ROUTING config to config file for persistence
|
Closing due to branch conflict. Replaced with new PR from feat/clawdbot-integration-v2. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| async function testGatewayConnection(gatewayUrl: string): Promise<boolean> { | ||
| try { | ||
| const response = await fetch(`${gatewayUrl}/v1/models`, { |
There was a problem hiding this comment.
Double /v1 suffix in URL paths breaks API
High Severity
The normalizeBaseUrl() function adds a /v1 suffix to URLs, but testGatewayConnection(), fetchAvailableModels(), and the provider config all append /v1 again. This creates malformed URLs like http://localhost:8080/v1/v1/models. The gateway connection test and model fetching will fail, and the baseUrl in the provider configuration will be incorrect.
Additional Locations (2)
| next | ||
| } | ||
| { print } | ||
| ' "$MODEL_ROUTER_FILE" > "$TEMP_FILE" |
There was a problem hiding this comment.
Duplicate autoRouting inserted on container recreation
Medium Severity
The awk script inserts an autoRouting block after matching modelToHeader: x-higress-llm-model without checking if one already exists. When a container is deleted and recreated (data folder persists, CONFIGURED_MARK exists), configureAutoRouting runs again on the existing YAML file that already has autoRouting. This inserts a duplicate block, producing invalid YAML with duplicate keys that would break configuration parsing.
| else | ||
| sed -i "$@" | ||
| fi | ||
| } |
There was a problem hiding this comment.
Unused sedInPlace function is dead code
Low Severity
The sedInPlace function is defined to provide cross-platform sed in-place editing for macOS vs Linux, but it is never called anywhere in the script. The script uses awk for YAML modifications instead. This dead code adds maintenance burden and confuses developers who may expect it to be used.
概述
本 PR 为 Higress AI Gateway 添加了与 Clawdbot 的深度集成,支持基于消息内容的自动路由功能,并将 Higress 作为统一的模型 provider 供 Clawdbot 使用。
主要改动
1. 改进安装脚本 (
all-in-one/get-ai-gateway.sh)~/clawd目录是否存在/data/wasmplugins/model-router.internal.yaml2. Clawdbot Plugin (
all-in-one/clawdbot-integration/plugin/)基于 API Key 认证方式的模型 provider 插件:
/v1/chat/completions接口higress/auto模型用于基于内容的路由clawdbot models auth login --provider higress配置3. Higress Auto Router Skill (
all-in-one/skill/higress-auto-router/)自然语言配置路由规则:
深入思考/deep thinking→ 推理模型写代码/code:→ 编码模型创意写作/creative:→ 创意写作模型/data/wasmplugins/model-router.internal.yaml使用方式
安装
cd all-in-one ./get-ai-gateway.sh安装向导会自动:
配置模型 Provider
配置自动路由规则
在 Clawdbot 中直接说:
Skill 会自动:
深入思考/deep thinkingmodel-router.internal.yaml文件使用自动路由
发送请求时使用
higress/auto作为模型:{ "model": "higress/auto", "messages": [ { "role": "user", "content": "深入思考 如何设计一个高并发系统?" } ] }Higress 会根据消息内容自动路由到合适的模型。
技术细节
配置文件修改
脚本会在容器启动后:
/data/wasmplugins/model-router.internal.yaml文件生成sed在modelToHeader行后插入 autoRouting 配置Plugin 配置
优势
注意事项
相关文档
@higress-group/higress-team 请 review,如有问题欢迎讨论!
Note
Medium Risk
Touches the installer/startup script and auto-edits
model-router.internal.yaml, so misconfiguration could break local gateway startup or routing behavior. Changes are scoped to optional Clawdbot/auto-routing paths and add new integration files rather than modifying core gateway runtime code.Overview
Adds a new Clawdbot integration for Higress AI Gateway, including a provider plugin that guides users through configuring gateway/console URLs, optional API key, and an editable model list (including
higress/autofor auto-routing), then patches Clawdbot configs to register the provider and enable the plugin.Enhances
get-ai-gateway.shto detect a local Clawdbot workspace, optionally enable auto-routing during setup, install the plugin/skill into Clawdbot directories, persist auto-routing settings indefault.cfg, and on start injectautoRoutingconfig intomodel-router.internal.yaml(with backup + reload trigger) and show updated usage instructions. Also adds documentation for thehigress-auto-routerskill that updates routing rules via natural language by editing the in-container YAML and reloading.Written by Cursor Bugbot for commit 9649654. This will update automatically on new commits. Configure here.