@delali/narsil 0.2.0 → 0.2.1

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 (151) hide show
  1. package/dist/adapters/filesystem.d.ts +23 -1
  2. package/dist/adapters/filesystem.mjs +1 -1
  3. package/dist/adapters/indexeddb.d.ts +25 -1
  4. package/dist/adapters/indexeddb.mjs +1 -1
  5. package/dist/adapters/memory.d.ts +14 -1
  6. package/dist/adapters-CVqI5NBt.d.ts +149 -0
  7. package/dist/{chunk-S6IAXOBA.mjs → chunk-ASI6AOW2.mjs} +1 -1
  8. package/dist/{chunk-AUMKFYTG.mjs → chunk-FKK76OR7.mjs} +56 -55
  9. package/dist/{chunk-M2EDG55Y.mjs → chunk-UNJZ7ZDB.mjs} +10 -0
  10. package/dist/{chunk-XAKNSWIK.mjs → chunk-WLR5BFL3.mjs} +16 -14
  11. package/dist/config-CAjTHzkH.d.ts +256 -0
  12. package/dist/{direct-executor-2FV3MEDD.mjs → direct-executor-3W4QRA4E.mjs} +2 -2
  13. package/dist/distribution/coordinator/etcd.d.ts +44 -3
  14. package/dist/distribution/coordinator/etcd.mjs +2 -2
  15. package/dist/distribution/coordinator/in-memory.d.ts +14 -3
  16. package/dist/distribution.d.ts +312 -45
  17. package/dist/distribution.mjs +4 -4
  18. package/dist/embeddings/openai.d.ts +28 -1
  19. package/dist/embeddings/openai.mjs +1 -1
  20. package/dist/engine-CCrlfLyq.d.ts +431 -0
  21. package/dist/index.browser.mjs +24 -12
  22. package/dist/index.d.ts +173 -8
  23. package/dist/index.mjs +3 -3
  24. package/dist/invalidation/broadcast-channel.d.ts +20 -1
  25. package/dist/invalidation/filesystem.d.ts +24 -1
  26. package/dist/invalidation/noop.d.ts +14 -1
  27. package/dist/language-DB8KG1z5.d.ts +53 -0
  28. package/dist/languages/albanian.d.ts +11 -1
  29. package/dist/languages/amharic.d.ts +11 -1
  30. package/dist/languages/arabic.d.ts +10 -1
  31. package/dist/languages/armenian.d.ts +10 -1
  32. package/dist/languages/azerbaijani.d.ts +11 -1
  33. package/dist/languages/bambara.d.ts +11 -1
  34. package/dist/languages/basque.d.ts +10 -1
  35. package/dist/languages/belarusian.d.ts +11 -1
  36. package/dist/languages/bengali.d.ts +11 -1
  37. package/dist/languages/bosnian.d.ts +11 -1
  38. package/dist/languages/breton.d.ts +11 -1
  39. package/dist/languages/bulgarian.d.ts +10 -1
  40. package/dist/languages/burmese.d.ts +11 -1
  41. package/dist/languages/catalan.d.ts +10 -1
  42. package/dist/languages/chinese.d.ts +11 -1
  43. package/dist/languages/croatian.d.ts +11 -1
  44. package/dist/languages/czech.d.ts +10 -1
  45. package/dist/languages/dagbani.d.ts +11 -1
  46. package/dist/languages/danish.d.ts +10 -1
  47. package/dist/languages/dutch.d.ts +10 -1
  48. package/dist/languages/english.d.ts +10 -1
  49. package/dist/languages/esperanto.d.ts +10 -1
  50. package/dist/languages/estonian.d.ts +10 -1
  51. package/dist/languages/ewe.d.ts +11 -1
  52. package/dist/languages/faroese.d.ts +11 -1
  53. package/dist/languages/fijian.d.ts +11 -1
  54. package/dist/languages/finnish.d.ts +10 -1
  55. package/dist/languages/french.d.ts +10 -1
  56. package/dist/languages/ga.d.ts +11 -1
  57. package/dist/languages/galician.d.ts +11 -1
  58. package/dist/languages/georgian.d.ts +11 -1
  59. package/dist/languages/german.d.ts +10 -1
  60. package/dist/languages/greek.d.ts +10 -1
  61. package/dist/languages/guarani.d.ts +11 -1
  62. package/dist/languages/gujarati.d.ts +11 -1
  63. package/dist/languages/haitian-creole.d.ts +11 -1
  64. package/dist/languages/hausa.d.ts +11 -1
  65. package/dist/languages/hawaiian.d.ts +11 -1
  66. package/dist/languages/hebrew.d.ts +11 -1
  67. package/dist/languages/hindi.d.ts +10 -1
  68. package/dist/languages/hungarian.d.ts +10 -1
  69. package/dist/languages/icelandic.d.ts +11 -1
  70. package/dist/languages/igbo.d.ts +11 -1
  71. package/dist/languages/indonesian.d.ts +10 -1
  72. package/dist/languages/irish.d.ts +10 -1
  73. package/dist/languages/italian.d.ts +10 -1
  74. package/dist/languages/japanese.d.ts +11 -1
  75. package/dist/languages/kannada.d.ts +11 -1
  76. package/dist/languages/kazakh.d.ts +11 -1
  77. package/dist/languages/khmer.d.ts +11 -1
  78. package/dist/languages/kinyarwanda.d.ts +11 -1
  79. package/dist/languages/kirundi.d.ts +11 -1
  80. package/dist/languages/korean.d.ts +11 -1
  81. package/dist/languages/kurmanji.d.ts +11 -1
  82. package/dist/languages/kyrgyz.d.ts +11 -1
  83. package/dist/languages/lao.d.ts +11 -1
  84. package/dist/languages/latin.d.ts +11 -1
  85. package/dist/languages/latvian.d.ts +11 -1
  86. package/dist/languages/lingala.d.ts +11 -1
  87. package/dist/languages/lithuanian.d.ts +10 -1
  88. package/dist/languages/luxembourgish.d.ts +11 -1
  89. package/dist/languages/macedonian.d.ts +11 -1
  90. package/dist/languages/malagasy.d.ts +11 -1
  91. package/dist/languages/malay.d.ts +11 -1
  92. package/dist/languages/malayalam.d.ts +11 -1
  93. package/dist/languages/maltese.d.ts +11 -1
  94. package/dist/languages/maori.d.ts +11 -1
  95. package/dist/languages/marathi.d.ts +11 -1
  96. package/dist/languages/nepali.d.ts +10 -1
  97. package/dist/languages/norwegian.d.ts +10 -1
  98. package/dist/languages/oromo.d.ts +11 -1
  99. package/dist/languages/persian.d.ts +10 -1
  100. package/dist/languages/polish.d.ts +10 -1
  101. package/dist/languages/portuguese.d.ts +10 -1
  102. package/dist/languages/punjabi.d.ts +11 -1
  103. package/dist/languages/romanian.d.ts +10 -1
  104. package/dist/languages/russian.d.ts +10 -1
  105. package/dist/languages/samoan.d.ts +11 -1
  106. package/dist/languages/sanskrit.d.ts +10 -1
  107. package/dist/languages/scottish-gaelic.d.ts +11 -1
  108. package/dist/languages/serbian.d.ts +10 -1
  109. package/dist/languages/shona.d.ts +11 -1
  110. package/dist/languages/sinhala.d.ts +11 -1
  111. package/dist/languages/slovak.d.ts +11 -1
  112. package/dist/languages/slovenian.d.ts +10 -1
  113. package/dist/languages/sorani.d.ts +11 -1
  114. package/dist/languages/spanish.d.ts +10 -1
  115. package/dist/languages/swahili.d.ts +10 -1
  116. package/dist/languages/swedish.d.ts +10 -1
  117. package/dist/languages/tagalog.d.ts +11 -1
  118. package/dist/languages/tamil.d.ts +10 -1
  119. package/dist/languages/tatar.d.ts +11 -1
  120. package/dist/languages/telugu.d.ts +11 -1
  121. package/dist/languages/thai.d.ts +11 -1
  122. package/dist/languages/tibetan.d.ts +11 -1
  123. package/dist/languages/tigrinya.d.ts +11 -1
  124. package/dist/languages/tongan.d.ts +11 -1
  125. package/dist/languages/turkish.d.ts +10 -1
  126. package/dist/languages/twi.d.ts +11 -1
  127. package/dist/languages/ukrainian.d.ts +10 -1
  128. package/dist/languages/urdu.d.ts +11 -1
  129. package/dist/languages/vietnamese.d.ts +11 -1
  130. package/dist/languages/welsh.d.ts +11 -1
  131. package/dist/languages/wolof.d.ts +11 -1
  132. package/dist/languages/xhosa.d.ts +11 -1
  133. package/dist/languages/yoruba.d.ts +11 -1
  134. package/dist/languages/zulu.d.ts +11 -1
  135. package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
  136. package/dist/persistence/durability/checkpoint-worker.mjs +3 -3
  137. package/dist/schema-CE6S_aAr.d.ts +208 -0
  138. package/dist/search-CgQQIciB.d.ts +786 -0
  139. package/dist/server.d.ts +213 -12
  140. package/dist/server.mjs +29 -1
  141. package/dist/types-BV3nAKTL.d.ts +302 -0
  142. package/dist/vector/hnsw-build-worker.d.ts +68 -2
  143. package/dist/vector/hnsw-build-worker.mjs +0 -2
  144. package/dist/workers/entry.mjs +1 -1
  145. package/package.json +5 -2
  146. package/dist/adapters-Bo2JQg8b.d.ts +0 -37
  147. package/dist/config-P27AtSn4.d.ts +0 -502
  148. package/dist/language-CmJBHf1j.d.ts +0 -17
  149. package/dist/narsil-CMZRPDlQ.d.ts +0 -159
  150. package/dist/schema-BnvLvjRp.d.ts +0 -67
  151. package/dist/types-BRTcBgAp.d.ts +0 -73
