evidence-mcp-dev 1.0.2 → 1.0.4
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 +20 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -124,7 +124,7 @@ async function firstOk(tasks, decisive = () => null) {
|
|
|
124
124
|
if (done) return;
|
|
125
125
|
const gone = r.ok ? null : decisive(r);
|
|
126
126
|
if (r.ok) end(r, `${task.name} won`);
|
|
127
|
-
else if (gone) end(null, `${task.name}
|
|
127
|
+
else if (gone) end(null, `${task.name} had ${gone}`);
|
|
128
128
|
else if (--left === 0) {
|
|
129
129
|
done = true;
|
|
130
130
|
resolve4({ won: null, results: results2 });
|
|
@@ -5086,10 +5086,6 @@ async function searchTrials(raw, libraryDir = FH_EVIDENCE_DIR, fetchImpl = liveF
|
|
|
5086
5086
|
}
|
|
5087
5087
|
return { ok: true, result, cached: false };
|
|
5088
5088
|
}
|
|
5089
|
-
function trialsLogId(q) {
|
|
5090
|
-
const s = (q.intervention ?? q.condition ?? q.query ?? "").replace(/\s+/g, "_");
|
|
5091
|
-
return s.length > 10 ? s.slice(0, 9) + "\u2026" : s || "-";
|
|
5092
|
-
}
|
|
5093
5089
|
|
|
5094
5090
|
// src/pubmedsearch.ts
|
|
5095
5091
|
import { createHash as createHash5 } from "crypto";
|
|
@@ -5163,12 +5159,14 @@ function parseEsummary(json2, ids, libraryDir) {
|
|
|
5163
5159
|
const first = String(s.sortfirstauthor ?? (Array.isArray(s.authors) && s.authors[0]?.name) ?? "").replace(/\s+[A-Z]{1,3}$/, "").trim() || null;
|
|
5164
5160
|
const pmc2 = (Array.isArray(s.articleids) ? s.articleids : []).find((a) => a.idtype === "pmc")?.value ?? null;
|
|
5165
5161
|
const types = Array.isArray(s.pubtype) ? reviewTypes(s.pubtype.map(String)).join("; ") : "";
|
|
5166
|
-
|
|
5167
|
-
const level = entryExists(paths) ? String(readStatus(paths, emptyStatus(`pmid:${id}`, "pmid", id, libraryDir)).level) : null;
|
|
5168
|
-
rows.push([id, String(s.title ?? "").replace(/\.$/, "") || null, first, year, s.source ? String(s.source) : null, types || null, pmc2 ? String(pmc2) : null, level]);
|
|
5162
|
+
rows.push([id, String(s.title ?? "").replace(/\.$/, "") || null, first, year, s.source ? String(s.source) : null, types || null, pmc2 ? String(pmc2) : null, levelOf(id, libraryDir)]);
|
|
5169
5163
|
}
|
|
5170
5164
|
return rows;
|
|
5171
5165
|
}
|
|
5166
|
+
function levelOf(id, libraryDir) {
|
|
5167
|
+
const paths = entryPaths(libraryDir, "pmid", id);
|
|
5168
|
+
return entryExists(paths) ? String(readStatus(paths, emptyStatus(`pmid:${id}`, "pmid", id, libraryDir)).level) : null;
|
|
5169
|
+
}
|
|
5172
5170
|
var live = (url) => fetchText(url, { "User-Agent": "evidence-mcp", Accept: "application/json" });
|
|
5173
5171
|
async function searchArticles(raw, libraryDir = FH_EVIDENCE_DIR, fetchImpl = live) {
|
|
5174
5172
|
const q = normalizeQuery2(raw);
|
|
@@ -5177,7 +5175,11 @@ async function searchArticles(raw, libraryDir = FH_EVIDENCE_DIR, fetchImpl = liv
|
|
|
5177
5175
|
if (existsSync12(file3)) {
|
|
5178
5176
|
try {
|
|
5179
5177
|
const r = JSON.parse(readFileSync10(file3, "utf8"));
|
|
5180
|
-
if (daysSince(r.searched) < searchCacheDays()) return { ok: true, result: r,
|
|
5178
|
+
if (daysSince(r.searched) < searchCacheDays()) return { ok: true, result: { ...r, rows: r.rows.map((row3) => {
|
|
5179
|
+
const c = [...row3];
|
|
5180
|
+
c[7] = levelOf(String(row3[0]), libraryDir);
|
|
5181
|
+
return c;
|
|
5182
|
+
}) }, cached: true };
|
|
5181
5183
|
} catch {
|
|
5182
5184
|
}
|
|
5183
5185
|
}
|
|
@@ -5203,10 +5205,6 @@ async function searchArticles(raw, libraryDir = FH_EVIDENCE_DIR, fetchImpl = liv
|
|
|
5203
5205
|
}
|
|
5204
5206
|
return { ok: true, result, cached: false };
|
|
5205
5207
|
}
|
|
5206
|
-
function logId2(q) {
|
|
5207
|
-
const s = q.query.replace(/\s+/g, "_");
|
|
5208
|
-
return s.length > 10 ? s.slice(0, 9) + "\u2026" : s;
|
|
5209
|
-
}
|
|
5210
5208
|
|
|
5211
5209
|
// src/trialrecord.ts
|
|
5212
5210
|
var list4 = (a) => Array.isArray(a) ? a : [];
|
|
@@ -5914,7 +5912,7 @@ ${st.funding.map((f) => `- ${f}`).join("\n")}` : ""].filter(Boolean).join("\n\n"
|
|
|
5914
5912
|
const { cached, ...r } = await verifyCached(claim, id, cfg, cfg ? decider(cfg) : null, FH_EVIDENCE_DIR);
|
|
5915
5913
|
if (!r.error && r.score !== null) bump("verify", cached);
|
|
5916
5914
|
const secs = `${((Date.now() - t0) / 1e3).toFixed(1).padStart(4, "0")}s`;
|
|
5917
|
-
log("verify", r.id, r.error ? `${modelFailure(r.error, cfg) ? "!! " : ""}${secs} ${"error".padEnd(20)} ${r.error} | ${claim}` : `${cached ? "" :
|
|
5915
|
+
log("verify", r.id, r.error ? `${modelFailure(r.error, cfg) ? "!! " : ""}${secs} ${"error".padEnd(20)} ${r.error} | ${claim}` : `${cached ? "cached" : secs} verdict=${r.verdict.padEnd(12)} basis=${r.basis.padEnd(9)} score=${r.score === null ? "- " : r.score.toFixed(3)}${r.windows > 1 ? ` windows=${r.windows}` : ""}${r.superseded ? " superseded" : ""}${r.glyphs_unresolved ? ` glyphs=${r.glyphs_unresolved}` : ""} | ${claim}`);
|
|
5918
5916
|
return { content: [{ type: "text", text: verdictAnswer(r) }] };
|
|
5919
5917
|
}
|
|
5920
5918
|
);
|
|
@@ -5989,7 +5987,7 @@ ${st.funding.map((f) => `- ${f}`).join("\n")}` : ""].filter(Boolean).join("\n\n"
|
|
|
5989
5987
|
const text4 = title_only ? `Contents of ${url}:
|
|
5990
5988
|
${(md.split("\n").find((l) => l.trim()) ?? "").trim()}` : fetchAnswer(url, md, "", max_length, start_index);
|
|
5991
5989
|
bump("fetch", had);
|
|
5992
|
-
put(`library ${rid}
|
|
5990
|
+
put(`library ${rid} chars=${text4.length}${title_only ? " title" : maxLog}${start_index ? ` start=${start_index}` : ""} ${had ? "cached" : "added"}`);
|
|
5993
5991
|
return { content: [{ type: "text", text: text4 }] };
|
|
5994
5992
|
}
|
|
5995
5993
|
const r = await libraryFetch(FH_EVIDENCE_DIR, url, { max_length, start_index, raw, title_only }, `${pkg.name} ${pkg.version}`, {
|
|
@@ -5999,10 +5997,11 @@ ${(md.split("\n").find((l) => l.trim()) ?? "").trim()}` : fetchAnswer(url, md, "
|
|
|
5999
5997
|
const secs = ((Date.now() - t0) / 1e3).toFixed(1).padStart(4, "0") + "s";
|
|
6000
5998
|
if (r.meta) bump("fetch", r.cached);
|
|
6001
5999
|
if (r.ok) {
|
|
6002
|
-
put(
|
|
6000
|
+
put(`ok ${r.cached ? "cached" : secs} ${r.meta.format} retrieved_by=${r.meta.retrieved_by} fetched=${r.meta.fetched} chars=${r.text.length}${raw ? " raw" : ""}${title_only ? " title" : maxLog}${start_index ? ` start=${start_index}` : ""}`);
|
|
6003
6001
|
return { content: [{ type: "text", text: r.text }] };
|
|
6004
6002
|
}
|
|
6005
|
-
|
|
6003
|
+
const why = r.error.replace(url, "<url>").replace(/^Failed to fetch <url> - status code (\d+)$/, "HTTP $1").replace(/^Failed to fetch <url>: /, "");
|
|
6004
|
+
put(`failed ${r.cached ? "cached" : secs}: ${why}`);
|
|
6006
6005
|
return { content: [{ type: "text", text: r.error }], isError: true };
|
|
6007
6006
|
}
|
|
6008
6007
|
);
|
|
@@ -6034,12 +6033,12 @@ ${(md.split("\n").find((l) => l.trim()) ?? "").trim()}` : fetchAnswer(url, md, "
|
|
|
6034
6033
|
const r = await searchArticles(args, FH_EVIDENCE_DIR);
|
|
6035
6034
|
const secs = ((Date.now() - t0) / 1e3).toFixed(1).padStart(4, "0") + "s";
|
|
6036
6035
|
if (!r.ok) {
|
|
6037
|
-
log("search", "
|
|
6036
|
+
log("search", "pubmed", `error: ${r.error}`);
|
|
6038
6037
|
return { content: [{ type: "text", text: compact2({ error: r.error }) }], isError: true };
|
|
6039
6038
|
}
|
|
6040
6039
|
bump("search", r.cached);
|
|
6041
6040
|
const q = r.result.query;
|
|
6042
|
-
log("search", `
|
|
6041
|
+
log("search", "pubmed", `ok ${r.cached ? "cached" : secs} rows=${r.result.rows.length} total=${r.result.total}${q.sort !== "relevance" ? ` sort=${q.sort}` : ""}${q.years ? ` years=${q.years}` : ""} | ${q.query}`);
|
|
6043
6042
|
return { content: [{ type: "text", text: searchAnswer(r.result) }] };
|
|
6044
6043
|
}
|
|
6045
6044
|
);
|
|
@@ -6059,12 +6058,12 @@ ${(md.split("\n").find((l) => l.trim()) ?? "").trim()}` : fetchAnswer(url, md, "
|
|
|
6059
6058
|
const r = await searchTrials(args, FH_EVIDENCE_DIR);
|
|
6060
6059
|
const secs = ((Date.now() - t0) / 1e3).toFixed(1).padStart(4, "0") + "s";
|
|
6061
6060
|
if (!r.ok) {
|
|
6062
|
-
log("search", "
|
|
6061
|
+
log("search", "nct", `error: ${r.error}`);
|
|
6063
6062
|
return { content: [{ type: "text", text: compact2({ error: r.error }) }], isError: true };
|
|
6064
6063
|
}
|
|
6065
6064
|
bump("search", r.cached);
|
|
6066
6065
|
const q = r.result.query, parts = [q.intervention && `intervention=${q.intervention}`, q.condition && `condition=${q.condition}`, q.query && `query=${q.query}`].filter(Boolean).join(" ");
|
|
6067
|
-
log("search", `
|
|
6066
|
+
log("search", "nct", `ok ${r.cached ? "cached" : secs} rows=${r.result.rows.length} total=${r.result.total} status=${q.status}${q.sort !== "relevance" ? ` sort=${q.sort}` : ""} | ${parts}`);
|
|
6068
6067
|
return { content: [{ type: "text", text: searchAnswer(r.result) }] };
|
|
6069
6068
|
}
|
|
6070
6069
|
);
|