export { earliestMatchOffsetChars } from "./text-match.js"; export declare const TOOL_OUTPUT_MAX_BYTES: number; export declare const DEFAULT_READ_WINDOW_CHARS = 12000; export declare const MAX_READ_WINDOW_CHARS = 50000; export declare const HISTORY_PREVIEW_CHARS = 1200; /** True when `value` serializes within the same wire budget `output()` enforces. */ export declare function withinBudget(value: unknown, budget?: number): boolean; /** True when `text` fits the wire budget verbatim, for raw payloads with no JSON encoding. */ export declare function withinTextBudget(text: string, budget?: number): boolean; /** Marker standing in for characters elided from the middle of an oversized single unit. */ export declare function truncationMarker(removedChars: number): string; export declare function middleTruncate(text: string, fits: (content: string) => boolean): string; /** * Longest contiguous prefix of `text` (counted in code points) accepted by `fits`. * * This is the truncation used by every cursor-bearing payload: the delivered text is * always a plain prefix of the original, so a cursor computed from its code-point length * addresses exactly the first undelivered character. No marker character is ever appended; * the companion `truncated`/`total_chars` fields name what was left out. */ export declare function prefixFit(text: string, fits: (content: string) => boolean): string; /** * Fields every character-window read returns; each tool adds its own identity and metadata. * `offset_chars` is always the resolved absolute offset, and `next_offset_chars` is exactly * that offset plus the delivered code-point count, null only at the text's true end. */ export type CharacterWindow = { offset_chars: number; content: string; total_chars: number; next_offset_chars: number | null; }; /** * Read one character window of `text`: the longest contiguous prefix of * `chars[resolved, resolved + limit)` that fits the wire budget. * * `offsetChars` is a code-point offset. A negative value counts back from the end and * resolves to `max(0, total_chars + offsetChars)`, so `-N` reaches the tail and any * `N >= total_chars` reads from the start; the resolved absolute offset is always echoed. * Following `next_offset_chars` reconstructs `text` by plain concatenation, because the * payload is always a plain prefix with no marker. `render` builds the exact response for * a candidate window, and `measure` decides whether that response fits the wire budget (JSON * serialization by default; raw-text renders pass a verbatim byte measure), so the budget is * always measured on the bytes that go on the wire. */ export declare function readCharacterWindow(text: string, offsetChars: number | undefined, limitChars: number | undefined, render: (window: CharacterWindow) => T, measure?: (rendered: T) => boolean): T; /** * Fixed metadata block preceding any raw character-window payload. Callers supply their * source identity fields in wire order; range and continuation semantics are shared. */ export declare function readWindowBlock(identity: ReadonlyArray, window: CharacterWindow): string; /** * Encode a structured result through the common tool result boundary. `details` is slim * metadata for logs/UI (pi convention: never a second copy of the payload) and stays * undefined unless the tool has metadata worth persisting. */ export declare function output(value: unknown, details?: unknown, terminate?: boolean): { content: { type: "text"; text: string; }[]; details: unknown; terminate: boolean; }; /** * Encode a prose payload as raw text: metadata prefix, a blank line, then the payload * verbatim. `details` carries the slim metadata object and never duplicates the payload. */ export declare function outputRaw(header: string, content: string, details: unknown, terminate?: boolean): { content: { type: "text"; text: string; }[]; details: unknown; terminate: boolean; };