/** * Agent-Based Processing Interfaces * Provides multi-step agentic workflows for complex document parsing */ import { ZodType } from 'zod'; import { VisionParserResult, TokenUsage } from '../interfaces'; /** * Agent processing strategy */ export declare enum AgentStrategy { /** Process document in multiple passes, refining each time */ ITERATIVE = "iterative", /** Process different parts of document simultaneously */ PARALLEL = "parallel", /** Process from high-level to detailed extraction */ HIERARCHICAL = "hierarchical", /** Choose strategy based on document complexity */ ADAPTIVE = "adaptive" } /** * Available agent tasks */ export declare enum AgentTask { /** Extract tables from document */ EXTRACT_TABLES = "extract_tables", /** Identify named entities (people, organizations, dates, etc.) */ IDENTIFY_ENTITIES = "identify_entities", /** Summarize document sections */ SUMMARIZE_SECTIONS = "summarize_sections", /** Extract metadata (author, date, title, etc.) */ EXTRACT_METADATA = "extract_metadata", /** Extract form fields and values */ EXTRACT_FORMS = "extract_forms", /** Identify key-value pairs */ EXTRACT_KEY_VALUES = "extract_key_values", /** Custom extraction task */ CUSTOM = "custom" } /** * Agent tool definition */ export interface AgentTool { /** Tool name/identifier */ name: string; /** Tool description for the agent */ description: string; /** Input schema for the tool */ inputSchema?: ZodType; /** Output schema for the tool */ outputSchema?: ZodType; /** Tool execution function */ execute: (input: any, context: AgentContext) => Promise; } /** * Agent context - maintains state across parsing steps */ export interface AgentContext { /** Original vision parser result */ rawResult: VisionParserResult; /** Intermediate results from previous steps */ intermediateResults: Map; /** Document metadata extracted so far */ metadata: Record; /** Memory of previous extractions for consistency */ memory: Map; /** Current processing step */ currentStep: number; /** Total steps planned */ totalSteps: number; } /** * Agent task configuration */ export interface AgentTaskConfig { /** Task type */ task: AgentTask | string; /** Custom tool for task execution */ tool?: AgentTool; /** Input for the task */ input?: any; /** Output schema for validation */ schema?: ZodType; /** Custom prompt for the task */ prompt?: string; /** Priority (higher = executed first in parallel mode) */ priority?: number; } /** * Agent parser configuration */ export interface AgentParserConfig { /** Processing strategy */ strategy?: AgentStrategy; /** Vision model provider */ provider?: string; /** Cache configuration */ cache?: any; /** List of tasks to execute */ tasks?: AgentTaskConfig[]; /** Custom tools for the agent */ customTools?: AgentTool[]; /** Maximum number of iterations for iterative strategy */ maxIterations?: number; /** Maximum parallel tasks for parallel strategy */ maxParallelTasks?: number; /** Enable memory and context management */ enableMemory?: boolean; /** Output schema for final validation */ outputSchema?: ZodType; } /** * Agent execution step */ export interface AgentStep { /** Step name/identifier */ name: string; /** Step type (task or tool) */ type: 'task' | 'tool'; /** Step configuration */ config: AgentTaskConfig; /** Step status */ status: 'pending' | 'running' | 'completed' | 'failed'; /** Step result */ result?: any; /** Step error if failed */ error?: Error; /** Execution start time */ startTime?: number; /** Execution end time */ endTime?: number; } /** * Agent execution result */ export interface AgentResult { /** Final extracted data */ data: T; /** Raw vision parser result */ raw: VisionParserResult; /** Agent context after execution */ context: AgentContext; /** All execution steps */ steps: AgentStep[]; /** Strategy used */ strategy: AgentStrategy; /** Token usage statistics */ usage?: TokenUsage; /** Whether validation passed (if schema provided) */ isValid?: boolean; /** Total execution time in ms */ executionTime: number; /** Metadata about the execution */ metadata: { totalSteps: number; completedSteps: number; failedSteps: number; iterationCount?: number; }; } /** * Task decomposition result */ export interface TaskDecomposition { /** Main task to decompose */ mainTask: string; /** Sub-tasks */ subTasks: Array<{ name: string; description: string; dependencies: string[]; priority: number; }>; /** Execution order (for sequential execution) */ executionOrder: string[]; } /** * Cross-reference resolution context */ export interface CrossReferenceContext { /** References found in the document */ references: Array<{ id: string; type: string; location: { page: number; section?: string; }; target?: string; }>; /** Resolved references */ resolved: Map; } //# sourceMappingURL=agent-interfaces.d.ts.map