@cyanheads/biorxiv-mcp-server 0.4.1 → 0.4.3
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/AGENTS.md +5 -4
- package/CLAUDE.md +5 -4
- package/Dockerfile +3 -3
- package/README.md +10 -7
- package/changelog/0.4.x/0.4.2.md +34 -0
- package/changelog/0.4.x/0.4.3.md +27 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts +2 -2
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js +9 -6
- package/dist/mcp-server/tools/definitions/biorxiv-get-fulltext.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts +4 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js +9 -5
- package/dist/mcp-server/tools/definitions/biorxiv-get-preprint.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts +19 -8
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js +51 -18
- package/dist/mcp-server/tools/definitions/biorxiv-get-published-version.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-published-versions.tool.d.ts +13 -0
- package/dist/mcp-server/tools/definitions/biorxiv-list-published-versions.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-published-versions.tool.js +70 -12
- package/dist/mcp-server/tools/definitions/biorxiv-list-published-versions.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts +5 -2
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js +22 -17
- package/dist/mcp-server/tools/definitions/biorxiv-list-recent.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts +10 -5
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js +23 -17
- package/dist/mcp-server/tools/definitions/biorxiv-search-preprints.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +27 -12
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.d.ts +31 -21
- package/dist/services/biorxiv/biorxiv-service.d.ts.map +1 -1
- package/dist/services/biorxiv/biorxiv-service.js +90 -39
- package/dist/services/biorxiv/biorxiv-service.js.map +1 -1
- package/dist/services/biorxiv/types.d.ts +29 -3
- package/dist/services/biorxiv/types.d.ts.map +1 -1
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts +5 -3
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.d.ts.map +1 -1
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js +311 -14
- package/dist/services/biorxiv-fulltext/biorxiv-fulltext-service.js.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.d.ts +21 -5
- package/dist/services/europe-pmc/europe-pmc-service.d.ts.map +1 -1
- package/dist/services/europe-pmc/europe-pmc-service.js +111 -25
- package/dist/services/europe-pmc/europe-pmc-service.js.map +1 -1
- package/dist/services/shared.d.ts +52 -16
- package/dist/services/shared.d.ts.map +1 -1
- package/dist/services/shared.js +121 -22
- package/dist/services/shared.js.map +1 -1
- package/dist/services/upstream-text-tables.d.ts +11 -1
- package/dist/services/upstream-text-tables.d.ts.map +1 -1
- package/dist/services/upstream-text-tables.js +42 -1
- package/dist/services/upstream-text-tables.js.map +1 -1
- package/package.json +9 -9
- package/server.json +3 -3
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
* Detects HTML error pages, retries an HTTP 200 body that carries no result
|
|
11
11
|
* list, and classifies an origin rate limit (HTTP 429) as its own retryable
|
|
12
12
|
* `rate_limited` condition carrying the parsed `Retry-After` wait — never the
|
|
13
|
-
* upstream response body.
|
|
13
|
+
* upstream response body. A cursor page that fails every attempt the way a
|
|
14
|
+
* malformed `cursorMark` does is told apart from an outage by one request for
|
|
15
|
+
* the same query's first page.
|
|
14
16
|
* @module services/europe-pmc/europe-pmc-service
|
|
15
17
|
*/
|
|
16
18
|
import { McpError, rateLimited, serviceUnavailable, validationError, } from '@cyanheads/mcp-ts-core/errors';
|
|
17
19
|
import { fetchWithTimeout } from '@cyanheads/mcp-ts-core/utils';
|
|
18
20
|
import { getServerConfig } from '../../config/server-config.js';
|
|
19
|
-
import { describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSeconds, retryWithinBudget, SERVER_VERSION, } from '../shared.js';
|
|
21
|
+
import { describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSeconds, remainingBudgetMs, retryWithinBudget, SERVER_VERSION, } from '../shared.js';
|
|
20
22
|
/**
|
|
21
23
|
* The one status this service classifies itself rather than treating as a bug.
|
|
22
24
|
* Passing it to `fetchWithTimeout` only lowers the log severity from `error` to
|
|
@@ -25,25 +27,62 @@ import { describeWait, detectHtmlError, normalizeUpstreamText, parseRetryAfterSe
|
|
|
25
27
|
const EXPECTED_STATUSES = [429];
|
|
26
28
|
/**
|
|
27
29
|
* `data.reason` on the error thrown for an HTTP 200 body with no `resultList`.
|
|
28
|
-
* EuropePMC answers some requests with only `{"version":"6.9"}
|
|
29
|
-
* for a valid first page or cursor page
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* EuropePMC answers some requests with only `{"version":"6.9"}`, intermittently
|
|
31
|
+
* for a valid first page or cursor page. Read as data, the body becomes a
|
|
32
|
+
* zero-result page, so it is thrown as a transient `ServiceUnavailable` inside
|
|
33
|
+
* `withRetry` instead.
|
|
32
34
|
*/
|
|
33
35
|
const EMPTY_BODY_REASON = 'empty_response_body';
|
|
36
|
+
/**
|
|
37
|
+
* How one failed attempt reads if a malformed `cursorMark` caused it — HTTP 503
|
|
38
|
+
* or the empty body — or `undefined` for a failure no malformed token produces.
|
|
39
|
+
*/
|
|
40
|
+
function tokenFailure(err) {
|
|
41
|
+
if (!(err instanceof McpError))
|
|
42
|
+
return;
|
|
43
|
+
const data = err.data;
|
|
44
|
+
if (data?.reason === EMPTY_BODY_REASON)
|
|
45
|
+
return 'came back with no result list';
|
|
46
|
+
if (data?.status === 503)
|
|
47
|
+
return 'failed with HTTP 503';
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The `invalid_cursor_mark` error a cursor page's failure becomes if the token
|
|
52
|
+
* is to blame, or `undefined` when the failure is not one a malformed token
|
|
53
|
+
* produces. EuropePMC answers a `cursorMark` it does not recognize on every
|
|
54
|
+
* attempt — with its generic outage answer, HTTP 503, and earlier with the
|
|
55
|
+
* empty body — so only a ladder that ran every attempt and failed each one of
|
|
56
|
+
* those two ways qualifies; `answers` holds how they failed, and is `undefined`
|
|
57
|
+
* once any attempt failed some other way. Only the same query's first page
|
|
58
|
+
* answering (see `EuropePmcService.firstPageAnswers`) then settles that the
|
|
59
|
+
* token was at fault. A ladder the budget cut short ends on
|
|
60
|
+
* `retry_deadline_exceeded` and no `status`, so it never qualifies: the
|
|
61
|
+
* attempts that did not run might have answered.
|
|
62
|
+
*
|
|
63
|
+
* The message is written here rather than kept from the exhausted error, whose
|
|
64
|
+
* `(failed after N attempts)` suffix would reach the caller inside the tool's
|
|
65
|
+
* message; the count is in `data.retryAttempts`.
|
|
66
|
+
*/
|
|
67
|
+
function asInvalidCursorMark(err, cursorMark, answers) {
|
|
68
|
+
if (!answers || !tokenFailure(err))
|
|
69
|
+
return;
|
|
70
|
+
const { retryAttempts } = err.data;
|
|
71
|
+
if (typeof retryAttempts !== 'number')
|
|
72
|
+
return;
|
|
73
|
+
return validationError(`EuropePMC did not recognize the supplied cursor_mark — ${retryAttempts} consecutive attempts ${[...answers].join(' or ')}, while the first page of the same query answered.`, { reason: 'invalid_cursor_mark', cursor_mark: cursorMark, retryAttempts }, { cause: err });
|
|
74
|
+
}
|
|
34
75
|
/**
|
|
35
76
|
* Re-throws a failed EuropePMC call with the two conditions this service
|
|
36
77
|
* classifies itself:
|
|
37
78
|
*
|
|
38
|
-
* - an empty body that outlasted every retry
|
|
39
|
-
* page was requested (`invalid_cursor_mark`), an upstream failure on a first
|
|
40
|
-
* page, which has no caller input to blame;
|
|
79
|
+
* - an empty body that outlasted every retry, as an upstream failure;
|
|
41
80
|
* - HTTP 429, as its own retryable `rate_limited` condition.
|
|
42
81
|
*
|
|
43
82
|
* Everything else — 5xx, timeout, network error, the HTML-error guard below —
|
|
44
83
|
* re-throws untouched for the framework's auto-classifier.
|
|
45
84
|
*
|
|
46
|
-
* The empty-body
|
|
85
|
+
* The empty-body error is built fresh rather than re-thrown: `withRetry`
|
|
47
86
|
* suffixes an exhausted error's message with `(failed after N attempts)`, and
|
|
48
87
|
* that wording would otherwise reach the caller inside the tool's message. The
|
|
49
88
|
* attempt count moves to `data.retryAttempts`.
|
|
@@ -55,7 +94,7 @@ const EMPTY_BODY_REASON = 'empty_response_body';
|
|
|
55
94
|
* and fails fast when the requested wait exceeds its cap, so by the time a 429
|
|
56
95
|
* reaches here the waiting is over and only classification is left.
|
|
57
96
|
*/
|
|
58
|
-
function rethrowClassified(err
|
|
97
|
+
function rethrowClassified(err) {
|
|
59
98
|
const data = err instanceof McpError
|
|
60
99
|
? err.data
|
|
61
100
|
: undefined;
|
|
@@ -63,11 +102,7 @@ function rethrowClassified(err, cursorMark) {
|
|
|
63
102
|
// Always set: the empty body is transient, so it only escapes `withRetry`
|
|
64
103
|
// exhausted, and exhaustion is what attaches the count.
|
|
65
104
|
const retryAttempts = data.retryAttempts;
|
|
66
|
-
|
|
67
|
-
if (cursorMark !== '*') {
|
|
68
|
-
throw validationError(`EuropePMC did not recognize the supplied cursor_mark — ${tries} came back with no result list.`, { reason: 'invalid_cursor_mark', cursor_mark: cursorMark, retryAttempts }, { cause: err });
|
|
69
|
-
}
|
|
70
|
-
throw serviceUnavailable(`EuropePMC answered ${tries} with HTTP 200 and no result list.`, { reason: EMPTY_BODY_REASON, retryAttempts }, { cause: err });
|
|
105
|
+
throw serviceUnavailable(`EuropePMC answered ${retryAttempts} consecutive attempts with HTTP 200 and no result list.`, { reason: EMPTY_BODY_REASON, retryAttempts }, { cause: err });
|
|
71
106
|
}
|
|
72
107
|
// A 429 the budget ran out after arrives here in place of the expiry.
|
|
73
108
|
if (data?.status !== 429)
|
|
@@ -102,10 +137,15 @@ export class EuropePmcService {
|
|
|
102
137
|
* firstPublicationDate), which carries no abstract — see `getAbstracts`.
|
|
103
138
|
* Throws a retryable `rate_limited` error when the origin returns HTTP 429.
|
|
104
139
|
* A body with no result list is retried; if every attempt returns one, throws
|
|
105
|
-
* `
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
140
|
+
* `ServiceUnavailable` (`empty_response_body`).
|
|
141
|
+
*
|
|
142
|
+
* On a cursor page other than `*`, a ladder that every attempt failed with
|
|
143
|
+
* HTTP 503 or the empty body sends one more request, unretried: the same
|
|
144
|
+
* query's first page. When that answers, throws `ValidationError`
|
|
145
|
+
* (`invalid_cursor_mark`) — four requests plus one; otherwise the ladder's
|
|
146
|
+
* own failure. A deadline that runs out first is a `Timeout` expiry either
|
|
147
|
+
* way: fewer attempts than the full ladder do not establish that the cursor
|
|
148
|
+
* is at fault.
|
|
109
149
|
*/
|
|
110
150
|
async search(options, deadline, ctx) {
|
|
111
151
|
const limit = Math.min(options.limit ?? 25, 100);
|
|
@@ -151,8 +191,20 @@ export class EuropePmcService {
|
|
|
151
191
|
format: 'json',
|
|
152
192
|
});
|
|
153
193
|
const url = `${this.baseUrl}/search?${params.toString()}&filter=${filterParam}`;
|
|
194
|
+
// How each attempt failed, while every one failed the way a malformed token
|
|
195
|
+
// does; cleared for good by any other failure, so a ladder that merely ended
|
|
196
|
+
// on an HTTP 503 or the empty body is never checked against the first page.
|
|
197
|
+
let tokenAnswers = new Set();
|
|
198
|
+
const observed = (attempt) => (a) => attempt(a).catch((err) => {
|
|
199
|
+
const answer = tokenFailure(err);
|
|
200
|
+
if (answer)
|
|
201
|
+
tokenAnswers?.add(answer);
|
|
202
|
+
else
|
|
203
|
+
tokenAnswers = undefined;
|
|
204
|
+
throw err;
|
|
205
|
+
});
|
|
154
206
|
try {
|
|
155
|
-
return await retryWithinBudget(async ({ signal, remainingMs }) => {
|
|
207
|
+
return await retryWithinBudget(observed(async ({ signal, remainingMs }) => {
|
|
156
208
|
const response = await fetchWithTimeout(url, Math.min(20_000, remainingMs), ctx, {
|
|
157
209
|
signal,
|
|
158
210
|
headers: { 'User-Agent': this.userAgent },
|
|
@@ -187,7 +239,7 @@ export class EuropePmcService {
|
|
|
187
239
|
// callers read "no field" as "no more pages".
|
|
188
240
|
...(data.nextCursorMark && { nextCursorMark: data.nextCursorMark }),
|
|
189
241
|
};
|
|
190
|
-
}, {
|
|
242
|
+
}), {
|
|
191
243
|
operation: 'EuropePmcService.search',
|
|
192
244
|
context: ctx,
|
|
193
245
|
baseDelayMs: 300,
|
|
@@ -196,7 +248,42 @@ export class EuropePmcService {
|
|
|
196
248
|
});
|
|
197
249
|
}
|
|
198
250
|
catch (err) {
|
|
199
|
-
|
|
251
|
+
const invalidCursor = cursorMark === '*' ? undefined : asInvalidCursorMark(err, cursorMark, tokenAnswers);
|
|
252
|
+
if (invalidCursor) {
|
|
253
|
+
params.set('cursorMark', '*');
|
|
254
|
+
params.set('pageSize', '1');
|
|
255
|
+
const firstPageUrl = `${this.baseUrl}/search?${params.toString()}&filter=${filterParam}`;
|
|
256
|
+
if (await this.firstPageAnswers(firstPageUrl, deadline, ctx))
|
|
257
|
+
throw invalidCursor;
|
|
258
|
+
}
|
|
259
|
+
rethrowClassified(err);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Whether EuropePMC answers a first-page search right now: one request, never
|
|
264
|
+
* retried, timed out at 20 s or what is left of the call's budget, and not
|
|
265
|
+
* sent at all once that budget is spent. A miss of any kind — a status, the
|
|
266
|
+
* empty body, a page that is not JSON, a network error, the timeout — is
|
|
267
|
+
* `false`; retrying would only add requests against an origin that may be in
|
|
268
|
+
* outage. A caller cancellation is re-thrown, never read as a miss.
|
|
269
|
+
*/
|
|
270
|
+
async firstPageAnswers(url, deadline, ctx) {
|
|
271
|
+
const budgetMs = remainingBudgetMs(deadline);
|
|
272
|
+
if (budgetMs === 0)
|
|
273
|
+
return false;
|
|
274
|
+
try {
|
|
275
|
+
const response = await fetchWithTimeout(url, Math.min(20_000, budgetMs), ctx, {
|
|
276
|
+
signal: ctx.signal,
|
|
277
|
+
headers: { 'User-Agent': this.userAgent },
|
|
278
|
+
expectedStatuses: EXPECTED_STATUSES,
|
|
279
|
+
});
|
|
280
|
+
const data = JSON.parse(await response.text());
|
|
281
|
+
return data?.resultList != null;
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (ctx.signal.aborted)
|
|
285
|
+
throw err;
|
|
286
|
+
return false;
|
|
200
287
|
}
|
|
201
288
|
}
|
|
202
289
|
/**
|
|
@@ -254,8 +341,7 @@ export class EuropePmcService {
|
|
|
254
341
|
});
|
|
255
342
|
}
|
|
256
343
|
catch (err) {
|
|
257
|
-
|
|
258
|
-
rethrowClassified(err, '*');
|
|
344
|
+
rethrowClassified(err);
|
|
259
345
|
}
|
|
260
346
|
}
|
|
261
347
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-pmc-service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"europe-pmc-service.js","sourceRoot":"","sources":["../../../src/services/europe-pmc/europe-p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BAAqB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;oBACzD,IAAI,GAAG,IAAI,QAAQ,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;wBAAE,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAC3E,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC,EACD;gBACE,SAAS,EAAE,+BAA+B;gBAC1C,OAAO,EAAE,GAAG;gBACZ,WAAW,EAAE,GAAG;gBAChB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,QAAQ;aACT,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAEhF,IAAI,QAAsC,CAAC;AAE3C,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,OAAuB;IAC7E,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* upstream-text normalization, the Markdown escaper every `format()` applies
|
|
5
5
|
* to upstream text, `Retry-After` parsing and rate-limit rejection lookup
|
|
6
6
|
* shared by every fetch path, the per-tool-call time budget every upstream
|
|
7
|
-
* request draws on (with the retry ladder that runs inside it
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* request draws on (with the retry ladder that runs inside it, backs off on a
|
|
8
|
+
* 429 whose `Retry-After` names no usable wait, and keeps an origin's 429 as
|
|
9
|
+
* its answer when the budget runs out), the per-server DOI fan-out that settles
|
|
10
|
+
* on the server holding the DOI, and the server version string used in
|
|
11
|
+
* User-Agent headers across all services.
|
|
10
12
|
* @module services/shared
|
|
11
13
|
*/
|
|
12
14
|
import { type RetryAttempt, type RetryOptions } from '@cyanheads/mcp-ts-core/utils';
|
|
@@ -24,6 +26,14 @@ export declare function detectHtmlError(text: string): boolean;
|
|
|
24
26
|
* without a prior regex gate.
|
|
25
27
|
*/
|
|
26
28
|
export declare function isValidCalendarDate(dateStr: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The DOI prefixes bioRxiv and medRxiv issue preprint DOIs under — both servers
|
|
31
|
+
* share both, so a prefix never names the server. Cold Spring Harbor
|
|
32
|
+
* Laboratory Press also registers its journal articles under `10.1101/`
|
|
33
|
+
* (`10.1101/gr.…`, `gad.…`, `lm.…`), so a DOI here is a preprint DOI or one of
|
|
34
|
+
* those; any other DOI is a journal article's.
|
|
35
|
+
*/
|
|
36
|
+
export declare const BIORXIV_DOI_PREFIXES: readonly ['10.1101/', '10.64898/'];
|
|
27
37
|
/** A preprint DOI reduced to its bare form, plus the revision a version suffix named. */
|
|
28
38
|
export interface NormalizedDoi {
|
|
29
39
|
/** Bare DOI, e.g. `10.64898/2026.03.11.711201`. */
|
|
@@ -32,7 +42,7 @@ export interface NormalizedDoi {
|
|
|
32
42
|
version?: string;
|
|
33
43
|
}
|
|
34
44
|
/**
|
|
35
|
-
* Reduce a pasted preprint reference to its bare DOI. Accepts the bare DOI
|
|
45
|
+
* Reduce a pasted preprint or journal reference to its bare DOI. Accepts the bare DOI
|
|
36
46
|
* itself, a `https://doi.org/` or `http(s)://dx.doi.org/` resolver URL, a
|
|
37
47
|
* `doi:` label, or a `{www.}{biorxiv,medrxiv}.org/content/` article URL — any
|
|
38
48
|
* of them with a trailing `vN` revision and an article-tab suffix (`.full`,
|
|
@@ -41,8 +51,13 @@ export interface NormalizedDoi {
|
|
|
41
51
|
* suffix named alongside the DOI, and `undefined` when what is left is not a
|
|
42
52
|
* DOI — callers raise their `invalid_doi_format` on that.
|
|
43
53
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
54
|
+
* On a DOI under {@link BIORXIV_DOI_PREFIXES}, any article-tab suffix is
|
|
55
|
+
* stripped, only ever as text around the bioRxiv/medRxiv identifier, never
|
|
56
|
+
* characters of one. Any other DOI is a journal's, whose own trailing
|
|
57
|
+
* components (`10.7554/eLife.55185.sa1`, `….pone.0123456.g001`, Wiley's `.x`)
|
|
58
|
+
* name a different record than the DOI without them, so only the page-format
|
|
59
|
+
* tabs (`.pdf`, `.full`, `.full.pdf`, `.full-text`, …) and a `vN` revision
|
|
60
|
+
* after a digit are stripped from it, never one of its own components.
|
|
46
61
|
*/
|
|
47
62
|
export declare function normalizeDoi(input: string): NormalizedDoi | undefined;
|
|
48
63
|
/**
|
|
@@ -59,6 +74,13 @@ export declare function normalizeRorId(input: string): string | undefined;
|
|
|
59
74
|
* into raw title and abstract text, so no upstream markup reaches
|
|
60
75
|
* `structuredContent` or the rendered `content[]`. Handles:
|
|
61
76
|
*
|
|
77
|
+
* - the two backslash escapes bioRxiv abstracts posted before December 2019
|
|
78
|
+
* carry: a literal backslash-`n` (single, paired, or longer runs) read as a
|
|
79
|
+
* real line break, and a literal backslash-`"` read as `"` — first, so the
|
|
80
|
+
* heading and list handling below sees the breaks. Only in text with no real
|
|
81
|
+
* line break, the one form those abstracts use, and never where the
|
|
82
|
+
* backslash follows another backslash or a backslash-`n` opens a TeX
|
|
83
|
+
* control word (`\nabla`, `\neq`);
|
|
62
84
|
* - whole blocks removed with everything inside: figures (`O_FIG … C_FIG`),
|
|
63
85
|
* display figures (`O_FIG_DISPLAY_L … C_FIG_DISPLAY`), and tables
|
|
64
86
|
* (`O_TBL … C_TBL`, caption included) — image refs, `SRC=` paths,
|
|
@@ -112,18 +134,22 @@ export declare function normalizeUpstreamText(text: string | undefined): string
|
|
|
112
134
|
* assembled text (the formatter's own `**Label:**` markup must survive), and
|
|
113
135
|
* never to `structuredContent`, identifiers an agent copies back into a call
|
|
114
136
|
* (DOIs, `jatsxmlUrl`, `sourceUrl`), or extractor-produced Markdown such as the
|
|
115
|
-
* `biorxiv_get_fulltext` `content`.
|
|
116
|
-
*
|
|
137
|
+
* `biorxiv_get_fulltext` `content`. Kept local rather than the framework's
|
|
138
|
+
* `escapeMarkdownInline` because that one escapes more by design — every `[`,
|
|
139
|
+
* `]`, `|`, and `~`, entity-shaped `&` runs, edge whitespace — so it would add
|
|
140
|
+
* backslashes to the abstracts and titles every tool renders where none
|
|
141
|
+
* changes how they render.
|
|
117
142
|
*/
|
|
118
143
|
export declare function escapeMarkdown(text: string): string;
|
|
119
144
|
/**
|
|
120
145
|
* Reads a `Retry-After` header value as a wait in whole seconds. RFC 9110 §10.2.3
|
|
121
146
|
* allows either delta-seconds or an HTTP-date; the date form is converted to a
|
|
122
147
|
* wait from now. Returns undefined for an absent, malformed, or unparseable
|
|
123
|
-
* value, and for a wait of zero or less (`0`, an HTTP-date already past):
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
148
|
+
* value, and for a wait of zero or less (`0`, an HTTP-date already past): a
|
|
149
|
+
* zero wait is no usable wait. Callers then fall back to generic wording
|
|
150
|
+
* rather than telling an agent to wait 0 seconds and walk back into the
|
|
151
|
+
* limiter, and `retryWithinBudget` keeps such a header from `withRetry`, which
|
|
152
|
+
* would re-send at once.
|
|
127
153
|
*
|
|
128
154
|
* Shared by every fetch path — the JSON API, the full-text article origin, and
|
|
129
155
|
* EuropePMC each surface the same header and must read it identically.
|
|
@@ -149,6 +175,12 @@ export declare function findRateLimit(errors: readonly unknown[]): {
|
|
|
149
175
|
* named no usable wait.
|
|
150
176
|
*/
|
|
151
177
|
export declare function describeWait(seconds: number | undefined): string;
|
|
178
|
+
/**
|
|
179
|
+
* A not-found recovery hint for a lookup across `servers`. A call that checked
|
|
180
|
+
* one server only is first sent to the other, since bioRxiv and medRxiv share
|
|
181
|
+
* their DOI prefixes; a call that checked both gets `hint` alone.
|
|
182
|
+
*/
|
|
183
|
+
export declare function notFoundHint(servers: readonly string[], hint: string): string;
|
|
152
184
|
/**
|
|
153
185
|
* Wall-clock budget for one tool call: every upstream request the call makes,
|
|
154
186
|
* with each request's attempts, backoffs, and honored `Retry-After` waits. Kept
|
|
@@ -183,11 +215,15 @@ export declare function ladderBudgetMs(deadline: CallDeadline, operation: string
|
|
|
183
215
|
/**
|
|
184
216
|
* Runs one retry ladder on what is left of a call's budget: `withRetry` with
|
|
185
217
|
* {@link ladderBudgetMs} as its `deadlineMs`, so a spent budget fails before
|
|
186
|
-
* any request.
|
|
187
|
-
*
|
|
188
|
-
*
|
|
218
|
+
* any request. A 429 whose `Retry-After` names no usable wait reaches
|
|
219
|
+
* `withRetry` without the header, so the ladder paces it with the exponential
|
|
220
|
+
* backoff a header-less 429 takes rather than re-sending at once.
|
|
221
|
+
*
|
|
222
|
+
* The ladder remembers the last HTTP 429 an attempt received. When the budget
|
|
223
|
+
* then runs out — in the backoff after it, or by cutting a later attempt
|
|
224
|
+
* short — `withRetry` rejects with a `Timeout`
|
|
189
225
|
* (`reason: 'retry_deadline_exceeded'`) whose `cause` is only the last
|
|
190
|
-
* attempt; the ladder rejects with the 429 instead,
|
|
226
|
+
* attempt; the ladder rejects with the 429 instead, as the origin sent it,
|
|
191
227
|
* since it is still the origin's answer and the one the services classify.
|
|
192
228
|
* Every other failure is rejected as `withRetry` threw it.
|
|
193
229
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/services/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAa,MAAM,8BAA8B,CAAC;AAU/F,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB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