/**
 * @module adapters/mcp
 * @description Adapter from manifest entries to MCP server tool array +
 * dispatcher. Consumed by `packages/mcp-server/src/tools/index.ts`.
 */
import { type JsonSchema } from "../zod-to-json-schema.js";
import type { ToolDefinition } from "../define-tool.js";
/**
 * Top-level MCP tool inputSchema. We always emit `{ type:"object", properties,
 * required }` at the root, so unlike the generic `JsonSchema` (which has
 * optional `properties`/`required` for leaf nodes), the top-level shape's
 * `properties` is required.
 */
export interface McpInputSchema {
    type: "object";
    properties: Record<string, JsonSchema>;
    required: string[];
    description?: string;
}
/** MCP spec ToolAnnotations — safety hints surfaced to hosts. */
export interface McpToolAnnotations {
    readOnlyHint: boolean;
    destructiveHint?: boolean;
    idempotentHint?: boolean;
    openWorldHint: boolean;
}
export interface McpTool {
    name: string;
    /** Human-readable display name (MCP BaseMetadata.title). */
    title: string;
    description: string;
    inputSchema: McpInputSchema;
    annotations: McpToolAnnotations;
}
/**
 * Structural mirror of the MCP elicitation form request/result (the CLI
 * package deliberately has no dependency on @modelcontextprotocol/sdk).
 * `requestedSchema.properties` values follow the spec's flat primitive
 * schema: string (optionally with enum/enumNames), number, boolean.
 */
export interface ElicitForm {
    message: string;
    requestedSchema: {
        type: "object";
        properties: Record<string, unknown>;
        required?: string[];
    };
}
export interface ElicitOutcome {
    action: "accept" | "decline" | "cancel";
    content?: Record<string, string | number | boolean | string[]>;
}
export type ElicitFn = (form: ElicitForm) => Promise<ElicitOutcome>;
/** Per-call extras forwarded by the MCP server request handler. */
export interface McpCallExtra {
    /**
     * Raw progress sink — typically sends an MCP `notifications/progress` for
     * the request's progressToken. The dispatcher wraps it with throttling,
     * monotonicity, and post-completion cutoff before exposing it to tools.
     */
    onProgress?: (update: {
        progress: number;
        total?: number;
        message?: string;
    }) => void;
    /**
     * Sends an `elicitation/create` form to the client and resolves with the
     * user's answer. Only present when the connected client advertises the
     * elicitation capability.
     */
    elicit?: ElicitFn;
}
export type McpDispatcher = (name: string, args: Record<string, unknown>, extra?: McpCallExtra) => Promise<{
    content: Array<{
        type: "text";
        text: string;
    }>;
}>;
export interface ProgressSink {
    send: (update: {
        progress?: number;
        total?: number;
        message?: string;
    }) => void;
    close: () => void;
}
/**
 * Wrap a raw progress callback with the guarantees the MCP spec expects:
 * `progress` increases monotonically per token, updates are throttled to at
 * most one per `minIntervalMs` (the first always passes), and nothing is
 * emitted after `close()` — progress notifications must stop once the
 * request's result has been sent.
 */
export declare function makeProgressSink(raw: McpCallExtra["onProgress"], minIntervalMs?: number): ProgressSink;
/** Filter manifest by `surfaces.mcp` (default: included) and project to MCP tool shape. */
export declare function manifestToMcpTools(manifest: readonly ToolDefinition[]): McpTool[];
/** Build the dispatcher used by `handleToolCall` in the MCP server. */
export declare function buildMcpDispatcher(manifest: readonly ToolDefinition[]): McpDispatcher;
