npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openclaw-intent-router

v1.0.0

Published

Intent Router - The Search Layer for Agent Capabilities. Intelligent routing system that matches user intents to the most appropriate agent skills and capabilities.

Downloads

85

Readme

Intent Router

The Search Layer for Agent Capabilities

Intelligent routing system that analyzes user intents and matches them to the most appropriate agent skills and capabilities.


What is Intent Router?

Intent Router is a capability discovery and routing framework for AI agents. It solves the fundamental problem: "Given a user's intent, which agent skill should handle this request?"

Think of it as a smart dispatcher that:

  • Analyzes natural language intents
  • Matches intents to registered skills
  • Routes requests to the best-fit capability
  • Provides confidence scores and fallbacks

Core Concepts

1. Intent

A user's goal expressed in natural language.

{
  text: "I need to analyze this image for objects",
  context: { imageUrl: "...", format: "jpg" },
  priority: "high"
}

2. Skill

A discrete capability that an agent can perform.

{
  name: "image-object-detection",
  description: "Detect and classify objects in images",
  triggers: ["detect objects", "identify items", "what's in this image"],
  parameters: { imageUrl: string, threshold?: number },
  execute: async (params) => { ... }
}

3. Router

The matching engine that connects intents to skills.

const result = await router.route("what objects are in this photo?");
// => { skill: "image-object-detection", confidence: 0.95 }

Quick Start

Installation

npm install openclaw-intent-router

Basic Usage

import { IntentRouter, Skill } from 'openclaw-intent-router';

// 1. Create router
const router = new IntentRouter();

// 2. Register skills
router.registerSkill({
  name: 'weather-lookup',
  description: 'Get current weather for a location',
  triggers: ['weather', 'temperature', 'forecast'],
  execute: async (params) => {
    return await fetchWeather(params.location);
  }
});

// 3. Route intent
const result = await router.route('What is the weather in Paris?');

// 4. Execute matched skill
const response = await result.skill.execute(result.params);

Features

Intelligent Matching

Multiple matching strategies:

  • Keyword matching - Trigger words and phrases
  • Semantic similarity - Embedding-based intent understanding
  • Context awareness - Previous conversation history
  • Parameter extraction - Automatic entity recognition
router.route("book a flight to Tokyo next Tuesday")
// => Skill: travel-booking
// => Params: { destination: "Tokyo", date: "2024-01-16" }

Confidence Scoring

Every match includes a confidence score:

{
  skill: "weather-lookup",
  confidence: 0.95,
  alternativeSkills: [
    { skill: "general-search", confidence: 0.45 }
  ]
}

Fallback Handling

router.setFallback({
  threshold: 0.6,  // Minimum confidence
  handler: async (intent) => {
    return "I'm not sure how to help with that. Can you rephrase?";
  }
});

Middleware & Hooks

// Pre-routing hook
router.use('before-route', (intent) => {
  console.log('Processing:', intent.text);
});

// Post-execution hook
router.use('after-execute', (result) => {
  logAnalytics(result);
});

Architecture

┌─────────────────────────────────────────────┐
│           User Intent (Natural Language)    │
└──────────────────┬──────────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────────┐
│         Intent Analyzer                     │
│  - Tokenization                             │
│  - Entity Extraction                        │
│  - Context Enrichment                       │
└──────────────────┬──────────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────────┐
│         Skill Matcher                       │
│  - Keyword Matching                         │
│  - Semantic Similarity                      │
│  - Confidence Scoring                       │
└──────────────────┬──────────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────────┐
│         Router Decision                     │
│  - Best Skill Selection                     │
│  - Parameter Binding                        │
│  - Fallback Handling                        │
└──────────────────┬──────────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────────┐
│         Skill Execution                     │
│  - Input Validation                         │
│  - Execute Handler                          │
│  - Response Formatting                      │
└─────────────────────────────────────────────┘

Project Structure

