/** * Content-aware tool-output compression. * * Today's tool path shrinks oversized output with blunt head/tail line cuts * (`truncate.ts`). That throws away whichever half the model didn't get — a * stack trace buried in the middle of a 10k-line log, the one failing assertion * between thousands of passing ones, the shape of a giant JSON array. * * `compressOutput` keeps the *signal* instead of a positional slice: * - logs: collapse repeated runs, keep every error/warn line + local context, * keep head and tail, drop only the boring middle. * - JSON: keep array shape + a sample, replace the long tail with a count. * - text: middle-out (head + tail) so the command/context AND the result survive. * * It is lossy by design but information-preserving: the goal is fewer tokens * with the same understanding. Pair with an overflow file for full reversibility. */ export interface CompressResult { content: string; /** Which strategy fired — for telemetry / benchmarking. */ strategy: "json" | "log" | "text" | "none"; originalTokens: number; compressedTokens: number; } export interface CompressOptions { /** Don't compress below this token count — small output isn't worth touching. */ minTokens?: number; /** Lines of context to keep on each side of an important log line. */ contextLines?: number; /** Head/tail lines always retained. */ headLines?: number; tailLines?: number; /** Max elements kept per JSON array before summarising the rest. */ jsonArraySample?: number; } /** * Compress a tool output string, auto-detecting its content type. */ export declare function compressOutput(raw: string, opts?: CompressOptions): CompressResult; export interface ToolOutputCompression { content: string; /** Human/agent-facing summary of what was kept, for the truncation notice. */ notice: string; strategy: CompressResult["strategy"]; } /** * Compress output that a tool was ALREADY going to truncate. * * This is the only sanctioned live integration point. It is invoked solely on * the over-limit branch of a tool (bash / task_output) — where today's * alternative is a blind tail slice that discards the head and any mid-stream * error. It keeps generous head/tail (tool output is tail-oriented) plus every * error line and collapses repeats. The caller still writes the full original * to an overflow file, so this stays fully reversible. */ export declare function compressToolOutput(raw: string): ToolOutputCompression; //# sourceMappingURL=compress.d.ts.map