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

@draht/router

v2026.7.13-1

Published

Role-based model routing with direct API calls, auto-fallback, and cost tracking

Readme

@draht/router

Role-based model routing with direct API calls, automatic fallback, and cost tracking.

Overview

The router maps task roles to LLM provider/model combinations with ordered fallback chains. No OpenRouter — direct API calls only for minimal latency.

Configuration

Config is loaded from (in priority order):

  1. .draht/router.json (project-level)
  2. ~/.draht/router.json (global)
  3. Built-in defaults

Example .draht/router.json

{
  "architect": {
    "primary": { "provider": "anthropic", "model": "claude-opus-4-6" },
    "fallbacks": [{ "provider": "google", "model": "gemini-2.5-pro" }]
  },
  "implement": {
    "primary": { "provider": "anthropic", "model": "claude-sonnet-4-6" },
    "fallbacks": [
      { "provider": "openai", "model": "gpt-5.2" },
      { "provider": "deepseek", "model": "deepseek-v3" }
    ]
  }
}

Default Role Mapping

| Role | Primary | Fallbacks | |------|---------|-----------| | architect | anthropic/claude-opus-4-6 | google/gemini-2.5-pro | | implement | anthropic/claude-sonnet-4-6 | openai/gpt-5.2 → deepseek/deepseek-v3 | | boilerplate | deepseek/deepseek-v3 | google/gemini-2.5-flash | | quick | google/gemini-2.5-flash | deepseek/deepseek-v3 | | review | anthropic/claude-sonnet-4-6 | — | | docs | openai/gpt-5.2 | anthropic/claude-sonnet-4-6 |

CLI Usage

# Show current configuration
draht router show

# Set model for a role
draht router set implement anthropic/claude-sonnet-4-6 --fallback openai/gpt-5.2,deepseek/deepseek-v3

# Test resolution (dry-run)
draht router test
draht router test architect

# View cost summary
draht router cost

Fallback Behavior

When the primary model fails with a retryable error (429, 5xx, timeout), the router automatically tries the next model in the fallback chain. Non-retryable errors (401, 400) are thrown immediately.

Cost Tracking

Every API call is logged to .draht/cost-log.jsonl with:

  • Timestamp, role, provider/model
  • Input/output token counts
  • Estimated cost in USD
  • Session ID

Coding Agent Extension

import { createRouterExtension } from "@draht/router/extension";

const ext = createRouterExtension();
const model = ext.selectModel("implementation"); // → anthropic/claude-sonnet-4-6
const chain = ext.selectModelWithFallbacks("architecture"); // → full fallback chain

Task types are automatically mapped to roles:

  • planning, architecture → architect
  • implementation, coding → implement
  • scaffold, boilerplate → boilerplate
  • question, quick → quick
  • review, pr-review → review
  • documentation, readme → docs