@framers/agentos-ext-citation-check 0.0.0-stage → 0.1.1

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 (48) hide show
  1. package/LICENSE +98 -0
  2. package/README.md +167 -2
  3. package/dist/bin.d.ts +10 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +11 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/cli.d.ts +36 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +145 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/embeddings.d.ts +54 -0
  12. package/dist/embeddings.d.ts.map +1 -0
  13. package/dist/embeddings.js +52 -0
  14. package/dist/embeddings.js.map +1 -0
  15. package/dist/index.d.ts +55 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +63 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/match.d.ts +44 -0
  20. package/dist/match.d.ts.map +1 -0
  21. package/dist/match.js +108 -0
  22. package/dist/match.js.map +1 -0
  23. package/dist/page.d.ts +105 -0
  24. package/dist/page.d.ts.map +1 -0
  25. package/dist/page.js +400 -0
  26. package/dist/page.js.map +1 -0
  27. package/dist/parse.d.ts +36 -0
  28. package/dist/parse.d.ts.map +1 -0
  29. package/dist/parse.js +314 -0
  30. package/dist/parse.js.map +1 -0
  31. package/dist/report.d.ts +28 -0
  32. package/dist/report.d.ts.map +1 -0
  33. package/dist/report.js +128 -0
  34. package/dist/report.js.map +1 -0
  35. package/dist/runner.d.ts +89 -0
  36. package/dist/runner.d.ts.map +1 -0
  37. package/dist/runner.js +298 -0
  38. package/dist/runner.js.map +1 -0
  39. package/dist/tools/citationVerify.d.ts +59 -0
  40. package/dist/tools/citationVerify.d.ts.map +1 -0
  41. package/dist/tools/citationVerify.js +98 -0
  42. package/dist/tools/citationVerify.js.map +1 -0
  43. package/dist/types.d.ts +150 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +20 -0
  46. package/dist/types.js.map +1 -0
  47. package/manifest.json +66 -0
  48. package/package.json +79 -3
