UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

43 lines • 2.36 kB
/** * Model-facing formatting for PTY terminal output. * * The PTY bash tools capture a raw terminal stream: escape sequences, and one * redraw frame per spinner tick. Returned unbounded (up to the 1 MB session * buffer), a single `gh run view --log-failed` injected ~1M chars of ANSI soup * into the conversation and forced emergency compactions. Before output * reaches the model it is (a) sanitized — escape sequences stripped and * carriage-return/backspace redraws collapsed — then (b) tail-truncated to the * same budget the core bash tool enforces. */ import type { TextContent } from "@earendil-works/pi-ai"; import { type TruncationResult } from "../../../tools/truncate.ts"; /** Mirrors the core bash tool budget (`DEFAULT_MAX_LINES` / `DEFAULT_MAX_BYTES`). */ export declare const TERMINAL_TOOL_MAX_LINES = 2000; export declare const TERMINAL_TOOL_MAX_BYTES: number; /** Strip escape sequences and collapse carriage-return/backspace redraws. */ export declare function sanitizeTerminalOutput(raw: string): string; export interface FormattedTerminalToolOutput { /** Model-facing text: the kept output, then the truncation marker when content was cut. */ readonly text: string; /** The kept output alone, without the marker. */ readonly body: string; /** Truncation marker addressed to the model; UIs never render it. */ readonly marker?: string; readonly truncated: boolean; readonly truncation: TruncationResult; } /** * Sanitize `raw` PTY output and bound it to the core-bash budget, keeping the * tail (where exit status and errors live) with a marker when content was cut. */ export declare function formatTerminalToolOutput(raw: string): FormattedTerminalToolOutput; /** * Split a tool-result text into parts so each notice becomes its own model-only * part. Providers join a tool result's text parts with "\n", so every notice * must sit on its own line: the newline before it (and after it, when text * follows) is taken out of the neighbouring parts and restored by that join. * The joined parts are therefore byte-identical to `text`. A notice that is * absent or not line-delimited leaves `text` as one visible part. */ export declare function splitModelOnlyNotices(text: string, notices: ReadonlyArray<string | undefined>): TextContent[]; //# sourceMappingURL=output-format.d.ts.map