The Web Harness: Browser UI Driven by the CLI
Kompile's Web Harness gives you a multi-project browser interface — live streaming chat, interactive subagent & process controls, an embedded PTY terminal, disk/storage auditing, provider authentication, and cross-session insights — without duplicating a single line of agent logic.
Every prompt, Enforcer rule, Judge verdict, permission check, failover ladder, and tool call still executes inside the real kompile CLI harness. The web server is strictly a thin transport, replay buffer, and UI shell over it.
TIP
Deciding whether to start in the terminal or the browser? See the companion getting-started guide: CLI vs. Web Harness.
Slim vs. full persona packaging
Kompile ships the Web Harness in two forms that share the exact same web controller layer (kompile-app-web-chat-harness) and Angular SPA (kompile-app-ui:chat):
| Artifact | Ships With | Footprint | What's Included |
|---|---|---|---|
kompile-chat-harness (lib/kompile-chat-harness.jar or native bin/kompile-chat) | cli-harness distribution | ~58 MB JAR (includes 6.4 MB Angular SPA) | Full Web Harness UI (multi-project chat workspace, live controls, embedded terminal, processes, sources/peers, insights, storage, provider auth) — zero ND4J, DL4J, Hibernate/JPA, Anserini/Lucene, or local graph/ingest engines |
kompile-chat (lib/kompile-chat.jar or native bin/kompile-chat) | Full / GPU distributions | Full chat persona | Everything in kompile-chat-harness plus local RAG, fact sheets, and read-only knowledge-graph exploration |
Both bind port :8081 by default and strictly enforce the App Persona Boundary: admin routes (/data, /developer, /agents, /enforcer, and graph build/audit/ontology mutation surfaces) stay on :8080 (kompile-app-main), while crawl/ingest operations stay on :8082 (kompile-app-crawl-manager). Their components are not even on the chat app's classpath.
Launching the Web Harness
Launch directly from any repository with kompile chat --web, or run the standalone launcher script:
# Default: LAN-accessible multi-project workspace on :8081 (or next free port)
cd /path/to/your/repo
kompile chat --web
# Automatically open your default browser
kompile chat --web --open-browser
# Bind a specific port (0 = automatic ephemeral port)
kompile chat --web --web-port 9081
# Restrict to a single-project chat view (no multi-project sidebar)
kompile chat --web --single-chat
# Standalone dist launcher (prefers native bin/kompile-chat, falls back to JAR / JBang)
bin/kompile-chat.sh --port 8081TIP
Zero-config startup: kompile chat --web does not require pre-existing provider credentials — it prints the local URL immediately so you can configure providers, accounts, and models right inside the browser (or pass --setup to run the CLI wizard first).
Instance registration (HarnessInstanceRegistrar)
On startup, every kompile-app-chat-harness or kompile-app-chat JVM registers itself in ~/.kompile/instances/<type>-<port>-<pid> with its bound port, PID, canonical Kompile home path, and persistent homeId. Running two web harness instances against the same Kompile home is immediately visible to CLI commands, peer status checks, and the Web UI.
Architecture: CLI-as-Authority transport
flowchart LR
UI["Angular Chat SPA\n(kompile-app-ui:chat)\n/chat /processes /sources\n/insights /storage /settings"] <-->|"SSE Stream + REST Controls\n+ PTY WebSocket"| WEB["Spring Web Layer\n(kompile-app-web-chat-harness)\nHarnessReplayBuffer"]
WEB -->|"web-json + JSONL stdin\n(--web-controls -)"| CLIENT["KompileCliHarnessClient\n(Worker Pool: 4 default, cap 8)"]
CLIENT -->|"stream-json stdout"| WEB
CLIENT <--> CLI["kompile chat Child Process\n(HeadlessAgentRunner /\nHeadlessPassthroughRunner)"]
CLI --> ENGINE["Enforcer • Judge • Permissions\nSubagentAdmission • ModelFailoverController\nMCP Tools • Native CLIs"]
WEB <-->|"pty4j PTY"| TERM["Embedded CLI Terminal\n(/api/agents/chat/terminal/socket/*)"]How a browser turn executes
- Launch:
KompileCliHarnessClientspawnskompile chat --input-format web-json --output-format stream-json --web-controls -inside the selected project's working directory. Unlike plain one-shotexec,--web-controls -consumes one initialweb-jsonpayload and keepsstdinopen for live JSONL control frames. (Embedded immutable product profiles use a persistent--web-session-workermanaged byKompileCliSessionWorkerwith explicitsession_openframing.) - Authority stays in the CLI: The web layer never constructs system prompts, never runs tool calls itself, and never bypasses permission policies. The CLI child enforces the exact same Enforcer, Judge, Subagent admission/failover rules, and
ModelFailoverControllerrequest-boundary retry logic as terminal chat. - Serialized turn loop: The CLI's dispatch owner serializes model turns. Queued follow-up inputs and background task/process completion wake-ups trigger follow-up turns inside the same live run before emitting the final
resultevent.
Multi-project workspace & native session browser
By default (kompile chat --web), the browser opens in Workspace mode:
- Explicit canonical project roots: Your launch directory is registered automatically. Add additional absolute directories on the server host from the project sidebar. The non-secret index persists at
~/.kompile/chat-workspace.jsonusing cross-process locking and atomic replacement. Registering a parent directory never implicitly authorizes arbitrary subdirectories. - Independent concurrent panes: Open up to 8 panes across one or many projects. Switching tabs hides rather than destroys panes, so multiple chats keep streaming in parallel. Each pane owns its own CLI transport, provider/model state, scoped history, and live controls (keyboard shortcuts and the header settings gear always target only the active pane).
- Bounded CLI worker pool: Workspace mode defaults to 4 concurrent CLI workers (single-chat mode uses 1). Override via
-Dkompile.web.chat.harness.maxConcurrent=<N>(capped at 8, with 2 queued turns). - Project-scoped session identity: Session identity combines the canonical project root and browser chat ID, so one project cannot accidentally resume another project's transcript.
- Native external session browser: Through
/api/agents/chat/workspace/native-sourcesand/native/open, browse and open existing native sessions from external coding CLIs (claude-code,codex,agy,opencode, etc.) directly inside the workspace — powered by the same adapters documented in Import & Resume.
Live controls, streaming & bounded reconnect
Bidirectional control protocol
While a run is active, the browser streams monotonic SSE events from POST /api/agents/chat/stream and sends live control actions (background, input, command, etc.) to POST /api/agents/chat/control/{runId} when you click UI buttons, press Ctrl+B, or type into the input bar:
| Control Action / Shortcut | What It Does |
|---|---|
background (Ctrl+B / Background) | Transfers an eligible blocking subagent invocation into the CLI's retained background-task lifecycle (model thinking is not backgroundable) |
input (Enter while running) | Queues plain-text follow-up input for the next turn boundary (visible in the Activity panel; capped at 64 queued inputs per run) |
command (/ during a run) | Dispatches live slash commands directly to WebHarnessControls — never injected into the model's prompt text |
subagent_input / subagent_cancel | Sends targeted follow-up input to, or cancels, a single retained child subagent (Enter in a child composer / Delete on a focused child) |
process_list / process_output / process_kill / process_unmonitor | Lists live processes, reads up to 2,000 log lines, stops a process, or cancels a completion wake-up monitor (Cancel wake-up) without killing the process |
workflow_approve | Approves or rejects pending workflow / supervised action gates |
POST /api/agents/chat/cancel/{runId} (Escape / Stop) | Ends the entire live run and all work owned by it (Ctrl+C stays browser copy) |
Strict acknowledgement semantics:
HTTP 202 {"accepted": true}means the control frame was written to the CLI's stdin pipe — not executed.- Only the correlated
controlSSE event (requestId,action,ok,message) confirms execution. A lost acknowledgement is treated as unknown and never blindly retried. - Frame limits are enforced fail-closed in the CLI: max 64 KiB per frame, 64 queued inputs, and 4,096 request IDs per run.
Bounded SSE replay & resilient browser reconnect
Disconnecting a browser tab or putting a laptop/phone to sleep only detaches the SSE subscriber — the CLI child keeps running.
- Atomic replay + live attach: Every SSE event carries a monotonic
id(starting withqueued). Reconnecting toGET /api/agents/chat/events/{runId}?after=Nreplays missed events fromHarnessReplayBufferand attaches live atomically. - No tab fighting (
superseded): If a new connection takes over a run, the superseded view receives asupersededevent and stops automatic reconnect instead of racing for ownership. - Origin-scoped checkpoints: The browser checkpoints rendered message state, turn identity, cursor, and
runId(never credentials) tolocalStorageat turn boundaries and at most every 250 ms. Reloading a tab, navigating back (pageshow), or waking a page hidden for ≥5 s automatically drops stale sockets and replays from the saved cursor. - Backoff & resync: Broken streams retry up to 8 visible/online attempts with exponential backoff (
0.5 s→8 s, treating proxy502/503/504as network errors). If a cursor falls behind the replay buffer (1 MiB / 2,000 events per run, 32 completed runs, 35-minute retention), the server sendsresyncand the browser reloads the full CLI transcript once the run ends so partial replay is never shown as complete. - Clean expiration: After server restart or buffer expiration (
410), the browser clears the checkpoint cleanly and loads the saved CLI transcript — never silently resubmitting user input.
Web Harness surfaces (UI tabs & embedded terminal)
The Angular SPA exposes six primary harness surfaces (plus local RAG/Graph/Fact Sheet tabs when running full kompile-chat):
| Route | Backend Controller(s) | What You Can Do |
|---|---|---|
/chat & /single-chat | HarnessAgentChatController, ChatWorkspaceController, CliTerminalController | Multi-project workspace or single chat, capability-driven / menu (GET /api/agents/chat/capabilities), live context budget (/context-budget) and /compact, settings dialog, saved child conversation picker, and embedded PTY terminal |
/processes | HarnessProcessesController, /api/agents/chat/timeline/stream | Terminal /processes parity: active watchers, running commands, 8 most recent finished processes, 2,000-line log viewer, completion wake-up monitor cancellation, child subagents, token breakdowns, and live SSE timeline Follow |
/sources | HarnessSourcesController | Discover, auto-attach, search, read/write, pull/push, and install external sources; manage kompile sync peers and artifact transfers; inspect local model runtime status |
/insights | ChatInsightsController, SessionMetricsController | Cross-session reports for judge verdicts, tool calls, project-scoped /test-milestones, crawls, and graphs, plus the headless /cost query panel |
/storage | HarnessStorageController | Non-overlapping disk breakdown of ~/.kompile and active project, interactive file browser, kompile gc cleanup actions, conversation pin/unpin/restore, and gc-config.json / log-retention.json policy editing |
/settings | HarnessAuthController (/api/agents/chat/auth) | CLI-backed provider auth status, API key login, named account switching, and logout (plus Model Staging connection settings) |
Settings drafts & saved child conversations
- No secrets in route drafts: The browser's
/subagent-configand/model failover(alias/model ladder) editors save atomic JSON drafts containing only canonical route metadata (provider,model,credentialName,label,thinking,authenticationMethod). No API key/token fields are accepted, and parse errors never echo pasted input. - Saved child conversations: The settings picker uses
/subagents saved,/subagents show <exact-id>, and/subagents resumeto inspect (up to 30 plain-text messages / 64 KiB) and continue durable subagents directly through the realsubagent_resumetool — preserving child ID, caller permissions, locks, and budget totals.
Embedded interactive CLI terminal (pty4j over WebSocket)
Need a raw interactive shell or terminal TUI without leaving the browser? CliTerminalController (/api/agents/chat/terminal) and CliTerminalWebSocketConfiguration (/api/agents/chat/terminal/socket/*) host real pty4j terminal sessions bound to the active project:
- Strict access boundary: Enforces a loopback guard, Spring same-origin check, required
Originheader, and an established HTTP session bound to the terminal owner (64 KiBmax WebSocket text frame). - Session lifecycle: Supports listing sessions, inspecting transcripts, launching new sessions, and stopping/reaping idle terminals cleanly.
Truthful telemetry
Usage-only SSE events preserve token counts while leaving unmeasured fields (cost, elapsed generation time, throughput, turn count) explicitly omitted rather than fabricating 0. Invalid, negative, or NaN values are never rendered as real measurements.
CLI ↔ Web slash-command parity & boundaries
The Web Harness shares its slash-command catalog and parsers directly with terminal chat (ChatCommandCatalog → GET /api/agents/chat/capabilities drives the browser's / autocomplete menu):
- Shared report & command executors:
WebTaskReports(/todos*,/progress-reports*,/dashboard-tasks,/subagent-breakdown),WebSessionReports(/diffs,/sessions,/conversations,/transcript,/history,/recall,/tools,/agents,/status),WebSessionCommands(/config,/provider,/resources,/tool,/local-tool,/crawl),WebMaintenanceCommands(/title,/memory,/auto-compact,/gc,/mcp,/agent,/mode,/enforcer), andWebTestMilestones(/test-milestones, strictly project-scoped). - Mid-run vs. deferred execution: Read-only and run-state commands (
/processes,/jobs,/todos,/progress-reports,/status, …) answer immediately during an active run; state-changing builtins queue cleanly and execute when the live run finishes. - Terminal-bound commands: Terminal-only commands (
restart,reset,passthrough,resume*,image/attach) return an explicitTERMINAL_REQUIREDresponse naming the corresponding web UI control rather than failing cryptically.
Explicit architectural boundaries
- Not durable daemon recovery: Live runs do not survive application shutdown or the run timeout (max 30 minutes). Reconnect recovers browser drops and reloads — it cannot resurrect a killed JVM.
- Per-JVM concurrency & local GPU reality: Subagent admission caps apply per CLI JVM; running multiple browser panes in parallel calls remote providers concurrently, but does not multiply local GPU VRAM capacity.
- CLI owns permissions: Another session's shared background process can be inspected from the browser, but never killed across session ownership boundaries.
Related guides
- The CLI Harness (TUI, Navigation & Configuration) — Terminal UI layout, menu navigation,
/uipresets, andkompile configure - Why Kompile Is Opinionated — The shared harness model behind both CLI and Web
- Import & Resume — Importing external CLI/IDE histories and cross-agent resume
- Peers & Sources — Multi-machine TLS peers, blob stores, GitHub Releases, and the
/#/sourcestab - Subagents & Orchestration — Durable subagents, admission caps, and failover
- Cost & Quota Estimation —
/cost,/usage, and session metrics - App Persona Boundary — How
:8080,:8081, and:8082stay isolated - Security & Permission Model — Minimal defaults,
/permissions, fail-closed web overrides, and network exposure guidance - CLI Chat & Harness Reference — Terminal flags, modes, and passthrough options