/** * Windows can transiently fail an atomic rename-over-existing with EPERM/EBUSY * (antivirus, the search indexer, or a concurrent reader briefly holding the * destination handle). Those are retryable; a missing path or bad input is not. */ export declare function isTransientFsError(error: unknown): boolean; export interface FsRetryOptions { attempts?: number; initialDelayMs?: number; maxDelayMs?: number; /** Injectable for tests so retries don't actually wait. */ sleep?: (ms: number) => Promise; } /** * Retry a filesystem operation on transient Windows lock errors with bounded * exponential backoff. * Non-transient errors propagate immediately. */ export declare function withFsRetry(operation: () => Promise, options?: FsRetryOptions): Promise; /** * Write a file so a reader never observes a half-written one: temp file, then * rename over the destination. * * `Buffer` as well as `string`, and EXPORTED, because a caller restoring bytes * it captured earlier — a rollback putting back exactly what was there — needs * the same atomicity every writer in this module already gets. A raw * `writeFile` in that position can be interrupted between truncate and the last * byte, which turns a rollback into a truncation: strictly worse than either * outcome it was choosing between. Buffer rather than string specifically so the * restore is byte-for-byte and never round-trips through an encoding. */ export declare function writeFileAtomic(path: string, content: string | Buffer): Promise; export declare function isFileMissingError(error: unknown): boolean; /** * A file that EXISTS but does not parse as JSON. Typed (rather than a bare * `Error` with a message prefix) so consumers of submitted artifacts can treat * a malformed submission as quarantine-able content — distinct from the * infrastructure IO failures that must still propagate. */ export declare class JsonParseError extends Error { readonly path: string; constructor(path: string, cause: unknown); } /** Whether an error is `readJsonFile`'s exists-but-does-not-parse failure. */ export declare function isJsonParseError(error: unknown): error is JsonParseError; export declare function readJsonFile(path: string): Promise; export declare function writeJsonFile(path: string, value: unknown): Promise; /** * Bounded-accessor read path for an over-cap SCALAR string value. * * 2-space indentation (see `writeJsonFile`) wraps containers across lines but * CANNOT wrap a single scalar string — a >2000-char `quoted_text` / base64 * `evidence` value lands on one physical line, which a line-truncating reader * (e.g. the host Read tool, capped at ~2000 chars/line) silently clips. A * worker that must re-read such a value cannot reconstruct it by eyeballing the * file. This accessor reconstructs it programmatically: it `JSON.parse`s the * whole file (Node has no per-line cap) and returns the full scalar at * `segments`, regardless of length. * * Returns the string value, or `undefined` if the path is missing or the value * at the path is not a string scalar. */ export declare function readJsonStringScalar(path: string, segments: readonly string[]): Promise; /** * Same reconstruction as `readJsonStringScalar`, but yields the scalar in * fixed-size character chunks so a consumer whose own read surface is bounded * (e.g. a worker relaying through a capped transport) can stream an arbitrarily * long scalar without ever holding a single over-cap line. Concatenating the * yielded chunks reproduces the scalar exactly. Yields nothing if the path is * missing or the value is not a string. */ export declare function readJsonStringScalarChunks(path: string, segments: readonly string[], chunkSize?: number): AsyncGenerator; export declare function appendNdjsonFile(path: string, value: unknown): Promise; export declare function readNdjsonFile(path: string): Promise; export declare function readOptionalJsonFile(path: string): Promise; export declare function readOptionalNdjsonFile(path: string): Promise; export declare function writeNdjsonFile(path: string, values: unknown[]): Promise; export declare function readOptionalTextFile(path: string): Promise; export declare function writeTextFile(path: string, value: string): Promise; //# sourceMappingURL=json.d.ts.map