import { type Table as ArrowTable } from 'apache-arrow'; import type { CancelOutcome, SqlOptions, SqlQuery, SqlQueryStatus } from './db.js'; import { type ProcedureCallOptions, type ProcedureSpec } from './procedure.js'; import { type TriggerSpec } from './trigger.js'; import { type VirtualTableSpec } from './external.js'; export type RemoteAuth = { bearerToken: string; } | { username: string; password: string; }; export type RemoteOptions = { auth?: RemoteAuth; }; export type RemoteSqlPaginationOptions = { queryId?: string; timeoutMs?: number; projection: string[]; pageSizeRows: number; maxPageBytes?: number; maxPageTokens?: number; maxOutputRows?: number; maxOutputBytes?: number; }; export type RemoteSqlControlOptions = { queryId?: string; timeoutMs?: number; signal?: AbortSignal; }; export type RemoteSqlPage = { status: string; rows: Record[]; nextCursor?: string; page: { offset: number; rowCount: number; totalRows: number; byteCount: number; estimatedTokens: number; limits: { rows: number; bytes: number; tokens: number; }; projection: string[]; expiresAtMs: number; snapshot: string; tokenEstimate: string; }; }; export type RemoteIdempotentSqlOptions = { queryId?: string; timeoutMs?: number; idempotencyKey: string; maxOutputRows?: number; maxOutputBytes?: number; }; export type RemoteSqlWriteReceipt = { queryId: string; originalQueryId: string; status: string; terminalState?: string; serverState?: string; cancelOutcome?: CancelOutcome; cancellationReason?: string; committed: boolean; committedStatements: number; lastCommitEpoch?: bigint; firstCommitStatementIndex?: number; lastCommitStatementIndex?: number; completedStatements: number; statementIndex: number; retryable: boolean; idempotencyReplayed: boolean; idempotencyPersisted: boolean; idempotencyExpiresAtMs: number; terminalError?: { code: string; category: string; }; }; /** Structural HLC from server durable recovery (0.64+). */ export type RemoteCommitHlc = { physical_micros: number; logical?: number; node_tiebreaker?: number; }; export type RemoteDurableOutcome = { committed: boolean | null; committed_statements?: number | null; last_commit_epoch?: number | null; last_commit_epoch_text?: string | null; last_commit_hlc?: RemoteCommitHlc | null; first_commit_statement_index?: number | null; last_commit_statement_index?: number | null; completed_statements?: number | null; statement_index?: number | null; serialization?: string; serialization_state?: string | null; terminal_state?: string | null; }; export type RemoteQueryStatus = SqlQueryStatus; /** * A thin Kit client for a running `mongreldb-server` daemon. * * Unlike the embedded {@link KitDatabase}, the daemon speaks SQL + native query * over HTTP, not the Kit's typed/validated object model — so this surface is * SQL-oriented: run SQL (returning Arrow), read table names / counts, force a * commit, and health-check. Schema, validation, and constraints are the local * KitDatabase's job; connect a remote for cross-process reads/queries. * * TypeScript-only: the addon exposes the daemon client; the Rust/Python kit * would need the `mongreldb-client` crate for an equivalent. */ export declare class RemoteDatabase { #private; private readonly inner; private readonly url; private capabilities?; /** Connect (lazily) to a daemon at `url`, e.g. `http://127.0.0.1:8453`. */ constructor(url: string, options?: RemoteOptions); private request; private recoveryRequest; /** Liveness check; returns the server's health string (throws if down). */ health(): string; /** Live table names on the server. */ tableNames(): string[]; /** Row count of `table`. */ count(table: string): bigint; setHistoryRetentionEpochs(epochs: bigint): void; historyRetentionEpochs(): bigint; earliestRetainedEpoch(): bigint; /** Run a SQL query without blocking the Node event loop. */ sql(sql: string, options?: SqlOptions): Promise; sqlRows(sql: string, options?: SqlOptions): Promise[]>; startSql(sql: string, options?: SqlOptions): SqlQuery; cancelSql(queryId: string): Promise; private cancelSqlForSignal; private sendCancelSql; queryStatus(queryId: string): Promise; /** * Text → embed under the active semantic identity → ANN retrieve * (`POST /kit/retrieve_text`, 0.64+). */ retrieveText(table: string, embeddingColumn: number, text: string, options?: { k?: number; deadlineMs?: number; maxWork?: number; }): Promise<{ hits: Array<{ rowId: string; rank: number; score: unknown; }>; provenance: { embeddingColumn: number; providerRegistryGeneration: number; querySourceFingerprint: string; semanticIdentity: Record; }; }>; /** * Build a multi-retriever hybrid search body for `POST /kit/search`. * Exposed for wire tests and callers that need the payload without executing. */ static buildKitSearchBody(input: { table: string; retrievers: Array>; fusionConstant?: number; limit?: number; must?: Array>; rerank?: Record; projection?: number[]; }): Record; /** Multi-retriever hybrid search (`POST /kit/search`). */ kitSearch(body: Record): Promise<{ hits: Array>; trace?: unknown; nextCursor?: string; }>; sqlPage(sql: string, options: RemoteSqlPaginationOptions): Promise; continueSqlPage(cursor: string, options?: RemoteSqlControlOptions): Promise; executeIdempotentSql(sql: string, options: RemoteIdempotentSqlOptions): Promise; private executeIdempotentSqlOnce; private resolveIdempotentSqlLoss; private rawQueryStatus; private resolveLostQueryOutcome; private recoveryTimeout; private queryStatusForRecovery; private cancelSqlForRecovery; private executeSql; private loadCapabilities; private validateSqlCancellationCapability; private validateSqlIdempotencyCapability; private requireSqlCancellation; private requireSqlPagination; private requireSqlIdempotency; private requireFreshSqlIdempotency; /** Flush/commit `table` on the server; returns the new epoch. */ commit(table: string): bigint; createProcedure(spec: ProcedureSpec): unknown; dropProcedure(name: string): void; callProcedure(name: string, opts?: ProcedureCallOptions): unknown; createTrigger(spec: TriggerSpec): unknown; replaceTrigger(name: string, spec: TriggerSpec): unknown; dropTrigger(name: string): void; triggers(): unknown; trigger(name: string): unknown; createVirtualTable(spec: VirtualTableSpec): Promise; dropVirtualTable(name: string): Promise; /** Compact every table on the daemon (POST /compact). Returns * `{ compacted, skipped }`. */ compact(): { compacted: number; skipped: number; }; /** Compact a single table on the daemon (POST /tables/{name}/compact). * Returns `true` if compacted, `false` if skipped. */ compactTable(table: string): boolean; } //# sourceMappingURL=remote.d.ts.map