@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
46 lines • 3.01 kB
TypeScript
import { type DaemonPidFile } from "../../utils/process-identity.ts";
import { type HostDaemonPaths } from "./host-daemon-paths.ts";
export interface StartupIntent {
readonly attempt: string;
readonly instanceId: string;
readonly generation: number;
readonly launcher: DaemonPidFile;
/** Absent until the launcher bound the spawned child's identity. */
readonly child?: DaemonPidFile;
/** Wall-clock milliseconds: the intent outlives the process that wrote it, so no monotonic origin applies. */
readonly writtenAt: number;
}
export declare function startupIntentPath(daemonDir: string): string;
/** Written (mode 0600, by rename) under the ensure lock, before the spawn. */
export declare function writeStartupIntent(daemonDir: string, intent: StartupIntent): Promise<void>;
/** `unreadable` carries the file's age source, so even a torn intent expires. */
export declare function readStartupIntent(daemonDir: string): Promise<StartupIntent | {
readonly unreadable: true;
readonly writtenAt: number;
} | undefined>;
export declare function clearStartupIntent(daemonDir: string): Promise<void>;
/** The identity a supervisor recorded for `attempt` in its own generation directory, if it got that far. */
export declare function readStartupAttemptRecord(generationDir: string, attempt: string): Promise<DaemonPidFile | undefined>;
/**
* - `none`: no intent; a start may proceed.
* - `candidate_gone`: the candidate's own identity proves it exited; clear and proceed.
* - `expired`: nobody could identify the candidate, and the intent is past the settled-result bound; clear and proceed.
* - `candidate_live`: preserve every record and refuse; nothing is signalled.
* - `unknown`: no identity was bound or recorded, or one could not be read; preserve and refuse.
*/
export type StartupIntentVerdict = "none" | "candidate_gone" | "expired" | "candidate_live" | "unknown";
export declare function reconcileStartupIntent(intent: Awaited<ReturnType<typeof readStartupIntent>>, options: {
/** Whether a recorded identity is still that process; it throws when it cannot tell. */
readonly matches: (record: DaemonPidFile) => Promise<boolean>;
/** The supervisor's own attempt record for this intent's generation. */
readonly attemptRecord: (instanceId: string, attempt: string) => Promise<DaemonPidFile | undefined>;
/** E: the settled-result bound after which an unidentifiable candidate no longer wedges the endpoint. */
readonly expiryMs: number;
readonly now: number;
}): Promise<StartupIntentVerdict>;
/**
* Run under the ensure lock before a start: a leftover intent whose candidate is gone, or that expired, is
* cleared; one whose candidate may still run refuses this start and stays as evidence. Nothing is signalled.
*/
export declare function settleStartupIntent(paths: HostDaemonPaths, socket: string, readStartTime?: (pid: number) => Promise<string | undefined>): Promise<void>;
//# sourceMappingURL=host-startup-intent.d.ts.map