██████╗ ██████╗ ██╗ ██╗████████╗███████╗██████╗ ██████╗ ███████╗███╗ ██╗████████╗
██╔══██╗██╔═══██╗██║ ██║╚══██╔══╝██╔════╝██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝
██████╔╝██║ ██║██║ ██║ ██║ █████╗ ██████╔╝██║ ███╗█████╗ ██╔██╗ ██║ ██║
██╔══██╗██║ ██║██║ ██║ ██║ ██╔══╝ ██╔══██╗██║ ██║██╔══╝ ██║╚██╗██║ ██║
██║ ██║╚██████╔╝╚██████╔╝ ██║ ███████╗██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝
One app. Many accounts. One unbroken conversation.
RouterGent is a standalone router for the snapgent connector. This Electron app runs several AI accounts at once, picks a ready node for each prompt, and automatically hands the work over to another node when one fails, so the task continues instead of starting over.
| Module | Location | Purpose |
|---|---|---|
| 🧭 Router | src/main/router.js |
Selects a webview node (random or pinned), performs automatic failover, and writes a .txt handoff so the replacement node continues the work. |
| 🔌 Bridge | src/main/mcp-hub.js |
Node port of the MCP side of bridge.py. One hub is shared by all nodes, so new nodes get it automatically. |
| 🖥️ Webview Node | src/renderer |
One <webview> per account. Each node has its own login partition (persist:rg-<node-id>). |
| 🤖 Driver | src/driver/node-driver.js |
Injected into each webview after the snapgent content script. Receives prompts from the router, presses Start when needed, sends the prompt through ZSProvider, records progress, and reports done or failed. |
┌──────────────────────┐
│ PARENT PROMPT │
└──────────┬───────────┘
│
┌──────────▼───────────┐
│ ROUTER │ ◄── AUTO / PIN mode
│ select · failover │
│ handoff · history │
└───┬──────┬───────┬───┘
│ │ │
┌─────────▼┐ ┌──▼──────┐ ┌▼─────────┐
│ NODE 01 │ │ NODE 02 │ │ NODE N │ webview + driver
│ persist: │ │ persist:│ │ persist: │ separate login partitions
│ rg-<id> │ │ rg-<id> │ │ rg-<id> │
└─────┬────┘ └────┬────┘ └────┬─────┘
└────────────┼───────────┘
│
┌────────────▼────────────┐
│ MCP HUB │ one hub, shared by all nodes
│ (vscode, etc.) │
└─────────────────────────┘
cd routergent
npm install
npm start| Variable | Purpose | Default |
|---|---|---|
ROUTERGENT_EXTENSION_DIR |
Location of the snapgent-extension folder |
resources/snapgent-extension |
ROUTERGENT_CONFIG |
Location of config.json containing mcpServers |
resources/config.json |
ROUTERGENT_MCP |
Comma-separated ids of the MCP servers to load | vscode |
[1] + Node ──► [2] Start agent ──► [3] Parent prompt ──► [4] Conversation panel ──► [5] Failover
- Click + Node, choose a provider, and log in inside the webview.
- Click Start agent on that node. Repeat for other accounts or providers.
- Type in the parent prompt. Auto mode picks a ready node at random, or you can pin a single node.
- Your prompt, the node replies, and tool results appear in the conversation panel above the input. After a failover the panel still shows one continuous conversation, labeled with the node that answered.
- If the working node fails (quota exhausted, error, stuck), the router switches to another node and sends it a handoff summary.
Build a Windows portable executable:
npm run distThe output is dist/RouterGent 0.1.0.exe.
- Self-contained resources. Everything the build needs lives in
resources/:snapgent-extension/,vscode_mcp.exe, and a minimalconfig.jsonthat only declares thevscodeserver.package.jsonbundles all three asextraResources, so nothing is read from the parent folder. To update the extension or the MCP server, replace the copies inresources/. - The
vscodecommand inconfig.jsonis always overridden at runtime with the bundledvscode_mcp.exe, so no absolute paths are needed. - Windows
winCodeSignsymlink error. If extraction fails with "A required privilege is not held by the client", either enable Developer Mode, run the terminal as Administrator, or extract thewinCodeSignarchive manually into the electron-builder cache folder. The two macOS symlinks that fail to extract are not needed for Windows builds.
npm testCurrent tests cover router.js (node selection, failover, handoff, history) and mcp-hub.js (config loading and overrides). The driver and webview integration have no automated tests yet.
⚠️ This project is experimental. Known limitations:
- The driver has not been tested in a real webview. Selectors and done/failed detection depend on each provider's DOM and must be verified per provider.
world: "MAIN"content scripts (ChatGPTchatgpt-cm.js, Qwenqwen-net.js) run atdocument_startin the manifest, while RouterGent injects them atdom-ready. Those providers may be affected.- Hidden webviews. Nodes that are not selected are hidden by the UI. The snapgent extension parks its agent loop while
document.hiddenis true, sowebview-preload.jsforces the page to report that it is always visible to keep background nodes working. This needs verification in a real webview. - Chats that already contain a conversation. The extension shows "No agent. Open a new chat." and does not offer Start. The driver treats this as a failed start, so the router moves to another node. Open a new chat on that node before pressing Start agent.
- MCP servers cannot be added or removed from the UI yet; edit
config.json.
routergent/
├── src/
│ ├── driver/ node-driver.js
│ ├── main/ main.js · router.js · mcp-hub.js
│ ├── preload/ app-preload.js · webview-preload.js
│ └── renderer/ index.html · renderer.js
├── resources/ snapgent-extension/ · vscode_mcp.exe · config.json
├── test/ router.test.js · mcp-hub.test.js
└── package.json
> END OF TRANSMISSION
License: GPL-3.0-or-later