import { EventEmitter } from 'events';
import type { TraceProcessorService } from '../services/traceProcessorService';
import type { AnalysisResult, AnalysisOptions, IOrchestrator } from '../agent/core/orchestratorTypes';
import type { ArchitectureInfo } from '../agent/detectors/types';
import { type ClaudeAgentConfig } from './claudeConfig';
import { type SceneType } from './sceneClassifier';
import type { AnalysisNote, AnalysisPlanV3, UncertaintyFlag } from './types';
import type { SessionStateSnapshot, SessionFieldsForSnapshot } from './sessionStateSnapshot';
declare function correctionResultLooksUsable(text: string): boolean;
declare function sanitizeClaudeConclusionText(text: string): string;
declare function ensureClaudeFinalReportHeading(text: string, sceneType: SceneType | undefined, outputLanguage: string): string;
declare function shouldMarkCorrectionTimeoutPartial(input: {
    correctedResult: string;
    existingConclusion: string;
}): boolean;
declare function chooseClaudeConclusionText(input: {
    finalResult: string;
    accumulatedAnswer: string;
}): string;
import { buildQuickConversationContext } from '../agentRuntime/runtimeCommon';
interface SessionMapEntry {
    sdkSessionId: string;
    updatedAt: number;
    mode?: 'full';
}
declare function getSdkResultErrorMessage(msg: any): string | undefined;
declare function isMissingSdkConversationError(message: string): boolean;
declare function isFreshFullSdkSessionEntry(entry: SessionMapEntry | undefined, now?: number): entry is SessionMapEntry & {
    mode: 'full';
};
export declare const __testing: {
    getSdkResultErrorMessage: typeof getSdkResultErrorMessage;
    isMissingSdkConversationError: typeof isMissingSdkConversationError;
    isFreshFullSdkSessionEntry: typeof isFreshFullSdkSessionEntry;
    buildQuickConversationContext: typeof buildQuickConversationContext;
    correctionResultLooksUsable: typeof correctionResultLooksUsable;
    chooseClaudeConclusionText: typeof chooseClaudeConclusionText;
    ensureClaudeFinalReportHeading: typeof ensureClaudeFinalReportHeading;
    sanitizeClaudeConclusionText: typeof sanitizeClaudeConclusionText;
    shouldMarkCorrectionTimeoutPartial: typeof shouldMarkCorrectionTimeoutPartial;
};
/**
 * Claude Agent SDK runtime for SmartPerfetto.
 * Claude SDK orchestrator implementation behind the shared IOrchestrator contract.
 * Implements the same EventEmitter + analyze() interface as AgentRuntime.
 */
