import type { Body, ByteRange, StoredFile } from "../index.js"; export interface OutputOpts { json: boolean; pretty: boolean; verbose: boolean; } /** * `JSON.stringify` replacer that makes a {@link FilesError} serialize * usefully. A bare stringify drops `message` (a non-enumerable `Error` * property) while leaking the enumerable `cause` — the raw provider error, * which can carry request ids and headers the docs on {@link FilesError} * explicitly warn against shipping across a trust boundary. Bulk partial * failures embed live `FilesError`s in their `errors` arrays, so every * outward serialization goes through this. */ export declare const filesErrorReplacer: (_key: string, value: unknown) => unknown; /** Stringify for output, with {@link filesErrorReplacer} applied. */ export declare const toJson: (data: unknown, pretty: boolean) => string; export declare const exitCode: (code: string) => number; export declare const emit: (data: unknown, out: OutputOpts) => void; export declare const fail: (err: unknown, out: OutputOpts) => never; /** * Resolve a body source from CLI flags as a web ReadableStream — the adapter * decides whether to buffer or stream. Both stdin and file paths are * streamed; size is unknown for stdin and reported as `-1`. */ export declare const readBody: (source: { file?: string; stdin?: boolean; }) => Promise<{ body: Body; size: number; hint: string; }>; /** * Write a downloaded body to a destination file or stdout. When piping to * stdout, no JSON envelope is emitted on stdout — agents calling * `download --stdout` want the bytes, not a wrapper. */ export declare const writeBody: (file: StoredFile, dest: { out?: string; stdout?: boolean; }) => Promise; /** * A web `ReadableStream` over a local file that opens the descriptor lazily — * only on the first read, never at construction. The bulk-upload path builds * one of these per file and hands them all to `files.upload(items)`; deferring * the open (via a zero high-water-mark, so nothing is pre-buffered) keeps the * number of simultaneously-open descriptors bounded by the SDK's upload * concurrency rather than by the file count — a directory of thousands of * files won't exhaust the process's fd limit. */ export declare const fileBodyStream: (absPath: string) => ReadableStream; export interface WalkedFile { absPath: string; /** Path relative to the walk root, always with `/` separators (an object key). */ key: string; } /** * Recursively list every regular file under `root`, returning each file's * absolute path and its `/`-separated key relative to `root`. Directories are * descended; symlinks and other special entries are skipped. The result is * sorted by key so a directory upload produces deterministic output. */ export declare const walkDir: (root: string) => Promise; /** * Write a downloaded {@link StoredFile} into `dir`, at the path its key * implies (`dir/`), creating intermediate directories. Refuses keys that * would escape `dir` (`../`, absolute) so a hostile or malformed key can't * write outside the chosen output directory. Returns the path written. */ export declare const writeBodyToDir: (file: StoredFile, dir: string) => Promise; export declare const parseKeyValuePairs: (pairs?: readonly string[]) => Record | undefined; /** * Parse a `--range` flag into a {@link ByteRange}. Mirrors the HTTP `Range` * header's `start-end` form (both bounds 0-based and inclusive): * * - `"0-99"` → `{ start: 0, end: 99 }` (first 100 bytes) * - `"100-"` → `{ start: 100 }` (byte 100 to EOF) * * Only the numeric `start-end` / `start-` shapes are accepted — suffix ranges * (`-500`) have no {@link ByteRange} representation. The SDK does the final * `start`/`end` validation, so this just rejects unparseable input loudly. */ export declare const parseRange: (raw?: string) => ByteRange | undefined; export declare const parseJson: (raw?: string, flag?: string) => T | undefined; export declare const storedFileToJson: (f: StoredFile) => Record; //# sourceMappingURL=io.d.ts.map