Sign In

@toolroute/hook

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toolroute/hook

Auto-route every agent task through ToolRoute. Install once, every task gets the best tool and model recommendation.

Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
8
60%
Maintainers
1
Weekly downloads
 
Created
Source

@toolroute/hook

Auto-route every agent task through ToolRoute. Install once — every task gets the best MCP server and LLM model recommendation, automatically.

Install

npm install @toolroute/hook

Quick Start

import { createHook } from '@toolroute/hook'

const hook = createHook({
  agentName: 'my-agent',
  verbose: true, // logs routing decisions
})

// Register (optional, earns 2x credits)
await hook.register()

// Wrap any task — routing + reporting happens automatically
const result = await hook.run('scrape competitor pricing data', async (routing) => {
  console.log(`Best tool: ${routing.skillName}`) // e.g., "Firecrawl MCP"
  console.log(`Best model: ${routing.model}`)    // e.g., "haiku-3.5"
  console.log(`Confidence: ${routing.confidence}`)

  // ... your actual task logic here ...
  return { prices: [29, 49, 99] }
})

console.log(result.data)          // { prices: [29, 49, 99] }
console.log(result.executionMs)   // 1847
console.log(result.creditsEarned) // 5

Just Route (no wrapper)

const routing = await hook.route('draft an email to a client')
// routing.skill → "gmail-mcp"
// routing.model → "haiku-3.5"
// routing.confidence → 0.87

A/B Testing

// Set bypass: true to skip routing — compare routed vs unrouted performance
const hook = createHook({ bypass: Math.random() > 0.5 })

How It Works

  • Before your task — calls POST /api/route with your task description
  • Returns routing context — best skill, model, alternatives, confidence score
  • You execute — use the recommendation (or ignore it)
  • After your task — reports outcome to ToolRoute (fire-and-forget)
  • Earns credits — 3-10 credits per report, 2x if verified

Keywords

toolroute

FAQs

Package last updated on 26 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts