import fs from "node:fs"; import JSON5 from "json5"; import type { BotConfig, ConfigFileSnapshot } from "./types.js"; export { CircularIncludeError, ConfigIncludeError } from "./includes.js"; export { MissingEnvVarError } from "./env-substitution.js"; export type ParseConfigJson5Result = { ok: true; parsed: unknown; } | { ok: false; error: string; }; export type ConfigWriteOptions = { /** * Read-time env snapshot used to validate `${VAR}` restoration decisions. * If omitted, write falls back to current process env. */ envSnapshotForRestore?: Record; /** * Optional safety check: only use envSnapshotForRestore when writing the * same config file path that produced the snapshot. */ expectedConfigPath?: string; /** * Paths that must be explicitly removed from the persisted file payload, * even if schema/default normalization reintroduces them. */ unsetPaths?: string[][]; }; export type ReadConfigFileSnapshotForWriteResult = { snapshot: ConfigFileSnapshot; writeOptions: ConfigWriteOptions; }; export declare function resolveConfigSnapshotHash(snapshot: { hash?: string; raw?: string | null; }): string | null; export type ConfigIoDeps = { fs?: typeof fs; json5?: typeof JSON5; env?: NodeJS.ProcessEnv; homedir?: () => string; configPath?: string; logger?: Pick; }; export declare function parseConfigJson5(raw: string, json5?: { parse: (value: string) => unknown; }): ParseConfigJson5Result; export declare function createConfigIO(overrides?: ConfigIoDeps): { configPath: string; loadConfig: () => BotConfig; readConfigFileSnapshot: () => Promise; readConfigFileSnapshotForWrite: () => Promise; writeConfigFile: (cfg: BotConfig, options?: ConfigWriteOptions) => Promise; }; export declare function clearConfigCache(): void; export declare function setRuntimeConfigSnapshot(config: BotConfig, sourceConfig?: BotConfig): void; export declare function clearRuntimeConfigSnapshot(): void; export declare function getRuntimeConfigSnapshot(): BotConfig | null; export declare function loadConfig(): BotConfig; export declare function readConfigFileSnapshot(): Promise; export declare function readConfigFileSnapshotForWrite(): Promise; export declare function writeConfigFile(cfg: BotConfig, options?: ConfigWriteOptions): Promise;