@delali/narsil 0.2.4-next.49 → 0.2.4-next.51

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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/{options-Dtk99qUs.d.ts → capabilities-BWm4IITU.d.ts} +56 -48
  3. package/dist/chunk-AV4IJKD2.mjs +35 -0
  4. package/dist/{chunk-M6JGMKA5.mjs → chunk-BEIK3EOZ.mjs} +503 -2273
  5. package/dist/chunk-CMVG2UEF.mjs +2038 -0
  6. package/dist/chunk-CV5H7XL7.mjs +876 -0
  7. package/dist/{chunk-KGRYQVZ5.mjs → chunk-MHE7YWAU.mjs} +2 -1
  8. package/dist/{chunk-56PJBIJ6.mjs → chunk-ND34I3SV.mjs} +427 -1455
  9. package/dist/chunk-PIWKZPP7.mjs +64 -0
  10. package/dist/{chunk-HGJC5L65.mjs → chunk-PMBHH44R.mjs} +121 -2
  11. package/dist/chunk-RP23PWMV.mjs +11 -0
  12. package/dist/{chunk-RDGXYRF4.mjs → chunk-WYJXSLER.mjs} +8 -19
  13. package/dist/{chunk-JXHUHFJ5.mjs → chunk-X6YZO4MQ.mjs} +2 -11
  14. package/dist/{chunk-OWCFK42Q.mjs → chunk-XE6XR2OE.mjs} +3 -10
  15. package/dist/chunk-ZHUQKZBE.mjs +1292 -0
  16. package/dist/{client-DX7xPcNA.d.ts → client-B_X6_AbT.d.ts} +34 -10
  17. package/dist/client.d.ts +8 -8
  18. package/dist/client.mjs +26 -10
  19. package/dist/{config-B41W23Us.d.ts → config-Czh2YNDi.d.ts} +2 -2
  20. package/dist/{config-Co-zAXqO.d.ts → config-OON7IJ_B.d.ts} +26 -5
  21. package/dist/direct-executor-OREXU72C.mjs +12 -0
  22. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  23. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  24. package/dist/distribution.d.ts +8 -8
  25. package/dist/distribution.mjs +28 -11
  26. package/dist/{engine-CABZg25p.d.ts → engine-9PtFY50q.d.ts} +114 -62
  27. package/dist/index.browser.mjs +3255 -2516
  28. package/dist/index.d.ts +7 -7
  29. package/dist/index.mjs +11 -6
  30. package/dist/{search-FjWhZN3f.d.ts → memory-Bzd5xcEW.d.ts} +88 -79
  31. package/dist/persistence/durability/checkpoint-worker.d.ts +1 -1
  32. package/dist/persistence/durability/checkpoint-worker.mjs +11 -6
  33. package/dist/react.d.ts +6 -6
  34. package/dist/{schema-B7juWg8Q.d.ts → schema-BqRx9t4E.d.ts} +22 -3
  35. package/dist/server.d.ts +48 -43
  36. package/dist/server.mjs +326 -819
  37. package/dist/{tasks-Bn4R1NPN.d.ts → tasks-DT7L1p6w.d.ts} +20 -1
  38. package/dist/thread-PZLEO6JL.mjs +310 -0
  39. package/dist/{types-DsSSjY4d.d.ts → types-DXPxaXPO.d.ts} +1 -1
  40. package/dist/vector/hnsw-build-worker.mjs +2 -1
  41. package/dist/vector/search-worker.mjs +3 -121
  42. package/dist/workers/entry.mjs +47 -3
  43. package/package.json +5 -1
  44. package/dist/direct-executor-HRTDWMVB.mjs +0 -9
package/README.md CHANGED
@@ -91,7 +91,7 @@ Every hit holds the document, its id, and its BM25 score. `results.count` report
91
91
 