export declare class ClaudeRuntime extends EventEmitter implements IOrchestrator {
    private traceProcessorService;
    private config;
    private sessionMap;
    /** Cache architecture detection results per traceId (deterministic per trace). */
    private architectureCache;
    /** Cache vendor detection results per traceId (deterministic per trace). */
    private vendorCache;
    /** Cache trace completeness probe results per traceId (deterministic per trace). */
    private completenessCache;
    /** Per-session artifact stores — persist across turns within a session. */
    private artifactStores;
    /** Per-session analysis notes — persist across turns within a session. */
    private sessionNotes;
    /** Per-session SQL error tracking for error-fix pair learning. */
    private sessionSqlErrors;
    /** Per-session analysis plans for plan adherence tracking. */
    private sessionPlans;
    /** Per-session hypotheses for hypothesis-verify cycle (P0-G4). */
    private sessionHypotheses;
    /** Per-session uncertainty flags for non-blocking human interaction (P1-G1). */
    private sessionUncertaintyFlags;
    /** Guard against concurrent analyze() calls for the same session. */
    private activeAnalyses;
    constructor(traceProcessorService: TraceProcessorService, config?: Partial<ClaudeAgentConfig>);
    /** Restore a previously persisted SDK session mapping (e.g., after server restart). */
    restoreSessionMapping(smartPerfettoSessionId: string, sdkSessionId: string): void;
    /** Restore a cached architecture detection result (e.g., from session persistence). */
    restoreArchitectureCache(traceId: string, architecture: ArchitectureInfo): void;
    /** Get cached architecture for a traceId (used for persistence). */
    getCachedArchitecture(traceId: string): ArchitectureInfo | undefined;
    /** Get SDK session ID for persistence. */
    getSdkSessionId(smartPerfettoSessionId: string, referenceTraceId?: string): string | undefined;
    private buildSessionMapKey;
    private persistSessionMapEntry;
    private rememberFullSdkSessionMapping;
    private forgetSdkSessionMapping;
    private retryWithoutSdkResume;
    private removeSessionMapEntries;
    analyze(query: string, sessionId: string, traceId: string, options?: AnalysisOptions): Promise<AnalysisResult>;
    /**
     * Quick analysis path for simple factual queries.
     * Minimal context prep, 3 MCP tools, no planning/verification/report.
     * Target: 3-8s latency, 2k-5k tokens.
     */
    private analyzeQuick;
    removeSession(sessionId: string): void;
    /** Clean up all session-scoped state for a given session. */
    cleanupSession(sessionId: string): void;
    /** P1-R3: Public getter for session notes — used by report generation. */
    getSessionNotes(sessionId: string): AnalysisNote[];
    /** P1-R3: Public getter for current analysis plan — used by report generation. */
    getSessionPlan(sessionId: string): AnalysisPlanV3 | null;
    /** P1-R3: Public getter for uncertainty flags — used by report generation. */
    getSessionUncertaintyFlags(sessionId: string): UncertaintyFlag[];
    /** P1-1: Public getter for plan history — used for persistence. */
    getSessionPlanHistory(sessionId: string): AnalysisPlanV3[];
    /**
     * Take a snapshot of all session state for atomic persistence.
     *
     * Reads from ClaudeRuntime's 7 internal Maps (notes, plans, hypotheses,
     * flags, artifacts, architectureCache, sessionMap) and merges with
     * session-level arrays provided by the route layer.
     *
     * @param sessionId - The SmartPerfetto session ID
     * @param traceId - The trace ID
     * @param sessionFields - Session-level arrays from AnalysisSession (route layer)
     */
    takeSnapshot(sessionId: string, traceId: string, sessionFields: SessionFieldsForSnapshot): SessionStateSnapshot;
    /**
     * Restore all ClaudeRuntime Maps from a persisted snapshot.
     *
     * Called during session resume to repopulate the 7 internal Maps
     * that are normally built up during analysis.
     *
     * @param sessionId - The SmartPerfetto session ID
     * @param traceId - The trace ID (for architectureCache key)
     * @param snapshot - The persisted snapshot to restore from
     */
    restoreFromSnapshot(sessionId: string, traceId: string, snapshot: SessionStateSnapshot): void;
    /** P0-1: Convert agentv3 Hypothesis to agentProtocol Hypothesis format for AnalysisResult. */
    private toProtocolHypothesis;
    reset(): void;
    private emitUpdate;
    /**
     * Collect the most recent findings from previous turns for system prompt injection.
     * Caps at 5 findings to prevent unbounded prompt growth.
     */
    private collectPreviousFindings;
    /**
     * Build a compact entity context string for the system prompt.
     * Gives Claude awareness of known frames/sessions for drill-down resolution.
     */
    private buildEntityContext;
    /**
     * Prepare all context needed for a Claude analysis run.
     * Extracts focus app detection, architecture detection, session context,
     * scene classification, MCP server creation, and system prompt building
     * into a single cohesive preparation phase.
     */
    private prepareAnalysisContext;
    private estimateConfidence;
    /** Capture entities from skill displayResults into EntityStore for multi-turn drill-down. */
    private captureEntitiesFromSkillDisplayResults;
}
export {};
//# sourceMappingURL=claudeRuntime.d.ts.map