/** * persistence.ts — Disk I/O for session registry and voice configuration. * * Parameterized by appDir (e.g. "~/.whazaa" or "~/.telex") so each * consumer uses its own data directory. Transport-specific store caches * (Baileys stores, Telegram chats) remain in per-project code. * * Both stores here load into module state at startup and save that state back, * which is the read -> substitute-empty -> make-it-permanent shape described at * the top of core/json-store.ts. They go through it: an unparseable file blocks * writes instead of being replaced, and every write is atomic with a `.bak`. */ import type { VoiceConfig } from "../types/index.js"; /** * Set the application data directory. * Must be called before any load/save operations. */ export declare function setAppDir(dir: string): void; export declare function getAppDir(): string; export declare const DEFAULT_VOICE_CONFIG: VoiceConfig; export declare function loadVoiceConfig(): VoiceConfig; export declare function saveVoiceConfig(config?: VoiceConfig): void; export declare function loadSessionRegistry(): void; export declare function saveSessionRegistry(): void; type SessionNamesStore = Record; /** Drop the cached name store (used when the app dir changes, and by tests). */ export declare function resetSessionNamesCache(): void; /** * Persist a user-chosen name for an iTerm2 session. * @param itermSessionId - the raw iTerm2 session UUID (e.g. "942A4044-...") * @param name - the user-set name */ export declare function setPersistentSessionName(itermSessionId: string, name: string): void; /** * Drop names whose session no longer exists. * * This map is keyed by session id and has never been garbage-collected: on * 2026-08-04 it held 96 entries, most of them ids belonging to terminals closed * days earlier, including four separate dead ids all answering to "PAI". That * is not merely untidy. `lookupPersistentName` resolves by durable id as well * as primary id, so a stale entry is a live session's opportunity to answer to * the wrong name — and answering to the wrong name is how `pai ` * reached the wrong terminal. * * `liveIds` must be the CURRENT set. The guard below is the whole safety of * this function: called with an empty set — iTerm not running, an enumeration * that failed, a daemon starting before the terminal — "no session is live" * reads identically to "every session ended", and pruning would erase every * name the user has ever assigned. So an empty set prunes nothing. * * Returns the number of entries removed, for the caller to log. */ export declare function pruneSessionNames(liveIds: Iterable): number; /** * Get the user-chosen persistent name for an iTerm2 session, or undefined. */ export declare function getPersistentSessionName(itermSessionId: string): string | undefined; /** * Get all persistent session names (for re-assert on rescan). */ export declare function getAllPersistentSessionNames(): SessionNamesStore; /** * Resolve the persistent name for a session, preferring the durable id over the * primary id. tmux pane ids (%N) reset on server restart, so tmux names are keyed * on the pane's @aibroker_id (passed as `durableId`); iTerm GUIDs are already * stable and pass `durableId` undefined. */ export declare function lookupPersistentName(names: SessionNamesStore, id: string, durableId?: string | null): string | null; /** * Remove a persistent name when a session ends. */ export declare function removePersistentSessionName(itermSessionId: string): void; export {}; //# sourceMappingURL=persistence.d.ts.map