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

@0xkobold/pi-gateway

v0.6.0

Published

Hermes-style messaging gateway for pi - multi-platform agent with sessions, security, and background tasks

Readme

Pi-Gateway

Hermes-style messaging gateway for pi-coding-agent — multi-platform session management, security, and background tasks.

Installation

pi install npm:@0xkobold/pi-gateway

Or as part of the meta-extension:

pi install npm:@0xkobold/pi-kobold

Features

  • Per-Chat Sessions — Unique session ID per platform/channel with reset policies
  • Reset Policies — Daily (hour-based) and idle (minutes-based) session resets
  • Session Persistence — Sessions survive restarts via SQLite (sql.js)
  • Background Tasks — Isolated sessions for long-running commands
  • Security — Per-platform user allowlists and DM pairing flow
  • Rate Limiting — Configurable per-identifier rate limiting
  • Multi-Platform Adapters — Discord, Telegram, Slack, WhatsApp, Twitch, WebSocket

Architecture

┌──────────────────────────────────────────────────────┐
│                    Pi-Gateway                         │
├──────────────┬──────────────┬────────────────────────┤
│  Sessions    │  Security    │  Background Tasks      │
│  ──────────  │  ──────────  │  ──────────────────   │
│  • Per-chat  │  • Allowlist │  • Isolated sessions   │
│  • Reset     │  • Pairing   │  • Progress tracking   │
│  • Persist   │  • Rate limit│  • Result delivery     │
├──────────────┴──────────────┴────────────────────────┤
│              Platform Adapters                        │
│  Discord · Telegram · Slack · WhatsApp · Twitch      │
├──────────────────────────────────────────────────────┤
│              SQLite via sql.js                        │
└──────────────────────────────────────────────────────┘

Commands

| Command | Description | |---------|-------------| | /gateway start [port] | Start the gateway | | /gateway stop | Stop the gateway | | /gateway status | Show status | | /gateway restart | Restart the gateway | | /gateway pair <code> | Approve a pairing code | | /gateway allow <platform> <userId> | Add user to allowlist | | /gateway sessions | List active sessions | | /gateway tasks | List background tasks | | /gateway config | Show configuration |

Tools

| Tool | Description | |------|-------------| | gateway_status | Check gateway status | | gateway_sessions | List active sessions | | gateway_background_tasks | List and manage background tasks | | gateway_pairing | Generate, list, or approve pairing codes |

Programmatic API

Pi-gateway now exports a programmatic API so it can be started from outside a pi session:

import { startGateway, stopGateway, isGatewayRunning, getStatus } from '@0xkobold/pi-gateway/api';

// Check if already running
const running = await isGatewayRunning(3847);

// Start the gateway
const status = await startGateway({ port: 3847, host: '0.0.0.0' });

// Get status
const current = getStatus();

// Stop
await stopGateway();

| Function | Description | |----------|-------------| | startGateway(opts?) | Start HTTP/WS server, adapters, and cron | | stopGateway() | Stop all adapters, close server, kill RPC process | | isGatewayRunning(port?) | Check if a gateway is already running on a port | | getStatus() | Get current status (running, adapters, clients, sessions) | | getConfig() | Get current gateway config | | isRunning() | Check if gateway is running (sync) | | getAdapter(platform) | Get a platform adapter by name | | getAdapters() | Get all active adapters | | sendMessage(platform, channelId, content) | Send a message through a platform adapter | | broadcast(event, data) | Broadcast to all connected WebSocket clients |

Start Options

interface StartGatewayOptions {
  port?: number;       // Override config port
  host?: string;      // Override config host
  noAgent?: boolean;  // Don't spawn pi RPC process (when pi is already running)
}

Session Reset Policies

  • idle — Reset after N minutes of inactivity (default: 1440 = 24h)
  • daily — Reset at a specific hour each day (default: 4:00)
  • both — Reset on either condition

Security

Allowlist Mode

By default, all users are allowed (allowAll: true). To restrict access:

  1. Set allowAll: false in config
  2. Use pairing codes or /gateway allow to grant access

Pairing Flow

  1. User sends a message on a platform
  2. Agent generates a pairing code via gateway_pairing (generate)
  3. Admin approves code via /gateway pair <code>
  4. User is added to the allowlist

Configuration

Stored at ~/.0xkobold/gateway/config.json:

{
  "port": 3847,
  "host": "localhost",
  "tokens": [],
  "corsOrigins": ["*"],
  "enableWebSocket": true,
  "enableHttp": true,
  "security": {
    "allowAll": true,
    "requirePairing": false
  },
  "sessions": {
    "resetPolicy": "idle",
    "dailyHour": 4,
    "idleMinutes": 1440
  },
  "platforms": {
    "discord": {
      "enabled": false,
      "botToken": ""
    }
  }
}

Local Storage

Data is stored in SQLite via sql.js (WebAssembly) for cross-runtime compatibility (Node.js and Bun):

  • ~/.0xkobold/gateway-sessions.db — Session data
  • ~/.0xkobold/gateway-security.db — Allowlist, pairing codes, rate limits
  • ~/.0xkobold/gateway-background-tasks.db — Background task records

Local Development

git clone https://github.com/0xKobold/pi-gateway
cd pi-gateway
npm install
npm run build
pi install ./

License

MIT