pikelet-wasm 0.14.0 → 0.16.0

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.
@@ -62,6 +62,13 @@ export declare function httpRangeSource(url: string, options?: {
62
62
  * disables. CDNs rate-limit the parallel range bursts a query issues.
63
63
  */
64
64
  maxRetries?: number;
65
+ /**
66
+ * How long, in milliseconds, each wait on the host (response headers, then
67
+ * each body chunk) may go without progress before the read fails with code
68
+ * ETIMEDOUT and the request is aborted. Default 30000; 0 disables. Retry
69
+ * sleeps do not count.
70
+ */
71
+ idleTimeoutMs?: number;
65
72
  /**
66
73
  * Called with each redirect target before it is followed; throw to refuse
67
74
  * the hop. When set, range reads never auto-follow redirects. A chain walk
@@ -79,6 +86,8 @@ export declare function httpRangeSource(url: string, options?: {
79
86
  method?: string;
80
87
  headers?: Record<string, string>;
81
88
  redirect?: 'follow' | 'manual' | 'error';
89
+ /** Aborted when a request makes no progress for idleTimeoutMs. */
90
+ signal?: unknown;
82
91
  }) => Promise<any>;
83
92
  }): HttpRangeSource;
84
93
 
@@ -94,6 +103,12 @@ export declare function nodeFetch(input: string, init?: {
94
103
  signal?: unknown;
95
104
  /** Inflate a gzip/deflate body a server sent despite identity (crawled HTML); Brotli/zstd still refused. */
96
105
  inflateGzip?: boolean;
106
+ /**
107
+ * Milliseconds the connection may sit idle (no response headers, or a gap
108
+ * in the body) before the request fails with code ETIMEDOUT. Default
109
+ * 30000; 0 disables. Time queued for a socket does not count.
110
+ */
111
+ idleTimeoutMs?: number;
97
112
  }): Promise<any>;
98
113
 
99
114
  /** openPikeletFile's options.blobCache: bytes keyed by their sha256 (lowercase hex, 32-64 digits). */
