import { ArtifactComponentApiInsert, FullExecutionContext } from "@inkeep/agents-core";

//#region src/domains/run/artifacts/ArtifactService.d.ts
interface ArtifactSummaryData {
  artifactId: string;
  toolCallId: string;
  name: string;
  description: string;
  type?: string;
  data: any;
}
interface ArtifactFullData {
  artifactId: string;
  toolCallId: string;
  name: string;
  description: string;
  type?: string;
  data: any;
  metadata?: {
    isOversized?: boolean;
    retrievalBlocked?: boolean;
    originalTokenSize?: number;
    contextWindowSize?: number;
    toolName?: string;
    toolArgs?: unknown;
    toolCallId?: string;
    baseSelector?: string;
    detailsSelector?: Record<string, string>;
    sessionId?: string;
    artifactType?: string;
  };
}
interface ArtifactCreateRequest {
  artifactId: string;
  toolCallId: string;
  type: string;
  baseSelector: string;
  detailsSelector?: Record<string, string>;
}
interface ArtifactServiceContext {
  executionContext: FullExecutionContext;
  sessionId?: string;
  taskId?: string;
  contextId?: string;
  artifactComponents?: ArtifactComponentApiInsert[];
  streamRequestId?: string;
  subAgentId?: string;
}
/**
 * Service class responsible for artifact business logic operations
 * Handles database persistence, tool result extraction, and artifact management
 * Separated from parsing concerns for better architecture
 */
declare class ArtifactService {
  private context;
  private createdArtifacts;
  private static selectorCache;
  constructor(context: ArtifactServiceContext);
  /**
   * Clear static caches to prevent memory leaks between sessions
   */
  static clearCaches(): void;
  /**
   * Update artifact components in the context
   */
  updateArtifactComponents(artifactComponents: ArtifactComponentApiInsert[]): void;
  /**
   * Get raw tool result by toolCallId from the current session.
   * Unwraps MCP-style content arrays; returns the value as-is for non-MCP results.
   */
  getToolResultRaw(toolCallId: string): unknown;
  /**
   * Get all artifacts for a context from database
   */
  getContextArtifacts(contextId: string): Promise<Map<string, any>>;
  /**
   * Create artifact from tool result and request data
   */
  createArtifact(request: ArtifactCreateRequest, subAgentId?: string, contextWindowSize?: number): Promise<ArtifactSummaryData | null>;
  /**
   * Get artifact summary data by ID and tool call ID
   */
  getArtifactSummary(artifactId: string, toolCallId: string, artifactMap?: Map<string, any>): Promise<ArtifactSummaryData | null>;
  /**
   * Get artifact full data by ID and tool call ID
   */
  getArtifactFull(artifactId: string, toolCallId: string, artifactMap?: Map<string, any>): Promise<ArtifactFullData | null>;
  /**
   * Format raw artifact to standardized summary data format
   */
  private formatArtifactSummaryData;
  /**
   * Format raw artifact to standardized full data format
   */
  private formatArtifactFullData;
  /**
   * Validate extracted data against the schemas used for extraction
   */
  private validateExtractedData;
  /**
   * Persist artifact to database vian agent session
   */
  private persistArtifact;
  /**
   * Cache artifact for immediate access
   */
  private cacheArtifact;
  /**
   * Sanitize JMESPath selector to fix common syntax issues (with caching)
   */
  private sanitizeJMESPathSelector;
  /**
   * Save an already-created artifact directly to the database
   * Used by AgentSession to save artifacts after name/description generation
   */
  saveArtifact(artifact: {
    artifactId: string;
    name: string;
    description: string;
    type: string;
    data: Record<string, any>;
    summaryData?: Record<string, any>;
    metadata?: Record<string, any>;
    toolCallId?: string;
  }): Promise<void>;
  /**
   * Clean up over-escaped strings that have been through multiple JSON serialization cycles
   */
  cleanEscapedContent(value: any): any;
  /**
   * Extract properties from data using schema-defined fields and custom selectors
   */
  private extractPropsFromSchema;
  /**
   * Filter extracted props based on schema
   */
  private filterBySchema;
}
//#endregion
export { ArtifactCreateRequest, ArtifactFullData, ArtifactService, ArtifactServiceContext, ArtifactSummaryData };