@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
62 lines • 3.12 kB
TypeScript
/** Crash records kept per agent dir. A crash loop rewrites the file down to this many. */
export declare const PROCESS_CRASH_RECORD_LIMIT = 50;
/** How often a live process refreshes its marker, which bounds the error of a recorded uptime. */
export declare const PROCESS_MARKER_HEARTBEAT_MS = 60000;
export interface ProcessCrashPaths {
readonly dir: string;
readonly liveDir: string;
readonly recordsFile: string;
}
export declare function processCrashPaths(agentDir: string): ProcessCrashPaths;
/** What a live process says about itself; the crash record is derived from it. */
export interface ProcessLifetimeMarker {
readonly kind: string;
readonly pid: number;
readonly startedAt: number;
readonly bunVersion?: string;
readonly senpiVersion: string;
/** The branded product's version (omo's), present only when a brand names one. */
readonly productVersion?: string;
}
export interface ProcessCrashRecord {
/** ISO-8601 instant of the last heartbeat before the death: the latest moment it was known alive. */
readonly at: string;
/** Which kind of process died: the app mode (`interactive`, `print`, `json`). */
readonly kind: string;
/** A marker left behind proves the death but not its signal. */
readonly detection: "unclean_exit";
/** Start to last heartbeat, in milliseconds; short by at most one heartbeat interval. */
readonly uptimeMs: number;
readonly bunVersion?: string;
readonly senpiVersion: string;
readonly productVersion?: string;
}
/** Runtime identity every record carries; the product version only when a brand sets one. */
export declare function crashingRuntimeVersions(): {
bunVersion?: string;
senpiVersion: string;
productVersion?: string;
};
export interface RecordProcessLifetimeOptions {
readonly pid?: number;
readonly now?: () => number;
readonly isAlive?: (pid: number) => boolean;
readonly heartbeatMs?: number;
}
/**
* The launch seam: turn every dead peer's marker into a crash record, then, for a process no parent
* supervises, start this process's own marker. Returns the disposer of this process's marker.
*/
export declare function recordProcessLifetime(agentDir: string, kind: string, options: RecordProcessLifetimeOptions & {
readonly supervised: boolean;
}): () => void;
/** Write this process's marker, keep it fresh, and remove it on every observable exit. */
export declare function installProcessLifetimeMarker(agentDir: string, kind: string, options?: RecordProcessLifetimeOptions): () => void;
/**
* Record one crash per marker whose process is gone. A marker is CLAIMED by renaming it before it is
* recorded, so two processes starting at once cannot both record the same death.
*/
export declare function sweepDeadProcessMarkers(agentDir: string, options?: RecordProcessLifetimeOptions): number;
/** Every record currently held, oldest first. Unparseable lines are skipped, never thrown on. */
export declare function readProcessCrashRecords(agentDir: string): readonly ProcessCrashRecord[];
//# sourceMappingURL=process-crash-record.d.ts.map