/**
 * Skill Analysis Adapter
 *
 * Integrates SkillExecutor with the orchestrator.
 * Provides intent detection, skill execution, and result conversion.
 */
import { TraceProcessorService } from '../traceProcessorService';
import { LayeredResult } from './skillExecutor';
import { SkillDefinition, SkillEvent, DisplayLevel, DisplayLayer } from './types';
import { EventSummary } from './eventCollector';
export interface SkillAnalysisRequest {
    traceId: string;
    skillId?: string;
    question?: string;
    packageName?: string;
    params?: Record<string, any>;
}
export interface SkillAnalysisResponse {
    skillId: string;
    skillName: string;
    success: boolean;
    sections: Record<string, any>;
    diagnostics: Array<{
        id: string;
        severity: string;
        message: string;
        suggestions?: string[];
    }>;
    summary: string;
    executionTimeMs: number;
    vendor?: string;
    displayResults?: Array<{
        stepId: string;
        title: string;
        level: DisplayLevel;
        format: string;
        data: any;
        columnDefinitions?: Array<Record<string, any>>;
    }>;
    aiSummary?: string;
    /** 直接回答用户问题的自然语言 */
    directAnswer?: string;
    /** 回答的问题类型 */
    questionType?: string;
    /** 回答置信度 */
    answerConfidence?: 'high' | 'medium' | 'low';
    /** 分层结果（overview/list/session/deep）- 用于交互式分层视图 */
    layeredResult?: LayeredResult;
    /** 执行事件列表（用于前端进度展示） */
    executionEvents?: SkillEvent[];
    /** 事件摘要 */
    eventSummary?: EventSummary;
}
export interface SkillListItem {
    id: string;
    name: string;
    displayName: string;
    description: string;
    type: string;
    keywords: string[];
    tags?: string[];
}
export interface AdaptedResult {
    format: 'layered';
    layers: LayeredResult['layers'];
    defaultExpanded: DisplayLayer[];
    metadata: LayeredResult['metadata'];
}
export declare class SkillAnalysisAdapter {
    private traceProcessor;
    private executor;
    private initialized;
    private eventHandler?;
    private currentEventCollector?;
    constructor(traceProcessor: TraceProcessorService, eventHandler?: (event: SkillEvent) => void);
    /**
     * 设置 AI 服务（用于 ai_decision 和 ai_summary 步骤）
     */
    setAIService(aiService: any): void;
    /**
     * 设置事件处理器
     */
    setEventHandler(handler: (event: SkillEvent) => void): void;
    /**
     * 确保 skill registry 已初始化
     */
    ensureInitialized(): Promise<void>;
    /**
     * 从自然语言问题检测意图
     * 返回匹配的 skill ID 或 null
     */
    detectIntent(question: string): string | null;
    /**
     * 检测厂商（从 trace 数据）
     */
    detectVendor(traceId: string): Promise<{
        vendor: string;
        confidence: number;
    }>;
    /**
     * 检测 skill 是否使用分层输出（overview/list/session/deep）
     */
    private hasLayeredOutput;
    private collectLayeredSteps;
    private collectLayeredFailures;
    /**
     * 执行 skill 分析
     * 这是主要的入口点
     */
    analyze(request: SkillAnalysisRequest): Promise<SkillAnalysisResponse>;
    /**
     * 将 LayeredResult 转换为 displayResults 格式
     * 用于处理分层输出模式（overview/list/session/deep）
     */
    private convertLayeredResultToDisplayResults;
    /**
     * 将 displayResults 转换为 sections 格式（兼容 v1）
     */
    private convertDisplayResultsToSections;
    /**
     * 从分层 StepResult 提取可展示数据。
     * 对 skill 引用步骤进行解包，避免把嵌套 SkillExecutionResult 直接透传到展示层。
     */
    private extractLayerStepData;
    /**
     * 从 StepResult.display.columns 中提取列定义（含 type/format/unit/clickAction）。
     */
    private extractColumnDefinitions;
    /**
     * 将行数组转换为对象数组
     */
    private rowsToObjects;
    /**
     * 获取所有可用的 skills 列表
     */
    listSkills(): Promise<SkillListItem[]>;
    /**
     * 获取指定 skill 的详细信息
     */
    getSkillDetail(skillId: string): Promise<SkillDefinition | null>;
    /**
     * Adapt skill result to layered format
     * This method converts LayeredResult to AdaptedResult for API responses
     */
    adaptSkillResult(result: LayeredResult): Promise<AdaptedResult>;
}
export declare function getSkillAnalysisAdapter(traceProcessor: TraceProcessorService, eventHandler?: (event: SkillEvent) => void): SkillAnalysisAdapter;
export declare function createSkillAnalysisAdapter(traceProcessor: TraceProcessorService, eventHandler?: (event: SkillEvent) => void): SkillAnalysisAdapter;
//# sourceMappingURL=skillAnalysisAdapter.d.ts.map