/** * APIClaw Chain Resolver * * Handles reference resolution between chain steps. * Supports: $prev, $stepId, $parallel, $chain, $inputs, $forEach */ export interface ChainContext { results: Record; inputs?: Record; currentIndex: number; startedAt: string; prevStepId?: string; parallelResults?: any[]; forEachItem?: any; forEachIndex?: number; forEachResults?: any[]; env?: Record; } export interface Reference { raw: string; type: 'prev' | 'step' | 'parallel' | 'chain' | 'inputs' | 'forEach' | 'item' | 'index' | 'env'; stepId?: string; path: string[]; arrayIndex?: number; } export interface ValidationResult { valid: boolean; errors: ValidationError[]; warnings: ValidationWarning[]; } export interface ValidationError { stepId: string; reference: string; message: string; } export interface ValidationWarning { stepId: string; reference: string; message: string; } export interface ChainStep { id: string; provider: string; action: string; params?: Record; onError?: ErrorConfig; } export interface ParallelStep { parallel: ChainStep[]; } export interface ConditionalStep { if: string; then: ChainStep | ChainStep[]; else?: ChainStep | ChainStep[]; } export interface ForEachStep { forEach: string; as?: string; do: ChainStep; } export type ChainStepUnion = ChainStep | ParallelStep | ConditionalStep | ForEachStep; export interface ErrorConfig { retry?: { attempts: number; backoff?: number[]; }; fallback?: ChainStep; abort?: boolean; } /** * Extract all $references from a string */ export declare function extractReferences(text: string): Reference[]; /** * Parse a single reference string into a Reference object */ export declare function parseReference(raw: string): Reference | null; /** * Resolve a reference to its actual value from context */ export declare function resolveReference(ref: Reference, context: ChainContext): any; /** * Resolve all $references in a params object * Recursively processes strings, arrays, and nested objects */ export declare function resolveReferences(params: Record, context: ChainContext): Record; /** * Validate all references in a chain before execution * Checks that referenced steps exist and come before the referencing step */ export declare function validateReferences(steps: ChainStepUnion[]): ValidationResult; /** * Evaluate a conditional expression string * Supports: ===, !==, >, <, >=, <=, &&, ||, ! */ export declare function evaluateCondition(condition: string, context: ChainContext): boolean; export declare class ReferenceError extends Error { constructor(message: string); } //# sourceMappingURL=chainResolver.d.ts.map