@delali/narsil 0.3.1-next.96 → 0.3.1-next.97

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 (107) hide show
  1. package/README.md +2 -1
  2. package/dist/adapters/filesystem.d.ts +1 -1
  3. package/dist/adapters/filesystem.mjs +1 -1
  4. package/dist/adapters/indexeddb.d.ts +1 -1
  5. package/dist/adapters/indexeddb.mjs +1 -1
  6. package/dist/adapters/memory.d.ts +1 -1
  7. package/dist/{adapters-79OIa4xm.d.ts → adapters-BQFQ4PRz.d.ts} +27 -1
  8. package/dist/browser/{chunk-ZGMR46O3.mjs → chunk-CN4I4FZU.mjs} +2 -2
  9. package/dist/browser/chunk-JPTQZWJQ.mjs +10 -0
  10. package/dist/browser/{chunk-WKPJ4E73.mjs → chunk-LD55ZGU3.mjs} +2 -1
  11. package/dist/browser/{chunk-KPMIHLOV.mjs → chunk-NAFT3K6X.mjs} +240 -135
  12. package/dist/browser/{chunk-3MYKLHRO.mjs → chunk-NNG3EEB6.mjs} +5 -4
  13. package/dist/browser/{chunk-HARBSUWP.mjs → chunk-QWES44AW.mjs} +2 -197
  14. package/dist/browser/chunk-RELZRJNR.mjs +203 -0
  15. package/dist/browser/{chunk-FYFQJKFW.mjs → chunk-Z7QH2XHB.mjs} +40 -45
  16. package/dist/browser/{durability-wiring-R7P64REL.mjs → durability-wiring-PY3L7DES.mjs} +7 -5
  17. package/dist/browser/{module-IEOQI5GI.mjs → module-PDXYHT75.mjs} +18 -10
  18. package/dist/browser/{restore-queue-WMYC5ZK6.mjs → restore-queue-DVIYJ7RU.mjs} +1 -1
  19. package/dist/browser/runtime-NYE5TB6O.mjs +557 -0
  20. package/dist/browser/{snapshot-3A3WDNHO.mjs → snapshot-J57MZK6L.mjs} +8 -6
  21. package/dist/browser/{write-JODZHKIF.mjs → write-L7FAQA47.mjs} +6 -4
  22. package/dist/{capabilities-BvxvFzVA.d.ts → capabilities-BTTIs96E.d.ts} +19 -3
  23. package/dist/{chunk-GJZHU4FC.mjs → chunk-2WYMG3OZ.mjs} +4 -4
  24. package/dist/{chunk-H75XXPMY.mjs → chunk-45AVKHMJ.mjs} +2 -2
  25. package/dist/{chunk-QM3VPX4Z.mjs → chunk-ASY5PHYI.mjs} +2 -2
  26. package/dist/{chunk-RDJKYKMQ.mjs → chunk-AY3AQ3UH.mjs} +1 -1
  27. package/dist/{chunk-2BY6K52M.mjs → chunk-BKB3XTMI.mjs} +6 -6
  28. package/dist/{chunk-MWT5WCJ5.mjs → chunk-COVCQ73F.mjs} +5 -5
  29. package/dist/{chunk-FGMGUDHX.mjs → chunk-E74YLAIG.mjs} +4 -1
  30. package/dist/chunk-FMWRCP2C.mjs +57 -0
  31. package/dist/{chunk-ES33L3HO.mjs → chunk-GGSH6KBQ.mjs} +1 -1
  32. package/dist/chunk-HJSN7UYG.mjs +10 -0
  33. package/dist/{chunk-ICL2AELD.mjs → chunk-HXJBSHXF.mjs} +40 -46
  34. package/dist/{chunk-ZHS44YKF.mjs → chunk-JFRNNBOM.mjs} +1 -1
  35. package/dist/{chunk-CHOGQSHK.mjs → chunk-K25LZA54.mjs} +39 -13
  36. package/dist/chunk-K7D4ZTSW.mjs +126 -0
  37. package/dist/{chunk-SYWGORQB.mjs → chunk-KV3AZFT3.mjs} +2 -0
  38. package/dist/chunk-KZ3NX2P7.mjs +21 -0
  39. package/dist/{chunk-GMY7F2VA.mjs → chunk-L3L5YFXC.mjs} +4 -4
  40. package/dist/{chunk-VVFLEGZI.mjs → chunk-LH4NZNJJ.mjs} +10 -10
  41. package/dist/{chunk-7KC56574.mjs → chunk-LU2CE5AE.mjs} +1 -1
  42. package/dist/{chunk-4ZJWRETC.mjs → chunk-LXPIXDUJ.mjs} +2 -2
  43. package/dist/{chunk-Q5DC6WAB.mjs → chunk-LXWDQLTW.mjs} +1 -1
  44. package/dist/{chunk-SBCEHIPL.mjs → chunk-MHOSCQCQ.mjs} +4 -4
  45. package/dist/{chunk-R36MIGBU.mjs → chunk-NKRBEGJZ.mjs} +169 -130
  46. package/dist/{chunk-LJBJQPB5.mjs → chunk-NTRMFARG.mjs} +7 -7
  47. package/dist/chunk-NW4XDSP2.mjs +212 -0
  48. package/dist/{chunk-BB7MASRQ.mjs → chunk-OOEXLUGR.mjs} +1 -1
  49. package/dist/{chunk-3LYY62M6.mjs → chunk-OWNZYMRE.mjs} +10 -10
  50. package/dist/{chunk-HBVLF3HA.mjs → chunk-PPY2GSIB.mjs} +1 -1
  51. package/dist/{chunk-WLOF6HSP.mjs → chunk-R7EEKAJE.mjs} +12 -3
  52. package/dist/{chunk-2GZGBOQI.mjs → chunk-RONEOEON.mjs} +2 -2
  53. package/dist/{chunk-T2QN2FA4.mjs → chunk-UCDF35PU.mjs} +2 -2
  54. package/dist/{chunk-O5WPRAVZ.mjs → chunk-VWULPWRJ.mjs} +60 -21
  55. package/dist/{chunk-F52QGNZ2.mjs → chunk-WCJKUGHB.mjs} +1 -1
  56. package/dist/{chunk-RUIXODYU.mjs → chunk-YA7XLE2R.mjs} +32 -5
  57. package/dist/{chunk-TCYUAUHF.mjs → chunk-ZG477IPV.mjs} +7 -7
  58. package/dist/chunk-ZYNAMIYX.mjs +113 -0
  59. package/dist/{client-DKwterMb.d.ts → client-i9eLJrw5.d.ts} +3 -3
  60. package/dist/client.d.ts +9 -9
  61. package/dist/client.mjs +2 -0
  62. package/dist/{config-6YBtxekG.d.ts → config-BGB_fDtq.d.ts} +2 -2
  63. package/dist/{config-DPphZfuM.d.ts → config-P__Diiy4.d.ts} +25 -3
  64. package/dist/direct-executor-CXZ66ACP.mjs +22 -0
  65. package/dist/distribution/coordinator/etcd.d.ts +3 -3
  66. package/dist/distribution/coordinator/etcd.mjs +1 -1
  67. package/dist/distribution/coordinator/in-memory.d.ts +3 -3
  68. package/dist/distribution/transport/grpc.mjs +1 -1
  69. package/dist/distribution.d.ts +24 -12
  70. package/dist/distribution.mjs +177 -54
  71. package/dist/{durability-wiring-2VBNYYDY.mjs → durability-wiring-QTHOGFMZ.mjs} +26 -25
  72. package/dist/embeddings/openai.d.ts +2 -2
  73. package/dist/embeddings/openai.mjs +22 -133
  74. package/dist/{engine-CbZmXUp6.d.ts → engine-BGCEm9E_.d.ts} +48 -18
  75. package/dist/{index-ONAEaqtx.d.ts → index-lcdGLyJH.d.ts} +1 -1
  76. package/dist/index.browser.mjs +4 -2
  77. package/dist/index.d.ts +8 -8
  78. package/dist/index.mjs +19 -18
  79. package/dist/invalidation/broadcast-channel.d.ts +1 -1
  80. package/dist/invalidation/filesystem.d.ts +1 -1
  81. package/dist/invalidation/noop.d.ts +1 -1
  82. package/dist/{memory-COdoGthn.d.ts → memory-CUEDwr-F.d.ts} +70 -2
  83. package/dist/{module-IUTNXWMV.mjs → module-3NONKBZX.mjs} +25 -18
  84. package/dist/partial-words.mjs +6 -6
  85. package/dist/pattern.mjs +3 -3
  86. package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
  87. package/dist/persistence/durability/checkpoint-worker.mjs +23 -22
  88. package/dist/react.d.ts +8 -8
  89. package/dist/react.mjs +2 -0
  90. package/dist/rerank-NWTKK636.mjs +60 -0
  91. package/dist/rerankers/http.d.ts +50 -0
  92. package/dist/rerankers/http.mjs +104 -0
  93. package/dist/{restore-queue-UFIQJTSG.mjs → restore-queue-JPRBUYII.mjs} +1 -1
  94. package/dist/runtime-ZKYZFJJC.mjs +177 -0
  95. package/dist/{schema-DttzM-ln.d.ts → schema-4W_7tk1f.d.ts} +2 -2
  96. package/dist/server.d.ts +11 -11
  97. package/dist/server.mjs +63 -22
  98. package/dist/{snapshot-XII3ANGW.mjs → snapshot-HOGXNO5W.mjs} +29 -28
  99. package/dist/synonyms.mjs +3 -3
  100. package/dist/{tasks-BJmamiC4.d.ts → tasks-HG3rlxx6.d.ts} +1 -1
  101. package/dist/{thread-U7XYJWGG.mjs → thread-B657LQXK.mjs} +49 -30
  102. package/dist/vector/search-worker.d.ts +6 -2
  103. package/dist/vector/search-worker.mjs +9 -7
  104. package/dist/workers/entry.mjs +5 -5
  105. package/dist/{write-6M3VG4TU.mjs → write-XLIGTXBU.mjs} +21 -20
  106. package/package.json +11 -7
  107. package/dist/direct-executor-5KJGVQHM.mjs +0 -22
