evidence-mcp-dev 0.2.39 → 0.2.41
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/dist/index.js +22 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/stdout-guard.ts
|
|
4
|
+
var toStderr = (...args) => console.error(...args);
|
|
5
|
+
console.log = toStderr;
|
|
6
|
+
console.info = toStderr;
|
|
7
|
+
console.debug = toStderr;
|
|
8
|
+
|
|
3
9
|
// src/env.ts
|
|
4
10
|
import { existsSync, readFileSync } from "fs";
|
|
5
11
|
import { join, resolve } from "path";
|
|
@@ -976,7 +982,7 @@ function headingOf(line) {
|
|
|
976
982
|
return BY_SQUEEZED.get(squeeze(bare2)) ?? null;
|
|
977
983
|
}
|
|
978
984
|
async function pdfToMarkdown(bytes, title, headLine2, stats2) {
|
|
979
|
-
const pdf = await getDocumentProxy(new Uint8Array(bytes), { fontExtraProperties: true });
|
|
985
|
+
const pdf = await getDocumentProxy(new Uint8Array(bytes), { fontExtraProperties: true, verbosity: 0 });
|
|
980
986
|
const text4 = await extractPages(pdf);
|
|
981
987
|
if (stats2) {
|
|
982
988
|
stats2.pages = pdf.numPages;
|
|
@@ -2444,8 +2450,10 @@ async function download(tier, p, candidates, ctx) {
|
|
|
2444
2450
|
const c = ordered[i];
|
|
2445
2451
|
ctx.tried.add(c.url);
|
|
2446
2452
|
let link;
|
|
2453
|
+
let gone;
|
|
2447
2454
|
const note = (x) => {
|
|
2448
2455
|
if (!x.ok && x.pdfUrl) link ??= x.pdfUrl;
|
|
2456
|
+
if (!x.ok && !gone && /\bHTTP (404|410)\b/.test(x.reason)) gone = x.reason;
|
|
2449
2457
|
return x;
|
|
2450
2458
|
};
|
|
2451
2459
|
let r = note(await tryOne(p, c, tier));
|
|
@@ -2492,7 +2500,7 @@ async function download(tier, p, candidates, ctx) {
|
|
|
2492
2500
|
if (!r.ok && /^unlocker HTTP 4\d\d/.test(bare(r.reason))) ctx.onAlert?.(`brightdata: ${bare(r.reason)}`);
|
|
2493
2501
|
}
|
|
2494
2502
|
if (r.ok) return r;
|
|
2495
|
-
reasons.push(`${r.reason}: ${hostOf2(c.url)}`);
|
|
2503
|
+
reasons.push(`${gone ?? r.reason}: ${hostOf2(c.url)}`);
|
|
2496
2504
|
if (link && !ctx.tried.has(link) && !NCBI.test(link) && !ordered.slice(i + 1).some((o) => o.url === link)) {
|
|
2497
2505
|
ctx.onTry?.(`${target.url} \u2192 pdf ${link}`);
|
|
2498
2506
|
ordered.splice(i + 1, 0, { url: link, version: c.version, source: c.source, host: c.host, pdf: true });
|
|
@@ -3308,7 +3316,6 @@ function fragment(claim) {
|
|
|
3308
3316
|
const first = /^(\S+)/.exec(body)?.[1] ?? "";
|
|
3309
3317
|
const oddsRatio = first === "OR" && /^OR\s+(\d|=|\(|of\b|for\b)/.test(body);
|
|
3310
3318
|
if (!oddsRatio && /^(and|or|but|nor|which|whereas|while)$/i.test(first.replace(/[,;:]$/, ""))) return `claim is a fragment: starts with "${first}" \u2014 send a complete statement with its subject`;
|
|
3311
|
-
if (/^[a-z]/.test(body) && !/[A-Z0-9]/.test(first)) return `claim is a fragment: starts with "${first}" in lowercase \u2014 send a complete statement with its subject`;
|
|
3312
3319
|
return null;
|
|
3313
3320
|
}
|
|
3314
3321
|
var SUPERSEDED = "The corrected text replaces figures that the paper first published wrongly. Does the statement give a figure for a quantity the corrected text also gives, but with a different value \u2014 the superseded, uncorrected figure? If the statement's figures match the corrected text, or it concerns something the corrected text does not cover, answer false.";
|
|
@@ -4100,6 +4107,12 @@ async function rung(url, via) {
|
|
|
4100
4107
|
var climb = async (url, onTry, onAlert) => {
|
|
4101
4108
|
let r = await rung(url, "fetch");
|
|
4102
4109
|
const firstReason = r.ok ? void 0 : r.reason;
|
|
4110
|
+
let gone;
|
|
4111
|
+
const seen = (g) => {
|
|
4112
|
+
if (!g.ok) gone ??= goneReason(g.reason);
|
|
4113
|
+
return g;
|
|
4114
|
+
};
|
|
4115
|
+
seen(r);
|
|
4103
4116
|
const target = !r.ok && r.url && r.url !== url ? r.url : url;
|
|
4104
4117
|
if (target !== url) onTry?.(`\u2192 ${target}`);
|
|
4105
4118
|
onTry?.(r.ok ? "ok fetch" : `failed fetch: ${r.reason}`);
|
|
@@ -4113,7 +4126,7 @@ var climb = async (url, onTry, onAlert) => {
|
|
|
4113
4126
|
const w = walled(target, name);
|
|
4114
4127
|
if (w) onTry?.(`skipped ${name}: ${wallNote(w)}`);
|
|
4115
4128
|
else {
|
|
4116
|
-
r = await rung(target, { proxy: f.proxy, label: f.label });
|
|
4129
|
+
r = seen(await rung(target, { proxy: f.proxy, label: f.label }));
|
|
4117
4130
|
recordRung(target, name, r.ok, r.ok ? "" : r.reason);
|
|
4118
4131
|
if (!r.ok && r.shell && !shell) shell = r.shell;
|
|
4119
4132
|
onTry?.(r.ok ? `ok ${name}` : `failed ${name}: ${r.reason}`);
|
|
@@ -4127,7 +4140,7 @@ var climb = async (url, onTry, onAlert) => {
|
|
|
4127
4140
|
onTry?.(`skipped ${name}: ${wallNote(w)}`);
|
|
4128
4141
|
continue;
|
|
4129
4142
|
}
|
|
4130
|
-
r = await rung(target, { browser: b.endpoint, label: b.label });
|
|
4143
|
+
r = seen(await rung(target, { browser: b.endpoint, label: b.label }));
|
|
4131
4144
|
recordRung(target, name, r.ok, r.ok ? "" : r.reason);
|
|
4132
4145
|
if (!r.ok && r.shell && !shell) shell = r.shell;
|
|
4133
4146
|
onTry?.(r.ok ? `ok ${name}` : `failed ${name}: ${r.reason}`);
|
|
@@ -4136,7 +4149,7 @@ var climb = async (url, onTry, onAlert) => {
|
|
|
4136
4149
|
const uw = !r.ok && unlockerConfigured() ? walled(target, "brightdata") : null;
|
|
4137
4150
|
if (uw) onTry?.(`skipped brightdata: ${wallNote(uw)}`);
|
|
4138
4151
|
else if (!r.ok && unlockerConfigured() && (!plainVia(r) || met(r, /^(HTTP 403|wall page|script shell)/))) {
|
|
4139
|
-
r = await rung(target, "brightdata");
|
|
4152
|
+
r = seen(await rung(target, "brightdata"));
|
|
4140
4153
|
recordRung(target, "brightdata", r.ok, r.ok ? "" : r.reason);
|
|
4141
4154
|
onTry?.(r.ok ? "ok brightdata" : `failed brightdata: ${r.reason}`);
|
|
4142
4155
|
if (!r.ok && /^unlocker HTTP 4\d\d/.test(r.reason)) onAlert?.(`brightdata: ${r.reason}`);
|
|
@@ -4145,8 +4158,10 @@ var climb = async (url, onTry, onAlert) => {
|
|
|
4145
4158
|
onTry?.("shell kept: no rung rendered the page, the script shell is served");
|
|
4146
4159
|
return shell;
|
|
4147
4160
|
}
|
|
4148
|
-
return r.ok || r.via === "fetch" ? r : { ...r, first: firstReason };
|
|
4161
|
+
return r.ok || r.via === "fetch" ? r : { ...r, first: gone ?? firstReason };
|
|
4149
4162
|
};
|
|
4163
|
+
var GONE = /\bHTTP (404|410)\b/;
|
|
4164
|
+
var goneReason = (reason) => reason.match(GONE)?.[0];
|
|
4150
4165
|
var mediaType = (contentType) => contentType.split(";")[0].trim().toLowerCase();
|
|
4151
4166
|
function isHtml(contentType, text4) {
|
|
4152
4167
|
const ct = contentType.toLowerCase();
|