@@ -1,128 +1,395 @@
1
- import { C as ClusterCoordinator, N as NodeRegistration, A as AllocationTable, a as NodeRole, b as NodeCapacity } from './types-BRTcBgAp.js';
2
- export { c as AllocationConstraints, d as AllocationEvent, e as NodeEvent, P as PartitionAssignment, f as PartitionState, S as SchemaEvent } from './types-BRTcBgAp.js';
3
- import { I as IndexConfig, A as AnyDocument } from './schema-BnvLvjRp.js';
4
- import { B as BatchResult, Q as QueryParams, t as QueryResult, N as NarsilConfig } from './config-P27AtSn4.js';
1
+ import { N as NarsilConfig } from './config-CAjTHzkH.js';
2
+ import { B as BatchResult, Q as QueryParams, q as QueryResult } from './search-CgQQIciB.js';
3
+ import { I as IndexConfig, A as AnyDocument } from './schema-CE6S_aAr.js';
4
+ import { A as AllocationTable, N as NodeRole, C as ClusterCoordinator, a as NodeCapacity } from './types-BV3nAKTL.js';
5
+ export { b as AllocationConstraints, c as AllocationEvent, d as NodeEvent, e as NodeRegistration, P as PartitionAssignment, f as PartitionState, S as SchemaEvent } from './types-BV3nAKTL.js';
5
6
  export { createInMemoryCoordinator } from './distribution/coordinator/in-memory.js';
