agentfootprint 9.2.0 → 9.3.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.
Files changed (91) hide show
  1. package/dist/adapters/memory/pgVector.js +731 -0
  2. package/dist/adapters/memory/pgVector.js.map +1 -0
  3. package/dist/adapters/memory/s3Vectors.js +628 -0
  4. package/dist/adapters/memory/s3Vectors.js.map +1 -0
  5. package/dist/adapters/memory/sqliteVector.js +16 -79
  6. package/dist/adapters/memory/sqliteVector.js.map +1 -1
  7. package/dist/embedders/index.js +240 -76
  8. package/dist/embedders/index.js.map +1 -1
  9. package/dist/esm/adapters/memory/pgVector.d.ts +243 -0
  10. package/dist/esm/adapters/memory/pgVector.js +726 -0
  11. package/dist/esm/adapters/memory/pgVector.js.map +1 -0
  12. package/dist/esm/adapters/memory/s3Vectors.d.ts +208 -0
  13. package/dist/esm/adapters/memory/s3Vectors.js +624 -0
  14. package/dist/esm/adapters/memory/s3Vectors.js.map +1 -0
  15. package/dist/esm/adapters/memory/sqliteVector.d.ts +5 -27
  16. package/dist/esm/adapters/memory/sqliteVector.js +10 -73
  17. package/dist/esm/adapters/memory/sqliteVector.js.map +1 -1
  18. package/dist/esm/embedders/index.d.ts +99 -19
  19. package/dist/esm/embedders/index.js +240 -76
  20. package/dist/esm/embedders/index.js.map +1 -1
  21. package/dist/esm/lib/embedderMismatch.d.ts +67 -0
  22. package/dist/esm/lib/embedderMismatch.js +96 -0
  23. package/dist/esm/lib/embedderMismatch.js.map +1 -0
  24. package/dist/esm/lib/rag/defineRAG.d.ts +28 -6
  25. package/dist/esm/lib/rag/defineRAG.js +39 -5
  26. package/dist/esm/lib/rag/defineRAG.js.map +1 -1
  27. package/dist/esm/memory/define.js +31 -1
  28. package/dist/esm/memory/define.js.map +1 -1
  29. package/dist/esm/memory/define.types.d.ts +13 -2
  30. package/dist/esm/memory/define.types.js.map +1 -1
  31. package/dist/esm/memory/embedding/loadRelevant.d.ts +10 -2
  32. package/dist/esm/memory/embedding/loadRelevant.js +36 -18
  33. package/dist/esm/memory/embedding/loadRelevant.js.map +1 -1
  34. package/dist/esm/memory/pipeline/semantic.d.ts +13 -2
  35. package/dist/esm/memory/pipeline/semantic.js +11 -5
  36. package/dist/esm/memory/pipeline/semantic.js.map +1 -1
  37. package/dist/esm/memory/store/capability.d.ts +25 -6
  38. package/dist/esm/memory/store/capability.js +68 -3
  39. package/dist/esm/memory/store/capability.js.map +1 -1
  40. package/dist/esm/memory/store/index.d.ts +1 -0
  41. package/dist/esm/memory/store/index.js +4 -0
  42. package/dist/esm/memory/store/index.js.map +1 -1
  43. package/dist/esm/memory/store/types.d.ts +40 -0
  44. package/dist/esm/memory-providers.d.ts +7 -4
  45. package/dist/esm/memory-providers.js +18 -4
  46. package/dist/esm/memory-providers.js.map +1 -1
  47. package/dist/lib/embedderMismatch.js +103 -0
  48. package/dist/lib/embedderMismatch.js.map +1 -0
  49. package/dist/lib/rag/defineRAG.js +39 -5
  50. package/dist/lib/rag/defineRAG.js.map +1 -1
  51. package/dist/memory/define.js +31 -1
  52. package/dist/memory/define.js.map +1 -1
  53. package/dist/memory/define.types.js.map +1 -1
  54. package/dist/memory/embedding/loadRelevant.js +36 -18
  55. package/dist/memory/embedding/loadRelevant.js.map +1 -1
  56. package/dist/memory/pipeline/semantic.js +11 -5
  57. package/dist/memory/pipeline/semantic.js.map +1 -1
  58. package/dist/memory/store/capability.js +70 -4
  59. package/dist/memory/store/capability.js.map +1 -1
  60. package/dist/memory/store/index.js +7 -1
  61. package/dist/memory/store/index.js.map +1 -1
  62. package/dist/memory-providers.js +22 -5
  63. package/dist/memory-providers.js.map +1 -1
  64. package/dist/types/adapters/memory/pgVector.d.ts +244 -0
  65. package/dist/types/adapters/memory/pgVector.d.ts.map +1 -0
  66. package/dist/types/adapters/memory/s3Vectors.d.ts +209 -0
  67. package/dist/types/adapters/memory/s3Vectors.d.ts.map +1 -0
  68. package/dist/types/adapters/memory/sqliteVector.d.ts +5 -27
  69. package/dist/types/adapters/memory/sqliteVector.d.ts.map +1 -1
  70. package/dist/types/embedders/index.d.ts +99 -19
  71. package/dist/types/embedders/index.d.ts.map +1 -1
  72. package/dist/types/lib/embedderMismatch.d.ts +68 -0
  73. package/dist/types/lib/embedderMismatch.d.ts.map +1 -0
  74. package/dist/types/lib/rag/defineRAG.d.ts +28 -6
  75. package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
  76. package/dist/types/memory/define.d.ts.map +1 -1
  77. package/dist/types/memory/define.types.d.ts +13 -2
  78. package/dist/types/memory/define.types.d.ts.map +1 -1
  79. package/dist/types/memory/embedding/loadRelevant.d.ts +10 -2
  80. package/dist/types/memory/embedding/loadRelevant.d.ts.map +1 -1
  81. package/dist/types/memory/pipeline/semantic.d.ts +13 -2
  82. package/dist/types/memory/pipeline/semantic.d.ts.map +1 -1
  83. package/dist/types/memory/store/capability.d.ts +25 -6
  84. package/dist/types/memory/store/capability.d.ts.map +1 -1
  85. package/dist/types/memory/store/index.d.ts +1 -0
  86. package/dist/types/memory/store/index.d.ts.map +1 -1
  87. package/dist/types/memory/store/types.d.ts +40 -0
  88. package/dist/types/memory/store/types.d.ts.map +1 -1
  89. package/dist/types/memory-providers.d.ts +7 -4
  90. package/dist/types/memory-providers.d.ts.map +1 -1
  91. package/package.json +9 -1
