export type OpenAISearchProvider = "openai-codex" | "openai"; export type PiWebProvider = OpenAISearchProvider | "exa"; export type SearchPipeline = "openai" | "openai-summary" | "exa"; export type WebSearchMode = "disabled" | "cached" | "indexed" | "live"; export type SearchContextSize = "low" | "medium" | "high"; export type SearchResponseLength = "short" | "medium" | "long"; export interface WebSearchLocation { country?: string; region?: string; city?: string; timezone?: string; } export interface PiWebConfigFile { provider?: PiWebProvider; model?: string; summary_provider?: string; summary_model?: string; exa_api_key?: string; mode?: WebSearchMode; search_context_size?: SearchContextSize; allowed_domains?: string[]; user_location?: WebSearchLocation; max_output_tokens?: number; timeout_ms?: number; } export interface ResolvedPiWebConfig { provider: PiWebProvider; pipeline: SearchPipeline; model: string; summaryProvider?: string; summaryModel?: string; exaApiKey?: string; mode: WebSearchMode; searchContextSize?: SearchContextSize; allowedDomains?: string[]; userLocation?: WebSearchLocation; maxOutputTokens: number; timeoutMs: number; source: string; } export interface SearchQuery { q: string; recency?: number; domains?: string[]; } export interface OpenOperation { ref_id: string; lineno?: number; } export interface ClickOperation { ref_id: string; id: number; } export interface FindOperation { ref_id: string; pattern: string; } export interface ScreenshotOperation { ref_id: string; pageno: number; } export interface FinanceOperation { ticker: string; type: "equity" | "fund" | "crypto" | "index"; market?: string; } export interface WeatherOperation { location: string; start?: string; duration?: number; } export interface SportsOperation { tool?: "sports"; fn: "schedule" | "standings"; league: "nba" | "wnba" | "nfl" | "nhl" | "mlb" | "epl" | "ncaamb" | "ncaawb" | "ipl"; team?: string; opponent?: string; date_from?: string; date_to?: string; num_games?: number; locale?: string; } export interface TimeOperation { utc_offset: string; } export interface SearchCommands { search_query?: SearchQuery[]; image_query?: SearchQuery[]; open?: OpenOperation[]; click?: ClickOperation[]; find?: FindOperation[]; screenshot?: ScreenshotOperation[]; finance?: FinanceOperation[]; weather?: WeatherOperation[]; sports?: SportsOperation[]; time?: TimeOperation[]; response_length?: SearchResponseLength; } export type WebSearchAction = | { type: "search"; query?: string; queries?: string[] } | { type: "openPage"; url?: string } | { type: "findInPage"; url?: string; pattern?: string } | { type: "other" }; export interface SearchInputText { type: "input_text"; text: string; } export interface SearchOutputText { type: "output_text"; text: string; } export interface SearchInputMessage { type: "message"; role: "user" | "assistant"; content: (SearchInputText | SearchOutputText)[]; } export interface SearchSettings { user_location?: { type: "approximate"; country?: string; region?: string; city?: string; timezone?: string; }; search_context_size?: SearchContextSize; filters?: { allowed_domains?: string[]; }; allowed_callers: ["direct"]; external_web_access: boolean | "indexed"; } export interface SearchRequest { id: string; model: string; input?: SearchInputMessage[]; commands: SearchCommands; settings: SearchSettings; max_output_tokens: number; } export interface SearchResponse { encrypted_output?: string | null; output: string; } export interface SearchTarget { endpoint: string; model: string; provider: OpenAISearchProvider; headers: Record; }