import { ComponentLogger } from '../core/logger.service.js';
import { SessionCommandHelper } from '../session/index.js';
import { RuntimeType } from '../../constants.js';
/**
 * Result of MCP configuration operation.
 * Returned by ensureMcpConfig to indicate what was configured.
 */
export interface McpConfigResult {
    /** Whether the config was written successfully */
    success: boolean;
    /** Number of new servers added */
    addedServers: number;
    /** Total servers in the final config */
    totalServers: number;
    /** Names of servers in the final config */
    serverNames: string[];
    /** Error message if success is false */
    error?: string;
}
/**
 * Runtime configuration interface
 */
export interface RuntimeConfig {
    displayName: string;
    initScript: string;
    welcomeMessage: string;
    timeout: number;
    description: string;
}
/**
 * Abstract base class for AI runtime services that handles tmux session initialization,
 * detection, and interaction patterns for different AI CLI tools.
 *
 * Uses Template Method pattern for maximum code reuse while allowing runtime-specific customization.
 */
export declare abstract class RuntimeAgentService {
    protected logger: ComponentLogger;
    protected sessionHelper: SessionCommandHelper;
    protected projectRoot: string;
    protected runtimeConfig: RuntimeConfig | null;
    private detectionInProgress;
    private detectionResults;
    constructor(sessionHelper: SessionCommandHelper, projectRoot: string);
    protected abstract getRuntimeType(): RuntimeType;
    protected abstract detectRuntimeSpecific(sessionName: string): Promise<boolean>;
    protected abstract getRuntimeReadyPatterns(): string[];
    protected abstract getRuntimeErrorPatterns(): string[];
    protected abstract getRuntimeExitPatterns(): RegExp[];
    /**
     * Get patterns that indicate this runtime has exited.
     * Used by RuntimeExitMonitorService to detect when the CLI process exits.
     *
     * @returns Array of RegExp patterns that match runtime exit output
     */
    getExitPatterns(): RegExp[];
    /**
     * Template method for executing runtime initialization script.
     * Most logic is shared, only runtime-specific parts are delegated to abstract methods.
     *
     * @param sessionName - PTY session name
     * @param targetPath - Working directory for the session
     * @param runtimeFlags - Optional CLI flags to inject before --dangerously-skip-permissions
     * @param promptFilePath - Optional path to a prompt file; for non-Claude-Code runtimes,
     *                         appends --append-system-prompt-file flag
     * @param agentName - Optional agent name for Claude Code --agent flag (#207)
     */
    executeRuntimeInitScript(sessionName: string, targetPath?: string, runtimeFlags?: string[], promptFilePath?: string, agentName?: string): Promise<void>;
    /**
     * Template method for detecting if runtime is running.
     * Handles caching and concurrent access, delegates actual detection to concrete classes.
     */
    detectRuntimeWithCommand(sessionName: string, forceRefresh?: boolean): Promise<boolean>;
    /**
     * Simplified method for waiting for runtime to be ready.
     * Checks at regular intervals until timeout, looking for ready patterns in the terminal output.
     */
    waitForRuntimeReady(sessionName: string, timeout: number, checkInterval?: number): Promise<boolean>;
    /**
     * Hook called after the runtime is ready but before prompts are sent.
     * Override in concrete classes for runtime-specific post-initialization steps
     * (e.g., Gemini CLI directory allowlist additions).
     *
     * Default implementation is a no-op.
     *
     * @param sessionName - PTY session name
     * @param targetProjectPath - Optional target project path for the agent (where MCP configs should be written).
     *                            Falls back to this.projectRoot if not provided.
     */
    postInitialize(sessionName: string, targetProjectPath?: string, additionalAllowlistPaths?: string[], browserAutomationOverride?: boolean): Promise<void>;
    /**
     * Clear cached detection results for a session
     */
    clearDetectionCache(sessionName: string): void;
    /**
     * Get runtime configuration
     */
    getRuntimeConfiguration(): RuntimeConfig | null;
    /**
     * Ensure MCP server configuration exists at the given config file path.
     *
     * Reads `enableBrowserAutomation` from settings, builds the required MCP servers
     * list, reads any existing config at `configFilePath`, merge-only adds missing
     * servers, and writes the result back via `atomicWriteJson`.
     *
     * Parent directories of `configFilePath` are created automatically with
     * `fs.mkdir({ recursive: true })`.
     *
     * Preserves any existing user-configured MCP servers (never overwrites).
     * Errors are non-fatal and logged as warnings.
     *
     * @param configFilePath - Absolute path to the MCP config JSON file
     *                         (e.g., `/project/.mcp.json` or `/project/.gemini/settings.json`)
     * @param projectPath - Project directory path, used only for log context
     * @param browserAutomationOverride - Per-agent override for browser automation.
     *                                    When provided, takes precedence over global settings.
     *                                    `undefined` means use global setting.
     */
    protected ensureMcpConfig(configFilePath: string, projectPath: string, browserAutomationOverride?: boolean): Promise<McpConfigResult>;
    /**
     * Verify MCP config file exists and contains expected servers.
     *
     * Reads the config file back after write and checks that the expected
     * server names are present. Non-fatal — logs warnings on failure.
     *
     * @param configFilePath - Absolute path to the MCP config JSON file
     * @param expectedServers - Server names expected to be present (e.g. ['playwright'])
     * @returns True if all expected servers are present, false otherwise
     */
    protected verifyMcpConfig(configFilePath: string, expectedServers: string[]): Promise<boolean>;
    /**
     * Check if the Crewly Pro addon is installed.
     *
     * Pro addon provides its own Crewly in Chrome bridge, so Playwright MCP
     * should not be injected when it is present.
     *
     * @returns True if crewly-pro addon manifest exists
     */
    protected isProAddonInstalled(): boolean;
    /**
     * Initialize runtime configuration from config file
     */
    private initializeRuntimeConfig;
    /**
     * Get runtime configuration with fallback
     */
    protected getRuntimeConfig(): RuntimeConfig;
    /**
     * Load initialization script commands from file
     */
    protected loadInitScript(scriptName: string): Promise<string[]>;
    /**
     * Send shell commands to session
     */
    protected sendShellCommandsToSession(sessionName: string, commands: string[], targetPath?: string): Promise<void>;
}
//# sourceMappingURL=runtime-agent.service.abstract.d.ts.map