@@ -127,39 +127,99 @@ export function openaiEmbedder(options = {}) {
127
127
  };
128
128
  }
129
129
  /**
130
- * Default output size per Titan text-embedding model, so `.dimensions` reports
131
- * the truth rather than one hard-coded guess.
130
+ * The Bedrock embedding models this library knows by name — three facts each,
131
+ * in one table, because they arrive together and drift apart when they are
132
+ * kept apart (9.3.0; two Titan-only tables until then).
132
133
  *
133
- * Titan Text Embeddings **V2** is configurable — 1024 (default), 512, 256.
134
- * Titan Embeddings G1 – Text (**V1**) has one size, 1536, and no `dimensions`
135
- * parameter at all. Every other model on Bedrock (Cohere's, a custom
136
- * deployment, one released after this version) has a size this library cannot
137
- * know, so it must state its own rather than be guessed at — the same rule
138
- * `openaiEmbedder` applies, for the same reason: a store that trusts
134
+ * **Size.** Titan Text Embeddings **V2** is the configurable one — 1024
135
+ * (default), 512, 256. Titan Embeddings G1 – Text (**V1**) has one size, 1536,
136
+ * and no `dimensions` parameter at all. Cohere Embed v3 (English and
137
+ * Multilingual) returns 1024 and likewise takes no size. A model outside this
138
+ * table has a length this library cannot know and must state its own — the same
139
+ * rule `openaiEmbedder` applies, for the same reason: a store that trusts
139
140
  * `.dimensions` and gets a different length back corrupts silently.
141
+ *
142
+ * **Window.** Both Titan text-embedding models accept **8,192 tokens** —
143
+ * sixteen times the on-device model the shipped default ceiling was measured
144
+ * on. Cohere Embed v3 accepts **512**, and that number is the whole argument
145
+ * for a per-MODEL ceiling rather than a per-VENDOR one: 512 tokens is ~2,000
146
+ * characters, so the same corpus that is embedded whole by Titan is silently
147
+ * truncated by Cohere at a quarter of the chunk. Declared, the indexers cut to
148
+ * fit; guessed from a sibling model, they would not.
149
+ *
150
+ * **Family.** The body shape (see {@link BedrockEmbeddingFamily}) — the fact
151
+ * whose absence made a Cohere model id constructible and unusable before 9.3.0.
140
152
  */
