@cerefox/memory 1.1.0-beta.4 → 1.1.0-beta.6

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.
@@ -7438,7 +7438,7 @@ var exports_meta = {};
7438
7438
  __export(exports_meta, {
7439
7439
  PKG_VERSION: () => PKG_VERSION
7440
7440
  });
7441
- var PKG_VERSION = "1.1.0-beta.4";
7441
+ var PKG_VERSION = "1.1.0-beta.6";
7442
7442
  var init_meta = () => {};
7443
7443
 
7444
7444
  // ../../_shared/config/paths.ts
@@ -78094,7 +78094,7 @@ async function action27(options) {
78094
78094
  println(c.bold(`Reindexing ${chunks.length} chunk(s) ${reindexAll ? "(--all)" : "(stale only)"}${dryRun ? " — DRY RUN" : ""}`));
78095
78095
  warnLargeBulkWrite({
78096
78096
  count: chunks.length,
78097
- threshold: 1000,
78097
+ threshold: 5000,
78098
78098
  unit: "chunk",
78099
78099
  batchHint: "reindex in stages with --document-id"
78100
78100
  });
@@ -78189,9 +78189,9 @@ async function action28(options) {
78189
78189
  }
78190
78190
  warnLargeBulkWrite({
78191
78191
  count: targets.length,
78192
- threshold: 500,
78192
+ threshold: 1000,
78193
78193
  unit: "document",
78194
- batchHint: "run it in batches with --limit 200"
78194
+ batchHint: "run it in batches with --limit 100"
78195
78195
  });
78196
78196
  if (options.dryRun) {
78197
78197
  println(c.yellow("⚠ --dry-run: nothing was written."));
@@ -82384,6 +82384,107 @@ function registerAuditUsageRoutes(app, ctx) {
82384
82384
  }
82385
82385
 
82386
82386
  // src/web/routes/config.ts
82387
+ import { homedir as homedir9 } from "node:os";
82388
+ import { sep } from "node:path";
82389
+
82390
+ // ../../_shared/config-catalog/index.ts
82391
+ var CONFIG_CATALOG = [
82392
+ {
82393
+ key: "usage_tracking_enabled",
82394
+ description: "Log reads and writes to cerefox_usage_log.",
82395
+ kind: "boolean",
82396
+ defaultValue: "false",
82397
+ group: "Governance"
82398
+ },
82399
+ {
82400
+ key: "require_requestor_identity",
82401
+ description: "Require a requestor/author on MCP tool calls.",
82402
+ kind: "boolean",
82403
+ defaultValue: "false",
82404
+ group: "Governance",
82405
+ highImpact: true,
82406
+ impactNote: "Agents that do not send a requestor will start getting errors. Confirm your MCP clients identify themselves before enabling."
82407
+ },
82408
+ {
82409
+ key: "requestor_identity_format",
82410
+ description: "Regex the requestor/author must match. Only enforced while “require requestor identity” is on.",
82411
+ kind: "string",
82412
+ defaultValue: "",
82413
+ group: "Governance"
82414
+ },
82415
+ {
82416
+ key: "min_search_score",
82417
+ description: "Minimum cosine similarity for vector-side results. Use 0.6 with the local embedder.",
82418
+ kind: "number",
82419
+ defaultValue: "0.5",
82420
+ min: 0,
82421
+ max: 1,
82422
+ group: "Retrieval"
82423
+ },
82424
+ {
82425
+ key: "min_term_coverage",
82426
+ description: "Fraction of a query's meaningful terms a keyword OR-fallback match must cover to count as confident.",
82427
+ kind: "number",
82428
+ defaultValue: "0.5",
82429
+ min: 0,
82430
+ max: 1,
82431
+ group: "Retrieval"
82432
+ },
82433
+ {
82434
+ key: "search_alpha",
82435
+ description: "Hybrid fusion weight: 1 = pure semantic, 0 = pure keyword.",
82436
+ kind: "number",
82437
+ defaultValue: "0.7",
82438
+ min: 0,
82439
+ max: 1,
82440
+ group: "Retrieval"
82441
+ },
82442
+ {
82443
+ key: "relations_enabled",
82444
+ description: "Expose the four document-relation tools to agents. The feature is dormant until enabled.",
82445
+ kind: "boolean",
82446
+ defaultValue: "false",
82447
+ group: "Features",
82448
+ highImpact: true,
82449
+ impactNote: "This adds four tools (set/delete/get relations, get neighbours) to every connected agent's tool list — local MCP, remote MCP, and Edge Functions alike. Relations data and schema are always present; this switch only controls whether agents can see and use the tools. Turning it back off hides them again without deleting anything."
82450
+ }
82451
+ ];
82452
+ function configKeySpec(key) {
82453
+ return CONFIG_CATALOG.find((k) => k.key === key);
82454
+ }
82455
+ var CONFIG_KEYS2 = CONFIG_CATALOG.map((k) => k.key);
82456
+ function validateConfigValue(key, value) {
82457
+ const spec = configKeySpec(key);
82458
+ if (!spec)
82459
+ return `Unknown config key: ${key}`;
82460
+ if (spec.kind === "boolean") {
82461
+ return value === "true" || value === "false" ? null : `${key} must be "true" or "false" (got ${JSON.stringify(value)}).`;
82462
+ }
82463
+ if (spec.kind === "number") {
82464
+ const n = Number(value);
82465
+ if (!Number.isFinite(n)) {
82466
+ return `${key} must be a number (got ${JSON.stringify(value)}).`;
82467
+ }
82468
+ if (spec.min !== undefined && n < spec.min) {
82469
+ return `${key} must be ≥ ${spec.min} (got ${n}).`;
82470
+ }
82471
+ if (spec.max !== undefined && n > spec.max) {
82472
+ return `${key} must be ≤ ${spec.max} (got ${n}).`;
82473
+ }
82474
+ return null;
82475
+ }
82476
+ if (key === "requestor_identity_format" && value.length > 0) {
82477
+ try {
82478
+ new RegExp(value);
82479
+ } catch (err) {
82480
+ return `${key} must be a valid regular expression: ${err instanceof Error ? err.message : String(err)}`;
82481
+ }
82482
+ }
82483
+ return null;
82484
+ }
82485
+
82486
+ // src/web/routes/config.ts
82487
+ init_config();
82387
82488
  function unwrapScalarRpc(data) {
82388
82489
  if (typeof data === "string")
82389
82490
  return data;
@@ -82393,7 +82494,43 @@ function unwrapScalarRpc(data) {
82393
82494
  }
82394
82495
  return null;
82395
82496
  }
82497
+ var ENV_OVERRIDES = {
82498
+ min_search_score: "CEREFOX_MIN_SEARCH_SCORE",
82499
+ min_term_coverage: "CEREFOX_MIN_TERM_COVERAGE",
82500
+ search_alpha: "CEREFOX_SEARCH_ALPHA"
82501
+ };
82396
82502
  function registerConfigRoutes(app, ctx) {
82503
+ app.get("/api/v1/config", async (c2) => {
82504
+ const entries = await Promise.all(CONFIG_CATALOG.map(async (spec) => {
82505
+ const { data, error: error3 } = await ctx.supabase.rpc("cerefox_get_config", {
82506
+ p_key: spec.key
82507
+ });
82508
+ const stored = error3 ? null : unwrapScalarRpc(data);
82509
+ const envVar = ENV_OVERRIDES[spec.key];
82510
+ const envValue = envVar ? (process.env[envVar] ?? "").trim() : "";
82511
+ return {
82512
+ key: spec.key,
82513
+ value: stored,
82514
+ effective: stored ?? spec.defaultValue,
82515
+ description: spec.description,
82516
+ kind: spec.kind,
82517
+ default: spec.defaultValue,
82518
+ min: spec.min ?? null,
82519
+ max: spec.max ?? null,
82520
+ group: spec.group,
82521
+ high_impact: spec.highImpact ?? false,
82522
+ impact_note: spec.impactNote ?? null,
82523
+ env_override: envValue ? { name: envVar, value: envValue } : null
82524
+ };
82525
+ }));
82526
+ let configFile = null;
82527
+ try {
82528
+ const abs = resolveEnvFile();
82529
+ const home = homedir9();
82530
+ configFile = abs === home || abs.startsWith(home + sep) ? `~${abs.slice(home.length)}` : abs;
82531
+ } catch {}
82532
+ return c2.json({ keys: entries, config_file: configFile });
82533
+ });
82397
82534
  app.get("/api/v1/config/:key", async (c2) => {
82398
82535
  const key = c2.req.param("key");
82399
82536
  const { data, error: error3 } = await ctx.supabase.rpc("cerefox_get_config", {
@@ -82412,6 +82549,9 @@ function registerConfigRoutes(app, ctx) {
82412
82549
  return c2.json({ detail: "Invalid JSON body" }, 400);
82413
82550
  }
82414
82551
  const value = typeof body.value === "string" ? body.value : String(body.value ?? "");
82552
+ const invalid = validateConfigValue(key, value);
82553
+ if (invalid)
82554
+ return c2.json({ detail: invalid }, 400);
82415
82555
  const { error: error3 } = await ctx.supabase.rpc("cerefox_set_config", {
82416
82556
  p_key: key,
82417
82557
  p_value: value
@@ -84071,9 +84211,9 @@ import {
84071
84211
  rmSync,
84072
84212
  writeFileSync as writeFileSync7
84073
84213
  } from "node:fs";
84074
- import { homedir as homedir9 } from "node:os";
84214
+ import { homedir as homedir10 } from "node:os";
84075
84215
  import { join as join18 } from "node:path";
84076
- function resolveStateDir(override = process.env.CEREFOX_CONFIG_DIR, home = homedir9()) {
84216
+ function resolveStateDir(override = process.env.CEREFOX_CONFIG_DIR, home = homedir10()) {
84077
84217
  override = (override ?? "").trim();
84078
84218
  if (!override)
84079
84219
  return join18(home, ".cerefox");