Skip to main content

WebBridge channel plugin for nanobot - universal web interface

Project description

nanobot-webbridge-plugin

๐ŸŽ‰ WebBridge channel plugin for nanobot โ€” Enables a beautiful web chat interface for your AI agent!

This plugin adds a WebSocket server to nanobot that accepts connections from agent-webbridge, providing a universal web frontend.


Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   agent-webbridge  โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚   nanobot (with     โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚   AI Agent (LLM)    โ”‚
โ”‚   (Web Frontend)   โ”‚  wss    โ”‚   webbridge plugin) โ”‚  json    โ”‚                     โ”‚
โ”‚   port 8080        โ”‚          โ”‚   port 18791       โ”‚          โ”‚                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                                                                              โ”‚
         โ”‚  User's Browser                                                             โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Prerequisites

  • nanobot installed and running
  • Python 3.10+
  • agent-webbridge frontend (see agent-webbridge)

Installation

1. Install the plugin

# Using pip
pip install nanobot-webbridge-plugin

# Or from source
git clone https://github.com/ramonpaolo/nanobot-webbridge-plugin.git
cd nanobot-webbridge-plugin
pip install -e .

2. Configure nanobot

Edit your ~/.nanobot/config.json:

{
  "channels": {
    "webbridge": {
      "enabled": true,
      "host": "0.0.0.0",
      "port": 18791,
      "hmac_secret": "",           // Optional: for message signatures
      "allowed_connections": [
        {
          "api_key": "sk_live_your_unique_api_key_here",
          "ip": null               // null = any IP, or "192.168.1.100" for specific IP
        }
      ]
    }
  }
}

3. Generate a secure API Key

# Generate a 32-character random key
openssl rand -hex 16

# Example output: 4a7b9c2e1f3d8h6i0jklmnopqrstuvwx

4. Restart nanobot

# If using systemd
systemctl --user restart nanobot

# If using PM2
pm2 restart nanobot

# If running directly
nanobot run

Frontend Setup

Now set up the agent-webbridge frontend:

git clone https://github.com/ramonpaolo/webbridge-agent.git
cd webbridge-agent
cp .env.example .env

Edit .env:

API_KEY=sk_live_your_unique_api_key_here    # Must match nanobot config
AGENT_WS_URL=ws://localhost:18791           # nanobot webbridge URL
HMAC_SECRET=                                # Leave empty if not using HMAC
AGENT_NAME=My Agent

Run:

pip install -r requirements.txt
uvicorn src.main:app --reload --port 8080

Open http://localhost:8080 in your browser.


Security

Security Layers

Layer Description
API Key Required for WebSocket handshake
IP Whitelist Optional per-API-key IP restriction
HMAC Signature Optional message integrity verification

IP Whitelist

Restrict access to specific IPs:

"allowed_connections": [
  {
    "api_key": "sk_live_...",
    "ip": "192.168.1.100"    // Only this IP can use this key
  },
  {
    "api_key": "sk_live_...",
    "ip": null               // Any IP can use this key
  }
]

HMAC Signatures (Optional)

For extra security, enable HMAC signatures:

  1. Set the same hmac_secret in both nanobot config and agent-webbridge .env
  2. Messages will include a signature verified by both sides

Configuration Reference

nanobot config.json

{
  "channels": {
    "webbridge": {
      "enabled": true,                      // true to enable
      "host": "0.0.0.0",                   // Interface to bind
      "port": 18791,                        // WebSocket port
      "hmac_secret": "",                   // Optional HMAC secret
      "allowed_connections": [              // Required: at least one
        {
          "api_key": "sk_live_...",        // Your API key
          "ip": null                        // IP whitelist (null = any)
        }
      ]
    }
  }
}

agent-webbridge .env

API_KEY=sk_live_your_unique_api_key_here    # Required
AGENT_WS_URL=ws://localhost:18791           # Required
HMAC_SECRET=                                 # Optional
AGENT_NAME=My Agent                         # Optional
PORT=8080                                    # Optional
ALLOWED_ORIGINS=*                           # Optional

Troubleshooting

"Access denied" error

  1. Verify api_key matches exactly in both configs
  2. Check that allowed_connections is not empty
  3. If using IP whitelist, verify your IP is allowed

"Connection refused" error

  1. Ensure nanobot is running with webbridge enabled
  2. Check that AGENT_WS_URL in agent-webbridge .env is correct
  3. Verify no firewall is blocking the ports

Messages not being received

  1. Check nanobot logs for message processing errors
  2. Verify the agent is configured to respond on the webbridge channel

Development

# Clone the repo
git clone https://github.com/ramonpaolo/nanobot-webbridge-plugin.git
cd nanobot-webbridge-plugin

# Install in development mode
pip install -e .

# Run tests
pytest tests/ -v

License

MIT ยฉ ramonpaolo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanobot_webbridge_plugin-1.0.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanobot_webbridge_plugin-1.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file nanobot_webbridge_plugin-1.0.1.tar.gz.

File metadata

File hashes

Hashes for nanobot_webbridge_plugin-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9e7328a44620673e38a801b85d5d01f2341474bdfc0c2cf7dd33fe3e89102fb0
MD5 9ad6088c968492a54fdaeb7f03969e1b
BLAKE2b-256 eac0f00cf7e6302d8f01b3bc38c8f95c8314054a791610ff898c19a92b2f4149

See more details on using hashes here.

File details

Details for the file nanobot_webbridge_plugin-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nanobot_webbridge_plugin-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b760e446d3783a3c3ac0e187fea844b545e92cee40291872d879322fa8a4c14b
MD5 8de46d655140c5dfdc390f15691c2262
BLAKE2b-256 e250d331ac1578dc80be0cce2797540fc2487779ccc40eadf27e2d428d0471b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page