The dashboard.py module#
Summary#
Summarize the tail of a lane log. |
|
Build the status document served at |
|
Build the request handler serving the page and the status JSON. |
|
Create the dashboard server on loopback without starting it. |
|
Add the dashboard options to a parser. |
|
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:
- path
pathlib.Path Lane log file.
- now
float,optional Current POSIX time. Defaults to
time.time().
- path
- Returns:
- 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.
- dashboard.make_handler(refresh_seconds: int) type[http.server.BaseHTTPRequestHandler]#
Build the request handler serving the page and the status JSON.
- Parameters:
- refresh_seconds
int Refresh interval suggested to the page.
- refresh_seconds
- 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:
- Returns:
http.server.ThreadingHTTPServerDashboard server.
- dashboard.add_arguments(parser: argparse.ArgumentParser) None#
Add the dashboard options to a parser.
- Parameters:
- parser
argparse.ArgumentParser Parser to extend.
- parser
- dashboard.run(port: int, refresh_seconds: int, open_browser: bool = True) int#
Serve the dashboard until interrupted.
- 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'#