Implementation:23blocks OS Ai maestro Diagnostics Service
| Knowledge Sources | |
|---|---|
| Domains | Diagnostics, Services |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete tool for running system self-diagnostics — tmux, node-pty, registry, remote hosts, Node.js, disk space — and returning a structured report, provided by AI Maestro's `services/diagnostics-service.ts`.
Description
The diagnostics-service is a pure-logic service that runs a series of health checks and returns a `DiagnosticReport`. Each check returns a `DiagnosticCheck` with `status` ('pass', 'fail', 'warn'), message, and optional details. Checks: `checkTmux` (tmux availability and version via `tmux -V`), `checkNodePty` (dynamic import of the native module), `checkAgentRegistry` (filesystem access to `~/.aimaestro/agents/`), `checkRemoteHosts` (reachability of configured peer hosts), `checkNodeVersion` (Node.js version), `checkDiskSpace` (free space on `~/.aimaestro/` partition), and AMP key/channel checks. The report summary gives total/passed/failed/warnings and an overall status.
Usage
Call `runDiagnostics()` from the `GET /api/diagnostics` route. Return the report directly to the client.
Code Reference
Source Location
- Repository: ai-maestro
- File: services/diagnostics-service.ts
- Lines: L1-L479
Signature
export type DiagnosticStatus = 'pass' | 'fail' | 'warn'
export interface DiagnosticCheck {
name: string
status: DiagnosticStatus
message: string
details?: Record<string, unknown>
}
export interface DiagnosticReport {
timestamp: string
hostname: string
summary: { total: number; passed: number; failed: number; warnings: number; status: DiagnosticStatus }
checks: DiagnosticCheck[]
}
export async function runDiagnostics(): Promise<ServiceResult<DiagnosticReport>>
Import
import { runDiagnostics, type DiagnosticReport } from '@/services/diagnostics-service'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | — | — | No inputs; reads system state directly |
Outputs
| Name | Type | Description |
|---|---|---|
| DiagnosticReport | object | timestamp, hostname, summary, checks[] |
Usage Examples
Run diagnostics
import { runDiagnostics } from '@/services/diagnostics-service'
const { data } = await runDiagnostics()
if (data.summary.status !== 'pass') {
for (const check of data.checks) {
if (check.status === 'fail') console.error(`FAIL: ${check.name} — ${check.message}`)
}
}