import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { ExtractedContent } from "./extract.ts"; import type { SearchResult } from "./perplexity.ts"; declare const FETCH_CACHE_VERSION = 1; interface FetchCacheLimits { maxEntries: number; maxBytes: number; } export interface QueryResultData { query: string; answer: string; results: SearchResult[]; error: string | null; provider?: string | undefined; providers?: string[] | undefined; } interface FetchCacheRef { version: typeof FETCH_CACHE_VERSION; key: string; storedAt: number; } interface StoredFetchUrlMetadata { url: string; title: string; error: string | null; contentLength: number; mimeType?: string | undefined; status?: number | undefined; duration?: number | undefined; } export interface StoredSearchData { id: string; type: "search" | "fetch" | "research"; timestamp: number; queries?: QueryResultData[] | undefined; urls?: ExtractedContent[] | undefined; artifact?: unknown; fetchCache?: FetchCacheRef | undefined; urlMetadata?: StoredFetchUrlMetadata[] | undefined; fetchCacheError?: string | undefined; } export declare function generateId(): string; export declare function getFetchCacheDir(): string; export declare function pruneExpiredFetchCache(now?: number, requestedLimits?: Partial): void; export declare function storeResult(id: string, data: StoredSearchData): void; export declare function storeFetchedContentResult(id: string, data: StoredSearchData & { type: "fetch"; urls: ExtractedContent[]; }): StoredSearchData; export declare function getResult(id: string): StoredSearchData | null; export declare function getAllResults(): StoredSearchData[]; export declare function deleteResult(id: string): boolean; export declare function clearResults(): void; /** Record that one more live session holds each of these results. */ export declare function holdResults(ids: Iterable): void; /** Release one session's hold on each result, and drop a result from memory once no live * session holds it. Unlike deleteResult, the fetch cache files stay: the session journal * still references them, and a later restore reads them back. */ export declare function releaseResults(ids: Iterable): void; /** Delete a result for one session that holds it. Other live sessions holding the same * result keep it and its fetch cache file; the last holder deletes both. */ export declare function deleteHeldResult(id: string): void; /** Add one session's stored results to memory, leaving other sessions' results in place, * and return the results it loaded. A host that runs several sessions at once (one extension * instance per session) restores each with this, holds their ids with holdResults, and * releases them with releaseResults. */ export declare function loadSessionResults(ctx: ExtensionContext): StoredSearchData[]; export {};