@delali/narsil 0.2.4-next.59 → 0.3.1-next.101
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/README.md +9 -8
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/{adapters-79OIa4xm.d.ts → adapters-BQFQ4PRz.d.ts} +27 -1
- package/dist/browser/chunk-BDOSMEEP.mjs +493 -0
- package/dist/browser/chunk-EJDUFWSO.mjs +602 -0
- package/dist/browser/chunk-HOZW3PKP.mjs +9 -0
- package/dist/browser/chunk-JOVZ6HMT.mjs +4358 -0
- package/dist/browser/chunk-JPTQZWJQ.mjs +10 -0
- package/dist/browser/chunk-KPJMDPHG.mjs +24558 -0
- package/dist/browser/chunk-PGIM3HIM.mjs +2743 -0
- package/dist/browser/chunk-RHG4O77A.mjs +206 -0
- package/dist/browser/chunk-RIJSLY2I.mjs +360 -0
- package/dist/browser/durability-wiring-SRUYT3VV.mjs +3875 -0
- package/dist/browser/module-CBB2ETYP.mjs +3111 -0
- package/dist/browser/release-76MXRPGV.mjs +33 -0
- package/dist/browser/replace-RURXTGVG.mjs +57 -0
- package/dist/browser/restore-queue-EEZQO6RF.mjs +35 -0
- package/dist/browser/runtime-7ZAHCHWR.mjs +557 -0
- package/dist/browser/snapshot-OAAA5UJ7.mjs +1210 -0
- package/dist/browser/write-7D6VIK6O.mjs +208 -0
- package/dist/{capabilities-DSsOGz6F.d.ts → capabilities-DiGlB6Sr.d.ts} +68 -7
- package/dist/chunk-2RIRGOUL.mjs +113 -0
- package/dist/chunk-37CD3OKS.mjs +87 -0
- package/dist/chunk-44W3CBNG.mjs +7 -0
- package/dist/chunk-46D6JQIG.mjs +426 -0
- package/dist/{chunk-VMRR3DQU.mjs → chunk-5JNA5SKS.mjs} +546 -35
- package/dist/chunk-747OHOUA.mjs +11 -0
- package/dist/chunk-75XIEF6H.mjs +126 -0
- package/dist/chunk-7X5JST5L.mjs +114 -0
- package/dist/chunk-BOFBLJFZ.mjs +209 -0
- package/dist/{chunk-USKFU7J5.mjs → chunk-BWJVNZPR.mjs} +8 -1
- package/dist/chunk-C7SLA6CM.mjs +19 -0
- package/dist/{chunk-POWOTUKJ.mjs → chunk-CQUMNIIG.mjs} +3 -6
- package/dist/chunk-CVXLLEQ3.mjs +1011 -0
- package/dist/chunk-DJHHF2L5.mjs +17 -0
- package/dist/chunk-E74YLAIG.mjs +24 -0
- package/dist/{chunk-UXNWQZST.mjs → chunk-EMRMGYRE.mjs} +236 -18
- package/dist/chunk-EWZLIYHV.mjs +57 -0
- package/dist/chunk-GBEEG5AN.mjs +35 -0
- package/dist/chunk-GES7U2PM.mjs +68 -0
- package/dist/chunk-HJSN7UYG.mjs +10 -0
- package/dist/chunk-HLPRHOSO.mjs +17 -0
- package/dist/chunk-HMFNFVP7.mjs +14 -0
- package/dist/chunk-J5QP52HA.mjs +1751 -0
- package/dist/{chunk-YNVIUGF5.mjs → chunk-JZVARCRZ.mjs} +3 -28
- package/dist/chunk-KOKM4PQN.mjs +52 -0
- package/dist/{chunk-B2TFROFX.mjs → chunk-KWTW6VTG.mjs} +465 -250
- package/dist/chunk-KZ3NX2P7.mjs +21 -0
- package/dist/chunk-L5ORED7V.mjs +25 -0
- package/dist/{chunk-THYRHHO2.mjs → chunk-LGAMKHA2.mjs} +2009 -2351
- package/dist/chunk-LKOB5COA.mjs +117 -0
- package/dist/chunk-LPQOEU5M.mjs +96 -0
- package/dist/{chunk-3LHGNRYE.mjs → chunk-LXWDQLTW.mjs} +7 -2
- package/dist/{chunk-L6TNPLAR.mjs → chunk-OEYI3KRB.mjs} +270 -108
- package/dist/chunk-OM362BRO.mjs +948 -0
- package/dist/chunk-OZDFA4WC.mjs +67 -0
- package/dist/chunk-P36MUFEJ.mjs +10 -0
- package/dist/chunk-PC2G76VW.mjs +2540 -0
- package/dist/{chunk-GCM3JFVA.mjs → chunk-PNEYIHA4.mjs} +11 -2
- package/dist/chunk-PNFKUCG3.mjs +1130 -0
- package/dist/chunk-Q6XWVUZX.mjs +44 -0
- package/dist/chunk-R27EMH5M.mjs +617 -0
- package/dist/{chunk-YMZCMH5M.mjs → chunk-R6A773WK.mjs} +19 -24
- package/dist/chunk-RF7PLG43.mjs +106 -0
- package/dist/chunk-RFBLQLLZ.mjs +16 -0
- package/dist/{chunk-Y3L5MDRV.mjs → chunk-RFVUDM5E.mjs} +17 -2
- package/dist/chunk-S7FL6UAH.mjs +521 -0
- package/dist/chunk-S7GNDRPS.mjs +651 -0
- package/dist/chunk-SP3NM3ZG.mjs +3537 -0
- package/dist/chunk-U476IXKQ.mjs +10 -0
- package/dist/chunk-UA3AUGNV.mjs +462 -0
- package/dist/chunk-UTG5YNXV.mjs +507 -0
- package/dist/chunk-VI4R6W25.mjs +8484 -0
- package/dist/chunk-WQBCBKY3.mjs +8 -0
- package/dist/{chunk-24RXHMEL.mjs → chunk-WVCOCKBU.mjs} +3794 -7570
- package/dist/chunk-X5CV2E2B.mjs +1 -0
- package/dist/chunk-XADZPPZI.mjs +614 -0
- package/dist/chunk-YEEQHT4V.mjs +212 -0
- package/dist/chunk-YTJCGKM4.mjs +56 -0
- package/dist/chunk-YYQIODMF.mjs +275 -0
- package/dist/chunk-ZI34TVOA.mjs +144 -0
- package/dist/{chunk-OOSIDHA3.mjs → chunk-ZKWYWW4Y.mjs} +1 -1
- package/dist/chunk-ZM7KU4YW.mjs +35 -0
- package/dist/{client-BQK6Tf6A.d.ts → client-BOStAkc5.d.ts} +160 -37
- package/dist/client.d.ts +11 -10
- package/dist/client.mjs +209 -45
- package/dist/{config-DmXULPa-.d.ts → config-Cjvzbs_j.d.ts} +51 -3
- package/dist/config-DffQlmRq.d.ts +421 -0
- package/dist/direct-executor-ZD64PPEZ.mjs +24 -0
- package/dist/distribution/coordinator/etcd.d.ts +79 -18
- package/dist/distribution/coordinator/etcd.mjs +553 -109
- package/dist/distribution/coordinator/in-memory.d.ts +4 -3
- package/dist/distribution/coordinator/in-memory.mjs +22 -3
- package/dist/distribution/transport/grpc.d.ts +2 -2
- package/dist/distribution/transport/grpc.mjs +79 -14
- package/dist/distribution/transport/in-memory.d.ts +2 -2
- package/dist/distribution/transport/in-memory.mjs +12 -7
- package/dist/distribution/transport/tcp.d.ts +2 -2
- package/dist/distribution/transport/tcp.mjs +50 -28
- package/dist/distribution.d.ts +144 -23
- package/dist/distribution.mjs +14479 -8173
- package/dist/durability-wiring-FEUBR5BT.mjs +3330 -0
- package/dist/embeddings/openai.d.ts +2 -2
- package/dist/embeddings/openai.mjs +22 -133
- package/dist/{engine-CIOyFozK.d.ts → engine-rC0vjjY-.d.ts} +165 -141
- package/dist/{memory-yFaVn2xZ.d.ts → events-DqOIg5xa.d.ts} +645 -136
- package/dist/{types-DAK7mnUZ.d.ts → index-Bkdt8nDw.d.ts} +182 -45
- package/dist/index.browser.mjs +4 -32180
- package/dist/index.d.ts +91 -20
- package/dist/index.mjs +33 -16
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +2 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/module-3S65MVCM.mjs +2151 -0
- package/dist/partial-words-DTIHO8G4.d.ts +19 -0
- package/dist/partial-words.d.ts +22 -0
- package/dist/partial-words.mjs +17 -0
- package/dist/pattern-Cledccbl.d.ts +18 -0
- package/dist/pattern.d.ts +22 -0
- package/dist/pattern.mjs +12 -0
- package/dist/persistence/durability/checkpoint-worker.d.ts +119 -72
- package/dist/persistence/durability/checkpoint-worker.mjs +51 -18
- package/dist/react.d.ts +279 -183
- package/dist/react.mjs +201 -48
- package/dist/release-BH3DKW3T.mjs +33 -0
- package/dist/replace-CEO5KJJ3.mjs +57 -0
- package/dist/rerank-K7C4WZFG.mjs +60 -0
- package/dist/rerankers/http.d.ts +50 -0
- package/dist/rerankers/http.mjs +104 -0
- package/dist/restore-queue-KQHA7ZV2.mjs +35 -0
- package/dist/runtime-6Y4ZYXOG.mjs +177 -0
- package/dist/{schema-d5Afu03A.d.ts → schema-4W_7tk1f.d.ts} +81 -11
- package/dist/server.d.ts +13 -12
- package/dist/server.mjs +611 -80
- package/dist/snapshot-QGZPODM5.mjs +799 -0
- package/dist/synonyms-CpOAHPa-.d.ts +52 -0
- package/dist/synonyms.d.ts +22 -0
- package/dist/synonyms.mjs +12 -0
- package/dist/{tasks-CH2Dod8w.d.ts → tasks-CwPTz-tP.d.ts} +10 -3
- package/dist/thread-N3IUGUS3.mjs +697 -0
- package/dist/{types-BQDlIvfS.d.ts → types-2qoitTXg.d.ts} +1 -1
- package/dist/{types-D5OwhtsQ.d.ts → types-Cz5okLml.d.ts} +2 -2
- package/dist/vector/search-worker.d.ts +46 -4
- package/dist/vector/search-worker.mjs +21 -11
- package/dist/workers/entry.mjs +9 -6
- package/dist/write-U5RI7MAX.mjs +241 -0
- package/package.json +55 -9
- package/dist/chunk-3L4U6EJQ.mjs +0 -49
- package/dist/chunk-IFBKLBGB.mjs +0 -7
- package/dist/chunk-ORBLD3EL.mjs +0 -6
- package/dist/chunk-U7KYW4BA.mjs +0 -135
- package/dist/chunk-ZJ4CSAB2.mjs +0 -13
- package/dist/chunk-ZNZBXMP5.mjs +0 -2117
- package/dist/chunk-ZZT3EAUC.mjs +0 -11168
- package/dist/config-BhldZgaK.d.ts +0 -194
- package/dist/direct-executor-ALAVE7FC.mjs +0 -12
- package/dist/serialization/crc32-worker.d.ts +0 -20
- package/dist/serialization/crc32-worker.mjs +0 -62
- package/dist/simd-DW5AtJ6B.d.ts +0 -41
- package/dist/thread-DYHEQRVY.mjs +0 -402
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Narsil is an open source search engine with full-text, vector, hybrid, and geose
|
|
|
15
15
|
The engine partitions large indexes across workers and merges the results of the partitions into a single ranked list. This TypeScript package is the reference implementation of the `.nrsl` format, so a second implementation in Go or Rust is the headline item on the [roadmap](https://github.com/assetcorp/narsil/blob/main/ROADMAP.md).
|
|
16
16
|
|
|
17
17
|
<!-- BENCH:headline START -->
|
|
18
|
-
On BEIR SciFact, Narsil's BM25 ranking scores 0.681 nDCG@10, which is within 0.002 of the Anserini reference of 0.679. Elasticsearch scores 0.679 and OpenSearch scores 0.679 on the same queries. On SciFact, Narsil answers
|
|
18
|
+
On BEIR SciFact, Narsil's BM25 ranking scores 0.681 nDCG@10, which is within 0.002 of the Anserini reference of 0.679. Elasticsearch scores 0.679 and OpenSearch scores 0.679 on the same queries. On SciFact, Narsil answers 4,200 keyword queries a second at its peak, and OpenSearch follows with 3,027. On DBpedia entities 1M with every engine held at 0.99 recall, Narsil answers 670 vector queries a second at its peak, while OpenSearch leads with 869. With each engine's recommended production settings on the same set, Narsil answers 1,154 vector queries a second at its peak, and OpenSearch follows with 1,111. Narsil has the highest peak throughput in 16 of the 20 keyword, vector, and hybrid comparisons in the newest recorded run: 8 of 12 with every engine on equal settings, and all 8 with each engine's recommended production settings. The harness recorded these figures on 2026-09-28 in run `20260928T002255Z`. GCP c3-standard-8 hardware in us-central1-a, us-east1-b, and us-west1-a hosted the engines. You'll find every dataset, every engine's settings, and the full method in [`BENCHMARKS.md`](https://github.com/assetcorp/narsil/blob/main/BENCHMARKS.md).
|
|
19
19
|
<!-- BENCH:headline END -->
|
|
20
20
|
|
|
21
21
|
Try it in your browser at [narsil.sondelali.com/demo](https://narsil.sondelali.com/demo). Read the full documentation at [narsil.sondelali.com/docs](https://narsil.sondelali.com/docs).
|
|
@@ -100,17 +100,17 @@ Every hit holds the document, its id, and its BM25 score. Beside the hits, `resu
|
|
|
100
100
|
|
|
101
101
|
## Features
|
|
102
102
|
|
|
103
|
-
**Search.** For [full-text search](https://github.com/assetcorp/narsil/blob/main/docs/full-text-search.md), the engine scores with BM25 and supports field boosting, fuzzy matching through bounded Levenshtein distance, search as you type through last-word prefix matching, and term-coverage and score thresholds. You can combine a query with [filters, facets, sorting, grouping, cursor pagination, and pinned results](https://github.com/assetcorp/narsil/blob/main/docs/filters-facets-and-pagination.md).
|
|
103
|
+
**Search.** For [full-text search](https://github.com/assetcorp/narsil/blob/main/docs/full-text-search.md), the engine scores with BM25 and supports field boosting, fuzzy matching through bounded Levenshtein distance, search as you type through last-word prefix matching, and term-coverage and score thresholds. You can combine a query with [filters, facets, sorting, grouping, cursor pagination, and pinned results](https://github.com/assetcorp/narsil/blob/main/docs/filters-facets-and-pagination.md). On a field that you declare for [pattern search](https://github.com/assetcorp/narsil/blob/main/docs/filters-facets-and-pagination.md#pattern-tests), a filter can find text anywhere inside a value with `contains`, test the whole value against a wildcard pattern, look for a match of a regular expression, and accept a typo or two in an `eq` test. With [partial-word search](https://github.com/assetcorp/narsil/blob/main/docs/full-text-search.md#matching-inside-words), a query word also matches inside longer words, so a search for `proof` finds `waterproof`.
|
|
104
104
|
|
|
105
|
-
**Vector and hybrid retrieval.** For [vector search](https://github.com/assetcorp/narsil/blob/main/docs/vector-search.md), the engine compares vectors by cosine similarity, dot product, or Euclidean distance. It scans a field exactly until the field holds 1,024 vectors, a count that you can change, after which it builds an HNSW graph with optimised scalar quantization on by default. Outside a browser, on an arm64 or x64 machine under macOS, Linux, or Windows, the engine searches that graph through a [native core in C](https://github.com/assetcorp/narsil/blob/main/docs/vector-search.md#native-search-core), which returns the same results as its WebAssembly search. For [hybrid search](https://github.com/assetcorp/narsil/blob/main/docs/hybrid-search.md), the engine fuses BM25 and vector rankings through reciprocal rank fusion or linear blending. [Embedding adapters](https://github.com/assetcorp/narsil/blob/main/docs/embedding-adapters.md) turn text into vectors on insert and query, through OpenAI, local Transformers.js models, or an adapter of your own.
|
|
105
|
+
**Vector and hybrid retrieval.** For [vector search](https://github.com/assetcorp/narsil/blob/main/docs/vector-search.md), the engine compares vectors by cosine similarity, dot product, or Euclidean distance. It scans a field exactly until the field holds 1,024 vectors, a count that you can change, after which it builds an HNSW graph with optimised scalar quantization on by default. Outside a browser, on an arm64 or x64 machine under macOS, Linux, or Windows, the engine searches that graph through a [native core in C](https://github.com/assetcorp/narsil/blob/main/docs/vector-search.md#native-search-core), which returns the same results as its WebAssembly search. For [hybrid search](https://github.com/assetcorp/narsil/blob/main/docs/hybrid-search.md), the engine fuses BM25 and vector rankings through reciprocal rank fusion or linear blending. [Embedding adapters](https://github.com/assetcorp/narsil/blob/main/docs/embedding-adapters.md) turn text into vectors on insert and query, through OpenAI, local Transformers.js models, or an adapter of your own. A query can [rerank](https://github.com/assetcorp/narsil/blob/main/docs/reranking.md) its top hits with a cross-encoder, through a Cohere-compatible rerank service, a local Transformers.js model, or an adapter of your own.
|
|
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.
|
|
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
|
|
|
113
|
-
**Operations.** The [HTTP server](https://github.com/assetcorp/narsil/blob/main/docs/http-server.md) subpath wraps an engine in a REST API with health probes, bulk NDJSON import, snapshot and restore endpoints, and task-based long operations. The [client](https://github.com/assetcorp/narsil/blob/main/docs/client.md) subpath calls every one of those routes from a browser or from Node under the engine's own method names. The [React](https://github.com/assetcorp/narsil/blob/main/docs/react.md) subpath
|
|
113
|
+
**Operations.** The [HTTP server](https://github.com/assetcorp/narsil/blob/main/docs/http-server.md) subpath wraps an engine in a REST API with health probes, bulk NDJSON import, snapshot and restore endpoints, and task-based long operations. The [client](https://github.com/assetcorp/narsil/blob/main/docs/client.md) subpath calls every one of those routes from a browser or from Node under the engine's own method names. The [React](https://github.com/assetcorp/narsil/blob/main/docs/react.md) subpath turns the read methods into hooks that call either a client or an engine in the same page. For observability, you have [events, plugins, and memory reporting](https://github.com/assetcorp/narsil/blob/main/docs/observability.md). [Language modules](https://github.com/assetcorp/narsil/blob/main/docs/language-support.md) cover 107 languages as separate entry points, including 20 African languages.
|
|
114
114
|
|
|
115
115
|
## Documentation
|
|
116
116
|
|
|
@@ -124,13 +124,14 @@ 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
|
-
| [
|
|
127
|
+
| [Reranking](https://github.com/assetcorp/narsil/blob/main/docs/reranking.md) | Reordering the top hits with a cross-encoder, the bundled rerank adapters, and custom ones |
|
|
128
|
+
| [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
129
|
| [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
130
|
| [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
131
|
| [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 |
|
|
131
132
|
| [Cluster mode](https://github.com/assetcorp/narsil/blob/main/docs/cluster.md) | Multi-node indexes: nodes and roles, replication, routed writes, distributed searches and reads, and the calls that fail in a cluster |
|
|
132
133
|
| [Client](https://github.com/assetcorp/narsil/blob/main/docs/client.md) | Reaching a server from a browser or Node, following a task, and the codes it raises |
|
|
133
|
-
| [React](https://github.com/assetcorp/narsil/blob/main/docs/react.md) | The hooks over the
|
|
134
|
+
| [React](https://github.com/assetcorp/narsil/blob/main/docs/react.md) | The hooks over a client or an engine in the page, one shared request per key, and loading a corpus from a component |
|
|
134
135
|
| [Observability](https://github.com/assetcorp/narsil/blob/main/docs/observability.md) | Plugin hooks, engine events, and memory reporting |
|
|
135
136
|
| [Errors](https://github.com/assetcorp/narsil/blob/main/docs/errors.md) | The codes you handle most often, and the three sets that `NarsilError.code` covers |
|
|
136
137
|
|
|
@@ -146,7 +147,7 @@ The [specification](https://github.com/assetcorp/narsil/tree/main/packages/spec)
|
|
|
146
147
|
|
|
147
148
|
## Distribution
|
|
148
149
|
|
|
149
|
-
`@delali/narsil/distribution` holds Narsil's multi-node cluster mode: nodes and roles, replication, coordinator adapters for etcd and in-process testing, TCP and gRPC transports with mutual TLS, and distributed query routing. A cluster node can create, drop, clear, write, update, search, list, count, and suggest across every partition. The [cluster dashboard example](https://github.com/assetcorp/narsil/tree/main/packages/ts/examples/cluster-dashboard) starts three nodes against etcd and shows the state of each partition while you cut the network links.
|
|
150
|
+
`@delali/narsil/distribution` holds Narsil's multi-node cluster mode: nodes and roles, replication, coordinator adapters for etcd and in-process testing, TCP and gRPC transports with mutual TLS, and distributed query routing. A cluster node can create, drop, clear, write, update, search, list, count, and suggest across every partition, and it can change the replication factor and the partition count of an index. A node with a durability directory keeps its id there across restarts, and the etcd coordinator connects over TLS with a user and a password. A node that the HTTP server fronts reports the health of the cluster and its own Prometheus metrics. The [cluster dashboard example](https://github.com/assetcorp/narsil/tree/main/packages/ts/examples/cluster-dashboard) starts three nodes against etcd and shows the state of each partition while you cut the network links. The [cluster guide](https://github.com/assetcorp/narsil/blob/main/docs/cluster.md) covers the API, including the packages that the etcd coordinator and the gRPC transport each need. For the contract that every implementation must uphold, read [`packages/spec/distribution`](https://github.com/assetcorp/narsil/tree/main/packages/spec/distribution).
|
|
150
151
|
|
|
151
152
|
## Search quality
|
|
152
153
|
|
|
@@ -145,5 +145,31 @@ interface EmbeddingAdapter {
|
|
|
145
145
|
/** Releases whatever the adapter holds open, such as a model or a connection pool. */
|
|
146
146
|
shutdown?(): Promise<void>;
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Scores the top hits of a query with a second model, such as a cross-encoder
|
|
150
|
+
* that reads the query and each document together, so that a query can
|
|
151
|
+
* reorder its first-stage ranking.
|
|
152
|
+
*
|
|
153
|
+
* Register one under a name through {@link NarsilConfig.rerankAdapters} or
|
|
154
|
+
* {@link AdapterRegistrationOperations.registerRerankAdapter}, and give that
|
|
155
|
+
* name in a query's `rerank.adapter`.
|
|
156
|
+
*
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
interface RerankAdapter {
|
|
160
|
+
/**
|
|
161
|
+
* Scores every document against one query.
|
|
162
|
+
*
|
|
163
|
+
* @param query - The text that the model compares each document with.
|
|
164
|
+
* @param documents - The text of each document, which is an empty string
|
|
165
|
+
* where a document holds no text in the reranked fields.
|
|
166
|
+
* @param signal - Aborts a call that the engine no longer needs.
|
|
167
|
+
* @returns One finite score per document, in the order of `documents`,
|
|
168
|
+
* where a higher score marks a more relevant document.
|
|
169
|
+
*/
|
|
170
|
+
rerank(query: string, documents: string[], signal?: AbortSignal): Promise<number[]>;
|
|
171
|
+
/** Releases whatever the adapter holds open, such as a model or a connection pool. The engine calls it once as it shuts down. */
|
|
172
|
+
shutdown?(): Promise<void>;
|
|
173
|
+
}
|
|
148
174
|
|
|
149
|
-
export type { EmbeddingAdapter as E, InvalidationAdapter as I, PersistenceAdapter as P, InvalidationEvent as a, PartitionStatistics as b };
|
|
175
|
+
export type { EmbeddingAdapter as E, InvalidationAdapter as I, PersistenceAdapter as P, RerankAdapter as R, InvalidationEvent as a, PartitionStatistics as b };
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import { NarsilError, ErrorCodes } from './chunk-RHG4O77A.mjs';
|
|
2
|
+
|
|
3
|
+
// src/serialization/constants.ts
|
|
4
|
+
var CHECKSUM_YIELD_CHUNK_BYTES = 4 * 1024 * 1024;
|
|
5
|
+
var NATIVE_CRC32_MIN_BYTES = 16;
|
|
6
|
+
var MAX_FILE_BYTES = 2147483647;
|
|
7
|
+
var MAX_DOCUMENT_ENCODING_DEPTH = 100;
|
|
8
|
+
var DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES = 1048576;
|
|
9
|
+
var VALID_HNSW_METRICS = /* @__PURE__ */ new Set(["cosine", "dotProduct", "euclidean"]);
|
|
10
|
+
|
|
11
|
+
// src/runtime/simd-support.ts
|
|
12
|
+
var SIMD_PROBE_MODULE = new Uint8Array([
|
|
13
|
+
0,
|
|
14
|
+
97,
|
|
15
|
+
115,
|
|
16
|
+
109,
|
|
17
|
+
1,
|
|
18
|
+
0,
|
|
19
|
+
0,
|
|
20
|
+
0,
|
|
21
|
+
1,
|
|
22
|
+
5,
|
|
23
|
+
1,
|
|
24
|
+
96,
|
|
25
|
+
0,
|
|
26
|
+
1,
|
|
27
|
+
123,
|
|
28
|
+
3,
|
|
29
|
+
2,
|
|
30
|
+
1,
|
|
31
|
+
0,
|
|
32
|
+
10,
|
|
33
|
+
10,
|
|
34
|
+
1,
|
|
35
|
+
8,
|
|
36
|
+
0,
|
|
37
|
+
65,
|
|
38
|
+
0,
|
|
39
|
+
253,
|
|
40
|
+
15,
|
|
41
|
+
253,
|
|
42
|
+
98,
|
|
43
|
+
11
|
|
44
|
+
]);
|
|
45
|
+
function runtimeStartsSimdModule() {
|
|
46
|
+
try {
|
|
47
|
+
if (typeof WebAssembly === "undefined") return false;
|
|
48
|
+
new WebAssembly.Instance(new WebAssembly.Module(SIMD_PROBE_MODULE));
|
|
49
|
+
return true;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
var simdAvailable = runtimeStartsSimdModule();
|
|
55
|
+
function isSimdAvailable() {
|
|
56
|
+
return simdAvailable;
|
|
57
|
+
}
|
|
58
|
+
function markSimdUnavailable() {
|
|
59
|
+
simdAvailable = false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/core/ordering/code-points.ts
|
|
63
|
+
function exceedsCodePoints(value, maximum) {
|
|
64
|
+
if (value.length <= maximum) return false;
|
|
65
|
+
let counted = 0;
|
|
66
|
+
let i = 0;
|
|
67
|
+
while (i < value.length) {
|
|
68
|
+
const unit = value.charCodeAt(i);
|
|
69
|
+
if (unit >= 55296 && unit < 56320 && i + 1 < value.length) {
|
|
70
|
+
const low = value.charCodeAt(i + 1);
|
|
71
|
+
if (low >= 56320 && low < 57344) i++;
|
|
72
|
+
}
|
|
73
|
+
i++;
|
|
74
|
+
counted++;
|
|
75
|
+
if (counted > maximum) return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
var SURROGATE_UNIT = /[\ud800-\udfff]/;
|
|
80
|
+
function holdsUnpairedSurrogate(value) {
|
|
81
|
+
if (!SURROGATE_UNIT.test(value)) return false;
|
|
82
|
+
for (let i = 0; i < value.length; i++) {
|
|
83
|
+
const unit = value.charCodeAt(i);
|
|
84
|
+
if (unit < 55296 || unit >= 57344) continue;
|
|
85
|
+
if (unit >= 56320) return true;
|
|
86
|
+
const low = value.charCodeAt(i + 1);
|
|
87
|
+
if (!(low >= 56320 && low < 57344)) return true;
|
|
88
|
+
i++;
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
function codePointCount(value) {
|
|
93
|
+
let counted = 0;
|
|
94
|
+
for (let i = 0; i < value.length; i++) {
|
|
95
|
+
const unit = value.charCodeAt(i);
|
|
96
|
+
if (unit >= 55296 && unit < 56320 && i + 1 < value.length) {
|
|
97
|
+
const low = value.charCodeAt(i + 1);
|
|
98
|
+
if (low >= 56320 && low < 57344) i++;
|
|
99
|
+
}
|
|
100
|
+
counted++;
|
|
101
|
+
}
|
|
102
|
+
return counted;
|
|
103
|
+
}
|
|
104
|
+
function adjustUtf16Unit(unit) {
|
|
105
|
+
if (unit < 55296) return unit;
|
|
106
|
+
if (unit < 57344) return unit + 8192;
|
|
107
|
+
return unit - 2048;
|
|
108
|
+
}
|
|
109
|
+
function compareCodePoints(a, b) {
|
|
110
|
+
const shorter = a.length < b.length ? a.length : b.length;
|
|
111
|
+
let i = 0;
|
|
112
|
+
while (i < shorter && a.charCodeAt(i) === b.charCodeAt(i)) i++;
|
|
113
|
+
if (i === shorter) return a.length - b.length;
|
|
114
|
+
return adjustUtf16Unit(a.charCodeAt(i)) - adjustUtf16Unit(b.charCodeAt(i));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/core/ordering/fold-table.ts
|
|
118
|
+
var SINGLE_FOLDS = "1t,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;2j,lj;b,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;2,w;1,w;1,w;1,w;1,w;1,w;1,w;y,1;2,1;2,1;2,1;2,1;2,1;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1,-tzk;1,-tzk;1,-tzk;ggy,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;xy,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;3t,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;4d,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;2,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;2,13;1,13;1,13;1,13;1,13;1,13;1,13;2,13;1,13;1d7,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;4e,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;27v,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w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1,qf,n6,qh;5,qf,qh;6,qh,lk,lc;1,qh,lk,ld;3,qh,n6;1,qh,lk,n6;b,qt,lk,lc;1,qt,lk,ld;1,qp,lv;2,qt,n6;1,qt,lk,n6;b,67w,qh;1,qx,qh;1,r2,qh;2,qx,n6;1,qx,n6,qh;5,qx,qh;179g,2u,2u;1,2u,2x;1,2u,30;1,2u,2u,2x;1,2u,2u,30;1,37,38;1,37,38;d,12s,12u;1,12s,12d;1,12s,12j;1,132,12u;1,12s,12l;";
|
|
120
|
+
var singleTable = null;
|
|
121
|
+
var multiTable = null;
|
|
122
|
+
function singleFoldTable() {
|
|
123
|
+
if (singleTable === null) {
|
|
124
|
+
singleTable = /* @__PURE__ */ new Map();
|
|
125
|
+
let source = 0;
|
|
126
|
+
for (const entry of SINGLE_FOLDS.split(";")) {
|
|
127
|
+
if (entry.length === 0) continue;
|
|
128
|
+
const [delta, offset] = entry.split(",");
|
|
129
|
+
source += Number.parseInt(delta, 36);
|
|
130
|
+
singleTable.set(source, source + Number.parseInt(offset, 36));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return singleTable;
|
|
134
|
+
}
|
|
135
|
+
function multiFoldTable() {
|
|
136
|
+
if (multiTable === null) {
|
|
137
|
+
multiTable = /* @__PURE__ */ new Map();
|
|
138
|
+
let source = 0;
|
|
139
|
+
for (const entry of MULTI_FOLDS.split(";")) {
|
|
140
|
+
if (entry.length === 0) continue;
|
|
141
|
+
const parts = entry.split(",");
|
|
142
|
+
source += Number.parseInt(parts[0], 36);
|
|
143
|
+
multiTable.set(
|
|
144
|
+
source,
|
|
145
|
+
parts.slice(1).map((cp) => Number.parseInt(cp, 36))
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return multiTable;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/core/ordering/fold-compare.ts
|
|
153
|
+
var EXHAUSTED = -1;
|
|
154
|
+
function foldOf(codePoint, single, multi) {
|
|
155
|
+
if (codePoint < 128) return codePoint >= 65 && codePoint <= 90 ? codePoint + 32 : codePoint;
|
|
156
|
+
return single.get(codePoint) ?? multi.get(codePoint) ?? codePoint;
|
|
157
|
+
}
|
|
158
|
+
function nextFoldedCodePoint(text, cursor, single, multi) {
|
|
159
|
+
if (cursor.pending !== null) {
|
|
160
|
+
const cp2 = cursor.pending[cursor.pendingIndex];
|
|
161
|
+
cursor.pendingIndex++;
|
|
162
|
+
if (cursor.pendingIndex === cursor.pending.length) {
|
|
163
|
+
cursor.pending = null;
|
|
164
|
+
cursor.pendingIndex = 0;
|
|
165
|
+
}
|
|
166
|
+
return cp2;
|
|
167
|
+
}
|
|
168
|
+
if (cursor.index >= text.length) return EXHAUSTED;
|
|
169
|
+
let cp = text.charCodeAt(cursor.index);
|
|
170
|
+
cursor.index++;
|
|
171
|
+
if (cp >= 55296 && cp < 56320 && cursor.index < text.length) {
|
|
172
|
+
const low = text.charCodeAt(cursor.index);
|
|
173
|
+
if (low >= 56320 && low < 57344) {
|
|
174
|
+
cp = 65536 + (cp - 55296 << 10) + (low - 56320);
|
|
175
|
+
cursor.index++;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const folded = foldOf(cp, single, multi);
|
|
179
|
+
if (typeof folded === "number") return folded;
|
|
180
|
+
if (folded.length > 1) {
|
|
181
|
+
cursor.pending = folded;
|
|
182
|
+
cursor.pendingIndex = 1;
|
|
183
|
+
}
|
|
184
|
+
return folded[0];
|
|
185
|
+
}
|
|
186
|
+
function compareCaseFolded(a, b) {
|
|
187
|
+
const shorter = a.length < b.length ? a.length : b.length;
|
|
188
|
+
let start = 0;
|
|
189
|
+
while (start < shorter && a.charCodeAt(start) === b.charCodeAt(start)) start++;
|
|
190
|
+
if (start === a.length && start === b.length) return 0;
|
|
191
|
+
if (start > 0) {
|
|
192
|
+
const previous = a.charCodeAt(start - 1);
|
|
193
|
+
if (previous >= 55296 && previous < 56320) start--;
|
|
194
|
+
}
|
|
195
|
+
const single = singleFoldTable();
|
|
196
|
+
const multi = multiFoldTable();
|
|
197
|
+
const aCursor = { index: start, pending: null, pendingIndex: 0 };
|
|
198
|
+
const bCursor = { index: start, pending: null, pendingIndex: 0 };
|
|
199
|
+
for (; ; ) {
|
|
200
|
+
const aCp = nextFoldedCodePoint(a, aCursor, single, multi);
|
|
201
|
+
const bCp = nextFoldedCodePoint(b, bCursor, single, multi);
|
|
202
|
+
if (aCp !== bCp) return aCp - bCp;
|
|
203
|
+
if (aCp === EXHAUSTED) return 0;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function compareSortStrings(a, b) {
|
|
207
|
+
const folded = compareCaseFolded(a, b);
|
|
208
|
+
if (folded !== 0) return folded;
|
|
209
|
+
return compareCodePoints(a, b);
|
|
210
|
+
}
|
|
211
|
+
function appendFoldedCodePoint(codePoint, out) {
|
|
212
|
+
const folded = foldOf(codePoint, singleFoldTable(), multiFoldTable());
|
|
213
|
+
if (typeof folded === "number") {
|
|
214
|
+
out.push(folded);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
for (const foldedCodePoint of folded) out.push(foldedCodePoint);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/core/ordering/constants.ts
|
|
221
|
+
var SORT_VALUE_MAX_CODE_POINTS = 512;
|
|
222
|
+
|
|
223
|
+
// src/core/ordering/sort-values.ts
|
|
224
|
+
var SORT_MODES = ["min", "max", "avg", "median"];
|
|
225
|
+
function isSortMode(value) {
|
|
226
|
+
return value === "min" || value === "max" || value === "avg" || value === "median";
|
|
227
|
+
}
|
|
228
|
+
function defaultSortMode(direction) {
|
|
229
|
+
return direction === "desc" ? "max" : "min";
|
|
230
|
+
}
|
|
231
|
+
function sortModeOf(entry) {
|
|
232
|
+
return entry.mode ?? defaultSortMode(entry.direction);
|
|
233
|
+
}
|
|
234
|
+
function truncateSortString(value) {
|
|
235
|
+
if (value.length <= SORT_VALUE_MAX_CODE_POINTS) return value;
|
|
236
|
+
let index = 0;
|
|
237
|
+
let counted = 0;
|
|
238
|
+
while (index < value.length && counted < SORT_VALUE_MAX_CODE_POINTS) {
|
|
239
|
+
const unit = value.charCodeAt(index);
|
|
240
|
+
if (unit >= 55296 && unit < 56320 && index + 1 < value.length) {
|
|
241
|
+
const low = value.charCodeAt(index + 1);
|
|
242
|
+
if (low >= 56320 && low < 57344) index++;
|
|
243
|
+
}
|
|
244
|
+
index++;
|
|
245
|
+
counted++;
|
|
246
|
+
}
|
|
247
|
+
return value.slice(0, index);
|
|
248
|
+
}
|
|
249
|
+
function toComparableSortValue(value) {
|
|
250
|
+
if (typeof value === "string") return truncateSortString(value);
|
|
251
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
252
|
+
if (typeof value === "boolean") return value;
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
function numericReduction(values, mode) {
|
|
256
|
+
const numbers = [];
|
|
257
|
+
for (const element of values) {
|
|
258
|
+
if (typeof element === "number" && Number.isFinite(element)) numbers.push(element);
|
|
259
|
+
}
|
|
260
|
+
if (numbers.length === 0) return null;
|
|
261
|
+
if (mode === "avg") {
|
|
262
|
+
let mean = 0;
|
|
263
|
+
for (let index = 0; index < numbers.length; index++) {
|
|
264
|
+
mean += (numbers[index] - mean) / (index + 1);
|
|
265
|
+
}
|
|
266
|
+
return mean;
|
|
267
|
+
}
|
|
268
|
+
numbers.sort((a, b) => a - b);
|
|
269
|
+
const middle = numbers.length >> 1;
|
|
270
|
+
if (numbers.length % 2 === 1) return numbers[middle];
|
|
271
|
+
return numbers[middle - 1] / 2 + numbers[middle] / 2;
|
|
272
|
+
}
|
|
273
|
+
function toReducedSortValue(value, mode) {
|
|
274
|
+
if (!Array.isArray(value)) return toComparableSortValue(value);
|
|
275
|
+
if (mode === "avg" || mode === "median") return numericReduction(value, mode);
|
|
276
|
+
let chosen = null;
|
|
277
|
+
for (const element of value) {
|
|
278
|
+
const comparable = toComparableSortValue(element);
|
|
279
|
+
if (comparable === null) continue;
|
|
280
|
+
if (chosen === null) {
|
|
281
|
+
chosen = comparable;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
const comparison = comparePresentValues(comparable, chosen);
|
|
285
|
+
if (mode === "min" ? comparison < 0 : comparison > 0) chosen = comparable;
|
|
286
|
+
}
|
|
287
|
+
return chosen;
|
|
288
|
+
}
|
|
289
|
+
function readSortField(document, path) {
|
|
290
|
+
const segments = path.split(".");
|
|
291
|
+
let current = document;
|
|
292
|
+
for (const segment of segments) {
|
|
293
|
+
if (current === null || current === void 0 || typeof current !== "object") return void 0;
|
|
294
|
+
if (!Object.hasOwn(current, segment)) return void 0;
|
|
295
|
+
current = current[segment];
|
|
296
|
+
}
|
|
297
|
+
return current;
|
|
298
|
+
}
|
|
299
|
+
function typeRank(value) {
|
|
300
|
+
if (typeof value === "number") return 0;
|
|
301
|
+
if (typeof value === "string") return 1;
|
|
302
|
+
return 2;
|
|
303
|
+
}
|
|
304
|
+
function comparePresentValues(a, b) {
|
|
305
|
+
const rankDifference = typeRank(a) - typeRank(b);
|
|
306
|
+
if (rankDifference !== 0) return rankDifference;
|
|
307
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
308
|
+
if (typeof a === "string" && typeof b === "string") return compareSortStrings(a, b);
|
|
309
|
+
if (a === b) return 0;
|
|
310
|
+
return a ? 1 : -1;
|
|
311
|
+
}
|
|
312
|
+
function compareComparableValues(a, b, direction) {
|
|
313
|
+
if (a === null && b === null) return 0;
|
|
314
|
+
if (a === null) return 1;
|
|
315
|
+
if (b === null) return -1;
|
|
316
|
+
const comparison = comparePresentValues(a, b);
|
|
317
|
+
if (comparison === 0) return 0;
|
|
318
|
+
return direction === "desc" ? -comparison : comparison;
|
|
319
|
+
}
|
|
320
|
+
function compareComparableKeys(aKey, bKey, directions) {
|
|
321
|
+
for (let i = 0; i < directions.length; i++) {
|
|
322
|
+
const comparison = compareComparableValues(aKey[i] ?? null, bKey[i] ?? null, directions[i]);
|
|
323
|
+
if (comparison !== 0) return comparison;
|
|
324
|
+
}
|
|
325
|
+
return 0;
|
|
326
|
+
}
|
|
327
|
+
function compareSortValues(aValues, bValues, directions) {
|
|
328
|
+
for (let i = 0; i < directions.length; i++) {
|
|
329
|
+
const a = toComparableSortValue(aValues[i]);
|
|
330
|
+
const b = toComparableSortValue(bValues[i]);
|
|
331
|
+
if (a === null && b === null) continue;
|
|
332
|
+
if (a === null) return 1;
|
|
333
|
+
if (b === null) return -1;
|
|
334
|
+
const comparison = comparePresentValues(a, b);
|
|
335
|
+
if (comparison !== 0) return directions[i] === "desc" ? -comparison : comparison;
|
|
336
|
+
}
|
|
337
|
+
return 0;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/vector/hnsw/constants.ts
|
|
341
|
+
var MAX_LAYER_CAP = 32;
|
|
342
|
+
var MAX_M = 512;
|
|
343
|
+
var MIN_M = 2;
|
|
344
|
+
var EARLIER_RELEASE_MIN_M = 1;
|
|
345
|
+
var INITIAL_UPPER_SLOTS = 64;
|
|
346
|
+
var INITIAL_LIST_CAPACITY = 64;
|
|
347
|
+
var PLACEMENT_ROOM_REQUESTS = 8;
|
|
348
|
+
var FARTHEST_REJECTED_LINKS_KEPT = 1;
|
|
349
|
+
var COMPACTION_TOMBSTONE_RATIO = 0.1;
|
|
350
|
+
var COMPACTION_ABSOLUTE_THRESHOLD = 1e3;
|
|
351
|
+
var DEFAULT_EF_SEARCH = 50;
|
|
352
|
+
|
|
353
|
+
// src/workers/thread-slot.ts
|
|
354
|
+
var goneThreadSlots = /* @__PURE__ */ new Set();
|
|
355
|
+
function threadSlotOfWorker(workerId) {
|
|
356
|
+
return workerId + 1;
|
|
357
|
+
}
|
|
358
|
+
function noteThreadSlotLive(threadSlot) {
|
|
359
|
+
goneThreadSlots.delete(threadSlot);
|
|
360
|
+
}
|
|
361
|
+
function noteThreadSlotGone(threadSlot) {
|
|
362
|
+
goneThreadSlots.add(threadSlot);
|
|
363
|
+
}
|
|
364
|
+
function threadSlotGone(threadSlot) {
|
|
365
|
+
return goneThreadSlots.has(threadSlot);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/vector/constants.ts
|
|
369
|
+
var WASM_PAGE_BYTES = 65536;
|
|
370
|
+
var MAX_WASM_PAGES = 65536;
|
|
371
|
+
var VECTOR_STORE_INITIAL_CAPACITY = 16;
|
|
372
|
+
var VECTOR_BLOCK_INITIAL_SLOTS = 256;
|
|
373
|
+
var DISK_STORAGE_BLOCK_BYTES = 67108864;
|
|
374
|
+
var MAX_VECTOR_ORDINALS = 16777216;
|
|
375
|
+
var UNPLACED_FLAG_CHUNK_ORDINALS = 1024;
|
|
376
|
+
var VECTOR_SCRATCH_SLOTS = 64;
|
|
377
|
+
var SCRATCH_SLOTS_PER_THREAD_POOL = 31;
|
|
378
|
+
var MAX_DOC_ID_TABLE_BYTES = 1073741824;
|
|
379
|
+
var VECTOR_SEARCH_TIMEOUT_MS = 3e4;
|
|
380
|
+
var VECTOR_SEARCH_LOAD_TIMEOUT_MS = 3e5;
|
|
381
|
+
var VECTOR_INSERT_TIMEOUT_MS = 6e5;
|
|
382
|
+
var NATIVE_ATTACH_RETRY_MS = 1e3;
|
|
383
|
+
var MAX_RENUMBERED_SEARCH_ATTEMPTS = 3;
|
|
384
|
+
var LOCK_SPIN_ITERATIONS = 128;
|
|
385
|
+
var LOCK_WAIT_SLICE_MS = 20;
|
|
386
|
+
var GRAPH_LOCK_WAIT_SLICE_MS = 1;
|
|
387
|
+
var GRAPH_EXCLUSIVE_WAIT_DEADLINE_MS = 1e4;
|
|
388
|
+
var GRAPH_BUILD_DISPATCH_CHUNK = 64;
|
|
389
|
+
var GRAPH_BUILD_CHUNKS_IN_FLIGHT_PER_WORKER = 2;
|
|
390
|
+
|
|
391
|
+
// src/vector/osq/constants.ts
|
|
392
|
+
var OSQ_GRID = { 1: 0.798, 2: 1.493, 4: 2.514, 8: 3.922 };
|
|
393
|
+
var OSQ_STEPS = { 1: 1, 2: 3, 4: 15, 8: 255 };
|
|
394
|
+
var OSQ_QUERY_BITS = { 1: 4, 2: 4, 4: 4, 8: 8 };
|
|
395
|
+
var OSQ_PLACEMENT_QUERY_BITS = { 1: 4, 2: 4, 4: 8, 8: 8 };
|
|
396
|
+
var OSQ_LAMBDA = 0.1;
|
|
397
|
+
var OSQ_REFINE_ROUNDS = 5;
|
|
398
|
+
var OSQ_REFINE_TOLERANCE = 1e-8;
|
|
399
|
+
var MIN_OVERSAMPLE = 1;
|
|
400
|
+
|
|
401
|
+
// src/workers/constants.ts
|
|
402
|
+
var WORKER_YOUNG_GENERATION_MB = 24;
|
|
403
|
+
var MIN_WORKER_COUNT = 2;
|
|
404
|
+
var MAX_WORKER_COUNT = 8;
|
|
405
|
+
var FALLBACK_CPU_COUNT = 4;
|
|
406
|
+
var MIN_CORES_FOR_SEVERAL_REQUEST_THREADS = 3;
|
|
407
|
+
var DEFAULT_BACKPRESSURE_LIMIT = 100;
|
|
408
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
409
|
+
var SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
410
|
+
var CONSECUTIVE_TIMEOUTS_BEFORE_DEATH = 3;
|
|
411
|
+
|
|
412
|
+
// src/workers/worker-count.ts
|
|
413
|
+
function detectCpuCount() {
|
|
414
|
+
try {
|
|
415
|
+
if (navigator?.hardwareConcurrency) {
|
|
416
|
+
return navigator.hardwareConcurrency;
|
|
417
|
+
}
|
|
418
|
+
if (typeof process !== "undefined") {
|
|
419
|
+
const ap = process.availableParallelism;
|
|
420
|
+
if (typeof ap === "function") {
|
|
421
|
+
return ap();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} catch {
|
|
425
|
+
return FALLBACK_CPU_COUNT;
|
|
426
|
+
}
|
|
427
|
+
return FALLBACK_CPU_COUNT;
|
|
428
|
+
}
|
|
429
|
+
function resolveWorkerCount(requested) {
|
|
430
|
+
if (requested !== void 0 && requested > 0) {
|
|
431
|
+
return Math.min(requested, SCRATCH_SLOTS_PER_THREAD_POOL);
|
|
432
|
+
}
|
|
433
|
+
return Math.max(MIN_WORKER_COUNT, Math.min(MAX_WORKER_COUNT, detectCpuCount() - 1));
|
|
434
|
+
}
|
|
435
|
+
function resolveRequestThreadCount(requested) {
|
|
436
|
+
if (detectCpuCount() < MIN_CORES_FOR_SEVERAL_REQUEST_THREADS) return 1;
|
|
437
|
+
return resolveWorkerCount(requested);
|
|
438
|
+
}
|
|
439
|
+
function splitWorkerBudget(total) {
|
|
440
|
+
const keyword = Math.ceil(total / 2);
|
|
441
|
+
return { keyword, vector: total - keyword };
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// src/runtime/detect.ts
|
|
445
|
+
function detectRuntimeName() {
|
|
446
|
+
if ("Bun" in globalThis) {
|
|
447
|
+
return "bun";
|
|
448
|
+
}
|
|
449
|
+
if ("Deno" in globalThis) {
|
|
450
|
+
return "deno";
|
|
451
|
+
}
|
|
452
|
+
const proc = globalThis.process;
|
|
453
|
+
if (typeof proc === "object" && proc !== null && typeof proc.versions === "object" && typeof proc.versions?.node === "string") {
|
|
454
|
+
return "node";
|
|
455
|
+
}
|
|
456
|
+
return "browser";
|
|
457
|
+
}
|
|
458
|
+
function getCpuCount() {
|
|
459
|
+
const nav = globalThis.navigator;
|
|
460
|
+
if (nav && typeof nav.hardwareConcurrency === "number" && nav.hardwareConcurrency >= 1) {
|
|
461
|
+
return nav.hardwareConcurrency;
|
|
462
|
+
}
|
|
463
|
+
return 1;
|
|
464
|
+
}
|
|
465
|
+
function detectRuntime() {
|
|
466
|
+
const runtime = detectRuntimeName();
|
|
467
|
+
return {
|
|
468
|
+
runtime,
|
|
469
|
+
cpuCount: getCpuCount(),
|
|
470
|
+
supportsWorkerThreads: runtime === "node" || runtime === "bun",
|
|
471
|
+
supportsWebWorkers: runtime === "browser" || runtime === "deno" || runtime === "bun",
|
|
472
|
+
supportsFileSystem: runtime === "node" || runtime === "bun" || runtime === "deno",
|
|
473
|
+
supportsIndexedDB: runtime === "browser" || "indexedDB" in globalThis,
|
|
474
|
+
supportsBroadcastChannel: "BroadcastChannel" in globalThis
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// src/workers/entry-point.ts
|
|
479
|
+
var DIST_SEGMENT = "/dist/";
|
|
480
|
+
function resolveWorkerEntry(moduleUrl, sourceDirectory, distEntry) {
|
|
481
|
+
const distIndex = moduleUrl.lastIndexOf(DIST_SEGMENT);
|
|
482
|
+
const entry = distIndex !== -1 ? new URL(distEntry, moduleUrl.slice(0, distIndex + DIST_SEGMENT.length)).href : sourceDirectory.test(moduleUrl) ? moduleUrl.replace(sourceDirectory, `${DIST_SEGMENT}${distEntry}`) : null;
|
|
483
|
+
return entry === moduleUrl ? null : entry;
|
|
484
|
+
}
|
|
485
|
+
function missingWorkerEntry(moduleUrl) {
|
|
486
|
+
return new NarsilError(
|
|
487
|
+
ErrorCodes.CONFIG_INVALID,
|
|
488
|
+
`The engine finds no worker entry beside its own module at "${moduleUrl}", which happens where a bundler folds @delali/narsil into an application bundle. Keep @delali/narsil outside the bundle, or set workers.enabled to false`,
|
|
489
|
+
{ moduleUrl }
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export { CHECKSUM_YIELD_CHUNK_BYTES, COMPACTION_ABSOLUTE_THRESHOLD, COMPACTION_TOMBSTONE_RATIO, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH, DEFAULT_BACKPRESSURE_LIMIT, DEFAULT_EF_SEARCH, DEFAULT_REQUEST_TIMEOUT_MS, DISK_STORAGE_BLOCK_BYTES, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, EARLIER_RELEASE_MIN_M, FARTHEST_REJECTED_LINKS_KEPT, GRAPH_BUILD_CHUNKS_IN_FLIGHT_PER_WORKER, GRAPH_BUILD_DISPATCH_CHUNK, GRAPH_EXCLUSIVE_WAIT_DEADLINE_MS, GRAPH_LOCK_WAIT_SLICE_MS, INITIAL_LIST_CAPACITY, INITIAL_UPPER_SLOTS, LOCK_SPIN_ITERATIONS, LOCK_WAIT_SLICE_MS, MAX_DOCUMENT_ENCODING_DEPTH, MAX_DOC_ID_TABLE_BYTES, MAX_FILE_BYTES, MAX_LAYER_CAP, MAX_M, MAX_RENUMBERED_SEARCH_ATTEMPTS, MAX_VECTOR_ORDINALS, MAX_WASM_PAGES, MIN_M, MIN_OVERSAMPLE, NATIVE_ATTACH_RETRY_MS, NATIVE_CRC32_MIN_BYTES, OSQ_GRID, OSQ_LAMBDA, OSQ_PLACEMENT_QUERY_BITS, OSQ_QUERY_BITS, OSQ_REFINE_ROUNDS, OSQ_REFINE_TOLERANCE, OSQ_STEPS, PLACEMENT_ROOM_REQUESTS, SHUTDOWN_TIMEOUT_MS, SORT_MODES, SORT_VALUE_MAX_CODE_POINTS, UNPLACED_FLAG_CHUNK_ORDINALS, VALID_HNSW_METRICS, VECTOR_BLOCK_INITIAL_SLOTS, VECTOR_INSERT_TIMEOUT_MS, VECTOR_SCRATCH_SLOTS, VECTOR_SEARCH_LOAD_TIMEOUT_MS, VECTOR_SEARCH_TIMEOUT_MS, VECTOR_STORE_INITIAL_CAPACITY, WASM_PAGE_BYTES, WORKER_YOUNG_GENERATION_MB, appendFoldedCodePoint, codePointCount, compareCodePoints, compareComparableKeys, compareComparableValues, compareSortValues, defaultSortMode, detectRuntime, exceedsCodePoints, holdsUnpairedSurrogate, isSimdAvailable, isSortMode, markSimdUnavailable, missingWorkerEntry, noteThreadSlotGone, noteThreadSlotLive, readSortField, resolveRequestThreadCount, resolveWorkerCount, resolveWorkerEntry, singleFoldTable, sortModeOf, splitWorkerBudget, threadSlotGone, threadSlotOfWorker, toComparableSortValue, toReducedSortValue, truncateSortString };
|