UNPKG

@plust/datasleuth

Version:

Build LLM-powered research pipelines and output structured data.

51 lines (50 loc) 1.85 kB
/** * Parallel execution of multiple research tracks * Enables concurrent research paths for more efficient deep research */ import { createStep } from '../utils/steps.js'; import { ResearchState, ResearchStep } from '../types/pipeline.js'; import { TrackResult } from './track.js'; import { ProcessingError } from '../types/errors.js'; /** * Custom error for parallel execution issues */ export declare class ParallelError extends ProcessingError { constructor(options: Omit<ConstructorParameters<typeof ProcessingError>[0], 'code'>); } /** * Options for parallel execution */ export interface ParallelOptions { /** An array of steps to execute in parallel */ tracks: ResearchStep[]; /** Whether to continue execution if one track fails */ continueOnError?: boolean; /** Maximum time in ms to wait for all tracks to complete */ timeout?: number; /** Function to merge results from all tracks */ mergeFunction?: (tracks: Record<string, TrackResult>, state: ResearchState) => any; /** Whether to include the merged result in the results array */ includeInResults?: boolean; /** Retry configuration for the parallel step */ retry?: { /** Maximum number of retries */ maxRetries?: number; /** Base delay between retries in ms */ baseDelay?: number; }; } /** * Creates a parallel execution step * * @param options Options for parallel execution * @returns A research step that executes tracks in parallel */ export declare function parallel(options: ParallelOptions): ReturnType<typeof createStep>; /** * Default merge function that combines results from all tracks * * @param tracks The track results to merge * @returns A merged result object */ export declare function defaultMergeFunction(tracks: Record<string, TrackResult>): Record<string, any>;