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

@tetrixdev/ai-bridge

v0.4.0

Published

Local CLI bridge for AI web apps — connects Codex, Claude, and Gemini CLIs to web applications via WebSocket

Readme

@tetrixdev/ai-bridge

A local CLI bridge that connects your AI command-line tools (Codex, Claude, Gemini) to web applications via WebSocket. The bridge runs on your machine, receives AI requests from a server, pipes them through your locally installed CLI tools, and streams normalized responses back -- letting web apps use your own AI subscriptions without touching your credentials.

Quick Start

The connection token is generated from the web application that uses the AI Bridge server package (for example, php artisan ai-bridge:token for Laravel apps). The server URL is the WebSocket server address provided by that application (typically wss://your-app.com/api/ai-bridge/ws).

npx @tetrixdev/ai-bridge --server wss://your-app.com/api/ai-bridge/ws --token YOUR_CONNECTION_TOKEN

Or using environment variables:

export AI_BRIDGE_SERVER=wss://your-app.com/api/ai-bridge/ws
export AI_BRIDGE_TOKEN=YOUR_CONNECTION_TOKEN
npx @tetrixdev/ai-bridge

Options

| Flag | Environment Variable | Description | |------|---------------------|-------------| | --server <url> | AI_BRIDGE_SERVER | WebSocket server URL (wss://...) | | --token <token> | AI_BRIDGE_TOKEN | Connection token from the web app | | --test | | Test mode -- responds with mock data instead of calling real CLIs | | --debug | | Enable verbose debug logging | | --log-file <path> | AI_BRIDGE_LOG_FILE | Also append logs to this file. Rotates once past 5 MB, keeping one previous copy (<path>.1) |

Supported Providers

| Provider | CLI Binary | Session Resume | Streaming | Thinking | Server Tools | |----------|-----------|----------------|-----------|----------|--------------| | Codex (OpenAI) | codex | Yes | NDJSON | Yes | Yes | | Claude (Anthropic) | claude | Yes | NDJSON | Yes | Yes | | Gemini (Google) | gemini | Yes | NDJSON | Partial | Yes |

The bridge auto-detects which CLIs are installed on startup.

Server-defined tools registered by the web application are exposed to every provider as Bash wrapper scripts placed on the CLI's PATH; the CLI invokes them as ordinary shell commands and the bridge routes the call back through the WebSocket. For Codex, the bridge runs codex exec with a workspace-write sandbox and network access enabled so the wrapper scripts can reach the bridge — this is handled automatically when tools are present.

Test Mode

Use --test to verify your WebSocket connection and protocol behaviour without needing a real CLI installed. Note that --server and --token are still required in test mode — the WebSocket connection to the server is what test mode exercises.

npx @tetrixdev/ai-bridge --server wss://your-app.com/api/ai-bridge/ws --token TOKEN --test

In test mode, AI requests receive mock streaming responses (thinking block + text block + done event) that exercise the full protocol.

Troubleshooting

Get detailed diagnostics with --debug For detailed diagnostic output, add --debug to the command. This logs each WebSocket message, provider command, and session operation, which is the fastest way to pin down a confusing error before filing a support request.

"Authentication token is required" / "Server URL is required" The token is generated by your web application (e.g. php artisan ai-bridge:token for Laravel apps). The server URL is the WebSocket endpoint exposed by that application (typically wss://your-app.com/api/ai-bridge/ws). See your application's documentation for the exact values.

"Connection rejected: invalid or expired token" Your token has expired or was revoked. Generate a new one from your web application's admin interface and restart the bridge.

"No AI CLI tools detected" Install one or more supported CLIs:

  • Codex: https://github.com/openai/codex
  • Claude: https://claude.ai/download
  • Gemini: https://github.com/google-gemini/gemini-cli

"Authentication required — run `<provider> auth login`" Your AI CLI's authentication session has expired. Run the indicated login command (e.g. claude auth login) and then restart the bridge.

Where are sessions stored? Session mappings are persisted to ~/.ai-bridge/sessions.json so conversations can be resumed across bridge restarts. You can delete this file to clear all sessions.

Protocol

See PROTOCOL.md for the full wire format specification.

License

MIT