import { z } from "zod"; import type { Host } from "../../host/host.js"; export declare const AttachRecordSchema: z.ZodObject<{ pid: z.ZodNumber; program: z.ZodString; node: z.ZodString; startedAt: z.ZodNumber; }, z.core.$strict>; export type AttachRecord = z.infer; export declare function sessionsDir(host: Pick): string; export declare function recordPaths(dir: string, pid: number): { json: string; sock: string; }; /** Why the sessions directory cannot be used. */ export type DirectoryRefusal = { refused: string; }; /** The sessions directory, made with mode `0700` when missing, and * refused unless the current user owns it and no group or world bits are * set. The safety argument for attach rests on this check: the socket in * it is also `chmod 0600`, but that happens after `listen`, with a short * window at the umask's mode. The run and the CLI both call this. */ export declare function ensureSessionsDir(dir: string): DirectoryRefusal | null; /** Write `.json`. The path is removed first and the file created * anew (`wx`), so a symlink left at that name is replaced, not followed. */ export declare function writeRecord(dir: string, record: AttachRecord): void; /** Remove one run's record and socket. Paths are built here from the * directory and a pid, never taken from outside, so this can only ever * delete files a run wrote. */ export declare function removeRecord(dir: string, pid: number): void; /** The record in `.json`, or null when there is none, it is not a * record, or its pid is not the file's: a record is only trusted to say * what its name says, so a hand-edited file cannot point the CLI at * another process. */ export declare function readRecord(dir: string, pid: number): AttachRecord | null; export declare function listRecords(dir: string): AttachRecord[]; /** Delete the records whose process is gone, and nothing else. */ export declare function removeStale(dir: string, records: readonly AttachRecord[]): AttachRecord[];