@polycode-projects/the-mechanical-code-talker 3.0.1 → 3.0.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.
@@ -38,6 +38,7 @@ import { registerReferencePackProvider } from "../../adapters/corpus/reference-p
38
38
  import { registerLiveReferenceProvider, registerResearchProvider } from "../../adapters/corpus/wikipedia-live.mjs";
39
39
  import { groundTextToFacts } from "./ingest-browser-entry.mjs";
40
40
  import { openPersistedStore } from "./idb-persist.mjs";
41
+ import { digestTermFromPayloadBrowser } from "./digest-client.mjs";
41
42
 
42
43
  // The Fact individual's first-write-wins timestamp, read straight off the
43
44
  // stored attribute (mgx:createdAt) so a "recently learned" ordering never
@@ -202,7 +203,7 @@ export async function researchSnapshot(memoryDir, sessionIds = {}, { recentCap =
202
203
  *
203
204
  * Returns the store plus both session ids so the page can classify provenance.
204
205
  */
205
- export function createResearchSession({ seedPayload = null, vocabSeeded = false, liveReference = false, onLiveLookup = null, synthesisBudget = 12 } = {}) {
206
+ export function createResearchSession({ seedPayload = null, vocabSeeded = false, liveReference = false, onLiveLookup = null, synthesisBudget = 12, digestStructures = null } = {}) {
206
207
  const memoryDir = createInMemoryStore();
207
208
  if (seedPayload) memoryDir.payload = { ...memoryDir.payload, ...seedPayload };
208
209
 
@@ -311,6 +312,24 @@ export function createResearchSession({ seedPayload = null, vocabSeeded = false,
311
312
  }
312
313
  return ans && ans.text ? { text: ans.text, miss: false } : { text: "", miss: true };
313
314
  },
315
+
316
+ /**
317
+ * A deterministic digest of one term over the live in-browser store, run
318
+ * client-side through the pure digest layer from the structure table
319
+ * embedded in the page (no filesystem, no LLM). Returns the render-ready
320
+ * view { term, paragraphs, sources, facts, factCount } — the narrative
321
+ * leads, the sources ride through, the full fact list stays behind the
322
+ * "show the facts" escape — or null when the term holds no facts, no
323
+ * structures were embedded, or the selector kept nothing renderable.
324
+ */
325
+ async digest(term, { budget = 10 } = {}) {
326
+ const t = normFactTerm(term);
327
+ if (!t) return null;
328
+ let payload;
329
+ try { payload = await loadMemory(memoryDir); } catch { return null; }
330
+ try { return digestTermFromPayloadBrowser(payload, t, digestStructures, { budget }); }
331
+ catch { return null; }
332
+ },
314
333
  };
315
334
  }
316
335