6
- import './adapters-Bo2JQg8b.js';
7
+ import './adapters-CVqI5NBt.js';
7
8
 
9
+ /**
10
+ * How much replication history a primary keeps, and how many replicas have to
11
+ * confirm a write before it is acknowledged.
12
+ *
13
+ * A replica that falls further behind than the retained log recovers from a
14
+ * whole snapshot instead of replaying entries, so a larger retention trades
15
+ * memory for cheaper recovery.
16
+ *
17
+ * @public
18
+ */
8
19
  interface ReplicationConfig {
20
+ /** A primary keeps this many bytes of replication log before it drops the oldest entries. */
9
21
  logRetentionBytes: number;
22
+ /** This many replicas must acknowledge a write before the primary reports it as done. */
10
23
  waitForActiveReplicas: number;
11
24
  }
12
25
 
26
+ /**
27
+ * One message on the wire between cluster nodes.
28
+ *
29
+ * The payload is opaque bytes, which is what lets a node written in another
30
+ * language join the same cluster: only the header fields have to agree.
31
+ *
32
+ * @public
33
+ */
13
34
  interface TransportMessage {
35
+ /** This says what the message is, such as a replication entry or a search request. */
14
36
  type: string;
37
+ /** This node sent the message. */
15
38
  sourceId: string;
39
+ /** This correlates a reply with its request. */
16
40
  requestId: string;
41
+ /** This carries the encoded body, and the message type tells a reader how to decode it. */
17
42
  payload: Uint8Array;
18
43
  }
44
+ /**
45
+ * How long a transport waits before giving up on each kind of exchange.
46
+ *
47
+ * Every value is in milliseconds. Replication and snapshot transfers carry
48
+ * their own timeouts because they move far more than a search does.
49
+ *
50
+ * @public
51
+ */
19
52
  interface TransportConfig {
53
+ /** Opening a connection to a peer may take this long. */
20
54
  connectTimeout: number;
55
+ /** An ordinary request and its reply may take this long. */
21
56
  requestTimeout: number;
57
+ /** A replication entry may take this long to reach a replica and come back acknowledged. */
22
58
  replicationTimeout: number;
59
+ /** A whole snapshot transfer, which moves a partition between nodes, may take this long. */
23
60
  snapshotTimeout: number;
24
61
  }
