@delali/narsil 0.3.1-next.72 → 0.3.1-next.74

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.
Files changed (70) hide show
  1. package/README.md +2 -2
  2. package/dist/adapters/filesystem.mjs +1 -1
  3. package/dist/adapters/indexeddb.mjs +1 -1
  4. package/dist/{capabilities-D6gjjQyA.d.ts → capabilities-CAMzmkAg.d.ts} +19 -4
  5. package/dist/{chunk-P2ZZN32C.mjs → chunk-2E35UM3G.mjs} +2 -12
  6. package/dist/chunk-3DDUNI6N.mjs +48 -0
  7. package/dist/{chunk-KZTI25D3.mjs → chunk-4MQ5F4IL.mjs} +1 -1
  8. package/dist/{chunk-HVJYTKK7.mjs → chunk-BVBIQQKG.mjs} +947 -1327
  9. package/dist/{chunk-2X2ZQOAB.mjs → chunk-CTOSGRM7.mjs} +101 -21
  10. package/dist/{chunk-7QMTA7AA.mjs → chunk-CUZOX6CN.mjs} +7784 -4276
  11. package/dist/chunk-I23G3IZC.mjs +593 -0
  12. package/dist/{chunk-RV77FR2F.mjs → chunk-I64LXKO3.mjs} +0 -1
  13. package/dist/chunk-KEHK2O6P.mjs +13 -0
  14. package/dist/{chunk-CVPA5Q7R.mjs → chunk-LX4JERXI.mjs} +9 -6
  15. package/dist/{chunk-EDMCZLSJ.mjs → chunk-NOZUQM7J.mjs} +193 -13
  16. package/dist/{chunk-LCCL6EEH.mjs → chunk-PO53FV4Q.mjs} +93 -94
  17. package/dist/chunk-T5ZWEWVD.mjs +658 -0
  18. package/dist/{chunk-Y52WZWAU.mjs → chunk-TVFLHM7M.mjs} +4 -4
  19. package/dist/{chunk-QR4OKRVY.mjs → chunk-VKX2BPXD.mjs} +147 -642
  20. package/dist/{chunk-3HQPUCCT.mjs → chunk-XW25X6AU.mjs} +66 -237
  21. package/dist/{chunk-M6XF5HDE.mjs → chunk-Z3DQPOJQ.mjs} +127 -30
  22. package/dist/{client-C2TiW29y.d.ts → client-C-I70ArH.d.ts} +77 -26
  23. package/dist/client.d.ts +9 -9
  24. package/dist/client.mjs +44 -22
  25. package/dist/{config-BLguB-om.d.ts → config-C6Iw5rCX.d.ts} +11 -4
  26. package/dist/{config-C7Ip8Ife.d.ts → config-DJPH3IQB.d.ts} +11 -2
  27. package/dist/direct-executor-KFAGILJC.mjs +17 -0
  28. package/dist/distribution/coordinator/etcd.d.ts +29 -16
  29. package/dist/distribution/coordinator/etcd.mjs +162 -75
  30. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  31. package/dist/distribution/transport/grpc.d.ts +2 -2
  32. package/dist/distribution/transport/grpc.mjs +22 -2
  33. package/dist/distribution/transport/in-memory.d.ts +2 -2
  34. package/dist/distribution/transport/in-memory.mjs +6 -3
  35. package/dist/distribution/transport/tcp.d.ts +2 -2
  36. package/dist/distribution/transport/tcp.mjs +40 -16
  37. package/dist/distribution.d.ts +9 -9
  38. package/dist/distribution.mjs +647 -366
  39. package/dist/embeddings/openai.mjs +1 -1
  40. package/dist/{engine-Dm4446j1.d.ts → engine-B8eRPO7m.d.ts} +97 -188
  41. package/dist/index.browser.mjs +12132 -8592
  42. package/dist/index.d.ts +27 -8
  43. package/dist/index.mjs +15 -14
  44. package/dist/{memory-CKHTU1CL.d.ts → memory-DJEwWoCi.d.ts} +1204 -968
  45. package/dist/partial-words-DTIHO8G4.d.ts +19 -0
  46. package/dist/partial-words.d.ts +22 -0
  47. package/dist/partial-words.mjs +11 -0
  48. package/dist/pattern.mjs +1 -1
  49. package/dist/persistence/durability/checkpoint-worker.d.ts +57 -29
  50. package/dist/persistence/durability/checkpoint-worker.mjs +26 -16
  51. package/dist/react.d.ts +7 -7
  52. package/dist/react.mjs +0 -1
  53. package/dist/{schema-BBOCdhND.d.ts → schema-DgyDijhf.d.ts} +6 -2
  54. package/dist/server.d.ts +11 -11
  55. package/dist/server.mjs +212 -32
  56. package/dist/{tasks-BECd0b__.d.ts → tasks-BVmAKYBh.d.ts} +3 -3
  57. package/dist/{thread-IBSIZZ6W.mjs → thread-W6DPKEF6.mjs} +82 -21
  58. package/dist/{types-BQDlIvfS.d.ts → types-B3b68nfF.d.ts} +1 -1
  59. package/dist/{types-D5OwhtsQ.d.ts → types-Cb9kiY5P.d.ts} +1 -1
  60. package/dist/{types-BiUmaiWT.d.ts → types-ChrVy4lH.d.ts} +1 -1
  61. package/dist/vector/search-worker.d.ts +1 -1
  62. package/dist/vector/search-worker.mjs +4 -3
  63. package/dist/workers/entry.mjs +4 -4
  64. package/package.json +15 -7
  65. package/dist/chunk-3L4U6EJQ.mjs +0 -49
  66. package/dist/chunk-IFBKLBGB.mjs +0 -7
  67. package/dist/chunk-XZ4PAREY.mjs +0 -25
  68. package/dist/direct-executor-SVCHXR74.mjs +0 -14
  69. package/dist/serialization/crc32-worker.d.ts +0 -20
  70. package/dist/serialization/crc32-worker.mjs +0 -62