@@ -0,0 +1,557 @@
1
+ import { MIN_RERANK_TIMEOUT_MS, MAX_RERANK_TIMEOUT_MS, MIN_RERANK_WINDOW, MAX_RERANK_WINDOW, DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS, DEFAULT_RERANK_WINDOW } from './chunk-JPTQZWJQ.mjs';
2
+ import { NarsilError, ErrorCodes, MIN_HYBRID_DEPTH, MAX_HYBRID_DEPTH, HYBRID_RESCORE_WINDOW, DEFAULT_LIMIT, DEFAULT_OFFSET, RESULT_WINDOW } from './chunk-RELZRJNR.mjs';
3
+
4
+ // src/search/hybrid-depth.ts
5
+ function fixedHybridDepthOf(hybrid) {
6
+ const depth = hybrid?.depth;
7
+ if (depth === void 0 || depth === null) return void 0;
8
+ if (!Number.isInteger(depth) || depth < MIN_HYBRID_DEPTH || depth > MAX_HYBRID_DEPTH) {
9
+ throw new NarsilError(
10
+ ErrorCodes.CONFIG_INVALID,
11
+ `hybrid.depth must be a whole number from ${MIN_HYBRID_DEPTH} to ${MAX_HYBRID_DEPTH}`,
12
+ { depth }
13
+ );
14
+ }
15
+ return depth;
16
+ }
17
+ function requireWithinHybridDepth(cursorDepth, offset, depth) {
18
+ const start = cursorDepth + offset;
19
+ if (start < depth) return;
20
+ throw new NarsilError(
21
+ ErrorCodes.SEARCH_RESULT_WINDOW_EXCEEDED,
22
+ `A hybrid query pages through the first ${depth} fused results, and this page starts at ${start}. Raise hybrid.depth to page further`,
23
+ { offset, cursorDepth, depth }
24
+ );
25
+ }
26
+
27
+ // src/search/position-page.ts
28
+ function lastOrganic(page, pinnedIds) {
29
+ for (let i = page.length - 1; i >= 0; i--) {
30
+ if (pinnedIds === void 0 || !pinnedIds.has(page[i].id)) return page[i];
31
+ }
32
+ return void 0;
33
+ }
34
+ function positionOf(organic, id) {
35
+ for (let i = 0; i < organic.length; i++) {
36
+ if (organic[i].id === id) return i;
37
+ }
38
+ return -1;
39
+ }
40
+ function pageByPosition(placed, organic, { start, limit, pinnedIds, binding, encodeCursor }) {
41
+ if (limit <= 0) return { page: [] };
42
+ const page = placed.slice(start, start + limit);
43
+ const last = lastOrganic(page, pinnedIds);
44
+ if (placed.length <= start + limit || last === void 0) return { page };
45
+ const depth = pinnedIds === void 0 ? start + page.lastIndexOf(last) + 1 : positionOf(organic, last.id) + 1;
46
+ const cursor = encodeCursor({
47
+ anchor: last.id,
48
+ score: last.score ?? null,
49
+ sortKey: null,
50
+ sortSignature: null,
51
+ depth,
52
+ binding
53
+ });
54
+ return { page, cursor };
55
+ }
56
+
57
+ // src/engine/query/hybrid-depth.ts
58
+ function countOfUnion(text, vectorScored) {
59
+ const textIds = /* @__PURE__ */ new Set();
60
+ for (const doc of text.scored) textIds.add(doc.docId);
61
+ let vectorOnly = 0;
62
+ for (const doc of vectorScored) if (!textIds.has(doc.docId)) vectorOnly++;
63
+ if (text.scored.length === text.totalMatched) return text.totalMatched + vectorOnly;
64
+ return Math.max(text.totalMatched, text.scored.length + vectorOnly);
65
+ }
66
+ async function fusedAtDepth(params, context, depth, legs) {
67
+ const { textLeg, vectorLeg } = legs;
68
+ const { vector: vectorConfig, mode: _mode, hybrid: _hybrid, searchAfter: _after, pinned: _pinned, ...rest } = params;
69
+ const fusion = legs.resolveHybridFusion(params.hybrid);
70
+ const textOnlyParams = { ...rest, limit: depth, offset: 0 };
71
+ const filtered = legs.filteredSearchOf(params, context);
72
+ if (filtered !== void 0 && legs.filterSubsetsMatchNothing(filtered.first)) {
73
+ return { scored: [], totalMatched: 0 };
74
+ }
75
+ if (!vectorConfig || !vectorConfig.value) {
76
+ const textOnly = await textLeg(textOnlyParams, context);
77
+ return { scored: textOnly.scored, totalMatched: textOnly.totalMatched, facets: textOnly.facets };
78
+ }
79
+ const vectorPending = vectorLeg(
80
+ vectorConfig,
81
+ new Float32Array(vectorConfig.value),
82
+ context,
83
+ filtered,
84
+ depth,
85
+ HYBRID_RESCORE_WINDOW
86
+ );
87
+ const [textFanOutResult, vectorOutcome] = await Promise.all([textLeg(textOnlyParams, context), vectorPending]);
88
+ const vectorScored = vectorOutcome.scored;
89
+ const textScored = textFanOutResult.scored.slice(0, depth);
90
+ let fusedScored;
91
+ if (fusion.strategy === "rrf") {
92
+ fusedScored = legs.reciprocalRankFusion([textScored, vectorScored], { k: fusion.k });
93
+ } else {
94
+ fusedScored = legs.linearCombination(textScored, vectorScored, { alpha: fusion.alpha });
95
+ }
96
+ const textHoldsEveryMatch = textFanOutResult.scored.length === textFanOutResult.totalMatched;
97
+ const threshold = params.minScore ?? 0;
98
+ const filtersByScore = threshold > 0;
99
+ if (filtersByScore) fusedScored = fusedScored.filter((doc) => doc.score >= threshold);
100
+ return {
101
+ scored: fusedScored.length > depth ? fusedScored.slice(0, depth) : fusedScored,
102
+ totalMatched: filtersByScore ? fusedScored.length : countOfUnion(textFanOutResult, vectorScored),
103
+ matchedExact: vectorOutcome.holdsEveryMatch && textHoldsEveryMatch && (!filtersByScore || textScored.length === textFanOutResult.totalMatched),
104
+ facets: textFanOutResult.facets
105
+ };
106
+ }
107
+ async function searchFixedDepthHybrid(params, context, { cursorDepth, offset, limit }, host) {
108
+ const depth = fixedHybridDepthOf(params.hybrid) ?? 0;
109
+ requireWithinHybridDepth(cursorDepth, offset, depth);
110
+ const result = await fusedAtDepth(params, context, depth, host);
111
+ const placesPins = context.partitionIds === void 0;
112
+ const paginate = (placed, _limit, _offset, _binding, _cursor, _sort, pinnedIds) => {
113
+ const pins = placesPins ? pinnedIds : void 0;
114
+ const organic = pins === void 0 ? placed : result.scored.map((doc) => ({ id: doc.docId }));
115
+ const { page, cursor } = pageByPosition(placed, organic, {
116
+ start: cursorDepth + offset,
117
+ limit,
118
+ pinnedIds: pins,
119
+ binding: context.cursorBinding,
120
+ encodeCursor: host.encodePageCursor
121
+ });
122
+ return { paginated: page, nextCursor: cursor };
123
+ };
124
+ return { ...result, paginate };
125
+ }
126
+
127
+ // src/rerank/query-text.ts
128
+ function nonBlank(value) {
129
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
130
+ }
131
+ function rerankQueryTextOf(params) {
132
+ const rerank = params.rerank;
133
+ if (typeof rerank === "object" && rerank !== null && "query" in rerank && rerank.query !== void 0) {
134
+ return nonBlank(rerank.query);
135
+ }
136
+ return nonBlank(params.term) ?? nonBlank(params.vector?.text);
137
+ }
138
+ function withRerankQueryText(params) {
139
+ const rerank = params.rerank;
140
+ if (rerank === void 0 || typeof rerank !== "object" || rerank === null || rerank.query !== void 0) {
141
+ return params;
142
+ }
143
+ const query = rerankQueryTextOf(params);
144
+ return query === void 0 ? params : { ...params, rerank: { ...rerank, query } };
145
+ }
146
+
147
+ // src/rerank/params.ts
148
+ function invalid(message, details = {}) {
149
+ return new NarsilError(ErrorCodes.RERANK_CONFIG_INVALID, message, details);
150
+ }
151
+ function requireTextFields(fields, schema, host) {
152
+ if (!Array.isArray(fields) || fields.length === 0) {
153
+ throw invalid("rerank.fields must list at least one text field");
154
+ }
155
+ const flat = host.flattenSchema(schema);
156
+ const checked = [];
157
+ const seen = /* @__PURE__ */ new Set();
158
+ for (const field of fields) {
159
+ if (typeof field !== "string") {
160
+ throw invalid("rerank.fields accepts field paths written as strings", { field: String(field) });
161
+ }
162
+ const parsed = host.parsedTypeOf(Object.hasOwn(flat, field) ? flat[field] : void 0);
163
+ if (parsed === void 0 || !host.isStringValuedBase(parsed.base)) {
164
+ throw invalid(`rerank.fields gives "${field}", which the schema does not declare as a text field`, { field });
165
+ }
166
+ if (seen.has(field)) {
167
+ throw invalid(`rerank.fields gives "${field}" more than once`, { field });
168
+ }
169
+ seen.add(field);
170
+ checked.push(field);
171
+ }
172
+ return checked;
173
+ }
174
+ function requireWindow(window, maxWindow, hybridDepth) {
175
+ if (window === void 0) return Math.min(DEFAULT_RERANK_WINDOW, maxWindow, hybridDepth ?? maxWindow);
176
+ if (typeof window !== "number" || !Number.isInteger(window) || window < MIN_RERANK_WINDOW || window > maxWindow) {
177
+ throw invalid(`rerank.window must be a whole number from ${MIN_RERANK_WINDOW} to ${maxWindow}`, {
178
+ window: typeof window === "number" ? window : String(window),
179
+ maxRerankWindow: maxWindow
180
+ });
181
+ }
182
+ if (hybridDepth !== void 0 && window > hybridDepth) {
183
+ throw invalid(
184
+ `rerank.window is ${window}, above the hybrid.depth of ${hybridDepth} that a hybrid query reranks from`,
185
+ {
186
+ window,
187
+ depth: hybridDepth
188
+ }
189
+ );
190
+ }
191
+ return window;
192
+ }
193
+ function resolveRerankParams(params, schema, maxWindow, hybridDepth, host) {
194
+ const rerank = params.rerank;
195
+ if (typeof rerank !== "object" || rerank === null || Array.isArray(rerank)) {
196
+ throw invalid("rerank must be an object that gives an adapter and the fields to rerank by");
197
+ }
198
+ if (host.normalizeSort(params.sort).length > 0) {
199
+ throw new NarsilError(
200
+ ErrorCodes.SEARCH_INVALID_MODE,
201
+ "A query cannot carry both rerank and a sort, because each of them sets the order of the hits"
202
+ );
203
+ }
204
+ const { adapter, fields, window } = rerank;
205
+ if (typeof adapter !== "string" || adapter.length === 0) {
206
+ throw invalid("rerank.adapter must give the name of a registered rerank adapter");
207
+ }
208
+ const checkedFields = requireTextFields(fields, schema, host);
209
+ const checkedWindow = requireWindow(window, maxWindow, hybridDepth);
210
+ const query = rerankQueryTextOf(params);
211
+ if (query === void 0) {
212
+ throw invalid("A reranked query needs text to compare each hit with: set rerank.query, term, or vector.text");
213
+ }
214
+ return { adapter, fields: checkedFields, query, window: checkedWindow };
215
+ }
216
+ function rerankTextOf(values) {
217
+ if (values === void 0) return "";
218
+ const lines = [];
219
+ for (const value of values) {
220
+ if (typeof value === "string") {
221
+ lines.push(value);
222
+ } else if (Array.isArray(value)) {
223
+ for (const member of value) if (typeof member === "string") lines.push(member);
224
+ }
225
+ }
226
+ return lines.join("\n");
227
+ }
228
+
229
+ // src/rerank/pipeline.ts
230
+ function rerankCursorDepth(cursor, binding, host) {
231
+ const decoded = host.decodePageCursor(cursor);
232
+ host.requireMatchingCursor(decoded, cursor, null, true, binding);
233
+ return decoded.depth ?? 0;
234
+ }
235
+ function requireWithinReach(cursorDepth, offset, limit) {
236
+ const reach = cursorDepth + offset + limit;
237
+ if (reach <= RESULT_WINDOW) return;
238
+ throw new NarsilError(
239
+ ErrorCodes.SEARCH_RESULT_WINDOW_EXCEEDED,
240
+ `The engine pages a reranked query through the first ${RESULT_WINDOW} results, and this page ends at ${reach}`,
241
+ { limit, offset, cursorDepth, window: RESULT_WINDOW }
242
+ );
243
+ }
244
+ function reorderByRerank(ranked, windowSize, scores, compareCodePoints) {
245
+ let initialLow = Number.POSITIVE_INFINITY;
246
+ let initialHigh = Number.NEGATIVE_INFINITY;
247
+ let finalLow = Number.POSITIVE_INFINITY;
248
+ let finalHigh = Number.NEGATIVE_INFINITY;
249
+ const ordered = new Array(windowSize);
250
+ for (let i = 0; i < windowSize; i++) {
251
+ const first = ranked[i].score ?? 0;
252
+ const score = scores[i];
253
+ if (first < initialLow) initialLow = first;
254
+ if (first > initialHigh) initialHigh = first;
255
+ if (score < finalLow) finalLow = score;
256
+ if (score > finalHigh) finalHigh = score;
257
+ ordered[i] = { ...ranked[i], score };
258
+ }
259
+ ordered.sort((a, b) => (b.score ?? 0) - (a.score ?? 0) || compareCodePoints(a.id, b.id));
260
+ const rescale = initialLow > finalLow;
261
+ const scale = rescale ? Math.max(finalHigh - finalLow, 1) / Math.max(initialHigh - initialLow, 1) : 1;
262
+ const bias = rescale ? finalLow - initialLow * scale : 0;
263
+ for (let i = windowSize; i < ranked.length; i++) {
264
+ const hit = ranked[i];
265
+ ordered.push(rescale ? { ...hit, score: (hit.score ?? 0) * scale + bias } : hit);
266
+ }
267
+ return ordered;
268
+ }
269
+ function firstStageDepth(hybridDepth, window, cursorDepth, offset, limit) {
270
+ if (hybridDepth === void 0) {
271
+ requireWithinReach(cursorDepth, offset, limit);
272
+ return Math.max(window + 1, Math.min(cursorDepth + offset + limit + 1, RESULT_WINDOW));
273
+ }
274
+ requireWithinHybridDepth(cursorDepth, offset, hybridDepth);
275
+ return hybridDepth;
276
+ }
277
+ async function runRerankedQuery(request, io) {
278
+ const fuses = io.fusesRankings(request);
279
+ const hybridDepth = fuses ? fixedHybridDepthOf(request.hybrid) : void 0;
280
+ const { host } = io;
281
+ const plan = resolveRerankParams(request, io.schema, io.maxWindow, hybridDepth, host);
282
+ const limit = host.clampRowCount(request.limit, DEFAULT_LIMIT);
283
+ const offset = host.clampRowCount(request.offset, DEFAULT_OFFSET);
284
+ const cursorDepth = request.searchAfter === void 0 ? 0 : rerankCursorDepth(request.searchAfter, io.binding, host);
285
+ const depth = firstStageDepth(hybridDepth, plan.window, cursorDepth, offset, limit);
286
+ const projection = host.resolveProjection(request.document);
287
+ const { rerank: _rerank, pinned: _pinned, searchAfter: _searchAfter, highlight: _highlight, ...firstParams } = request;
288
+ const placesPins = request.searchAfter === void 0 && request.pinned !== void 0;
289
+ const countsApart = placesPins || request.vector !== void 0 && !fuses;
290
+ const [first, plain] = await Promise.all([
291
+ io.firstStage({ ...firstParams, offset: 0, limit: depth, document: false }),
292
+ countsApart ? io.firstStage({
293
+ ...firstParams,
294
+ ...placesPins ? { pinned: request.pinned } : {},
295
+ facets: void 0,
296
+ group: void 0,
297
+ offset: cursorDepth + offset,
298
+ limit,
299
+ document: false
300
+ }) : void 0
301
+ ]);
302
+ const ranked = first.hits;
303
+ let pins = placesPins ? request.pinned : void 0;
304
+ if (pins !== void 0) {
305
+ const stored = await io.storedPins(host.dedupePinnedEntries(pins).map((entry) => entry.docId));
306
+ const clamps = io.clampsPins || first.countExact && ranked.length >= first.count;
307
+ pins = pins.filter((entry) => stored.has(entry.docId) && (clamps || entry.position < depth));
308
+ }
309
+ const placedPins = pins;
310
+ const place = (hits) => placedPins === void 0 ? hits : host.placePinned(hits, placedPins, (docId) => ({ id: docId, score: 0, document: void 0 })).hits;
311
+ const start = cursorDepth + offset;
312
+ const windowSize = Math.min(plan.window, ranked.length);
313
+ const pageHoldsHits = limit > 0 && start < place(ranked).length;
314
+ let ordered = ranked;
315
+ if (windowSize > 0 && pageHoldsHits) {
316
+ const texts = await io.texts(
317
+ ranked.slice(0, windowSize).map((hit) => hit.id),
318
+ plan.fields
319
+ );
320
+ ordered = reorderByRerank(
321
+ ranked,
322
+ windowSize,
323
+ await io.score(plan.adapter, plan.query, texts),
324
+ host.compareCodePoints
325
+ );
326
+ } else {
327
+ await io.score(plan.adapter, plan.query, []);
328
+ }
329
+ const pinnedIds = placedPins === void 0 ? void 0 : new Set(placedPins.map((entry) => entry.docId));
330
+ const { page, cursor } = pageByPosition(place(ordered), ordered, {
331
+ start,
332
+ limit,
333
+ pinnedIds,
334
+ binding: io.binding,
335
+ encodeCursor: host.encodePageCursor
336
+ });
337
+ await io.fillDocuments(page, first.groups, projection);
338
+ if (request.highlight) io.highlight?.(page, projection);
339
+ return {
340
+ hits: page,
341
+ count: (plain ?? first).count,
342
+ countExact: (plain ?? first).countExact,
343
+ elapsed: 0,
344
+ cursor,
345
+ facets: first.facets,
346
+ groups: first.groups,
347
+ coverage: first.coverage
348
+ };
349
+ }
350
+
351
+ // src/engine/query/rerank.ts
352
+ async function executeRerankedQuery(request, context, firstStage, host) {
353
+ const startTime = host.now();
354
+ const runner = context.rerank;
355
+ if (runner === void 0) {
356
+ throw new NarsilError(ErrorCodes.RERANK_CONFIG_INVALID, "This search path holds no rerank adapters");
357
+ }
358
+ const { manager } = context;
359
+ const result = await runRerankedQuery(request, {
360
+ host,
361
+ schema: context.config.schema,
362
+ maxWindow: runner.maxWindow,
363
+ binding: context.cursorBinding,
364
+ clampsPins: true,
365
+ fusesRankings: (params) => params.vector !== void 0 && (params.mode === "hybrid" || params.term !== void 0 && params.term.trim().length > 0),
366
+ firstStage: (params) => firstStage(params, context),
367
+ async texts(docIds, fields) {
368
+ return docIds.map((docId) => rerankTextOf(manager.fieldValues(docId, fields)));
369
+ },
370
+ async storedPins(docIds) {
371
+ return new Set(docIds.filter((docId) => manager.getRef(docId) !== void 0));
372
+ },
373
+ score: (adapter, query, documents) => runner.score(adapter, query, documents),
374
+ async fillDocuments(hits, groups, projection) {
375
+ const read = (docId) => projection.kind === "none" ? {} : manager.get(docId, projection) ?? {};
376
+ for (const hit of hits) hit.document = read(hit.id);
377
+ for (const group of groups ?? []) {
378
+ for (const hit of group.hits) hit.document = read(hit.id);
379
+ }
380
+ },
381
+ highlight(page, projection) {
382
+ const fields = request.highlight?.fields ?? [];
383
+ const dropped = fields.some((field) => !host.projectionKeepsField(projection, field));
384
+ const readStoredDocument = dropped ? (docId) => manager.get(docId, { kind: "full" }) : void 0;
385
+ host.applyHighlights(
386
+ page,
387
+ request,
388
+ context.language,
389
+ manager.analysis,
390
+ manager.schema,
391
+ readStoredDocument,
392
+ manager.synonyms
393
+ );
394
+ }
395
+ });
396
+ result.elapsed = host.now() - startTime;
397
+ return result;
398
+ }
399
+
400
+ // src/rerank/call.ts
401
+ function unregistered(adapters, name) {
402
+ const registered = [...adapters.keys()].sort();
403
+ return new NarsilError(
404
+ ErrorCodes.RERANK_CONFIG_INVALID,
405
+ `The query gives rerank adapter "${name}", which this engine has not registered. Register it with registerRerankAdapter or the rerankAdapters setting`,
406
+ { adapter: name, registered }
407
+ );
408
+ }
409
+ function scoresOf(raw, expected, name) {
410
+ const list = Array.isArray(raw) ? raw : ArrayBuffer.isView(raw) && !(raw instanceof DataView) ? Array.from(raw) : null;
411
+ if (list === null) {
412
+ throw new NarsilError(
413
+ ErrorCodes.RERANK_FAILED,
414
+ `Rerank adapter "${name}" returned ${typeof raw}, expected a list of scores`,
415
+ {
416
+ adapter: name
417
+ }
418
+ );
419
+ }
420
+ if (list.length !== expected) {
421
+ throw new NarsilError(
422
+ ErrorCodes.RERANK_FAILED,
423
+ `Rerank adapter "${name}" returned ${list.length} scores for ${expected} documents`,
424
+ { adapter: name, expected, actual: list.length }
425
+ );
426
+ }
427
+ const scores = new Array(expected);
428
+ for (let i = 0; i < expected; i++) {
429
+ const score = list[i];
430
+ if (typeof score !== "number" || !Number.isFinite(score)) {
431
+ throw new NarsilError(
432
+ ErrorCodes.RERANK_FAILED,
433
+ `Rerank adapter "${name}" returned a score that is not a finite number at position ${i}`,
434
+ { adapter: name, position: i }
435
+ );
436
+ }
437
+ scores[i] = score;
438
+ }
439
+ return scores;
440
+ }
441
+ function requireRerankAdapter(adapters, name) {
442
+ const adapter = adapters.get(name);
443
+ if (adapter === void 0) throw unregistered(adapters, name);
444
+ return adapter;
445
+ }
446
+ function timedOut(name, timeoutMs) {
447
+ return new NarsilError(
448
+ ErrorCodes.RERANK_FAILED,
449
+ `Rerank adapter "${name}" did not answer within ${timeoutMs} ms, so the engine cancelled the call`,
450
+ { adapter: name, timeoutMs }
451
+ );
452
+ }
453
+ function cancelled(name) {
454
+ return new NarsilError(ErrorCodes.RERANK_FAILED, `The engine cancelled the call to rerank adapter "${name}"`, {
455
+ adapter: name
456
+ });
457
+ }
458
+ function wrapped(err, name) {
459
+ if (err instanceof NarsilError && err.code === ErrorCodes.RERANK_FAILED) return err;
460
+ const message = err instanceof Error ? err.message : String(err);
461
+ return new NarsilError(ErrorCodes.RERANK_FAILED, `Rerank adapter "${name}" failed: ${message}`, {
462
+ adapter: name,
463
+ cause: message,
464
+ ...err instanceof NarsilError ? { causeCode: err.code } : {}
465
+ });
466
+ }
467
+ async function callRerankAdapter(adapters, name, query, documents, options) {
468
+ const adapter = requireRerankAdapter(adapters, name);
469
+ if (documents.length === 0) return [];
470
+ const outer = options.signal;
471
+ if (outer?.aborted) throw cancelled(name);
472
+ const controller = new AbortController();
473
+ let timer;
474
+ let detach;
475
+ const stopped = new Promise((_resolve, reject) => {
476
+ timer = setTimeout(() => {
477
+ controller.abort();
478
+ reject(timedOut(name, options.timeoutMs));
479
+ }, options.timeoutMs);
480
+ if (outer !== void 0) {
481
+ const onAbort = () => {
482
+ controller.abort();
483
+ reject(cancelled(name));
484
+ };
485
+ outer.addEventListener("abort", onAbort, { once: true });
486
+ detach = () => outer.removeEventListener("abort", onAbort);
487
+ }
488
+ });
489
+ let raw;
490
+ try {
491
+ raw = await Promise.race([
492
+ Promise.resolve().then(() => adapter.rerank(query, documents, controller.signal)),
493
+ stopped
494
+ ]);
495
+ } catch (err) {
496
+ throw wrapped(err, name);
497
+ } finally {
498
+ clearTimeout(timer);
499
+ detach?.();
500
+ }
501
+ return scoresOf(raw, documents.length, name);
502
+ }
503
+ function rerankOnHost(host, name, query, documents) {
504
+ return callRerankAdapter(host.rerankAdapters, name, query, documents, {
505
+ timeoutMs: host.rerankSettings.timeoutMs,
506
+ signal: host.abortController.signal
507
+ });
508
+ }
509
+
510
+ // src/rerank/runner.ts
511
+ function rerankRunnerFor(core) {
512
+ return {
513
+ maxWindow: core.rerankSettings.maxWindow,
514
+ score: (adapter, query, documents) => rerankOnHost(core, adapter, query, documents)
515
+ };
516
+ }
517
+
518
+ // src/rerank/settings.ts
519
+ function wholeNumberIn(value, low, high) {
520
+ return typeof value === "number" && Number.isInteger(value) && value >= low && value <= high;
521
+ }
522
+ function resolveRerankSettings(config) {
523
+ const timeout = config?.rerankTimeout;
524
+ const maxWindow = config?.maxRerankWindow;
525
+ if (timeout !== void 0 && !wholeNumberIn(timeout, MIN_RERANK_TIMEOUT_MS, MAX_RERANK_TIMEOUT_MS)) {
526
+ throw new NarsilError(
527
+ ErrorCodes.CONFIG_INVALID,
528
+ `rerankTimeout must be a whole number of milliseconds from ${MIN_RERANK_TIMEOUT_MS} to ${MAX_RERANK_TIMEOUT_MS}`,
529
+ { rerankTimeout: timeout }
530
+ );
531
+ }
532
+ if (maxWindow !== void 0 && !wholeNumberIn(maxWindow, MIN_RERANK_WINDOW, MAX_RERANK_WINDOW)) {
533
+ throw new NarsilError(
534
+ ErrorCodes.CONFIG_INVALID,
535
+ `maxRerankWindow must be a whole number from ${MIN_RERANK_WINDOW} to ${MAX_RERANK_WINDOW}`,
536
+ {
537
+ maxRerankWindow: maxWindow
538
+ }
539
+ );
540
+ }
541
+ return {
542
+ timeoutMs: timeout ?? DEFAULT_RERANK_TIMEOUT_MS,
543
+ maxWindow: maxWindow ?? DEFAULT_MAX_RERANK_WINDOW
544
+ };
545
+ }
546
+ async function shutdownRerankAdapters(adapters) {
547
+ const distinct = new Set(adapters.values());
548
+ adapters.clear();
549
+ for (const adapter of distinct) {
550
+ try {
551
+ await adapter.shutdown?.();
552
+ } catch {
553
+ }
554
+ }
555
+ }
556
+
557
+ export { executeRerankedQuery, rerankOnHost, rerankRunnerFor, resolveRerankSettings, searchFixedDepthHybrid, shutdownRerankAdapters, withRerankQueryText };
@@ -1,9 +1,11 @@
1
- import { vectorsPerFile } from './chunk-FYFQJKFW.mjs';
2
- import { indexMetadataOf, writeCheckpointSegments, DEFAULT_COMPACTION_THRESHOLD, writeLiveVectors, commitCheckpointManifest, manifestKey, decodeSegmentManifest, SINGLE_NODE_PRIMARY_TERM, partitionContentsOf, manifestFileRefs, unpackIndexSnapshotEnvelope, encodeSegmentManifest, loadSegmentedCheckpoint, writeMetadataEnvelope, openManifestPayload, listedKeysOf, decodeManifestPayload, readSegmentFile, readVectorFile, readGraphParts, documentsOfPayloadV2, deserializePayloadV1 } from './chunk-3MYKLHRO.mjs';
3
- import './chunk-ZGMR46O3.mjs';
4
- import { encodeIndexConfiguration, createByteReader, hasNrslMagic, HEADER_SIZE, readHeader, raiseEarlierReleaseGraphSetting, restoredConfigFields, restoredEmbedding, getLanguage, validateSchema, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateVectorPromotion, validateVectorStorage, validateRequiredFieldsInSchema, resolveIndexAnalysis, validateEmbeddingConfig, prepareStoredSynonyms, rejectSnapshot, readHeapStatistics, readResidentMemory, extractVectorFieldsFromSchema, loadVectorCodeFor, decodeEveryStoredDocument, parseVectorDimension, insertDocumentVectors, decodeIndexConfiguration, flattenSchema } from './chunk-KPMIHLOV.mjs';
5
- import { decodeVectorIndexParts, vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION, bytesToVectors } from './chunk-WKPJ4E73.mjs';
6
- import { NarsilError, ErrorCodes, MAX_FILE_BYTES } from './chunk-HARBSUWP.mjs';
1
+ import { vectorsPerFile } from './chunk-Z7QH2XHB.mjs';
2
+ import { indexMetadataOf, writeCheckpointSegments, DEFAULT_COMPACTION_THRESHOLD, writeLiveVectors, commitCheckpointManifest, manifestKey, decodeSegmentManifest, SINGLE_NODE_PRIMARY_TERM, partitionContentsOf, manifestFileRefs, unpackIndexSnapshotEnvelope, encodeSegmentManifest, loadSegmentedCheckpoint, writeMetadataEnvelope, openManifestPayload, listedKeysOf, decodeManifestPayload, readSegmentFile, readVectorFile, readGraphParts, documentsOfPayloadV2, deserializePayloadV1 } from './chunk-NNG3EEB6.mjs';
3
+ import './chunk-CN4I4FZU.mjs';
4
+ import { encodeIndexConfiguration, createByteReader, hasNrslMagic, HEADER_SIZE, readHeader, raiseEarlierReleaseGraphSetting, restoredConfigFields, restoredEmbedding, getLanguage, validateSchema, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateVectorPromotion, validateVectorStorage, validateRequiredFieldsInSchema, resolveIndexAnalysis, validateEmbeddingConfig, prepareStoredSynonyms, rejectSnapshot, readHeapStatistics, readResidentMemory, extractVectorFieldsFromSchema, loadVectorCodeFor, decodeEveryStoredDocument, parseVectorDimension, insertDocumentVectors, decodeIndexConfiguration, flattenSchema } from './chunk-NAFT3K6X.mjs';
5
+ import { decodeVectorIndexParts, vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION, bytesToVectors } from './chunk-LD55ZGU3.mjs';
6
+ import { MAX_FILE_BYTES } from './chunk-QWES44AW.mjs';
7
+ import './chunk-JPTQZWJQ.mjs';
8
+ import { NarsilError, ErrorCodes } from './chunk-RELZRJNR.mjs';
7
9
  import { decode } from '@msgpack/msgpack';
