@delali/narsil 0.2.4-next.48 → 0.2.4-next.50

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 (60) hide show
  1. package/README.md +2 -2
  2. package/dist/adapters/indexeddb.mjs +15 -10
  3. package/dist/{options-BC68VPoE.d.ts → capabilities-JrVQOwi4.d.ts} +55 -47
  4. package/dist/{chunk-BFIH7OV5.mjs → chunk-2GWVQWGA.mjs} +3 -1
  5. package/dist/chunk-AV4IJKD2.mjs +35 -0
  6. package/dist/{chunk-EV45L35L.mjs → chunk-BEIK3EOZ.mjs} +845 -2407
  7. package/dist/chunk-CBLS46IE.mjs +10 -0
  8. package/dist/chunk-CMVG2UEF.mjs +2038 -0
  9. package/dist/chunk-CV5H7XL7.mjs +876 -0
  10. package/dist/{chunk-JQUL2T6I.mjs → chunk-GCM3JFVA.mjs} +1 -2
  11. package/dist/{chunk-XWICBGYT.mjs → chunk-MHE7YWAU.mjs} +3 -5
  12. package/dist/{chunk-UZTT2BKQ.mjs → chunk-ND34I3SV.mjs} +1202 -1881
  13. package/dist/{chunk-PM52SMBT.mjs → chunk-OOSIDHA3.mjs} +2 -1
  14. package/dist/chunk-ORBLD3EL.mjs +6 -0
  15. package/dist/chunk-PIWKZPP7.mjs +64 -0
  16. package/dist/{chunk-4COAUBLJ.mjs → chunk-PMBHH44R.mjs} +124 -8
  17. package/dist/chunk-RP23PWMV.mjs +11 -0
  18. package/dist/chunk-UNEEFTEU.mjs +7 -0
  19. package/dist/{chunk-WTONLDU3.mjs → chunk-WYJXSLER.mjs} +9 -19
  20. package/dist/{chunk-DFZDV5FV.mjs → chunk-X6YZO4MQ.mjs} +19 -15
  21. package/dist/chunk-XE6XR2OE.mjs +23 -0
  22. package/dist/chunk-YEO6G2NG.mjs +6 -0
  23. package/dist/chunk-ZHUQKZBE.mjs +1292 -0
  24. package/dist/{client-C5BkUqB8.d.ts → client-CBOVHdjp.d.ts} +31 -7
  25. package/dist/client.d.ts +7 -7
  26. package/dist/client.mjs +250 -232
  27. package/dist/{config-B-ZI-ft5.d.ts → config-Czh2YNDi.d.ts} +2 -2
  28. package/dist/{config-BZRExglL.d.ts → config-OON7IJ_B.d.ts} +50 -13
  29. package/dist/direct-executor-OREXU72C.mjs +12 -0
  30. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  31. package/dist/distribution/coordinator/etcd.mjs +2 -3
  32. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  33. package/dist/distribution/coordinator/in-memory.mjs +2 -2
  34. package/dist/distribution/transport/grpc.mjs +7 -9
  35. package/dist/distribution/transport/in-memory.mjs +2 -1
  36. package/dist/distribution/transport/tcp.mjs +3 -2
  37. package/dist/distribution.d.ts +8 -8
  38. package/dist/distribution.mjs +142 -101
  39. package/dist/embeddings/openai.mjs +5 -3
  40. package/dist/{engine-Cjr1uBLa.d.ts → engine-9PtFY50q.d.ts} +125 -69
  41. package/dist/index.browser.mjs +4689 -3330
  42. package/dist/index.d.ts +7 -7
  43. package/dist/index.mjs +14 -8
  44. package/dist/invalidation/broadcast-channel.mjs +2 -1
  45. package/dist/invalidation/filesystem.mjs +3 -4
  46. package/dist/{search-DDHjfXhJ.d.ts → memory-Bzd5xcEW.d.ts} +89 -63
  47. package/dist/persistence/durability/checkpoint-worker.d.ts +1 -1
  48. package/dist/persistence/durability/checkpoint-worker.mjs +14 -8
  49. package/dist/react.d.ts +4 -4
  50. package/dist/react.mjs +7 -5
  51. package/dist/{schema-B7juWg8Q.d.ts → schema-BqRx9t4E.d.ts} +22 -3
  52. package/dist/server.d.ts +47 -42
  53. package/dist/server.mjs +338 -821
  54. package/dist/thread-PZLEO6JL.mjs +310 -0
  55. package/dist/{types-DsSSjY4d.d.ts → types-DXPxaXPO.d.ts} +1 -1
  56. package/dist/vector/hnsw-build-worker.mjs +3 -4
  57. package/dist/vector/search-worker.mjs +4 -123
  58. package/dist/workers/entry.mjs +47 -3
  59. package/package.json +5 -1
  60. package/dist/direct-executor-EOTFGXTO.mjs +0 -8
