@cerefox/memory 1.0.0-rc.1 → 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.
package/dist/bin/cerefox.js
CHANGED
|
@@ -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.
|
|
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-
|
|
74662
|
+
var EF_VERSION = "1.0.0-rc.3";
|
|
74650
74663
|
|
|
74651
74664
|
// src/cli/util/checks.ts
|
|
74652
74665
|
init_config();
|
|
@@ -76889,13 +76902,12 @@ function registerMetadataSearch(program2) {
|
|
|
76889
76902
|
init_dist4();
|
|
76890
76903
|
init_cli_core();
|
|
76891
76904
|
init_config();
|
|
76892
|
-
var DEFAULT_MODEL = "text-embedding-3-small";
|
|
76893
76905
|
async function action27(options) {
|
|
76894
76906
|
const settings = loadSettings();
|
|
76895
76907
|
if (!settings.supabaseUrl || !settings.supabaseKey) {
|
|
76896
76908
|
throw userError("Supabase credentials not configured — run `cerefox init` first.");
|
|
76897
76909
|
}
|
|
76898
|
-
if (!settings.openaiApiKey) {
|
|
76910
|
+
if (!settings.openaiApiKey && resolveEmbedderKind() !== "local") {
|
|
76899
76911
|
throw userError("OPENAI_API_KEY not set — required for embeddings.");
|
|
76900
76912
|
}
|
|
76901
76913
|
const supabase = createClient(settings.supabaseUrl, settings.supabaseKey, {
|
|
@@ -76911,8 +76923,9 @@ async function action27(options) {
|
|
|
76911
76923
|
if (options.documentId) {
|
|
76912
76924
|
query = query.eq("document_id", options.documentId);
|
|
76913
76925
|
}
|
|
76926
|
+
const targetModel = activeEmbedderName();
|
|
76914
76927
|
if (!reindexAll) {
|
|
76915
|
-
query = query.neq("embedder_primary",
|
|
76928
|
+
query = query.neq("embedder_primary", targetModel);
|
|
76916
76929
|
}
|
|
76917
76930
|
const { data, error: error3 } = await query;
|
|
76918
76931
|
if (error3)
|
|
@@ -76941,7 +76954,7 @@ ${c2.content}`;
|
|
|
76941
76954
|
});
|
|
76942
76955
|
let embeddings;
|
|
76943
76956
|
try {
|
|
76944
|
-
embeddings = await embedBatch(texts, settings.openaiApiKey);
|
|
76957
|
+
embeddings = await embedBatch(texts, settings.openaiApiKey ?? "");
|
|
76945
76958
|
} catch (err) {
|
|
76946
76959
|
errors4 += slice.length;
|
|
76947
76960
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -76951,7 +76964,7 @@ ${c2.content}`;
|
|
|
76951
76964
|
for (let i = 0;i < slice.length; i++) {
|
|
76952
76965
|
const { error: updErr } = await supabase.from("cerefox_chunks").update({
|
|
76953
76966
|
embedding_primary: embeddings[i],
|
|
76954
|
-
embedder_primary:
|
|
76967
|
+
embedder_primary: targetModel
|
|
76955
76968
|
}).eq("id", slice[i].id);
|
|
76956
76969
|
if (updErr) {
|
|
76957
76970
|
errors4 += 1;
|
|
@@ -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.
|
|
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",
|