@polycode-projects/the-mechanical-code-talker 5.0.33 → 5.0.35
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/package.json +1 -1
- package/src/domain/choice-question.mjs +91 -0
- package/src/domain/news-feed.mjs +216 -11
- package/src/services/chat.mjs +208 -14
- package/src/services/extract-facts.mjs +124 -15
- package/src/services/news-viz.mjs +164 -19
- package/src/services/news.mjs +17 -3
- package/src/surfaces/web/memory-ask-browser.bundle.js +62 -62
- package/src/surfaces/web/news-browser-entry.mjs +24 -3
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
import { createInMemoryStore, applySeedPayload, loadMemory, readFactRows, appendFacts, removeFacts, normFactTerm, normFactPredicate } from "../../adapters/memory/core.mjs";
|
|
33
33
|
import { factIdFor } from "../../domain/hash.mjs";
|
|
34
34
|
import { loadLexicon } from "../../domain/grammar/lexicon.mjs";
|
|
35
|
-
import { ingestText } from "../../services/extract-facts.mjs";
|
|
35
|
+
import { ingestText, setIngestYield } from "../../services/extract-facts.mjs";
|
|
36
|
+
import { isNewsProvenance } from "../../domain/news-feed.mjs";
|
|
36
37
|
import {
|
|
37
38
|
resolveNewsConfig, createNewsState, pollNewsSources, enrichTopTerms, buildFeed,
|
|
38
39
|
ingestUploadedFactRows, isVocabGroundedTerm,
|
|
@@ -125,14 +126,22 @@ function fixtureRawItems(format, body) {
|
|
|
125
126
|
* own one-off preflight rather than the poll cycle's consent.
|
|
126
127
|
*
|
|
127
128
|
* Returns `{ memoryDir, phase, consented, metrics, nextPollAt, config,
|
|
128
|
-
* requestLog, health, start, poll, enrich, buildFeed, rank, addSource,
|
|
129
|
+
* requestLog, health, start, poll, enrich, buildFeed, stats, rank, addSource,
|
|
129
130
|
* setInterval, ingestText, ingestFile, replayFixture, revokeConsent,
|
|
130
131
|
* destroy }`.
|
|
131
132
|
*/
|
|
132
133
|
export function createNewsSession({
|
|
133
134
|
seedPayload = null, vocabSeeded = false, fetchImpl = null, now = isoNow,
|
|
134
|
-
prefs = null, prefKey = NEWS_START_PREF_KEY,
|
|
135
|
+
prefs = null, prefKey = NEWS_START_PREF_KEY, yieldToHost,
|
|
135
136
|
} = {}) {
|
|
137
|
+
// Grounding one article is seconds of straight-line work, and the page has
|
|
138
|
+
// only the one thread. A macrotask between candidates lets it paint, answer
|
|
139
|
+
// a click and keep the "polling…" affordance honest instead of going
|
|
140
|
+
// unresponsive mid-poll. A Node caller gets no yield and pays nothing.
|
|
141
|
+
setIngestYield(yieldToHost === undefined
|
|
142
|
+
? (typeof document === "undefined" ? null : () => new Promise((resolve) => setTimeout(resolve, 0)))
|
|
143
|
+
: yieldToHost);
|
|
144
|
+
|
|
136
145
|
const memoryDir = createInMemoryStore();
|
|
137
146
|
applySeedPayload(memoryDir, seedPayload);
|
|
138
147
|
|
|
@@ -272,6 +281,18 @@ export function createNewsSession({
|
|
|
272
281
|
|
|
273
282
|
async buildFeed() { return buildFeed(ctx()); },
|
|
274
283
|
|
|
284
|
+
/** The two whole-graph counts the dashboard shows: every fact the store
|
|
285
|
+
* holds, and the subset a news, fixture-replay or research ingest
|
|
286
|
+
* contributed. Read off the same provenance rule the feed window uses,
|
|
287
|
+
* so a tile and the feed can never disagree about what came from news. */
|
|
288
|
+
async stats() {
|
|
289
|
+
const memory = await store.loadMemory(memoryDir);
|
|
290
|
+
const rows = store.readFactRows(memory);
|
|
291
|
+
let fromNews = 0;
|
|
292
|
+
for (const row of rows) if (isNewsProvenance(row.provenance)) fromNews += 1;
|
|
293
|
+
return { graphSize: rows.length, factsFromNews: fromNews };
|
|
294
|
+
},
|
|
295
|
+
|
|
275
296
|
/** The fact rows behind a set of ids — a feed item's own `factIds`,
|
|
276
297
|
* expanded so the page's `<details>` fact list can show each one as a
|
|
277
298
|
* sentence and, nested under it, the raw triple record. */
|