UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

41 lines • 2.18 kB
import { type ChildProcessIdentity, type OwnBootReader } from "./process-identity.ts"; export type OwnerVerdict = "confirmed" | "dead" | "unverifiable"; export interface ProcessEvidence { readonly startedAtMs?: number; /** The command line the OS reports for the pid, space-joined. */ readonly argv?: string; /** Linux only: raw NUL-separated `/proc/<pid>/environ`. */ readonly environ?: string; } export interface OwnerProbes { readonly platform?: NodeJS.Platform; readonly isProcessAlive?: (pid: number) => boolean; readonly readProcessEvidence?: (pid: number) => Promise<ProcessEvidence | undefined>; readonly bootAtMs?: OwnBootReader; } export interface KillTreeOptions { readonly graceMs?: number; readonly isProcessAlive?: (pid: number) => boolean; readonly kill?: (pid: number, signal: NodeJS.Signals) => void; readonly wait?: (ms: number) => Promise<void>; } export interface ReapResult { readonly action: "killed" | "already-dead" | "none"; readonly reason?: string; } /** Start instants further apart than this are different processes, even on the same pid. */ export declare const OWNER_START_TOLERANCE_MS = 2000; export declare const DEFAULT_KILL_GRACE_MS = 1000; export declare function isProcessAlive(pid: number): boolean; /** * A pid alone is never trusted: after a crash or reboot the OS recycles it, so killing on a bare * pid match can take down an unrelated process. Ownership needs the pid alive on the same boot, * the same start instant, and a per-platform content marker (env on Linux, argv elsewhere). A * background session carries no monitor id in its environment, so it is matched by argv everywhere. */ export declare function confirmOwner(runtime: ChildProcessIdentity, monitorId: string | undefined, probes?: OwnerProbes): Promise<OwnerVerdict>; export declare function killTree(runtime: ChildProcessIdentity, options?: KillTreeOptions): Promise<{ action: "killed" | "already-dead"; }>; export declare function reapBeforeRespawn(runtime: ChildProcessIdentity, monitorId: string, probes?: OwnerProbes & KillTreeOptions): Promise<ReapResult>; //# sourceMappingURL=orphan-reaper.d.ts.map