9router/cli
Tri Dung Nguyen 5cab23d92e
fix(tray): switch macOS/Linux tray to systray2 fork (#1080)
The legacy `systray@1.0.5` package (last published 2018) bundles a 2017
x86_64 Go binary whose Mach-O headers are rejected by modern dyld (macOS
14+ / Apple Silicon). The result on affected systems was that
`9router --tray` (and "Hide to Tray" from the interactive menu) printed
"Router is now running in system tray" but no menubar icon appeared —
the failure was silently swallowed by `catch (err) { return null }`.

This swaps the runtime tray library for `systray2@2.1.4`, which embeds
the maintained getlantern/systray-portable binaries that work on macOS
14+ under Rosetta. Changes:

- hooks/trayRuntime.js: install `systray2@2.1.4` (not `systray@1.0.5`)
  into ~/.9router/runtime/node_modules. Always purge the legacy systray
  package on every run — its binary is broken on macOS and an AV false
  positive on Windows. chmod +x the bundled Go binary in case the npm
  tarball drops the executable bit (observed on macOS).
- src/cli/tray/tray.js: resolveSystray() now prefers systray2 with a
  fallback to legacy systray for safety. initUnixTray() uses the new
  .ready() promise API, surfaces failures to stderr instead of silently
  returning null, and sets isTemplateIcon:false so the full-color
  icon.png renders correctly (template mode would show a solid white
  square because only the alpha channel is used). killTray() passes
  false to systray2's kill so it doesn't call process.exit(0) before
  the rest of cleanup (server SIGKILL, MITM/tunnel) runs.
- package.json: update the `comment_systray` field to describe the new
  package choice.

Fixes #1079
2026-05-13 15:30:33 +07:00
..
hooks fix(tray): switch macOS/Linux tray to systray2 fork (#1080) 2026-05-13 15:30:33 +07:00
scripts TUI Source 2026-05-12 20:26:08 +07:00
src/cli fix(tray): switch macOS/Linux tray to systray2 fork (#1080) 2026-05-13 15:30:33 +07:00
.gitignore TUI Source 2026-05-12 20:26:08 +07:00
.npmignore TUI Source 2026-05-12 20:26:08 +07:00
cli.js TUI Source 2026-05-12 20:26:08 +07:00
LICENSE TUI Source 2026-05-12 20:26:08 +07:00
package.json fix(tray): switch macOS/Linux tray to systray2 fork (#1080) 2026-05-13 15:30:33 +07:00
README.md TUI Source 2026-05-12 20:26:08 +07:00

9Router - FREE AI Router & Token Saver

Never stop coding. Save 20-40% tokens with RTK + auto-fallback to FREE & cheap AI models.

Connect All AI Code Tools (Claude Code, Cursor, Antigravity, Copilot, Codex, Gemini, OpenCode, Cline, OpenClaw...) to 40+ AI Providers & 100+ Models.

npm Downloads License

decolua%2F9router | Trendshift

🌐 Website📖 Full Docs


🤔 Why 9Router?

Stop wasting money, tokens and hitting limits:

  • Subscription quota expires unused every month
  • Rate limits stop you mid-coding
  • Tool outputs (git diff, grep, ls...) burn tokens fast
  • Expensive APIs ($20-50/month per provider)

9Router solves this:

  • RTK Token Saver - Auto-compress tool_result, save 20-40% tokens
  • Maximize subscriptions - Track quota, use every bit before reset
  • Auto fallback - Subscription → Cheap → Free, zero downtime
  • Multi-account - Round-robin between accounts per provider
  • Universal - Works with any OpenAI/Claude-compatible CLI

Quick Start

1. Install & run:

npm install -g 9router
9router

# Or run directly with npx
npx 9router

🎉 Dashboard opens at http://localhost:20128

2. Connect a FREE provider (no signup needed):

Dashboard → Providers → Connect Kiro AI (free Claude unlimited) or OpenCode Free (no auth) → Done!

3. Use in your CLI tool:

Claude Code/Codex/OpenClaw/Cursor/Cline Settings:
  Endpoint: http://localhost:20128/v1
  API Key:  [copy from dashboard]
  Model:    kr/claude-sonnet-4.5

That's it! Start coding with FREE AI models.


🚀 CLI Options

9router                    # Start with default settings
9router --port 8080        # Custom port
9router --no-browser       # Don't open browser
9router --skip-update      # Skip auto-update check
9router --help             # Show all options

Dashboard: http://localhost:20128/dashboard


🛠️ Supported CLI Tools

Claude-Code • OpenClaw • Codex • OpenCode • Cursor • Antigravity • Cline • Continue • Droid • Roo • Copilot • Kilo Code • Gemini CLI • Qwen Code • iFlow • Crush • Crusher • Aider

Any tool supporting OpenAI/Claude-compatible API works.


💾 Data Location

  • macOS/Linux: ~/.9router/db.json
  • Windows: %APPDATA%/9router/db.json

📚 Documentation

Full docs, advanced setup, video tutorials & development guide:


🙏 Acknowledgments

📄 License

MIT License - see LICENSE for details.