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

wopr-plugin-router

v0.3.0

Published

Message routing middleware for WOPR

Readme

WOPR Router Plugin

License: MIT WOPR

A middleware plugin for WOPR that routes messages between channels and sessions. Fan out incoming messages to multiple sessions or forward outgoing responses to specific channels.

Part of the WOPR ecosystem - Self-sovereign AI session management over P2P.

Features

  • Incoming Routes: Fan out messages from one session to multiple target sessions
  • Outgoing Routes: Forward responses to specific channel types or IDs
  • Web UI: Built-in configuration panel integrated into WOPR settings
  • Hot Reload: Configuration changes apply immediately without restart

Installation

Place the plugin in your WOPR plugins directory or install via npm:

npm install wopr-plugin-router

The plugin exports an ES module with the following interface:

export default {
  name: "router",
  version: "0.1.0",
  description: "Example routing middleware between channels and sessions",
  init(pluginContext),
  shutdown()
}

Configuration

Plugin Configuration

Configure routes in the plugin config (stored at plugins.data.router):

{
  "uiPort": 7333,
  "routes": [
    {
      "sourceSession": "support",
      "targetSessions": ["billing", "engineering"],
      "channelType": "discord",
      "channelId": "123456789"
    }
  ],
  "outgoingRoutes": [
    {
      "sourceSession": "support",
      "channelType": "discord",
      "channelId": "123456789"
    }
  ]
}

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | uiPort | number | 7333 | Port for the plugin's web UI server | | routes | array | [] | Incoming message routing rules | | outgoingRoutes | array | [] | Outgoing response routing rules |

Route Fields

Incoming Routes (routes):

| Field | Type | Required | Description | |-------|------|----------|-------------| | sourceSession | string | No | Match messages from this session | | targetSessions | array | Yes | Forward messages to these sessions | | channelType | string | No | Match only this channel type (e.g., "discord", "slack") | | channelId | string | No | Match only this specific channel ID |

Outgoing Routes (outgoingRoutes):

| Field | Type | Required | Description | |-------|------|----------|-------------| | sourceSession | string | No | Match responses from this session | | channelType | string | No | Forward only to channels of this type | | channelId | string | No | Forward only to this specific channel ID |

CLI Configuration

wopr config set plugins.data.router '{
  "uiPort": 7333,
  "routes": [
    {
      "sourceSession": "support",
      "targetSessions": ["billing", "engineering"],
      "channelType": "discord"
    }
  ],
  "outgoingRoutes": [
    {
      "sourceSession": "support",
      "channelType": "discord"
    }
  ]
}'

API Configuration

curl -X PUT http://localhost:7437/config/plugins.data.router \
  -H "Content-Type: application/json" \
  -d '{
    "uiPort": 7333,
    "routes": [
      {
        "sourceSession": "support",
        "targetSessions": ["billing", "engineering"],
        "channelType": "discord"
      }
    ],
    "outgoingRoutes": [
      {
        "sourceSession": "support",
        "channelType": "discord"
      }
    ]
  }'

Web UI

The plugin includes a web-based configuration panel that integrates into WOPR's settings interface.

  • URL: http://127.0.0.1:7333 (or configured uiPort)
  • Location: Appears in WOPR settings under "Message Router"
  • Features: Add/delete routing rules, view current configuration

The UI component is built with SolidJS signals for reactive updates.

Behavior

Incoming Message Flow

  1. Message arrives at a session via a channel
  2. Plugin checks all routes for matches
  3. For each matching route, message is injected into targetSessions
  4. Original message continues to the source session normally

Match Logic: A route matches if ALL specified fields match:

  • sourceSession matches the message's session (if specified)
  • channelType matches the channel's type (if specified)
  • channelId matches the channel's ID (if specified)

Outgoing Response Flow

  1. Session generates a response
  2. Plugin checks all outgoingRoutes for matches
  3. For each matching route, response is sent to channels connected to that session
  4. Channel filtering applies: only channels matching channelType and/or channelId receive the response

Plugin Context API

The plugin uses the following WOPR plugin context methods:

| Method | Description | |--------|-------------| | ctx.getPluginDir() | Get the plugin's directory path | | ctx.getConfig() | Get the plugin's current configuration | | ctx.log.info(msg) | Log informational messages | | ctx.registerMiddleware(config) | Register incoming/outgoing middleware | | ctx.registerUiComponent(config) | Register a UI component in WOPR | | ctx.inject(session, message) | Inject a message into a session | | ctx.getChannelsForSession(session) | Get all channel adapters for a session |

Examples

Support Ticket Routing

Route customer support messages to both billing and engineering teams:

{
  "routes": [
    {
      "sourceSession": "support",
      "targetSessions": ["billing", "engineering"],
      "channelType": "discord"
    }
  ]
}

Channel-Specific Routing

Route messages from a specific Discord channel to multiple sessions:

{
  "routes": [
    {
      "channelId": "1234567890",
      "targetSessions": ["alerts", "logs", "monitoring"]
    }
  ]
}

Broadcast Responses

Send all responses from a session to all connected Discord channels:

{
  "outgoingRoutes": [
    {
      "sourceSession": "announcements",
      "channelType": "discord"
    }
  ]
}

Requirements

  • WOPR >= 1.0.0
  • Node.js (ES modules support)

License

MIT