import { BaseCompressor, CompressionConfig, CompressionResult } from "./BaseCompressor.js";
import { ModelSettings } from "@inkeep/agents-core";

//#region src/domains/run/compression/MidGenerationCompressor.d.ts

/**
 * Mid-generation compressor
 * Compresses context when generate() steps get too large with manual compression support
 */
declare class MidGenerationCompressor extends BaseCompressor {
  private shouldCompress;
  private generatedMessagesBaseline;
  private compressionCycleCount;
  /**
   * Called after compression succeeds to record where the next cycle's generated messages start.
   * Because the AI SDK accumulates all messages in stepMessages regardless of what prepareStep
   * returns, we track the step count at compression time and slice from there next cycle.
   */
  markCompressed(stepCount: number): void;
  effectiveBaseline(originalMessageCount: number): number;
  constructor(sessionId: string, conversationId: string, tenantId: string, projectId: string, agentId: string, config?: CompressionConfig, summarizerModel?: ModelSettings, baseModel?: ModelSettings);
  /**
   * Get compression type for this compressor
   */
  getCompressionType(): 'mid_generation';
  /**
   * Manual compression request from LLM tool
   */
  requestManualCompression(reason?: string): void;
  /**
   * Check if compression is needed using actual AI SDK token counts from previous steps.
   * This is the preferred method — uses real data instead of character-based estimation.
   */
  isCompressionNeededFromActualUsage(actualContextTokens: number): boolean;
  /**
   * @deprecated Use isCompressionNeededFromActualUsage() with actual AI SDK step usage instead.
   * Kept for ConversationCompressor which doesn't have step data.
   */
  isCompressionNeeded(messages: any[]): boolean;
  /**
   * Perform mid-generation compression.
   * Each call receives the current generatedMessages slice — the AI SDK continues accumulating
   * all messages in stepMessages regardless of what prepareStep returns, so
   * handlePrepareStepCompression slices from generatedMessagesBaseline to get only new messages
   * for each cycle. processedToolCalls guards against artifact re-creation; cumulativeSummary
   * carries forward the prior summary context.
   */
  compress(messages: any[]): Promise<CompressionResult>;
  getCompressionCycleCount(): number;
  /**
   * Get current state for debugging
   */
  getState(): {
    shouldCompress: boolean;
    compressionCycleCount: number;
    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;
  };
}
//#endregion
export { MidGenerationCompressor };