diff --git a/packages/plugin/src/bin/doctor.ts b/packages/plugin/src/bin/doctor.ts new file mode 100644 index 0000000..cb11a7d --- /dev/null +++ b/packages/plugin/src/bin/doctor.ts @@ -0,0 +1,14 @@ +import type { HostPluginRuntime } from '../service.js' + +export function doctor(runtime: HostPluginRuntime): string { + const state = runtime.diagnostics() + return [ + 'DSH Remote doctor', + `Plugin: ${state.loaded ? 'loaded' : 'starting'}`, + `Identity: ${state.identityValid ? `valid (${state.deviceId})` : 'unavailable'}`, + `Server: ${state.serverConfigured ? state.serverOnline ? 'online' : 'configured, offline' : 'not configured'}`, + ...(state.serverError === undefined ? [] : [`Server error: ${state.serverError}`]), + `Peer channel: ${state.online ? 'online' : 'offline'}`, + `Trusted devices: ${state.trustedPeers}`, + ].join('\n') +}