@wrenautomation/birdwatch 0.0.0-stage → 0.30.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.
Files changed (141) hide show
  1. package/LICENSE.md +61 -0
  2. package/README.md +320 -2
  3. package/dist/app/cli.d.ts +4 -0
  4. package/dist/app/cli.js +149 -0
  5. package/dist/app/cli.js.map +1 -0
  6. package/dist/app/engine-cli.d.ts +44 -0
  7. package/dist/app/engine-cli.js +596 -0
  8. package/dist/app/engine-cli.js.map +1 -0
  9. package/dist/app/index.d.ts +6 -0
  10. package/dist/app/index.js +7 -0
  11. package/dist/app/index.js.map +1 -0
  12. package/dist/app/serve.d.ts +14 -0
  13. package/dist/app/serve.js +102 -0
  14. package/dist/app/serve.js.map +1 -0
  15. package/dist/document/body.d.ts +6 -0
  16. package/dist/document/body.js +18 -0
  17. package/dist/document/body.js.map +1 -0
  18. package/dist/document/check.d.ts +35 -0
  19. package/dist/document/check.js +68 -0
  20. package/dist/document/check.js.map +1 -0
  21. package/dist/document/extract.d.ts +81 -0
  22. package/dist/document/extract.js +226 -0
  23. package/dist/document/extract.js.map +1 -0
  24. package/dist/document/index.d.ts +11 -0
  25. package/dist/document/index.js +12 -0
  26. package/dist/document/index.js.map +1 -0
  27. package/dist/document/model.d.ts +10 -0
  28. package/dist/document/model.js +2 -0
  29. package/dist/document/model.js.map +1 -0
  30. package/dist/document/readers.d.ts +24 -0
  31. package/dist/document/readers.js +87 -0
  32. package/dist/document/readers.js.map +1 -0
  33. package/dist/document/types.d.ts +99 -0
  34. package/dist/document/types.js +93 -0
  35. package/dist/document/types.js.map +1 -0
  36. package/dist/engine/agent.d.ts +475 -0
  37. package/dist/engine/agent.js +990 -0
  38. package/dist/engine/agent.js.map +1 -0
  39. package/dist/engine/canonical.d.ts +4 -0
  40. package/dist/engine/canonical.js +55 -0
  41. package/dist/engine/canonical.js.map +1 -0
  42. package/dist/engine/context.d.ts +9 -0
  43. package/dist/engine/context.js +141 -0
  44. package/dist/engine/context.js.map +1 -0
  45. package/dist/engine/cost.d.ts +13 -0
  46. package/dist/engine/cost.js +31 -0
  47. package/dist/engine/cost.js.map +1 -0
  48. package/dist/engine/index.d.ts +16 -0
  49. package/dist/engine/index.js +17 -0
  50. package/dist/engine/index.js.map +1 -0
  51. package/dist/engine/judge.d.ts +158 -0
  52. package/dist/engine/judge.js +323 -0
  53. package/dist/engine/judge.js.map +1 -0
  54. package/dist/engine/people.d.ts +34 -0
  55. package/dist/engine/people.js +125 -0
  56. package/dist/engine/people.js.map +1 -0
  57. package/dist/engine/plan.d.ts +6 -0
  58. package/dist/engine/plan.js +7 -0
  59. package/dist/engine/plan.js.map +1 -0
  60. package/dist/engine/plans/index.d.ts +19 -0
  61. package/dist/engine/plans/index.js +104 -0
  62. package/dist/engine/plans/index.js.map +1 -0
  63. package/dist/engine/ports.d.ts +76 -0
  64. package/dist/engine/ports.js +28 -0
  65. package/dist/engine/ports.js.map +1 -0
  66. package/dist/engine/recall.d.ts +42 -0
  67. package/dist/engine/recall.js +71 -0
  68. package/dist/engine/recall.js.map +1 -0
  69. package/dist/engine/state.d.ts +96 -0
  70. package/dist/engine/state.js +162 -0
  71. package/dist/engine/state.js.map +1 -0
  72. package/dist/engine/steps.d.ts +98 -0
  73. package/dist/engine/steps.js +435 -0
  74. package/dist/engine/steps.js.map +1 -0
  75. package/dist/engine/tree.d.ts +76 -0
  76. package/dist/engine/tree.js +148 -0
  77. package/dist/engine/tree.js.map +1 -0
  78. package/dist/engine/types.d.ts +250 -0
  79. package/dist/engine/types.js +168 -0
  80. package/dist/engine/types.js.map +1 -0
  81. package/dist/engine/view.d.ts +138 -0
  82. package/dist/engine/view.js +188 -0
  83. package/dist/engine/view.js.map +1 -0
  84. package/dist/index.d.ts +15 -0
  85. package/dist/index.js +16 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/ledger/files.d.ts +39 -0
  88. package/dist/ledger/files.js +113 -0
  89. package/dist/ledger/files.js.map +1 -0
  90. package/dist/ledger/ids.d.ts +4 -0
  91. package/dist/ledger/ids.js +9 -0
  92. package/dist/ledger/ids.js.map +1 -0
  93. package/dist/ledger/index.d.ts +11 -0
  94. package/dist/ledger/index.js +12 -0
  95. package/dist/ledger/index.js.map +1 -0
  96. package/dist/ledger/ledger.d.ts +46 -0
  97. package/dist/ledger/ledger.js +105 -0
  98. package/dist/ledger/ledger.js.map +1 -0
  99. package/dist/ledger/memory.d.ts +19 -0
  100. package/dist/ledger/memory.js +19 -0
  101. package/dist/ledger/memory.js.map +1 -0
  102. package/dist/ledger/records.d.ts +1424 -0
  103. package/dist/ledger/records.js +292 -0
  104. package/dist/ledger/records.js.map +1 -0
  105. package/dist/sources/arxiv.d.ts +105 -0
  106. package/dist/sources/arxiv.js +321 -0
  107. package/dist/sources/arxiv.js.map +1 -0
  108. package/dist/sources/exa.d.ts +19 -0
  109. package/dist/sources/exa.js +59 -0
  110. package/dist/sources/exa.js.map +1 -0
  111. package/dist/sources/fetcher.d.ts +35 -0
  112. package/dist/sources/fetcher.js +67 -0
  113. package/dist/sources/fetcher.js.map +1 -0
  114. package/dist/sources/google.d.ts +16 -0
  115. package/dist/sources/google.js +64 -0
  116. package/dist/sources/google.js.map +1 -0
  117. package/dist/sources/index.d.ts +17 -0
  118. package/dist/sources/index.js +18 -0
  119. package/dist/sources/index.js.map +1 -0
  120. package/dist/sources/junk.d.ts +10 -0
  121. package/dist/sources/junk.js +16 -0
  122. package/dist/sources/junk.js.map +1 -0
  123. package/dist/sources/ladder.d.ts +47 -0
  124. package/dist/sources/ladder.js +158 -0
  125. package/dist/sources/ladder.js.map +1 -0
  126. package/dist/sources/ledger.d.ts +7 -0
  127. package/dist/sources/ledger.js +35 -0
  128. package/dist/sources/ledger.js.map +1 -0
  129. package/dist/sources/paste.d.ts +8 -0
  130. package/dist/sources/paste.js +22 -0
  131. package/dist/sources/paste.js.map +1 -0
  132. package/dist/sources/searxng.d.ts +11 -0
  133. package/dist/sources/searxng.js +38 -0
  134. package/dist/sources/searxng.js.map +1 -0
  135. package/dist/sources/sites.d.ts +53 -0
  136. package/dist/sources/sites.js +285 -0
  137. package/dist/sources/sites.js.map +1 -0
  138. package/dist/sources/ytdlp.d.ts +43 -0
  139. package/dist/sources/ytdlp.js +117 -0
  140. package/dist/sources/ytdlp.js.map +1 -0
  141. package/package.json +61 -3
