Import packages/plugin/src/bin/doctor.ts

This commit is contained in:
QQ 2026-11-14 14:52:16 +08:00
parent 41a3e1b20d
commit 925d3ab660
1 changed files with 14 additions and 0 deletions

View File

@ -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')
}