Skip to content

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):

ArtifactShips WithFootprintWhat'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 distributionsFull chat personaEverything 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:

bash
# 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 8081

TIP

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 ​

mermaid
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 ​

  1. Launch: KompileCliHarnessClient spawns kompile chat --input-format web-json --output-format stream-json --web-controls - inside the selected project's working directory. Unlike plain one-shot exec, --web-controls - consumes one initial web-json payload and keeps stdin open for live JSONL control frames. (Embedded immutable product profiles use a persistent --web-session-worker managed by KompileCliSessionWorker with explicit session_open framing.)
  2. 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 ModelFailoverController request-boundary retry logic as terminal chat.
  3. 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 result event.

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.json using 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-sources and /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 / ShortcutWhat 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_cancelSends 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_unmonitorLists 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_approveApproves 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 control SSE 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 with queued). Reconnecting to GET /api/agents/chat/events/{runId}?after=N replays missed events from HarnessReplayBuffer and attaches live atomically.
  • No tab fighting (superseded): If a new connection takes over a run, the superseded view receives a superseded event 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) to localStorage at 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 proxy 502/503/504 as 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 sends resync and 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):

RouteBackend Controller(s)What You Can Do
/chat & /single-chatHarnessAgentChatController, ChatWorkspaceController, CliTerminalControllerMulti-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
/processesHarnessProcessesController, /api/agents/chat/timeline/streamTerminal /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
/sourcesHarnessSourcesControllerDiscover, auto-attach, search, read/write, pull/push, and install external sources; manage kompile sync peers and artifact transfers; inspect local model runtime status
/insightsChatInsightsController, SessionMetricsControllerCross-session reports for judge verdicts, tool calls, project-scoped /test-milestones, crawls, and graphs, plus the headless /cost query panel
/storageHarnessStorageControllerNon-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
/settingsHarnessAuthController (/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-config and /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 resume to inspect (up to 30 plain-text messages / 64 KiB) and continue durable subagents directly through the real subagent_resume tool — 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 Origin header, and an established HTTP session bound to the terminal owner (64 KiB max 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), and WebTestMilestones (/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 explicit TERMINAL_REQUIRED response 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.

Released under the Apache-2.0 License.