# 9Router

> Launch and control the real 9Router AI gateway (multi-provider, key rotation, auto-fallback) and open its local web dashboard.

| | |
|---|---|
| Version | 1.0.0 |
| Category | AI & Agents |
| Permissions | shell.exec |

# 9Router

Launch and control the real **9Router** AI gateway from Kazuo AI, and open its web dashboard.

**Type:** `backend` — spawns the real `9router` CLI as a child process in the Electron main process.
**Platforms:** Windows, macOS, Linux (spawns through the system shell; Stop kills the whole process tree).

## What it does

This plugin does NOT route requests itself. It runs the real **9router** (npm package `9router`) on
your machine and opens its built-in web dashboard. Providers, API keys, fallback rules and the local
Bearer token are all managed in 9router's own dashboard (data stored under `~/.9router`).

- Start / Stop the `9router` server.
- Open its dashboard at `http://localhost:<port>` (default `20128`).
- Live log tail + status in the widget.

Point your OpenAI/Claude-compatible tools (Cursor, Cline, Codex, Claude Code…) at
`http://localhost:20128/v1` and copy the API key shown in the dashboard.

## Requirements

Node.js ≥ 18 available on PATH (the default command uses `npx`). Or set a custom launch command in
Settings (e.g. a global install, a pinned version, or a Docker command) — use `{port}` as a placeholder.

## Files

- `manifest.json` — metadata, `platforms`, `defaultSettings`, `permissions` (`shell.exec`)
- `main/index.ts` (+ compiled `main/index.js`) — IPC wiring + auto-start
- `main/runner.ts` (+ compiled `.js`) — spawns/stops the `9router` process, opens the dashboard
- `widget.html` / `js/widget.js` / `css/widget.css` — control panel (status, Start/Stop/Open, log, settings overlay)
- `settings.html` / `js/settings.js` / `css/settings.css` — same fields for the Plugin Manager / pop-out window
- `locales/en.json5` / `locales/vi.json5` — UI strings, `widget.*`/`settings.*` namespaces (same key set in both)

## Default settings

- `port` — `20128`
- `command` — `npx -y 9router --port {port} --host 127.0.0.1 --no-browser --skip-update` (`{port}` is replaced at launch)
- `autoStart` — `false`
- `openOnStart` — `true` (open the dashboard right after Start)

## Build

After editing `main/*.ts`, recompile before testing (from the project root):

```
npx tsc -p tsconfig.plugins.json
```

## Test

Open Kazuo AI → Plugin Manager — this plugin appears automatically → Install → Enable → open the
widget → Start. The first start may take a moment while `npx` fetches 9router. Then click
**Open dashboard** and configure your providers there.
