@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
75 lines • 4.44 kB
TypeScript
/**
* `senpi host status --all`: one status row per endpoint an agent directory holds state for.
*
* Enumeration is the daemon directory (`listHostEndpoints`), and every row is the single-socket
* report read with `prune: false` - so this answer removes NOTHING. Dead generations stay visible as
* `alive: false` rows, an endpoint whose host exited stays listed through its `endpoint.json`, and
* the reclaiming of what ended is a separate, evidence-gated command rather than a side effect of
* looking. A directory that names no socket still gets a row (`socket: null`), built from the
* directory alone, because it is exactly what an operator asking "what is on this machine" needs to
* see.
*
* Every row carries the endpoint's `endpoint_kind` and the liveness verdict (`host-endpoint-liveness.ts`)
* as `alive` (routable) plus `reason` when it is not. `alive` is judged from what the socket itself
* answered, never from the directory's record of it: a socket that answers without naming an instance
* is not routable, whatever generation the directory last recorded. A `tui` row is read under
* TUI_PROBE_TIMEOUT_MS whatever budget the caller grants the hosts, so one suspended terminal costs the
* listing 1.5 s, not 10; it is sent `get_protocol_info` and `list_sessions` only - the two commands a
* terminal endpoint and a host both answer - and carries `owner`: the terminal process and the one
* session it holds. A host row also carries `stale_old_engine`: whether `senpi host gc` would stop it as a
* stale older-engine leftover (`host-stale-engine.ts`, #3268), judged with observing reads only.
*/
import { type EndpointKind } from "./host-daemon-paths.ts";
import { type EndpointLiveness } from "./host-endpoint-liveness.ts";
import { type HostEndpointEntry, type HostEndpointIdentitySource } from "./host-endpoints.ts";
import { type StaleEngineOptions } from "./host-stale-engine.ts";
import { type HostStatusReport } from "./host-status.ts";
/** Who serves a `tui` endpoint: the terminal process (as recorded) and the session it holds, when it answered. */
export interface TuiEndpointOwner {
readonly pid: number | null;
readonly cwd: string | null;
readonly session: {
readonly id: string;
readonly path: string | null;
readonly name: string | null;
} | null;
}
export interface HostEndpointStatus extends Omit<HostStatusReport, "socket"> {
readonly socket: string | null;
readonly dir: string;
readonly identity: HostEndpointIdentitySource;
readonly endpoint_kind: EndpointKind;
/** `true` exactly when the endpoint is routable: it answered with an instance its directory recorded. */
readonly alive: boolean;
/** Why a row is not alive: still running but not answering, or provably gone. `null` when alive. */
readonly reason: Exclude<EndpointLiveness, "routable"> | null;
/** `tui` rows only; `null` for a host endpoint. */
readonly owner: TuiEndpointOwner | null;
/** A running older-engine host that holds nothing and outlived its idle window: `senpi host gc` stops it. */
readonly stale_old_engine: boolean;
}
/**
* Endpoints read at once. Each read holds a socket and a few files open until its budget runs out, so
* an unbounded fan-out over hundreds of hung hosts hit EMFILE under a 256-descriptor hard limit and
* returned no rows at all; up to this many hung hosts still cost about one budget in total.
*/
export declare const STATUS_ALL_MAX_IN_FLIGHT = 64;
interface StatusAllOptions {
readonly agentDir: string;
readonly includeWorkers: boolean;
/** Budget for each read of each host endpoint's socket, default 10 s (`readHostStatus`); `tui` rows never exceed 1.5 s. */
readonly timeoutMs?: number;
readonly staleEngine?: StaleEngineOptions;
/** Replaces the per-endpoint read; tests observe how many run at once. */
readonly _test?: {
readonly readEndpoint?: (endpoint: HostEndpointEntry) => Promise<HostEndpointStatus>;
};
}
/**
* Endpoints are read concurrently, at most STATUS_ALL_MAX_IN_FLIGHT at a time, each under its own
* budget, so hung hosts cost about one budget per STATUS_ALL_MAX_IN_FLIGHT rather than one each; rows
* keep the enumeration order (sorted by directory name).
*/
export declare function readAllHostStatus(options: StatusAllOptions): Promise<readonly HostEndpointStatus[]>;
export {};
//# sourceMappingURL=host-status-all.d.ts.map