import { CompressedArtifactInfo } from "../artifacts/artifact-utils.js";
import { ConversationSummary } from "../tools/distill-conversation-tool.js";
import { ModelSettings } from "@inkeep/agents-core";

//#region src/domains/run/compression/BaseCompressor.d.ts
interface CompressionConfig {
  hardLimit: number;
  safetyBuffer: number;
  enabled?: boolean;
}
interface CompressionResult {
  artifactIds: string[];
  summary: ConversationSummary | any[];
}
interface CompressionEventData {
  reason: 'manual' | 'automatic';
  messageCount: number;
  artifactCount: number;
  contextSizeBefore: number;
  contextSizeAfter: number;
  compressionType: 'mid_generation' | 'conversation_level';
}
declare abstract class BaseCompressor {
  protected sessionId: string;
  protected conversationId: string;
  protected tenantId: string;
  protected projectId: string;
  protected agentId: string;
  protected config: CompressionConfig;
  protected summarizerModel?: ModelSettings | undefined;
  protected baseModel?: ModelSettings | undefined;
  protected processedToolCalls: Set<string>;
  protected cumulativeSummary: ConversationSummary | null;
  protected contextWindowSize?: number;
  private toolCallInputMap;
  constructor(sessionId: string, conversationId: string, tenantId: string, projectId: string, agentId: string, config: CompressionConfig, summarizerModel?: ModelSettings | undefined, baseModel?: ModelSettings | undefined);
  getHardLimit(): number;
  protected estimateTokens(content: any): number;
  calculateContextSize(messages: any[]): number;
  saveToolResultsAsArtifacts(messages: any[], startIndex?: number): Promise<Record<string, CompressedArtifactInfo>>;
  private findExistingArtifacts;
  private convertDatabaseFormatMessage;
  private processToolResult;
  private shouldSkipToolCall;
  private extractToolCallIds;
  private isEmpty;
  private buildArtifactData;
  private createNewArtifact;
  protected formatMessagesForDistillation(messages: any[], toolCallToArtifactMap: Record<string, CompressedArtifactInfo> | undefined, maxTotalChars?: number): string;
  protected createConversationSummary(messages: any[], toolCallToArtifactMap: Record<string, CompressedArtifactInfo>, compressionCycle?: number): Promise<any>;
  private refreshSummaryArtifactNames;
  protected generatePreview(value: any, maxChars?: number): string | null;
  protected recordCompressionEvent(eventData: CompressionEventData): void;
  getCompressionSummary(): ConversationSummary | null;
  hasSummarizedArtifact(artifactId: string): boolean;
  getSummarizedArtifact(artifactId: string): {
    key_findings: string[];
    tool_call_id: string;
  } | null;
  protected persistArtifactKeyFindings(relatedArtifacts: NonNullable<ConversationSummary['related_artifacts']>): Promise<{
    persisted: number;
    skipped: number;
    failed: number;
  }>;
  cleanup(options?: {
    resetSummary?: boolean;
    keepRecentToolCalls?: number;
  }): void;
  partialCleanup(): void;
  fullCleanup(): void;
  getState(): {
    config: CompressionConfig;
    processedToolCalls: string[];
    cumulativeSummary: {
      type: "conversation_summary_v1";
      session_id: string | null;
      _fallback: boolean | null;
      high_level: string;
      user_intent: string;
      decisions: string[];
      open_questions: string[];
      next_steps: {
        for_agent: string[];
        for_user: string[];
      };
      related_artifacts: {
        id: string;
        name: string;
        tool_name: string;
        tool_call_id: string;
        content_type: string;
        key_findings: string[];
      }[] | null;
    } | null;
  };
  safeCompress(messages: any[], fullContextSize?: number): Promise<CompressionResult>;
  protected simpleCompressionFallback(messages: any[]): Promise<CompressionResult>;
  abstract isCompressionNeeded(messages: any[]): boolean;
  abstract compress(messages: any[]): Promise<CompressionResult>;
  abstract getCompressionType(): string;
}
declare function getModelAwareCompressionConfig(modelSettings?: ModelSettings, targetPercentage?: number): CompressionConfig;
//#endregion
export { BaseCompressor, CompressionConfig, CompressionEventData, CompressionResult, getModelAwareCompressionConfig };