← 返回 Skills 市场
pathemata-mathemata

Clawhub Skill

作者 pathemata-mathemata · GitHub ↗ · v0.1.4
cross-platform ⚠ suspicious
1691
总下载
0
收藏
2
当前安装
5
版本数
在 OpenClaw 中安装
/install clawhub-skill-2
功能描述
Configure, run, and troubleshoot the OpenRouter hardware-aware classifier router (wizard setup, local model, routing, and dashboard).
使用说明 (SKILL.md)

Xrouter

Xrouter is an open-source inference router that sits between OpenClaw and your LLM providers. It uses a fast, hardware-aware classifier to route each request to the most cost-effective model that can handle the task.

This project is MIT licensed. See the MIT License.

Core Features

  • OpenAI-compatible reverse proxy at POST /v1/chat/completions.
  • 3-tier classifier (0 = cheap, 1 = medium, 2 = frontier) with early stream cutoff.
  • Hardware detection helper to recommend local engine.
  • Provider selection wizard to choose local and cloud endpoints.
  • Cache layer with Redis or in-memory LRU fallback.
  • Full cloud mode when local inference is not viable.
  • Token tracking dashboard at /dashboard.

Workflow

flowchart TD
  A["Client / OpenClaw request"] --> B["Router (OpenAI-compatible)"]
  B --> C{"Classifier enabled?"}
  C -->|No| F["Route to Frontier provider"]
  C -->|Yes| D["Classifier (0 / 1 / 2)"]
  D --> E{"Decision"}
  E -->|0| G["Route to Cheap provider"]
  E -->|1| M["Route to Medium provider"]
  E -->|2| F
  G --> H["Provider adapter (auto or explicit)"]
  M --> H
  F --> H
  H --> I["Upstream API call"]
  I --> J["Stream/Response back to client"]

Repository Layout

  • src/server.js: router and streaming proxy.
  • src/classifier.js: classifier call and retry logic.
  • src/config.js: configuration and env parsing.
  • src/cache.js: Redis + LRU cache.
  • src/token_tracker.js: token tracking.
  • scripts/check_hw.js: hardware detection.
  • scripts/configure_providers.js: interactive provider setup.

Requirements

  • Node.js 20+.
  • Local classifier engine (optional).
  • A frontier provider endpoint (required).

Quickstart

  1. Install dependencies.
  2. (Optional) Start a local model server.
  3. Run the configuration wizard.
  4. Start the router.
npm install
npm run configure
npm run dev

How To Use

  1. Start your local model server (optional but recommended).
  2. Run the wizard to configure providers and models.
  3. Start the router.
  4. Send OpenAI-compatible requests to the router.
  5. Inspect routing decisions in response headers or the dashboard.

Example local setup (Ollama):

ollama pull llama3.1
ollama run llama3.1

Run the wizard:

npm run configure

Start the router:

npm run dev

Test a request:

curl -i http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"any","messages":[{"role":"user","content":"Fix this sentence: I has a apple."}]}'

Look for these headers:

  • X-Xrouter-decision: 0, 1, or 2.
  • X-Xrouter-upstream: cheap, medium, or frontier.

Open the dashboard:

  • http://localhost:3000/dashboard

Raw usage JSON:

  • http://localhost:3000/usage

Provider Selection (Terminal Wizard) Run:

npm run configure

The wizard:

  • Scans hardware and recommends a local engine.
  • Suggests a local classifier model.
  • Lets you choose provider base URLs, API keys, and model overrides for cheap/medium/frontier routes.
  • Writes upstreams.json and optionally updates .env.

Quick Start Mode

  • If your machine can run a local model, you can choose Quick Start.
  • Quick Start auto-configures the local classifier.
  • Cheap route always uses the same local model as the classifier to avoid Ollama model swapping.
  • You only need to choose medium and frontier providers/models.
  • On Apple Silicon (Ollama), the wizard lists installed Ollama models and can auto-download a recommended model.