package/dist/runner.js ADDED
@@ -0,0 +1,298 @@
1
+ /**
2
+ * @file runner.ts
3
+ * @description The check itself. Each distinct page a document cites is read once, a few at a time. Classical first:
4
+ * a claim whose words stand on its page is `exact`, with the sentence they stand in. A claim that is not is graded by
5
+ * AgentOS's `CitationVerifier` against the page's sentences when the caller gives an embedding function (an NLI
6
+ * function, when given too, turning a `supported` claim the page contradicts into `contradicted`), and is `not_found`
7
+ * otherwise, with the sentences nearest it by shared words. Nothing that costs money is called unless the caller
8
+ * passes it in; no search service is called at all.
9
+ *
10
+ * @module agentos/extensions/research/citation-check/runner
11
+ */
12
+ import { sentenceSpans } from '@framers/agentos-ext-grounding-guard/values';
13
+ import { WebScraperService } from '@framers/agentos-ext-web-scraper';
14
+ import { lexicalNearest, locateQuote, normalizeForMatch, quoteFragments } from './match.js';
15
+ import { egressTransport, fetchTransport, originOf, pageKey, readPage } from './page.js';
16
+ import { CitationInputError, parseCitedClaims } from './parse.js';
17
+ import { CITATION_VERDICTS } from './types.js';
18
+ /** Settings the check cannot run with. */
19
+ export class CitationSetupError extends Error {
20
+ /** @param message - What is wrong. */
21
+ constructor(message) {
22
+ super(message);
23
+ this.name = 'CitationSetupError';
24
+ }
25
+ }
26
+ /** A whole number of at least `least`, or the default when left out. */
27
+ function whole(name, value, fallback, least) {
28
+ if (value === undefined)
29
+ return fallback;
30
+ if (!Number.isInteger(value) || value < least)
31
+ throw new CitationSetupError(`${name} must be a whole number of at least ${least}`);
32
+ return value;
33
+ }
34
+ /** The options' numbers with their defaults, refused when out of range. */
35
+ function settingsOf(options) {
36
+ if (options.fetch !== undefined && options.egress !== undefined)
37
+ throw new CitationSetupError('pass fetch or egress, not both');
38
+ if (options.egress !== undefined && options.egress !== 'hosted' && options.egress !== 'local')
39
+ throw new CitationSetupError('egress must be hosted or local');
40
+ for (const [name, value] of [['supportThreshold', options.supportThreshold], ['unverifiableThreshold', options.unverifiableThreshold]]) {
41
+ if (value !== undefined && !(value >= 0 && value <= 1))
42
+ throw new CitationSetupError(`${name} must be between 0 and 1`);
43
+ }
44
+ return {
45
+ timeoutMs: whole('timeoutMs', options.timeoutMs, 15_000, 1),
46
+ maxBytes: whole('maxBytes', options.maxBytes, 5_000_000, 1),
47
+ textBudget: whole('textBudget', options.textBudget, 300_000, 1),
48
+ concurrency: whole('concurrency', options.concurrency, 4, 1),
49
+ maxPages: whole('maxPages', options.maxPages, 100, 1),
50
+ maxPassages: whole('maxPassages', options.maxPassages, 2_000, 1),
51
+ nearest: whole('nearest', options.nearest, 3, 0),
52
+ now: options.now ?? Date.now,
53
+ };
54
+ }
55
+ /** The request the pages go through. */
56
+ async function transportOf(options, settings) {
57
+ if (options.egress !== undefined)
58
+ return egressTransport(options.egress, { timeoutMs: settings.timeoutMs, maxBytes: settings.maxBytes }, options.userAgent);
59
+ return fetchTransport(options.fetch ?? ((input, init) => globalThis.fetch(input, init)), options.userAgent);
60
+ }
61
+ /** The fallback scraper, or null for none. */
62
+ function scraperOf(options) {
63
+ const fallback = options.fallback ?? (options.fetch === undefined && options.egress === undefined);
64
+ if (fallback === false)
65
+ return null;
66
+ if (fallback === true)
67
+ return new WebScraperService();
68
+ return fallback;
69
+ }
70
+ /** Runs `work` over the items, at most `limit` at once, the answers in the items' order. */
71
+ async function eachLimited(items, limit, work) {
72
+ const out = new Array(items.length);
73
+ let next = 0;
74
+ const lane = async () => {
75
+ while (next < items.length) {
76
+ const index = next;
77
+ next += 1;
78
+ out[index] = await work(items[index]);
79
+ }
80
+ };
81
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, lane));
82
+ return out;
83
+ }
84
+ /** A check with its verdict and its page's status, and nothing else filled in. */
85
+ function bare(claim, verdict, page) {
86
+ return { line: claim.line, claim: claim.claim, url: claim.url, exact: claim.exact, verdict, grader: null, score: null, passage: null, nearest: [], note: null, page };
87
+ }
88
+ /** The page's blocks read with `normalizeForMatch` and joined by spaces, with each block's start and end. */
89
+ function matchTextOf(blocks) {
90
+ let text = '';
91
+ const starts = [];
92
+ const ends = [];
93
+ for (const block of blocks) {
94
+ if (text !== '')
95
+ text += ' ';
96
+ starts.push(text.length);
97
+ text += normalizeForMatch(block);
98
+ ends.push(text.length);
99
+ }
100
+ return { text, starts, ends };
101
+ }
102
+ /** The longest a passage a report shows runs, in characters. */
103
+ const PASSAGE_MAX = 600;
104
+ /** A passage held to {@link PASSAGE_MAX} characters. */
105
+ function clip(text) {
106
+ return text.length <= PASSAGE_MAX ? text : `${text.slice(0, PASSAGE_MAX - 1).trimEnd()}…`;
107
+ }
108
+ /** The sentence of a block that holds all of a quotation's pieces, or the block when no one sentence does. */
109
+ function passageIn(block, fragments) {
110
+ for (const { start, end } of sentenceSpans(block)) {
111
+ const sentence = block.slice(start, end);
112
+ if (locateQuote(normalizeForMatch(sentence), fragments) !== null)
113
+ return clip(sentence);
114
+ }
115
+ return clip(block);
116
+ }
117
+ /**
118
+ * The sentence a claim's words stand in on the page, or their block when they run past one sentence; null when they do
119
+ * not stand there. A quotation with gaps stands only where all its pieces stand in one block (a paragraph, a list item,
120
+ * a table cell, a caption or a quotation), so a sentence of one paragraph and a cell further down the page never make
121
+ * one quotation; a quotation without gaps may run on from one block into the next, as across a line break.
122
+ */
123
+ function exactPassage(claim, page, match) {
124
+ const fragments = quoteFragments(claim);
125
+ if (fragments.length > 1) {
126
+ for (const [index, block] of page.blocks.entries()) {
127
+ const text = match.text.slice(match.starts[index] ?? 0, match.ends[index] ?? 0);
128
+ if (locateQuote(text, fragments) !== null)
129
+ return passageIn(block, fragments);
130
+ }
131
+ return null;
132
+ }
133
+ const span = locateQuote(match.text, fragments);
134
+ if (span === null)
135
+ return null;
136
+ let index = match.starts.length - 1;
137
+ while (index > 0 && (match.starts[index] ?? 0) > span.start)
138
+ index -= 1;
139
+ return passageIn(page.blocks[index] ?? '', fragments);
140
+ }
141
+ /** The first line of an error's message, held to 200 characters. */
142
+ function reasonOf(error) {
143
+ const message = error instanceof Error ? error.message : String(error);
144
+ return (message.split('\n')[0] ?? '').slice(0, 200);
145
+ }
146
+ /** The `not_found` verdict with the nearest sentences. */
147
+ function lexical(claim, page, count, note) {
148
+ const nearest = lexicalNearest(claim.claim, page.passages.map((passage) => passage.content), count);
149
+ return { ...bare(claim, 'not_found', page.status), grader: 'lexical', score: nearest[0]?.score ?? 0, passage: nearest[0]?.text ?? null, nearest, note };
150
+ }
151
+ /** Grades one page's claims that are not on it word for word through AgentOS's `CitationVerifier`. */
152
+ async function graded(claims, page, options, embedFn, settings) {
153
+ const sources = page.passages.slice(0, settings.maxPassages);
154
+ const { CitationVerifier } = await import('@framers/agentos/cognition/rag/citation/index');
155
+ const verifier = new CitationVerifier({
156
+ embedFn,
157
+ ...(options.supportThreshold !== undefined ? { supportThreshold: options.supportThreshold } : {}),
158
+ ...(options.unverifiableThreshold !== undefined ? { unverifiableThreshold: options.unverifiableThreshold } : {}),
159
+ ...(options.nliFn !== undefined ? { nliFn: options.nliFn } : {}),
160
+ });
161
+ const result = await verifier.verify(claims.map((claim) => claim.claim), sources);
162
+ return claims.map((claim, index) => {
163
+ const verdict = result.claims[index];
164
+ if (verdict === undefined)
165
+ throw new Error('the citation verifier answered fewer verdicts than claims');
166
+ const source = verdict.sourceIndex === undefined ? undefined : sources[verdict.sourceIndex];
167
+ return { ...bare(claim, verdict.verdict, page.status), grader: 'embedding', score: verdict.confidence, passage: source === undefined ? null : clip(source.content) };
168
+ });
169
+ }
170
+ /**
171
+ * Checks each cited claim against the page it cites, and reports the verdicts, the pages and a summary.
172
+ *
173
+ * @param claims - The claims, as {@link parseCitedClaims} gives them.
174
+ * @param options - How to run; see {@link CitationCheckOptions}.
175
+ * @returns The report: one check per claim in the claims' order, one status per distinct page.
176
+ * @throws {CitationInputError} For a claim whose address is not http or https, or more distinct pages than `maxPages`.
177
+ * @throws {CitationSetupError} For options out of range, or `egress` with an AgentOS that has no checked egress.
178
+ * @throws The caller's cancellation reason, when `signal` aborts.
179
+ */
180
+ export async function checkCitations(claims, options = {}) {
181
+ const settings = settingsOf(options);
182
+ const checkedAt = new Date(settings.now()).toISOString();
183
+ const keys = claims.map((claim) => {
184
+ if (claim.url === null)
185
+ return null;
186
+ try {
187
+ const url = new URL(claim.url);
188
+ if (url.protocol === 'http:' || url.protocol === 'https:')
189
+ return pageKey(claim.url);
190
+ }
191
+ catch {
192
+ // Refused below.
193
+ }
194
+ throw new CitationInputError(`line ${claim.line}: ${JSON.stringify(claim.url)} is not an http or https address`);
195
+ });
196
+ const distinct = [...new Set(keys.filter((key) => key !== null))];
197
+ if (distinct.length > settings.maxPages) {
198
+ throw new CitationInputError(`the document cites ${distinct.length} distinct pages; one check reads at most ${settings.maxPages}`);
199
+ }
200
+ options.signal?.throwIfAborted();
201
+ let transport;
202
+ try {
203
+ transport = await transportOf(options, settings);
204
+ }
205
+ catch (error) {
206
+ throw new CitationSetupError(reasonOf(error));
207
+ }
208
+ const scraper = distinct.length > 0 ? scraperOf(options) : null;
209
+ const read = await eachLimited(distinct, settings.concurrency, (url) => readPage(url, {
210
+ transport,
211
+ scraper,
212
+ timeoutMs: settings.timeoutMs,
213
+ maxBytes: settings.maxBytes,
214
+ textBudget: settings.textBudget,
215
+ now: settings.now,
216
+ ...(options.signal ? { signal: options.signal } : {}),
217
+ ...(options.logger ? { logger: options.logger } : {}),
218
+ }));
219
+ const pages = new Map(distinct.map((url, index) => [url, read[index]]));
220
+ const checks = claims.map((claim) => bare(claim, 'uncited', null));
221
+ const waiting = new Map();
222
+ claims.forEach((claim, index) => {
223
+ const key = keys[index];
224
+ if (key === null || key === undefined)
225
+ return;
226
+ const page = pages.get(key);
227
+ if (page.status.outcome !== 'read') {
228
+ checks[index] = bare(claim, page.status.outcome, page.status);
229
+ return;
230
+ }
231
+ waiting.set(key, [...(waiting.get(key) ?? []), index]);
232
+ });
233
+ for (const [key, indexes] of waiting) {
234
+ const page = pages.get(key);
235
+ const match = matchTextOf(page.blocks);
236
+ const rest = [];
237
+ for (const index of indexes) {
238
+ const claim = claims[index];
239
+ const passage = exactPassage(claim.claim, page, match);
240
+ if (passage === null)
241
+ rest.push(index);
242
+ else
243
+ checks[index] = { ...bare(claim, 'exact', page.status), grader: 'exact', score: 1, passage };
244
+ }
245
+ if (rest.length === 0)
246
+ continue;
247
+ const embedFn = options.embedFn;
248
+ if (embedFn !== undefined) {
249
+ const restClaims = rest.map((index) => claims[index]);
250
+ try {
251
+ const verdicts = await graded(restClaims, page, options, embedFn, settings);
252
+ rest.forEach((index, at) => {
253
+ checks[index] = verdicts[at];
254
+ });
255
+ continue;
256
+ }
257
+ catch (error) {
258
+ if (options.signal?.aborted)
259
+ throw options.signal.reason;
260
+ const reason = reasonOf(error);
261
+ options.logger?.warn('citation_check.embedding_failed', { origin: originOf(key), claims: rest.length, error: reason });
262
+ for (const index of rest)
263
+ checks[index] = lexical(claims[index], page, settings.nearest, `embedding grader failed: ${reason}`);
264
+ continue;
265
+ }
266
+ }
267
+ for (const index of rest)
268
+ checks[index] = lexical(claims[index], page, settings.nearest, null);
269
+ }
270
+ const statuses = distinct.map((url) => pages.get(url).status);
271
+ const counts = Object.fromEntries(CITATION_VERDICTS.map((verdict) => [verdict, 0]));
272
+ for (const check of checks)
273
+ counts[check.verdict] += 1;
274
+ return {
275
+ checkedAt,
276
+ grading: options.embedFn === undefined ? 'lexical' : 'embedding',
277
+ checks,
278
+ pages: statuses,
279
+ summary: {
280
+ claims: checks.length,
281
+ pages: statuses.length,
282
+ counts,
283
+ uncited: checks.filter((check) => check.verdict === 'uncited').map((check) => ({ line: check.line, claim: check.claim })),
284
+ unreachable: statuses.filter((status) => status.outcome !== 'read'),
285
+ },
286
+ };
287
+ }
288
+ /**
289
+ * Parses a document's cited claims and checks them: {@link parseCitedClaims}, then {@link checkCitations}.
290
+ *
291
+ * @param text - Markdown, or a JSON array of claims.
292
+ * @param options - The check's options, and `format` for the parser.
293
+ */
294
+ export async function checkCitationDocument(text, options = {}) {
295
+ const { format, ...check } = options;
296
+ return checkCitations(parseCitedClaims(text, { format: format ?? 'auto' }), check);
297
+ }
298
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAuE,MAAM,WAAW,CAAC;AAC9J,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAyB,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAkJ,MAAM,YAAY,CAAC;AAoD/L,0CAA0C;AAC1C,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,sCAAsC;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAcD,wEAAwE;AACxE,SAAS,KAAK,CAAC,IAAY,EAAE,KAAyB,EAAE,QAAgB,EAAE,KAAa;IACrF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,KAAK;QAAE,MAAM,IAAI,kBAAkB,CAAC,GAAG,IAAI,uCAAuC,KAAK,EAAE,CAAC,CAAC;IACnI,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2EAA2E;AAC3E,SAAS,UAAU,CAAC,OAA6B;IAC/C,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IA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,MAAM,KAAK,IAAI,MAAM;QAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO;QACL,SAAS;QACT,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW;QAChE,MAAM;QACN,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE;YACP,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,QAAQ,CAAC,MAAM;YACtB,MAAM;YACN,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YACzH,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC;SACpE;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAAY,EAAE,UAAgE,EAAE;IAC1H,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACrC,OAAO,cAAc,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @file citationVerify.ts
3
+ * @description The `citation_verify` tool: an agent passes a document and gets back the report, the markdown log and
4
+ * whether the check fails. Unless the host passes its own `fetch` or another egress policy, the tool reads pages
5
+ * through AgentOS's checked egress with the hosted policy, so a document cannot point it at a private address.
6
+ *
7
+ * @module agentos/extensions/research/citation-check/tools/citationVerify
8
+ */
9
+ import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
10
+ import type { CitedClaimFormat } from '../parse.js';
11
+ import { type CitationCheckOptions } from '../runner.js';
12
+ import type { CitationReport } from '../types.js';
13
+ /** What an agent passes the tool. */
14
+ export interface CitationVerifyInput {
15
+ /** Markdown whose quoted claims are each followed by their address, or a JSON array of `{ claim, url, exact }`. */
16
+ document: string;
17
+ /** `auto` (the default), `markdown` or `json`. */
18
+ format?: CitedClaimFormat;
19
+ /** Count a claim whose page could not be fetched or read as no failure. */
20
+ allowUnreachable?: boolean;
21
+ }
22
+ /** What the tool answers. */
23
+ export interface CitationVerifyOutput {
24
+ /** Whether the check fails (see `citationReportFails`). */
25
+ fails: boolean;
26
+ /** The markdown for a document's "Citation check log" section. */
27
+ log: string;
28
+ /** The verdicts, the pages and the summary. */
29
+ report: CitationReport;
30
+ }
31
+ /** Checks each quoted claim of a document against the page its address names. */
32
+ export declare class CitationVerifyTool implements ITool<CitationVerifyInput, CitationVerifyOutput> {
33
+ /** The tool's identifier, with its version. */
34
+ readonly id = "citation-verify-v1";
35
+ /** The name an agent calls the tool by. */
36
+ readonly name = "citation_verify";
37
+ /** The name a person sees. */
38
+ readonly displayName = "Citation check";
39
+ /** What the tool does, for the model that chooses it. */
40
+ readonly description = "Checks each quoted claim in a document against the page its address names: whether its words stand on the page, and, when an embedding model is configured, how closely the page supports it. Each page is fetched once; no search service is called. Pass markdown in which each quotation is followed by its source address, such as \"the quoted words\" (https://example.org/page), or a JSON array of {\"claim\", \"url\", \"exact\"}.";
41
+ /** The category the tool is listed under. */
42
+ readonly category = "research";
43
+ /** False: the tool reads pages and changes nothing. */
44
+ readonly hasSideEffects = false;
45
+ /** The arguments: the document, how to read it, and whether a page not read fails the check. */
46
+ readonly inputSchema: JSONSchemaObject;
47
+ private readonly options;
48
+ /**
49
+ * @param options - The check's options. With neither `fetch` nor `egress`, pages are read through AgentOS's checked
50
+ * egress with the hosted policy (from AgentOS 0.13.120).
51
+ */
52
+ constructor(options?: CitationCheckOptions);
53
+ /**
54
+ * Checks the document. A document the parser cannot read, arguments of the wrong type and settings the check cannot
55
+ * run with answer `success: false` with the reason; a page that fails is a verdict in the report.
56
+ */
57
+ execute(args: CitationVerifyInput, context?: ToolExecutionContext): Promise<ToolExecutionResult<CitationVerifyOutput>>;
58
+ }
59
+ //# sourceMappingURL=citationVerify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"citationVerify.d.ts","sourceRoot":"","sources":["../../src/tools/citationVerify.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAyB,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,qCAAqC;AACrC,MAAM,WAAW,mBAAmB;IAClC,mHAAmH;IACnH,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,6BAA6B;AAC7B,MAAM,WAAW,oBAAoB;IACnC,2DAA2D;IAC3D,KAAK,EAAE,OAAO,CAAC;IACf,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,MAAM,EAAE,cAAc,CAAC;CACxB;AAaD,iFAAiF;AACjF,qBAAa,kBAAmB,YAAW,KAAK,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;IACzF,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,wBAAwB;IACnC,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,qBAAqB;IAClC,8BAA8B;IAC9B,QAAQ,CAAC,WAAW,oBAAoB;IACxC,yDAAyD;IACzD,QAAQ,CAAC,WAAW,ibACoZ;IACxa,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,cAAc;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,cAAc,SAAS;IAChC,gGAAgG;IAChG,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAuBpC;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAE/C;;;OAGG;gBACS,OAAO,GAAE,oBAAyB;IAI9C;;;OAGG;IACG,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;CAgB7H"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @file citationVerify.ts
3
+ * @description The `citation_verify` tool: an agent passes a document and gets back the report, the markdown log and
4
+ * whether the check fails. Unless the host passes its own `fetch` or another egress policy, the tool reads pages
5
+ * through AgentOS's checked egress with the hosted policy, so a document cannot point it at a private address.
6
+ *
7
+ * @module agentos/extensions/research/citation-check/tools/citationVerify
8
+ */
9
+ import { citationReportFails, renderCitationLog } from '../report.js';
10
+ import { checkCitationDocument } from '../runner.js';
11
+ /** The longest document the tool takes, in characters. */
12
+ const DOCUMENT_MAX = 1_000_000;
13
+ /** Why the arguments cannot be used, or null when they can. */
14
+ function argumentProblem(args) {
15
+ if (args === null || typeof args !== 'object')
16
+ return 'the arguments must be an object with a document';
17
+ const { document, format, allowUnreachable } = args;
18
+ if (typeof document !== 'string' || document.trim() === '')
19
+ return 'document must be a string that is not empty';
20
+ if (document.length > DOCUMENT_MAX)
21
+ return `document must be at most ${DOCUMENT_MAX} characters`;
22
+ if (format !== undefined && format !== 'auto' && format !== 'markdown' && format !== 'json')
23
+ return 'format must be auto, markdown or json';
24
+ if (allowUnreachable !== undefined && typeof allowUnreachable !== 'boolean')
25
+ return 'allowUnreachable must be true or false';
26
+ return null;
27
+ }
28
+ /** Checks each quoted claim of a document against the page its address names. */
29
+ export class CitationVerifyTool {
30
+ /** The tool's identifier, with its version. */
31
+ id = 'citation-verify-v1';
32
+ /** The name an agent calls the tool by. */
33
+ name = 'citation_verify';
34
+ /** The name a person sees. */
35
+ displayName = 'Citation check';
36
+ /** What the tool does, for the model that chooses it. */
37
+ description = 'Checks each quoted claim in a document against the page its address names: whether its words stand on the page, and, when an embedding model is configured, how closely the page supports it. Each page is fetched once; no search service is called. Pass markdown in which each quotation is followed by its source address, such as "the quoted words" (https://example.org/page), or a JSON array of {"claim", "url", "exact"}.';
38
+ /** The category the tool is listed under. */
39
+ category = 'research';
40
+ /** False: the tool reads pages and changes nothing. */
41
+ hasSideEffects = false;
42
+ /** The arguments: the document, how to read it, and whether a page not read fails the check. */
43
+ inputSchema = {
44
+ type: 'object',
45
+ required: ['document'],
46
+ properties: {
47
+ document: {
48
+ type: 'string',
49
+ minLength: 1,
50
+ maxLength: DOCUMENT_MAX,
51
+ description: 'Markdown whose quoted claims are each followed by their source address, or a JSON array of {"claim", "url", "exact"}.',
52
+ },
53
+ format: {
54
+ type: 'string',
55
+ enum: ['auto', 'markdown', 'json'],
56
+ default: 'auto',
57
+ description: 'How to read the document: auto reads a JSON array as JSON and anything else as markdown.',
58
+ },
59
+ allowUnreachable: {
60
+ type: 'boolean',
61
+ default: false,
62
+ description: 'Count a claim whose page could not be fetched or read as no failure.',
63
+ },
64
+ },
65
+ additionalProperties: false,
66
+ };
67
+ options;
68
+ /**
69
+ * @param options - The check's options. With neither `fetch` nor `egress`, pages are read through AgentOS's checked
70
+ * egress with the hosted policy (from AgentOS 0.13.120).
71
+ */
72
+ constructor(options = {}) {
73
+ this.options = options.fetch !== undefined || options.egress !== undefined ? { ...options } : { ...options, egress: 'hosted' };
74
+ }
75
+ /**
76
+ * Checks the document. A document the parser cannot read, arguments of the wrong type and settings the check cannot
77
+ * run with answer `success: false` with the reason; a page that fails is a verdict in the report.
78
+ */
79
+ async execute(args, context) {
80
+ const problem = argumentProblem(args);
81
+ if (problem !== null)
82
+ return { success: false, error: problem };
83
+ // The call's cancellation, when this AgentOS passes one in the context; the options' own otherwise.
84
+ const signal = context?.signal ?? this.options.signal;
85
+ try {
86
+ const report = await checkCitationDocument(args.document, { ...this.options, ...(signal ? { signal } : {}), format: args.format ?? 'auto' });
87
+ const allowUnreachable = args.allowUnreachable === true;
88
+ return {
89
+ success: true,
90
+ output: { fails: citationReportFails(report, { allowUnreachable }), log: renderCitationLog(report, { allowUnreachable }), report },
91
+ };
92
+ }
93
+ catch (error) {
94
+ return { success: false, error: error instanceof Error ? error.message : String(error) };
95
+ }
96
+ }
97
+ }
98
+ //# sourceMappingURL=citationVerify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"citationVerify.js","sourceRoot":"","sources":["../../src/tools/citationVerify.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAA6B,MAAM,cAAc,CAAC;AAGhF,0DAA0D;AAC1D,MAAM,YAAY,GAAG,SAAS,CAAC;AAsB/B,+DAA+D;AAC/D,SAAS,eAAe,CAAC,IAAa;IACpC,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,iDAAiD,CAAC;IACxG,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAA+B,CAAC;IAC/E,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,6CAA6C,CAAC;IACjH,IAAI,QAAQ,CAAC,MAAM,GAAG,YAAY;QAAE,OAAO,4BAA4B,YAAY,aAAa,CAAC;IACjG,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,UAA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 @@
1
+ /**
2
+ * @file types.ts
3
+ * @description What the citation check reads and writes: a cited claim as the parser finds it, the verdict on it with
4
+ * the passage it rests on, how each page fared, and the report with its summary.
5
+ *
6
+ * @module agentos/extensions/research/citation-check/types
7
+ */
8
+ import type { ClaimVerdictKind } from '@framers/agentos';
9
+ /** A claim and the address it cites, as a document gives them. */
10
+ export interface CitedClaim {
11
+ /** The line of the document the claim starts on, counted from 1. */
12
+ line: number;
13
+ /** The claim: the quoted words, or a JSON entry's `claim`, white space collapsed. */
14
+ claim: string;
15
+ /** The address it cites, as written; null when it cites none. */
16
+ url: string | null;
17
+ /** Whether the claim gives itself as the page's own words: true for a quotation, a JSON entry's `exact` otherwise. */
18
+ exact: boolean;
19
+ }
20
+ /**
21
+ * The verdict on one claim:
22
+ * - `exact`: its words stand on the page, read with typographic quotes, dashes, case and white space set aside, the
23
+ * pieces of a quotation with gaps all in one block of it;
24
+ * - `supported`, `weak`, `unverifiable`, `contradicted`: AgentOS's `CitationVerifier` graded a claim whose words do not
25
+ * stand on the page against the page's sentences, through the embedding function given;
26
+ * - `not_found`: its words do not stand on the page and no embedding function graded it;
27
+ * - `unreachable`: the page could not be fetched;
28
+ * - `unreadable`: the page came but holds no text this check reads (a PDF, another binary, a page past the size cap, a
29
+ * page with no text);
30
+ * - `uncited`: the claim cites no address.
31
+ */
32
+ export type CitationVerdict = 'exact' | ClaimVerdictKind | 'not_found' | 'unreachable' | 'unreadable' | 'uncited';
33
+ /** Every verdict, in the order a summary lists them. */
34
+ export declare const CITATION_VERDICTS: readonly CitationVerdict[];
35
+ /** How a verdict was reached: the words on the page, AgentOS's `CitationVerifier`, or shared words alone. */
36
+ export type CitationGrader = 'exact' | 'embedding' | 'lexical';
37
+ /** A sentence of a page and how near it is to a claim. */
38
+ export interface CitationPassage {
39
+ /** The sentence as the page shows it, white space collapsed. */
40
+ text: string;
41
+ /** The share of content words and numbers the sentence and the claim have in common (Jaccard), from 0 to 1. */
42
+ score: number;
43
+ }
44
+ /** The verdict on one claim, with the passage it rests on. */
45
+ export interface CitationCheck {
46
+ /** The claim's line in the document. */
47
+ line: number;
48
+ /** The claim, as parsed. */
49
+ claim: string;
50
+ /** The address it cites, as written; null for an uncited claim. */
51
+ url: string | null;
52
+ /** Whether the claim gives itself as the page's own words (see {@link CitedClaim.exact}). */
53
+ exact: boolean;
54
+ /** The verdict on the claim; see {@link CitationVerdict}. */
55
+ verdict: CitationVerdict;
56
+ /** How the verdict was reached; null for an unreachable, unreadable or uncited claim. */
57
+ grader: CitationGrader | null;
58
+ /**
59
+ * 1 for `exact`; the cosine similarity of the best passage for an embedding verdict; the {@link CitationPassage.score}
60
+ * of the nearest passage for `not_found`, 0 when no passage shares a word; null otherwise.
61
+ */
62
+ score: number | null;
63
+ /**
64
+ * The sentence the verdict rests on: where the words stand (their block when they run past one sentence), the passage
65
+ * graded best, or the nearest one; null when none.
66
+ */
67
+ passage: string | null;
68
+ /** For `not_found`, the passages nearest the claim by shared words, nearest first; empty otherwise. */
69
+ nearest: CitationPassage[];
70
+ /** Why an embedding function that was given did not grade the claim, when it failed; null otherwise. */
71
+ note: string | null;
72
+ /**
73
+ * The status of the page the claim cites (whether its text was read, its HTTP status, why it was not read), the
74
+ * same as its entry in {@link CitationReport.pages}; null for an uncited claim.
75
+ */
76
+ page: PageStatus | null;
77
+ }
78
+ /**
79
+ * Why a page was not read. A page is unreachable for `timeout` (no answer by the deadline), `network` (no connection,
80
+ * or a name that does not resolve), `status` (an answer that is not 2xx), `refused` (the egress policy refused the
81
+ * address) or `redirects` (too many redirects); it is unreadable for `too_large` (past the size cap), `pdf`, `binary`
82
+ * (another type that is not text) or `no_text` (no text a reader sees).
83
+ */
84
+ export type PageFailure = 'timeout' | 'network' | 'status' | 'refused' | 'redirects' | 'too_large' | 'pdf' | 'binary' | 'no_text';
85
+ /** How one page fared. */
86
+ export interface PageStatus {
87
+ /** The address fetched: a claim's address without its fragment. */
88
+ url: string;
89
+ /** Whether its text was read, or why not. */
90
+ outcome: 'read' | 'unreachable' | 'unreadable';
91
+ /** The address the answer came from, after redirects; null when no answer came. */
92
+ finalUrl: string | null;
93
+ /** The answer's HTTP status; null when none came. */
94
+ status: number | null;
95
+ /** Why it was not read; null when it was. */
96
+ failure: PageFailure | null;
97
+ /** More about the failure: the content type of a binary answer, the egress policy's reason; null otherwise. */
98
+ detail: string | null;
99
+ /** How its text was read: the plain request, or the web scraper's fallback; null when it was not read. */
100
+ via: 'fetch' | 'fallback' | null;
101
+ /** How many sentences it gave. */
102
+ passages: number;
103
+ }
104
+ /** The counts and the lists a reader needs first. */
105
+ export interface CitationSummary {
106
+ /** How many claims were checked. */
107
+ claims: number;
108
+ /** How many distinct pages were fetched. */
109
+ pages: number;
110
+ /** How many claims have each verdict; every verdict is present. */
111
+ counts: Record<CitationVerdict, number>;
112
+ /** The claims that cite no address. */
113
+ uncited: Array<{
114
+ line: number;
115
+ claim: string;
116
+ }>;
117
+ /** The pages that were not read: unreachable or unreadable. */
118
+ unreachable: PageStatus[];
119
+ }
120
+ /** What a check found. */
121
+ export interface CitationReport {
122
+ /** When the check started, as an ISO 8601 time. */
123
+ checkedAt: string;
124
+ /** `embedding` when an embedding function was given, `lexical` otherwise. */
125
+ grading: 'lexical' | 'embedding';
126
+ /** One verdict for each claim, in the document's order. */
127
+ checks: CitationCheck[];
128
+ /** One status for each distinct page, in the order the claims first cite them. */
129
+ pages: PageStatus[];
130
+ /** The count of each verdict, the uncited claims and the pages that were not read. */
131
+ summary: CitationSummary;
132
+ }
133
+ /**
134
+ * The structured logger the check writes its events to: AgentOS's `ILogger`, such as its `PinoLogger`, or any logger
135
+ * with the same methods. Each event is a name and its fields; a page appears by its origin alone, a claim never.
136
+ */
137
+ export interface CitationLogger {
138
+ info(message: string, meta?: Record<string, unknown>): void;
139
+ warn(message: string, meta?: Record<string, unknown>): void;
140
+ error(message: string, meta?: Record<string, unknown>): void;
141
+ debug?(message: string, meta?: Record<string, unknown>): void;
142
+ }
143
+ /** A batch embedding function: texts in, one vector each, in order (`CitationVerifierConfig.embedFn`). */
144
+ export type EmbedFn = (texts: string[]) => Promise<number[][]>;
145
+ /** A natural language inference function, premise first (`CitationVerifierConfig.nliFn`). */
146
+ export type NliFn = (premise: string, hypothesis: string) => Promise<{
147
+ label: 'entailment' | 'contradiction' | 'neutral';
148
+ score: number;
149
+ }>;
150
+ //# sourceMappingURL=types.d.ts.map