Skip to content

c0hm/miniclaw-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐚 MiniClaw UI

Real-time web dashboard for the OpenClaw Gateway. Watch agent sessions unfold, inspect tool calls and LLM reasoning, track token usage, chat with agents, and share files β€” all from a browser.

Vanilla JS SPA Β· WebSocket-driven Β· Dark theme Β· Zero build step


✨ What It Does

MiniClaw UI connects to your OpenClaw Gateway via WebSocket and streams every session event to your browser in real time. You get a live, scrollable feed of every agent action β€” tool calls, model reasoning, assistant responses, errors, and token costs β€” as they happen.

Watch agent sessions in real time. Inspect tool calls and their results with syntax-highlighted inputs and outputs. Read LLM thinking traces and assistant responses with full markdown rendering. Track token usage and estimated costs per session. Chat with any agent directly from the UI. Share files via one-shot secure URLs with an inline code viewer.


πŸš€ Quick Start

# Install
npm install

# Run (all defaults)
node miniclaw-ui.js

# Open β†’ http://localhost:1234
# Password β†’ miniclaw

That's it. The server auto-connects to your Gateway at ws://127.0.0.1:18789, loads device identity if available, and starts streaming.


πŸ“Έ What You'll See

MiniClaw UI screenshot

Area What's There
Header Title, sidebar toggle, connection status dot (green = gateway connected)
Sidebar Session list with event/message counts, click to select, delete, or create new
Event Feed Scrollable timeline of all events with badges, timestamps, expandable content
Filters Full-text search + quick filter buttons (All / LLM / Tools / Errors)
Stats Bar Live counters: Sessions Β· LLM Calls Β· Tool Calls Β· Errors
Chat Input Textarea at the bottom, Enter to send, Shift+Enter for newline, Stop button

Event Types Rendered

Badge Event What You See
πŸ”§ TOOL START tool_start Tool name, syntax-highlighted input, compact/expanded toggle
βœ… TOOL RESULT tool_result Result content, error highlighting if failed, scroll-capped
β–Ά LLM START run_start Model name, token counts as they stream in
πŸ€– RESPONSE assistant_text Full markdown rendering (12-phase pipeline), streaming updates
πŸ’­ THINKING thinking Model reasoning in muted style, auto-collapsed
πŸ‘€ USER user_text User messages, no truncation
βœ– ERROR run_error Error details in red

Tool Call Renderers

Specialized renderers for 9 tool types: read, write, edit, exec, process, web_search, web_fetch, image, and image_generate. Each renders its input/output in the most readable format β€” file contents get syntax highlighting, diffs get inline Β± markers, shell commands show the working directory and flags.


βš™οΈ Configuration

All via environment variables. No config files needed.

