UNPKG

@mesh-tech/mesh-cli

Version:

CLI for Mesh platform development utilities

72 lines (71 loc) 2.91 kB
import type { SessionState } from "./dev.js"; import type { ResolvedAwsCreds } from "../utils/aws-auth.js"; import { type CredProbe } from "./login.js"; export type CheckStatus = "ok" | "warn" | "error"; export type CheckPhase = "preflight" | "ondemand"; export interface CheckResult { status: CheckStatus; summary: string; remediation?: string; detail?: string; } export interface Check<C = DoctorContext> { id: string; title: string; phases: CheckPhase[]; run(ctx: C, phase?: CheckPhase): Promise<CheckResult>; } export type CheckOutcome = { check: Pick<Check<unknown>, "id" | "title">; result: CheckResult; }; export interface DoctorContext { appRoot: string; stack: string; sessionName: string; deployerRole: string | null; platformContext: string | null; credMethod: ResolvedAwsCreds["method"] | "ambient" | null; sessionState: SessionState | null; } export declare function aggregateStatus(results: CheckResult[]): CheckStatus; export declare function runChecks<C = DoctorContext>(ctx: C, phase: CheckPhase, checks: Check<C>[]): Promise<Array<{ check: Check<C>; result: CheckResult; }>>; export declare const ICONS: Record<CheckStatus, string>; export declare function renderHuman(results: CheckOutcome[]): string; export declare function jsonReport(results: CheckOutcome[]): { status: CheckStatus; checks: Array<{ id: string; status: CheckStatus; summary: string; remediation: string | null; detail: string | null; }>; }; export declare function renderJson(results: CheckOutcome[]): string; export declare function credProbeToResult(probe: CredProbe, context: string, headless: boolean): CheckResult; export declare const credsCheck: Check; export declare const registryCheck: Check; export declare function parsePortSquatter(lsofOut: string, psOut: string): { pid: number; command: string; } | null; export declare function sharesWorktreeRoot(serviceSrc: string, repoRoot: string): boolean; export type PortOwnership = "owned" | "foreign" | "dead"; export declare function classifyPortListener(listenerPid: number | null, sessionPids: ReadonlySet<number>): PortOwnership; export declare function collectSessionPids(panePids: number[], psOut: string): Set<number>; export declare const tmuxCheck: Check; export declare const portsCheck: Check; export declare function isConfigStale(configMtimeMs: number, startedAtIso: string): boolean; export declare const configStalenessCheck: Check; export declare const worktreeCheck: Check; export declare function canConnect(host: string, port: number, timeoutMs?: number): Promise<boolean>; export declare const tunnelsCheck: Check; export declare const temporalCheck: Check; export declare const ALL_CHECKS: Check[]; export declare function runDoctor(ctx: DoctorContext, opts: { json: boolean; }): Promise<CheckStatus>;