/**
 * MCP per-connection session — speaks the JSON-RPC protocol (initialize,
 * tools/list, tools/call) over a single {@link JsonRpcTransport}. It owns
 * per-client state only (which protocol version the client asked for, whether
 * it advertised `roots`, the one-shot roots/list latch); the heavyweight
 * resources (CodeGraph, watcher, ToolHandler) live in the shared
 * {@link MCPEngine} so daemon mode can collapse N inotify sets / DB handles
 * to one.
 *
 * The state-machine itself mirrors what `MCPServer` used to do inline before
 * issue #411 split it out — the same regression tests in
 * `__tests__/mcp-initialize.test.ts` still drive this code path.
 */
import { JsonRpcTransport } from './transport';
import { MCPEngine } from './engine';
import { ExploreSessionState } from './explore-session-state';
/**
 * MCP Server Info — kept on the session because some clients log it. The
 * version tracks the real package version (was a hard-coded '0.1.0').
 */
export declare const SERVER_INFO: {
    name: string;
    version: string;
};
/**
 * Instructions for the `initialize` response, with the update-availability
 * notice appended when one is known (#1243). Exported so the proxy's local
 * handshake sends the IDENTICAL payload — same convention as SERVER_INFO.
 * `getUpdateNotice` is a memoized synchronous cache read, so the #172
 * respond-fast contract holds; when no notice exists the instructions are
 * byte-identical to the bare constants.
 *
 * Test-authoring note: on a machine whose real `~/.codegraph` cache knows a
 * newer release, spawned servers append the notice — a test asserting exact
 * instructions equality must set `CODEGRAPH_NO_UPDATE_CHECK=1` in the spawn
 * env or it will fail only in the weeks after a release ships.
 */
export declare function initializeInstructions(base: string, notice?: string | null): string;
/** MCP Protocol Version (latest the server claims). */
export declare const PROTOCOL_VERSION = "2024-11-05";
export interface MCPSessionOptions {
    /**
     * Explicit project path from the `--path` CLI flag. When set, the session
     * will not bother asking the client for `roots/list` — we already know
     * where the project lives.
     */
    explicitProjectPath?: string | null;
}
/**
 * One MCP client's view of the server. Created fresh per stdio launch
 * (direct mode) or per socket connection (daemon mode).
 */
export declare class MCPSession {
    private transport;
    private engine;
    private clientSupportsRoots;
    /** From the initialize handshake — attributes usage rollups to the agent host. */
    private clientInfo;
    private rootsAttempted;
    private resolvePromise;
    private explicitProjectPath;
    /**
     * What `codegraph_explore` has already returned to THIS client, per project
     * (CG-17). Owned by the session, not the engine: the daemon shares one engine
     * (and one ToolHandler, and a pool of worker threads) across every connected
     * client, so state kept over there would blend two agents' histories and let
     * one session's calls suppress source the other has never seen. It dies with
     * the session — a reconnecting client starts clean.
     */
    private readonly exploreSession;
    constructor(transport: JsonRpcTransport, engine: MCPEngine, opts?: MCPSessionOptions);
    /**
     * Start handling messages from the transport. Returns immediately — the
     * session lives for as long as the transport is open.
     */
    start(): void;
    /**
     * Tear down the session. Does NOT touch the engine (the engine may serve
     * other sessions) or call `process.exit` (the daemon decides when to exit).
     */
    stop(): void;
    /** Underlying transport — exposed for daemon-side close hooks. */
    getTransport(): JsonRpcTransport;
    /**
     * This session's explore call history (CG-17). Exposed so tests can assert
     * that two sessions on one daemon keep separate state; nothing in the server
     * reaches for another session's copy.
     */
    getExploreSessionState(): ExploreSessionState;
    private handleMessage;
    private handleInitialize;
    private handleToolsList;
    private handleToolsCall;
    /**
     * Lazy default-project resolution. Three layers:
     *   1. await the in-flight init kicked off from `handleInitialize` (if any);
     *   2. if still uninitialized and we never asked the client for its roots,
     *      do so now (one-shot); fall back to cwd if the client lacks roots;
     *   3. last-resort: re-walk from the best candidate — picks up projects
     *      that were `codegraph init`'d *after* the server started.
     */
    private retryInitIfNeeded;
    /**
     * Ask the client for its workspace root via `roots/list` and open the
     * first one. Falls back to `process.cwd()` on timeout or empty answer.
     */
    private initFromRoots;
}
//# sourceMappingURL=session.d.ts.map