import { type AgentRuntimeAnalysisResult, type Hypothesis, type IOrchestrator, type StreamingUpdate } from '../../agent';
import type { ProviderScope } from '../../services/providerManager';
import type { ComparisonReportSection, ComparisonSourceKind } from '../../agentv3/sessionStateSnapshot';
import { type EnhancedSessionContext } from '../../agent/context/enhancedSessionContext';
import type { ClaimSupportV1 } from '../../types/evidenceContract';
import type { ClaimVerificationResult } from '../../types/claimVerification';
import type { IdentityResolutionV1 } from '../../types/identityContract';
import { type SessionLogger } from '../../services/sessionLogger';
import { SessionPersistenceService } from '../../services/sessionPersistenceService';
import { AssistantApplicationService, type ManagedAssistantSession } from './assistantApplicationService';
export interface AnalyzeSessionConversationStep {
    eventId: string;
    ordinal: number;
    phase: 'progress' | 'thinking' | 'tool' | 'result' | 'error';
    role: 'agent' | 'system';
    text: string;
    timestamp: number;
    sourceEventType?: string;
}
export interface AnalyzeSessionAgentDialogueItem {
    agentId: string;
    type: 'task' | 'response' | 'question';
    content: any;
    timestamp: number;
}
export interface AnalyzeSessionAgentResponseItem {
    taskId: string;
    agentId: string;
    response: any;
    timestamp: number;
}
export interface AnalyzeSessionRunContext {
    runId: string;
    requestId: string;
    sequence: number;
    query: string;
    startedAt: number;
    completedAt?: number;
    status: 'pending' | 'running' | 'completed' | 'failed' | 'quota_exceeded';
    error?: string;
}
export interface AnalyzeManagedSession extends ManagedAssistantSession {
    orchestrator: IOrchestrator;
    orchestratorUpdateHandler?: (update: StreamingUpdate) => void;
    traceId: string;
    query: string;
    tenantId?: string;
    workspaceId?: string;
    userId?: string;
    /** Provider Manager profile used for this SDK session. null means env/default fallback is pinned. */
    providerId?: string | null;
    /** Non-secret ProviderSnapshot hash used to decide whether SDK session state can be reused. */
    providerSnapshotHash?: string | null;
    providerSnapshotChanged?: boolean;
    providerSnapshotChangeReason?: string;
    /** Reference trace ID for raw dual-trace comparison sessions. */
    referenceTraceId?: string;
    /** Comparison source model used by this session. */
    comparisonSource?: ComparisonSourceKind;
    /** Shared deterministic comparison section for report generation. */
    comparisonReportSection?: ComparisonReportSection;
    logger: SessionLogger;
    result?: AgentRuntimeAnalysisResult;
    hypotheses: Hypothesis[];
    agentDialogue: AnalyzeSessionAgentDialogueItem[];
    dataEnvelopes: any[];
    claimSupport?: ClaimSupportV1[];
    claimVerificationResult?: ClaimVerificationResult;
    identityResolutions?: IdentityResolutionV1[];
    agentResponses: AnalyzeSessionAgentResponseItem[];
    conversationOrdinal: number;
    conversationSteps: AnalyzeSessionConversationStep[];
    runSequence?: number;
    activeRun?: AnalyzeSessionRunContext;
    lastRun?: AnalyzeSessionRunContext;
    /** Cross-turn query history — appended on each turn, never overwritten */
    queryHistory?: Array<{
        turn: number;
        query: string;
        timestamp: number;
    }>;
    /** Cross-turn conclusion history — appended after each turn completes */
    conclusionHistory?: Array<{
        turn: number;
        conclusion: string;
        confidence: number;
        timestamp: number;
    }>;
}
interface SessionContextManagerLike {
    set(sessionId: string, traceId: string, context: EnhancedSessionContext): void;
}
interface AgentAnalyzeSessionServiceDeps<TSession extends AnalyzeManagedSession> {
    assistantAppService: AssistantApplicationService<TSession>;
    createSessionLogger: (sessionId: string) => SessionLogger;
    sessionPersistenceService: SessionPersistenceService;
    /** Defaults to the module-level `sessionContextManager` singleton. Callers
     *  (HTTP route, CLI) no longer need to import it just to satisfy the deps. */
    sessionContextManager?: SessionContextManagerLike;
    buildRecoveredResultFromContext: (sessionId: string, context: EnhancedSessionContext) => AgentRuntimeAnalysisResult | null;
}
interface PrepareAnalyzeSessionInput {
    traceId: string;
    query: string;
    requestedSessionId?: string;
    referenceTraceId?: string;
    providerId?: string | null;
    providerScope?: ProviderScope;
    options?: any;
}
export interface PrepareAnalyzeSessionResult<TSession extends AnalyzeManagedSession> {
    sessionId: string;
    session: TSession;
    isNewSession: boolean;
}
export declare class AnalyzeSessionPreparationError extends Error {
    readonly code: string;
    readonly httpStatus: number;
    readonly hint?: string;
    constructor(message: string, options: {
        code: string;
        httpStatus: number;
        hint?: string;
    });
}
export declare class AgentAnalyzeSessionService<TSession extends AnalyzeManagedSession> {
    private readonly assistantAppService;
    private readonly createSessionLogger;
    private readonly sessionPersistenceService;
    private readonly sessionContextManager;
    private readonly buildRecoveredResultFromContext;
    constructor(deps: AgentAnalyzeSessionServiceDeps<TSession>);
    prepareSession(input: PrepareAnalyzeSessionInput): PrepareAnalyzeSessionResult<TSession>;
}
export {};
//# sourceMappingURL=agentAnalyzeSessionService.d.ts.map