interface / server.py

Browser-facing FastAPI proxy on port 8080. Handles auth, streaming, file I/O, log tailing, voice forwarding.

Endpoints

Method · PathPurpose
GET /Auth gate (?key=…). Renders index.html and injects the API key into a script.
GET /sw.jsService worker for offline / PWA.
WS /wsPersistent websocket — log line broadcast.
POST /api/chatStreaming or non-streaming chat. Returns task_id for streams.
GET /api/chat/resume/{task_id}Resume after disconnect at offset.
POST /api/chat/cancel/{task_id}Cancel an in-flight task.
POST /api/workspace/save · /loadZip download / upload of state.
POST /api/upload · GET /api/download/{path}File I/O against the agent.
POST /api/sttAudio → text via the Raspberry Pi voice server.
POST /api/ttsText → audio stream via the Raspberry Pi voice server.

Streaming model

Buffer & payload limits

Log streaming

A log_streamer() task spawns tail -f on the agent log and broadcasts to connected websockets. Detects ERROR/Exception and tags is_error for client reactivity. Subprocess is cleaned up with timeout-then-kill on shutdown.

Auth

Concurrency

Static assets

interface/static/ holds index.html (three.js, marked, dompurify, mermaid, papaparse, chart.js via CDN), app.js (auth wrapper that injects X-Ghost-Key on every /api/ fetch, voice queue management, monologue display, renderer iframe), style.css (cyan/magenta cyber theme), matrix_graph.js (three.js particle system), image_face.js, cyber_face.png, and sw.js (service worker).