@cerefox/memory 1.0.0-rc.2 → 1.0.0-rc.3

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.
@@ -7184,7 +7184,7 @@ var exports_meta = {};
7184
7184
  __export(exports_meta, {
7185
7185
  PKG_VERSION: () => PKG_VERSION
7186
7186
  });
7187
- var PKG_VERSION = "1.0.0-rc.2";
7187
+ var PKG_VERSION = "1.0.0-rc.3";
7188
7188
  var init_meta = () => {};
7189
7189
 
7190
7190
  // ../../node_modules/.bun/tslib@2.8.1/node_modules/tslib/tslib.js
@@ -25532,9 +25532,22 @@ async function ensurePipeline() {
25532
25532
  async function warmup() {
25533
25533
  await ensurePipeline();
25534
25534
  }
25535
+ function onnxBatchSize() {
25536
+ const env4 = globalThis.process?.env ?? {};
25537
+ const n = Number.parseInt(env4.CEREFOX_ONNX_BATCH ?? "", 10);
25538
+ return Number.isFinite(n) && n > 0 ? n : DEFAULT_ONNX_BATCH;
25539
+ }
25535
25540
  async function onnxEmbed(texts, role) {
25536
25541
  if (texts.length === 0)
25537
25542
  return [];
25543
+ const batch = onnxBatchSize();
25544
+ if (texts.length > batch) {
25545
+ const out2 = [];
25546
+ for (let i = 0;i < texts.length; i += batch) {
25547
+ out2.push(...await onnxEmbed(texts.slice(i, i + batch), role));
25548
+ }
25549
+ return out2;
25550
+ }
25538
25551
  const pipeline = await ensurePipeline();
25539
25552
  const inputs = buildPrefixedInputs(texts, role);
25540
25553
  const out = await pipeline(inputs, { pooling: "mean", normalize: true });
@@ -25549,7 +25562,7 @@ async function onnxEmbed(texts, role) {
25549
25562
  }
25550
25563
  return vectors;
25551
25564
  }
25552
- var ONNX_MODEL_ID = "nomic-ai/nomic-embed-text-v1.5", ONNX_MODEL_NAME = "nomic-embed-text-v1.5", ONNX_MODEL_DTYPE = "q8", ONNX_MODEL_DIM = 768, ONNX_MODEL_APPROX_MB = 130, transformersModule = null, pipelinePromise = null;
25565
+ var ONNX_MODEL_ID = "nomic-ai/nomic-embed-text-v1.5", ONNX_MODEL_NAME = "nomic-embed-text-v1.5", ONNX_MODEL_DTYPE = "q8", ONNX_MODEL_DIM = 768, ONNX_MODEL_APPROX_MB = 130, transformersModule = null, pipelinePromise = null, DEFAULT_ONNX_BATCH = 4;
25553
25566
  var init_onnx_embedder = () => {};
25554
25567
 
25555
25568
  // ../../_shared/embeddings/index.ts
@@ -74646,7 +74659,7 @@ import { homedir as homedir6 } from "node:os";
74646
74659
  import { join as join9 } from "node:path";
74647
74660
 
74648
74661
  // ../../_shared/ef-meta/index.ts
74649
- var EF_VERSION = "1.0.0-beta.4";
74662
+ var EF_VERSION = "1.0.0-rc.3";
74650
74663
 
74651
74664
  // src/cli/util/checks.ts
74652
74665
  init_config();
@@ -18,7 +18,7 @@
18
18
  * doesn't touch `supabase/functions/` leaves it alone).
19
19
  */
20
20
 
21
- export const EF_VERSION = "1.0.0-beta.4";
21
+ export const EF_VERSION = "1.0.0-rc.3";
22
22
 
23
23
  /**
24
24
  * The 8 peer EFs the cerefox-mcp aggregator probes (excludes cerefox-mcp
@@ -208,8 +208,32 @@ export async function warmup(): Promise<void> {
208
208
  * Mean pooling + L2 normalisation (sentence-transformers convention; nomic
209
209
  * expects both). Returns plain `number[][]` to match the OpenAI path.
210
210
  */
211
+ /**
212
+ * Per-inference sub-batch. Peak tensor memory scales with the batch, and the
213
+ * container shares a (often small) Docker VM with Postgres + PostgREST + the
214
+ * web server — a 12-text single call was OOM-killed on Colima's default 2 GB
215
+ * VM (rc.2 dogfood, exit 137). 4 keeps peak memory flat at personal scale;
216
+ * override with CEREFOX_ONNX_BATCH.
217
+ */
218
+ const DEFAULT_ONNX_BATCH = 4;
219
+
220
+ function onnxBatchSize(): number {
221
+ const env = (globalThis as { process?: { env?: Record<string, string | undefined> } })
222
+ .process?.env ?? {};
223
+ const n = Number.parseInt(env.CEREFOX_ONNX_BATCH ?? "", 10);
224
+ return Number.isFinite(n) && n > 0 ? n : DEFAULT_ONNX_BATCH;
225
+ }
226
+
211
227
  export async function onnxEmbed(texts: string[], role: EmbedRole): Promise<number[][]> {
212
228
  if (texts.length === 0) return [];
229
+ const batch = onnxBatchSize();
230
+ if (texts.length > batch) {
231
+ const out: number[][] = [];
232
+ for (let i = 0; i < texts.length; i += batch) {
233
+ out.push(...(await onnxEmbed(texts.slice(i, i + batch), role)));
234
+ }
235
+ return out;
236
+ }
213
237
  const pipeline = await ensurePipeline();
214
238
  const inputs = buildPrefixedInputs(texts, role);
215
239
  const out = await pipeline(inputs, { pooling: "mean", normalize: true });
@@ -49,6 +49,10 @@ install; switching later requires a re-index (see below).
49
49
  The local model (~130 MB) downloads once — at install/init when selected — into the
50
50
  data volume, so it survives `cerefox-local upgrade`.
51
51
 
52
+ > **Memory**: give the Docker VM **≥ 4 GB** for comfortable local-embedder use
53
+ > (Colima defaults to 2 GB: `colima start --memory 4`). Inference is
54
+ > sub-batched to keep peak memory flat, so smaller VMs work — just slower.
55
+
52
56
  > **Switching embedders on existing data is breaking**: the two models produce
53
57
  > incompatible vector spaces, so documents embedded with one are invisible to
54
58
  > semantic search under the other. `cerefox-local init` warns and requires
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerefox/memory",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.3",
4
4
  "description": "Cerefox — user-owned shared memory for AI agents. The local TypeScript runtime: stdio MCP server in v0.4; CLI binary added in v0.5; in-process web server in v0.6; ingestion pipeline in v0.7.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/fstamatelopoulos/cerefox",