/** * Cross-Domain Dispatcher * * Routes natural-language input to the correct domain by trying all registered * domains and picking the highest-confidence match. Supports auto-detection, * composite multi-line parsing, and confidence-based routing. * * @example * ```typescript * import { DomainRegistry, CrossDomainDispatcher } from '@lokascript/framework'; * * const registry = new DomainRegistry(); * registry.register(sqlDescriptor); * registry.register(bddDescriptor); * * const dispatcher = new CrossDomainDispatcher(registry); * * // Auto-detect which domain handles the input * const result = await dispatcher.detect('select name from users', 'en'); * // → { domain: 'sql', node: ..., confidence: 0.95, dsl: ... } * * // Parse multi-line input across domains * const composite = await dispatcher.parseComposite(` * select name from users * given page http://localhost * `, 'en'); * ``` */ import type { SemanticNode } from '../core/types'; import type { MultilingualDSL, CompileResult, ValidationResult } from './create-dsl'; import { DomainRegistry } from './domain-registry'; /** Result of domain auto-detection */ export interface DispatchResult { /** The domain that matched */ readonly domain: string; /** Parsed semantic node */ readonly node: SemanticNode; /** Confidence score (0-1) */ readonly confidence: number; /** The DSL instance that parsed it */ readonly dsl: MultilingualDSL; } /** A single statement in a composite parse result */ export interface CompositeStatement { readonly line: number; readonly input: string; readonly domain: string; readonly node: SemanticNode; readonly confidence: number; } /** An error from a composite parse */ export interface CompositeError { readonly line: number; readonly input: string; readonly message: string; } /** Result of multi-domain composite parsing */ export interface CompositeParseResult { /** Successfully parsed statements */ readonly statements: readonly CompositeStatement[]; /** Lines that could not be matched to any domain */ readonly errors: readonly CompositeError[]; } /** A single compiled statement in a composite compile result */ export interface CompositeCompileStatement { readonly line: number; readonly input: string; readonly domain: string; readonly ok: boolean; readonly code?: string | undefined; readonly errors?: string[] | undefined; } /** Result of multi-domain composite compilation */ export interface CompositeCompileResult { /** Successfully detected and compiled statements */ readonly statements: readonly CompositeCompileStatement[]; /** Lines that could not be matched to any domain */ readonly errors: readonly CompositeError[]; } /** Dispatcher configuration options */ export interface DispatcherOptions { /** Minimum confidence to accept a match (default: 0.5) */ readonly minConfidence?: number; /** Domain priority order — earlier domains win on confidence ties */ readonly priority?: readonly string[]; } /** * Dispatcher that routes input to the correct domain by confidence scoring. * * Built on top of DomainRegistry — uses registered domains' DSL instances * to try parsing input and picks the highest-confidence match. */ export declare class CrossDomainDispatcher { private registry; private minConfidence; private priority; constructor(registry: DomainRegistry, options?: DispatcherOptions); /** * Auto-detect which domain handles the input. * Tries all registered domains and returns the highest-confidence match. * Returns null if no domain matches above minConfidence. */ detect(input: string, language?: string): Promise; /** * Parse multi-line input where each line may belong to a different domain. * Empty lines and comment lines (starting with //, --, or #) are skipped. */ parseComposite(input: string, language?: string): Promise; /** * Compile input using auto-detected domain. * Returns the compilation result with the domain name. */ compile(input: string, language?: string): Promise<(CompileResult & { domain: string; }) | null>; /** * Compile multi-line input where each line may belong to a different domain. * Detects the domain for each line and compiles it, returning per-line results. * Empty lines and comment lines are skipped. */ compileComposite(input: string, language?: string): Promise; /** * Validate input against all domains, returning the best match. */ validate(input: string, language?: string): Promise; private getPriorityIndex; } //# sourceMappingURL=dispatcher.d.ts.map