/** Env var that pins automatic saving off for one MCP server process. */ export declare const AUTO_SAVE_ENV = "MEMWAL_AUTO_SAVE"; /** Where the answer is stored. Outside every repository, on purpose. */ export declare function settingsPath(): string; /** Where the resolved state is published for the plugin hooks to read. */ export declare function hookStatePath(): string; /** * Parse a human-written boolean. Returns null for "not set" and for anything * unparseable — an unreadable value must not be read as an answer. */ export declare function parseBooleanSetting(raw: string | undefined | null): boolean | null; /** `on`/`off` are answers; `unset` means nobody has been asked yet. */ export type AutoSaveState = "on" | "off" | "unset"; export type AutoSaveSource = /** `MEMWAL_AUTO_SAVE=0` in this process's environment. */ "env" /** An answer written to settings.json. */ | "settings" /** Unset, on an install that predates the consent prompt — keeps saving. */ | "legacy" /** Unset, on an install created after it — saves nothing until answered. */ | "unanswered"; export interface AutoSaveStatus { /** Whether this process may save without being asked. */ enabled: boolean; /** The stored answer, or `unset`. */ state: AutoSaveState; source: AutoSaveSource; /** True while the question is still owed a human answer. */ pendingConsent: boolean; /** Where an answer lives (or would be written). */ path: string; } /** * Resolve the current state: a disabling `MEMWAL_AUTO_SAVE` override, then the * stored answer, then the unset rules above. */ export declare function autoSaveStatus(): AutoSaveStatus; /** * True when this process may save without being asked. * * Read at call time, never cached: the answer can be written between calls in * the same process. */ export declare function isAutoSaveEnabled(): boolean; /** True while a human still owes the consent question an answer. */ export declare function isConsentPending(): boolean; /** The file the plugin hooks read. Contains no secret — only the answer. */ export interface HookAutoSaveState { version: number; enabled: boolean; state: AutoSaveState; source: AutoSaveSource; pendingConsent: boolean; /** The settings file this was resolved from, for diagnosis only. */ settingsPath: string; updatedAt: string; } /** * Publish the resolved state where the plugin hooks can read it. * * This is the whole hook contract: the hooks do no resolution, consult no * project directory and parse no credentials file — they read this one file out * of the trusted state dir, or they fail safe. Called at every point the answer * can change (`setAutoSave`, `markConsentPending`) and once at start-up, so a * hook spawned in the same session as an MCP server sees the current answer. * * Best effort: a read-only or missing home directory must not stop the server * from running, and a hook that finds no file already behaves as "off". */ export declare function publishHookState(): HookAutoSaveState | null; /** * Record the answer, preserving any other keys already in the file. Clears the * pending stamp — the question has been answered and must not be asked again. */ export declare function setAutoSave(enabled: boolean): { path: string; enabled: boolean; }; /** * Mark this install as created after the consent prompt existed, so an unset * state here is read as "never asked" rather than "long-standing user". * * Called once when a brand-new install first appears — before the signed-out * server boots, and immediately after a first interactive login — so that an * abandoned or headless sign-in cannot mature into automatic saving nobody * agreed to. A no-op once any answer exists. */ export declare function markConsentPending(): void; /** One line for a TTY, naming the state, where it came from, and how to flip it. */ export declare function autoSaveSummary(): string; /** * The single line a non-interactive run prints while consent is outstanding. * * Non-TTY is every MCP client spawn, so this is stderr-only and says what is * happening rather than asking anything — there is no human on the other end of * this stdin, and a prompt here would hang the server forever. */ export declare function pendingConsentNotice(): string | null; //# sourceMappingURL=auto-save.d.ts.map