The dashboard.py module#

Summary#

summarize_log

Summarize the tail of a lane log.

collect_status

Build the status document served at /api/status.

make_handler

Build the request handler serving the page and the status JSON.

make_server

Create the dashboard server on loopback without starting it.

add_arguments

Add the dashboard options to a parser.

run

Serve the dashboard until interrupted.

Description#

Local, read-only status dashboard for lanes.

Serves one HTML page and one JSON endpoint on 127.0.0.1. Status comes only from cheap, static sources: the registry file, process liveness, TCP connects to the registered ports, and the tail of each lane log. The dashboard never opens an MCP session, so it cannot load or be blocked by a busy lane.

Module detail#

dashboard.summarize_log(path: pathlib.Path, now: float | None = None) → dict[str, Any]#

Summarize the tail of a lane log.

A call is considered in progress when the most recent MCP protocol event in the log is a CallToolRequest. This is a heuristic: the lane may also be frozen inside the call.

Parameters:
pathpathlib.Path

Lane log file.

nowfloat, optional

Current POSIX time. Defaults to time.time().

Returns:
dict[str, Any]

Log size, idle time, last protocol event, running call, and last error.

dashboard.collect_status(refresh_seconds: int = DEFAULT_REFRESH_SECONDS) → dict[str, Any]#

Build the status document served at /api/status.

The registry is read without the lock: writers replace the file atomically, and a monitor must never contend with the live registry.

Parameters:
refresh_secondsint, default: 30

Refresh interval suggested to the page.

Returns:
dict[str, Any]

Registry details and per-lane status. Lane tokens are never included.

dashboard.make_handler(refresh_seconds: int) → type[http.server.BaseHTTPRequestHandler]#

Build the request handler serving the page and the status JSON.

Parameters:
refresh_secondsint

Refresh interval suggested to the page.

Returns:
type[http.server.BaseHTTPRequestHandler]

Handler class.

dashboard.make_server(port: int, refresh_seconds: int) → http.server.ThreadingHTTPServer#

Create the dashboard server on loopback without starting it.

Parameters:
portint

Port to bind. 0 picks a free port.

refresh_secondsint

Refresh interval suggested to the page.

Returns:
http.server.ThreadingHTTPServer

Dashboard server.

dashboard.add_arguments(parser: argparse.ArgumentParser) → None#

Add the dashboard options to a parser.

Parameters:
parserargparse.ArgumentParser

Parser to extend.

dashboard.run(port: int, refresh_seconds: int, open_browser: bool = True) → int#

Serve the dashboard until interrupted.

Parameters:
portint

Port to bind.

refresh_secondsint

Refresh interval suggested to the page.

open_browserbool, default: True

Whether to open the page in a browser.

Returns:
int

Process exit code.

dashboard.DEFAULT_PORT = 8765#
dashboard.DEFAULT_REFRESH_SECONDS = 30#
dashboard.MIN_REFRESH_SECONDS = 2#
dashboard.LOG_TAIL_BYTES = 65536#
dashboard.BUSY_WARN_SECONDS = 30.0#
dashboard.HOST = '127.0.0.1'#