src/
├── core/
│   ├── types.ts           # Core type definitions
│   ├── router.ts          # Main routing engine
│   ├── intent-analyzer.ts # Intent parsing & analysis
│   └── skill-matcher.ts   # Skill matching algorithms
│
├── skills/
│   ├── base.ts            # Base skill class
│   └── registry.ts        # Skill registration system
│
├── matchers/
│   ├── keyword.ts         # Keyword-based matching
│   ├── semantic.ts        # Embedding-based matching
│   └── hybrid.ts          # Combined strategy
│
└── cli/
    └── index.ts           # CLI interface

config/
└── skills.json            # Skill definitions

examples/
├── basic-router.ts
├── custom-skill.ts
└── advanced-matching.ts

Configuration

Router Configuration

const router = new IntentRouter({
  matchingStrategy: 'hybrid',       // 'keyword' | 'semantic' | 'hybrid'
  confidenceThreshold: 0.6,
  maxAlternatives: 3,
  enableContextTracking: true,
  logLevel: 'info'
});

Skill Configuration

{
  "skills": [
    {
      "name": "code-generator",
      "description": "Generate code from natural language descriptions",
      "triggers": ["write code", "generate function", "create class"],
      "parameters": {
        "language": { "type": "string", "required": true },
        "description": { "type": "string", "required": true }
      },
      "examples": [
        "write a Python function to sort a list",
        "generate a React component for a button"
      ]
    }
  ]
}

Advanced Usage

Custom Matching Strategy

import { BaseMatcher } from 'openclaw-intent-router';

class CustomMatcher extends BaseMatcher {
  async match(intent: Intent, skills: Skill[]): Promise<MatchResult> {
    // Your custom matching logic
    return {
      skill: bestSkill,
      confidence: score,
      params: extractedParams
    };
  }
}

router.setMatcher(new CustomMatcher());

Skill Composition

// Create composite skill
const complexSkill = router.composeSkills(
  'multi-step-task',
  ['skill-a', 'skill-b', 'skill-c'],
  {
    strategy: 'sequential',  // or 'parallel'
    onError: 'rollback'
  }
);

Context Management

// Maintain conversation context
const session = router.createSession();

await session.route("What's the weather?");
await session.route("How about tomorrow?");  // Uses context
await session.route("And in Tokyo?");        // Inherits location context

CLI Usage

# Start interactive mode
intent-router interactive

# Route a single intent
intent-router route "analyze this image for sentiment"

# List registered skills
intent-router skills

# Test skill matching
intent-router test --intent "book a flight" --verbose

# Load skills from config
intent-router load --config ./skills.json

Use Cases

1. Multi-Agent Systems

Route user requests to specialized sub-agents (code, research, image, etc.)

2. Chatbot Frameworks

Determine which intent handler should process user messages

3. API Gateway

Intelligent routing to microservices based on request intent

4. Voice Assistants

Map voice commands to appropriate action handlers

5. Workflow Automation

Trigger automation based on natural language triggers


API Reference

IntentRouter

class IntentRouter {
  registerSkill(skill: SkillDefinition): void
  route(intent: string | Intent): Promise<RouteResult>
  execute(routeResult: RouteResult): Promise<any>
  setMatcher(matcher: BaseMatcher): void
  setFallback(config: FallbackConfig): void
  use(hook: string, handler: Function): void
}

Skill

interface Skill {
  name: string
  description: string
  triggers: string[]
  parameters?: ParameterSchema
  execute: (params: any) => Promise<any>
  validate?: (params: any) => boolean
}

Intent

interface Intent {
  text: string
  context?: Record<string, any>
  priority?: 'low' | 'medium' | 'high'
  timestamp?: Date
}

Examples

Check the examples/ directory for:

  • Basic routing setup
  • Custom skill creation
  • Advanced matching strategies
  • Multi-turn conversations
  • Error handling patterns

Contributing

Contributions welcome! See CONTRIBUTING.md


License

MIT


Links


Route smarter. Execute faster. Build better agents.