/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * Safely replaces text with literal strings, avoiding ECMAScript GetSubstitution issues.
 * Escapes $ characters to prevent template interpretation.
 */
export declare function safeLiteralReplace(str: string, oldString: string, newString: string): string;
/**
 * Strips ANSI/VT escape sequences from a raw byte buffer.
 * Uses latin1 encoding to preserve every byte's value exactly (0-255)
 * while allowing string-based removal of escape sequences.
 */
export declare function stripAnsiFromBuffer(data: Buffer): Buffer;
/**
 * Checks if a Buffer is likely binary by testing for the presence of a NULL byte.
 * The presence of a NULL byte is a strong indicator that the data is not plain text.
 * @param data The Buffer to check.
 * @param sampleSize The number of bytes from the start of the buffer to test.
 * @param isPtyOutput When true, ANSI escape sequences are stripped before
 *   checking and a null-byte ratio threshold is used instead of failing on
 *   a single null byte.  This prevents false positives caused by node-pty
 *   on Windows emitting VT control sequences that contain null bytes.
 * @returns True if the data is likely binary, false otherwise.
 */
export declare function isBinary(data: Buffer | null | undefined, sampleSize?: number, isPtyOutput?: boolean): boolean;
/**
 * Detects the line ending style of a string.
 * @param content The string content to analyze.
 * @returns '\r\n' for Windows-style, '\n' for Unix-style.
 */
export declare function detectLineEnding(content: string): '\r\n' | '\n';
/**
 * Truncates a string to a maximum length, appending a suffix if truncated.
 * @param str The string to truncate.
 * @param maxLength The maximum length of the string.
 * @param suffix The suffix to append if truncated (default: '...[TRUNCATED]').
 * @returns The truncated string.
 */
export declare function truncateString(str: string, maxLength: number, suffix?: string): string;
/**
 * Safely replaces placeholders in a template string with values from a replacements object.
 * This performs a single-pass replacement to prevent double-interpolation attacks.
 *
 * @param template The template string containing {{key}} placeholders.
 * @param replacements A record of keys to their replacement values.
 * @returns The resulting string with placeholders replaced.
 */
export declare function safeTemplateReplace(template: string, replacements: Record<string, string>): string;
/**
 * Sanitizes output for injection into the model conversation.
 * Wraps output in a secure <output> tag and handles potential injection vectors
 * (like closing tags or template patterns) within the data.
 * @param output The raw output to sanitize.
 * @returns The sanitized string ready for injection.
 */
export declare function sanitizeOutput(output: string): string;
/**
 * Wraps text in <untrusted_context> tags to mitigate prompt injection.
 */
export declare function wrapUntrusted(text: string): string;
