@brainbox-labs/sdk 0.25.0 → 0.26.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.
@@ -82,25 +82,31 @@ function diffSources(local, remote) {
82
82
  }
83
83
  var MAX_LIST_PAGES = 500;
84
84
  var LIST_PAGE_LIMIT = 50;
85
- var SERVER_SCAN_WINDOW = 1e3;
85
+ var LEGACY_SCAN_WINDOW = 1e3;
86
86
  function executorLister(exec) {
87
87
  return {
88
88
  async listSources(namespace, opts) {
89
89
  const want = serverNamespace(namespace);
90
90
  const out = [];
91
91
  let seen = 0;
92
+ let serverTruncated = false;
92
93
  let cursor;
93
94
  for (let i = 0; i < MAX_LIST_PAGES; i++) {
94
95
  const args = { kind: "raw-source", limit: LIST_PAGE_LIMIT, ...want !== "" ? { namespace: want } : {}, ...cursor ? { cursor } : {} };
95
96
  const res = await exec("list_wiki_pages", args);
96
97
  seen += res.pages?.length ?? 0;
98
+ if (res.truncated) serverTruncated = true;
97
99
  for (const p of res.pages ?? []) {
98
100
  if (!p.sourceKey) continue;
99
101
  const ns = normalizeNamespace(p.namespace);
100
102
  if (ns !== want && !(opts?.subtree && ns.startsWith(`${want}/`))) continue;
101
103
  out.push({ sourceKey: p.sourceKey, title: p.title, pageId: p.pageId, sourceVersion: p.sourceVersion, namespace: p.namespace, analysisDepth: p.analysisDepth });
102
104
  }
103
- if (!res.nextCursor) return { sources: out, truncated: seen >= SERVER_SCAN_WINDOW };
105
+ if (!res.nextCursor) {
106
+ if (serverTruncated) return { sources: out, truncated: true, truncatedReason: "the server reported that its scan window filled" };
107
+ if (res.complete) return { sources: out, truncated: false };
108
+ return seen >= LEGACY_SCAN_WINDOW ? { sources: out, truncated: true, truncatedReason: `the server sent no completeness flag and ${seen} pages were listed, as many as its ${LEGACY_SCAN_WINDOW}-doc scan window` } : { sources: out, truncated: false };
109
+ }
104
110
  cursor = res.nextCursor;
105
111
  }
106
112
  throw new Error("[BrainBox] sync: too many raw-source pages to list; narrow with a namespace");
@@ -251,7 +257,7 @@ async function performSync(ctx, syncOpts, deps = {}) {
251
257
  dryRun: opts.dryRun ?? false,
252
258
  namespace: opts.namespace,
253
259
  ...projectMissing && { projectMissing: true },
254
- ...listing.truncated && { listingTruncated: true },
260
+ ...listing.truncated && { listingTruncated: true, ...listing.truncatedReason && { listingTruncatedReason: listing.truncatedReason } },
255
261
  added: diff.added.map(toEntry),
256
262
  changed: diff.changed.map(toEntry),
257
263
  unchanged: diff.unchanged.map(toEntry),
package/dist/index.d.ts CHANGED
@@ -268,6 +268,8 @@ interface SyncResult {
268
268
  projectMissing?: boolean;
269
269
  /** The server may have cut the listing short, so deletes were not computed (nothing is reported or archived). */
270
270
  listingTruncated?: boolean;
271
+ /** Why the listing was treated as possibly incomplete; set with `listingTruncated`. */
272
+ listingTruncatedReason?: string;
271
273
  added: SyncEntry[];
272
274
  changed: SyncEntry[];
273
275
  /** Same key + version + namespace as the Brain. Not sent unless `force`. */
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SyncPartialFailureError
3
- } from "./chunk-BT5L23RH.js";
3
+ } from "./chunk-SUTD4AF4.js";
4
4
  import {
5
5
  IngestPartialFailureError
6
6
  } from "./chunk-3DMBWVAH.js";
@@ -411,7 +411,7 @@ var BrainBox = class {
411
411
  throw new Error("[BrainBox] brain.sync does not support tenant keys yet. Use a project or org key.");
412
412
  }
413
413
  const ctx = await this.ingestContext("sync");
414
- const { performSync } = await import("./sync-2IZHSU3F.js");
414
+ const { performSync } = await import("./sync-G2GH3PEJ.js");
415
415
  return performSync(ctx, opts);
416
416
  }
417
417
  /** Archive the synced pages for these `sourceKey`s (soft, reversible server-side). Unknown keys come back in `notFound`. */
@@ -420,7 +420,7 @@ var BrainBox = class {
420
420
  throw new Error("[BrainBox] brain.prune does not support tenant keys yet. Use a project or org key.");
421
421
  }
422
422
  const ctx = await this.ingestContext("prune");
423
- const { performPrune } = await import("./sync-2IZHSU3F.js");
423
+ const { performPrune } = await import("./sync-G2GH3PEJ.js");
424
424
  return performPrune(ctx, sourceKeys);
425
425
  }
426
426
  /** Target for write-side calls: a tenant key's overlay project, else the handle's `project`. */
@@ -11,7 +11,7 @@ import {
11
11
  performPrune,
12
12
  performSync,
13
13
  splitIntoBatches
14
- } from "./chunk-BT5L23RH.js";
14
+ } from "./chunk-SUTD4AF4.js";
15
15
  import "./chunk-3DMBWVAH.js";
16
16
  import {
17
17
  deriveSourceKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainbox-labs/sdk",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "BrainBox JavaScript/TypeScript SDK — MCP server + API client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@brainbox-labs/api": "^0.11.0",
35
- "@brainbox-labs/types": "^1.34.0",
35
+ "@brainbox-labs/types": "^1.36.0",
36
36
  "@modelcontextprotocol/sdk": "^1.27.1",
37
37
  "dotenv": "^16.4.5",
38
38
  "express": "^5.0.0",