141
- const TITAN_DIMENSIONS = {
142
- 'amazon.titan-embed-text-v2:0': 1024,
143
- 'amazon.titan-embed-text-v1': 1536,
153
+ const BEDROCK_EMBEDDING_MODELS = {
154
+ 'amazon.titan-embed-text-v2:0': {
155
+ family: 'titan',
156
+ dimensions: 1024,
157
+ sizes: [1024, 512, 256],
158
+ maxInputTokens: 8192,
159
+ },
160
+ 'amazon.titan-embed-text-v1': { family: 'titan', dimensions: 1536, maxInputTokens: 8192 },
161
+ 'cohere.embed-english-v3': { family: 'cohere', dimensions: 1024, maxInputTokens: 512 },
162
+ 'cohere.embed-multilingual-v3': { family: 'cohere', dimensions: 1024, maxInputTokens: 512 },
144
163
  };
145
164
  /**
146
- * Documented input window per Titan text-embedding model, in TOKENS.
165
+ * Titan V2's configurable sizes, kept as a constant because an id this table
166
+ * has never seen can still be recognisably Titan V2 (a variant released after
167
+ * this version) — and for such an id the size must still be SENT, or the model
168
+ * returns 1024 while `.dimensions` reports 512.
169
+ */
170
+ const TITAN_V2_SIZES = [1024, 512, 256];
171
+ /**
172
+ * How many texts Cohere embeds in ONE `InvokeModel` call.
147
173
  *
148
- * Both Titan text-embedding models accept **8,192 tokens** — sixteen times the
149
- * on-device model the shipped default ceiling was measured on. That gap is the
150
- * whole point of declaring one: without it, a corpus split at 2,500 characters
151
- * is reported as clipped (and treated as such by the indexer's default) by an
152
- * embedder that reads every one of those chunks whole.
174
+ * **96**, the documented maximum, and the reason `embedBatch` is a real batch
175
+ * here and N calls for Titan: a 500-chunk corpus is 6 round-trips instead of
176
+ * 500. Chunked at exactly the documented number rather than under it, because
177
+ * unlike a byte limit this one is a count the caller can see — and a batch that
178
+ * silently used half the allowance would be a cost nobody asked for.
179
+ */
180
+ const COHERE_MAX_TEXTS_PER_CALL = 96;
181
+ /**
182
+ * The body shape sent to a model id this library has never met.
153
183
  *
154
- * A model outside this table gets NO declared ceiling — the same rule
155
- * `.dimensions` applies. Another vendor's embedding model on the same runtime
156
- * may have a far shorter window, and guessing this one's would clip in silence.
184
+ * Titan's — because it is the shape EVERY release before 9.3.0 sent to every
185
+ * model, so an unknown id keeps doing exactly what it did. `family` is how a
186
+ * caller says otherwise, and the read-side refusal names that option.
157
187
  */
158
- const TITAN_MAX_INPUT_TOKENS = {
159
- 'amazon.titan-embed-text-v2:0': 8192,
160
- 'amazon.titan-embed-text-v1': 8192,
161
- };
162
- const TITAN_V2_SUPPORTED = [1024, 512, 256];
188
+ const DEFAULT_BEDROCK_FAMILY = 'titan';
189
+ /**
190
+ * The facts for a model id, including ids that WRAP a known one.
191
+ *
192
+ * A cross-region inference profile (`us.amazon.titan-embed-text-v2:0`) and an
193
+ * inference-profile ARN both END in the model id they route to, so containment
194
+ * resolves them exactly rather than by guess — and an id that names its model is
195
+ * not "unknown" just because it has a prefix. Before 9.3.0 those were refused
196
+ * as unknown models, which is why widening this is safe: it accepts what used
197
+ * to throw.
198
+ */
199
+ function bedrockFactsFor(model) {
200
+ const exact = BEDROCK_EMBEDDING_MODELS[model];
201
+ if (exact)
202
+ return exact;
203
+ for (const [id, facts] of Object.entries(BEDROCK_EMBEDDING_MODELS)) {
204
+ if (model.includes(id))
205
+ return facts;
206
+ }
207
+ return undefined;
208
+ }
209
+ /**
210
+ * The family a model id NAMES, or `undefined` when it names none.
211
+ *
212
+ * Substring, not prefix: the id may be wrapped by a region prefix or an ARN.
213
+ * An id that says neither gets Titan's body — the shape every release before
214
+ * 9.3.0 sent to everything — and `family` is how you say otherwise.
215
+ */
216
+ function inferBedrockFamily(model) {
217
+ if (model.includes('cohere.embed'))
218
+ return 'cohere';
219
+ if (model.includes('titan-embed'))
220
+ return 'titan';
221
+ return undefined;
222
+ }
163
223
  /**
164
224
  * Amazon Bedrock's hosted embeddings, through `InvokeModel`.
165
225
  *
@@ -188,19 +248,31 @@ const TITAN_V2_SUPPORTED = [1024, 512, 256];
188
248
  * q8 and an fp32 build of one model are near-identical spaces, and "near" is
189
249
  * exactly the difference that surfaces as a mysteriously worse ranking.)
190
250
  *
251
+ * ── One operation, two body shapes (9.3.0) ───────────────────────────────
252
+ * `InvokeModel` is a single API over vendor-specific JSON. Titan takes
253
+ * `{ inputText }` and answers `{ embedding }`; Cohere takes
254
+ * `{ texts, input_type }` and answers `{ embeddings }`, embeds up to
255
+ * {@link COHERE_MAX_TEXTS_PER_CALL} of them per call, and distinguishes a
256
+ * QUERY from a DOCUMENT. So the model id selects a FAMILY
257
+ * ({@link BedrockEmbeddingFamily}), and the family owns the request, the
258
+ * response and the batching. Before this, one shape was sent to everything —
259
+ * a Cohere id constructed fine and failed at the first embed.
260
+ *
191
261
  * ── The input ceiling (9.1.0) ────────────────────────────────────────────
192
- * `.maxInputChars` reports **32,000** for both Titan text-embedding models:
193
- * their documented 8,192-token window, converted at the stated
194
- * {@link CHARS_PER_TOKEN} assumption of 4 characters per token. Sixteen times
195
- * the indexer's own default, which was measured on an on-device model — so an
196
- * indexing run against this embedder now embeds a 2,500-character chunk whole
197
- * instead of clipping it and calling that success. Dense text (code, tables,
198
- * CJK) tokenises tighter than the assumption; pass an explicit `maxChunkChars`
199
- * for such a corpus, and it wins over this number.
262
+ * `.maxInputChars` is per MODEL, from its documented token window converted at
263
+ * the stated {@link CHARS_PER_TOKEN} assumption of 4 characters per token:
264
+ * **32,000** for both Titan text-embedding models (8,192 tokens — sixteen
265
+ * times the indexer's own default, which was measured on an on-device model),
266
+ * and **2,000** for Cohere Embed v3 (512 tokens). Those two numbers are why the
267
+ * ceiling cannot be a per-vendor constant: the same 2,500-character chunk is
268
+ * read whole by Titan and truncated by Cohere. Dense text (code, tables, CJK)
269
+ * tokenises tighter than the assumption; pass an explicit `maxChunkChars` for
270
+ * such a corpus, and it wins over this number.
200
271
  *
201
272
  * @throws if `model` is unknown and `dimensions` was not supplied; if
202
- * `dimensions` is not one of Titan V2's supported sizes; or if the SDK
203
- * is missing and no `client` / `_client` / `_sdk` was passed.
273
+ * `dimensions` is a size the model does not produce; if `family`
274
+ * contradicts a known model id; or if the SDK is missing and no
275
+ * `client` / `_client` / `_sdk` was passed.
204
276
  *
205
277
  * @example
206
278
  * ```ts
@@ -211,24 +283,61 @@ const TITAN_V2_SUPPORTED = [1024, 512, 256];
211
283
  * const embedder = bedrockEmbedder({ region: 'us-east-1', dimensions: 512 });
212
284
  * await indexFolder('./docs', { to: sqliteVectorStore({ file: './corpus.db' }), embedder });
213
285
  * ```
286
+ *
287
+ * @example A Cohere embedding model on the same runtime
288
+ * ```ts
289
+ * // Body shape, response field, batch size and 512-token window all follow
290
+ * // from the model id — nothing else changes at the call site.
291
+ * const embedder = bedrockEmbedder({ model: 'cohere.embed-english-v3' });
292
+ * ```
214
293
  */
215
294
  export function bedrockEmbedder(options = {}) {
216
295
  const model = options.model ?? 'amazon.titan-embed-text-v2:0';
217
- const isTitanV2 = model.startsWith('amazon.titan-embed-text-v2');
296
+ const facts = bedrockFactsFor(model);
297
+ const named = inferBedrockFamily(model);
298
+ if (options.family !== undefined && facts !== undefined && options.family !== facts.family) {
299
+ throw new Error(`bedrockEmbedder: model '${model}' is a ${facts.family} model, and \`family: ` +
300
+ `'${options.family}'\` says otherwise. The two cannot both be right, and guessing ` +
301
+ `which line is the mistake would decide the request body — the one thing a wrong ` +
302
+ `answer here breaks at the first embed. Drop \`family\` (the model id already says ` +
303
+ `it), or name the model you meant.`);
304
+ }
305
+ // Explicit, then what the id names, then Titan — which is the body every
306
+ // release before 9.3.0 sent to every model, so an id this library has never
307
+ // met keeps behaving exactly as it did.
308
+ const family = options.family ?? facts?.family ?? named ?? DEFAULT_BEDROCK_FAMILY;
218
309
  const requested = options.dimensions;
219
- const dimensions = requested ?? TITAN_DIMENSIONS[model];
310
+ const dimensions = requested ?? facts?.dimensions;
220
311
  if (dimensions === undefined) {
221
312
  throw new Error(`bedrockEmbedder: unknown model '${model}' — its vector length is not something this ` +
222
313
  `library can know, and reporting a wrong .dimensions silently corrupts a vector store. ` +
223
314
  `Pass { dimensions } with the length that model returns.`);
224
315
  }
225
- if (isTitanV2 && requested !== undefined && !TITAN_V2_SUPPORTED.includes(requested)) {
226
- throw new Error(`bedrockEmbedder: Titan Text Embeddings V2 returns ${TITAN_V2_SUPPORTED.join(', ')} ` +
316
+ // A model this table has never seen can still be recognisably Titan V2, and
317
+ // for one of those the requested size must still be validated and SENT.
318
+ const sizes = facts?.sizes ??
319
+ (family === 'titan' && model.includes('titan-embed-text-v2') ? TITAN_V2_SIZES : undefined);
320
+ if (requested !== undefined && sizes !== undefined && !sizes.includes(requested)) {
321
+ throw new Error(`bedrockEmbedder: '${model}' returns ${sizes.join(', ')} ` +
227
322
  `dimensions — received ${String(requested)}. Asking for a size the model does not ` +
228
323
  `produce would store vectors of a length that disagrees with the .dimensions this ` +
229
324
  `embedder reports.`);
230
325
  }
231
- const maxInputChars = charsFor(TITAN_MAX_INPUT_TOKENS[model]);
326
+ if (requested !== undefined &&
327
+ sizes === undefined &&
328
+ facts !== undefined &&
329
+ requested !== facts.dimensions) {
330
+ throw new Error(`bedrockEmbedder: '${model}' returns ${facts.dimensions}-dimension vectors and takes no ` +
331
+ `size parameter — received ${String(requested)}, which would be reported as ` +
332
+ `.dimensions and never be the length that comes back. Drop \`dimensions\`: this ` +
333
+ `factory already knows this model's size.`);
334
+ }
335
+ const maxInputChars = options.maxInputChars ?? charsFor(facts?.maxInputTokens);
336
+ // Only a size the model actually TAKES is sent. Titan V2 defaults to 1024 on
337
+ // its own side, V1 and Cohere reject the field — so a caller who asked for
338
+ // nothing gets a request body identical to the one before this option
339
+ // existed.
340
+ const sendSize = requested !== undefined && sizes !== undefined;
232
341
  let connection;
233
342
  /**
234
343
  * Resolve the client + command constructor, once, on first embed.
@@ -271,20 +380,26 @@ export function bedrockEmbedder(options = {}) {
271
380
  return connection;
272
381
  };
273
382
  /**
274
- * One text in, one vector out. Titan's `InvokeModel` embeds a SINGLE
275
- * `inputText` per call — there is no batch operation on the API, so
276
- * `embedBatch` below is honest about being N calls rather than pretending
277
- * to a batch discount that does not exist.
383
+ * ONE `InvokeModel` round-trip, with the family's body on the way in and the
384
+ * family's field on the way out.
385
+ *
386
+ * Takes a slice of texts rather than one, because how many fit in a call is
387
+ * itself a family fact: Titan embeds a single `inputText`, Cohere embeds up
388
+ * to {@link COHERE_MAX_TEXTS_PER_CALL}. The callers below never have to know
389
+ * which — they hand over texts and get one vector per text back, in order.
278
390
  */
279
- async function invoke(text, signal) {
391
+ async function invoke(texts, inputType, signal) {
280
392
  const conn = connect();
281
- const body = JSON.stringify({
282
- inputText: text,
283
- // Only an EXPLICIT request is sent. Titan V2 defaults to 1024 on its own
284
- // side, and V1 rejects the field — so a caller who asked for nothing
285
- // gets a request body identical to the one before this option existed.
286
- ...(requested !== undefined && isTitanV2 && { dimensions: requested }),
287
- });
393
+ const body = JSON.stringify(family === 'cohere'
394
+ ? {
395
+ texts: [...texts],
396
+ // Required by the model, so there is no "unset" — see `inputType`.
397
+ input_type: options.inputType ?? inputType,
398
+ }
399
+ : {
400
+ inputText: texts[0],
401
+ ...(sendSize && { dimensions: requested }),
402
+ });
288
403
  const command = new conn.Command({
289
404
  modelId: model,
290
405
  contentType: 'application/json',
@@ -294,7 +409,29 @@ export function bedrockEmbedder(options = {}) {
294
409
  const out = await (signal
295
410
  ? conn.client.send(command, { abortSignal: signal })
296
411
  : conn.client.send(command));
297
- return readEmbedding(out, model);
412
+ return readEmbeddings(out, model, family, texts.length, facts === undefined);
413
+ }
414
+ /**
415
+ * The calls one batch becomes: Titan one text at a time, Cohere in chunks.
416
+ *
417
+ * Sequential rather than parallel either way: callers of the batch path are
418
+ * usually indexing a whole corpus, and `indexCorpus` already fans out over
419
+ * batches with its own bounded parallelism and retry. Racing N more requests
420
+ * inside one of those branches is how a corpus index meets a throttling
421
+ * error.
422
+ *
423
+ * The abort is checked between calls as well as passed into each one, so an
424
+ * aborted batch stops at the next boundary instead of embedding the rest of a
425
+ * corpus nobody is waiting for.
426
+ */
427
+ async function invokeAll(texts, inputType, signal) {
428
+ const perCall = family === 'cohere' ? COHERE_MAX_TEXTS_PER_CALL : 1;
429
+ const out = [];
430
+ for (let i = 0; i < texts.length; i += perCall) {
431
+ signal?.throwIfAborted();
432
+ out.push(...(await invoke(texts.slice(i, i + perCall), inputType, signal)));
433
+ }
434
+ return out;
298
435
  }
299
436
  return {
300
437
  dimensions,
@@ -304,24 +441,16 @@ export function bedrockEmbedder(options = {}) {
304
441
  // than one it cannot stand behind.
305
442
  ...(maxInputChars !== undefined && { maxInputChars }),
306
443
  async embed({ text, signal }) {
307
- return invoke(text, signal);
444
+ // ONE text is this library's query shape (`loadRelevant` embeds the
445
+ // question) — so Cohere is told it is a query unless `inputType` says
446
+ // otherwise. Titan ignores the argument entirely.
447
+ return (await invoke([text], 'search_query', signal))[0];
308
448
  },
309
449
  async embedBatch({ texts, signal }) {
310
- // Titan has no batch embed operation. Sequential rather than parallel:
311
- // callers of this path are usually indexing a whole corpus, and
312
- // `indexCorpus` already fans out over batches with its own bounded
313
- // parallelism and retry. Racing N more requests inside one of those
314
- // branches is how a corpus index meets a throttling error.
315
- //
316
- // The abort is checked between calls as well as passed into each one,
317
- // so an aborted batch stops at the next boundary instead of embedding
318
- // the rest of a corpus nobody is waiting for.
319
- const out = [];
320
- for (const text of texts) {
321
- signal?.throwIfAborted();
322
- out.push(await invoke(text, signal));
323
- }
324
- return out;
450
+ // MANY texts is this library's document shape (`indexDocuments`,
451
+ // `embedMessages`), and Cohere embeds a document into a different place
452
+ // from a query on purpose.
453
+ return invokeAll(texts, 'search_document', signal);
325
454
  },
326
455
  };
327
456
  }
@@ -342,15 +471,26 @@ function loadBedrockRuntimeSdk() {
342
471
  }
343
472
  }
344
473
  /**
345
- * Pull the vector out of an `InvokeModel` response.
474
+ * Pull the vectors out of an `InvokeModel` response, by FAMILY.
346
475
  *
347
476
  * The SDK hands back `body` as a `Uint8Array`; a hand-rolled or mock client
348
477
  * may hand back the decoded object or a string. All three are read, and
349
478
  * anything else is refused by NAME rather than returning an empty vector —
350
479
  * an embedder that silently returns `[]` writes a row a store will never
351
480
  * rank, which is indistinguishable from "the corpus does not mention that".
481
+ *
482
+ * The field differs with the family (`embedding` vs `embeddings`), so the
483
+ * refusal has to as well: told the wrong family, the response is perfectly
484
+ * valid and this is the only place that can say so — which is why the message
485
+ * names `family` when the model id was not one this library knows.
486
+ *
487
+ * @param expected how many vectors were asked for. A count mismatch is refused
488
+ * rather than returned short: the caller pairs vectors with texts by
489
+ * POSITION, so a missing one does not go missing — it silently re-labels
490
+ * every passage after it.
491
+ * @param guessedFamily whether the family was a fallback rather than a fact.
352
492
  */
353
- function readEmbedding(response, model) {
493
+ function readEmbeddings(response, model, family, expected, guessedFamily) {
354
494
  const body = response?.body ?? response;
355
495
  let parsed = body;
356
496
  if (body instanceof Uint8Array) {
@@ -359,13 +499,37 @@ function readEmbedding(response, model) {
359
499
  else if (typeof body === 'string') {
360
500
  parsed = JSON.parse(body);
361
501
  }
362
- const embedding = parsed?.embedding;
363
- if (!Array.isArray(embedding) || embedding.some((n) => typeof n !== 'number')) {
364
- throw new Error(`bedrockEmbedder: '${model}' returned no \`embedding\` array. Bedrock answered with ` +
502
+ const field = family === 'cohere' ? 'embeddings' : 'embedding';
503
+ const raw = parsed?.[field];
504
+ // Cohere answers `{ embeddings: [[...]] }`, or `{ embeddings: { float: [[...]] } }`
505
+ // when a caller asked for typed embeddings. This never asks, and reads both.
506
+ const rows = family === 'cohere'
507
+ ? Array.isArray(raw)
508
+ ? raw
509
+ : raw?.float
510
+ : [raw];
511
+ const vectors = Array.isArray(rows) &&
512
+ rows.every((row) => Array.isArray(row) && row.every((n) => typeof n === 'number'))
513
+ ? rows
514
+ : undefined;
515
+ if (vectors === undefined) {
516
+ throw new Error(`bedrockEmbedder: '${model}' returned no \`${field}\` array. Bedrock answered with ` +
365
517
  `${describeShape(parsed)}, which this adapter cannot read — check the model id names an ` +
366
- `EMBEDDING model (a text-generation model answers a different shape).`);
518
+ `EMBEDDING model (a text-generation model answers a different shape).` +
519
+ (guessedFamily
520
+ ? `\n This model id is not one this library knows, so it was sent the ${family} ` +
521
+ `request body. If it is a ${family === 'titan' ? 'Cohere' : 'Titan'} model, pass ` +
522
+ `\`family: '${family === 'titan' ? 'cohere' : 'titan'}'\` — the request body and ` +
523
+ `the response field both differ per family.`
524
+ : ''));
525
+ }
526
+ if (vectors.length !== expected) {
527
+ throw new Error(`bedrockEmbedder: '${model}' was sent ${expected} text(s) and answered with ` +
528
+ `${vectors.length} vector(s). Vectors are paired with texts by POSITION, so a short ` +
529
+ `answer would not lose one passage — it would attach every later vector to the wrong ` +
530
+ `passage, and the corpus would rank confidently and wrongly forever.`);
367
531
  }
368
- return embedding;
532
+ return vectors;
369
533
  }
370
534
  /** Describe a response by shape, never by content — it may carry customer text. */
371
535
  function describeShape(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/embedders/index.ts"],"names":[],"mappings":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AAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * EmbedderMismatchError — one class, for every store that can tell.
3
+ *
4
+ * Pattern: shared refusal type (the `SqliteUnavailableError` precedent).
5
+ * Role: lib/, so no store adapter owns it and none has to import another.
6
+ * Emits: N/A.
7
+ *
8
+ * It lived inside `sqliteVector.ts` from 8.9.0 until 9.3.0, when a second and
9
+ * a third store learned to make the same check. A duplicate class of the same
10
+ * name would mean `catch (e) { if (e instanceof EmbedderMismatchError) }`
11
+ * quietly depended on WHICH store threw — so there is exactly one, here, and
12
+ * the stores import it.
13
+ */
14
+ /**
15
+ * Raised when a vector meets an index built by a different embedder.
16
+ *
17
+ * **This is the refusal that keeps a vector store honest.** Cosine similarity
18
+ * between two different embedding spaces is not a weak signal — it is not a
19
+ * signal at all, and it comes back as a confident number in the same 0-to-1
20
+ * range as a real one. There is no threshold that separates them, and nothing
21
+ * downstream can tell them apart. So the mismatch is refused where it happens,
22
+ * on both sides:
23
+ *
24
+ * - at **write**, so a second embedder's vectors never enter a namespace;
25
+ * - at **query**, so a swapped embedder never scores against the old ones.
26
+ *
27
+ * The named fix is an explicit re-index — delete the namespace and build it
28
+ * again with one embedder, or point the retriever somewhere else. It is never a
29
+ * fallback: silently ignoring the mismatch is the failure, and silently
30
+ * re-embedding somebody's corpus is a bill they did not agree to.
31
+ *
32
+ * `problem` says which half is wrong. `'dimensions'` is arithmetically
33
+ * impossible to score at all; `'model'` would score, and lie.
34
+ */
35
+ export declare class EmbedderMismatchError extends Error {
36
+ readonly code: "ERR_EMBEDDER_MISMATCH";
37
+ /** The fingerprint the namespace was built with, `'<id>@<dims>'`. */
38
+ readonly indexed: string;
39
+ /** The fingerprint that just arrived. */
40
+ readonly incoming: string;
41
+ /** Which half disagrees. */
42
+ readonly problem: 'dimensions' | 'model';
43
+ /**
44
+ * @param alternative the store-specific second way out, named in the
45
+ * message. A file-backed store says "point this store at a different
46
+ * file"; a service-backed one names its own unit of separation.
47
+ */
48
+ constructor(namespace: string, indexed: string, incoming: string, problem: EmbedderMismatchError['problem'], operation: 'write to' | 'search', alternative?: string);
49
+ }
50
+ /** An embedder fingerprint, split into the two halves that decide separately. */
51
+ export interface Fingerprint {
52
+ readonly id?: string;
53
+ readonly dims: number;
54
+ }
55
+ /** `'<id>@<dims>'`, with `'?'` for an embedder that did not name itself. */
56
+ export declare function fingerprintText(fp: Fingerprint): string;
57
+ /** Parse the `'<id>@<dims>'` form back into its halves. */
58
+ export declare function parseFingerprint(text: string): Fingerprint;
59
+ /**
60
+ * What, if anything, makes these two incompatible.
61
+ *
62
+ * Dimensions always decide: two lengths cannot be compared at all. Model ids
63
+ * decide only when BOTH sides named themselves — an anonymous vector is not
64
+ * evidence of a different embedder, and refusing on absence would break every
65
+ * caller who never passed an `embedderId`, which is most of them.
66
+ */
67
+ export declare function fingerprintConflict(stored: Fingerprint, incoming: Fingerprint): 'dimensions' | 'model' | null;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * EmbedderMismatchError — one class, for every store that can tell.
3
+ *
4
+ * Pattern: shared refusal type (the `SqliteUnavailableError` precedent).
5
+ * Role: lib/, so no store adapter owns it and none has to import another.
6
+ * Emits: N/A.
7
+ *
8
+ * It lived inside `sqliteVector.ts` from 8.9.0 until 9.3.0, when a second and
9
+ * a third store learned to make the same check. A duplicate class of the same
10
+ * name would mean `catch (e) { if (e instanceof EmbedderMismatchError) }`
11
+ * quietly depended on WHICH store threw — so there is exactly one, here, and
12
+ * the stores import it.
13
+ */
14
+ /**
15
+ * Raised when a vector meets an index built by a different embedder.
16
+ *
17
+ * **This is the refusal that keeps a vector store honest.** Cosine similarity
18
+ * between two different embedding spaces is not a weak signal — it is not a
19
+ * signal at all, and it comes back as a confident number in the same 0-to-1
20
+ * range as a real one. There is no threshold that separates them, and nothing
21
+ * downstream can tell them apart. So the mismatch is refused where it happens,
22
+ * on both sides:
23
+ *
24
+ * - at **write**, so a second embedder's vectors never enter a namespace;
25
+ * - at **query**, so a swapped embedder never scores against the old ones.
26
+ *
27
+ * The named fix is an explicit re-index — delete the namespace and build it
28
+ * again with one embedder, or point the retriever somewhere else. It is never a
29
+ * fallback: silently ignoring the mismatch is the failure, and silently
30
+ * re-embedding somebody's corpus is a bill they did not agree to.
31
+ *
32
+ * `problem` says which half is wrong. `'dimensions'` is arithmetically
33
+ * impossible to score at all; `'model'` would score, and lie.
34
+ */
35
+ export class EmbedderMismatchError extends Error {
36
+ code = 'ERR_EMBEDDER_MISMATCH';
37
+ /** The fingerprint the namespace was built with, `'<id>@<dims>'`. */
38
+ indexed;
39
+ /** The fingerprint that just arrived. */
40
+ incoming;
41
+ /** Which half disagrees. */
42
+ problem;
43
+ /**
44
+ * @param alternative the store-specific second way out, named in the
45
+ * message. A file-backed store says "point this store at a different
46
+ * file"; a service-backed one names its own unit of separation.
47
+ */
48
+ constructor(namespace, indexed, incoming, problem, operation, alternative = 'point this store at a different index') {
49
+ super(`[memory] cannot ${operation} the namespace '${namespace}': it was indexed by ` +
50
+ `'${indexed}' and this vector is from '${incoming}'. ` +
51
+ (problem === 'dimensions'
52
+ ? `Vectors of different lengths cannot be compared at all. `
53
+ : `Cosine similarity between two embedding spaces is not a weak signal — it is ` +
54
+ `not a signal, and it comes back as a confident number in the same range as a ` +
55
+ `real one, which no threshold can separate. `) +
56
+ `Re-index this namespace with one embedder (delete it and build it again), or ` +
57
+ `${alternative}. This refuses rather than re-embedding ` +
58
+ `your corpus on your behalf — that is a bill you did not agree to — and rather ` +
59
+ `than mixing the two, which would silently corrupt every ranking it touched.`);
60
+ this.name = 'EmbedderMismatchError';
61
+ this.indexed = indexed;
62
+ this.incoming = incoming;
63
+ this.problem = problem;
64
+ }
65
+ }
66
+ /** `'<id>@<dims>'`, with `'?'` for an embedder that did not name itself. */
67
+ export function fingerprintText(fp) {
68
+ return `${fp.id ?? '?'}@${fp.dims}`;
69
+ }
70
+ /** Parse the `'<id>@<dims>'` form back into its halves. */
71
+ export function parseFingerprint(text) {
72
+ const at = text.lastIndexOf('@');
73
+ const id = at === -1 ? '?' : text.slice(0, at);
74
+ const dims = at === -1 ? 0 : Number(text.slice(at + 1));
75
+ return {
76
+ ...(id !== '?' && id !== '' && { id }),
77
+ dims: Number.isFinite(dims) ? dims : 0,
78
+ };
79
+ }
80
+ /**
81
+ * What, if anything, makes these two incompatible.
82
+ *
83
+ * Dimensions always decide: two lengths cannot be compared at all. Model ids
84
+ * decide only when BOTH sides named themselves — an anonymous vector is not
85
+ * evidence of a different embedder, and refusing on absence would break every
86
+ * caller who never passed an `embedderId`, which is most of them.
87
+ */
88
+ export function fingerprintConflict(stored, incoming) {
89
+ if (stored.dims !== incoming.dims)
90
+ return 'dimensions';
91
+ if (stored.id !== undefined && incoming.id !== undefined && stored.id !== incoming.id) {
92
+ return 'model';
93
+ }
94
+ return null;
95
+ }
96
+ //# sourceMappingURL=embedderMismatch.js.map