@antfly/embedded 0.0.0 → 0.3.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +452 -4
- package/dist/chunk-ELM44XQ4.js +168 -0
- package/dist/database-D9gL3wnT.d.cts +585 -0
- package/dist/database-D9gL3wnT.d.ts +585 -0
- package/dist/index.cjs +2498 -0
- package/dist/index.d.cts +322 -0
- package/dist/index.d.ts +322 -0
- package/dist/index.js +2253 -0
- package/dist/kysely.cjs +346 -0
- package/dist/kysely.d.cts +28 -0
- package/dist/kysely.d.ts +28 -0
- package/dist/kysely.js +169 -0
- package/package.json +82 -10
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
import { LibraryHandle, KoffiFunc } from 'koffi';
|
|
2
|
+
|
|
3
|
+
/** Where a resolved libantfly path came from, for diagnostics/logging. */
|
|
4
|
+
type LibrarySource = "ANTFLY_LIBRARY" | "ANTFLY_LIB_DIR" | "embedded-package" | "source-tree" | "system";
|
|
5
|
+
interface ResolvedLibrary {
|
|
6
|
+
/** Absolute path to the shared library, or a bare loader name for "system". */
|
|
7
|
+
path: string;
|
|
8
|
+
source: LibrarySource;
|
|
9
|
+
}
|
|
10
|
+
declare class LibraryNotFoundError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
declare class UnsupportedPlatformError extends Error {
|
|
14
|
+
constructor(platform: string);
|
|
15
|
+
}
|
|
16
|
+
/** The libantfly shared library file name for a platform, e.g. "libantfly.dylib". */
|
|
17
|
+
declare function platformLibraryFileName(platform: NodeJS.Platform): string | undefined;
|
|
18
|
+
/** The Apache @antfly/embedded-<platform> package that ships libantfly. */
|
|
19
|
+
declare function embeddedPlatformPackageName(platform: NodeJS.Platform, arch: string): string | undefined;
|
|
20
|
+
interface ResolveLibraryOptions {
|
|
21
|
+
platform?: NodeJS.Platform;
|
|
22
|
+
arch?: string;
|
|
23
|
+
env?: NodeJS.ProcessEnv;
|
|
24
|
+
/** Directory to walk up from when looking for zig/zig-out/lib (a source checkout). Defaults to this package's own directory. */
|
|
25
|
+
startDir?: string;
|
|
26
|
+
existsSync?: (path: string) => boolean;
|
|
27
|
+
/** Like require.resolve; used to locate an installed @antfly/embedded-<platform> package. */
|
|
28
|
+
resolve?: (specifier: string) => string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the libantfly shared library to load, in order:
|
|
32
|
+
*
|
|
33
|
+
* 1. `ANTFLY_LIBRARY` env var: an exact file path.
|
|
34
|
+
* 2. `ANTFLY_LIB_DIR` env var: a directory containing the platform library file.
|
|
35
|
+
* 3. The installed `@antfly/embedded-<platform>` package's `lib/` directory.
|
|
36
|
+
* 4. `zig/zig-out/lib/` found by walking up from this package (a source checkout).
|
|
37
|
+
* 5. The bare system loader name, resolved by the OS's shared library search
|
|
38
|
+
* path (LD_LIBRARY_PATH / DYLD_LIBRARY_PATH / PATH / rpath).
|
|
39
|
+
*
|
|
40
|
+
* Throws LibraryNotFoundError if an explicit env var names a path that does
|
|
41
|
+
* not exist, so misconfiguration fails loudly instead of silently falling
|
|
42
|
+
* through to another tier.
|
|
43
|
+
*/
|
|
44
|
+
declare function resolveLibrary(options?: ResolveLibraryOptions): ResolvedLibrary;
|
|
45
|
+
|
|
46
|
+
/** How a database is opened (antfly_open_mode_* in antfly.h). */
|
|
47
|
+
declare enum OpenMode {
|
|
48
|
+
Writer = 0,
|
|
49
|
+
Readonly = 1,
|
|
50
|
+
StatusOnly = 2
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* How a database is stored (antfly_storage_kind_* in antfly.h). The zero
|
|
54
|
+
* value, Lite, is a single-file .aflite database.
|
|
55
|
+
*/
|
|
56
|
+
declare enum Storage {
|
|
57
|
+
/** A single-file .aflite database. */
|
|
58
|
+
Lite = 0,
|
|
59
|
+
/** A normal single-node Antfly directory. */
|
|
60
|
+
Directory = 1
|
|
61
|
+
}
|
|
62
|
+
/** The Lite runtime profile (antfly_profile_* in antfly.h). */
|
|
63
|
+
declare enum Profile {
|
|
64
|
+
Native = 0,
|
|
65
|
+
Hosted = 1
|
|
66
|
+
}
|
|
67
|
+
/** Graph edge traversal direction (antfly_graph_direction_* in antfly.h). */
|
|
68
|
+
declare enum GraphDirection {
|
|
69
|
+
Out = 0,
|
|
70
|
+
In = 1,
|
|
71
|
+
Both = 2
|
|
72
|
+
}
|
|
73
|
+
/** Transaction intent lifecycle state (antfly_txn_status in antfly.h). */
|
|
74
|
+
declare enum TxnStatus {
|
|
75
|
+
Pending = 0,
|
|
76
|
+
Committed = 1,
|
|
77
|
+
Aborted = 2
|
|
78
|
+
}
|
|
79
|
+
/** Inference mode strings returned by Lite status and capabilities JSON. */
|
|
80
|
+
declare const InferenceMode: {
|
|
81
|
+
readonly CallerSuppliedOrDisabled: "caller_supplied_or_disabled";
|
|
82
|
+
readonly CallerSuppliedArtifacts: "caller_supplied_artifacts";
|
|
83
|
+
readonly RemoteProvider: "remote_provider";
|
|
84
|
+
readonly LocalEmbedded: "local_embedded";
|
|
85
|
+
readonly ManualMaintenance: "manual_maintenance";
|
|
86
|
+
readonly DisabledDeferred: "disabled_deferred";
|
|
87
|
+
};
|
|
88
|
+
/** The only libantfly threading contract (antfly_threading_mode() return value), like sqlite3_threadsafe(). */
|
|
89
|
+
declare const THREADING_SERIALIZED = 1;
|
|
90
|
+
/** The Antfly C ABI version this binding was written against (antfly_abi_version()). */
|
|
91
|
+
declare const SUPPORTED_ABI_VERSION = 3;
|
|
92
|
+
/** Configures TTL cleanup for a native-profile Lite handle. */
|
|
93
|
+
interface TTLCleanupOptions {
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
leaseOwned: boolean;
|
|
96
|
+
ownerId?: string;
|
|
97
|
+
leaseTtlMs?: Uint64Like;
|
|
98
|
+
intervalMs?: Uint64Like;
|
|
99
|
+
batchSize?: number;
|
|
100
|
+
gracePeriodNs?: Uint64Like;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Configures open/create. See antfly_open_options in antfly.h and
|
|
104
|
+
* zig/LITE.md's "Local Embedded Inference" section for the inference budget
|
|
105
|
+
* fields. All fields are optional; unset numeric budgets mean "automatic".
|
|
106
|
+
*/
|
|
107
|
+
interface OpenOptions {
|
|
108
|
+
/** Selects a .aflite file (the default) or a directory. Directory storage is created by opening a missing path; createWithOptions only creates .aflite files. */
|
|
109
|
+
storage?: Storage;
|
|
110
|
+
mode?: OpenMode;
|
|
111
|
+
profile?: Profile;
|
|
112
|
+
noSync?: boolean;
|
|
113
|
+
remoteProviderConfigured?: boolean;
|
|
114
|
+
localRuntimeConfigured?: boolean;
|
|
115
|
+
generatedEnrichmentReplay?: boolean;
|
|
116
|
+
mapSize?: Uint64Like;
|
|
117
|
+
ttlCleanup?: TTLCleanupOptions;
|
|
118
|
+
/** Milliseconds to retry while another writer holds the writer lock (ANTFLY_BUSY), like sqlite3_busy_timeout. 0 (default) fails immediately. */
|
|
119
|
+
busyTimeoutMs?: Uint64Like;
|
|
120
|
+
inferenceHostBudgetMb?: number;
|
|
121
|
+
inferenceBackendBudgetMb?: number;
|
|
122
|
+
inferenceCombinedBudgetMb?: number;
|
|
123
|
+
inferenceKvBudgetMb?: number;
|
|
124
|
+
inferenceScratchBudgetMb?: number;
|
|
125
|
+
inferenceProcessMemoryBudgetMb?: number;
|
|
126
|
+
}
|
|
127
|
+
/** A single key/value write or delete in a batch. */
|
|
128
|
+
interface WriteIntent {
|
|
129
|
+
key: string;
|
|
130
|
+
value?: Uint8Array | Record<string, unknown>;
|
|
131
|
+
delete?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/** Configures restore() and restoreFile(). */
|
|
134
|
+
interface RestoreOptions {
|
|
135
|
+
/** Selects the kind of database created at the destination: a .aflite file (the default) or a directory. */
|
|
136
|
+
storage?: Storage;
|
|
137
|
+
/** Atomically replaces an existing destination. */
|
|
138
|
+
replace?: boolean;
|
|
139
|
+
}
|
|
140
|
+
interface StorageStatus {
|
|
141
|
+
format: string;
|
|
142
|
+
engine: string;
|
|
143
|
+
primary_layout: string;
|
|
144
|
+
replay_layout: string;
|
|
145
|
+
index_layout: string;
|
|
146
|
+
index_namespace?: string;
|
|
147
|
+
format_version?: number;
|
|
148
|
+
page_size?: number;
|
|
149
|
+
active_checkpoint?: number;
|
|
150
|
+
checkpoint_sequence?: number;
|
|
151
|
+
page_count?: number;
|
|
152
|
+
}
|
|
153
|
+
/** Historical snapshot of the local runtime's last denied memory admission. */
|
|
154
|
+
interface MemoryAdmissionStats {
|
|
155
|
+
pressure: string;
|
|
156
|
+
denied_count: number;
|
|
157
|
+
last_denied_ns: number;
|
|
158
|
+
request_count: number;
|
|
159
|
+
requested_host_bytes: number;
|
|
160
|
+
requested_backend_bytes: number;
|
|
161
|
+
requested_kv_bytes: number;
|
|
162
|
+
requested_scratch_bytes: number;
|
|
163
|
+
admitted_host_bytes: number;
|
|
164
|
+
admitted_backend_bytes: number;
|
|
165
|
+
host_limit_bytes: number;
|
|
166
|
+
backend_limit_bytes: number;
|
|
167
|
+
combined_limit_bytes: number;
|
|
168
|
+
available_memory_bytes: number;
|
|
169
|
+
}
|
|
170
|
+
interface InferenceStatus {
|
|
171
|
+
mode: string;
|
|
172
|
+
available_modes: string[];
|
|
173
|
+
configured: boolean;
|
|
174
|
+
remote_provider_configured: boolean;
|
|
175
|
+
local_runtime_configured: boolean;
|
|
176
|
+
local_runtime_available: boolean;
|
|
177
|
+
caller_supplied_artifacts: boolean;
|
|
178
|
+
no_inference_configured_ok: boolean;
|
|
179
|
+
host_budget_mb: number;
|
|
180
|
+
backend_budget_mb: number;
|
|
181
|
+
combined_budget_mb: number;
|
|
182
|
+
kv_budget_mb: number;
|
|
183
|
+
scratch_budget_mb: number;
|
|
184
|
+
process_memory_budget_mb: number;
|
|
185
|
+
process_memory_limit_bytes: number;
|
|
186
|
+
process_memory_limit_source: string;
|
|
187
|
+
memory_admission?: MemoryAdmissionStats;
|
|
188
|
+
}
|
|
189
|
+
interface Capabilities {
|
|
190
|
+
freestanding_build: boolean;
|
|
191
|
+
/** Always "serialized" for the current libantfly (see THREADING_SERIALIZED). */
|
|
192
|
+
threading: string;
|
|
193
|
+
hosted_profile: boolean;
|
|
194
|
+
manual_maintenance: boolean;
|
|
195
|
+
background_enrichment_runtime: boolean;
|
|
196
|
+
ttl_cleanup_runtime: boolean;
|
|
197
|
+
transaction_recovery_runtime: boolean;
|
|
198
|
+
local_template_rendering: boolean;
|
|
199
|
+
remote_template_rendering: boolean;
|
|
200
|
+
remote_template_host_callbacks: boolean;
|
|
201
|
+
inference_mode: string;
|
|
202
|
+
supported_inference_modes: string[];
|
|
203
|
+
available_inference_modes: string[];
|
|
204
|
+
inference_required: boolean;
|
|
205
|
+
no_inference_configured_ok: boolean;
|
|
206
|
+
caller_supplied_artifacts: boolean;
|
|
207
|
+
caller_supplied_embeddings: boolean;
|
|
208
|
+
remote_inference_providers: boolean;
|
|
209
|
+
local_inference_runtime: boolean;
|
|
210
|
+
generated_enrichment_planning: boolean;
|
|
211
|
+
text_search: boolean;
|
|
212
|
+
dense_vector_search: boolean;
|
|
213
|
+
sparse_vector_search: boolean;
|
|
214
|
+
hybrid_search: boolean;
|
|
215
|
+
graph_search: boolean;
|
|
216
|
+
distributed_shard_ownership: boolean;
|
|
217
|
+
raft_replication: boolean;
|
|
218
|
+
cluster_placement: boolean;
|
|
219
|
+
cross_node_joins: boolean;
|
|
220
|
+
remote_shard_fanout: boolean;
|
|
221
|
+
distributed_transaction_coordination: boolean;
|
|
222
|
+
cluster_heartbeat_status_aggregation: boolean;
|
|
223
|
+
server_side_autoscaling: boolean;
|
|
224
|
+
kubernetes_operator: boolean;
|
|
225
|
+
object_storage_primary: boolean;
|
|
226
|
+
}
|
|
227
|
+
interface PendingWorkStatus {
|
|
228
|
+
derived_target_sequence: number;
|
|
229
|
+
has_async_indexes: boolean;
|
|
230
|
+
portable_import_publication_in_progress: boolean;
|
|
231
|
+
portable_import_recovery_required: boolean;
|
|
232
|
+
portable_runtime_activation_pending: boolean;
|
|
233
|
+
enrichment: unknown;
|
|
234
|
+
resolution: unknown;
|
|
235
|
+
promotion: unknown;
|
|
236
|
+
text_merge: unknown;
|
|
237
|
+
replacements?: unknown[];
|
|
238
|
+
}
|
|
239
|
+
interface Status {
|
|
240
|
+
storage: StorageStatus;
|
|
241
|
+
stats: unknown;
|
|
242
|
+
pending_work: PendingWorkStatus;
|
|
243
|
+
inference: InferenceStatus;
|
|
244
|
+
capabilities: Capabilities;
|
|
245
|
+
}
|
|
246
|
+
interface ReplayGeneratedEnrichmentsResult {
|
|
247
|
+
replayed: number;
|
|
248
|
+
}
|
|
249
|
+
interface CheckReport {
|
|
250
|
+
valid: boolean;
|
|
251
|
+
file_size: number;
|
|
252
|
+
valid_prefix_size: number;
|
|
253
|
+
tail_bytes: number;
|
|
254
|
+
record_count: number;
|
|
255
|
+
live_file_count: number;
|
|
256
|
+
live_bytes: number;
|
|
257
|
+
compact_size: number;
|
|
258
|
+
reclaimable_bytes: number;
|
|
259
|
+
issue?: string;
|
|
260
|
+
}
|
|
261
|
+
interface VacuumReport {
|
|
262
|
+
before_size: number;
|
|
263
|
+
after_size: number;
|
|
264
|
+
reclaimed_bytes: number;
|
|
265
|
+
live_file_count: number;
|
|
266
|
+
live_bytes: number;
|
|
267
|
+
}
|
|
268
|
+
interface CompactReport {
|
|
269
|
+
compacted: boolean;
|
|
270
|
+
vacuum: VacuumReport;
|
|
271
|
+
}
|
|
272
|
+
interface StableSnapshotReport {
|
|
273
|
+
source_size: number;
|
|
274
|
+
snapshot_size: number;
|
|
275
|
+
checkpoint_sequence: number;
|
|
276
|
+
page_count: number;
|
|
277
|
+
tail_bytes: number;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Configures Inference.open(). See antfly_inference_options in antfly.h.
|
|
281
|
+
* All fields are optional; unset numeric budgets mean "automatic".
|
|
282
|
+
*/
|
|
283
|
+
interface InferenceOptions {
|
|
284
|
+
/** Models directory. Empty (default) uses $ANTFLY_INFERENCE_MODELS_DIR, else ~/.antfly/inference/models. */
|
|
285
|
+
modelsDir?: string;
|
|
286
|
+
hostBudgetMb?: number;
|
|
287
|
+
backendBudgetMb?: number;
|
|
288
|
+
processMemoryBudgetMb?: number;
|
|
289
|
+
combinedBudgetMb?: number;
|
|
290
|
+
kvBudgetMb?: number;
|
|
291
|
+
scratchBudgetMb?: number;
|
|
292
|
+
/** Deadline for each call in milliseconds; 0 (default) means none. */
|
|
293
|
+
callTimeoutMs?: Uint64Like;
|
|
294
|
+
}
|
|
295
|
+
/** One progress report from Inference.pull(), mirroring antfly_inference_pull_progress. */
|
|
296
|
+
interface PullProgress {
|
|
297
|
+
/** The model reference being pulled (one report series per requested variant). */
|
|
298
|
+
model: string;
|
|
299
|
+
file: string;
|
|
300
|
+
bytesDownloaded: bigint;
|
|
301
|
+
/** 0n when unknown. */
|
|
302
|
+
totalBytes: bigint;
|
|
303
|
+
filesDone: bigint;
|
|
304
|
+
filesTotal: bigint;
|
|
305
|
+
/** The file was already present and verified; nothing was downloaded. */
|
|
306
|
+
cached: boolean;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface NativeLibrary {
|
|
310
|
+
handle: LibraryHandle;
|
|
311
|
+
resolved: ResolvedLibrary;
|
|
312
|
+
abiVersion: KoffiFunc<() => number>;
|
|
313
|
+
threadingMode: KoffiFunc<() => number>;
|
|
314
|
+
openOptionsSize: KoffiFunc<() => number>;
|
|
315
|
+
errorCodeName: KoffiFunc<(code: number) => string>;
|
|
316
|
+
errorCodeDescription: KoffiFunc<(code: number) => string>;
|
|
317
|
+
openOptionsInit: KoffiFunc<(options: object) => number>;
|
|
318
|
+
dbOpenWithOptions: KoffiFunc<(path: string, options: object, outHandle: unknown[]) => number>;
|
|
319
|
+
dbCreateWithOptions: KoffiFunc<(path: string, options: object, outHandle: unknown[]) => number>;
|
|
320
|
+
liteOpenHosted: KoffiFunc<(path: string, outHandle: unknown[]) => number>;
|
|
321
|
+
liteCreateHosted: KoffiFunc<(path: string, outHandle: unknown[]) => number>;
|
|
322
|
+
dbClose: KoffiFunc<(handle: unknown) => void>;
|
|
323
|
+
bufferFree: KoffiFunc<(buffer: object) => void>;
|
|
324
|
+
dbSqlJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
325
|
+
dbOpenTable: KoffiFunc<(handle: unknown, name: object, out: unknown[]) => number>;
|
|
326
|
+
dbCreateTableJson: KoffiFunc<(handle: unknown, name: object, schema: object) => number>;
|
|
327
|
+
dbDropTable: KoffiFunc<(handle: unknown, name: object) => number>;
|
|
328
|
+
dbListTablesJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
329
|
+
dbSqlSessionOpen: KoffiFunc<(handle: unknown, out: unknown[]) => number>;
|
|
330
|
+
dbSqlSessionClose: KoffiFunc<(handle: unknown, session: number | bigint) => number>;
|
|
331
|
+
dbSqlOpenCursorJson: KoffiFunc<(handle: unknown, request: object, cursor: unknown[], out: object) => number>;
|
|
332
|
+
dbSqlFetchCursorJson: KoffiFunc<(handle: unknown, cursor: number | bigint, rows: number, out: object) => number>;
|
|
333
|
+
dbSqlCloseCursor: KoffiFunc<(handle: unknown, cursor: number | bigint) => number>;
|
|
334
|
+
dbStatusJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
335
|
+
dbCapabilitiesJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
336
|
+
dbBackup: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
337
|
+
dbImportBackup: KoffiFunc<(handle: unknown, backup: object) => number>;
|
|
338
|
+
restoreBackupJson: KoffiFunc<(destPath: string, options: object | null, backup: object, replace: boolean, out: object) => number>;
|
|
339
|
+
restoreBackupFileJson: KoffiFunc<(destPath: string, options: object | null, backupPath: string, replace: boolean, out: object) => number>;
|
|
340
|
+
liteCheckJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
341
|
+
liteCheckFileJson: KoffiFunc<(path: string, out: object) => number>;
|
|
342
|
+
liteCopyStableSnapshotJson: KoffiFunc<(handle: unknown, destPath: string, replace: boolean, out: object) => number>;
|
|
343
|
+
liteCopyStableSnapshotFileJson: KoffiFunc<(srcPath: string, destPath: string, replace: boolean, out: object) => number>;
|
|
344
|
+
liteCompactJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
345
|
+
liteVacuumJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
346
|
+
dbRunUntilIdle: KoffiFunc<(handle: unknown) => number>;
|
|
347
|
+
dbRunUntilIdleJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
348
|
+
dbReplayGeneratedEnrichmentsJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
349
|
+
dbPendingWorkStatsJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
350
|
+
dbBatch: KoffiFunc<(handle: unknown, writes: object[] | null, writeCount: number, predicates: object[] | null, predicateCount: number, timestampNs: number | bigint, syncLevel: number) => number>;
|
|
351
|
+
dbBatchJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
352
|
+
dbBeginTransactionWithId: KoffiFunc<(handle: unknown, txnId: Uint8Array, timestampNs: number | bigint, participants: object[] | null, participantCount: number) => number>;
|
|
353
|
+
dbWriteTransaction: KoffiFunc<(handle: unknown, txnId: Uint8Array, writes: object[] | null, writeCount: number, predicates: object[] | null, predicateCount: number) => number>;
|
|
354
|
+
dbResolveIntents: KoffiFunc<(handle: unknown, txnId: Uint8Array, status: number, commitVersion: number | bigint) => number>;
|
|
355
|
+
dbGetTransactionStatus: KoffiFunc<(handle: unknown, txnId: Uint8Array, outStatus: number[]) => number>;
|
|
356
|
+
dbGetCommitVersion: KoffiFunc<(handle: unknown, txnId: Uint8Array, outVersion: (number | bigint)[]) => number>;
|
|
357
|
+
dbLookupJson: KoffiFunc<(handle: unknown, key: object, out: object) => number>;
|
|
358
|
+
dbGetRaw: KoffiFunc<(handle: unknown, key: object, out: object) => number>;
|
|
359
|
+
dbGetSchemaJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
360
|
+
dbSetSchemaJson: KoffiFunc<(handle: unknown, schema: object) => number>;
|
|
361
|
+
dbRenderResolverKeyJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object, out: object) => number>;
|
|
362
|
+
dbMemoryJson: KoffiFunc<(handle: unknown, space: object, request: object, out: object) => number>;
|
|
363
|
+
dbResolveQueryJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object, out: object) => number>;
|
|
364
|
+
dbMergeResolverKeysJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object) => number>;
|
|
365
|
+
dbUnmergeResolverKeyJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object, out: object) => number>;
|
|
366
|
+
dbSuppressResolverKeysJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object, out: object) => number>;
|
|
367
|
+
dbUnsuppressResolverKeyJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object, out: object) => number>;
|
|
368
|
+
dbResolverCurationJson: KoffiFunc<(handle: unknown, arg0: object, out: object) => number>;
|
|
369
|
+
dbResolverReviewsJson: KoffiFunc<(handle: unknown, arg0: object, out: object) => number>;
|
|
370
|
+
dbCurateEntityJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object, arg2: object, out: object) => number>;
|
|
371
|
+
dbListResolverIdentitiesJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
372
|
+
dbSetResolverNamespaceJson: KoffiFunc<(handle: unknown, arg0: object, arg1: object) => number>;
|
|
373
|
+
dbDropResolverIdentity: KoffiFunc<(handle: unknown, name: object, out: object) => number>;
|
|
374
|
+
dbListIndexesJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
375
|
+
dbAddIndexJson: KoffiFunc<(handle: unknown, config: object) => number>;
|
|
376
|
+
dbDeleteIndex: KoffiFunc<(handle: unknown, name: object, outDeleted: boolean[]) => number>;
|
|
377
|
+
dbListEnrichmentsJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
378
|
+
dbAddEnrichmentJson: KoffiFunc<(handle: unknown, config: object) => number>;
|
|
379
|
+
dbDeleteEnrichment: KoffiFunc<(handle: unknown, kind: object, name: object, outDeleted: boolean[]) => number>;
|
|
380
|
+
dbScanJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
381
|
+
dbStatsJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
382
|
+
dbSearchJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
383
|
+
dbSearchDenseWire: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
384
|
+
dbSearchTextMatchWire: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
385
|
+
dbSearchTextTermWire: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
386
|
+
dbSearchTextMatchPhraseWire: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
387
|
+
dbAggregateHitsJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
388
|
+
dbLookupArtifactJson: KoffiFunc<(handle: unknown, artifactIdBase64: object, out: object) => number>;
|
|
389
|
+
decodeArtifactIdJson: KoffiFunc<(artifactIdBase64: object, out: object) => number>;
|
|
390
|
+
dbExtractEnrichmentsJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
391
|
+
dbComputeEnrichmentsJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
392
|
+
dbGetEdgesJson: KoffiFunc<(handle: unknown, indexName: object, key: object, edgeType: object, direction: number, out: object) => number>;
|
|
393
|
+
dbTraverseEdgesJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
394
|
+
dbExecuteGraphQueriesJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
395
|
+
dbGetNeighborsJson: KoffiFunc<(handle: unknown, indexName: object, key: object, edgeType: object, direction: number, out: object) => number>;
|
|
396
|
+
dbFindShortestPathJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
397
|
+
dbFindKShortestPathsJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
398
|
+
dbMatchPatternJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
399
|
+
inferenceOptionsSize: KoffiFunc<() => number>;
|
|
400
|
+
inferenceOptionsInit: KoffiFunc<(options: object) => number>;
|
|
401
|
+
inferenceOpen: KoffiFunc<(options: object | null, outHandle: unknown[]) => number>;
|
|
402
|
+
inferenceClose: KoffiFunc<(handle: unknown) => void>;
|
|
403
|
+
inferenceEmbedJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
404
|
+
inferenceRerankJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
405
|
+
inferenceChunkJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
406
|
+
inferenceGenerateJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
407
|
+
inferenceGenerateStreamJson: KoffiFunc<(handle: unknown, request: object, onChunk: unknown, chunkContext: unknown, out: object) => number>;
|
|
408
|
+
inferenceGenerateBatchJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
409
|
+
inferenceRewriteJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
410
|
+
inferenceDecideJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
411
|
+
inferenceExtractJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
412
|
+
inferenceReadJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
413
|
+
inferenceTranscribeJson: KoffiFunc<(handle: unknown, request: object, out: object) => number>;
|
|
414
|
+
inferenceListModelsJson: KoffiFunc<(handle: unknown, out: object) => number>;
|
|
415
|
+
inferencePullJson: KoffiFunc<(handle: unknown, request: object, progress: unknown, progressContext: unknown, out: object) => number>;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Native stack for every libantfly call. koffi runs foreign calls on its own
|
|
419
|
+
* stacks (128 KiB for async calls by default), but libantfly needs the
|
|
420
|
+
* minimum documented in zig/CAPI.md "Thread Safety" (ANTFLY_MIN_THREAD_STACK_SIZE
|
|
421
|
+
* in antfly.h): 8 MiB. Smaller stacks crash inside the storage engine.
|
|
422
|
+
*/
|
|
423
|
+
declare const NATIVE_STACK_SIZE: number;
|
|
424
|
+
|
|
425
|
+
/** Accepted shapes for a uint64_t argument: plain number (safe up to 2^53) or bigint. */
|
|
426
|
+
type Uint64Like = number | bigint;
|
|
427
|
+
/** Accepted shapes for a JSON request body: an object (JSON.stringify'd), a raw JSON string, or raw bytes. */
|
|
428
|
+
type JsonInput = Record<string, unknown> | unknown[] | string | Uint8Array;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* An embedded Antfly database handle.
|
|
432
|
+
*
|
|
433
|
+
* A Database is safe for concurrent use from any number of in-flight
|
|
434
|
+
* promises: libantfly runs in serialized threading mode (see
|
|
435
|
+
* threadingMode()) -- reads run in parallel, writes on one handle queue
|
|
436
|
+
* behind each other, and schema/index changes wait for in-flight calls (see
|
|
437
|
+
* zig/CAPI.md "Thread Safety"). All handle operations are async and run on
|
|
438
|
+
* koffi's worker thread pool so they never block the event loop; see the
|
|
439
|
+
* package README for a note on koffi's threadpool size.
|
|
440
|
+
*
|
|
441
|
+
* close() waits for every call this binding has dispatched (queued or
|
|
442
|
+
* in-flight) to finish before freeing the native handle, and rejects new
|
|
443
|
+
* calls immediately once close() has started. Node's own async FFI queueing
|
|
444
|
+
* means a call can be queued but not yet "entered" the C library when
|
|
445
|
+
* close() runs; libantfly's own close only drains calls that already entered
|
|
446
|
+
* it, so this extra bookkeeping is required to avoid a use-after-free.
|
|
447
|
+
*/
|
|
448
|
+
declare class Database implements AsyncDisposable {
|
|
449
|
+
#private;
|
|
450
|
+
readonly owner?: Database | undefined;
|
|
451
|
+
/** @internal use open()/create()/openHosted()/etc. instead of the constructor. */
|
|
452
|
+
constructor(native: NativeLibrary, handle: unknown, owner?: Database | undefined);
|
|
453
|
+
sqlJson(request: JsonInput): Promise<unknown>;
|
|
454
|
+
createTable(name: string, schema: JsonInput): Promise<void>;
|
|
455
|
+
dropTable(name: string): Promise<void>;
|
|
456
|
+
listTables(): Promise<string[]>;
|
|
457
|
+
openSqlSession(): Promise<Uint64Like>;
|
|
458
|
+
closeSqlSession(id: Uint64Like): Promise<void>;
|
|
459
|
+
openSqlCursor(request: JsonInput): Promise<Uint64Like>;
|
|
460
|
+
fetchSqlCursor(id: Uint64Like, rows?: number): Promise<unknown>;
|
|
461
|
+
closeSqlCursor(id: Uint64Like): Promise<void>;
|
|
462
|
+
/** Idempotent; waits for in-flight calls before freeing the native handle. Calls made after close() rejects with InvalidArgumentError. */
|
|
463
|
+
close(): Promise<void>;
|
|
464
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
465
|
+
/** Open a table-scoped document/schema/index/enrichment handle. */
|
|
466
|
+
openTable(name: string): Promise<Database>;
|
|
467
|
+
statusRaw(): Promise<Buffer>;
|
|
468
|
+
status(): Promise<Status>;
|
|
469
|
+
capabilitiesRaw(): Promise<Buffer>;
|
|
470
|
+
capabilities(): Promise<Capabilities>;
|
|
471
|
+
checkRaw(): Promise<Buffer>;
|
|
472
|
+
check(): Promise<CheckReport>;
|
|
473
|
+
vacuumRaw(): Promise<Buffer>;
|
|
474
|
+
vacuum(): Promise<VacuumReport>;
|
|
475
|
+
compactRaw(): Promise<Buffer>;
|
|
476
|
+
compact(): Promise<CompactReport>;
|
|
477
|
+
copyStableSnapshotRaw(destPath: string, replace: boolean): Promise<Buffer>;
|
|
478
|
+
copyStableSnapshot(destPath: string, replace: boolean): Promise<StableSnapshotReport>;
|
|
479
|
+
pendingWorkStatsRaw(): Promise<Buffer>;
|
|
480
|
+
pendingWorkStats(): Promise<PendingWorkStatus>;
|
|
481
|
+
/** Drains pending enrichment and index work; returns no result (see runUntilIdleStatus for the post-drain report). */
|
|
482
|
+
runUntilIdle(): Promise<void>;
|
|
483
|
+
runUntilIdleStatusRaw(): Promise<Buffer>;
|
|
484
|
+
runUntilIdleStatus(): Promise<PendingWorkStatus>;
|
|
485
|
+
replayGeneratedEnrichmentsRaw(): Promise<Buffer>;
|
|
486
|
+
replayGeneratedEnrichments(): Promise<ReplayGeneratedEnrichmentsResult>;
|
|
487
|
+
/** Returns a portable Antfly backup archive (.afb) of this database, which restores or imports into either storage kind. */
|
|
488
|
+
backup(): Promise<Buffer>;
|
|
489
|
+
/** Imports a portable Antfly backup archive into this empty database. OutcomeUnknown means the live handle adopted the imported generation, but crash durability could not be confirmed; inspect the handle and do not retry automatically. */
|
|
490
|
+
importBackup(backup: Uint8Array): Promise<void>;
|
|
491
|
+
backupToFile(path: string): Promise<void>;
|
|
492
|
+
batch(writes: WriteIntent[], timestampNs: Uint64Like): Promise<void>;
|
|
493
|
+
batchJsonRaw(request: JsonInput): Promise<Buffer>;
|
|
494
|
+
batchJson(request: JsonInput): Promise<unknown>;
|
|
495
|
+
lookupRaw(key: string | Uint8Array): Promise<Buffer>;
|
|
496
|
+
lookup(key: string | Uint8Array): Promise<unknown>;
|
|
497
|
+
/** Raw stored bytes for key (antfly_db_get_raw), not JSON. */
|
|
498
|
+
getRaw(key: string | Uint8Array): Promise<Buffer>;
|
|
499
|
+
getSchemaRaw(): Promise<Buffer>;
|
|
500
|
+
getSchema(): Promise<unknown>;
|
|
501
|
+
setSchema(schema: JsonInput): Promise<void>;
|
|
502
|
+
renderResolverKey(resolver: string, request: JsonInput): Promise<unknown>;
|
|
503
|
+
/** Execute native memory policy using the shared action/body envelope. */
|
|
504
|
+
memory(space: string, request: JsonInput): Promise<unknown>;
|
|
505
|
+
resolveQuery(resolver: string, request: JsonInput): Promise<unknown>;
|
|
506
|
+
mergeResolverKeys(resolver: string, request: JsonInput): Promise<void>;
|
|
507
|
+
unmergeResolverKey(resolver: string, request: JsonInput): Promise<unknown>;
|
|
508
|
+
suppressResolverKeys(resolver: string, request: JsonInput): Promise<unknown>;
|
|
509
|
+
unsuppressResolverKey(resolver: string, request: JsonInput): Promise<unknown>;
|
|
510
|
+
resolverCuration(resolver?: string): Promise<unknown>;
|
|
511
|
+
resolverReviews(request: JsonInput): Promise<unknown>;
|
|
512
|
+
curateEntity(table: string, key: string, request: JsonInput): Promise<unknown>;
|
|
513
|
+
listResolverIdentities(): Promise<unknown>;
|
|
514
|
+
setResolverNamespace(resolver: string, request: JsonInput): Promise<void>;
|
|
515
|
+
dropResolverIdentity(resolver: string): Promise<boolean>;
|
|
516
|
+
listIndexesRaw(): Promise<Buffer>;
|
|
517
|
+
listIndexes(): Promise<unknown>;
|
|
518
|
+
addIndex(config: JsonInput): Promise<void>;
|
|
519
|
+
deleteIndex(name: string): Promise<boolean>;
|
|
520
|
+
listEnrichmentsRaw(): Promise<Buffer>;
|
|
521
|
+
listEnrichments(): Promise<unknown>;
|
|
522
|
+
addEnrichment(config: JsonInput): Promise<void>;
|
|
523
|
+
deleteEnrichment(kind: string, name: string): Promise<boolean>;
|
|
524
|
+
scanRaw(request: JsonInput): Promise<Buffer>;
|
|
525
|
+
scan(request: JsonInput): Promise<unknown>;
|
|
526
|
+
statsRaw(): Promise<Buffer>;
|
|
527
|
+
stats(): Promise<unknown>;
|
|
528
|
+
searchRaw(request: JsonInput): Promise<Buffer>;
|
|
529
|
+
search(request: JsonInput): Promise<unknown>;
|
|
530
|
+
denseSearchWire(request: Uint8Array): Promise<Buffer>;
|
|
531
|
+
textMatchWire(request: Uint8Array): Promise<Buffer>;
|
|
532
|
+
textTermWire(request: Uint8Array): Promise<Buffer>;
|
|
533
|
+
textMatchPhraseWire(request: Uint8Array): Promise<Buffer>;
|
|
534
|
+
aggregateHitsRaw(request: JsonInput): Promise<Buffer>;
|
|
535
|
+
aggregateHits(request: JsonInput): Promise<unknown>;
|
|
536
|
+
lookupArtifactRaw(artifactIdBase64: string): Promise<Buffer>;
|
|
537
|
+
lookupArtifact(artifactIdBase64: string): Promise<unknown>;
|
|
538
|
+
extractEnrichmentsRaw(request: JsonInput): Promise<Buffer>;
|
|
539
|
+
extractEnrichments(request: JsonInput): Promise<unknown>;
|
|
540
|
+
computeEnrichmentsRaw(request: JsonInput): Promise<Buffer>;
|
|
541
|
+
computeEnrichments(request: JsonInput): Promise<unknown>;
|
|
542
|
+
edgesRaw(indexName: string, key: string, edgeType: string, direction: number): Promise<Buffer>;
|
|
543
|
+
edges(indexName: string, key: string, edgeType: string, direction: number): Promise<unknown>;
|
|
544
|
+
neighborsRaw(indexName: string, key: string, edgeType: string, direction: number): Promise<Buffer>;
|
|
545
|
+
neighbors(indexName: string, key: string, edgeType: string, direction: number): Promise<unknown>;
|
|
546
|
+
traverseEdgesRaw(request: JsonInput): Promise<Buffer>;
|
|
547
|
+
traverseEdges(request: JsonInput): Promise<unknown>;
|
|
548
|
+
executeGraphQueriesRaw(request: JsonInput): Promise<Buffer>;
|
|
549
|
+
executeGraphQueries(request: JsonInput): Promise<unknown>;
|
|
550
|
+
findShortestPathRaw(request: JsonInput): Promise<Buffer>;
|
|
551
|
+
findShortestPath(request: JsonInput): Promise<unknown>;
|
|
552
|
+
findKShortestPathsRaw(request: JsonInput): Promise<Buffer>;
|
|
553
|
+
findKShortestPaths(request: JsonInput): Promise<unknown>;
|
|
554
|
+
matchPatternRaw(request: JsonInput): Promise<Buffer>;
|
|
555
|
+
matchPattern(request: JsonInput): Promise<unknown>;
|
|
556
|
+
beginTransaction(txnId: Uint8Array | string, timestampNs: Uint64Like, participants?: string[]): Promise<void>;
|
|
557
|
+
writeTransaction(txnId: Uint8Array | string, writes: WriteIntent[]): Promise<void>;
|
|
558
|
+
resolveTransaction(txnId: Uint8Array | string, status: TxnStatus, commitVersion?: Uint64Like): Promise<void>;
|
|
559
|
+
transactionStatus(txnId: Uint8Array | string): Promise<TxnStatus>;
|
|
560
|
+
commitVersion(txnId: Uint8Array | string): Promise<bigint>;
|
|
561
|
+
}
|
|
562
|
+
/** Opens an existing native Antfly Lite database file for writing. */
|
|
563
|
+
declare function open(path: string): Promise<Database>;
|
|
564
|
+
/** Creates a new native Antfly Lite database file for writing. */
|
|
565
|
+
declare function create(path: string): Promise<Database>;
|
|
566
|
+
/** Opens an existing Antfly Lite database file read-only. */
|
|
567
|
+
declare function openReadonly(path: string): Promise<Database>;
|
|
568
|
+
/** Opens enough of an Antfly Lite database to read status. */
|
|
569
|
+
declare function openStatusOnly(path: string): Promise<Database>;
|
|
570
|
+
/** Opens an Antfly Lite database using explicit C ABI options. */
|
|
571
|
+
declare function openWithOptions(path: string, options?: OpenOptions): Promise<Database>;
|
|
572
|
+
/** Creates an Antfly Lite database using explicit C ABI options. */
|
|
573
|
+
declare function createWithOptions(path: string, options?: OpenOptions): Promise<Database>;
|
|
574
|
+
/**
|
|
575
|
+
* Opens an existing Antfly Lite database in hosted/manual maintenance mode.
|
|
576
|
+
* In this profile callers drive pending work explicitly with runUntilIdle.
|
|
577
|
+
*/
|
|
578
|
+
declare function openHosted(path: string): Promise<Database>;
|
|
579
|
+
/**
|
|
580
|
+
* Creates a new Antfly Lite database in hosted/manual maintenance mode. In
|
|
581
|
+
* this profile callers drive pending work explicitly with runUntilIdle.
|
|
582
|
+
*/
|
|
583
|
+
declare function createHosted(path: string): Promise<Database>;
|
|
584
|
+
|
|
585
|
+
export { openWithOptions as A, platformLibraryFileName as B, type CheckReport as C, Database as D, resolveLibrary as E, GraphDirection as G, type InferenceOptions as I, type JsonInput as J, LibraryNotFoundError as L, type MemoryAdmissionStats as M, type NativeLibrary as N, OpenMode as O, type PullProgress as P, type RestoreOptions as R, type StableSnapshotReport as S, THREADING_SERIALIZED as T, type Uint64Like as U, type VacuumReport as V, type WriteIntent as W, type Capabilities as a, type CompactReport as b, InferenceMode as c, type InferenceStatus as d, type LibrarySource as e, NATIVE_STACK_SIZE as f, type OpenOptions as g, type PendingWorkStatus as h, Profile as i, type ReplayGeneratedEnrichmentsResult as j, type ResolvedLibrary as k, SUPPORTED_ABI_VERSION as l, type Status as m, Storage as n, type StorageStatus as o, type TTLCleanupOptions as p, TxnStatus as q, UnsupportedPlatformError as r, create as s, createHosted as t, createWithOptions as u, embeddedPlatformPackageName as v, open as w, openHosted as x, openReadonly as y, openStatusOnly as z };
|