@@ -0,0 +1,323 @@
1
+ /**
2
+ * The judge's passes: cheap typed answers on every hit, document and finding, written as
3
+ * `judge` records. A hint and a router, never a call: the brief ranks hits and shows class
4
+ * guesses by them, the tree counts a facet's needed classes by them before a read, and the
5
+ * check sends each finding the judge doubts to the model. A failed judge call writes its spend
6
+ * and the step goes on; a refused key ends the pass.
7
+ */
8
+ import { choice, noul, top, } from "@wrenautomation/models/judge";
9
+ import { bodyOf, contextOf } from "../document/index.js";
10
+ import { SOURCE_CLASSES, } from "../ledger/records.js";
11
+ import { kept } from "./state.js";
12
+ /** Judge calls in flight at once. */
13
+ export const JUDGE_PARALLEL = 8;
14
+ /** A finding the judge backs under this goes to the model's check. */
15
+ export const DOUBT = 0.8;
16
+ /**
17
+ * Characters per judge call on a page read whole. Jev takes about 32k tokens of state (a 30k
18
+ * paper went in, 43k came back `max_tokens_exceeded`); 64k characters stays under it at 2
19
+ * characters a token.
20
+ */
21
+ export const CHUNK = 64_000;
22
+ /** Calls per page at most: a longer page is judged on its first `CHUNK * CHUNKS` characters. */
23
+ export const CHUNKS = 4;
24
+ const CLASS = choice("What kind of source is this page?", {
25
+ primary_data: "the party's own data: a filing, a public price page, a job ad, a dataset, a government statistic",
26
+ survey: "a survey or study of many respondents or firms",
27
+ practitioner: "one person who does the work, telling what they saw or did",
28
+ vendor: "a company writing about its own market, product or customers",
29
+ forum: "a forum thread or its comments: Reddit, a Facebook group, a Q&A site",
30
+ news: "a news or trade press article",
31
+ other: "anything else",
32
+ });
33
+ export const HIT_QUESTIONS = {
34
+ serves: noul("Could this page hold a specific fact (a number, a practice, a stated cause) that answers the ask?", {
35
+ true: "it likely holds such a fact",
36
+ false: "another topic, or nothing specific: a listicle, a directory, a sales page",
37
+ }),
38
+ side: choice("Who wrote this page, next to the people the ask is about?", {
39
+ subject: "those people, or a neutral party reporting on them",
40
+ seller: "a vendor, agency or coach selling to those people",
41
+ other: "neither, or it cannot tell",
42
+ }),
43
+ class: CLASS,
44
+ };
45
+ /**
46
+ * A trial (10-28): can Jev score a page's worth as a source before the extract reads it?
47
+ * A hint only; `judgeStats.worth` measures it against what the extract kept. From 0.25.0 it
48
+ * reads the whole page, in chunks, not the first 4,000 characters.
49
+ */
50
+ export const DOCUMENT_QUESTIONS = {
51
+ class: CLASS,
52
+ worth: noul("Would a careful researcher answering the ask cite this page as a source?", {
53
+ true: "it gives specific facts on the ask (numbers, practices, causes, first-hand accounts) from a party in a position to know, or credits a named source for them",
54
+ false: "off the ask, thin, generic advice, a sales pitch, a rehash with no source, a list of links, or a page shell",
55
+ }),
56
+ };
57
+ export const FINDING_QUESTIONS = {
58
+ backs: noul("Does the quote, read in its context, say everything the sentence says? A plain rewording is fine.", {
59
+ true: "the quote backs every part of the sentence",
60
+ false: "the sentence says more than the quote (a number, a cause, a scope, a certainty, who says it), or the context turns the quote (a question, a hypothetical, an ad)",
61
+ }),
62
+ cites: noul("Does the quote or the text around it credit the fact to another named source: a survey, a study, a report, a dataset?"),
63
+ };
64
+ /** The names the judge asks on its own: a criterion may not take one. */
65
+ export const RESERVED = new Set([
66
+ ...Object.keys(HIT_QUESTIONS),
67
+ ...Object.keys(DOCUMENT_QUESTIONS),
68
+ ...Object.keys(FINDING_QUESTIONS),
69
+ ]);
70
+ /** The ask's criteria as yes-or-no questions, by name. */
71
+ export const criteriaQuestions = (criteria) => Object.fromEntries((criteria ?? []).map((c) => [c.name, noul(c.question)]));
72
+ /** The body in judge-sized parts, each cut at a paragraph when one is near the limit. */
73
+ export function chunksOf(text) {
74
+ const out = [];
75
+ let rest = bodyOf(text);
76
+ while (rest.trim() && out.length < CHUNKS) {
77
+ if (rest.length <= CHUNK) {
78
+ out.push(rest);
79
+ break;
80
+ }
81
+ const cut = rest.lastIndexOf("\n\n", CHUNK);
82
+ const at = cut > CHUNK * 0.8 ? cut : CHUNK;
83
+ out.push(rest.slice(0, at));
84
+ rest = rest.slice(at);
85
+ }
86
+ return out;
87
+ }
88
+ /**
89
+ * One record's answers from its parts: a yes-or-no question takes the part most sure of a yes
90
+ * (a result sits in one section); a pick takes the first part's (the page's start says its kind).
91
+ */
92
+ export function mergeAnswers(parts) {
93
+ const out = { ...parts[0] };
94
+ for (const part of parts.slice(1))
95
+ for (const [k, probs] of Object.entries(part)) {
96
+ const was = out[k];
97
+ if (!was)
98
+ out[k] = probs;
99
+ else if (probs.yes !== undefined && was.yes !== undefined && probs.yes > was.yes)
100
+ out[k] = probs;
101
+ }
102
+ return out;
103
+ }
104
+ /**
105
+ * One question set over many items, a few at a time; each item's answers one `judge` record.
106
+ * An item in parts (a long page) is asked part by part and written only when every part answered:
107
+ * a missing part would read as a no, so the next pass asks again.
108
+ */
109
+ async function pass(ctx, items, questions) {
110
+ const out = { judged: 0, failed: 0 };
111
+ if (!ctx.deps.judge)
112
+ return out;
113
+ const askAll = async (x) => {
114
+ const parts = [];
115
+ let model = "";
116
+ for (const state of x.states) {
117
+ const g = await ctx.judge(x.on, x.about, state, questions);
118
+ if ("failure" in g)
119
+ return { failure: g.failure };
120
+ parts.push(g.answers);
121
+ model = g.model;
122
+ }
123
+ return { answers: mergeAnswers(parts), model };
124
+ };
125
+ for (let i = 0; i < items.length && !out.stopped; i += JUDGE_PARALLEL) {
126
+ const batch = items.slice(i, i + JUDGE_PARALLEL);
127
+ const got = await Promise.all(batch.map(askAll));
128
+ for (const [j, g] of got.entries()) {
129
+ const item = batch[j];
130
+ if ("failure" in g) {
131
+ out.failed++;
132
+ if (g.failure === "key")
133
+ out.stopped = `the judge's key was refused`;
134
+ continue;
135
+ }
136
+ await ctx.write({ type: "judge", on: item.on, answers: g.answers }, { from: "ai", by: g.model });
137
+ out.judged++;
138
+ }
139
+ }
140
+ return out;
141
+ }
142
+ /** "jev: 12 judged, 1 failed" for a step's note, or nothing. */
143
+ export const passNote = (p) => p.judged || p.failed
144
+ ? `; judge: ${p.judged} judged${p.failed ? `, ${p.failed} failed` : ""}${p.stopped ? ` (${p.stopped})` : ""}`
145
+ : "";
146
+ /** Uncalled hits with no answers yet: serves the ask, whose side, what class, each criterion. */
147
+ export function judgeHits(ctx, state) {
148
+ const ask = state.snapshot?.ask.text ?? "";
149
+ const whyOf = new Map(state.queries.map((q) => [q.id, q.why]));
150
+ const items = state.hits
151
+ .filter((h) => !state.judged.has(h.id) && !state.called.has(h.id))
152
+ .map((h) => ({
153
+ on: h.id,
154
+ about: h.url,
155
+ states: [
156
+ {
157
+ ask,
158
+ searched_for: [...new Set(h.queries.flatMap((q) => whyOf.get(q) ?? []))],
159
+ page: { url: h.url, title: h.title ?? "", snippet: h.snippet ?? "" },
160
+ },
161
+ ],
162
+ }));
163
+ return pass(ctx, items, { ...HIT_QUESTIONS, ...criteriaQuestions(state.snapshot?.ask.criteria) });
164
+ }
165
+ /** Documents with no answers yet: class, worth and each criterion, read whole in parts. */
166
+ export function judgeDocuments(ctx, state) {
167
+ const ask = state.snapshot?.ask.text ?? "";
168
+ const items = state.documents
169
+ .filter((d) => !state.judged.has(d.id) && d.text.trim())
170
+ .map((d) => {
171
+ const parts = chunksOf(d.text);
172
+ return {
173
+ on: d.id,
174
+ about: d.url,
175
+ states: parts.map((text, i) => ({
176
+ ask,
177
+ url: d.url,
178
+ title: d.title ?? "",
179
+ ...(parts.length > 1 ? { part: `${i + 1} of ${parts.length}` } : {}),
180
+ text,
181
+ })),
182
+ };
183
+ });
184
+ return pass(ctx, items, {
185
+ ...DOCUMENT_QUESTIONS,
186
+ ...criteriaQuestions(state.snapshot?.ask.criteria),
187
+ });
188
+ }
189
+ /** Findings with a quote and no answers yet: does the quote back it, does it credit a source. */
190
+ export function judgeFindings(ctx, state, findings) {
191
+ const docs = new Map(state.documents.map((d) => [d.id, d]));
192
+ const items = findings.flatMap((f) => {
193
+ const d = docs.get(f.document);
194
+ const quote = f.proof.quote;
195
+ if (!d || !quote || state.judged.has(f.id))
196
+ return [];
197
+ return [
198
+ {
199
+ on: f.id,
200
+ about: f.text,
201
+ states: [{ sentence: f.text, quote, context: contextOf(d.text, quote) }],
202
+ },
203
+ ];
204
+ });
205
+ return pass(ctx, items, FINDING_QUESTIONS);
206
+ }
207
+ /** The probability of a yes on one record's question, or undefined with no answer. */
208
+ export const yesOf = (state, on, question) => state.judged.get(on)?.[question]?.yes;
209
+ /** The judge's top label on a question, with its probability. */
210
+ export function pickOf(state, on, question) {
211
+ const probs = state.judged.get(on)?.[question];
212
+ if (!probs)
213
+ return undefined;
214
+ const [pick, p] = top(probs);
215
+ return { pick, p };
216
+ }
217
+ /**
218
+ * A hit's class as best known: the agent's on its document, else the judge's on the document,
219
+ * else the judge's on the hit.
220
+ */
221
+ export function classGuess(state, hit) {
222
+ const doc = state.documents.find((d) => d.hit === hit);
223
+ const agent = doc && state.classOf.get(doc.id);
224
+ if (agent)
225
+ return agent;
226
+ const guess = (doc && pickOf(state, doc.id, "class")) ?? pickOf(state, hit, "class");
227
+ return guess && SOURCE_CLASSES.includes(guess.pick)
228
+ ? guess.pick
229
+ : undefined;
230
+ }
231
+ /**
232
+ * How well a score ranks positives over negatives: the share of (positive, negative) pairs it
233
+ * orders right, ties a half. Null without both.
234
+ */
235
+ export function aucOf(pairs) {
236
+ const pos = pairs.filter(([, y]) => y).map(([p]) => p);
237
+ const neg = pairs.filter(([, y]) => !y).map(([p]) => p);
238
+ if (!pos.length || !neg.length)
239
+ return null;
240
+ let sum = 0;
241
+ for (const a of pos)
242
+ for (const b of neg)
243
+ sum += a > b ? 1 : a === b ? 0.5 : 0;
244
+ return sum / (pos.length * neg.length);
245
+ }
246
+ /** What the judge did in a run and how often the deciders agreed with it. */
247
+ export function judgeStats(state, judge) {
248
+ const ids = new Set(state.judges.map((j) => j.by));
249
+ const spends = state.spends.filter((s) => s.op === "ask" && (ids.has(s.source) || s.source === judge));
250
+ const tally = (pairs) => ({
251
+ both: pairs.length,
252
+ agree: pairs.filter(([a, b]) => a === b).length,
253
+ });
254
+ const hits = state.hits.flatMap((h) => {
255
+ const yes = yesOf(state, h.id, "serves");
256
+ const call = state.called.get(h.id);
257
+ return yes === undefined || !call ? [] : [[yes > 0.5, call === "keep"]];
258
+ });
259
+ const classes = state.documents.flatMap((d) => {
260
+ const guess = pickOf(state, d.id, "class");
261
+ const agent = state.classOf.get(d.id);
262
+ return !guess || !agent ? [] : [[true, guess.pick === agent]];
263
+ });
264
+ const lastCheck = new Map(state.checks.map((c) => [c.on, c.ok]));
265
+ const checks = [...lastCheck].flatMap(([on, ok]) => {
266
+ const yes = yesOf(state, on, "backs");
267
+ return yes === undefined ? [] : [[yes > 0.5, ok]];
268
+ });
269
+ const keptOn = new Set(state.findings.filter((f) => kept(state, f)).map((f) => f.document));
270
+ // Read for facts: an extract's verdict, a finding by hand, or a gap on the page.
271
+ const extracted = new Set([
272
+ ...state.verdicts.map((v) => v.document),
273
+ ...state.findings.map((f) => f.document),
274
+ ...state.gaps.flatMap((g) => (g.on ? [g.on] : [])),
275
+ ]);
276
+ // the last verdict per page: a rerun extract replaces the first
277
+ const quality = new Map(state.verdicts.map((v) => [v.document, v.quality]));
278
+ const hitOf = new Map(state.documents.map((d) => [d.id, d.hit]));
279
+ const scored = (name, on) => [...extracted].flatMap((d) => {
280
+ const id = on(d);
281
+ const yes = id === undefined ? undefined : yesOf(state, id, name);
282
+ return yes === undefined ? [] : [[yes, d]];
283
+ });
284
+ const ranked = (pairs) => ({
285
+ both: pairs.length,
286
+ auc: aucOf(pairs.map(([p, d]) => [p, keptOn.has(d)])),
287
+ rich: aucOf(pairs.flatMap(([p, d]) => (quality.has(d) ? [[p, quality.get(d) === "rich"]] : []))),
288
+ });
289
+ const worthPairs = scored("worth", (d) => d);
290
+ const worth = worthPairs.map(([p, d]) => [p, keptOn.has(d)]);
291
+ const under = worth.filter(([p]) => p < 0.5);
292
+ const criteria = Object.fromEntries((state.snapshot?.ask.criteria ?? []).map((c) => [
293
+ c.name,
294
+ {
295
+ hits: ranked(scored(c.name, (d) => hitOf.get(d))),
296
+ pages: ranked(scored(c.name, (d) => d)),
297
+ },
298
+ ]));
299
+ const doubted = [...lastCheck].filter(([on]) => (yesOf(state, on, "backs") ?? 1) < DOUBT);
300
+ return {
301
+ judge,
302
+ calls: spends.length,
303
+ failed: spends.filter((s) => !s.ok).length,
304
+ usd: spends.reduce((a, s) => a + (s.usd ?? 0), 0),
305
+ hits: tally(hits),
306
+ classes: tally(classes),
307
+ checks: {
308
+ ...tally(checks),
309
+ doubted: doubted.length,
310
+ doubtedFailed: doubted.filter(([, ok]) => !ok).length,
311
+ },
312
+ worth: {
313
+ both: worth.length,
314
+ good: worth.filter(([, y]) => y).length,
315
+ auc: aucOf(worth),
316
+ rich: ranked(worthPairs).rich,
317
+ under: under.length,
318
+ underGood: under.filter(([, y]) => y).length,
319
+ },
320
+ criteria,
321
+ };
322
+ }
323
+ //# sourceMappingURL=judge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judge.js","sourceRoot":"","sources":["../../src/engine/judge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EAGN,IAAI,EAGJ,GAAG,GACJ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAIL,cAAc,GAEf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAiB,MAAM,YAAY,CAAC;AAGjD,qCAAqC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,sEAAsE;AACtE,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAC;AACzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC;AAC5B,gG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ACL,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM;QAC1C,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACvB,MAAM,EAAE;YACN,GAAG,KAAK,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,OAAO,CAAC,MAAM;YACvB,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM;SACtD;QACD,KAAK,EAAE;YACL,IAAI,EAAE,KAAK,CAAC,MAAM;YAClB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM;YACvC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI;YAC7B,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM;SAC7C;QACD,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { PersonRecord } from "../ledger/records.js";
2
+ import { type RunState } from "./state.js";
3
+ /** A URL as a prefix key: host without www, path without its trailing slash, lower case. */
4
+ export declare function profileKey(url: string): string | null;
5
+ /** The latest record per name (case folded). */
6
+ export declare function peopleOf(state: RunState): PersonRecord[];
7
+ /** Each document's person, by follow, URL prefix, then channel name. */
8
+ export declare function ownersOf(state: RunState): Map<string, PersonRecord>;
9
+ export interface PersonView {
10
+ id: string;
11
+ name: string;
12
+ profiles: string[];
13
+ aka: string[];
14
+ why: string;
15
+ documents: number;
16
+ /** Kept findings on their documents. */
17
+ kept: number;
18
+ /** Distinct sites their documents sit on. */
19
+ sites: number;
20
+ }
21
+ /** People, most kept findings first. */
22
+ export declare function peopleView(state: RunState): PersonView[];
23
+ export interface Unfollowed {
24
+ document: string;
25
+ url: string;
26
+ title?: string;
27
+ channel?: string;
28
+ kept: number;
29
+ }
30
+ /**
31
+ * Kept pages no follow started from and no person owns: whose author's other posts and pages
32
+ * like it are still unseen. Most kept findings first.
33
+ */
34
+ export declare function unfollowedOf(state: RunState): Unfollowed[];
@@ -0,0 +1,125 @@
1
+ /**
2
+ * People across platforms: signals cluster in people, so a good page points at its author's
3
+ * other posts and profiles. The agent writes a `person` (profiles, names); a document is theirs
4
+ * when a follow from one of their profiles found it, when its URL sits under a profile, or when
5
+ * its channel is one of their names. The brief counts kept findings per person and lists the
6
+ * kept pages whose author no follow and no person covers yet.
7
+ */
8
+ import { hostOf } from "../document/index.js";
9
+ import { kept } from "./state.js";
10
+ /** A URL as a prefix key: host without www, path without its trailing slash, lower case. */
11
+ export function profileKey(url) {
12
+ try {
13
+ const u = new URL(url);
14
+ const host = u.hostname.toLowerCase().replace(/^www\./, "");
15
+ return `${host}${u.pathname.replace(/\/+$/, "").toLowerCase()}`;
16
+ }
17
+ catch {
18
+ return null;
19
+ }
20
+ }
21
+ /** The latest record per name (case folded). */
22
+ export function peopleOf(state) {
23
+ const out = new Map();
24
+ for (const p of state.people)
25
+ out.set(p.name.toLowerCase(), p);
26
+ return [...out.values()];
27
+ }
28
+ /** A document's channel, else its hit's: a web opener knows none. */
29
+ function channelsOf(state) {
30
+ const hits = new Map(state.hits.map((h) => [h.id, h.channel]));
31
+ const out = new Map();
32
+ for (const d of state.documents) {
33
+ const c = d.channel ?? hits.get(d.hit);
34
+ if (c)
35
+ out.set(d.id, c);
36
+ }
37
+ return out;
38
+ }
39
+ /** Each document's person, by follow, URL prefix, then channel name. */
40
+ export function ownersOf(state) {
41
+ const people = peopleOf(state);
42
+ const keys = people.flatMap((p) => p.profiles.flatMap((u) => {
43
+ const k = profileKey(u);
44
+ return k ? [{ k, p }] : [];
45
+ }));
46
+ const channels = channelsOf(state);
47
+ const names = new Map(people.flatMap((p) => [p.name, ...p.aka].map((n) => [n.toLowerCase(), p])));
48
+ // A follow from a profile: its hits are the profile's posts.
49
+ const byQuery = new Map();
50
+ for (const q of state.queries) {
51
+ if (q.follow?.as !== "posts")
52
+ continue;
53
+ const k = profileKey(q.follow.url);
54
+ const fromDoc = q.follow.document
55
+ ? state.documents.find((d) => d.id === q.follow?.document)
56
+ : undefined;
57
+ const p = keys.find((x) => k && (k === x.k || k.startsWith(`${x.k}/`)))?.p ??
58
+ (fromDoc ? names.get(channels.get(fromDoc.id)?.toLowerCase() ?? "") : undefined);
59
+ if (p)
60
+ byQuery.set(q.id, p);
61
+ }
62
+ const queriesOfHit = new Map(state.hits.map((h) => [h.id, [...h.queries]]));
63
+ for (const f of state.founds)
64
+ queriesOfHit.get(f.hit)?.push(f.query);
65
+ const out = new Map();
66
+ for (const d of state.documents) {
67
+ const k = profileKey(d.url);
68
+ const p = (queriesOfHit.get(d.hit) ?? []).map((q) => byQuery.get(q)).find(Boolean) ??
69
+ keys.find((x) => k && (k === x.k || k.startsWith(`${x.k}/`)))?.p ??
70
+ names.get(channels.get(d.id)?.toLowerCase() ?? "");
71
+ if (p)
72
+ out.set(d.id, p);
73
+ }
74
+ return out;
75
+ }
76
+ /** People, most kept findings first. */
77
+ export function peopleView(state) {
78
+ const owners = ownersOf(state);
79
+ return peopleOf(state)
80
+ .map((p) => {
81
+ const docs = state.documents.filter((d) => owners.get(d.id) === p);
82
+ const ids = new Set(docs.map((d) => d.id));
83
+ return {
84
+ id: p.id,
85
+ name: p.name,
86
+ profiles: p.profiles,
87
+ aka: p.aka,
88
+ why: p.why,
89
+ documents: docs.length,
90
+ kept: state.findings.filter((f) => ids.has(f.document) && kept(state, f)).length,
91
+ sites: new Set(docs.map((d) => hostOf(d.url))).size,
92
+ };
93
+ })
94
+ .sort((a, b) => b.kept - a.kept || a.name.localeCompare(b.name));
95
+ }
96
+ /**
97
+ * Kept pages no follow started from and no person owns: whose author's other posts and pages
98
+ * like it are still unseen. Most kept findings first.
99
+ */
100
+ export function unfollowedOf(state) {
101
+ const owners = ownersOf(state);
102
+ const channels = channelsOf(state);
103
+ const followed = new Set(state.queries.flatMap((q) => q.follow ? [q.follow.document, profileKey(q.follow.url)].filter(Boolean) : []));
104
+ const keptOn = new Map();
105
+ for (const f of state.findings)
106
+ if (kept(state, f))
107
+ keptOn.set(f.document, (keptOn.get(f.document) ?? 0) + 1);
108
+ return state.documents
109
+ .filter((d) => {
110
+ const k = profileKey(d.url);
111
+ return (keptOn.get(d.id) && !owners.has(d.id) && !followed.has(d.id) && !(k && followed.has(k)));
112
+ })
113
+ .map((d) => {
114
+ const channel = channels.get(d.id);
115
+ return {
116
+ document: d.id,
117
+ url: d.url,
118
+ ...(d.title ? { title: d.title } : {}),
119
+ ...(channel ? { channel } : {}),
120
+ kept: keptOn.get(d.id) ?? 0,
121
+ };
122
+ })
123
+ .sort((a, b) => b.kept - a.kept);
124
+ }
125
+ //# sourceMappingURL=people.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"people.js","sourceRoot":"","sources":["../../src/engine/people.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAiB,MAAM,YAAY,CAAC;AAEjD,4FAA4F;AAC5F,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CA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 * model seam is `@wrenautomation/models`'. `From` and `Step` stay out: the ledger's are wider.
4
+ */
5
+ export { ageOf, defaultPlanFile, PLAN_KINDS, rulesOf, TREE, treeOf } from "./plans/index.js";
6
+ export { Ask, AskKind, Budget, Criterion, Edge, HitView, type HitViewIn, PlanFile, Query, QueryTree, Snapshot, TreeGuide, Verdict, YieldRow, } from "./types.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The names a host needs to drive the engine: the plan file, the ask, the records' shapes. The
3
+ * model seam is `@wrenautomation/models`'. `From` and `Step` stay out: the ledger's are wider.
4
+ */
5
+ export { ageOf, defaultPlanFile, PLAN_KINDS, rulesOf, TREE, treeOf } from "./plans/index.js";
6
+ export { Ask, AskKind, Budget, Criterion, Edge, HitView, PlanFile, Query, QueryTree, Snapshot, TreeGuide, Verdict, YieldRow, } from "./types.js";
7
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/engine/plan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EACL,GAAG,EACH,OAAO,EACP,MAAM,EACN,SAAS,EACT,IAAI,EACJ,OAAO,EAEP,QAAQ,EACR,KAAK,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,YAAY,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The default plan file per ask kind. A copy of one, tuned and stored beside a ledger, is how
3
+ * a run learns: the recipe changes, the agent reads it. `birdwatch plans <kind>` prints one to start from.
4
+ */
5
+ import { type AskKind, type PlanFile, type TreeGuide } from "../types.js";
6
+ /**
7
+ * The five sides a researcher covers before the reads start. One tree per round; the agent
8
+ * fills each facet with tries, in order of what it expects to work.
9
+ */
10
+ export declare const TREE: TreeGuide;
11
+ /** The default plan file for a kind, validated, as a fresh copy. */
12
+ export declare function defaultPlanFile(kind: AskKind): PlanFile;
13
+ /** The plan file's word on age; a stored file from before version 4 takes its kind's default. Version 5: the review no longer says "at most". Version 6: `tree`, the query tree's guide. 0.30.0 dropped the prompts with no bump: the agent never read them. */
14
+ export declare const ageOf: (planFile: PlanFile) => string | undefined;
15
+ /** The plan file's rules for the agent; a stored file from before 0.30.0 takes its kind's default. */
16
+ export declare const rulesOf: (planFile: PlanFile) => string[];
17
+ /** The plan file's guide for a query tree; a stored file from before version 6 takes its kind's default. */
18
+ export declare const treeOf: (planFile: PlanFile) => TreeGuide;
19
+ export declare const PLAN_KINDS: AskKind[];