/** * Auto Portal Discovery (INT-016) * * Given a country code, discovers official government portals automatically. * Uses multiple discovery strategies: * 1. Known portal database (built-in knowledge) * 2. Web search for official sites * 3. DNS pattern probing (common gov TLDs) * 4. Link discovery from found portals * * Integrates with: * - GovernmentSkillPack for known portals * - DomainPresets for pre-configured selectors * - HeuristicsConfig for domain grouping * - DiscoveryCache for result caching * * @example * ```typescript * import { AutoPortalDiscovery } from 'llm-browser/sdk'; * * const discovery = new AutoPortalDiscovery(); * const portals = await discovery.discoverPortals('ES'); * console.log(portals.portals); // All discovered Spanish government portals * ``` */ import { type GovernmentServiceCategory } from './government-skill-pack.js'; /** * ISO 3166-1 alpha-2 country codes supported for discovery */ export type SupportedCountryCode = 'ES' | 'PT' | 'DE' | 'FR' | 'IT' | 'NL' | 'BE' | 'AT' | 'CH' | 'GB' | 'IE' | 'US' | 'CA' | 'AU' | 'NZ' | 'SE' | 'NO' | 'DK' | 'FI' | 'PL' | 'CZ' | 'GR' | 'HR' | 'RO' | 'BG' | 'HU' | 'SK' | 'SI' | 'EE' | 'LV' | 'LT' | 'CY' | 'MT' | 'LU' | 'MX' | 'BR' | 'AR' | 'CL' | 'CO' | 'JP' | 'KR' | 'SG' | 'IN' | 'AE' | 'IL' | 'ZA'; /** * A discovered government portal */ export interface DiscoveredPortal { /** Portal domain */ domain: string; /** Full URL to portal */ url: string; /** Human-readable name */ name: string; /** Description of the portal */ description: string; /** Country code */ countryCode: string; /** Primary language(s) */ languages: string[]; /** Service categories available */ categories: GovernmentServiceCategory[]; /** Confidence score (0-1) */ confidence: number; /** How this portal was discovered */ discoverySource: PortalDiscoverySource; /** Whether portal has been verified as accessible */ verified: boolean; /** Last verification timestamp */ verifiedAt?: number; /** Related portals (links to/from) */ relatedPortals?: string[]; /** Portal sections identified */ sections?: PortalSection[]; } /** * A section within a portal */ export interface PortalSection { /** Section name */ name: string; /** Section URL */ url: string; /** Service category */ category: GovernmentServiceCategory; /** Description */ description?: string; } /** * How a portal was discovered */ export type PortalDiscoverySource = 'known_database' | 'dns_probe' | 'web_search' | 'link_discovery' | 'heuristics_config' | 'user_provided'; /** * Portal discovery result */ export interface PortalDiscoveryResult { /** Country code queried */ countryCode: string; /** Country name */ countryName: string; /** All discovered portals */ portals: DiscoveredPortal[]; /** Portals grouped by category */ byCategory: Record; /** Discovery timestamp */ discoveredAt: number; /** Time taken in ms */ durationMs: number; /** Cache status */ fromCache: boolean; /** Discovery sources used */ sourcesUsed: PortalDiscoverySource[]; /** Any errors encountered */ errors?: string[]; } /** * Discovery options */ export interface PortalDiscoveryOptions { /** Skip cache lookup */ skipCache?: boolean; /** Include unverified portals */ includeUnverified?: boolean; /** Filter by specific categories */ categories?: GovernmentServiceCategory[]; /** Minimum confidence threshold (0-1) */ minConfidence?: number; /** Enable DNS probing (slower but discovers more) */ enableDnsProbing?: boolean; /** Enable web search (requires browser) */ enableWebSearch?: boolean; /** Timeout for discovery (ms) */ timeoutMs?: number; } /** * Country information for portal discovery */ interface CountryInfo { code: SupportedCountryCode; name: string; languages: string[]; govTlds: string[]; searchTerms: string[]; knownMainPortal?: string; } /** * Auto Portal Discovery service * * Discovers government portals for a given country using multiple strategies. */ export declare class AutoPortalDiscovery { private cache; private readonly cacheSource; constructor(); /** * Discover portals for a given country code */ discoverPortals(countryCode: string, options?: PortalDiscoveryOptions): Promise; /** * Get supported country codes */ getSupportedCountries(): Array<{ code: string; name: string; }>; /** * Check if a country is supported */ isCountrySupported(countryCode: string): boolean; /** * Get country info */ getCountryInfo(countryCode: string): CountryInfo | undefined; /** * Clear discovery cache for a country */ clearCache(countryCode?: string): Promise; private discoverFromKnownDatabase; private discoverFromSkillPack; private discoverFromHeuristicsConfig; private discoverViaDnsProbing; private inferPortalName; private inferPortalNameFromDomain; /** * Get languages array from shared patterns language setting */ private getLanguagesFromSharedPatterns; private inferCategoriesFromDomain; private groupByCategory; } /** * Get the portal discovery singleton */ export declare function getPortalDiscovery(): AutoPortalDiscovery; /** * Reset the portal discovery singleton (for testing) */ export declare function resetPortalDiscovery(): void; /** * Discover portals for a country (convenience function) */ export declare function discoverPortals(countryCode: string, options?: PortalDiscoveryOptions): Promise; /** * Get supported countries (convenience function) */ export declare function getSupportedCountries(): Array<{ code: string; name: string; }>; export {}; //# sourceMappingURL=auto-portal-discovery.d.ts.map