Catalog npm
Back to packageRELEASE DETAILS

0.2.0

npm

@0xkobold/pi-gateway

Hermes-style messaging gateway for pi-coding-agent

gatewayhermesmessagingpi-packagemulti-platformpi-extension
Published24 Mar 2026
Direct dependencies8
Transitive dependenciesNot calculated

README

Current package documentation

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

CommandDescription
/gateway start [port]Start the gateway
/gateway stopStop the gateway
/gateway statusShow status
/gateway restartRestart the gateway
/gateway pair <code>Approve a pairing code
/gateway allow <platform> <userId>Add user to allowlist
/gateway sessionsList active sessions
/gateway tasksList background tasks
/gateway configShow configuration

Tools

ToolDescription
gateway_statusCheck gateway status
gateway_sessionsList active sessions
gateway_background_tasksList and manage background tasks
gateway_pairingGenerate, 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();
FunctionDescription
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

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 8

Native requirements
8 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ws
Environment
{
  "local_name": "ws",
  "alias": false,
  "peer_metadata": null
}
^8.18.0runtime
zod
Environment
{
  "local_name": "zod",
  "alias": false,
  "peer_metadata": null
}
^3.25.0runtime
@types/ws
Environment
{
  "local_name": "@types/ws",
  "alias": false,
  "peer_metadata": null
}
^8.18.1development
bun-types
Environment
{
  "local_name": "bun-types",
  "alias": false,
  "peer_metadata": null
}
^1.2.0development
@types/bun
Environment
{
  "local_name": "@types/bun",
  "alias": false,
  "peer_metadata": null
}
^1.2.0development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^20.19.37development
@sinclair/typebox
Environment
{
  "local_name": "@sinclair/typebox",
  "alias": false,
  "peer_metadata": null
}
*peer
@mariozechner/pi-coding-agent
Environment
{
  "local_name": "@mariozechner/pi-coding-agent",
  "alias": false,
  "peer_metadata": null
}
*peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "33d9272de65ffffcdce2ad40f49e1c2e0bd7fe8d",
  "tarball": "https://registry.npmjs.org/@0xkobold/pi-gateway/-/pi-gateway-0.2.0.tgz",
  "fileCount": 18,
  "integrity": "sha512-wyL+3LMgzi9kvHF7IO5M4Ya6mOSUSOV1R2OCXb2bLik77R96t5wxUFghwNrxbKSBUU1jvUPXsb/26Ot5YdBU5w==",
  "signatures": [
    {
      "sig": "MEYCIQCibg81knJWD7uqNBgedjZluW5YCOEljNoPrJdypdseTwIhAP9g0cQxevwAaf94vVGhuwKSWZOk1VSXZR88B2PluOEP",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 205848
}

Repository

PENDING
0xkobold/pi-gateway

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:02 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:f401a3d52df86f6724761ebef5863b6a3399e2dedf19bfe5d4e6bf3936a1e7e5

Other collected versions

0.6.09 Apr0.5.27 Apr0.5.17 Apr0.5.07 Apr0.4.07 Apr0.3.17 AprView all collected versions →