/** * Research Workflow Templates (INT-006) * * Pre-built workflow templates for common research use cases. * These templates provide structured, repeatable research patterns * that can be customized with variables and executed against different targets. * * Use cases: * - Visa research across multiple countries * - Document extraction from government portals * - Fee tracking for immigration/tax procedures * - Cross-country comparison workflows * * @example * ```typescript * import { createResearchBrowser, WORKFLOW_TEMPLATES, executeTemplate } from 'llm-browser/sdk'; * * const browser = await createResearchBrowser(); * * // Execute a visa research workflow for Spain * const results = await executeTemplate(browser, WORKFLOW_TEMPLATES.visaResearch, { * country: 'ES', * visaType: 'digital_nomad', * }); * * console.log(results.summary); * ``` */ import type { VerificationCheck } from '../types/verification.js'; import type { ResearchTopic, ResearchBrowseOptions, ResearchResult } from '../sdk.js'; /** * Step in a workflow template */ export interface WorkflowTemplateStep { /** Step identifier */ id: string; /** Human-readable step name */ name: string; /** Description of what this step does */ description: string; /** URL template with {{variable}} placeholders */ urlTemplate: string; /** Research topic for this step */ topic: ResearchTopic; /** Optional: Fields expected in the result */ expectedFields?: string[]; /** Optional: Additional verification checks */ additionalChecks?: VerificationCheck[]; /** Optional: Whether this step is critical (failure stops workflow) */ critical?: boolean; /** Optional: Delay in ms before executing this step */ delayMs?: number; /** Optional: Custom options for this step */ options?: Partial; } /** * Workflow template definition */ export interface WorkflowTemplate { /** Template identifier */ id: string; /** Human-readable name */ name: string; /** Detailed description */ description: string; /** Categories/tags for filtering */ tags: string[]; /** Required variables (must be provided when executing) */ requiredVariables: string[]; /** Optional variables with default values */ optionalVariables?: Record; /** Steps in execution order */ steps: WorkflowTemplateStep[]; /** Default research topic for all steps (can be overridden per-step) */ defaultTopic?: ResearchTopic; /** Whether to continue on step failure */ continueOnFailure?: boolean; /** Maximum concurrent steps (default: 1 for sequential) */ maxConcurrency?: number; /** Notes about usage */ notes?: string; } /** * Result of executing a workflow template step */ export interface WorkflowTemplateStepResult { /** Step ID from template */ stepId: string; /** Step name */ stepName: string; /** URL that was browsed */ url: string; /** Whether the step succeeded */ success: boolean; /** Error message if failed */ error?: string; /** Research result if successful */ result?: ResearchResult; /** Duration in ms */ duration: number; } /** * Result of executing a complete workflow template */ export interface WorkflowTemplateResult { /** Template ID */ templateId: string; /** Template name */ templateName: string; /** Variables used */ variables: Record; /** Results for each step */ steps: WorkflowTemplateStepResult[]; /** Overall success (all critical steps passed) */ success: boolean; /** Total duration in ms */ totalDuration: number; /** Timestamp when workflow started */ startedAt: number; /** Timestamp when workflow completed */ completedAt: number; /** Summary of extracted information */ summary: WorkflowTemplateSummary; } /** * Summary extracted from workflow results */ export interface WorkflowTemplateSummary { /** Number of successful steps */ successfulSteps: number; /** Number of failed steps */ failedSteps: number; /** Key findings extracted from results */ findings: WorkflowFinding[]; /** Verification summary across all steps */ verificationSummary: { totalChecks: number; passedChecks: number; averageConfidence: number; }; } /** * A finding extracted from workflow results */ export interface WorkflowFinding { /** Category of finding */ category: 'requirement' | 'fee' | 'timeline' | 'document' | 'contact' | 'warning' | 'general'; /** Source step ID */ sourceStepId: string; /** The finding text */ text: string; /** Confidence level (0-1) */ confidence: number; } /** * Government portal URLs by country code */ export declare const COUNTRY_PORTALS: Record; /** * Visa type URL paths by country and visa type */ export declare const VISA_TYPE_PATHS: Record>; /** * Visa Research Workflow Template * * Comprehensive research workflow for visa requirements, including: * - Requirements and eligibility * - Required documents * - Fees and costs * - Processing timeline * - Application process */ export declare const VISA_RESEARCH_TEMPLATE: WorkflowTemplate; /** * Document Extraction Workflow Template * * Extract legal documents from official gazette and registry sites: * - Search for relevant legislation * - Extract document content * - Get effective dates and amendments */ export declare const DOCUMENT_EXTRACTION_TEMPLATE: WorkflowTemplate; /** * Fee Tracking Workflow Template * * Track and compare fees for procedures across sources: * - Immigration fees * - Tax obligations * - Administrative costs * - Social security contributions */ export declare const FEE_TRACKING_TEMPLATE: WorkflowTemplate; /** * Cross-Country Comparison Template * * Compare information across multiple countries: * - Visa requirements * - Cost of living factors * - Tax implications */ export declare const CROSS_COUNTRY_COMPARISON_TEMPLATE: WorkflowTemplate; /** * Tax Obligations Template * * Research tax obligations for expats/immigrants: * - Tax residency rules * - Filing requirements * - Double taxation treaties * - Special regimes */ export declare const TAX_OBLIGATIONS_TEMPLATE: WorkflowTemplate; /** * All workflow templates */ export declare const WORKFLOW_TEMPLATES: { readonly visaResearch: WorkflowTemplate; readonly documentExtraction: WorkflowTemplate; readonly feeTracking: WorkflowTemplate; readonly crossCountryComparison: WorkflowTemplate; readonly taxObligations: WorkflowTemplate; }; /** * Resolve URL template with variables */ export declare function resolveUrlTemplate(template: string, variables: Record): string; /** * Prepare variables for a workflow template * * Expands country codes to actual URLs and paths based on the template requirements. */ export declare function prepareVariables(template: WorkflowTemplate, userVariables: Record): Record; /** * Validate that all required variables are provided */ export declare function validateVariables(template: WorkflowTemplate, variables: Record): { valid: boolean; missing: string[]; }; /** * Extract findings from a research result */ export declare function extractFindings(result: ResearchResult, stepId: string): WorkflowFinding[]; /** * Build workflow summary from step results */ export declare function buildWorkflowSummary(stepResults: WorkflowTemplateStepResult[]): WorkflowTemplateSummary; /** * Get list of available workflow templates */ export declare function listTemplates(): Array<{ id: string; name: string; description: string; tags: string[]; requiredVariables: string[]; }>; /** * Get a template by ID */ export declare function getTemplate(id: string): WorkflowTemplate | undefined; //# sourceMappingURL=workflow-templates.d.ts.map