import type { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { ProjectConfig } from "../../types/index.js";
import type { KnowledgeIndexManager } from "../../knowledge/index_manager.js";
import type { TaskContextManager } from "../../engine/pipeline/task_context.js";
import type { LLMGateway } from "../../engine/core/llm_gateway.js";
import type { IOController } from "../../engine/core/io_controller.js";
/** MCP 工具 handler 参数类型 — schema 解析后的动态类型，消费者通过 args.xxx 直接访问字段 */
export type ToolRequestArgs = Record<string, any>;
/** MCP 工具 handler 返回类型 — 由中间件动态检查结构 */
export type ToolHandlerResult = unknown;
/**
 * 工具 handler 错误返回类型 — 结构化错误信息。
 * 用于新/修改的 handler 返回统一格式的错误，渐进式迁移。
 */
export interface ToolHandlerError {
    /** 错误描述 */
    error: string;
    /** 诊断码 — 对应 TOOL_DIAGNOSTIC_CODES 中的条目 */
    diagnostic_code?: string;
    /** 恢复建议 */
    recovery?: string;
    /** 恢复后推荐的下一步工具 */
    recovery_next_tools?: string[];
    /** 恢复后禁止使用的工具 */
    recovery_forbidden_tools?: string[];
}
export interface ToolRegistrationContext {
    server: McpServer;
    config: ProjectConfig;
    knowledgeIndex: KnowledgeIndexManager;
    taskContext: TaskContextManager;
    gateway: LLMGateway;
    ioController: IOController;
    projectPath: string;
}
export interface ToolRegistrar {
    registerSafeTool: (name: string, desc: string, schema: Record<string, z.ZodTypeAny>, handler: (args: ToolRequestArgs) => Promise<ToolHandlerResult>) => void;
    loadRelevantAnchors: (query: {
        module?: string;
        file_paths?: string[];
    }) => Promise<Array<{
        anchor_id: string;
        module: string;
        summary: string;
        stale_anchor?: boolean;
    }> | undefined>;
}
export declare function createToolRegistrar(ctx: ToolRegistrationContext): ToolRegistrar;
//# sourceMappingURL=middleware.d.ts.map