Routing Behavior

  • The classifier is called for each uncached request.
  • The first 0, 1, or 2 token returned decides the route.
  • If classification fails, the router defaults to the frontier route.
  • When the classifier is enabled, cheap, medium, and frontier routes must be configured.

Compatibility

  • The router accepts OpenAI-style requests and translates when needed.
  • Provider type can be explicit (xrouter, openai_compatible, openai, anthropic, gemini, cohere, azure_openai, mistral, groq, together, perplexity) or auto.
  • auto infers the provider adapter from the base URL or API key.
  • Providers that expose OpenAI-compatible endpoints use the openai_compatible adapter.
  • Anthropic/Gemini/Cohere streaming is translated into OpenAI-style SSE chunks.
  • Non-OpenAI adapters currently support text-only messages and basic sampling params (temperature/top_p/stop).

Token Tracking Dashboard

  • GET /usage: returns cumulative token usage for cheap, medium, and frontier.
  • GET /dashboard: UI that displays token split and totals.
  • Local usage is counted inside cheap when cheap uses the local model.

Environment Summary

  • HOST: bind host, default 0.0.0.0.
  • PORT: bind port, default 3000.
  • ROUTER_API_KEY: require Authorization: Bearer \x3Ckey>.
  • LOG_LEVEL: log level (debug/info/warn/error).
  • LOG_TO_FILE: set true to write logs to files.
  • LOG_DIR: directory for log files (default ./logs).
  • CLASSIFIER_ENABLED: set false to disable local classification.
  • CLASSIFIER_BASE_URL: OpenAI-compatible classifier endpoint.
  • CLASSIFIER_MODEL: classifier model name.
  • CLASSIFIER_SYSTEM_PROMPT: classifier prompt (single line).
  • CLASSIFIER_TIMEOUT_MS: classifier timeout.
  • CLASSIFIER_FORCE_STREAM: force streaming classifier request.
  • CLASSIFIER_WARMUP: warm the classifier on server start.
  • CLASSIFIER_WARMUP_DELAY_MS: delay before warmup request (ms).
  • CLASSIFIER_KEEP_ALIVE_MS: keep-alive interval for classifier warmup (ms).
  • CLASSIFIER_LOADING_RETRY_MS: delay between retries when the model is loading.
  • CLASSIFIER_LOADING_MAX_RETRIES: max retries when the model is loading.
  • CHEAP_BASE_URL: optional, defaults to classifier base URL.
  • CHEAP_API_KEY: cheap provider API key.
  • CHEAP_MODEL: optional model override for cheap route.
  • CHEAP_PROVIDER: provider type for cheap route (auto if empty).
  • CHEAP_HEADERS: optional JSON headers for cheap provider (stringified object).
  • CHEAP_DEPLOYMENT: Azure deployment override for cheap route.
  • CHEAP_API_VERSION: Azure API version override for cheap route.
  • MEDIUM_BASE_URL: required when classifier is enabled.
  • MEDIUM_API_KEY: medium provider API key.
  • MEDIUM_MODEL: optional model override for medium route.
  • MEDIUM_PROVIDER: provider type for medium route (auto if empty).
  • MEDIUM_HEADERS: optional JSON headers for medium provider (stringified object).
  • MEDIUM_DEPLOYMENT: Azure deployment override for medium route.
  • MEDIUM_API_VERSION: Azure API version override for medium route.
  • FRONTIER_BASE_URL: OpenAI-compatible frontier endpoint.
  • FRONTIER_API_KEY: frontier API key.
  • FRONTIER_MODEL: optional model override for frontier route.
  • FRONTIER_PROVIDER: provider type for frontier route (auto if empty).
  • FRONTIER_HEADERS: optional JSON headers for frontier provider (stringified object).
  • FRONTIER_DEPLOYMENT: Azure deployment override for frontier route.
  • FRONTIER_API_VERSION: Azure API version override for frontier route.
  • REDIS_URL: if set, enables Redis cache.

