/**
 * TCP client for the Workbench NET API.
 *
 * Each rawCall() opens a fresh TCP connection, sends one request, reads the
 * response, and closes the socket (protocol requirement).
 *
 * call() wraps rawCall() with auto-launch: if Workbench isn't running,
 * it installs handler scripts, launches the exe, waits for the NET API,
 * and retries the original call.
 */
import type { Config } from "../config.js";
export interface WorkbenchCallOptions {
    /** Timeout in milliseconds (default 10 000). */
    timeout?: number;
    /** Skip auto-launch on connection failure (used internally by ping). */
    skipAutoLaunch?: boolean;
}
export declare class WorkbenchError extends Error {
    readonly code: "CONNECTION_REFUSED" | "TIMEOUT" | "PROTOCOL_ERROR" | "API_ERROR" | "LAUNCH_FAILED";
    constructor(message: string, code?: "CONNECTION_REFUSED" | "TIMEOUT" | "PROTOCOL_ERROR" | "API_ERROR" | "LAUNCH_FAILED");
}
export declare class WorkbenchClient {
    private readonly host;
    private readonly port;
    private readonly config?;
    private readonly clientId;
    private launching;
    private launchPromise;
    constructor(host: string, port: number, config?: Config | undefined, clientId?: string);
    /**
     * Call a Workbench NET API function.
     * Auto-launches Workbench if not running.
     */
    call<T = Record<string, unknown>>(apiFunc: string, params?: Record<string, unknown>, options?: WorkbenchCallOptions): Promise<T>;
    /**
     * Ensure Workbench is running. Installs handler scripts, launches exe,
     * and waits for NET API. Safe to call concurrently — deduplicates launches.
     * @param gprojPath Optional .gproj file path to open directly (skips launcher).
     */
    ensureRunning(gprojPath?: string): Promise<void>;
    /**
     * Quick health check. Returns true if Workbench responds, false otherwise.
     * Does NOT auto-launch.
     *
     * Uses our custom EMCP_WB_Ping handler (not the built-in GetLoadedProjects)
     * so the launch poller only succeeds once the mod's handler scripts have
     * finished compiling — avoiding a race where the NET API socket is up but
     * custom handlers aren't loaded yet.
     */
    ping(): Promise<boolean>;
    /**
     * Remove injected handler scripts from a mod's directory.
     * Call this after Workbench work is done, before publishing the mod.
     * Deletes Scripts/WorkbenchGame/EnfusionMCP/ from the mod.
     * Safe to call even if scripts were never injected.
     */
    cleanupHandlerScripts(modDir: string): boolean;
    toString(): string;
    /**
     * Recover from "not existing Net API function" errors.
     * Workbench is running but our handler scripts aren't compiled.
     * Installs handlers, kills Workbench, relaunches so scripts compile on startup.
     */
    private recoverMissingHandlers;
    /**
     * Kill any running Workbench process. Windows-only (taskkill).
     * Safe to call even if Workbench isn't running.
     */
    private killWorkbench;
    private launchWorkbench;
    private findWorkbenchExe;
    /**
     * Find a .gproj to pass via -gproj so Workbench skips the launcher.
     * Looks for any .gproj in the default project path.
     */
    private findFallbackGproj;
    /**
     * Derive the Arma Reforger game install directory.
     * Checks ENFUSION_GAME_PATH env var first, then walks up from workbenchPath.
     * workbenchPath may point to the Tools root OR the Workbench subdirectory,
     * so we try both one and two levels up.
     */
    private findGameDir;
    /**
     * Copy handler scripts into a mod directory so they compile as part of that mod.
     * If no modDir given, installs to default project path (standalone, less useful).
     */
    private installHandlerScripts;
    /**
     * Raw TCP call — no auto-launch, no retry.
     */
    private rawCall;
}
//# sourceMappingURL=client.d.ts.map