/**
 * StandaloneMcpServer — Plan 41 M1 stdio server.
 *
 * Implements the minimum subset of the Model Context Protocol that
 * Claude Code, Cursor, and Codex CLI clients use:
 *   - `initialize` handshake with capabilities advertisement
 *   - `tools/list` — returns the public-exposure tools from
 *     `McpToolRegistry`
 *   - `tools/call` — invokes the requested tool's handler with
 *     args, returns the structured content
 *
 * Wire protocol is JSON-RPC 2.0 over line-delimited JSON
 * (one request per stdin line, one response per stdout line).
 *
 * The dispatcher is factored out from the actual stdio wiring so
 * unit tests can drive request/response pairs without spawning a
 * subprocess. `bin/smartperfetto-mcp.ts` is the thin entry that
 * pipes process.stdin/stdout into `runStdioLoop`.
 *
 * Out of scope:
 * - Capability negotiation beyond `tools` (no resources / prompts).
 * - Auth handshake (deferred to Plan 41 M2 A2A).
 * - Streaming tool output (the agent SDK handlers we wrap are
 *   request/response only).
 *
 * @module standaloneMcpServer
 */
import { McpToolRegistry } from './mcpToolRegistry';
/** JSON-RPC 2.0 request shape. `id` is optional for notifications. */
export interface JsonRpcRequest {
    jsonrpc: '2.0';
    id?: string | number | null;
    method: string;
    params?: unknown;
}
/** JSON-RPC 2.0 response shape. Either `result` or `error` is set. */
export interface JsonRpcResponse {
    jsonrpc: '2.0';
    id: string | number | null;
    result?: unknown;
    error?: {
        code: number;
        message: string;
        data?: unknown;
    };
}
/** Standard JSON-RPC error codes plus MCP-specific tool errors. */
export declare const RPC_ERROR_CODES: {
    readonly PARSE_ERROR: -32700;
    readonly INVALID_REQUEST: -32600;
    readonly METHOD_NOT_FOUND: -32601;
    readonly INVALID_PARAMS: -32602;
    readonly INTERNAL_ERROR: -32603;
    readonly TOOL_EXECUTION_FAILED: -32000;
};
/** Dispatch one JSON-RPC request against the registry. Pure
 * function — no I/O. The stdio loop wraps this and writes the
 * response back. */
export declare function dispatch(registry: McpToolRegistry, req: JsonRpcRequest): Promise<JsonRpcResponse | null>;
/** Stream of incoming JSON-RPC messages. Implementations split a
 * stdin readable into one parsed request per line. */
export interface RequestSource {
    /** Yields the next request, or null when input is closed. */
    next(): Promise<JsonRpcRequest | null>;
}
/** Sink for outgoing JSON-RPC responses. */
export interface ResponseSink {
    send(response: JsonRpcResponse): void;
}
/** Run the dispatch loop until the source is exhausted. Each
 * request is dispatched independently; failures in one tool call
 * never bring down the loop. */
export declare function runStdioLoop(registry: McpToolRegistry, source: RequestSource, sink: ResponseSink): Promise<void>;
/** stdin-backed request source: reads line-delimited JSON from a
 * Node Readable. Returns null when the stream ends. Malformed JSON
 * lines are surfaced as a special MALFORMED_PARSE request so the
 * dispatch layer can emit a proper PARSE_ERROR. */
export declare class LineDelimitedJsonSource implements RequestSource {
    private buffer;
    private queue;
    private closed;
    private wakeup;
    constructor(stream: NodeJS.ReadableStream);
    private drainBuffer;
    private tryParseAndQueue;
    private wake;
    next(): Promise<JsonRpcRequest | null>;
}
/** stdout-backed response sink. Writes one JSON-encoded response
 * per line. */
export declare class LineDelimitedJsonSink implements ResponseSink {
    private stream;
    constructor(stream: NodeJS.WritableStream);
    send(response: JsonRpcResponse): void;
}
//# sourceMappingURL=standaloneMcpServer.d.ts.map