@@ -1,5 +1,5 @@
1
- import { N as NarsilConfig } from './config-BZRExglL.js';
2
- import { A as AllocationTable, N as NodeRole, a as NodeRegistration, C as ClusterCoordinator, b as NodeCapacity } from './types-DsSSjY4d.js';
1
+ import { N as NarsilConfig } from './config-OON7IJ_B.js';
2
+ import { A as AllocationTable, N as NodeRole, a as NodeRegistration, C as ClusterCoordinator, b as NodeCapacity } from './types-DXPxaXPO.js';
3
3
  import { N as NodeTransport } from './types-D5OwhtsQ.js';
4
4
 
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { P as PersistenceAdapter, I as InvalidationAdapter, E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { Q as QueryParams, e as QueryResult } from './search-DDHjfXhJ.js';
3
- import { I as IndexConfig, A as AnyDocument } from './schema-B7juWg8Q.js';
2
+ import { Q as QueryParams, e as QueryResult } from './memory-Bzd5xcEW.js';
3
+ import { I as IndexConfig, A as AnyDocument } from './schema-BqRx9t4E.js';
4
4
 
5
5
  /**
6
6
  * Hooks that run alongside the engine's own work, which is how you add
@@ -148,7 +148,7 @@ interface NarsilConfig {
148
148
  plugins?: NarsilPlugin[];
149
149
  /** This supplies the id for a document inserted without one. The engine generates a UUID v7 by default. */
150
150
  idGenerator?: () => string;
151
- /** These settings control when the engine moves its indexes onto worker threads, and how many it uses. */
151
+ /** These settings control when an index gains worker copies, how many threads they share, and when an idle index gives them up. */
152
152
  workers?: WorkerConfig;
153
153
  /** Every index uses this adapter unless its own config names another. */
154
154
  embedding?: EmbeddingAdapter;
@@ -249,25 +249,62 @@ interface DurabilityConfig {
249
249
  compactionThreshold?: number;
250
250
  }
251
251
  /**
252
- * When the engine moves its indexes onto worker threads, and how many it uses.
252
+ * Which queries the main copy of an index answers once the index holds worker
253
+ * copies. Under `lone`, the main copy answers a query the engine receives
254
+ * while no copy holds one, on an index of at most 50,000 documents. Once
255
+ * every copy is busy, it also answers one query per turn of the event loop.
256
+ * Under `none`, every query on an index that holds copies goes to one of
257
+ * them, while the main copy still answers a query on an index whose copies
258
+ * are loading.
253
259
  *
254
- * An engine starts on the main thread, where a small index answers fastest.
255
- * Once an index passes a threshold the engine promotes it to a worker pool, so
256
- * that indexing and searching run off the calling thread.
260
+ * @public
261
+ */
262
+ type MainCopyQueries = 'lone' | 'none';
263
+ /**
264
+ * How the engine holds worker copies of its indexes, and how many threads
265
+ * they may use.
266
+ *
267
+ * A small index answers fastest on the main thread. Once an index holds as
268
+ * many documents as the copy threshold, the engine loads a copy of it onto
269
+ * every worker thread, and each query then runs whole on the copy with the
270
+ * fewest queries in flight. The same switch governs the vector search pool.
257
271
  *
258
272
  * @public
259
273
  */
260
274
  interface WorkerConfig {
261
- /** Setting this allows promotion to worker threads. The engine promotes nothing while it is false. */
275
+ /**
276
+ * Whether the engine may hold worker copies and a vector search pool. It is
277
+ * on everywhere but a browser page. Set it to false to hold the process to
278
+ * one thread, which leaves both pools absent.
279
+ */
262
280
  enabled?: boolean;
263
- /** The pool runs this many workers. The engine derives a count from the host's cores by default. */
281
+ /**
282
+ * The keyword copies and the vector search pool share this many threads
283
+ * between them, half each, in an embedded engine. The HTTP server holds a
284
+ * copy on every one of them and receives requests there. The engine takes
285
+ * the host's cores minus one by default, between 2 and 8.
286
+ */
264
287
  count?: number;
265
- /** This many documents in one index trigger promotion. */
288
+ /** An index gains worker copies once it holds this many documents, 1,000 by default. */
266
289
  promotionThreshold?: number;
267
- /** This many documents across every index trigger promotion. */
268
- totalPromotionThreshold?: number;
290
+ /**
291
+ * The engine drops an index's copies after this many milliseconds without a
292
+ * read or a write, five minutes by default, and loads them again on the
293
+ * next request while the main copy answers it. It may not exceed
294
+ * `lifecycle.idleTimeoutMs`, and where it is unset the copies take the
295
+ * smaller of five minutes and that interval.
296
+ */
297
+ idleTimeoutMs?: number;
298
+ /**
299
+ * Which queries the main copy answers, `lone` by default. Set `none` where
300
+ * the main thread also serves the host's own work, such as HTTP requests,
301
+ * because a query answered on the main copy then delays every other request
302
+ * waiting on that thread. A server created with `createServer` sets `none` on
303
+ * an engine that leaves this unset.
304
+ */
305
+ mainCopyQueries?: MainCopyQueries;
269
306
  /** Each worker imports this module on start-up, which is how a worker reaches a custom tokeniser or language. */
270
307
  bootstrapModule?: string;
271
308
  }
272
309
 
273
- export type { AnalysisConfig as A, DurabilityConfig as D, IndexContext as I, NarsilConfig as N, PartitionContext as P, RemoveContext as R, SearchContext as S, UpdateContext as U, WorkerConfig as W, IndexLifecycleConfig as a, InsertContext as b, NarsilPlugin as c, StaleAnalysis as d, WorkerContext as e };
310
+ export type { AnalysisConfig as A, DurabilityConfig as D, IndexContext as I, MainCopyQueries as M, NarsilConfig as N, PartitionContext as P, RemoveContext as R, SearchContext as S, UpdateContext as U, WorkerConfig as W, IndexLifecycleConfig as a, InsertContext as b, NarsilPlugin as c, StaleAnalysis as d, WorkerContext as e };
@@ -0,0 +1,12 @@
1
+ export { createDirectExecutor } from './chunk-BEIK3EOZ.mjs';
2
+ import './chunk-CMVG2UEF.mjs';
3
+ import './chunk-AV4IJKD2.mjs';
4
+ import './chunk-CBLS46IE.mjs';
5
+ import './chunk-TGP5M5R7.mjs';
6
+ import './chunk-PMBHH44R.mjs';
7
+ import './chunk-X6YZO4MQ.mjs';
8
+ import './chunk-RP23PWMV.mjs';
9
+ import './chunk-U2BKYEC7.mjs';
10
+ import './chunk-2GWVQWGA.mjs';
11
+ import './chunk-WYJXSLER.mjs';
12
+ import './chunk-P4ELXVJQ.mjs';
@@ -1,5 +1,5 @@
1
- import { C as ClusterCoordinator } from '../../types-DsSSjY4d.js';
2
- import '../../schema-B7juWg8Q.js';
1
+ import { C as ClusterCoordinator } from '../../types-DXPxaXPO.js';
2
+ import '../../schema-BqRx9t4E.js';
3
3
  import '../../adapters-79OIa4xm.js';
4
4
 
5
5
  /**
@@ -1,4 +1,5 @@
1
- import { compareCodePoints } from '../../chunk-BFIH7OV5.mjs';
1
+ import { MAX_NODE_ID_LENGTH, MAX_WATCHERS } from '../../chunk-ORBLD3EL.mjs';
2
+ import { compareCodePoints } from '../../chunk-2GWVQWGA.mjs';
2
3
  import { NarsilError, ErrorCodes } from '../../chunk-P4ELXVJQ.mjs';
3
4
  import { decode, encode } from '@msgpack/msgpack';
4
5
 
@@ -236,9 +237,7 @@ async function writeUnderLease(context, registration) {
236
237
  }
237
238
 
238
239
  // src/distribution/coordinator/etcd/validation.ts
239
- var MAX_NODE_ID_LENGTH = 255;
240
240
  var VALID_PARTITION_STATES = /* @__PURE__ */ new Set(["UNASSIGNED", "INITIALISING", "ACTIVE", "MIGRATING", "DECOMMISSIONING"]);
241
- var MAX_WATCHERS = 64;
242
241
  function validateNodeId(nodeId) {
243
242
  if (nodeId.length === 0) {
244
243
  throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Node ID must not be empty");
@@ -1,5 +1,5 @@
1
- import { C as ClusterCoordinator } from '../../types-DsSSjY4d.js';
2
- import '../../schema-B7juWg8Q.js';
1
+ import { C as ClusterCoordinator } from '../../types-DXPxaXPO.js';
2
+ import '../../schema-BqRx9t4E.js';
3
3
  import '../../adapters-79OIa4xm.js';
4
4
 
5
5
  /**
@@ -1,8 +1,8 @@
1
- import { compareCodePoints } from '../../chunk-BFIH7OV5.mjs';
1
+ import { NODE_HEARTBEAT_TTL_MS } from '../../chunk-ORBLD3EL.mjs';
2
+ import { compareCodePoints } from '../../chunk-2GWVQWGA.mjs';
2
3
 
3
4
  // src/distribution/coordinator/in-memory.ts
4
5
  var NODE_HEARTBEAT_PREFIX = "_narsil/node/";
5
- var NODE_HEARTBEAT_TTL_MS = 3e4;
6
6
  function bytesEqual(a, b) {
7
7
  if (a.byteLength !== b.byteLength) {
8
8
  return false;
@@ -1,5 +1,6 @@
1
- import { decodeTransportMessage, encodeTransportMessage } from '../../chunk-PM52SMBT.mjs';
2
- import { TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES } from '../../chunk-JQUL2T6I.mjs';
1
+ import { decodeTransportMessage, encodeTransportMessage } from '../../chunk-OOSIDHA3.mjs';
2
+ import { MAX_MESSAGE_SIZE_BYTES, GRPC_KEEPALIVE_TIMEOUT_MS, GRPC_KEEPALIVE_TIME_MS, GRPC_ENVELOPE_OVERHEAD_BYTES } from '../../chunk-UNEEFTEU.mjs';
3
+ import { TransportError, TransportErrorCodes } from '../../chunk-GCM3JFVA.mjs';
3
4
  import { NarsilError, ErrorCodes } from '../../chunk-P4ELXVJQ.mjs';
4
5
 
5
6
  // src/distribution/transport/grpc/codec.ts
@@ -123,15 +124,12 @@ var DEFAULT_GRPC_CONFIG = {
123
124
  replicationTimeout: 1e4,
124
125
  snapshotTimeout: 3e5
125
126
  };
126
- var ENVELOPE_OVERHEAD_BYTES = 1024;
127
- var KEEPALIVE_TIME_MS = 3e4;
128
- var KEEPALIVE_TIMEOUT_MS = 1e4;
129
127
  function channelOptions() {
130
128
  return {
131
- "grpc.max_receive_message_length": MAX_MESSAGE_SIZE_BYTES + ENVELOPE_OVERHEAD_BYTES,
132
- "grpc.max_send_message_length": MAX_MESSAGE_SIZE_BYTES + ENVELOPE_OVERHEAD_BYTES,
133
- "grpc.keepalive_time_ms": KEEPALIVE_TIME_MS,
134
- "grpc.keepalive_timeout_ms": KEEPALIVE_TIMEOUT_MS,
129
+ "grpc.max_receive_message_length": MAX_MESSAGE_SIZE_BYTES + GRPC_ENVELOPE_OVERHEAD_BYTES,
130
+ "grpc.max_send_message_length": MAX_MESSAGE_SIZE_BYTES + GRPC_ENVELOPE_OVERHEAD_BYTES,
131
+ "grpc.keepalive_time_ms": GRPC_KEEPALIVE_TIME_MS,
132
+ "grpc.keepalive_timeout_ms": GRPC_KEEPALIVE_TIMEOUT_MS,
135
133
  "grpc.keepalive_permit_without_calls": 1
136
134
  };
137
135
  }
@@ -1,4 +1,5 @@
1
- import { DEFAULT_TRANSPORT_CONFIG, TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES } from '../../chunk-JQUL2T6I.mjs';
1
+ import { MAX_MESSAGE_SIZE_BYTES } from '../../chunk-UNEEFTEU.mjs';
2
+ import { DEFAULT_TRANSPORT_CONFIG, TransportError, TransportErrorCodes } from '../../chunk-GCM3JFVA.mjs';
2
3
 
3
4
  // src/distribution/transport/in-memory.ts
4
5
  function createInMemoryNetwork() {
@@ -1,5 +1,6 @@
1
- import { DEFAULT_TCP_CONFIG, encodeTransportMessage, encodeFrame, FRAME_TYPE_REQUEST, FrameParser, FRAME_TYPE_RESPONSE, decodeTransportMessage, FRAME_TYPE_STREAM_CHUNK, FRAME_TYPE_STREAM_END } from '../../chunk-PM52SMBT.mjs';
2
- import { MAX_MESSAGE_SIZE_BYTES, TransportError, TransportErrorCodes } from '../../chunk-JQUL2T6I.mjs';
1
+ import { DEFAULT_TCP_CONFIG, encodeTransportMessage, encodeFrame, FRAME_TYPE_REQUEST, FrameParser, FRAME_TYPE_RESPONSE, decodeTransportMessage, FRAME_TYPE_STREAM_CHUNK, FRAME_TYPE_STREAM_END } from '../../chunk-OOSIDHA3.mjs';
2
+ import { MAX_MESSAGE_SIZE_BYTES } from '../../chunk-UNEEFTEU.mjs';
3
+ import { TransportError, TransportErrorCodes } from '../../chunk-GCM3JFVA.mjs';
3
4
  import { connect as connect$1, createServer as createServer$1 } from 'net';
4
5
  import { connect, createServer } from 'tls';
5
6
 
@@ -1,12 +1,12 @@
1
- import { a as CreateIndexOptions, C as ClusterNamespace, b as ClusterNodeConfig } from './config-B-ZI-ft5.js';
2
- export { c as ClusterControllerConfig, d as ClusterNodeInfo, e as ClusterQueryConfig, N as NodeReadiness, R as ReplicationConfig } from './config-B-ZI-ft5.js';
3
- import { N as NarsilEventMap, a as Narsil } from './engine-Cjr1uBLa.js';
4
- import { B as BatchResult, L as ListParams, g as ListResult, i as SuggestParams, j as SuggestResult, Q as QueryParams, h as PreflightResult, f as IndexStats, P as PartitionStatsResult, M as MemoryStats, e as QueryResult } from './search-DDHjfXhJ.js';
5
- import { I as IndexConfig, A as AnyDocument, b as InsertOptions } from './schema-B7juWg8Q.js';
6
- import { b as NodeCapacity, N as NodeRole } from './types-DsSSjY4d.js';
7
- export { c as AllocationConstraints, d as AllocationEvent, A as AllocationTable, C as ClusterCoordinator, e as NodeEvent, a as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent, U as UnassignedReason } from './types-DsSSjY4d.js';
1
+ import { a as CreateIndexOptions, C as ClusterNamespace, b as ClusterNodeConfig } from './config-Czh2YNDi.js';
2
+ export { c as ClusterControllerConfig, d as ClusterNodeInfo, e as ClusterQueryConfig, N as NodeReadiness, R as ReplicationConfig } from './config-Czh2YNDi.js';
3
+ import { N as NarsilEventMap, a as Narsil } from './engine-9PtFY50q.js';
4
+ import { B as BatchResult, L as ListParams, g as ListResult, i as SuggestParams, j as SuggestResult, Q as QueryParams, h as PreflightResult, f as IndexStats, P as PartitionStatsResult, M as MemoryStats, e as QueryResult } from './memory-Bzd5xcEW.js';
5
+ import { I as IndexConfig, A as AnyDocument, b as InsertOptions } from './schema-BqRx9t4E.js';
6
+ import { b as NodeCapacity, N as NodeRole } from './types-DXPxaXPO.js';
7
+ export { c as AllocationConstraints, d as AllocationEvent, A as AllocationTable, C as ClusterCoordinator, e as NodeEvent, a as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent, U as UnassignedReason } from './types-DXPxaXPO.js';
8
8
  export { L as ListenHandler, N as NodeTransport, R as RespondFn, T as TransportConfig, a as TransportMessage } from './types-D5OwhtsQ.js';
9
- import './config-BZRExglL.js';
9
+ import './config-OON7IJ_B.js';
10
10
  import './adapters-79OIa4xm.js';
11
11
 
12
12
  /**