8
10
 
9
11
  // src/persistence/archive/memory-store.ts
@@ -1,7 +1,9 @@
1
- import { setNestedValue, KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment } from './chunk-ZGMR46O3.mjs';
2
- import { decodeStoredDocument, openChecksummedEnvelope, NUMBER_TAG, DATE_TAG, BYTES_TAG, encodeBase64, startsWithTagPrefix, OBJECT_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND, DOCUMENT_EXPORT_VERSION, DOCUMENT_EXPORT_FORMAT } from './chunk-KPMIHLOV.mjs';
3
- import { decodeVectorFilePayload, isDead, bytesToVectors } from './chunk-WKPJ4E73.mjs';
4
- import { EXPORT_CHUNK_BYTES, NarsilError, ErrorCodes } from './chunk-HARBSUWP.mjs';
1
+ import { setNestedValue, KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment } from './chunk-CN4I4FZU.mjs';
2
+ import { decodeStoredDocument, openChecksummedEnvelope, NUMBER_TAG, DATE_TAG, BYTES_TAG, encodeBase64, startsWithTagPrefix, OBJECT_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND, DOCUMENT_EXPORT_VERSION, DOCUMENT_EXPORT_FORMAT } from './chunk-NAFT3K6X.mjs';
3
+ import { decodeVectorFilePayload, isDead, bytesToVectors } from './chunk-LD55ZGU3.mjs';
4
+ import './chunk-QWES44AW.mjs';
5
+ import './chunk-JPTQZWJQ.mjs';
6
+ import { EXPORT_CHUNK_BYTES, NarsilError, ErrorCodes } from './chunk-RELZRJNR.mjs';
5
7
  import { decode } from '@msgpack/msgpack';
