export type SearchType = "threads_keyword" | "web_search" | "crawler"; export type KeywordPriority = "high" | "medium" | "low"; export type SearchProviderName = "threads" | "brave" | "crawler"; export interface SearchRequest { keyword: string; limit: number; since?: Date; source: SearchProviderName; searchType: SearchType; priority?: KeywordPriority; /** 直接指定 Brave 查詢(略過 keyword query builder) */ query?: string; /** 巡邏模式:檢查 high priority + 每日額度(預設 true) */ patrolMode?: boolean; /** 僅保留 threads.com 結果(預設 true) */ threadsOnly?: boolean; } export interface SearchResult { title: string; url: string; snippet: string; author: string; publishedAt?: Date; source: SearchProviderName; threadId?: string; raw?: Record; } export interface SearchResponse { provider: SearchProviderName; results: SearchResult[]; status: "success" | "unavailable" | "skipped"; skipReason?: string; quotaUsed?: number; quotaLimit?: number; } export interface KeywordInput { value: string; limit: number; priority: KeywordPriority; } export interface SearchProvider { name(): SearchProviderName; enabled(): boolean; search(req: SearchRequest): Promise; }