import { type ShardKind } from "./host-daemon-paths.ts";
import type { HostProtocolInfo } from "./host-decision.ts";
import { type HostGenerationRow } from "./host-generations.ts";
import { type HostUnit } from "./host-unit-placement.ts";
import { type HostPointerState } from "./host-pointer-election.ts";
import type { PathIdentityResolverStatus } from "./path-identity-status.ts";
import { type HostPathClaimRow, type HostSessionRow } from "./host-status-rows.ts";
import type { RpcLaunchProfile } from "./rpc-types.ts";
/**
 * Sessions the host reports. `foreign_*` is the same count from the point of view of a client that
 * holds none of them itself: for the CLI every session belongs to somebody else, which is exactly
 * why a hard stop is gated on it.
 */
export interface HostSessionCounts {
    readonly total: number;
    readonly interactive: number;
    readonly worker: number;
    /** Open at zero attachments: retained across a disconnect, still holding its transcript. */
    readonly retained: number;
    readonly foreign_attached: number;
    readonly foreign_retained: number;
}
export type { HostGenerationRow } from "./host-generations.ts";
/** A generation row as `host status` reports it: plus the cgroup and unit its supervisor runs in (senpi#7099). */
export interface HostGenerationStatusRow extends HostGenerationRow {
    readonly unit: HostUnit | null;
}
export type { HostPathClaimRow, HostSessionRow } from "./host-status-rows.ts";
export interface HostStatusReport {
    readonly reachable: boolean;
    readonly lifecycle: "ready" | "stopping" | null;
    readonly socket: string;
    readonly pid: number | null;
    readonly processStartTime: string | null;
    readonly instanceId: string | null;
    readonly generation: number | null;
    readonly engineVersion: string | null;
    readonly capabilities: readonly string[];
    readonly launchProfile: RpcLaunchProfile | null;
    /** Content digest of the runtime the ANSWERING host loaded at startup; `null` when nothing answers or it predates the field. */
    readonly runtimeBuildId: string | null;
    /** The conditional idle handover the answering host holds (`handover_pending`, ...); `null` when it holds none. */
    readonly handover: Readonly<Record<string, unknown>> | null;
    readonly sessions: HostSessionCounts;
    readonly zombies: number | null;
    readonly rss_mb: number | null;
    readonly host_rss_mb: number | null;
    /** The supervisor's and host's memory footprint (`phys_footprint` / `RssAnon`), which RSS understates (senpi#3110). */
    readonly host_footprint_mb: number | null;
    readonly open_fds: number | null;
    /**
     * Whether the ANSWERING generation's memory sampler reads pressure right now (RSS above
     * `SENPI_RPC_HOST_RSS_WARN_MB`); `null` when nothing answers or the host predates the field.
     */
    readonly memory_pressure: boolean | null;
    /** The answering host's path identity resolver (`not_started`, `ready`, or `unavailable` naming why its worker could not start); `null` when nothing answers or the host predates the field. */
    readonly path_identity_resolver: PathIdentityResolverStatus | null;
    /** Environment NAMES the daemon was granted, never values. */
    readonly env_keys: readonly string[];
    readonly generations: readonly HostGenerationStatusRow[];
    /**
     * Which generation the pointer names: `current`, `elected` when this read gave a lost pointer back to
     * the one proven live generation (senpi#1911), or `missing` with the `candidates` it saw.
     */
    readonly pointer: HostPointerState;
    /** Records in this endpoint's `crashes.jsonl`: supervised host children that DIED, not stopped. */
    readonly crashes: number;
    /** The owner-keyed shard the socket names (`<kind>-<16hex>.sock`), `null` for any other endpoint. */
    readonly shard: {
        readonly kind: ShardKind;
        readonly key: string;
    } | null;
    /** Every listed session, only when workers were asked for; `[]` otherwise. */
    readonly session_rows: readonly HostSessionRow[];
    /** Session-path claims in `reservations/` whose owner process is still running. */
    readonly claims_live: number;
    /** Every claim in `reservations/`, whichever generation wrote it, only when workers were asked for. */
    readonly claims: readonly HostPathClaimRow[];
}
export interface HostStatusOptions {
    readonly socket: string;
    readonly agentDir?: string;
    /** Ask the host to include `kind: "worker"` rows, exactly as `list_sessions` defines the flag. */
    readonly includeWorkers?: boolean;
}
/**
 * How a status read treats the daemon directory. `prune` (the default, and the single-socket
 * `status`) removes what ended before reporting; `prune: false` (`status --all`) reports dead
 * generations as `alive: false` rows and removes nothing.
 */
export interface HostStatusReadOptions {
    readonly prune?: boolean;
    /** Budget for each read of the socket, default 10 s. */
    readonly timeoutMs?: number;
}
export declare function readHostStatus(options: HostStatusOptions, read?: HostStatusReadOptions): Promise<HostStatusReport>;
/**
 * The report plus what the socket itself said, which the report blends with the directory: `answered`
 * is the raw `get_protocol_info` answer (`undefined` when nothing answered) - the report's `instanceId`
 * falls back to the RECORDED generation, so only this says whether the socket named an instance - and
 * `listing` is every row `list_sessions` returned, whether or not the report publishes them.
 */
export declare function probeHostStatus(options: HostStatusOptions, read?: HostStatusReadOptions): Promise<HostStatusProbe>;
interface HostStatusProbe {
    readonly report: HostStatusReport;
    readonly answered: HostProtocolInfo | undefined;
    readonly listing: readonly HostSessionRow[];
}
/**
 * The occupancy a stop decision is made on. A host that does not answer holds nothing a client can
 * see, and an empty count is what lets a stop proceed against a socket nobody serves.
 */
export declare function readSessionCounts(socket: string, includeWorkers: boolean): Promise<HostSessionCounts>;
/** Identity fields of a probed host, for the `host` field of a refusal. */
export declare function hostSummary(host: HostProtocolInfo | undefined): Record<string, unknown> | null;
//# sourceMappingURL=host-status.d.ts.map