shipwithjev

Catalog / Tools & apps

0337GitHub

hono-jev-router

Routes Hono HTTP requests by meaning.

yusukebe/hono-jev-routerREADME ↗
# hono-jev-router

Route HTTP requests by meaning.

`hono-jev-router` is an experimental router for [Hono](https://hono.dev). Instead of a method and a path, you describe a request in plain words, and [Jev](https://typesafe.ai) by TypeSafe AI decides which description fits the incoming request.

```ts
import { Hono } from 'hono'
import { JevRouter } from 'hono-jev-router'

const app = new Hono({
  router: new JevRouter({ apiKey: process.env.TYPESAFE_API_KEY }),
})

app.on('jev', 'a request from an AI agent', (c) => {
  return c.text('# Documentation', 200, { 'Content-Type': 'text/markdown' })
})

app.on('jev', 'a request from a human browser', (c) => {
  return c.html('<h1>Documentation</h1>')
})

app.on('jev', 'suspicious automated traffic', (c) => {
  return c.text('Forbidden', 403)
})

export default app
```

> [!WARNING]
> This is an experiment. Every semantically routed request calls a model, so it adds latency and cost, and the answer is a probability, not a guarantee.

## Before you use it

- **Do not use it for authentication or authorization.** The request is the input of the model, so whoever sends the request can try to steer the answer. `'suspicious automated traffic'` is a heuristic, not a security boundary.
- **Requests are sent to a third party.** The method, URL, headers and the first `maxBodyLength` bytes of a textual body go to Jev. The values of `Authorization`, `Cookie`, `Proxy-Authorization`, `X-API-Key` and `X-Auth-Token` are replaced with `[redacted]`. Change the list with `redactHeaders`.
- **Every semantically routed request is a model call you pay for.** Put a rate limit in front of it.

## Install

```bash
npm i hono-jev-router
```

## How it works

```
HTTP Request → JevRouter → Jev: "does the request match this description?" → first match → 

Also filed under Tools & apps

  1. 0573

    Support chat: agent offered a human escalation path

    A frustrated customer hits a bot loop twice; the judge checks whether a human handoff was offered.

    everyai-com · Tools & apps

  2. 0572

    Subscription cancel: effective date is explicit

    An agent cancels a subscription; the judge checks the exact date the cancellation takes effect.

    everyai-com · Tools & apps

  3. 0571

    Sales quote: numbers match the official price list

    An agent quotes $29/seat against a price list; the judge checks the quote matches exactly.

    everyai-com · Tools & apps

  4. 0570

    Refund chat: agent stated the amount before issuing it

    A support agent issues a $42.50 refund; the judge checks the exact amount was stated before the refund was confirmed.

    everyai-com · Tools & apps