@cerefox/memory 1.0.4 → 1.0.5

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.4";
7187
+ var PKG_VERSION = "1.0.5";
7188
7188
  var init_meta = () => {};
7189
7189
 
7190
7190
  // ../../node_modules/.bun/tslib@2.8.1/node_modules/tslib/tslib.js
@@ -69069,16 +69069,22 @@ import { join as join2, resolve } from "node:path";
69069
69069
  async function fetchAllPages(makeQuery, batchSize = 200) {
69070
69070
  const results = [];
69071
69071
  let offset = 0;
69072
+ let serverTotal = null;
69072
69073
  for (;; ) {
69073
- const { data, error } = await makeQuery(offset, offset + batchSize - 1);
69074
+ const { data, error, count } = await makeQuery(offset, offset + batchSize - 1);
69074
69075
  if (error)
69075
69076
  throw new Error(error.message ?? JSON.stringify(error));
69077
+ if (typeof count === "number")
69078
+ serverTotal = count;
69076
69079
  const page = data ?? [];
69077
69080
  results.push(...page);
69078
69081
  if (page.length < batchSize)
69079
69082
  break;
69080
69083
  offset += batchSize;
69081
69084
  }
69085
+ if (serverTotal !== null && results.length !== serverTotal) {
69086
+ throw new Error(`Paginated read returned ${results.length} row(s) but the server reports ` + `${serverTotal}. Refusing to return a partial result — retry, and if this ` + `persists please report it (the rows may be changing under the read).`);
69087
+ }
69082
69088
  return results;
69083
69089
  }
69084
69090
 
@@ -75000,7 +75006,7 @@ import { homedir as homedir6 } from "node:os";
75000
75006
  import { join as join9 } from "node:path";
75001
75007
 
75002
75008
  // ../../_shared/ef-meta/index.ts
75003
- var EF_VERSION = "1.0.4";
75009
+ var EF_VERSION = "1.0.5";
75004
75010
  var EF_LAST_CHANGED = "1.0.4";
75005
75011
 
75006
75012
  // src/cli/util/checks.ts
@@ -75527,9 +75533,9 @@ async function checkEdgeFunctionsCompat() {
75527
75533
  }
75528
75534
  return {
75529
75535
  name: "edge functions",
75530
- status: "skipped",
75531
- detail: `Deployed Edge Functions (v${deployed}) are older than the ones bundled with this client (v${EF_VERSION}). Compatible — nothing is broken — but redeploying ` + `picks up the latest server-side fixes.`,
75532
- hint: "Redeploy with: cerefox server deploy --functions-only"
75536
+ status: "warn",
75537
+ detail: `Deployed Edge Functions (v${deployed}) are older than this client's bundled v${EF_VERSION} and predate server-side fixes shipped in v${EF_LAST_CHANGED}. Still compatible, but you are missing those fixes.`,
75538
+ hint: "Update the Edge Functions (see remediation below)."
75533
75539
  };
75534
75540
  default:
