/**
 * Tool result storage — CC toolResultStorage.ts aligned.
 *
 * Two-layer mechanism to manage tool result sizes:
 *   Level 1 (per-tool): At execution time, results > DEFAULT_MAX_RESULT_SIZE_CHARS
 *           are persisted to disk and replaced with preview references.
 *   Level 2 (per-message budget): Before API call, aggregate tool results in
 *           each group (consecutive tool messages between assistant messages)
 *           are checked against MAX_TOOL_RESULTS_PER_MESSAGE_CHARS. The largest
 *           fresh results are persisted until under budget.
 *
 * ContentReplacementState tracks decisions across turns for prompt cache
 * stability — once a tool result's fate is decided (replaced or not), the
 * decision is frozen for the remainder of the conversation.
 *
 * CC reference: src/utils/toolResultStorage.ts
 * Zero imports from express/pg/ioredis/ws.
 */
export declare const TOOL_RESULTS_SUBDIR = "tool-results";
/** XML tag wrapping persisted output previews (CC PERSISTED_OUTPUT_TAG) */
export declare const PERSISTED_OUTPUT_TAG = "<persisted-output>";
export declare const PERSISTED_OUTPUT_CLOSING_TAG = "</persisted-output>";
/** Marker injected by microcompact when clearing old tool results (CC parity) */
export declare const TOOL_RESULT_CLEARED_MESSAGE = "[Old tool result content cleared]";
/**
 * Per-conversation-thread state for the aggregate tool result budget.
 * State must be stable to preserve prompt cache:
 *   - seenIds: tool_call_ids that have passed through the budget check (replaced
 *     or not). Once seen, a result's fate is frozen for the conversation.
 *   - replacements: subset of seenIds that were persisted to disk and
 *     replaced with previews, mapped to the exact preview string.
 *     Re-application is a Map lookup — no file I/O, byte-identical.
 *
 * CC reference: ContentReplacementState
 */
export type ContentReplacementState = {
    seenIds: Set<string>;
    replacements: Map<string, string>;
};
export type PersistedToolResult = {
    filepath: string;
    originalSize: number;
    preview: string;
    hasMore: boolean;
};
export declare function createContentReplacementState(): ContentReplacementState;
export declare function generatePreview(content: string, maxBytes: number): {
    preview: string;
    hasMore: boolean;
};
export declare function persistToolResult(content: string, toolCallId: string, sessionId: string): Promise<PersistedToolResult | null>;
/**
 * Build a reference message for large tool results (CC buildLargeToolResultMessage parity).
 */
export declare function buildLargeToolResultMessage(result: PersistedToolResult): string;
/**
 * If content exceeds threshold, persist to disk and return a preview reference.
 * Falls back to hard truncation if persistence fails.
 * Called at tool execution time in streaming-tool-executor.ts.
 */
export declare function maybePersistLargeToolResult(content: string, toolCallId: string, sessionId: string, threshold?: number): Promise<string>;
interface MessageLike {
    role: string;
    content?: string | unknown;
    tool_call_id?: string;
}
/**
 * Enforce per-message aggregate budget on tool results.
 * CC enforceToolResultBudget parity.
 *
 * For each group of tool messages whose content together exceeds
 * the per-message limit, the largest FRESH (never-before-seen) results
 * are persisted to disk and replaced with previews.
 *
 * State is tracked by tool_call_id: once a result is seen, its fate is
 * frozen. Previously-replaced results get the same replacement re-applied
 * (no I/O, byte-identical). Previously-unreplaced results are never
 * replaced later (would break prompt cache).
 *
 * @param state — MUTATED in place (seenIds and replacements updated)
 * @returns messages with replacements applied + count of new replacements
 */
export declare function enforceToolResultBudget(messages: MessageLike[], state: ContentReplacementState, sessionId: string, limit?: number): Promise<{
    messages: MessageLike[];
    newlyReplacedCount: number;
}>;
export {};