62
+ /**
63
+ * How one cluster node reaches the others.
64
+ *
65
+ * The package includes a TCP transport for real deployments and an in-process
66
+ * one for tests, and this is the contract either satisfies. Write your own to
67
+ * run a cluster over something else.
68
+ *
69
+ * @public
70
+ */
25
71
  interface NodeTransport {
72
+ /**
73
+ * Sends one request to a peer and waits for its reply.
74
+ *
75
+ * @param target - Node id to send to.
76
+ * @param message - The request.
77
+ * @returns The peer's reply.
78
+ * @throws A `TransportError` when the peer is unreachable, the message is
79
+ * oversized, or the request times out.
80
+ */
26
81
  send(target: string, message: TransportMessage): Promise<TransportMessage>;
82
+ /**
83
+ * Sends one request whose reply arrives in chunks, which is how a snapshot
84
+ * moves without being held in memory whole.
85
+ *
86
+ * @param target - Node id to send to.
87
+ * @param message - The request.
88
+ * @param handler - Called once per chunk, in order.
89
+ */
27
90
  stream(target: string, message: TransportMessage, handler: (chunk: Uint8Array) => void): Promise<void>;
91
+ /**
92
+ * Starts accepting requests from peers.
93
+ *
94
+ * @param handler - Called for each request, with the function that returns
95
+ * the reply.
96
+ * @returns A function that ends the listener.
97
+ */
28
98
  listen(handler: (message: TransportMessage, respond: (response: TransportMessage) => void) => void | Promise<void>): Promise<() => void>;
99
+ /** Closes every connection and releases the port or registration it held. */
29
100
  shutdown(): Promise<void>;
30
101
  }
31
102
 
32
- interface ControllerConfig {
33
- nodeId: string;
34
- coordinator: ClusterCoordinator;
35
- transport: NodeTransport;
36
- leaseTtlMs: number;
37
- standbyRetryMs: number;
38
- knownIndexNames: string[];
39
- onError?: (indexName: string, error: unknown) => void;
40
- }
41
- interface ControllerNode {
42
- readonly isActive: boolean;
43
- start(): Promise<void>;
44
- stop(): Promise<void>;
45
- shutdown(): Promise<void>;
46
- }
47
-
48
- type DataNodeLifecycleStatus = 'stopped' | 'joining' | 'active' | 'leaving' | 'shutdown';
49
- interface NodeLifecycleConfig {
50
- registration: NodeRegistration;
51
- coordinator: ClusterCoordinator;
52
- transport: NodeTransport;
53
- knownIndexNames: string[];
54
- bootstrapRetryBaseMs: number;
55
- bootstrapRetryMaxMs: number;
56
- bootstrapMaxRetries: number;
57
- allocationDebounceMs: number;
58
- onBootstrapPartition: (indexName: string, partitionId: number, primaryNodeId: string) => Promise<boolean>;
59
- onRemovePartition?: (indexName: string, partitionId: number) => void;
60
- onPrimaryDemotion?: (indexName: string, partitionId: number, newPrimaryNodeId: string) => void;
61
- onError?: (error: unknown) => void;
62
- }
63
- interface DataNodeHandle {
64
- readonly status: DataNodeLifecycleStatus;
65
- readonly nodeId: string;
66
- join(): Promise<void>;
67
- leave(): Promise<void>;
68
- shutdown(): Promise<void>;
69
- }
70
-
103
+ /**
104
+ * Everything {@link createClusterNode} needs to join a node to a cluster.
105
+ *
106
+ * The coordinator and the transport are the two pieces you choose: the
107
+ * coordinator holds the cluster's shared state, and the transport carries
108
+ * messages between nodes.
109
+ *
110
+ * @public
111
+ */
71
112
  interface ClusterNodeConfig {
113
+ /** This node reads and writes the cluster's shared state here. Every node in a cluster must point at the same one. */
72
114
  coordinator: ClusterCoordinator;
115
+ /** This node reaches its peers through this transport. */
73
116
  transport: NodeTransport;
117
+ /** Peers reach this node at this address, as the transport writes it. */
74
118
  address: string;
119
+ /** This node holds these roles in the cluster, and holds data alone by default. */
75
120
  roles?: NodeRole[];
121
+ /** This identifies the node across the cluster. The package generates an id by default, which a restart changes. */
76
122
  nodeId?: string;
123
+ /** This node offers this much capacity, which the allocator weighs. It offers {@link DEFAULT_CAPACITY} by default. */
77
124
  capacity?: NodeCapacity;
125
+ /** These settings configure the engine this node runs locally, such as its persistence and durability. */
78
126
  engine?: NarsilConfig;
127
+ /** These replication settings override the engine's own, and anything you leave out keeps its value. */
79
128
  replication?: Partial<ReplicationConfig>;
129
+ /** This receives the failures the node reports while running on its own, away from any call you made. */
80
130
  onError?: (error: Error) => void;
81
131
  }
