import { r as RootFileOpenFailure } from "./root-file-DhFzjJm7.js"; import fs from "node:fs"; //#region node_modules/@openclaw/fs-safe/dist/text-atomic.d.ts type WriteTextAtomicOptions$1 = { mode?: number; dirMode?: number; trailingNewline?: boolean; /** * When false, skip the temp-file and parent-directory fsync calls while * preserving the temp-file replace/rename behavior. * * Defaults to true. */ durable?: boolean; }; //#endregion //#region node_modules/@openclaw/fs-safe/dist/json.d.ts declare function tryReadJsonSync(pathname: string): T | null; declare function writeJsonSync(pathname: string, data: unknown): void; declare class JsonFileReadError extends Error { readonly filePath: string; readonly reason: "read" | "parse"; constructor(filePath: string, reason: "read" | "parse", cause: unknown); } type RootStructuredFileReadResult = { ok: true; value: T; stat: fs.Stats; path: string; rootRealPath: string; } | { ok: false; reason: "open"; failure: RootFileOpenFailure; } | { ok: false; reason: "invalid" | "parse"; error: string; }; type ReadRootStructuredFileSyncOptions = { rootDir: string; rootRealPath?: string; relativePath: string; boundaryLabel: string; rejectHardlinks?: boolean; maxBytes?: number; parse: (raw: string) => unknown; validate?: (value: unknown) => value is T; invalidMessage?: string | ((relativePath: string) => string); }; type ReadRootJsonSyncOptions = Omit, "parse" | "validate" | "invalidMessage">; declare function readRootStructuredFileSync(options: ReadRootStructuredFileSyncOptions): RootStructuredFileReadResult; declare function readRootJsonSync(options: ReadRootJsonSyncOptions): RootStructuredFileReadResult; declare function readRootJsonObjectSync(options: ReadRootJsonSyncOptions): RootStructuredFileReadResult>; declare function readJsonSync(filePath: string): T; type WriteJsonOptions = Pick; declare function writeJson(filePath: string, value: unknown, options?: WriteJsonOptions): Promise; //#endregion //#region src/infra/json-files.d.ts type WriteTextAtomicBeforeRename = (params: { filePath: string; tempPath: string; }) => Promise; declare function readJson(filePath: string): Promise; declare function readJsonFileStrict(filePath: string): Promise; declare function readJsonIfExists(filePath: string): Promise; declare function readDurableJsonFile(filePath: string): Promise; /** * tryReadJson delegates to readJsonIfExists instead of the internal * tryReadJsonImpl from @openclaw/fs-safe. The fs-safe implementation retries * race conditions before propagating errors; this wrapper keeps the historical * null-on-error contract for callers that intentionally treat reads as optional. */ declare function tryReadJson(filePath: string): Promise; declare function readJsonFile(filePath: string): Promise; type WriteTextAtomicOptions = { mode?: number; dirMode?: number; trailingNewline?: boolean; durable?: boolean; beforeRename?: WriteTextAtomicBeforeRename; /** * Prefix for the staged `...tmp` file. Defaults to the * generic `.fs-safe-replace`; pass a target-specific prefix so an orphaned * temp (from a crash between write and rename) is identifiable and reclaimable. */ tempPrefix?: string; }; declare function writeTextAtomic(filePath: string, content: string, options?: WriteTextAtomicOptions): Promise; //#endregion export { readJsonFileStrict as a, writeTextAtomic as c, readRootJsonObjectSync as d, readRootJsonSync as f, writeJsonSync as g, writeJson as h, readJsonFile as i, JsonFileReadError as l, tryReadJsonSync as m, readDurableJsonFile as n, readJsonIfExists as o, readRootStructuredFileSync as p, readJson as r, tryReadJson as s, WriteTextAtomicOptions as t, readJsonSync as u };