import { EncryptedIndex } from "./encryptedIndex"; import type { MetadataFieldPolicy } from "./models"; import type { HealthResponse } from "./types"; export declare class CyborgDB { private api; /** * Create a new CyborgDB client * @param baseUrl Base URL of the CyborgDB service * @param apiKey API key for authentication * @param verifySsl Optional SSL verification setting. If not provided, auto-detects based on URL */ constructor({ baseUrl, apiKey, verifySsl, }: { baseUrl: string; apiKey?: string; verifySsl?: boolean; }); /** * List all available indexes * @returns Promise with the list of index names */ listIndexes(): Promise; /** * Validate an optional index key is exactly 32 bytes. No-op when undefined * (KMS-managed indexes supply no key). Mirrors py's `_validate_index_key` * and go's `keyBytesToHex` length check. */ private validateKeyLength; /** * Create a new encrypted DiskIVF index * * Two key-management modes — pass exactly one of `indexKey` / `kmsName`: * - SDK-managed (legacy): pass `indexKey`, omit `kmsName`. The SDK * supplies the 32-byte key directly; the service records this as * `provider: none`. * - KMS-managed: pass `kmsName` (referencing a registry entry), omit * `indexKey`. The service generates and wraps the KEK internally; the * SDK never holds a key. * * At least one of `indexKey` / `kmsName` is required. Supplying both is * rejected by the service with a 400 (the named slot already determines * the key source); `none` is not a registry slot you reference by name. * * @param indexName Name of the index * @param indexKey 32-byte encryption key (required unless `kmsName` references a real KMS provider) * @param kmsName Optional name of a `kms.registry` entry in the service config * @param dimension Vector dimensionality (auto-detected from the first upsert if omitted) * @param metric Distance metric for the index (optional) * @param embeddingModel Optional name of embedding model * @param storagePrecision Optional on-disk rerank-vector precision. `'float32'` * (default) or `'float16'` (half the storage), or a TurboQuant tier * `'tq12'` / `'tq8'` / `'tq6'` / `'tq4'` (12/8/6/4 bits per dim) that trades * storage for a small recall/latency cost. `'tq4'` requires the cosine * metric. Chosen at create time and immutable. * @param metadataSchema Optional per-field metadata indexing policy, fixed at * create time: `{ title: { filterable: true, pattern: true } }`. Fields left * out are filterable (opt-out posture); `pattern` requires `filterable` and * builds the regex dictionary that `$regex`/`$contains` need. On `query()` * this only decides how a filter resolves; `queryMetadata()` enforces it. * * A third policy, `full_text`, routes the field's string value through the * BM25 analyzer instead of exact-match indexing, making it searchable by * `queryMetadata({ text })` and hybrid `query({ text })`. `full_text: true` * implies `filterable: false` and is incompatible with `pattern: true`: * `{ body: { fullText: true } }`. * @param textFields Shorthand for marking fields `full_text: true` in * `metadataSchema`. A field listed here is analyzed by BM25 and becomes * searchable by `query({ text })` / `queryMetadata({ text })`. * @param bm25K1 BM25 term-frequency saturation (default 1.2). Requires at * least one full-text field. * @param bm25B BM25 length-normalization strength (default 0.75). Requires at * least one full-text field. BM25 search is opt-in and derived — an index * with no full-text field writes no BM25 config at all. * @returns Promise with the created index */ createIndex({ indexName, indexKey, kmsName, dimension, metric, embeddingModel, storagePrecision, metadataSchema, textFields, bm25K1, bm25B, }: { indexName: string; indexKey?: Uint8Array; kmsName?: string; dimension?: number; metric?: "euclidean" | "squared_euclidean" | "cosine"; embeddingModel?: string; storagePrecision?: "float32" | "float16" | "tq12" | "tq8" | "tq6" | "tq4"; metadataSchema?: { [field: string]: MetadataFieldPolicy; }; textFields?: string[]; bm25K1?: number; bm25B?: number; }): Promise; /** * Retrieve detailed information about an existing index * * This is a low-level method used internally by other operations. It fetches * comprehensive index metadata including configuration, training status, and * operational parameters. * * **Information Retrieved:** * - Index name and type (disk_ivf) * - Current training status (trained/untrained) * - Index configuration (dimensions, metrics, clustering parameters) * - Vector count and other operational statistics * * **Security Note:** * Requires the correct encryption key - invalid keys will result in authentication errors. * The key must be the same 32-byte key used when the index was created. * * **Usage Examples:** * ```typescript * // Typically used internally, but can be called directly * const indexInfo = await client.describeIndex("my-index", indexKey); * console.log(`Is trained: ${indexInfo.isTrained}`); * console.log(`Dimensions: ${indexInfo.dimension}`); * ``` * * @param indexName Name of the index to describe * @param indexKey 32-byte encryption key (omit for fully-KMS-managed indexes) * @returns Promise resolving to complete index information and metadata * @throws Error if index doesn't exist, key is invalid, or server unreachable * @private Internal method - consider using loadIndex() for public access */ private describeIndex; /** * Generate a cryptographically secure 32-byte encryption key * * Creates a random 32-byte (256-bit) key suitable for index encryption. * Each key is unique and provides strong security for your vector data. * * @returns Uint8Array containing 32 cryptographically secure random bytes * @throws If the host provides no Web Crypto implementation */ generateKey(): Uint8Array; /** * Static method to generate a cryptographically secure 32-byte encryption key * * Creates a random 32-byte (256-bit) key suitable for index encryption. * Each key is unique and provides strong security for your vector data. * * @returns Uint8Array containing 32 cryptographically secure random bytes * @throws If the host provides no Web Crypto implementation */ static generateKey(): Uint8Array; /** * Load and connect to an existing encrypted index * * Establishes a connection to a previously created index using its name and * (optionally) its encryption key. For fully-KMS-managed indexes the service * resolves the KEK from its own cache, so `indexKey` is optional. For legacy * (SDK-managed) indexes and `provider: none` KMS slots, `indexKey` is required. * * @param indexName Name of the existing index to load * @param indexKey 32-byte encryption key (omit for fully-KMS-managed indexes) * @returns Promise resolving to EncryptedIndex instance ready for vector operations * @throws Error if index doesn't exist, key is incorrect, or connection fails */ loadIndex({ indexName, indexKey, }: { indexName: string; indexKey?: Uint8Array; }): Promise; /** * Check the health of the server * @returns Promise with the health status */ getHealth(): Promise; }