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

@nano-ui-kit/gateway

v0.0.1

Published

LLM transport — browser-safe streaming adapters (Anthropic, OpenAI, Gemini) plus a Node proxy that holds API keys server-side and pipes SSE responses back to the browser.

Downloads

168

Readme

@nano-ui-kit/gateway

LLM transport — one package, two concerns:

  1. Browser-safe streaming adapters (./adapters) — unified chat() / streamChat() / createClient() over fetch for Anthropic, OpenAI, and Gemini. Same chunk shape across providers ({ type: 'text' | 'thinking' | 'done' | 'error', ... }).
  2. Node proxy server (./server) — terminates browser /api/chat requests, attaches server-side API keys, pipes the upstream SSE stream back verbatim. Also fronts the compose pipeline's /api/generate + /api/generate/reset endpoints. The proxy reuses the same adapter buildRequest() the browser does — one source of truth for URL, headers, body.

Private package (not published). Consumed inside the monorepo by @nano-ui-kit/web-components (the nano-chat pattern uses the browser adapters) and @nano-ui-kit/a2ui-compose (the generator's llm-bridge wraps createClient).

Adapter usage

import { streamChat } from '@nano-ui-kit/gateway/adapters';

for await (const chunk of streamChat({
  provider: 'anthropic',                            // or auto-detect from model
  apiKey: 'sk-ant-...',
  model: 'claude-sonnet-4-20250514',
  messages: [{ role: 'user', content: 'Hello' }],
})) {
  if (chunk.type === 'text') process.stdout.write(chunk.text);
}

Chunk shape:

{ type: 'text',     text: string, snapshot: string }    — partial text delta
{ type: 'thinking', text: string }                       — reasoning delta (Anthropic)
{ type: 'done',     text: string, usage: {...}, stopReason: string }
{ type: 'error',    error: Error }

Provider auto-detects from opts.model when opts.provider is omitted — claude* → anthropic, gpt* / o1* → openai, gemini* → gemini.

Reusable client

import { createClient } from '@nano-ui-kit/gateway/adapters';

const client = createClient({ provider: 'anthropic', apiKey: '...' });
const reply = await client.chat({ model: 'claude-sonnet-4-20250514', messages: [...] });
for await (const chunk of client.stream({ model: '...', messages: [...] })) { ... }

Proxy server

Start the gateway so the browser can call LLMs without exposing API keys:

ANTHROPIC_API_KEY=sk-ant-... node packages/gateway/server.js

Or via the repo-level npm script:

npm run proxy

Default port 3456 (override with PORT=). .env at the repo root is auto-loaded (same file the MCP server reads). Startup logs show which provider keys are present.

Endpoints

| Method | Path | Purpose | |--------|--------------------------|--------------------------------------------------------------| | POST | /api/chat | Chat passthrough — { provider, model, messages, system?, … } | | POST | /api/generate | Compose pipeline — { intent, engine?, mode?, sessionId?, … } | | POST | /api/generate/reset | Clear a zettel session — { sessionId } |

/api/chat streams text/event-stream back. /api/generate returns a single JSON payload with the generated A2UI messages plus validation metadata.

@llm vite alias

In Vite dev the alias @llm resolves to packages/gateway/adapters/. In Node / published packages use the scoped specifier (@nano-ui-kit/gateway/adapters) — Vite aliases don't exist at runtime.

License

MIT © Kim Granlund