75535
75541
  return {
@@ -75628,11 +75634,11 @@ async function action15(options) {
75628
75634
  const needsEf = stale("edge functions");
75629
75635
  let remediation = null;
75630
75636
  if (needsSchema && needsEf) {
75631
- remediation = "Update the server (schema + RPCs + Edge Functions): cerefox server deploy";
75637
+ remediation = "This release needs a server update (schema + RPCs + Edge Functions): cerefox server deploy";
75632
75638
  } else if (needsSchema) {
75633
- remediation = "Update the schema + RPCs: cerefox server deploy --schema-only";
75639
+ remediation = "This release needs a schema + RPC update: cerefox server deploy --schema-only";
75634
75640
  } else if (needsEf) {
75635
- remediation = "Update the Edge Functions: cerefox server deploy --functions-only";
75641
+ remediation = "This release needs an Edge Function update: cerefox server deploy --functions-only";
75636
75642
  }
75637
75643
  if (remediation) {
75638
75644
  println(cErr.yellow("→ " + remediation));
@@ -75859,7 +75865,7 @@ class IngestionDbBridge {
75859
75865
  return rows.length > 0 ? rows[0] : null;
75860
75866
  }
75861
75867
  async listChunksForDocument(documentId) {
75862
- const { data } = await this.supabase.from("cerefox_chunks").select("id, document_id, chunk_index, heading_path, heading_level, title, content, char_count").eq("document_id", documentId).is("version_id", null).order("chunk_index");
75868
+ const data = await fetchAllPages((from, to) => this.supabase.from("cerefox_chunks").select("id, document_id, chunk_index, heading_path, heading_level, title, content, char_count").eq("document_id", documentId).is("version_id", null).order("chunk_index").range(from, to));
75863
75869
  return data ?? [];
75864
75870
  }
75865
75871
  async getDocumentProjectIds(documentId) {
@@ -81451,23 +81457,18 @@ function parseMetadataFilter(raw2) {
81451
81457
  }
81452
81458
  async function listDocuments(ctx, opts) {
81453
81459
  const { projectId, limit, offset = 0 } = opts;
81454
- let docIds = null;
81455
- if (projectId) {
81456
- const { data: data2, error: error4 } = await ctx.supabase.from("cerefox_document_projects").select("document_id").eq("project_id", projectId);
81457
- if (error4)
81458
- throw error4;
81459
- docIds = (data2 ?? []).map((r) => r.document_id);
81460
- if (docIds.length === 0)
81461
- return [];
81462
- }
81463
- let q = ctx.supabase.from("cerefox_documents").select(DOC_COLS).is("deleted_at", null).order("updated_at", { ascending: false });
81464
- if (docIds)
81465
- q = q.in("id", docIds);
81460
+ const selectCols = projectId ? `${DOC_COLS}, cerefox_document_projects!inner(project_id)` : DOC_COLS;
81461
+ let q = ctx.supabase.from("cerefox_documents").select(selectCols).is("deleted_at", null).order("updated_at", { ascending: false });
81462
+ if (projectId)
81463
+ q = q.eq("cerefox_document_projects.project_id", projectId);
81466
81464
  q = q.range(offset, offset + limit - 1);
81467
81465
  const { data, error: error3 } = await q;
81468
81466
  if (error3)
81469
81467
  throw error3;
81470
- return data ?? [];
81468
+ return (data ?? []).map((row) => {
81469
+ const { cerefox_document_projects: _j, ...doc2 } = row;
81470
+ return doc2;
81471
+ });
81471
81472
  }
81472
81473
  async function listAllProjects(ctx) {
81473
81474
  const { data, error: error3 } = await ctx.supabase.from("cerefox_projects").select("*").order("name");
@@ -81583,7 +81584,8 @@ function projectDocResult(r) {
81583
81584
  chunk_count: r.chunk_count ?? 0,
81584
81585
  total_chars: r.total_chars ?? 0,
81585
81586
  doc_updated_at: r.doc_updated_at ?? null,
81586
- is_partial: r.is_partial ?? false
81587
+ is_partial: r.is_partial ?? false,
81588
+ below_confidence: r.below_confidence ?? false
81587
81589
  };
81588
81590
  }
81589
81591
  function projectChunkResult(r) {
@@ -81599,7 +81601,8 @@ function projectChunkResult(r) {
81599
81601
  doc_title: r.doc_title ?? "",
81600
81602
  doc_source: r.doc_source ?? null,
81601
81603
  doc_project_ids: r.doc_project_ids ?? [],
81602
- doc_metadata: r.doc_metadata ?? {}
81604
+ doc_metadata: r.doc_metadata ?? {},
81605
+ below_confidence: r.below_confidence ?? false
81603
81606
  };
81604
81607
  }
81605
81608
  async function runSearch(ctx, opts) {
@@ -82079,7 +82082,7 @@ function registerDocumentReadRoutes(app, ctx) {
82079
82082
  });
82080
82083
  app.get("/api/v1/documents/:document_id/chunks", async (c2) => {
82081
82084
  const documentId = c2.req.param("document_id");
82082
- const { data, error: error3 } = await ctx.supabase.from("cerefox_chunks").select("id, document_id, chunk_index, heading_path, heading_level, title, content, char_count").eq("document_id", documentId).is("version_id", null).order("chunk_index");
82085
+ const { data, error: error3 } = await ctx.supabase.from("cerefox_chunks").select("id, document_id, chunk_index, heading_path, heading_level, title, content, char_count").eq("document_id", documentId).is("version_id", null).order("chunk_index").range(0, 4999);
82083
82086
  if (error3)
82084
82087
  return c2.json({ detail: error3.message }, 500);
82085
82088
  const rows = data ?? [];