6
8
 
7
9
  // src/engine/export/json-line.ts
@@ -1,6 +1,6 @@
1
- import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
2
- import { C as ClusterNamespace } from './config-6YBtxekG.js';
3
- import { h as TaskStore } from './tasks-BJmamiC4.js';
1
+ import { E as EmbeddingAdapter, R as RerankAdapter } from './adapters-BQFQ4PRz.js';
2
+ import { C as ClusterNamespace } from './config-BGB_fDtq.js';
3
+ import { h as TaskStore } from './tasks-HG3rlxx6.js';
4
4
 
5
5
  /**
6
6
  * Context handed to {@link OnRequestHook} for every inbound request, captured
@@ -89,6 +89,15 @@ interface ServerLimits {
89
89
  * request cannot ask for an unbounded result set. Excess → 400. Defaults to
90
90
  * 10000, matching the cluster query result window. */
91
91
  maxResultWindow?: number;
92
+ /**
93
+ * The server answers 400 for a search whose `rerank.window` is above this
94
+ * number, so that one remote request can send at most this many documents
95
+ * to a rerank model. A search that leaves `rerank.window` out reranks at
96
+ * most this many hits. Set it from 1 to the engine's `maxRerankWindow`,
97
+ * which the server checks when it starts. It defaults to 100, or to the
98
+ * engine's `maxRerankWindow` where that is lower.
99
+ */
100
+ maxRerankWindow?: number;
92
101
  /** Ceiling for the number of document ids in one multi-get request, so one
93
102
  * request cannot pull an unbounded number of documents. Excess → 400.
94
103
  * Defaults to 10000. */