132
+ /**
133
+ * How an index is spread across the cluster when a node creates it.
134
+ *
135
+ * @public
136
+ */
82
137
  interface CreateIndexOptions {
138
+ /** The cluster splits the index into this many partitions, and into {@link DEFAULT_PARTITION_COUNT} by default. */
83
139
  partitionCount?: number;
140
+ /** The cluster keeps this many copies of each partition, and {@link DEFAULT_REPLICATION_FACTOR} by default. */
84
141
  replicationFactor?: number;
85
142
  }
143
+ /**
144
+ * The cluster-facing side of a node, which is where you look at the cluster
145
+ * rather than at the data.
146
+ *
147
+ * @public
148
+ */
86
149
  interface ClusterNamespace {
150
+ /**
151
+ * Reads how one index is spread across the cluster.
152
+ *
153
+ * @param indexName - The index to describe.
154
+ * @returns Its allocation, or `null` when the index has none yet.
155
+ */
87
156
  getAllocation(indexName: string): Promise<AllocationTable | null>;
157
+ /**
158
+ * Describes this node.
159
+ *
160
+ * @returns Its id, its roles, and where it stands.
161
+ */
88
162
  getNodeInfo(): ClusterNodeInfo;
163
+ /**
164
+ * Reports whether this node is the cluster's active controller, which is the
165
+ * one node making allocation decisions.
166
+ *
167
+ * @returns True while this node holds the controller lease.
168
+ */
89
169
  isControllerActive(): boolean;
90
170
  }
171
+ /**
172
+ * What one node reports about itself.
173
+ *
174
+ * @public
175
+ */
91
176
  interface ClusterNodeInfo {
177
+ /** This identifies the node across the cluster. */
92
178
  nodeId: string;
179
+ /** The node holds these roles in the cluster. */
93
180
  roles: ReadonlyArray<NodeRole>;
181
+ /** This says where the node stands, from joining through to shut down. */
94
182
  status: string;
95
183
  }
