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

pi-typesafe-router

v0.2.1

Published

Opt-in Jev task routing for Pi with TypeSafe, Cloudflare, Vercel, and OpenRouter backends and ordered preflight model fallbacks

Readme

pi-typesafe-router

Use Jev to classify requests and route them to the right model for the task.

Setup

Do not enable this alongside another automatic router.

Install via:

`pi install npm:pi-typesafe-router`

Choose a real provider/model in Pi first, then run:

/typesafe-router setup typesafe

This creates ~/.pi/agent/typesafe-router.json, initially off, using your selected model for all three routes. Edit the mappings, set TYPESAFE_API_KEY in the environment that launches Pi, and run /reload.

pi install npm:pi-typesafe-router.

Usage

Verify your configuration, then enable routing:

/typesafe-router doctor
/typesafe-router on

Doctor tests the classifier and configured models with synthetic requests, without sending your conversation, using tools, or changing the selected model. These checks may incur charges.

Run /typesafe-router help for a table explaining every command.

Configuration

Configuration examples are provided for TypeSafe, Cloudflare, Vercel, and OpenRouter.

To use one:

/typesafe-router setup [typesafe|cloudflare|vercel|openrouter]

| Backend | Credential | Model | | --------------------- | --------------------------------------------------------- | ------------------- | | TypeSafe | TYPESAFE_API_KEY | jev-1.13.0 | | Cloudflare AI Gateway | CLOUDFLARE_API_TOKEN, account and gateway IDs in config | typesafe/jev | | Vercel AI Gateway | AI_GATEWAY_API_KEY | typesafe-ai/jev | | OpenRouter | OPENROUTER_API_KEY | typesafe/jev-1.13 |

Project structure

  • src/classifier.ts: transport adapters and response validation.
  • src/config.ts, context.ts, routing.ts: schema, bounded text projection, and deterministic policy.
  • src/index.ts, settings.ts: Pi lifecycle, commands, cancellation, and global settings.
  • tests/: synthetic transport, policy, lifecycle, and real Pi SDK tests. No paid API calls.
  • infra/github/: Pulumi-managed repository settings and main ruleset.
  • docs/: architecture decision records (ADRs), recording implemented decisions and their tradeoffs.

Testing

Run npm run check for offline tests, lint, formatting, and typechecking.

npm install also installs the Lefthook pre-commit hook. Each commit formats and lints its staged files, applying safe fixes before the commit is created. CI runs the same formatting and lint checks as a required job in parallel with the test matrix.

E2E tests require the following variables to be set:

  • OPENROUTER_API_KEY
  • TYPESAFE_API_KEY
  • CLOUDFLARE_API_TOKEN
  • CLOUDFLARE_ACCOUNT_ID
  • CLOUDFLARE_GATEWAY_ID
  • AI_GATEWAY_API_KEY

Then:

TYPESAFE_ROUTER_LIVE_E2E=1 npm run test:e2e

License

MIT. Third-party models, services, and dependencies retain their own terms.