92
92
  **Storage.** [Persistence adapters](https://github.com/assetcorp/narsil/blob/main/docs/persistence-and-durability.md) plug in filesystem, IndexedDB, memory, or custom backends. Durability adds a write-ahead log with periodic checkpoints and automatic recovery, and snapshots capture a whole index as one portable byte array.
93
93
 
94
- **Scale.** [Partitioned indexes](https://github.com/assetcorp/narsil/blob/main/docs/partitions-and-workers.md) route documents by deterministic hash and reshape online through `rebalance()`, with writes buffering in a write-ahead queue during the reshape. Worker copies answer keyword queries on half the worker threads once an index holds 1,000 documents.
94
+ **Scale.** [Partitioned indexes](https://github.com/assetcorp/narsil/blob/main/docs/partitions-and-workers.md) route documents by deterministic hash and reshape online through `rebalance()`, with writes buffering in a write-ahead queue during the reshape. Worker copies answer keyword queries on half the worker threads once an index holds 1,000 documents, and the HTTP server receives requests on the threads that hold them.
95
95
 
96
96
  **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 reaches every one of those routes from a browser or from Node under the engine's own method names, and the [React](https://github.com/assetcorp/narsil/blob/main/docs/react.md) subpath gives those methods to components as hooks. [Events, plugins, and memory reporting](https://github.com/assetcorp/narsil/blob/main/docs/observability.md) cover observability, and [language modules](https://github.com/assetcorp/narsil/blob/main/docs/language-support.md) cover 107 languages as separate entry points, 20 of them African.
97
97
 
@@ -1,51 +1,6 @@
1
1
  import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { C as ClusterNamespace } from './config-B41W23Us.js';
3
- import { h as TaskStore } from './tasks-Bn4R1NPN.js';
4
-
5
- /**
6
- * Marks that `POST /indexes/{name}/documents/_import` accepts `?async=true` and
7
- * answers with a task record.
8
- *
9
- * @public
10
- */
11
- declare const ASYNC_IMPORT_CAPABILITY = "documents.import.async";
12
- /**
13
- * Marks that `POST /tasks/{id}/_cancel` asks a running task to stop.
14
- *
15
- * @public
16
- */
17
- declare const TASK_CANCEL_CAPABILITY = "tasks.cancel";
18
- /**
19
- * Marks that `GET /tasks` filters by index, type, and status, and pages through
20
- * `from` and `limit`.
21
- *
22
- * @public
23
- */
24
- declare const TASK_FILTER_CAPABILITY = "tasks.filter";
25
- /**
26
- * Marks that `POST /indexes/{name}/_rebuild-analysis` reanalyses an index whose
27
- * language module moved on.
28
- *
29
- * @public
30
- */
31
- declare const REBUILD_ANALYSIS_CAPABILITY = "indexes.rebuildAnalysis";
32
- /**
33
- * Marks that `POST /indexes/{name}/_open` and `POST /indexes/{name}/_close`
34
- * load and release an index's server memory.
35
- *
36
- * @public
37
- */
38
- declare const INDEX_LIFECYCLE_CAPABILITY = "indexes.lifecycle";
39
- /**
40
- * Every capability this server announces at `/capabilities`.
41
- *
42
- * A client reads this list to find out whether an optional route or mode is
43
- * available before it sends a request, because a server that predates one of
44
- * them answers 404 rather than explaining itself.
45
- *
46
- * @public
47
- */
48
- declare const SERVER_CAPABILITIES: readonly string[];
2
+ import { C as ClusterNamespace } from './config-Czh2YNDi.js';
3
+ import { h as TaskStore } from './tasks-DT7L1p6w.js';
49
4
 
50
5
  /**
51
6
  * Context handed to {@link OnRequestHook} for every inbound request, captured
@@ -121,7 +76,7 @@ interface ServerLimits {
121
76
  maxLineBytes?: number;
122
77
  /** Documents handed to the engine per batch during NDJSON import; the loop yields between batches. */
123
78
  importBatchSize?: number;
124
- /** Maximum requests executing engine work at once; excess is shed with 429. Omit or 0 to disable. */
79
+ /** Maximum requests executing engine work at once, counted across every request thread; excess is shed with 429. Omit or 0 to disable. */
125
80
  maxConcurrentRequests?: number;
126
81
  /** Ceiling for a search's `limit`, `offset`, and `group.maxPerGroup`, so one
127
82
  * request cannot ask for an unbounded result set. Excess → 400. Defaults to
@@ -228,6 +183,14 @@ interface NarsilServer {
228
183
  close(): Promise<void>;
229
184
  /** The server bound to this port, which is what you read after binding to port 0. */
230
185
  readonly listeningPort: number;
186
+ /**
187
+ * How many request threads receive connections, which is the engine's
188
+ * worker count on a machine with three cores or more and one below that.
189
+ * It reads zero while the main thread answers every request itself, which
190
+ * happens on a runtime without worker threads, on an engine created with
191
+ * `workers.enabled: false`, and on a cluster node's engine.
192
+ */
193
+ readonly requestThreadCount: number;
231
194
  }
232
195
  /**
233
196
  * The body every failed response carries, which is what an HTTP client parses
@@ -247,4 +210,49 @@ interface ErrorEnvelope {
247
210
  };
248
211
  }
249
212
 
213
+ /**
214
+ * Marks that `POST /indexes/{name}/documents/_import` accepts `?async=true` and
215
+ * answers with a task record.
216
+ *
217
+ * @public
218
+ */
219
+ declare const ASYNC_IMPORT_CAPABILITY = "documents.import.async";
220
+ /**
221
+ * Marks that `POST /tasks/{id}/_cancel` asks a running task to stop.
222
+ *
223
+ * @public
224
+ */
225
+ declare const TASK_CANCEL_CAPABILITY = "tasks.cancel";
226
+ /**
227
+ * Marks that `GET /tasks` filters by index, type, and status, and pages through
228
+ * `from` and `limit`.
229
+ *
230
+ * @public
231
+ */
232
+ declare const TASK_FILTER_CAPABILITY = "tasks.filter";
233
+ /**
234
+ * Marks that `POST /indexes/{name}/_rebuild-analysis` reanalyses an index whose
235
+ * language module moved on.
236
+ *
237
+ * @public
238
+ */
239
+ declare const REBUILD_ANALYSIS_CAPABILITY = "indexes.rebuildAnalysis";
240
+ /**
241
+ * Marks that `POST /indexes/{name}/_open` and `POST /indexes/{name}/_close`
242
+ * load and release an index's server memory.
243
+ *
244
+ * @public
245
+ */
246
+ declare const INDEX_LIFECYCLE_CAPABILITY = "indexes.lifecycle";
247
+ /**
248
+ * Every capability this server announces at `/capabilities`.
249
+ *
250
+ * A client reads this list to find out whether an optional route or mode is
251
+ * available before it sends a request, because a server that predates one of
252
+ * them answers 404 rather than explaining itself.
253
+ *
254
+ * @public
255
+ */
256
+ declare const SERVER_CAPABILITIES: readonly string[];
257
+
250
258
  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 };
@@ -0,0 +1,35 @@
1
+ // src/runtime/detect.ts
2
+ function detectRuntimeName() {
3
+ if ("Bun" in globalThis) {
4
+ return "bun";
5
+ }
6
+ if ("Deno" in globalThis) {
7
+ return "deno";
8
+ }
9
+ const proc = globalThis.process;
10
+ if (typeof proc === "object" && proc !== null && typeof proc.versions === "object" && typeof proc.versions?.node === "string") {
11
+ return "node";
12
+ }
13
+ return "browser";
14
+ }
15
+ function getCpuCount() {
16
+ const nav = globalThis.navigator;
17
+ if (nav && typeof nav.hardwareConcurrency === "number" && nav.hardwareConcurrency >= 1) {
18
+ return nav.hardwareConcurrency;
19
+ }
20
+ return 1;
21
+ }
22
+ function detectRuntime() {
23
+ const runtime = detectRuntimeName();
24
+ return {
25
+ runtime,
26
+ cpuCount: getCpuCount(),
27
+ supportsWorkerThreads: runtime === "node" || runtime === "bun",
28
+ supportsWebWorkers: runtime === "browser" || runtime === "deno" || runtime === "bun",
29
+ supportsFileSystem: runtime === "node" || runtime === "bun" || runtime === "deno",
30
+ supportsIndexedDB: runtime === "browser" || "indexedDB" in globalThis,
31
+ supportsBroadcastChannel: "BroadcastChannel" in globalThis
32
+ };
33
+ }
34
+
35
+ export { detectRuntime };