package/README.md CHANGED
@@ -106,7 +106,7 @@ Every hit holds the document, its id, and its BM25 score. Beside the hits, `resu
106
106
 
107
107
  **Geosearch.** [Geo filters](https://github.com/assetcorp/narsil/blob/main/docs/geosearch.md) match documents by radius, using Haversine or Vincenty distance, or by polygon containment. You can combine a geo filter with every other query feature.
108
108
 
109
- **Storage.** [Persistence adapters](https://github.com/assetcorp/narsil/blob/main/docs/persistence-and-durability.md) store indexes on the filesystem, in IndexedDB, in memory, or in a backend of your own. With durability on, the engine keeps a write-ahead log with periodic checkpoints and recovers on its own after a crash. A snapshot captures a whole index as one portable byte array.
109
+ **Storage.** [Persistence adapters](https://github.com/assetcorp/narsil/blob/main/docs/persistence-and-durability.md) store indexes on the filesystem, in IndexedDB, in memory, or in a backend of your own. With durability on, the engine keeps a write-ahead log with periodic checkpoints and recovers on its own after a crash. You can stream a whole index into a portable snapshot archive, or export its documents as JSON Lines to move the index across releases.
110
110
 
111
111
  **Scale.** The engine routes each document to a [partition](https://github.com/assetcorp/narsil/blob/main/docs/partitions-and-workers.md) by a deterministic hash. When you call `rebalance()`, the engine reshapes the partitions online and buffers incoming writes in a write-ahead queue. Once an index holds 1,000 documents, the engine serves keyword queries from worker copies on half its worker threads, while the HTTP server receives requests on the threads that hold those copies.
112
112
 
@@ -124,7 +124,7 @@ Every hit holds the document, its id, and its BM25 score. Beside the hits, `resu
124
124
  | [Hybrid search](https://github.com/assetcorp/narsil/blob/main/docs/hybrid-search.md) | Reciprocal rank fusion and linear blending of text and vector rankings |
125
125
  | [Geosearch](https://github.com/assetcorp/narsil/blob/main/docs/geosearch.md) | Radius and polygon filters, and the two distance formulas |
126
126
  | [Embedding adapters](https://github.com/assetcorp/narsil/blob/main/docs/embedding-adapters.md) | Automatic embedding on insert and query, named adapters, the bundled ones, and custom ones |
127
- | [Persistence and durability](https://github.com/assetcorp/narsil/blob/main/docs/persistence-and-durability.md) | Storage backends, the write-ahead log, checkpoints, recovery, and snapshots |
127
+ | [Persistence and durability](https://github.com/assetcorp/narsil/blob/main/docs/persistence-and-durability.md) | Storage backends, the write-ahead log, checkpoints, recovery, snapshots, document exports, and indexes from an earlier release |
128
128
  | [Partitions and workers](https://github.com/assetcorp/narsil/blob/main/docs/partitions-and-workers.md) | Partition routing, online rebalancing, worker copies, and multi-instance invalidation |
129
129
  | [Language support](https://github.com/assetcorp/narsil/blob/main/docs/language-support.md) | The 107 language modules, analysis revisions and rebuilds, and named tokenizers and stop words |
130
130
  | [HTTP server](https://github.com/assetcorp/narsil/blob/main/docs/http-server.md) | Wrapping an engine in a REST API, every route it serves, and long-running tasks |
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from '../chunk-RV77FR2F.mjs';
1
+ import { NarsilError, ErrorCodes } from '../chunk-I64LXKO3.mjs';
2
2
 
3
3
  // src/persistence/filesystem.ts
4
4
  var cachedFs = null;
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from '../chunk-RV77FR2F.mjs';
1
+ import { NarsilError, ErrorCodes } from '../chunk-I64LXKO3.mjs';
2
2
 
3
3
  // src/persistence/constants.ts
4
4
  var DEFAULT_INDEXEDDB_NAME = "narsil";
@@ -1,6 +1,6 @@
1
1
  import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { C as ClusterNamespace } from './config-BLguB-om.js';
3
- import { h as TaskStore } from './tasks-BECd0b__.js';
2
+ import { C as ClusterNamespace } from './config-C6Iw5rCX.js';
3
+ import { h as TaskStore } from './tasks-BVmAKYBh.js';
4
4
 
5
5
  /**
6
6
  * Context handed to {@link OnRequestHook} for every inbound request, captured
@@ -70,8 +70,15 @@ interface CorsOptions {
70
70
  interface ServerLimits {
71
71
  /** Cap for JSON request bodies (single doc, batch, search). Excess → 413. */
72
72
  maxBodyBytes?: number;
73
- /** Cap for the NDJSON import stream and binary restore body. Excess → 413. */
73
+ /** Cap for the NDJSON import stream. Excess → 413. */
74
74
  maxImportBytes?: number;
75
+ /** The server accepts a snapshot archive for `POST /indexes/{name}/restore`
76
+ * and a document export for `POST /indexes/{name}/import` of up to this many
77
+ * bytes, and it answers a larger upload with 413. The server writes each
78
+ * upload to a temporary file as the upload arrives, so it needs the same
79
+ * memory for an upload of any size. The default is 64 GiB, and 0 accepts an
80
+ * upload of any size. */
81
+ maxRestoreBytes?: number;
75
82
  /** Cap for a single NDJSON line, so one unterminated line cannot exhaust memory. Excess → 413. */
76
83
  maxLineBytes?: number;
77
84
  /** Documents handed to the engine per batch during NDJSON import; the loop yields between batches. */
@@ -255,6 +262,14 @@ declare const REBUILD_ANALYSIS_CAPABILITY = "indexes.rebuildAnalysis";
255
262
  * @public
256
263
  */
257
264
  declare const INDEX_LIFECYCLE_CAPABILITY = "indexes.lifecycle";
265
+ /**
266
+ * Marks a server that answers `GET /indexes/{name}/export` with a stream of a
267
+ * document export and imports an export sent to `POST /indexes/{name}/import`
268
+ * in a task.
269
+ *
270
+ * @public
271
+ */
272
+ declare const DOCUMENT_EXPORT_CAPABILITY = "indexes.documentExport";
258
273
  /**
259
274
  * Every capability this server announces at `/capabilities`.
260
275
  *
@@ -266,4 +281,4 @@ declare const INDEX_LIFECYCLE_CAPABILITY = "indexes.lifecycle";
266
281
  */
267
282
  declare const SERVER_CAPABILITIES: readonly string[];
268
283
 
269
- export { ASYNC_IMPORT_CAPABILITY as A, type CorsOptions as C, type ErrorEnvelope as E, INDEX_LIFECYCLE_CAPABILITY as I, type NarsilServer as N, type OnRequestHook as O, REBUILD_ANALYSIS_CAPABILITY as R, SERVER_CAPABILITIES as S, TASK_CANCEL_CAPABILITY as T, TASK_FILTER_CAPABILITY as a, type ServerOptions as b, type RequestContext as c, type RequestDenial as d, type ServerLimits as e };
284
+ export { ASYNC_IMPORT_CAPABILITY as A, type CorsOptions as C, DOCUMENT_EXPORT_CAPABILITY as D, type ErrorEnvelope as E, INDEX_LIFECYCLE_CAPABILITY as I, type NarsilServer as N, type OnRequestHook as O, REBUILD_ANALYSIS_CAPABILITY as R, SERVER_CAPABILITIES as S, TASK_CANCEL_CAPABILITY as T, TASK_FILTER_CAPABILITY as a, type ServerOptions as b, type RequestContext as c, type RequestDenial as d, type ServerLimits as e };
@@ -1,18 +1,8 @@
1
- import { NarsilError, ErrorCodes } from './chunk-RV77FR2F.mjs';
1
+ import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
2
2
  import { existsSync } from 'fs';
3
3
  import { createRequire } from 'module';
4
4
  import { join, dirname } from 'path';
5
5
 
6
- // src/vector/hnsw/constants.ts
7
- var MAX_LAYER_CAP = 32;
8
- var MAX_M = 512;
9
- var INITIAL_UPPER_SLOTS = 64;
10
- var INITIAL_LIST_CAPACITY = 64;
11
- var PLACEMENT_ROOM_REQUESTS = 8;
12
- var COMPACTION_TOMBSTONE_RATIO = 0.1;
13
- var COMPACTION_ABSOLUTE_THRESHOLD = 1e3;
14
- var DEFAULT_EF_SEARCH = 50;
15
-
16
6
  // src/vector/native/backend.ts
17
7
  var nativeSearchCoreEnabled = true;
18
8
  function nativeSearchCoreIsEnabled() {
@@ -136,4 +126,4 @@ function loadNativeCore() {
136
126
  return loaded;
137
127
  }
138
128
 
139
- export { COMPACTION_ABSOLUTE_THRESHOLD, COMPACTION_TOMBSTONE_RATIO, DEFAULT_EF_SEARCH, INITIAL_LIST_CAPACITY, INITIAL_UPPER_SLOTS, MAX_LAYER_CAP, MAX_M, PLACEMENT_ROOM_REQUESTS, loadNativeCore, nativeSearchCoreIsEnabled, noteFallback, requireSearchBackendSettings, stopUsingTheNativeSearchCore };
129
+ export { loadNativeCore, nativeSearchCoreIsEnabled, noteFallback, requireSearchBackendSettings, stopUsingTheNativeSearchCore };
@@ -0,0 +1,48 @@
1
+ // src/search/constants.ts
2
+ var RESULT_WINDOW = 1e4;
3
+ var DEFAULT_PAGE_SIZE = 10;
4
+ var MAX_CURSOR_LENGTH = 40960;
5
+ var MAX_SORT_FIELDS = 8;
6
+ var MAX_SORT_FIELD_NAME_LENGTH = 255;
7
+ var MAX_CURSOR_ANCHOR_CODE_POINTS = 512;
8
+ var PREFIX_MAX_EXPANSIONS = 50;
9
+ var PARTIAL_WORDS_ADDED_PER_QUERY = 50;
10
+ var PARTIAL_WORD_MIN_CODE_POINTS = 3;
11
+ var DEFAULT_FUZZY_PREFIX_LENGTH = 2;
12
+ var MAX_TOLERANCE = 10;
13
+ var MAX_PREFIX_LENGTH = 1024;
14
+ var DEFAULT_MAX_PER_GROUP = 1;
15
+ var DEFAULT_RANK_CONSTANT = 60;
16
+ var MIN_RANK_CONSTANT = 1;
17
+ var DEFAULT_LINEAR_ALPHA = 0.5;
18
+ var MIN_LINEAR_ALPHA = 0;
19
+ var MAX_LINEAR_ALPHA = 1;
20
+
21
+ // src/engine/constants.ts
22
+ var MIN_DOCUMENTS_FOR_SEGMENTS = 64;
23
+ var BATCH_CHUNK_SIZE = 1e3;
24
+ var DEFAULT_LIMIT = DEFAULT_PAGE_SIZE;
25
+ var DEFAULT_OFFSET = 0;
26
+ var INDEX_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
27
+ var ABSOLUTE_WINDOWS_PATH_PATTERN = /^[a-zA-Z]:[\\/]/;
28
+ var MODULE_URL_SCHEME_PATTERN = /^(file|https?|data|node):/;
29
+ var MAX_INDEX_NAME_LENGTH = 255;
30
+ var MAX_DOC_ID_LENGTH = 512;
31
+ var EXPORT_CHUNK_BYTES = 1048576;
32
+ var MAX_EXPORT_LINE_BYTES = 117443592;
33
+ var MAX_INDEX_CONFIGURATION_BYTES = 16777216;
34
+ var IMPORT_BATCH_DOCUMENTS = 1e3;
35
+ var MAX_IMPORT_REFUSALS_REPORTED = 1e3;
36
+ var MIN_SWEEP_INTERVAL_MS = 100;
37
+ var MAX_SWEEP_INTERVAL_MS = 6e4;
38
+ var HEAP_PRESSURE_WARNING_FRACTION = 0.9;
39
+ var HEAP_PRESSURE_REARM_FRACTION = 0.8;
40
+ var STATISTICS_BROADCAST_INTERVAL_MS = 5e3;
41
+ var FOREIGN_STATS_TTL_MS = 6e4;
42
+ var DEFAULT_SUGGEST_LIMIT = 10;
43
+ var MAX_SUGGEST_LIMIT = 100;
44
+ var SUGGEST_OVERSAMPLE_FACTOR = 1.5;
45
+ var SUGGEST_OVERSAMPLE_PADDING = 10;
46
+ var MAX_SUGGEST_SCATTER_LIMIT = Math.ceil(MAX_SUGGEST_LIMIT * SUGGEST_OVERSAMPLE_FACTOR) + SUGGEST_OVERSAMPLE_PADDING;
47
+
48
+ export { ABSOLUTE_WINDOWS_PATH_PATTERN, BATCH_CHUNK_SIZE, DEFAULT_FUZZY_PREFIX_LENGTH, DEFAULT_LIMIT, DEFAULT_LINEAR_ALPHA, DEFAULT_MAX_PER_GROUP, DEFAULT_OFFSET, DEFAULT_PAGE_SIZE, DEFAULT_RANK_CONSTANT, DEFAULT_SUGGEST_LIMIT, EXPORT_CHUNK_BYTES, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_REARM_FRACTION, HEAP_PRESSURE_WARNING_FRACTION, IMPORT_BATCH_DOCUMENTS, INDEX_NAME_PATTERN, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_CURSOR_LENGTH, MAX_DOC_ID_LENGTH, MAX_EXPORT_LINE_BYTES, MAX_IMPORT_REFUSALS_REPORTED, MAX_INDEX_CONFIGURATION_BYTES, MAX_INDEX_NAME_LENGTH, MAX_LINEAR_ALPHA, MAX_PREFIX_LENGTH, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, MAX_SWEEP_INTERVAL_MS, MAX_TOLERANCE, MIN_DOCUMENTS_FOR_SEGMENTS, MIN_LINEAR_ALPHA, MIN_RANK_CONSTANT, MIN_SWEEP_INTERVAL_MS, MODULE_URL_SCHEME_PATTERN, PARTIAL_WORDS_ADDED_PER_QUERY, PARTIAL_WORD_MIN_CODE_POINTS, PREFIX_MAX_EXPANSIONS, RESULT_WINDOW, STATISTICS_BROADCAST_INTERVAL_MS, SUGGEST_OVERSAMPLE_FACTOR, SUGGEST_OVERSAMPLE_PADDING };
@@ -1,5 +1,5 @@
1
1
  import { english } from './chunk-TGP5M5R7.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-RV77FR2F.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-I64LXKO3.mjs';
3
3
 
4
4
  // src/languages/registry.ts
5
5
  var languages = /* @__PURE__ */ new Map();