/** * Persisted re-login state — what survives a backend restart. * * The owner is told once per harness per machine that it is signed out, then * re-reminded with backoff. Without persistence every restart (an * auto-update, a crash loop while every agent is stuck) would DM again. The * file also remembers which harnesses were seen signed in, so a later * `logged_out` is an expiry and not a machine that was never set up. * * File: `/harness-relogin-state.json` (mode 0600, no secrets). * * @module services/harness/relogin-state.store */ import { type HarnessId } from './harness.types.js'; /** What is remembered for one harness. */ export interface HarnessReloginRecord { /** When the harness was first confirmed signed out (epoch ms) */ signedOutSince?: number; /** When the owner was last told (epoch ms) */ lastNoticeAt?: number; /** Notices sent since it was signed out (drives the backoff) */ noticeCount?: number; /** Last time the harness was seen signed in (epoch ms) */ seenLoggedInAt?: number; } /** Storage for {@link HarnessReloginRecord}s. */ export interface ReloginStateStore { get(harnessId: HarnessId): HarnessReloginRecord; update(harnessId: HarnessId, patch: Partial | null): void; } /** In-memory store (tests, CLI). */ export declare class MemoryReloginStateStore implements ReloginStateStore { private readonly records; get(harnessId: HarnessId): HarnessReloginRecord; /** * Merge a patch (null / undefined fields are dropped; a null patch clears the record). * * @param harnessId - Harness * @param patch - Fields to set, or null to forget the harness */ update(harnessId: HarnessId, patch: Partial | null): void; /** @returns Every record (persistence) */ entries(): Array<[HarnessId, HarnessReloginRecord]>; } /** File-backed store; a missing or unreadable file starts empty. */ export declare class FileReloginStateStore extends MemoryReloginStateStore { private readonly file; /** * @param file - JSON file path */ constructor(file: string); /** @inheritdoc */ update(harnessId: HarnessId, patch: Partial | null): void; } /** * The backend's store under CREWLY_HOME. * * @returns A file store */ export declare function createDefaultReloginStateStore(): ReloginStateStore; //# sourceMappingURL=relogin-state.store.d.ts.map