@@ -140,6 +149,13 @@ interface ServerOptions {
140
149
  * needs query-time or ingest-time embedding names a server-registered adapter.
141
150
  */
142
151
  embeddingAdapters?: Record<string, EmbeddingAdapter>;
152
+ /**
153
+ * The server registers these rerank adapters on its engine under their
154
+ * keys, so that a JSON query can give a key in `rerank.adapter`. A rerank
155
+ * adapter is an object with methods, which JSON cannot carry, so a query
156
+ * reaches it by its key.
157
+ */
158
+ rerankAdapters?: Record<string, RerankAdapter>;
143
159
  /** These ceilings apply before the server hands any work to the engine. */
144
160
  limits?: ServerLimits;
145
161
  /**
@@ -1,10 +1,10 @@
1
1
  import { MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-P36MUFEJ.mjs';
2
- import { readSharedConfigFields, restoredEmbedding, restoredPartitionConfig } from './chunk-WLOF6HSP.mjs';
3
- import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-Q5DC6WAB.mjs';
4
- import { generateId, getLanguage } from './chunk-ZHS44YKF.mjs';
2
+ import { readSharedConfigFields, restoredEmbedding, restoredPartitionConfig } from './chunk-R7EEKAJE.mjs';
3
+ import { generateId, getLanguage } from './chunk-JFRNNBOM.mjs';
4
+ import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-LXWDQLTW.mjs';
5
5
  import { decodeSynonymRules } from './chunk-7X5JST5L.mjs';
6
6
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
7
- import { NarsilError, ErrorCodes } from './chunk-SYWGORQB.mjs';
7
+ import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
8
8
  import { encode, decode } from '@msgpack/msgpack';
9
9
 
10
10
  // src/distribution/cluster/constants.ts
@@ -1,7 +1,7 @@
1
1
  import { nodeThreadId } from './chunk-C7SLA6CM.mjs';
2
- import { DIRECTORY_LOCK_ATTEMPTS, DIRECTORY_LOCK_SETTLE_MS, DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS } from './chunk-VVFLEGZI.mjs';
2
+ import { DIRECTORY_LOCK_ATTEMPTS, DIRECTORY_LOCK_SETTLE_MS, DIRECTORY_LOCK_PROCESS_START_TOLERANCE_MS } from './chunk-LH4NZNJJ.mjs';
3
3
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
4
- import { NarsilError, ErrorCodes } from './chunk-SYWGORQB.mjs';
4
+ import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
5
5
  import { openSync, close, readFileSync } from 'fs';
6
6
  import { rename, readFile, writeFile, unlink, realpath, readdir, readlink } from 'fs/promises';
7
7
  import { endianness } from 'os';
@@ -1,8 +1,8 @@
1
1
  import { MAX_FILTER_ARRAY_SIZE } from './chunk-WQBCBKY3.mjs';
2
2
  import { tabulatedLevenshtein } from './chunk-GES7U2PM.mjs';
3
- import { parsedTypeOf } from './chunk-BB7MASRQ.mjs';
3
+ import { parsedTypeOf } from './chunk-OOEXLUGR.mjs';
4
4
  import { codePointCount, exceedsCodePoints } from './chunk-YTJCGKM4.mjs';
5
- import { NarsilError, ErrorCodes } from './chunk-SYWGORQB.mjs';
5
+ import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
6
6
 
7
7
  // src/core/bitset.ts
8
8
  function createBitSet(capacity) {
@@ -1,5 +1,5 @@
1
1
  import { SCRATCH_SLOTS_PER_THREAD_POOL } from './chunk-QY7GC2MW.mjs';
2
- import { NarsilError, ErrorCodes } from './chunk-SYWGORQB.mjs';
2
+ import { NarsilError, ErrorCodes } from './chunk-KV3AZFT3.mjs';
3
3
 
4
4
  // src/serialization/constants.ts
5
5
  var CHECKSUM_YIELD_CHUNK_BYTES = 4 * 1024 * 1024;