v0.2.0 — NOW ON PYPI

Tool routing for
AI agents

Two-stage embedding router that picks the right CLI from hundreds of tools in ~36 ms with ~150 tokens. Open source, multilingual, no fine-tuning required.

~36msP50 LATENCY
100%TOP-3 ON ADVERSARIAL
~150TOKENS / CALL
$ pip install clibrary-hub

Source on GitHub · MIT licensed · Python 3.10+

HUMAN · PROCESS VIEW

Call it directly
See what comes back

Use the router from a Python REPL, a notebook, or your own tool. You type an intent, the terminal returns a structured tool-call object — cli name, params, confidence. You run the command yourself. No magic.

See the source
input · what you type
terminal · what comes back
LLM AGENT · USER VIEW

Wrap the same call
for a real conversation

Inside an agent loop the router still returns a structured object — but the user never sees raw JSON. The agent reads choices, picks one, runs the tool, and reports back in plain language. No prompt-stuffing, no token blowup.

Write a manifest
agent

Start building today

Developer quickstart

Install the package, build the index, route your first intent. Three steps, about five minutes.

⏱ ~5 min
View on PyPI
# pip install clibrary-hub
# clibrary-build-index --manifest-dir ./manifests

from clibrary_hub import router

result = router.route("convert demo.mp4 to a 10-fps gif")

print(result["cli"])         # 'video-to-gif'
print(result["params"])      # {'input': 'demo.mp4', ...}
print(result["confidence"])  # 0.94
from clibrary_hub import validator

r = validator.validate_file("manifests/data/sql-runner.json")

if not r.ok:
    for e in r.errors:   print("ERROR:", e)
    for w in r.warnings: print("WARN: ", w)

# Or validate every manifest under a tree:
results = validator.validate_dir("manifests/")
from clibrary_hub import router
import subprocess

def handle_user(message: str):
    plan = router.route(message)

    if plan["action"] == "clarify":
        # Let your LLM choose from plan["choices"]
        plan = llm_pick(plan["choices"], chat_history)

    cmd = [plan["cli"]] + flatten(plan["params"])
    return subprocess.run(cmd, check=True)

WHY EMBEDDING ROUTING

Stuffing tools
into prompts breaks at scale

When an agent has 100+ tools, the LLM has to read every description before picking one. Token cost, latency, and accuracy all degrade.

STUFF ALL TOOLS IN PROMPT

Tokens per call3,000–50,000
Latency2–5 s
Accuracy at 500 tools~60–70%
Cost scales withtool count

CLIBRARY-HUB ROUTING

Tokens per call~150 (fixed)
Latency~36 ms
Accuracy at 500 tools82–92% top-1
Cost scales withflat

PERFORMANCE

Measured, not promised

Evaluated against 2,050 queries spanning 559 CLI tools (CLIbrary + MCP). Numbers from the latest router build (clibrary_top3 strategy, multilingual-e5-base).

EVAL SETSIZETOP-1TOP-3
in_domain50086.8%88%
paraphrase1,50081.8%83.4%
adversarial20484.3%100%

Adversarial set hardened by 3 rounds of intent-trigger patching. No model fine-tuning involved. Full benchmark →


HOW IT WORKS

Two stages,
three indices

Stage 1 retrieves candidate CLIs via FAISS. Stage 2 matches the closest example template. ~80% of queries skip the LLM entirely.

STAGE 1 · CLI INDEX

Mean-pooled candidate retrieval

Each CLI's intent_triggers are embedded and mean-pooled into a single vector. FAISS returns top-3 candidates. Re-ranked using MaxSim over the trigger_index.

STAGE 2 · EXAMPLE INDEX

Template matching with A/B split

Find the closest example.query within the winning CLI. If similarity ≥ 0.85, fill the template (Path A — no LLM). Else, ask a small LLM to extract params (Path B).

CLARIFY GATE

Ask, don't guess

If top-1 confidence is low and the gap to top-2 is small, return all three candidates and let the agent ask the user. Reduces silent mis-routes to near zero.


39 categories · 507 CLIs · all offline-first

507 tools · 39 categories · MIT licensed

Every tool is pure offline — no LLM dependency, no cloud credentials. Each ships with manifest, implementation, README, and pinned requirements.

OFFICE · 20 tools

Time · Calendar · Tasks

countdown tz-convert time-track cal-merge slot-find cal-conflict recur-helper todo-merge quick-idea deadline-board morning-boot omni-search +8
DATA · 12 tools

CSV · JSON · Schema

csv-stat csv-sql csv-infer pivot-quick data-transcode data-join json-path schema-brief schema-diff term-plot corr-matrix data-profile
DEVOPS · 12 tools

Code quality · Git · Deploy

lint-guard test-gap sec-scan dead-code code-dedupe commit-fmt changelog-bot api-compat deploy-rollback flag-cli ssl-renew-check pipeline-tpl
MEDIA · 20 tools

Video · Image · Audio

video-to-gif video-compress video-trim auto-subtitle img-shrink bg-remove img-ocr audio-stt text-tts exif-clean gif-opt +9
WEB · 12 tools

Fetch · Crawl · Parse

web-fetch headless-fetch rss-fold uptime-ping link-check sitemap-gen ld-extract page-archive page-diff polite-crawler api-sniff dataset-find
SMART-HOME · 20 tools

Lights · Sensors · IoT

scene-flip light-schedule lock-log solar-track pet-feed blind-schedule nas-health home-traffic home-backup cam-privacy rule-conflict +9
COMING security finance science

Browse the registry on GitHub — clone the repo, run clibrary-build-index --manifest-dir ./manifests, and the router picks them up.


The router is only
as smart as its tools

Other tool routers ship a fixed catalog. clibrary-hub ships a format. Anyone can describe a CLI in 10 minutes and the router picks it up.

  • One JSON file per tool — no Python registration, no class hierarchy
  • 5+ intent_triggers in any languages your users speak
  • Schema-validated offline by clibrary_hub.validator — no PR needed
  • 3–5 examples become Path-A templates — zero LLM cost on common queries
manifests/media/video-to-gif.json
{
  "name":        "video-to-gif",
  "category":    "media",
  "description": "Convert a video file to an animated GIF",

  "intent_triggers": [
    "convert mp4 to gif",
    "turn this video into a gif",
    "export the first 5 seconds as a gif",
    "把影片轉成 gif",
    "幫我做一個動圖"
  ],

  "input_schema": {
    "input":  { "type": "string", "required": true },
    "fps":    { "type": "integer", "default": 15 }
  },

  "examples": [...] // 3-5 templates
}

10 categories · 504 manifests so far · MIT-licensed registry