refactor: remove desktop GUI, keep CLI + tray architecture

- Delete cmd/proxypilotui/main_windows.go (desktop GUI)
- Keep cmd/proxypilotui/assets/ (web dashboard)
- Update cliproxytray to remove embedded asset server
- Update proxypilot_dashboard.go for standalone dashboard
- Update README and docs for CLI + tray architecture
- Update proxypilotpack build scripts
This commit is contained in:
Finessse
2025-12-30 00:25:15 +07:00
parent 7b58cdc5a6
commit ea371ccfc6
10 changed files with 118 additions and 1690 deletions
+2 -3
View File
@@ -44,7 +44,7 @@
- 🧩 **Context Compression** - LLM-based summarization for long sessions (Factory.ai research)
- 🤖 **Agentic Harness** - Guided workflow for coding agents (Anthropic research)
- 💾 **Session Memory** - Persistent storage across conversation turns
- 🎨 **Desktop App** - Native Windows control center with system tray
- 🎨 **System Tray** - Native Windows tray app for quick access
- 📡 **60+ Management APIs** - Full control via REST endpoints
---
@@ -169,9 +169,8 @@ All endpoints auto-translate between formats based on the target provider.
| Binary | Description |
|--------|-------------|
| `proxypilot` | Main API proxy server |
| `proxypilotui` | Desktop control center (Windows) |
| `cliproxytray` | System tray application (Windows) |
| `proxypilotpack` | Build and packaging tool |
| `ppswitch` | Provider/model switching utility |
---
-12
View File
@@ -7,7 +7,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/fs"
"net"
"net/http"
"net/http/httputil"
@@ -22,7 +21,6 @@ import (
"github.com/getlantern/systray"
"github.com/jchv/go-webview2"
"github.com/router-for-me/CLIProxyAPI/v6/cmd/proxypilotui/assets"
"github.com/router-for-me/CLIProxyAPI/v6/internal/api/middleware"
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
"github.com/router-for-me/CLIProxyAPI/v6/internal/desktopctl"
@@ -45,16 +43,6 @@ var dashboardMu sync.Mutex
var dashboardOpen bool
func main() {
// Start embedded asset server for the dashboard UI
assetLn, err := net.Listen("tcp", "127.0.0.1:0")
if err == nil {
assetServerURL = "http://" + assetLn.Addr().String()
go func() {
fsys, _ := fs.Sub(assets.FS, ".")
http.Serve(assetLn, http.FileServer(http.FS(fsys)))
}()
}
var repoRoot string
var configPath string
flag.StringVar(&repoRoot, "repo", "", "Repo root (used to locate logs/)")
+8 -27
View File
@@ -125,10 +125,6 @@ func buildBinaries(repoRoot, binRoot string) error {
if runtime.GOOS != "windows" {
trayExe = filepath.Join(binRoot, "ProxyPilot")
}
uiExe := filepath.Join(binRoot, "ProxyPilotUI.exe")
if runtime.GOOS != "windows" {
uiExe = filepath.Join(binRoot, "ProxyPilotUI")
}
if err := run(repoRoot, "go", "build", "-o", proxyExe, "./cmd/server"); err != nil {
return err
@@ -143,13 +139,6 @@ func buildBinaries(repoRoot, binRoot string) error {
return err
}
}
if runtime.GOOS == "windows" {
if err := run(repoRoot, "go", "build", "-ldflags", "-H=windowsgui", "-o", uiExe, "./cmd/proxypilotui"); err != nil {
return err
}
} else {
// The UI binary is only supported on Windows for now; skip on other OSes.
}
if runtime.GOOS == "windows" {
ico := trayicon.ProxyPilotICO()
@@ -169,7 +158,6 @@ func packageZip(repoRoot, binRoot, distRoot string) error {
dst string
}{
{src: filepath.Join(binRoot, "ProxyPilot.exe"), dst: "ProxyPilot.exe"},
{src: filepath.Join(binRoot, "ProxyPilotUI.exe"), dst: "ProxyPilotUI.exe"},
{src: filepath.Join(binRoot, "ProxyPilot.ico"), dst: "ProxyPilot.ico"},
{src: filepath.Join(binRoot, "proxypilot-engine.exe"), dst: "proxypilot-engine.exe"},
// Back-compat: keep a copy under the legacy name for older launchers/scripts.
@@ -223,14 +211,10 @@ func packageSetup(repoRoot, binRoot, distRoot string) error {
// Payload files
mgrExe := filepath.Join(binRoot, "ProxyPilot.exe")
uiExe := filepath.Join(binRoot, "ProxyPilotUI.exe")
srvExe := filepath.Join(binRoot, "proxypilot-engine.exe")
if err := copyFile(mgrExe, filepath.Join(staging, "ProxyPilot.exe")); err != nil {
return err
}
if err := copyFile(uiExe, filepath.Join(staging, "ProxyPilotUI.exe")); err != nil {
return err
}
if err := copyFile(srvExe, filepath.Join(staging, "proxypilot-engine.exe")); err != nil {
return err
}
@@ -250,7 +234,6 @@ func packageSetup(repoRoot, binRoot, distRoot string) error {
"set \"DEST=%LOCALAPPDATA%\\ProxyPilot\"\r\n" +
"if not exist \"%DEST%\" mkdir \"%DEST%\" >nul 2>&1\r\n" +
"copy /Y \"%SRC%ProxyPilot.exe\" \"%DEST%\\ProxyPilot.exe\" >nul\r\n" +
"copy /Y \"%SRC%ProxyPilotUI.exe\" \"%DEST%\\ProxyPilotUI.exe\" >nul\r\n" +
"copy /Y \"%SRC%proxypilot-engine.exe\" \"%DEST%\\proxypilot-engine.exe\" >nul\r\n" +
"copy /Y \"%SRC%proxypilot-engine.exe\" \"%DEST%\\cliproxyapi-latest.exe\" >nul\r\n" +
"if exist \"%SRC%config.example.yaml\" copy /Y \"%SRC%config.example.yaml\" \"%DEST%\\config.example.yaml\" >nul\r\n" +
@@ -279,8 +262,8 @@ func packageSetup(repoRoot, binRoot, distRoot string) error {
}
// If config.example.yaml is absent, omit it to avoid IExpress build failure.
if _, err := os.Stat(filepath.Join(staging, "config.example.yaml")); errors.Is(err, os.ErrNotExist) {
sed = strings.ReplaceAll(sed, "%FILE3%=config.example.yaml\r\n", "")
sed = strings.ReplaceAll(sed, "FILE3=config.example.yaml\r\n", "")
sed = strings.ReplaceAll(sed, "%FILE2%=config.example.yaml\r\n", "")
sed = strings.ReplaceAll(sed, "FILE2=config.example.yaml\r\n", "")
}
if err := os.WriteFile(sedPath, []byte(sed), 0o644); err != nil {
return err
@@ -334,16 +317,14 @@ SourceFiles=SourceFiles
SourceFiles0=%s
[SourceFiles0]
%%FILE0%%=ProxyPilot.exe
%%FILE1%%=ProxyPilotUI.exe
%%FILE2%%=proxypilot-engine.exe
%%FILE3%%=config.example.yaml
%%FILE4%%=install.cmd
%%FILE1%%=proxypilot-engine.exe
%%FILE2%%=config.example.yaml
%%FILE3%%=install.cmd
[Strings]
FILE0=ProxyPilot.exe
FILE1=ProxyPilotUI.exe
FILE2=proxypilot-engine.exe
FILE3=config.example.yaml
FILE4=install.cmd
FILE1=proxypilot-engine.exe
FILE2=config.example.yaml
FILE3=install.cmd
`, outEsc, stagingEsc), nil
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10 -17
View File
@@ -1,20 +1,13 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="pp-mgmt-key" content="test123" />
<title>webui</title>
<!-- Google Fonts preconnect for performance -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Google Fonts: Space Grotesk (display/headers), JetBrains Mono (code), IBM Plex Sans (body) -->
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<script type="module" crossorigin src="/assets/index.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index.css">
</head>
<body>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="pp-mgmt-key" content="">
<title>ProxyPilot</title>
</head>
<body>
<div id="root"></div>
</body>
<p>Run <code>npm run build</code> in the webui directory to build the dashboard.</p>
</body>
</html>
File diff suppressed because it is too large Load Diff
+75 -62
View File
@@ -1,58 +1,60 @@
# ProxyPilot Desktop App Build Process
# ProxyPilot CLI + Tray Build Process
Documentation of the desktop application build and release process established on December 27, 2025.
Documentation of the CLI and system tray application build and release process.
## Overview
ProxyPilot Desktop is a **single executable** that includes both the system tray UI and the proxy engine:
- **ProxyPilot.exe** - System tray app with embedded WebView2 dashboard and embedded proxy engine
ProxyPilot uses a **CLI + system tray architecture**:
- **proxypilot.exe** - CLI executable with all proxy functionality
- **ProxyPilot.exe** - System tray app that manages the CLI process and provides quick access to controls
The dashboard is accessed via web browser at `http://127.0.0.1:<port>/proxypilot.html`.
## Architecture
```
┌─────────────────────────────────────────────────────────────────┐
│ ProxyPilot.exe │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ System Tray │ │ WebView2 │ │ Embedded Assets │ │
│ │ (systray) │ │ Dashboard │ │ (webui/dist) │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
│ ProxyPilot System │
│ │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ Embedded Proxy Engine (goroutine) ││
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ ││
│ │ │Thinking Proxy│ │ Routing │ │ Provider Auth │ ││
│ │ │ (port 8317) │ │ Engine │ │ Management │ ││
│ │ └─────────────┘ └─────────────┘ └─────────────────────┘ ││
│ └─────────────────────────────────────────────────────────────┘│
│ ┌─────────────────────┐ ┌─────────────────────────────┐ │
│ │ ProxyPilot.exe │ │ proxypilot.exe │ │
│ │ (System Tray) │─────▶│ (CLI / Engine) │ │
│ │ │ │ │ │
│ │ - Start/Stop │ │ - Proxy Engine (port 8317) │ │
│ │ - Open Dashboard │ │ - Web Dashboard Server │ │
│ │ - Copy API URL │ │ - Provider Auth Mgmt │ │
│ │ - Autostart toggle │ │ - Routing Engine │ │
│ └─────────────────────┘ └─────────────────────────────┘ │
│ │
│ ┌─────────────────────┐ │
│ │ Web Browser │ │
│ │ (Dashboard UI) │ │
│ │ proxypilot.html │ │
│ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
```
### In-Process Engine
### CLI + Tray Separation
The proxy engine runs as a goroutine within the same process, managed by `EmbeddedEngine`:
The architecture separates concerns:
```go
// cmd/cliproxytray/engine.go
type EmbeddedEngine struct {
mu sync.Mutex
service *cliproxy.Service
cancel context.CancelFunc
running bool
port int
// ...
}
**proxypilot.exe (CLI)**:
- All proxy engine functionality
- Serves web dashboard at `/proxypilot.html`
- Can run standalone from command line
- Supports all CLI flags (`--help`, `--setup-claude`, etc.)
func (e *EmbeddedEngine) Start(cfg *config.Config, configPath, password string) error
func (e *EmbeddedEngine) Stop() error
func (e *EmbeddedEngine) Restart(cfg *config.Config, configPath, password string) error
func (e *EmbeddedEngine) Status() Status
```
**ProxyPilot.exe (Tray)**:
- Lightweight system tray wrapper
- Manages CLI process lifecycle (start/stop/restart)
- Opens dashboard in default browser
- Provides quick-access menu
Benefits of single-binary architecture:
- **Simpler deployment**: One file to distribute and install
- **Smaller total size**: ~29MB vs ~46MB (shared Go runtime)
- **Faster startup**: No process spawning overhead
- **Easier debugging**: Single process to monitor
Benefits of CLI + tray architecture:
- **Flexibility**: Use CLI directly or via tray app
- **No WebView2 dependency**: Dashboard runs in any browser
- **Simpler debugging**: Inspect network/console in browser DevTools
- **Cross-platform dashboard**: Same web UI works on all platforms
## Build Process
@@ -73,7 +75,7 @@ npm install
npm run build
```
This generates `webui/dist/` with the dashboard assets.
This generates `webui/dist/` with the dashboard assets that are served by the CLI at `/proxypilot.html`.
### Step 2: Create Multi-Resolution Icon
@@ -106,10 +108,13 @@ goversioninfo -icon="../../static/icon.ico"
This creates `resource.syso` files that Go automatically includes during build.
### Step 4: Build Executable
### Step 4: Build Executables
```bash
# Build single-binary tray app (with -H windowsgui to hide console)
# Build CLI executable
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/proxypilot.exe ./cmd/server
# Build tray app (with -H windowsgui to hide console)
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -H windowsgui" -o dist/ProxyPilot.exe ./cmd/cliproxytray
```
@@ -134,7 +139,7 @@ Output: `dist/ProxyPilot-0.1.0-Setup.exe`
"ProductVersion": {"Major": 0, "Minor": 1, "Patch": 0, "Build": 0}
},
"StringFileInfo": {
"FileDescription": "ProxyPilot Desktop App",
"FileDescription": "ProxyPilot System Tray",
"ProductName": "ProxyPilot",
"ProductVersion": "0.1.0"
},
@@ -142,12 +147,12 @@ Output: `dist/ProxyPilot-0.1.0-Setup.exe`
}
```
### Embedded Engine
### Tray Process Manager
**cmd/cliproxytray/engine.go** - Manages the in-process proxy service:
- Uses `cliproxy.NewBuilder()` SDK to build the service
- Runs in a goroutine with cancellable context
- Thread-safe start/stop/restart operations
**cmd/cliproxytray/engine.go** - Manages the CLI process:
- Spawns/stops `proxypilot.exe` subprocess
- Monitors process health
- Passes configuration and management password
### Tray Icon Embedding
@@ -170,8 +175,8 @@ func ProxyPilotICO() []byte {
### Installer Script
**installer/proxypilot.iss** - Inno Setup script that:
- Installs ProxyPilot.exe to `%LOCALAPPDATA%\ProxyPilot`
- Creates Start Menu and Desktop shortcuts
- Installs `proxypilot.exe` and `ProxyPilot.exe` to `%LOCALAPPDATA%\ProxyPilot`
- Creates Start Menu shortcut
- Adds optional Windows startup entry
- Copies config.example.yaml and creates config.yaml on first install
- Uses ProxyPilot icon for installer and shortcuts
@@ -182,12 +187,12 @@ Simplified flat menu structure:
```
┌─────────────────────┐
│ Open Dashboard │ → Opens WebView2 window
│ Open Dashboard │ → Opens browser to proxypilot.html
├─────────────────────┤
│ Start/Stop │ → Toggle proxy engine
│ Start/Stop │ → Toggle proxy engine (CLI process)
│ Copy API URL │ → Copies http://127.0.0.1:8317/v1
├─────────────────────┤
│ Quit │ → Exit application
│ Quit │ → Stop engine and exit
└─────────────────────┘
```
@@ -228,11 +233,11 @@ gh release upload v0.1.0 dist/ProxyPilot.exe
3. Verify resource.syso was generated after icon update
4. Rebuild the executable
### WebView2 Dashboard Not Loading
### Dashboard Not Loading in Browser
1. Ensure WebView2 runtime is installed on the system
2. Check that webui/dist/ assets are embedded (go:embed directive)
3. Verify the asset server is starting on a free port
1. Ensure the CLI process is running (check tray status)
2. Verify the port is correct: `http://127.0.0.1:8317/proxypilot.html`
3. Check for port conflicts with another application
### Tray Icon Shows Wrong Image
@@ -251,9 +256,11 @@ gh release upload v0.1.0 dist/ProxyPilot.exe
```
ProxyPilot/
├── cmd/
│ ├── server/
│ │ └── main.go # CLI entry point
│ └── cliproxytray/
│ ├── main_windows.go # Tray app with embedded engine
│ ├── engine.go # EmbeddedEngine implementation
│ ├── main_windows.go # Tray app entry point
│ ├── engine.go # CLI process manager
│ ├── versioninfo.json # Version/icon config
│ └── resource.syso # Compiled resources
├── internal/
@@ -265,23 +272,29 @@ ProxyPilot/
│ └── icon.png # Original PNG logo
├── webui/
│ ├── src/ # React dashboard source
│ └── dist/ # Built assets (embedded)
│ └── dist/ # Built assets (served by CLI)
├── installer/
│ └── proxypilot.iss # Inno Setup script
└── dist/ # Distribution files
└── ProxyPilot.exe # Single-binary (~29MB)
├── proxypilot.exe # CLI executable
└── ProxyPilot.exe # Tray app
```
## Version History
- **v0.3.0** (2025-12-30) - CLI + Tray architecture
- Removed WebView2 dependency
- Dashboard served by CLI, opened in browser
- Tray app manages CLI subprocess
- Simplified deployment and debugging
- **v0.2.0** (2025-12-27) - Single-binary architecture
- Embedded proxy engine runs in-process
- Removed separate proxypilot-engine.exe
- Reduced total size from ~46MB to ~29MB
- Faster startup with no process spawning
- **v0.1.0** (2025-12-27) - Initial desktop app release
- **v0.1.0** (2025-12-27) - Initial release
- System tray with minimal menu
- Embedded WebView2 dashboard
- Multi-resolution icon support
- Single-file Windows installer
+2 -2
View File
@@ -1,12 +1,12 @@
# ProxyPilot
ProxyPilot is a local “AI proxy + desktop UX” for agentic CLIs (Droid/Factory, Codex CLI, Warp).
ProxyPilot is a local AI proxy with CLI + system tray interface for agentic tools (Droid/Factory, Codex CLI, Warp).
This repo started as a fork of CLIProxyAPI, but is now branded as ProxyPilot. For compatibility, some internal names and headers still use `CLIProxyAPI` (e.g. `X-CLIProxyAPI-*`).
## What’s included
- ProxyPilot tray app (Windows) to start/stop/restart the proxy engine, open the dashboard, open logs, and toggle autostart.
- ProxyPilot tray app (Windows) to start/stop/restart the proxy engine, open the web dashboard in browser, open logs, and toggle autostart.
- Prompt-budget middleware to reduce “prompt too long” failures in strict CLIs.
- Long-session memory with pinned state + persistent TODO (local disk).
- Optional auth debugging and cooldown reset endpoints for local troubleshooting.
+19 -55
View File
@@ -1,16 +1,12 @@
package api
import (
"io"
"net/http"
"os"
"path"
"regexp"
"strings"
"github.com/gin-gonic/gin"
ppassets "github.com/router-for-me/CLIProxyAPI/v6/cmd/proxypilotui/assets"
"github.com/router-for-me/CLIProxyAPI/v6/internal/misc"
)
// ppMgmtKeyRegex matches existing pp-mgmt-key meta tags to be replaced
@@ -36,12 +32,19 @@ func (s *Server) serveProxyPilotDashboard(c *gin.Context) {
return
}
index, err := fsReadFile("index.html")
if err != nil {
c.AbortWithStatus(http.StatusNotFound)
return
}
html := string(index)
// Dashboard assets are not available - return a placeholder message
html := `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ProxyPilot</title>
</head>
<body>
<h1>ProxyPilot Dashboard</h1>
<p>Dashboard UI assets are not available.</p>
</body>
</html>`
// Use localPassword from the server instance (set via WithLocalManagementPassword)
// Fall back to MANAGEMENT_PASSWORD env var for legacy subprocess mode
key := strings.TrimSpace(s.localPassword)
@@ -68,18 +71,8 @@ func (s *Server) serveProxyPilotAsset(c *gin.Context) {
c.AbortWithStatus(http.StatusForbidden)
return
}
fp := strings.TrimPrefix(c.Param("filepath"), "/")
if fp == "" {
c.AbortWithStatus(http.StatusNotFound)
return
}
name := path.Clean("assets/" + fp)
data, err := fsReadFile(name)
if err != nil {
c.AbortWithStatus(http.StatusNotFound)
return
}
writeAssetResponse(c, name, data)
// Assets not available
c.AbortWithStatus(http.StatusNotFound)
}
func (s *Server) serveProxyPilotViteIcon(c *gin.Context) {
@@ -87,12 +80,8 @@ func (s *Server) serveProxyPilotViteIcon(c *gin.Context) {
c.AbortWithStatus(http.StatusForbidden)
return
}
data, err := fsReadFile("vite.svg")
if err != nil {
c.AbortWithStatus(http.StatusNotFound)
return
}
writeAssetResponse(c, "vite.svg", data)
// Asset not available
c.AbortWithStatus(http.StatusNotFound)
}
func (s *Server) serveProxyPilotLogo(c *gin.Context) {
@@ -100,33 +89,8 @@ func (s *Server) serveProxyPilotLogo(c *gin.Context) {
c.AbortWithStatus(http.StatusForbidden)
return
}
data, err := fsReadFile("logo.png")
if err != nil {
c.AbortWithStatus(http.StatusNotFound)
return
}
writeAssetResponse(c, "logo.png", data)
}
func writeAssetResponse(c *gin.Context, name string, data []byte) {
ext := strings.TrimPrefix(path.Ext(name), ".")
if mt := misc.MimeTypes[strings.ToLower(ext)]; mt != "" {
c.Header("Content-Type", mt)
} else {
c.Header("Content-Type", "application/octet-stream")
}
c.Header("Cache-Control", "public, max-age=600")
c.Writer.WriteHeader(http.StatusOK)
_, _ = c.Writer.Write(data)
}
func fsReadFile(name string) ([]byte, error) {
f, err := ppassets.FS.Open(name)
if err != nil {
return nil, err
}
defer func() { _ = f.Close() }()
return io.ReadAll(f)
// Asset not available
c.AbortWithStatus(http.StatusNotFound)
}
func isLocalClient(c *gin.Context) bool {