/**
 * @fileoverview Bash Tool Parser - Detects active Bash tool commands with file paths
 *
 * This module parses terminal output from Claude Code sessions to detect:
 * - Bash tool invocations (● Bash(command) pattern)
 * - File paths within commands (for tail, cat, head, grep, watch, less)
 * - Tool completion (✓ or ✗ status)
 *
 * When a file-viewing command is detected, emits events with clickable paths
 * that can be used to open live log viewer windows.
 *
 * @module bash-tool-parser
 */
import { EventEmitter } from 'node:events';
import { ActiveBashTool } from './types.js';
/**
 * Events emitted by BashToolParser.
 */
interface BashToolParserEvents {
    /** New Bash tool with file paths started */
    toolStart: [tool: ActiveBashTool];
    /** Bash tool completed */
    toolEnd: [tool: ActiveBashTool];
    /** Active tools list updated */
    toolsUpdate: [tools: ActiveBashTool[]];
}
/**
 * Configuration options for BashToolParser.
 */
interface BashToolParserConfig {
    /** Session ID this parser belongs to */
    sessionId: string;
    /** Whether the parser is enabled (default: true) */
    enabled?: boolean;
    /** Working directory for resolving relative paths */
    workingDir?: string;
}
/**
 * Parses Claude Code terminal output to detect Bash tool commands with file paths.
 * Emits events when file-viewing commands are detected, allowing the UI to
 * display clickable paths for opening live log viewers.
 *
 * @example
 * ```typescript
 * const parser = new BashToolParser({ sessionId: 'abc123' });
 * parser.on('toolStart', (tool) => {
 *   console.log(`New tool: ${tool.command}`);
 *   console.log(`File paths: ${tool.filePaths.join(', ')}`);
 * });
 * parser.processTerminalData(terminalOutput);
 * ```
 */
export declare class BashToolParser extends EventEmitter<BashToolParserEvents> {
    private _sessionId;
    private _enabled;
    private _activeTools;
    private _lineBuffer;
    private _lastToolId;
    private _workingDir;
    private _homeDir;
    private cleanup;
    private _destroyed;
    private _updateDeb;
    constructor(config: BashToolParserConfig);
    /** Whether the parser is currently enabled */
    get enabled(): boolean;
    /** Session ID this parser belongs to */
    get sessionId(): string;
    /** Currently active tools */
    get activeTools(): ActiveBashTool[];
    /** Current working directory used for path resolution */
    get workingDir(): string;
    /**
     * Normalize a file path to its canonical form.
     * - Expands ~ to home directory
     * - Resolves relative paths against working directory
     * - Normalizes . and .. components
     * - Removes trailing slashes
     */
    normalizePath(path: string): string;
    /**
     * Extract just the filename from a path.
     */
    private getFilename;
    /**
     * Check if a path is a "shallow root path" - an absolute path with only one
     * component after root (e.g., /test.txt, /file.log).
     * These are often typos where the user meant a relative path.
     */
    private isShallowRootPath;
    /**
     * Check if a path is inside (or is) the working directory.
     */
    isPathInWorkingDir(path: string): boolean;
    /**
     * Smart path equivalence check.
     * Two paths are considered equivalent if:
     * 1. They normalize to the same path (standard case)
     * 2. One is a "shallow root path" (e.g., /test.txt) and the other is the
     *    same filename inside the working directory - the shallow root path
     *    is likely a typo and they probably meant the same file.
     */
    pathsAreEquivalent(path1: string, path2: string): boolean;
    /**
     * Given multiple paths, deduplicate and return the "best" paths.
     * Uses smart equivalence checking:
     * - Standard normalization for relative vs absolute paths
     * - Detects likely typos (e.g., /file.txt when workingDir/file.txt exists)
     * - Prefers paths inside the working directory
     * - Prefers longer, more explicit paths
     */
    deduplicatePaths(paths: string[]): string[];
    /**
     * Update the working directory (e.g., when session changes directory).
     */
    setWorkingDir(workingDir: string): void;
    /**
     * Check if a file path is already being tracked by an active tool.
     * Uses path normalization to detect equivalent paths.
     * For example, "/test.txt" and "/home/user/test.txt" when workingDir
     * is "/home/user" would NOT be considered equivalent (different files),
     * but "test.txt" and "/home/user/test.txt" WOULD be (same file).
     */
    isFilePathTracked(filePath: string): boolean;
    /**
     * Get all tracked paths (normalized) for debugging.
     */
    getTrackedPaths(): {
        raw: string;
        normalized: string;
    }[];
    /**
     * Enables the parser.
     */
    enable(): void;
    /**
     * Disables the parser.
     */
    disable(): void;
    /**
     * Resets the parser state, clearing all tracked tools.
     */
    reset(): void;
    /**
     * Process terminal data to detect Bash tool patterns.
     * Call this with each chunk of PTY output.
     *
     * @param data - Raw terminal data (may include ANSI codes)
     */
    processTerminalData(data: string): void;
    /**
     * Process pre-stripped terminal data (ANSI codes already removed).
     * Use this when the caller has already stripped ANSI to avoid redundant regex work.
     */
    processCleanData(data: string): void;
    /**
     * Process a single line of terminal output (raw — will strip ANSI).
     */
    private processLine;
    /**
     * Process a single pre-stripped line of terminal output.
     */
    private processCleanLine;
    private _handleToolStart;
    private _handleToolCompletion;
    private _handleTextCommand;
    private _handleLogFileMention;
    private _createActiveTool;
    private _scheduleAutoRemove;
    /**
     * Check if a command is a file-viewing command worth tracking.
     */
    private isFileViewerCommand;
    /**
     * Extract file paths from a command string.
     * Returns deduplicated paths, preferring more complete/absolute versions.
     */
    private extractFilePaths;
    /**
     * Schedule a debounced update emission.
     */
    private scheduleUpdate;
    /**
     * Emit the current active tools list.
     */
    private emitUpdate;
    /**
     * Clean up resources.
     */
    destroy(): void;
}
export {};
//# sourceMappingURL=bash-tool-parser.d.ts.map