FluxRoute
README.md
<div align="center">
<img src="./docs/banner.svg" alt="FluxRoute — Intra-Workflow Multi-LLM Relay & MCP Console" width="100%" />
<br />
[](./LICENSE)
[-D97757.svg?style=flat-square)](https://nodejs.org/)
[](https://modelcontextprotocol.io/)
[](./packages/core/src/security.ts)
</div>
---
## Overview
**FluxRoute** is a real-time **intra-workflow multi-LLM model router** built as a unified **MCP Server + Interactive MCP App UI**, **Antigravity Plugin (Hooks + Skill + Rules)**, **Universal Coding Agent Skill**, and **VS Code Extension**.
Traditional LLM routers only inspect the *initial user prompt* on Turn 1. In real engineering sessions, a single prompt often spans multiple distinct phases:
1. **Steps 1–3 (High Complexity):** Distributed state design, security auditing, or race-condition debugging — requires frontier capability (**Claude Opus / Sonnet**, **OpenAI o3 / GPT-4.1+**, **Gemini Pro**).
2. **Steps 4–8 (Routine Execution):** Generating CRUD boilerplate, writing basic unit test stubs, formatting files, or updating `README.md` — tasks where **Gemini Flash**, **GPT Mini/Nano**, **Claude Haiku**, or **Local Ollama** deliver identical reliability at **85–95% lower cost**.
3. **Mid-Task Failure Loops:** Conversely, if you start on a lightweight economy model and hit 2+ consecutive test/compiler failures, staying on that model wastes developer time and requires immediate **Frontier Escalation**.
FluxRoute intercepts **every step inside an active workflow** in `<40ms` via IDE lifecycle hooks and MCP tools—firing real-time desktop & inline alerts, asking manual permission (`Manual Gate`), or automatically offloading subtasks (`Auto Relay`) with compact git-aware **Context Handoff Capsules**.
---
## Key Highlights
- **Zero Hardcoded Pricing or Fake Telemetry:**
- Dynamically syncs **360+ live interactive LLMs** (excluding offline `:batch` queues and non-chat audio/image endpoints) directly from OpenRouter's live catalog API (`https://openrouter.ai/api/v1/models`) plus locally running **Ollama** daemons (`http://127.0.0.1:11434/api/tags`).
- Stores every evaluation, policy change, and API token/USD execution in a local WAL-mode SQLite database (`node:sqlite`) starting strictly at `0`.
- **Four Real-Time Operating Modes:**
- **`manual_ask` (Manual Gate):** Pauses at genuine workflow phase transitions (`force_ask` / VS Code modal toast) so you can approve or decline model switches in real time.
- **`auto_switch` (Auto Relay):** Automatically delegates routine mid-workflow steps to fast economy models (or lightweight subagents) while notifying you in the background.
- **`notify_only` (Signal Only):** Non-blocking OS desktop toast alerts and live SQLite savings tracking without interrupting tool calls.
- **`off` (Bypass):** Disables routing hooks immediately.
- **Smart Context Handoff Capsules:**
- Switching models mid-session normally breaks KV prompt caches or wastes tens of thousands of tokens re-sending raw chat transcripts. FluxRoute inspects live `git status`, active branch, modified files, and JSONL conversation trajectories to build a **~200–600 token Markdown Capsule** ready for instant handoff.
- **Handcrafted Instrument Console (`ui://fluxroute/dashboard.html`):**
- Custom pixel-aligned vector iconography and an animated mechanical **Rotary Relay Schematic** (zero generic emojis or stock AI templates) supporting both Dark (Brushed Obsidian) and Light (Archival Vellum) host themes.
- **Enterprise-Grade Security Architecture:**
- **AES-256-GCM Encrypted Key Vault:** Provider API keys stored at rest use authenticated encryption (`enc:v1:<iv>:<tag>:<ciphertext>`).
- **Prompt-Injection Privilege Separation:** LLM-callable MCP tools **cannot** read/modify API keys or external webhook URLs; credential management is strictly isolated to the human-only MCP App iframe (`visibility: ['app']`) and local CLI/environment variables.
- **DLP Credential Scrubber & Free-Tier Privacy Gate:** Automatically redacts accidental API keys, GitHub PATs, AWS keys, Bearer tokens, and PEM private keys from logs/notifications and blocks routing proprietary code to `:free` shared-logging endpoints by default.
- **Header-Only Upstream Auth & SSRF/DNS-Rebinding Guards:** Gemini (`x-goog-api-key`), Anthropic (`x-api-key`), and OpenAI (`Authorization`) credentials never appear in URL query strings; webhooks block private LAN and cloud metadata IPs (`169.254.169.254`); Streamable HTTP `/mcp` enforces loopback `Host`, `Origin`, constant-time Bearer token auth, and `1 MiB` payload limits.
---
## Architecture & Mid-Workflow Lifecycle
```mermaid
flowchart LR
subgraph Clients["AI Coding Environments"]
AGY["Google Antigravity\n(Plugin + Hooks + Side-Pane UI)"]
VSC["VS Code Extension\n(@router + vscode.lm + Watcher)"]
MCP_HOSTS["ChatGPT / Claude / Cursor\n(Stdio & Streamable HTTP /mcp)"]
end
subgraph Core["@fluxroute/core Engine"]
HOOK["Lifecycle Hook Runner\n(Phase-Shift Hysteresis)"]
ANA["Multi-Signal Analyzer\n(AST + Transcript + Cache Math)"]
HO["Git & Trajectory\nHandoff Capsule Builder"]
SEC["Security Layer\n(AES-256-GCM + DLP + SSRF Guard)"]
DB[("Native SQLite WAL\nfluxroute.sqlite")]
end
subgraph Providers["Live LLM Ecosystem"]
GEM["Google Gemini\n(Pro / Flash / Lite)"]
CLAUDE["Anthropic Claude\n(Opus / Sonnet / Haiku)"]
OAI["OpenAI / ChatGPT\n(GPT-4.1+ / o3 / Mini / Nano)"]
OR["OpenRouter / DeepSeek / Grok"]
OLLAMA["Local Ollama\n($0 Loopback)"]
end
AGY --> HOOK
AGY <--> Core
VSC <--> Core
MCP_HOSTS <--> Core
HOOK --> ANA
ANA <--> DB
SEC <--> DB
Core --> HO
Core --> GEM & CLAUDE & OAI & OR & OLLAMA
```
---
## Monorepo Structure
```text
FluxRoute/
├── docs/
│ └── banner.svg # Handcrafted SVG schematic banner
├── packages/
│ ├── core/ # @fluxroute/core — Analyzer, SQLite WAL DB, Vault, Catalog, Executor, Hooks
│ ├── mcp-server/ # @fluxroute/mcp-server — Stdio + Streamable HTTP /mcp + Handcrafted UI App
│ ├── antigravity-plugin/ # Ready-to-load Antigravity Plugin + Universal Agent Skill + Standalone CLI
│ │ ├── plugin.json
│ │ ├── mcp_config.json
│ │ ├── hooks.json # SessionStart, PreInvocation, PreToolUse, PostToolUse
│ │ ├── bin/fluxroute-cli.mjs # Zero-dependency bundled Node ESM binary
│ │ ├── rules/AGENTS.md
│ │ └── skills/fluxroute-model-router/SKILL.md
│ └── vscode-extension/ # fluxroute-vscode — @router Chat Participant, Watcher, CSP Webview & .vsix
├── scripts/
│ └── bundle-plugin.mjs # Bundles single-file CLI and syncs plugin directories
└── tests/
└── e2e.test.ts # 7-part E2E security, encryption, SSRF, hysteresis, MCP & UI verification
```
---
## Quick Start & Installation
### Prerequisites
- **Node.js `>= 22.5.0`** (uses Node's built-in `node:sqlite` — zero native C++ addon compilation required; verified on Node `v24.x` across Windows, macOS, and Linux).
### 1. Clone, Build & Verify
```bash
git clone https://github.com/Sunil56224972/FluxRoute.git
cd FluxRoute
npm install
npm run build
npm run package:vscode
npm test
```
---
## Platform Setup Guides
### A. Google Antigravity (Plugin + Real-Time Hooks + Side-Pane Console)
`npm run build` automatically installs the plugin bundle into `~/.gemini/config/plugins/fluxroute` (or copy `packages/antigravity-plugin` there manually):
1. Enable **FluxRoute Smart Model Router** on the **Customizations → Plugins** page.
2. Open **FluxRoute Router** from the Side Pane `+` menu or send:
> `"Open the FluxRoute live model router dashboard"`
3. Real-time `PreInvocation`, `PreToolUse`, and `PostToolUse` hooks immediately begin monitoring mid-workflow complexity transitions and error streaks.
### B. VS Code Extension (`.vsix`)
Install the packaged extension directly:
```bash
code --install-extension packages/vscode-extension/fluxroute-vscode-1.0.0.vsix
```
- Mention **`@router`** in VS Code Chat to dynamically route prompts across your installed `vscode.lm` models (Copilot ChatGPT, Claude, Gemini) or direct API keys with interactive approval prompts.
- Click **`FluxRoute [Gate]`** in the bottom Status Bar to open the live Webview Console or run **`FluxRoute: Save Provider API Key in Encrypted Vault (AES-256-GCM)`** from the Command Palette.
### C. Claude Desktop / Cursor / Windsurf / Cline (Stdio MCP)
Add the standalone bundled binary to your client's `mcp_config.json` / `claude_desktop_config.json`:
```json
{
"mcpServers": {
"fluxroute": {
"command": "node",
"args": [
"--no-warnings",
"/absolute/path/to/FluxRoute/packages/antigravity-plugin/bin/fluxroute-cli.mjs"
]
}
}
}
```
### D. ChatGPT Desktop / Remote Connectors (Hardened Streamable HTTP `/mcp`)
Start the Streamable HTTP server bound to loopback with Bearer authentication:
```bash
node --no-warnings packages/antigravity-plugin/bin/fluxroute-cli.mjs \
--http --port 4789 --auth-token "your-strong-secret-token"
```
- **MCP Endpoint:** `http://127.0.0.1:4789/mcp`
- **Health & Posture Check:** `http://127.0.0.1:4789/healthz`
---
## MCP Tools Reference
| Tool | Visibility | Description |
| :--- | :--- | :--- |
| `open_router_dashboard` | Model + App (`ui://`) | Opens the interactive 4-tab **FluxRoute Console** inline, in the Side Pane, or full-page. |
| `analyze_workflow_step` | Model + App | Evaluates prompt/step complexity (`0–100`), workflow phase, active model cost, and best cross-provider target models with optional OS toast notification. |
| `route_and_execute` | Model + App | Executes a prompt or delegated routine phase on the optimal configured LLM API (`Google`, `Anthropic`, `OpenAI`, `OpenRouter`, `DeepSeek`, `xAI`, `Groq`, or local `Ollama`), recording exact tokens and realized USD savings. |
| `create_handoff_capsule` | Model + App | Builds a compact git- and trajectory-aware Markdown Context Capsule for low-token mid-workflow model switching. |
| `configure_router_policy` | Model + App | Updates safe operational settings (`mode`, `desktopNotifications`, `minSavingsPercentToNotify`, `allowFreeCommunityEndpoints`, `dailyBudgetUsd`). |
| `sync_live_models` | Model + App | Syncs fresh live interactive LLM models & per-token pricing from OpenRouter + local Ollama. |
| `get_router_telemetry` | Model + App | Reads real SQLite evaluations, realized/potential USD savings, provider health, and security posture. |
| `app_save_secret` | **App-Only** (`ui`) | Encrypts and stores provider API keys in the local AES-256-GCM SQLite vault without exposing secrets to any LLM context. |
---
## Provider Credentials (Optional — for Direct `route_and_execute`)
FluxRoute's real-time IDE switch alerts and Context Handoff Capsules work **immediately with zero API keys**. To also let FluxRoute execute delegated subtasks directly over provider APIs, add keys via the **Security & Vault** UI tab or environment variables:
| Provider | Environment Variable | Upstream Endpoint |
| :--- | :--- | :--- |
| **Google Gemini** | `GEMINI_API_KEY` or `GOOGLE_API_KEY` | `https://generativelanguage.googleapis.com/v1beta` (`x-goog-api-key` header) |
| **Anthropic Claude** | `ANTHROPIC_API_KEY` | `https://api.anthropic.com/v1/messages` |
| **OpenAI / ChatGPT** | `OPENAI_API_KEY` | `https://api.openai.com/v1/chat/completions` |
| **OpenRouter (300+ LLMs)** | `OPENROUTER_API_KEY` | `https://openrouter.ai/api/v1/chat/completions` |
| **DeepSeek** | `DEEPSEEK_API_KEY` | `https://api.deepseek.com/v1/chat/completions` |
| **xAI Grok** | `XAI_API_KEY` | `https://api.x.ai/v1/chat/completions` |
| **Groq** | `GROQ_API_KEY` | `https://api.groq.com/openai/v1/chat/completions` |
| **Ollama (Local Free)** | *(Auto-discovered on loopback)* | `http://127.0.0.1:11434` |
---
## Verification & Security Suite
Run the full automated test suite (`node:test`):
```bash
npm test
```
Verifies:
1. Fresh SQLite state (`0` fake rows) + live OpenRouter catalog sync filtering out `:batch` and audio generators.
2. **AES-256-GCM** encryption at rest in `provider_secrets` + **DLP** detection & redaction of leaked keys.
3. **SSRF & Loopback Guards** rejecting cloud metadata (`169.254.169.254`), private LAN webhooks, and remote unapproved Ollama hosts.
4. **Mid-Workflow Hysteresis** allowing complex architecture on Claude Opus, gating on transition to `README.md`, and suppressing duplicate prompts inside the same phase.
5. **Error-Streak Escalation** on consecutive `PostToolUse` failures + LLM privilege separation on `configure_router_policy`.
6. **Hardened Streamable HTTP `/mcp`** (`401` unauthenticated, `403` untrusted cross-origin CSRF, `200` Bearer-authenticated UI resource check).
---
## License
Released under the [MIT License](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues