/** * Large-result offloading for tool outputs. * * Goal: no truncated tool result is ever lost. The full output goes to a * file under `/offloads//`, and only a head+tail * preview plus a footer (path + re-read instructions) enters the LLM context. * The agent can then page through the file with `read` (offset/limit) or * `bash` (sed/head/tail). * * This is the generic version of the pattern pioneered by the bash tool * (preview + `Full output: ` footer). Small results pass through * untouched — no file, no overhead. Binary-looking content (NUL bytes) is * never offloaded. */ /** Default byte threshold above which a result is offloaded to disk. */ export declare const DEFAULT_OFFLOAD_BYTES: number; /** Default line threshold above which a result is offloaded to disk. */ export declare const DEFAULT_OFFLOAD_LINES = 2000; /** Preview head size (lines kept from the start). */ export declare const PREVIEW_HEAD_LINES = 100; /** Preview tail size (lines kept from the end). */ export declare const PREVIEW_TAIL_LINES = 100; /** Emergency byte cap for previews (head+tail can still be huge with long lines). */ export declare const PREVIEW_MAX_BYTES: number; /** Marker identifying an already-offloaded result (bash tool compat). */ export declare const OFFLOAD_MARKER = "Full output:"; /** Anchored marker check: only a real `Full output: .log` footer counts. */ export declare const OFFLOAD_PATH_RE: RegExp; /** * Parse a positive-int env override. Returns `fallback` when the variable is * unset, unparseable, zero, or negative — a non-positive budget would * otherwise disable offloading/GC entirely, so it is treated as "not set". */ export declare function envPositiveInt(name: string, fallback: number): number; /** Effective byte limit (override via `SPECTRAL_OFFLOAD_BYTES`). */ export declare function getOffloadByteLimit(): number; /** Effective line limit (override via `SPECTRAL_OFFLOAD_LINES`). */ export declare function getOffloadLineLimit(): number; export interface OffloadTruncation { originalBytes: number; shownBytes: number; headLines: number; tailLines: number; omittedLines: number; totalLines: number; fullOutputPath: string; } export interface OffloadResult { /** Model-facing text: full original for small results, preview+footer for large ones. */ preview: string; /** Absolute path of the persisted full output, or null when nothing was written. */ fullOutputPath: string | null; /** Truncation metadata, or null when nothing was offloaded. */ truncation: OffloadTruncation | null; } export declare function countLines(text: string): number; /** Marker for results that were already offloaded (or produced by the bash tool). */ export declare function isAlreadyOffloaded(text: string): boolean; /** * Whether `text` is large enough to deserve offloading. * Binary-looking content (NUL bytes) is never offloaded. */ export declare function shouldOffload(text: string): boolean; export interface PreviewResult { preview: string; headLines: number; tailLines: number; omittedLines: number; totalLines: number; } /** * Build a head+tail preview. Never cuts in the middle of a line (except via * the emergency byte cap below); the gap is replaced with a * `[... N lines omitted ...]` marker. When head+tail itself exceeds * `PREVIEW_MAX_BYTES` (e.g. a single giant line), the preview is cut * mid-line with a `[... N bytes omitted ...]` marker so the LLM context * never receives an unbounded preview. */ export declare function buildPreview(text: string, headLines?: number, tailLines?: number): PreviewResult; export interface OffloadFooterOptions { headLines?: number; tailLines?: number; totalLines?: number; } /** * Single-line footer appended to a preview. Carries the full-output path plus * a copy-pasteable re-read hint for the agent. */ export declare function formatOffloadFooter(path: string, shown: number, total: number, opts?: OffloadFooterOptions): string; /** * Resolve (and create) the offload file path for a tool result: * `/offloads//--.log`. * Honors `SPECTRAL_CONFIG_DIR` via `getConfigDir()`. */ export declare function resolveOffloadPath(sessionId: string, toolName: string): string; /** * Offload `text` to disk when it exceeds the size thresholds. * Small (or binary, or already-offloaded) results are returned unchanged * with `fullOutputPath: null` — no file, no overhead. */ export declare function offloadLargeResult(text: string, toolName: string, sessionId: string): OffloadResult; //# sourceMappingURL=offload.d.ts.map