import { type CursorPluginConfig } from "./config"; import type { RepositoryIndexMetadata } from "./workspace-context"; import { type CursorCloudCodeResult, type CursorCloudRepositoryContext, type CursorCloudSyncCodebaseStatus, type CursorCloudUploadFile } from "./cursor-index-wire"; export type CursorCloudSearchOutcome = "ok" | "no-token" | "no-results" | "codebase-not-found" | "rpc-error" | "transport-error" | "timeout" | "disabled" | "bootstrap-failed" | "empty-body" | "invalid-response" | "not-run-invalid-scope"; export interface CursorCloudSearchConfig { enabled: boolean; rpcPath: string; url: string; timeoutMs: number; topK: number; bootstrapTimeoutMs: number; bootstrapOnLoad: boolean; allowPluginGeneratedKeys: boolean; uploadMaxFiles: number; uploadMaxFileBytes: number; uploadMaxBatchBytes: number; cursorClientVersion: string; } export interface CursorCloudSearchResult { source: "cloud"; body: string; outcome: CursorCloudSearchOutcome; resultCount: number; results: CursorCloudCodeResult[]; } export interface CursorCloudSearchDiagnostic { outcome: CursorCloudSearchOutcome; resultCount: number; serverErrorCode?: string; responseBytes: number; elapsedMs: number; } export interface CursorCloudSearchAttempt { result?: CursorCloudSearchResult; diagnostic: CursorCloudSearchDiagnostic; } export interface CursorCloudEnsureResult { outcome: "already-indexed" | "uploaded" | "not-enabled" | "no-token" | "failed"; uploadCount: number; } export declare function ensureCloudIndex(adapter: CursorCloudIndexAdapter): Promise; declare function setBootstrapRetryDelaysForTest(delays: readonly number[]): () => void; declare function setBootstrapRetryCooldownForTest(ms: number): () => void; export declare const __test: { summarizeUploadedStatuses: typeof summarizeUploadedStatuses; emptyUploadSucceeds: typeof emptyUploadSucceeds; shouldBootstrapAfterSearch: typeof shouldBootstrapAfterSearch; makeLegacyRepoName: typeof import("./cursor-index-wire").makeLegacyRepoName; resolveStoredCursorIndexMetadataWithImportedKeys: (context: CursorCloudRepositoryContext, env: NodeJS.ProcessEnv, imported: import("./cursor-index-wire").StoredRepositoryKeys) => Promise; sanitizeResultPath: typeof sanitizeResultPath; renderCloudSearchResults: typeof renderCloudSearchResults; setBootstrapRetryDelaysForTest: typeof setBootstrapRetryDelaysForTest; setBootstrapRetryCooldownForTest: typeof setBootstrapRetryCooldownForTest; listGitUploadCandidates: typeof listGitUploadCandidates; listGitUploadCandidateSnapshot: typeof listGitUploadCandidateSnapshot; clearLsFilesCacheForTest: typeof clearLsFilesCacheForTest; computeRootHash: typeof computeRootHash; computeSimilarityMetric: typeof computeSimilarityMetric; collectUploadFiles: typeof collectUploadFiles; finalizeNativeBootstrapSnapshot: typeof finalizeNativeBootstrapSnapshot; selectBootstrapSnapshot: typeof selectBootstrapSnapshot; isAuthoritativeBootstrapSnapshot: typeof isAuthoritativeBootstrapSnapshot; chunkUploadFiles: typeof chunkUploadFiles; cursorUploadBatchMaxFiles: number; cursorUploadConcurrency: number; }; export declare function validateRepositoryIndexMetadata(value: unknown): RepositoryIndexMetadata | undefined; export declare function resolveCursorCloudIndexMetadata(contextOrEnv?: CursorCloudRepositoryContext | NodeJS.ProcessEnv, env?: NodeJS.ProcessEnv, _config?: CursorPluginConfig): RepositoryIndexMetadata | undefined; export declare function resolveCursorCloudIndexMetadataAsync(contextOrEnv?: CursorCloudRepositoryContext | NodeJS.ProcessEnv, env?: NodeJS.ProcessEnv, config?: CursorPluginConfig): Promise; export declare function resolveCursorCloudSearchConfig(env?: NodeJS.ProcessEnv): CursorCloudSearchConfig | undefined; export declare function cloudSearchConfigFromPluginConfig(config: CursorPluginConfig): CursorCloudSearchConfig | undefined; declare function sanitizeResultPath(path: string | undefined): string; export declare function renderCloudSearchResults(results: CursorCloudCodeResult[]): string | undefined; interface UploadCandidateSnapshot { paths: string[]; complete: boolean; } declare function listGitUploadCandidateSnapshot(root: string, maxFiles?: number): Promise; declare function listGitUploadCandidates(root: string, maxFiles?: number): Promise; declare function clearLsFilesCacheForTest(): void; declare function collectUploadFiles(root: string, config: CursorCloudSearchConfig): Promise; interface CloudBootstrapSnapshot { source: "native" | "filtered"; complete: boolean; files: CursorCloudUploadFile[]; rootHash: string; similarityMetric: number[]; } declare function selectBootstrapSnapshot(native: CloudBootstrapSnapshot | undefined, filtered: CloudBootstrapSnapshot | undefined): CloudBootstrapSnapshot | undefined; declare function isAuthoritativeBootstrapSnapshot(snapshot: CloudBootstrapSnapshot): boolean; declare function finalizeNativeBootstrapSnapshot(files: CursorCloudUploadFile[], nativeFileCount: number, maxFiles: number, nativeRootHash: string, nativeSimilarityMetric: Iterable): CloudBootstrapSnapshot; declare function computeRootHash(files: CursorCloudUploadFile[]): string; declare function computeSimilarityMetric(files: CursorCloudUploadFile[]): number[]; declare function chunkUploadFiles(files: CursorCloudUploadFile[], config: CursorCloudSearchConfig): CursorCloudUploadFile[][]; declare function summarizeUploadedStatuses(syncStatuses: CursorCloudSyncCodebaseStatus[]): CursorCloudEnsureResult; declare function emptyUploadSucceeds(status: number): boolean; declare function shouldBootstrapAfterSearch(outcome: CursorCloudSearchOutcome, everBootstrapped: boolean): boolean; export declare class CursorCloudIndexAdapter { private readonly metadata; private readonly config; private readonly context; private readonly accessTokenProvider?; private readonly now; private bootstrapPromise; private bootstrapSuccess; private searchTriggeredBootstrap; private lastBootstrapFailureAt; private disposed; private readonly lifecycle; constructor(metadata: RepositoryIndexMetadata, config: CursorCloudSearchConfig, context: CursorCloudRepositoryContext, accessTokenProvider?: (() => string | undefined | Promise) | undefined, now?: () => number); get enabled(): boolean; dispose(): void; search(args: { query: string; }): Promise; private searchAfterBootstrap; ensureCloudIndex(): Promise; private runBootstrap; private diagnostic; private resolveRequestAuth; private searchOnce; private uploadChunksForCodebase; private uploadChunk; private syncMerklePath; private collectStaleRemotePaths; private deleteRemotePath; private deleteRemotePaths; private syncCodebase; private finalizeBootstrapAfterUploads; private bootstrapCloudIndex; } export {};