184
+ /**
185
+ * One node of a cluster, which routes each write to the partition's primary
186
+ * and gathers each search from every partition.
187
+ *
188
+ * The write and search methods mirror {@link Narsil}, so code moving from a
189
+ * single engine to a cluster keeps its shape. Build one with
190
+ * {@link createClusterNode}.
191
+ *
192
+ * @public
193
+ */
96
194
  interface ClusterNode {
195
+ /** This identifies the node across the cluster. */
97
196
  readonly nodeId: string;
197
+ /** The node holds these roles in the cluster. */
98
198
  readonly roles: ReadonlyArray<NodeRole>;
199
+ /**
200
+ * Creates an index across the cluster, publishing its schema and allocating
201
+ * its partitions to nodes.
202
+ *
203
+ * @param name - Every later call uses this name to reach the index.
204
+ * @param config - The schema, and the language, scoring, and vector
205
+ * settings, exactly as a single engine takes them.
206
+ * @param options - How the index is spread across the cluster.
207
+ */
99
208
  createIndex(name: string, config: IndexConfig, options?: CreateIndexOptions): Promise<void>;
209
+ /**
210
+ * Adds one document, routing it to the partition's primary.
211
+ *
212
+ * @param indexName - The index that receives the document.
213
+ * @param document - Its fields must match the types the schema declares.
214
+ * @param docId - Pass an id to control it yourself, or omit it and read the
215
+ * returned value.
216
+ * @returns The id the document is stored under.
217
+ */
100
218
  insert(indexName: string, document: AnyDocument, docId?: string): Promise<string>;
219
+ /**
220
+ * Adds many documents, routing each to its own partition's primary, and
221
+ * reports each one's outcome.
222
+ *
223
+ * @param indexName - The index that receives the documents.
224
+ * @param documents - The documents to write.
225
+ * @returns The ids written, and each rejection with its error.
226
+ */
101
227
  insertBatch(indexName: string, documents: AnyDocument[]): Promise<BatchResult>;
228
+ /**
229
+ * Removes one document.
230
+ *
231
+ * @param indexName - The index holding the document.
232
+ * @param docId - The document to remove.
233
+ */
102
234
  remove(indexName: string, docId: string): Promise<void>;
235
+ /**
236
+ * Removes many documents and reports each one's outcome.
237
+ *
238
+ * @param indexName - The index holding the documents.
239
+ * @param docIds - The documents to remove.
240
+ * @returns The ids removed, and each failure with its error.
241
+ */
103
242
  removeBatch(indexName: string, docIds: string[]): Promise<BatchResult>;
243
+ /**
244
+ * Runs a search across every partition and merges the results into one
245
+ * ranking.
246
+ *
247
+ * The search skips a partition whose nodes are all unreachable instead of
248
+ * failing, so read the result's count against what you expect.
249
+ *
250
+ * @typeParam T - Shape of the stored documents.
251
+ * @param indexName - The index the search runs against.
252
+ * @param params - The same parameters a single engine takes.
253
+ * @returns The merged hits, the total count, and the elapsed time.
254
+ */
104
255
  query<T = AnyDocument>(indexName: string, params: QueryParams): Promise<QueryResult<T>>;
256
+ /** This reaches the cluster-facing side of the node. */
105
257
  cluster: ClusterNamespace;
258
+ /** Joins the cluster: the node registers, takes on its allocated partitions, and starts serving. */
106
259
  start(): Promise<void>;
260
+ /** Leaves the cluster: the node hands its partitions on, deregisters, and closes the engine it ran. */
107
261
  shutdown(): Promise<void>;
108
262
  }
263
+ /**
264
+ * The cluster splits an index into this many partitions when
265
+ * {@link CreateIndexOptions} names no count.
266
+ *
267
+ * @public
268
+ */
109
269
  declare const DEFAULT_PARTITION_COUNT = 5;
270
+ /**
271
+ * The cluster keeps this many copies of each partition when
272
+ * {@link CreateIndexOptions} names no factor. One copy means a lost node costs
273
+ * that partition, so raise it for anything you cannot rebuild.
274
+ *
275
+ * @public
276
+ */
110
277
  declare const DEFAULT_REPLICATION_FACTOR = 1;
278
+ /**
279
+ * A node claims this much capacity when {@link ClusterNodeConfig} declares
280
+ * none. Measure your own hosts and set it, because these figures are a
281
+ * placeholder rather than a reading.
282
+ *
283
+ * @public
284
+ */
111
285
  declare const DEFAULT_CAPACITY: NodeCapacity;
112
286
 
287
+ /**
288
+ * Builds one node of a cluster, ready to join.
289
+ *
290
+ * The node is idle until you call {@link ClusterNode.start}, which registers
291
+ * it, takes on the partitions the controller allocates to it, and starts
292
+ * answering. A node whose roles include `controller` stands for election and
293
+ * runs allocation for the whole cluster while it holds the lease.
294
+ *
295
+ * @param config - The coordinator, the transport, this node's address, and the
296
+ * settings for the engine it runs locally.
297
+ * @returns The node, ready for {@link ClusterNode.start}.
298
+ *
299
+ * @public
300
+ */
113
301
  declare function createClusterNode(config: ClusterNodeConfig): Promise<ClusterNode>;
114
302
 
303
+ /**
304
+ * Receives the chunks a streamed response carries, in order.
305
+ *
306
+ * @param chunks - Every chunk the responder produced.
307
+ *
308
+ * @public
309
+ */
115
310
  type StreamResponder = (chunks: Uint8Array[]) => void;
311
+ /**
312
+ * The delivery side of an in-memory transport, which the network calls to hand
313
+ * a peer its message.
314
+ *
315
+ * You reach this through {@link InMemoryNetwork} rather than building one, so
316
+ * treat it as the connection between two in-process nodes.
317
+ *
318
+ * @public
319
+ */
116
320
  interface InMemoryTransportInternal extends NodeTransport {
321
+ /**
322
+ * Delivers one request to this node's listener.
323
+ *
324
+ * @param message - The request the sender posted.
325
+ * @param respond - Hands the reply back to the sender.
326
+ */
117
327
  deliverMessage(message: TransportMessage, respond: (response: TransportMessage) => void): void;
328
+ /**
329
+ * Delivers one streamed request to this node's listener.
330
+ *
331
+ * @param message - The request the sender posted.
332
+ * @param responder - Hands the chunks back to the sender.
333
+ */
118
334
  deliverStream(message: TransportMessage, responder: StreamResponder): void;
119
335
  }
