export { LLMResponseParser } from './agent/parser.js';
import { ChatMessage, ToolCall, FinishFileSpec } from './agent/types.js';
export { ToolName } from './agent/types.js';
import { WarpGrepProvider, ListDirectoryEntry } from './providers/types.js';
export { GrepResult, ReadResult } from './providers/types.js';
export { SYSTEM_PROMPT, getSystemPrompt } from './agent/prompt.js';
export { formatAgentToolOutput as formatToolResult } from './agent/formatter.js';
export { n as normalizeFinishFiles, r as readFinishFiles, t as toolGrep, b as toolListDirectory, a as toolRead } from '../../finish-pPJfB0uO.js';
export { AGENT_CONFIG, DEFAULT_EXCLUDES } from './agent/config.js';
export { LocalRipgrepProvider } from './providers/local.js';
import '../utils/resilience.js';

/**
 * Shared helper functions for warp-grep agent loop.
 * Used by both the internal runner and exported for harness users.
 */

/**
 * Format the turn counter message shown to the model.
 */
declare function formatTurnMessage(turnsUsed: number, maxTurns: number): string;
/**
 * Calculate and format the context budget indicator.
 */
declare function calculateContextBudget(messages: ChatMessage[]): string;
/**
 * Build the initial state message containing repo structure and query.
 */
declare function buildInitialState(repoRoot: string, query: string, provider: WarpGrepProvider): Promise<string>;
/**
 * Format directory entries as an indented tree string.
 */
declare function formatListDirectoryTree(entries: ListDirectoryEntry[]): string;

/**
 * Warp Grep Harness Primitives
 *
 * Building blocks for custom agent harnesses.
 * Use these when you want to control the agent loop yourself.
 *
 * @example
 * ```typescript
 * import {
 *   parseToolCalls,
 *   SYSTEM_PROMPT,
 *   formatToolResult,
 *   formatTurnMessage,
 *   formatListDirectoryTree,
 *   calculateContextBudget,
 *   buildInitialState,
 *   toolGrep,
 *   toolRead,
 *   toolListDirectory,
 *   resolveFinishFiles,
 *   AGENT_CONFIG,
 *   LocalRipgrepProvider,
 *   type ToolCall,
 *   type WarpGrepProvider,
 * } from '@morphllm/morphsdk/tools/warp-grep/harness';
 *
 * const provider = new LocalRipgrepProvider(repoRoot);
 * const messages = [
 *   { role: 'system', content: SYSTEM_PROMPT },
 *   { role: 'user', content: await buildInitialState(repoRoot, query, provider) },
 * ];
 *
 * for (let turn = 1; turn <= AGENT_CONFIG.MAX_TURNS; turn++) {
 *   const response = await myModel(messages);
 *   messages.push({ role: 'assistant', content: response });
 *
 *   const toolCalls = parseToolCalls(response);
 *   const results: string[] = [];
 *
 *   for (const call of toolCalls) {
 *     if (call.name === 'finish') {
 *       return await resolveFinishFiles(provider, call.arguments.files);
 *     }
 *
 *     let output: string;
 *     if (call.name === 'grep') {
 *       const r = await toolGrep(provider, call.arguments);
 *       output = r.output;
 *     } else if (call.name === 'read') {
 *       output = await toolRead(provider, call.arguments);
 *     } else if (call.name === 'list_directory') {
 *       output = await toolListDirectory(provider, call.arguments);
 *     }
 *
 *     results.push(formatToolResult(call.name, call.arguments, output));
 *   }
 *
 *   const turnMsg = formatTurnMessage(turn, AGENT_CONFIG.MAX_TURNS);
 *   const budget = calculateContextBudget(messages);
 *   messages.push({ role: 'user', content: results.join('\n') + turnMsg + '\n' + budget });
 * }
 * ```
 */

declare function parseToolCalls(text: string): ToolCall[];

type ResolvedFile = {
    path: string;
    content: string;
};
declare function resolveFinishFiles(provider: WarpGrepProvider, files: FinishFileSpec[]): Promise<ResolvedFile[]>;

export { ChatMessage, FinishFileSpec, ListDirectoryEntry, type ResolvedFile, ToolCall, WarpGrepProvider, buildInitialState, calculateContextBudget, formatListDirectoryTree, formatTurnMessage, parseToolCalls, resolveFinishFiles };
