import { ArtifactFullData, ArtifactService, ArtifactSummaryData } from "./ArtifactService.js";
import { ArtifactComponentApiInsert, FullExecutionContext } from "@inkeep/agents-core";

//#region src/domains/run/services/ArtifactParser.d.ts
interface StreamPart {
  kind: 'text' | 'data';
  text?: string;
  data?: any;
}
type ArtifactData = {
  artifactId: string;
  toolCallId: string;
  name: string;
  description: string;
  type: string;
  summary: Record<string, any>;
};
interface ArtifactCreateAnnotation {
  artifactId: string;
  toolCallId: string;
  type: string;
  baseSelector: string;
  detailsSelector?: Record<string, string>;
  raw?: string;
}
/**
 * Artifact parser focused on parsing and text processing responsibilities
 * Delegates business logic operations to ArtifactService
 * Handles artifact tag detection, parsing, and text boundary detection
 */
declare class ArtifactParser {
  private static readonly ARTIFACT_CHECK_REGEX;
  private static readonly ATTR_REGEX;
  private static readonly ARTIFACT_PATTERNS;
  private static readonly INCOMPLETE_CREATE_REGEX;
  private artifactService;
  constructor(executionContext: FullExecutionContext, options?: {
    sessionId?: string;
    taskId?: string;
    projectId?: string;
    contextId?: string;
    artifactComponents?: ArtifactComponentApiInsert[];
    streamRequestId?: string;
    subAgentId?: string;
    artifactService?: ArtifactService;
  });
  /**
   * Check if text contains complete artifact markers (ref or create)
   */
  hasArtifactMarkers(text: string): boolean;
  /**
   * Check if text has incomplete artifact marker (for streaming)
   * More robust detection that handles streaming fragments
   */
  hasIncompleteArtifact(text: string): boolean;
  /**
   * Find safe text boundary before incomplete artifacts (for streaming)
   * Enhanced to handle streaming chunks that split in the middle of artifacts
   */
  findSafeTextBoundary(text: string): number;
  /**
   * Get all artifacts for a context - delegates to service
   */
  getContextArtifacts(contextId: string): Promise<Map<string, any>>;
  /**
   * Parse attributes from the artifact:create tag
   */
  private parseCreateAttributes;
  /**
   * Parse artifact creation annotations from text
   */
  private parseCreateAnnotations;
  /**
   * Extract artifact data from a create annotation - delegates to service
   */
  private extractFromCreateAnnotation;
  /**
   * Parse text with artifact markers into parts array
   * Handles both artifact:ref and artifact:create tags
   * Can work with or without pre-fetched artifact map
   */
  parseText(text: string, artifactMap?: Map<string, any>, subAgentId?: string): Promise<StreamPart[]>;
  /**
   * Process object/dataComponents for artifact components
   */
  parseObject(obj: any, artifactMap?: Map<string, any>, subAgentId?: string): Promise<StreamPart[]>;
  /**
   * Check if object is an artifact component
   */
  private isArtifactComponent;
  /**
   * Check if object is an artifact create component
   */
  private isArtifactCreateComponent;
  /**
   * Extract artifact from ArtifactCreate component
   */
  private extractFromArtifactCreateComponent;
  /**
   * Get artifact data - delegates to service
   */
  private getArtifactData;
}
//#endregion
export { ArtifactCreateAnnotation, ArtifactData, type ArtifactFullData, ArtifactParser, type ArtifactSummaryData, StreamPart };