336
+ /**
337
+ * The switchboard that connects in-process cluster nodes to each other.
338
+ *
339
+ * Every node registers its transport under its own id, and a message addressed
340
+ * to a node is handed straight to the transport registered under that id. This
341
+ * runs a whole cluster inside one process, which is what tests and local
342
+ * development use in place of TCP.
343
+ *
344
+ * @public
345
+ */
120
346
  interface InMemoryNetwork {
347
+ /**
348
+ * Makes a node reachable under its id.
349
+ *
350
+ * @param nodeId - The id peers address this node by.
351
+ * @param transport - The transport that receives its messages.
352
+ */
121
353
  register(nodeId: string, transport: InMemoryTransportInternal): void;
354
+ /**
355
+ * Makes a node unreachable, so a message addressed to it fails.
356
+ *
357
+ * @param nodeId - The node to remove.
358
+ */
122
359
  unregister(nodeId: string): void;
360
+ /**
361
+ * Looks a node's transport up.
362
+ *
363
+ * @param nodeId - The node to find.
364
+ * @returns Its transport, or `undefined` when no node holds that id.
365
+ */
123
366
  getTransport(nodeId: string): InMemoryTransportInternal | undefined;
124
367
  }
368
+ /**
369
+ * Builds the switchboard that connects in-process cluster nodes.
370
+ *
371
+ * Create one network, then create a transport per node against it, which is
372
+ * how a whole cluster runs inside a single process.
373
+ *
374
+ * @returns An empty network, ready for nodes to register against.
375
+ *
376
+ * @public
377
+ */
125
378
  declare function createInMemoryNetwork(): InMemoryNetwork;
379
+ /**
380
+ * Builds one node's transport and registers it on an in-process network.
381
+ *
382
+ * The network hands each message straight to the addressed node with no socket
383
+ * in between, so a cluster built this way behaves like a real one without any
384
+ * ports to open.
385
+ *
386
+ * @param nodeId - The id peers address this node by.
387
+ * @param network - The network this node joins.
388
+ * @param config - The timeouts to override. Omit it to accept the defaults.
389
+ * @returns The transport you pass as a cluster node's `transport`.
390
+ *
391
+ * @public
392
+ */
126
393
  declare function createInMemoryTransport(nodeId: string, network: InMemoryNetwork, config?: Partial<TransportConfig>): NodeTransport;
127
394
 
128
- export { AllocationTable, ClusterCoordinator, type ClusterNamespace, type ClusterNode, type ClusterNodeConfig, type ClusterNodeInfo, type ControllerConfig, type ControllerNode, type CreateIndexOptions, DEFAULT_CAPACITY, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, type DataNodeHandle, type InMemoryNetwork, type InMemoryTransportInternal, NodeCapacity, type NodeLifecycleConfig, NodeRegistration, NodeRole, type NodeTransport, type TransportConfig, createClusterNode, createInMemoryNetwork, createInMemoryTransport };
395
+ export { AllocationTable, ClusterCoordinator, type ClusterNamespace, type ClusterNode, type ClusterNodeConfig, type ClusterNodeInfo, type CreateIndexOptions, DEFAULT_CAPACITY, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, type InMemoryNetwork, type InMemoryTransportInternal, NodeCapacity, NodeRole, type NodeTransport, type ReplicationConfig, type StreamResponder, type TransportConfig, type TransportMessage, createClusterNode, createInMemoryNetwork, createInMemoryTransport };
@@ -1,12 +1,12 @@
1
1
  export { createInMemoryCoordinator } from './chunk-RQLXC2YS.mjs';