@@ -129,7 +144,7 @@ export interface CompleteQueryResult {
129
144
  * it measures retrieval relevance: 'none' means the pack does not appear
130
145
  * to cover the query's topic, 'strong' that it does — not that a
131
146
  * returned passage states the specific fact asked for. 'unscored': the
132
- * pack ships no fitted calibrator.
147
+ * pack ships no fitted calibrator, as every pack compiled after 0.14.0.
133
148
  */
134
149
  matchQuality: 'strong' | 'weak' | 'none' | 'unscored';
135
150
  confidence?: number;
@@ -141,17 +156,18 @@ export interface CompleteQueryResult {
141
156
  */
142
157
  results: Array<{ id: number; distance: number } & Record<string, unknown>>;
143
158
  /**
144
- * Which passage grounded the verdict and which of the query's content
145
- * words it contains. Present when a fitted calibrator scored the query
146
- * (absent on 'unscored'). An asked-for value in `uncovered` is one no top
147
- * passage states, whatever matchQuality says.
159
+ * Which of the query's content words the best of the top five passages
160
+ * (the one containing the most of them) contains (covered) and lacks
161
+ * (uncovered). Computed for every pack, calibrated or not; absent only
162
+ * when the query has no gradable word. An asked-for value in `uncovered`
163
+ * is one the best passage does not state, whatever matchQuality says.
148
164
  */
149
165
  grounding?: {
150
- /** Id of the passage the coverage score was taken from. */
166
+ /** Id of the passage that covered the most query words. */
151
167
  recordId: number | null;
152
168
  /** Index of that passage in the fused (or distance-ordered) window. */
153
169
  passageIndex: number;
154
- /** Weighted share of the query's content words the passage contains, 0-1. */
170
+ /** Share of the query's content words the passage contains, 0-1 (a heading-only match counts half). */
155
171
  coverage: number;
156
172
  covered: string[];
157
173
  uncovered: string[];
@@ -196,6 +212,11 @@ export interface CompleteSearch {
196
212
  * Kind 1: null (inline student encoder, nothing external to verify).
197
213
  */
198
214
  encoderVerified: boolean | null;
215
+ /**
216
+ * The rank-fusion parameters query() applies by default: FUSION_DEFAULTS
217
+ * overridden for the pack's encoder model (ENCODER_FUSION_DEFAULTS).
218
+ */
219
+ fusion: Readonly<Required<FusionOptions>>;
199
220
  /**
200
221
  * 'per-record-sha256' on format 2 (each hydrated record verified on its
201
222
  * own range read); 'segment-sha256' on format 1 (whole-segment digests
@@ -223,6 +244,8 @@ export interface CompleteSearch {
223
244
  docCount: number;
224
245
  /** 'segment-sha256' when read eagerly and verified whole; 'unverified-lazy-reads' for lazily opened segments. */
225
246
  integrity: 'segment-sha256' | 'unverified-lazy-reads';
247
+ /** True once the whole segment matched its digest: at open when eager, after verifyLexical() when lazy. */
248
+ verified: boolean;
226
249
  lazy?: true;
227
250
  } | null;
228
251
  /**
@@ -246,6 +269,12 @@ export interface CompleteSearch {
246
269
  * on match; throws on mismatch.
247
270
  */
248
271
  verifyVectors(options?: { chunkBytes?: number }): Promise<true>;
272
+ /**
273
+ * Stream a lazily opened lexical segment against its identity-anchored
274
+ * digest (an eager one was verified at open). Resolves false when the
275
+ * pack has no lexical segment; rejects if the bytes do not match.
276
+ */
277
+ verifyLexical(options?: { chunkBytes?: number }): Promise<boolean>;
249
278
  query(text: string, options?: {
250
279
  k?: number;
251
280
  /**
@@ -260,6 +289,11 @@ export interface CompleteSearch {
260
289
  * metric). Abstention scores identically in every mode.
261
290
  */
262
291
  retrieval?: 'hybrid' | 'vector' | 'lexical' | 'augmented';
292
+ /**
293
+ * Rank-fusion parameters for this call, merged over the pack's defaults
294
+ * (info().fusion). Hybrid retrieval only.
295
+ */
296
+ fusion?: FusionOptions;
263
297
  rerank?: number;
264
298
  parallelism?: number;
265
299
  gap?: number;
@@ -344,6 +378,14 @@ export declare function openPikeletFile(
344
378
  maxReadBytes?: number;
345
379
  /** Budget for a single corpus record read. Default 16 MiB. */
346
380
  maxRecordBytes?: number;
381
+ /**
382
+ * Lexical segments larger than this open lazily: term table and
383
+ * postings are read on demand and not verified per read until
384
+ * verifyLexical() runs. Smaller ones are read and verified whole at
385
+ * open. Default 8 MiB; Infinity reads every segment whole (up to
386
+ * maxReadBytes).
387
+ */
388
+ lazyLexicalBytes?: number;
347
389
  /** Override the kind-3 wasm kernel loader. */
348
390
  createEncoder?: () => Promise<unknown> | unknown;
349
391
  /**
@@ -382,6 +424,13 @@ export interface FusionOptions {
382
424
  guardMargin?: number;
383
425
  }
384
426
  export declare const FUSION_DEFAULTS: Readonly<Required<FusionOptions>>;
427
+ /**
428
+ * Per-encoder overrides of FUSION_DEFAULTS, keyed by the declared encoder
429
+ * model (BAAI/bge-small-en-v1.5: lexicalWeight 0.25).
430
+ */
431
+ export declare const ENCODER_FUSION_DEFAULTS: Readonly<Record<string, Readonly<FusionOptions>>>;
432
+ /** The fusion defaults for a pack whose encoder declares this model. */
433
+ export declare function fusionDefaultsFor(model: string | null | undefined): Readonly<Required<FusionOptions>>;
385
434
  /**
386
435
  * Fuse the exact-reranked vector order (every lexical candidate included) with the BM25 order.
387
436
  * Returns the same hit objects, reordered.