Local Model Installation & Run Guides Ollama (best for Mac, easiest cross-platform)

  • Install: Ollama Quickstart
  • Pull a model: ollama pull llama3.1
  • Run: ollama run llama3.1
  • Base URL: http://localhost:11434
  • Router config: CLASSIFIER_BASE_URL=http://localhost:11434 CLASSIFIER_MODEL=llama3.1

vLLM (NVIDIA GPU)

  • OpenAI server: vLLM OpenAI Server
  • Example: vllm serve NousResearch/Meta-Llama-3-8B-Instruct --dtype auto --api-key token-abc123
  • Base URL: http://localhost:8000
  • Router config: CLASSIFIER_BASE_URL=http://localhost:8000 CLASSIFIER_MODEL=NousResearch/Meta-Llama-3-8B-Instruct

TensorRT-LLM (NVIDIA, max speed)

  • Repo: TensorRT-LLM
  • Server: trtllm-serve
  • Base URL: http://\x3Chost>:\x3Cport>
  • Router config: CLASSIFIER_BASE_URL=http://\x3Chost>:\x3Cport> CLASSIFIER_MODEL=\x3Cyour model>

llama.cpp (CPU/AMD fallback)

  • Repo: llama.cpp
  • Example: llama-server -m model.gguf --port 8080
  • Base URL: http://localhost:8080
  • Router config: CLASSIFIER_BASE_URL=http://localhost:8080 CLASSIFIER_MODEL=\x3Cgguf model name>

Docker Build and run the router with Redis:

docker compose -f deploy/docker-compose.yml up --build

Hardware Detection Run:

npm run check-hw

This prints the recommended engine:

  • tensorrt-llm for large NVIDIA GPUs.
  • vllm for standard NVIDIA GPUs.
  • mlx for Apple Silicon.
  • llama.cpp for CPU/AMD fallback.

Model List Fetching

  • The wizard queries provider model list endpoints when possible.
  • OpenAI-compatible: /v1/models
  • Anthropic: /v1/models
  • Gemini: /v1beta/models
  • Cohere: /v1/models
  • If listing fails, the wizard falls back to scripts/cloud_model_catalog.json.

Star History

Star History Chart