Variable Default Purpose
PORT 1234 HTTP server port
OPENCLAW_TOKEN auto-loaded Gateway auth token (falls back to ~/.openclaw/openclaw.json)
MCPASS miniclaw UI password (Basic Auth always on; DCPASS still supported for backward compat)
DATA_DIR ./data Session persistence directory
GW_WSS false Set to true for secure WebSocket (wss://) to Gateway
# Production example
PORT=1234 \
OPENCLAW_TOKEN=your_token \
MCPASS=strong_password \
DATA_DIR=/var/lib/miniclaw-ui/data \
node miniclaw-ui.js

# Gateway over TLS
GW_WSS=true node miniclaw-ui.js

TLS / HTTPS

Drop fullchain.pem and privkey.pem in the project root and the server auto-starts as HTTPS. No config flags β€” it just works.


πŸ”Œ How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     WebSocket      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     WebSocket      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Gateway    β”‚ ◄────────────────► β”‚  miniclaw-ui.js   β”‚ ◄────────────────► β”‚ Browser  β”‚
β”‚  :18789      β”‚   session events,  β”‚  :1234            β”‚   events, sync,   β”‚  (SPA)   β”‚
β”‚              β”‚   messages, tokens β”‚                   β”‚   status, chat    β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                           β”‚
                                           β–Ό
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚  data/*.json β”‚
                                    β”‚  (disk)      β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Server starts β†’ loads device identity (Ed25519 keys from ~/.openclaw/identity/), connects to Gateway
  2. Gateway auth β†’ challenge-response with device signing, subscribes to all sessions
  3. Browser connects β†’ receives full session sync, then real-time event stream
  4. Events flow β†’ Gateway β†’ server converts/deduplicates β†’ browser renders live
  5. Sessions persist β†’ atomic JSON writes to disk, debounced at 1s

Device Identity (v3)

If ~/.openclaw/identity/device.json and device-auth.json exist, the server authenticates to the Gateway using Ed25519 device signing β€” the same identity protocol used by the OpenClaw CLI and other tools. Falls back to token-only auth if identity files aren't present.


πŸ“‘ API

Full REST API for automation and external tooling.

Sessions

Method Endpoint Description
GET /api/status Gateway status, session count, client count
GET /api/sessions List all sessions with summaries
GET /api/session/:key Full session: events + messages + token data
GET /api/events/:key?limit=100 Events only, paginated
POST /api/session/:key/reset Reset session (clear context)
POST /api/session/:key/delete Delete session permanently
POST /api/session/:key/clear-events Clear intermediate/tool events, keep final output

File Sharing

Method Endpoint Description
POST /api/files/share Generate one-shot share token β†’ { url, viewUrl, filename }
GET /api/files/serve/:token Download file (token consumed on access)
GET /api/files/view/:token Inline viewer (CodeMirror 5 + marked.js)

Agents

Method Endpoint Description
GET /api/agents Available agents from Gateway config

All endpoints require HTTP Basic Auth (password: miniclaw or MCPASS).


🧡 Browser WebSocket Protocol

The SPA speaks a simple JSON protocol over its own WebSocket to the server:

// Send a chat message
{ type: "chat", message: "Hello", sessionKey: "agent:main:main" }

// Abort a running session
{ type: "req", method: "sessions.abort", params: { key: "agent:main:main" } }

// Keepalive
{ type: "ping" }

Server pushes events as they arrive:

{ type: "event", event: "event.added", payload: { ... } }
{ type: "event", event: "session.sync", payload: { ... } }
{ type: "event", event: "session.tokens", payload: { ... } }
{ type: "event", event: "gateway.disconnected", payload: { ... } }

πŸ’» CLI Commands

When running interactively (stdin):

Command What It Does
status Show gateway connection, session count, client count
sessions List all sessions with event and message counts
events Show last 5 events per session
gc Remove sessions inactive > 1 hour
reset Clear all in-memory sessions (disk untouched)
help List available commands

πŸ—‚οΈ Project Structure

miniclaw-ui/
β”œβ”€β”€ miniclaw-ui.js      # Server: Gateway WS + HTTP + Browser WS + session state
β”œβ”€β”€ index.html          # Frontend: vanilla JS SPA (3776 lines)
β”œβ”€β”€ docs/               # Full documentation (17 files)
β”‚   β”œβ”€β”€ index.md                        # Architecture overview (LLM-optimized)
β”‚   β”œβ”€β”€ gateway-websocket.md            # Gateway protocol v4, device identity
β”‚   β”œβ”€β”€ event-types-reference.md        # All event shapes, tool input schemas
β”‚   β”œβ”€β”€ event-rendering.md              # Dispatch, renderers, markdown pipeline
β”‚   β”œβ”€β”€ websocket-client.md             # Browser WS client, dedup, state machine
β”‚   β”œβ”€β”€ ui-components.md                # 30+ state variables, modals, theme
β”‚   β”œβ”€β”€ frontend-patterns.md            # Copyable implementation patterns
β”‚   β”œβ”€β”€ session-management.md           # SessionState, persistence, dedup
β”‚   β”œβ”€β”€ message-processing.md           # Event conversion, metadata filtering
β”‚   β”œβ”€β”€ http-api.md                     # REST API reference
β”‚   β”œβ”€β”€ file-sharing.md                 # One-shot file URLs + viewer
β”‚   β”œβ”€β”€ authentication.md               # Basic Auth setup
β”‚   β”œβ”€β”€ configuration.md                # All env vars, TLS auto-detect
β”‚   β”œβ”€β”€ cli-commands.md                 # CLI reference
β”‚   β”œβ”€β”€ troubleshooting.md              # Common issues and fixes
β”‚   β”œβ”€β”€ glossary.md                     # Domain terminology
β”‚   └── contributing.md                 # How to contribute
β”œβ”€β”€ data/               # Session persistence (auto-created)
β”‚   └── session-{key}.json
β”œβ”€β”€ package.json
└── README.md

πŸ”§ Tech Stack

Layer Technology
Runtime Node.js (no transpilation, no build step)
WebSocket ws (both Gateway client and browser server)
HTTP Node.js built-in http/https
Frontend Vanilla JavaScript, CSS custom properties
Markdown Custom 12-phase pipeline (no external library)
Code Highlighting Custom regex-based (no highlight.js dependency)
File Viewer CodeMirror 5 + marked.js (loaded on demand)
Storage JSON files, atomic writes (temp β†’ rename)
Auth HTTP Basic Auth + Ed25519 device identity

πŸ› οΈ Troubleshooting

Problem Likely Fix
"Connecting to gateway..." stuck Gateway not running on :18789; check GW_WSS=true if TLS
401 Unauthorized Password is miniclaw (or your MCPASS value)
No sessions listed Send a message β€” sessions are created on first interaction
Empty event feed Click a session; events stream via WebSocket push, not on-demand fetch
Scroll stuck / "New messages" button Scroll to bottom manually or clear filters
High memory / slow Run gc from CLI; delete old data/*.json files
Corrupted session POST /api/session/:key/delete or rm data/session-{key}.json
# Quick health check
curl -u :miniclaw http://localhost:1234/api/status

# Nuclear option
rm -rf data/*.json && node miniclaw-ui.js

πŸ“š Documentation

Every aspect of the project is documented in docs/. Start with docs/index.md for the architecture overview β€” it's written to be LLM-friendly and serves as the single source of truth.

Key docs by topic:


πŸ€– Agent-Ready

This repo includes an AGENTS.md that turns any coder agent into a productive MiniClaw UI developer on first read. It contains:

  • Full architecture diagram with data flow
  • Complete source layout β€” every section of both source files (1838 + 3776 lines) mapped by line range with descriptions
  • Doc reading guide β€” which docs to read before touching each part of the code
  • Quick facts reference β€” dedup strategies, save behavior, auth, markdown pipeline
  • Mandatory task workflow β€” task docs before code, docs as source of truth
  • Edge cases & gotchas β€” dedup windows, session lifecycle, event conversion quirks, UI state machine, file sharing constraints
  • Shell script reference β€” install.sh interactive setup, restart.sh, systemd service

Drop a coder agent into this repo and it knows what to do.

🀝 Contributing

See docs/contributing.md. Task tracking lives in docs/tasks/. Every change gets a task doc before code is written.


Built for OpenClaw. MIT license.

About

a thin, no-framework dashboard for OpenClaw Gateway. Real-time session monitoring, full event visibility, zero bloat. Minimum payload, maximum control.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Contributors