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

@lawfare/ragtime-client

v0.1.0

Published

Typed client for the RAGtime worker: every corpus route the public frontend calls, the Explorer turn stream, the corpus registry, and the deep-link grammar.

Readme

@lawfare/ragtime-client

The one owner of the connection to the RAGtime worker for the browser UXs. Framework-free: fetch is the only platform call. React glue stays per app.

Install: npm install @lawfare/ragtime-client. Published from packages/client of thomkav/ragtime-explorer under MIT; ES module only, types included.

import { createClient } from '@lawfare/ragtime-client'

const client = createClient({
  baseUrl: 'http://127.0.0.1:8787',                 // a local wrangler dev; production by default
  auth: { mode: 'demo', model: 'claude-haiku-4-5', password },
})

const registry = await client.registry()            // GET /corpus/registry, typed

let messages = [{ role: 'user', content: 'Which OLC opinions address removal without cause?' }]
let envelope: string | null = null

for await (const ev of client.explorer.turn({ phase: 'orient', messages, envelope })) {
  switch (ev.type) {
    case 'text':        render(ev.delta); break
    case 'tool_call':   trail.call(ev); break
    case 'tool_result': trail.result(ev); break
    case 'handoff':     if (ev.kind === 'workspace') trail.handoff(ev); break
    case 'cost':        meter.set(ev); break
    case 'phase':       if (ev.outcome === 'brief') briefCard.show(ev.brief); break
    case 'done':        ({ messages, envelope } = continueFrom(messages, ev)); break
  }
}

client.links.document({ slug: 'olc', id: 50 })      // '/corpus/olc/50'
client.links.fromCitation('rt://olc/50')            // the same; the only resolver of rt://
client.links.workspace({ slug: 'olc', q: 'removal' })
client.links.parse('/corpus/olc?q=removal')         // the only reader

What is in it

| Module | What | |---|---| | worker-client.ts | Every typed wrapper the public frontend's app/src/lib/worker-client.ts has, lifted as one file. Three edits: two path-alias imports made relative, the Provider union copied out of a React context, and the Vite environment read for the worker URL replaced by workerUrl(). | | auth-arg.ts | The AuthArg discriminated union (BYOK / paid / demo) and the body and header builders, unchanged. | | corpus-types.ts | The frontend's spokes/types.ts: CorpusSlug and the spoke descriptor types, unchanged. | | explorer.ts | POST /explorer/turn as AsyncIterable<ExplorerEvent> — one variant per event name in the contract — plus runExplorerTurn (the same turn, collected) and continueFrom. | | registry.ts | GET /corpus/registry, typed. | | links.ts | The deep-link grammar: workspace, document, fromCitation, parseCitation, and parse, the one reader. Byte-for-byte what the worker emits in handoff events for the same inputs. | | config.ts | Where the worker is. |

One worker URL per loaded module

createClient({ baseUrl }) configures the module; every function in worker-client.ts reads it at call time. A second createClient with a different baseUrl reconfigures all of them, not just its own handle. That is the lift's honest limit: the corpus functions were written against a module constant, and threading a client through a hundred call sites is the step past two consumers, along with an OpenAPI description of the worker.

Running it

npm install            # at the repo root
npm run check -w @lawfare/ragtime-client     # tsc --strict, sources and tests
npm test -w @lawfare/ragtime-client          # node --test; no network

The live test drives one orient turn against a running endpoint (about a cent of the explorer credential's daily bucket). It is skipped unless asked for:

EXPLORER_LIVE=1 op run --env-file=.env.op -- node --test test/live.test.ts          # local wrangler dev on :8787
EXPLORER_BASE=https://ragtimeproxy.benjamin-wittes.workers.dev EXPLORER_LIVE=1 …    # the deployed worker

Node 22.18+ runs the TypeScript tests directly (type stripping); the sources use only erasable syntax so the same files build with tsc to dist/ for consumers.

tool_result carries detail beside the one-line summary (item 5 of the design answers on ragtime-dev#168, contract §9 row 9): ExplorerToolDetail, one variant per tool family — search (a hit count per corpus, zero or not, with the top titles), documents (a title per fetched id, text length in full mode), facets (field count, document count, facet groups), plan, answer, or text. The worker renders summary from the same object. The field is optional in the type because a worker deployed before it omits it and a failed result never has one.

Resolving the package inside this repo

exports points consumers at dist/. Inside the monorepo the development export condition points at src/ instead, so Vite's dev server (which asks for that condition) and node --conditions=development --test both run the sources without a build step; vite build and any outside consumer read dist/, which npm run build at the root emits first.

Contract

Built to the page frozen 2026-09-08 on benjaminwittes/ragtime-dev#168 (§4 the event stream and its four ordering rules, §5 the deep-link grammar, §7 this package's surface). Deviations the worker recorded when it was built are additive and typed here: exact spend beside integer cents, calls on done, a second phase event carrying the orient outcome.