2
- import './chunk-AUMKFYTG.mjs';
3
- import { ReplicationMessageTypes, ClusterMessageTypes, DEFAULT_TRANSPORT_CONFIG, TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES, createEngineCore, createNarsilFromCore, QueryMessageTypes, applyIndexEntry, applyDeleteEntry, validateEntryPayload, createAckMessage, validateReplicationEntry, MAX_PARTITION_COUNT, MAX_INDEX_NAME_LENGTH, validateIndexName, computeEntryChecksum, createInsyncConfirmMessage, createEntryMessage, getIndexMetadata, validateAckPayload, createInsyncRemoveMessage, validateInsyncConfirmPayload, putIndexMetadata, createForwardMessage } from './chunk-XAKNSWIK.mjs';
4
- import { deserializePayloadV2, createPartitionIndex, getLanguage, fnv1a, mergePartitionStats, MAX_NESTING_DEPTH } from './chunk-S6IAXOBA.mjs';
2
+ import './chunk-FKK76OR7.mjs';
3
+ import { ReplicationMessageTypes, ClusterMessageTypes, DEFAULT_TRANSPORT_CONFIG, TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES, createEngineCore, createNarsilFromCore, QueryMessageTypes, applyIndexEntry, applyDeleteEntry, validateEntryPayload, createAckMessage, validateReplicationEntry, MAX_PARTITION_COUNT, MAX_INDEX_NAME_LENGTH, validateIndexName, computeEntryChecksum, createInsyncConfirmMessage, createEntryMessage, getIndexMetadata, validateAckPayload, createInsyncRemoveMessage, validateInsyncConfirmPayload, putIndexMetadata, createForwardMessage } from './chunk-WLR5BFL3.mjs';
4
+ import { deserializePayloadV2, createPartitionIndex, getLanguage, fnv1a, mergePartitionStats, MAX_NESTING_DEPTH } from './chunk-ASI6AOW2.mjs';
5
5
  import './chunk-TGP5M5R7.mjs';
6
6
  import './chunk-S7RJJMHI.mjs';
7
7
  import { crc32 } from './chunk-KMMJMDUA.mjs';
8
8
  import './chunk-U2BKYEC7.mjs';
9
- import { ErrorCodes, NarsilError } from './chunk-M2EDG55Y.mjs';
9
+ import { ErrorCodes, NarsilError } from './chunk-UNJZ7ZDB.mjs';
10
10
  import { generateId } from './chunk-BKAI2WXI.mjs';
11
11
  import { encode, decode } from '@msgpack/msgpack';
12
12
 
@@ -1,13 +1,40 @@
1
- import { E as EmbeddingAdapter } from '../adapters-Bo2JQg8b.js';
1
+ import { E as EmbeddingAdapter } from '../adapters-CVqI5NBt.js';
2
2
 
3
+ /**
4
+ * How {@link createOpenAIEmbedding} reaches an embeddings endpoint.
5
+ *
6
+ * @public
7
+ */
3
8
  interface OpenAIEmbeddingConfig {
9
+ /** This points the adapter at OpenAI, at Azure, or at a compatible service you host. */
4
10
  baseUrl: string;
11
+ /** This holds the key, or a function returning it, which is how you rotate a key or fetch a short-lived token per request. */
5
12
  apiKey: string | (() => string | Promise<string>);
13
+ /** The adapter embeds with this model. */
6
14
  model: string;
15
+ /** The model returns vectors this long, which must match the schema's `vector[N]`. */
7
16
  dimensions: number;
17
+ /** The adapter aborts a request that runs longer than this many milliseconds. */
8
18
  timeout?: number;
19
+ /** The adapter retries this many times when the service rejects a request as retryable, such as on a rate limit. */
9
20
  maxRetries?: number;
10
21
  }
22
+ /**
23
+ * Builds an embedding adapter that calls an OpenAI-compatible embeddings
24
+ * endpoint, so an index embeds documents as they arrive and embeds a query as
25
+ * it runs.
26
+ *
27
+ * The adapter batches when the engine offers it a batch, retries a request the
28
+ * service says is retryable, and gives up once `maxRetries` is spent.
29
+ *
30
+ * @param config - Endpoint, credentials, model, and vector length.
31
+ * @returns An adapter you pass as `embedding`, or register by name with
32
+ * {@link Narsil.registerEmbeddingAdapter}.
33
+ * @throws A `NarsilError` with `EMBEDDING_CONFIG_INVALID` when the base URL,
34
+ * the model, or the dimension count is missing or out of range.
35
+ *
36
+ * @public
37
+ */
11
38
  declare function createOpenAIEmbedding(config: OpenAIEmbeddingConfig): EmbeddingAdapter;
12
39
 
13
40
  export { type OpenAIEmbeddingConfig, createOpenAIEmbedding };
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes } from '../chunk-M2EDG55Y.mjs';
1
+ import { NarsilError, ErrorCodes } from '../chunk-UNJZ7ZDB.mjs';
2
2
 
3
3
  // src/embeddings/openai.ts
4
4
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503]);