安全使用建议
This skill appears to be an instruction-only router (Xrouter) whose documentation expects you to run 'npm install' and a configure wizard that will scan hardware and ask for provider API keys, then write configuration files (.env, upstreams.json) and run a local server. That is coherent with its purpose, but there are two important caution points: (1) the registry metadata does not declare the many env vars and credentials the SKILL.md expects — treat that as an inconsistency; (2) the bundle contains no code or source URL/homepage, so running 'npm install' will pull code from upstream npm/github repositories you cannot verify from this package alone. Before installing: verify the upstream repository and package.json (source, maintainer, dependency list), run the wizard in an isolated environment or container, avoid supplying high-privilege credentials (use limited API keys or test accounts), bind the service to localhost (HOST=127.0.0.1) if you don't want it public, and inspect generated files (.env/upstreams.json) before placing real secrets there. If you cannot verify the source or dependency tree, avoid installing or run it in a tightly sandboxed environment.
功能分析
Type: OpenClaw Skill Name: clawhub-skill-2 Version: 0.1.4 The skill is classified as suspicious due to its inherent high-risk capabilities, specifically the explicit instructions in SKILL.md for the agent to handle and store sensitive API keys for LLM providers, and to modify local configuration files like `.env` and `upstreams.json` via `npm run configure`. While these actions are plausibly needed for the stated purpose of configuring an LLM inference router, they represent significant file system and credential management permissions that could be abused if the underlying scripts were malicious. No clear evidence of intentional harmful behavior (e.g., data exfiltration, unauthorized remote control, or stealthy prompt injection) is present in the provided documentation.
能力评估
Purpose & Capability
The SKILL.md describes an OpenRouter/Xrouter that needs provider endpoints, API keys, and optional local models — these capabilities align with the stated purpose. However, the registry metadata claims no required env vars or primary credential while the documentation explicitly references multiple API keys and a required 'frontier provider endpoint' (ROUTER_API_KEY, CHEAP_API_KEY, etc.). The missing declaration in metadata is an inconsistency.
Instruction Scope
The runtime instructions stay within the router's scope: run npm install, run a configure wizard that scans local hardware and writes upstreams.json/.env, start the server, and expose local endpoints (health, usage, dashboard). The wizard scanning hardware and listing local Ollama models is expected for a hardware-aware router. No instructions are present that obviously exfiltrate data to unexpected external endpoints.
Install Mechanism
This is an instruction-only skill (no bundled code). It instructs the user to run 'npm install' which will pull code and dependencies from the npm ecosystem and then run local scripts. Because the skill bundle provides no source or homepage, the actual code and dependencies that will be installed are unknown to reviewers — this introduces supply-chain risk even though no install spec is bundled.
Credentials
The SKILL.md lists many environment variables including provider API keys and a required frontier provider endpoint; these are proportionate for a router. The concern is that the registry metadata declares no required env vars or primary credential, so sensitive credentials are not declared at install/registration time. The configure wizard will prompt to store keys in .env/upstreams.json, which could persist secrets locally — users should be aware.
Persistence & Privilege
The skill does not request always:true, does not modify other skills, and is instruction-only. It will write local configuration files (.env, upstreams.json) and logs in the working directory if you run its wizard — this is expected behavior for a local router and within its scope.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install clawhub-skill-2
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /clawhub-skill-2 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.4
Version 0.1.4 - Renamed the router and headers from "openrouter" to "Xrouter". - Updated documentation and references throughout SKILL.md to reflect the new "Xrouter" naming. - Adjusted compatibility instructions to include the new provider type "xrouter". - No functional changes; updates are documentation and naming consistency only.
v0.1.3
Version 0.1.3 - Documentation in SKILL.md has been updated. - No changes to functionality or code; content is unchanged except for documentation formatting or minor edits.
v0.1.2
clawhub-skill-2 v0.1.2 changelog - Updated documentation in SKILL.md for clarity and completeness. - No code or feature changes in this release.
v0.1.1
- Major rewrite and expansion of SKILL.md with new information and usage guides. - Added comprehensive feature overview, workflow diagrams, and compatibility details. - Described repository layout, new provider selection wizard, and token tracking dashboard. - Included full environment variable documentation and local model setup guides. - Outlined routing logic, quick start mode, and troubleshooting tips for installation and operation.
v0.1.0
- Initial release of the OpenRouter Router skill. - Provides setup, configuration, and troubleshooting guidance for the OpenRouter hardware-aware classifier router. - Includes quick workflow steps for installation, setup, and running the router. - Documents key operational rules (environment config, classifier routing behavior, and local model requirements). - Offers troubleshooting tips for common issues and links to further usage references.
元数据
Slug clawhub-skill-2
版本 0.1.4
许可证
累计安装 5
当前安装数 2
历史版本数 5
常见问题

Clawhub Skill 是什么?

Configure, run, and troubleshoot the OpenRouter hardware-aware classifier router (wizard setup, local model, routing, and dashboard). 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1691 次。

如何安装 Clawhub Skill?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install clawhub-skill-2」即可一键安装,无需额外配置。

Clawhub Skill 是免费的吗?

是的,Clawhub Skill 完全免费(开源免费),可自由下载、安装和使用。

Clawhub Skill 支持哪些平台?

Clawhub Skill 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Clawhub Skill?

由 pathemata-mathemata(@pathemata-mathemata)开发并维护,当前版本 v0.1.4。

💬 留言讨论