WebBridge channel plugin for nanobot - universal web interface
Project description
nanobot-webbridge-plugin
๐ WebBridge channel plugin for nanobot โ Enables a beautiful web chat interface with streaming responses 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 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Features
- ๐ Secure โ API Key + HMAC + IP whitelist
- ๐ Universal โ Works with any WebSocket agent (nanobot, openclaw, etc.)
- ๐ฌ Real-time Streaming โ Responses appear word by word as AI generates them
- ๐ File Upload โ Images, PDFs, documents
- ๐จ Modern UI โ Dark-themed, responsive design
- ๐ Auto-reconnect โ Automatic reconnection on disconnect
- ๐ฑ Responsive โ Works on desktop and mobile
Streaming Configuration
The plugin supports real-time streaming of AI responses. Messages are sent as chunks for a natural feel.
{
"channels": {
"webbridge": {
"enabled": true,
"streaming": true,
"stream_chars_per_second": 100,
"host": "0.0.0.0",
"port": 18791,
"allowed_connections": [...]
}
}
}
| Setting | Type | Default | Description |
|---|---|---|---|
streaming |
boolean | true |
Enable/disable streaming |
stream_chars_per_second |
integer | 100 |
Speed of streaming (chars per second) |
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:
- Set the same
hmac_secretin both nanobot config and agent-webbridge.env - 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
- Verify
api_keymatches exactly in both configs - Check that
allowed_connectionsis not empty - If using IP whitelist, verify your IP is allowed
"Connection refused" error
- Ensure nanobot is running with webbridge enabled
- Check that
AGENT_WS_URLin agent-webbridge.envis correct - Verify no firewall is blocking the ports
Messages not being received
- Check nanobot logs for message processing errors
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nanobot_webbridge_plugin-1.3.0.tar.gz.
File metadata
- Download URL: nanobot_webbridge_plugin-1.3.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1d6ea3397bc6490e9cd2b68a04609b4fb481697ce92bcc4a17a02f510e7405a
|
|
| MD5 |
fe4088d5406f93aecbcea9cddd518472
|
|
| BLAKE2b-256 |
09cc9f2e0dfd77dac00af2ddb31419f96461677567e279343f34f8e3d249873a
|
File details
Details for the file nanobot_webbridge_plugin-1.3.0-py3-none-any.whl.
File metadata
- Download URL: nanobot_webbridge_plugin-1.3.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c572510ed4d9348ccb50e5e9969bc39e4b8e9527f70e44a78c56ef3e848a09d
|
|
| MD5 |
7490410b4048d7911f5dfe312828610c
|
|
| BLAKE2b-256 |
9e1716c2abbaa5fdb92863004fc0c363609832b8a61e006a1892106f815a8323
|