papersearch 0.5.6 → 0.5.8
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/README.en.md +25 -23
- package/README.md +25 -23
- package/assets/ask-with-skill.png +0 -0
- package/carsi/paper_search_carsi/assets/api_keys.json +6 -4
- package/carsi/paper_search_carsi/assets/capsule.html +173 -21
- package/carsi/paper_search_carsi/assets/capsule_en.json +68 -5
- package/carsi/paper_search_carsi/browser/watchdog.py +6 -1
- package/carsi/paper_search_carsi/capsule_placement.py +8 -5
- package/carsi/paper_search_carsi/capsule_window.py +495 -0
- package/carsi/paper_search_carsi/cli.py +2 -2
- package/carsi/paper_search_carsi/engine/batch_capture.py +11 -3
- package/carsi/paper_search_carsi/engine/batch_login.py +3 -2
- package/carsi/paper_search_carsi/engine/batch_waits.py +28 -7
- package/carsi/paper_search_carsi/i18n.py +5 -0
- package/carsi/paper_search_carsi/progress_capsule.py +177 -426
- package/carsi/paper_search_carsi/progress_macos.py +53 -6
- package/carsi/paper_search_carsi/progress_reporter.py +132 -20
- package/carsi/paper_search_carsi/progress_view.py +95 -14
- package/carsi/paper_search_carsi/server.py +25 -3
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js +1 -1
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.d.ts +4 -3
- package/dist/capabilities/pdf-discovery/batch.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.js +217 -85
- package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batchPapers.d.ts +19 -0
- package/dist/capabilities/pdf-discovery/batchPapers.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/batchPapers.js +44 -0
- package/dist/capabilities/pdf-discovery/batchPapers.js.map +1 -0
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts +6 -1
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batchSummary.js +33 -8
- package/dist/capabilities/pdf-discovery/batchSummary.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts +13 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js +77 -25
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts +4 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js +5 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiResultNormalizer.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiResultNormalizer.js +4 -3
- package/dist/capabilities/pdf-discovery/carsi/CarsiResultNormalizer.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/index.d.ts +1 -1
- package/dist/capabilities/pdf-discovery/carsi/index.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts +51 -2
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.js +2 -1
- package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
- package/dist/capabilities/pdf-discovery/outputLayout.d.ts +27 -2
- package/dist/capabilities/pdf-discovery/outputLayout.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/outputLayout.js +133 -29
- package/dist/capabilities/pdf-discovery/outputLayout.js.map +1 -1
- package/dist/capabilities/pdf-discovery/types.d.ts +5 -0
- package/dist/capabilities/pdf-discovery/types.d.ts.map +1 -1
- package/dist/cli.js +1 -31
- package/dist/cli.js.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.d.ts +4 -0
- package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.js +11 -3
- package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
- package/dist/management/carsi/autoUpdate.d.ts +2 -2
- package/dist/management/carsi/autoUpdate.d.ts.map +1 -1
- package/dist/management/carsi/autoUpdate.js +8 -2
- package/dist/management/carsi/autoUpdate.js.map +1 -1
- package/dist/management/carsi/cliProgress.d.ts +8 -0
- package/dist/management/carsi/cliProgress.d.ts.map +1 -0
- package/dist/management/carsi/cliProgress.js +38 -0
- package/dist/management/carsi/cliProgress.js.map +1 -0
- package/dist/management/carsi/installer.d.ts.map +1 -1
- package/dist/management/carsi/installer.js +3 -6
- package/dist/management/carsi/installer.js.map +1 -1
- package/dist/management/skills/nextSteps.js +1 -1
- package/dist/management/skills/nextSteps.js.map +1 -1
- package/dist/skills/SkillInstaller.d.ts +4 -0
- package/dist/skills/SkillInstaller.d.ts.map +1 -1
- package/dist/skills/SkillInstaller.js +20 -2
- package/dist/skills/SkillInstaller.js.map +1 -1
- package/package.json +2 -2
- package/skills/paper-search/SKILL.md +13 -9
- package/skills/paper-search/references/browser-download.md +4 -4
- package/skills/paper-search/references/cli-contract.md +2 -2
- package/skills/paper-search/references/management-layer.md +20 -10
- package/skills/paper-search/references/setup.md +3 -3
- package/skills/paper-search/references/troubleshooting.md +2 -1
- package/carsi/paper_search_carsi/progress_bar.py +0 -684
|
@@ -716,16 +716,24 @@ class CaptureMixin:
|
|
|
716
716
|
# article page shows "Download PDF", 2026-11-02).
|
|
717
717
|
before_click = self._pdf_candidates(page, doi) if bound_pdf_urls is None else []
|
|
718
718
|
click_started = time.time()
|
|
719
|
+
fallback = getattr(self, "_fallback_pdf", None)
|
|
719
720
|
if self._click_pdf_entry(page, result, doi=doi, bound=bound_pdf_urls):
|
|
720
721
|
begin("click", self._clicked_pdf_control(result), click_started)
|
|
721
722
|
# Until the PDF (or a block) arrives, or Firefox shows one it may
|
|
722
723
|
# read in its viewer. OUP's watermarked PDF URL names no article,
|
|
723
724
|
# so its response is what counts (BJS, 2026-11-01).
|
|
724
|
-
pump_until(page, lambda: bool(captured["bytes"] or captured["block_reason"]
|
|
725
|
+
pump_until(page, lambda: bool(captured["bytes"] or captured["block_reason"]
|
|
726
|
+
or getattr(self, "_fallback_pdf", None) is not fallback) or (
|
|
725
727
|
not self._is_chromium(page) and self._pdf_viewer_present(page)
|
|
726
728
|
and self._native_viewer_pdf_allowed(str(getattr(page, "url", "") or ""), **fallback_options)), 5_000)
|
|
727
729
|
if captured["bytes"] or captured["block_reason"]:
|
|
728
730
|
return captured["bytes"], str(captured["url"]), captured["block_reason"]
|
|
731
|
+
if getattr(self, "_fallback_pdf", None) is not fallback:
|
|
732
|
+
# The article's own PDF link gave a PDF naming neither DOI nor title.
|
|
733
|
+
# The page's other addresses give the same file (Science's reader and
|
|
734
|
+
# PDF addresses took the rest of the minute every time, 2026-11-09):
|
|
735
|
+
# it is saved now, unconfirmed, for PaperSearch to check.
|
|
736
|
+
return None, "", None
|
|
729
737
|
self._wait_past_redirect_page(page, result) # e.g. a sign-in round trip first
|
|
730
738
|
if not self._resolve_suspect_block(page, result, captured):
|
|
731
739
|
return None, "", captured["block_reason"]
|
|
@@ -767,8 +775,8 @@ class CaptureMixin:
|
|
|
767
775
|
# document; try each URL once.
|
|
768
776
|
candidates = list(dict.fromkeys(str(url).split("#", 1)[0] for url in candidates if url))
|
|
769
777
|
for pdf_url in candidates:
|
|
770
|
-
if captured["bytes"] or captured["block_reason"]:
|
|
771
|
-
break
|
|
778
|
+
if captured["bytes"] or captured["block_reason"] or getattr(self, "_fallback_pdf", None) is not None:
|
|
779
|
+
break # a PDF naming neither DOI nor title is in hand: saved unconfirmed, as after the click
|
|
772
780
|
if pdf_url in rejected_pdf_urls:
|
|
773
781
|
continue
|
|
774
782
|
if entitlement_denied():
|
|
@@ -332,8 +332,8 @@ class LoginMixin:
|
|
|
332
332
|
settle(page, 2_000)
|
|
333
333
|
self._select_institution(page, result)
|
|
334
334
|
|
|
335
|
-
deadline = self.
|
|
336
|
-
with self._login_wait_budget(result, "
|
|
335
|
+
deadline = self._school_login_deadline(result)
|
|
336
|
+
with self._login_wait_budget(result, "_school_login_deadline", deadline, time.time) as wait:
|
|
337
337
|
last_state = ""
|
|
338
338
|
last_auto_action = ""
|
|
339
339
|
last_auto_action_at = 0.0
|
|
@@ -1408,6 +1408,7 @@ class LoginMixin:
|
|
|
1408
1408
|
- ``school_login``: the school's own login page, the user's step;
|
|
1409
1409
|
- ``school_choice``: a school chooser with no school configured, also the user's;
|
|
1410
1410
|
- ``institution_chooser``: a chooser where the configured school was to be chosen;
|
|
1411
|
+
- ``authentication_redirect``: the school's site, its login not shown (yet);
|
|
1411
1412
|
- ``publisher``: the publisher's own pages: the login was never reached;
|
|
1412
1413
|
- ``other`` or ``closed``.
|
|
1413
1414
|
"""
|
|
@@ -78,7 +78,8 @@ class UserWaitMixin:
|
|
|
78
78
|
request with a human-verification page. Every open tab is checked; the
|
|
79
79
|
verification tab is brought to the front, the user is asked to
|
|
80
80
|
complete it, and the loop waits until the PDF is captured (success),
|
|
81
|
-
no verification/suspect page is left (the capture loop continues),
|
|
81
|
+
no verification/suspect page is left (the capture loop continues), a
|
|
82
|
+
PDF naming neither DOI nor title came through (saved unconfirmed), or
|
|
82
83
|
the bounded wait ends (only then ``ip_blocked``). Returns False when
|
|
83
84
|
the route must stop.
|
|
84
85
|
"""
|
|
@@ -108,7 +109,8 @@ class UserWaitMixin:
|
|
|
108
109
|
return self._wait_out_suspect_block(page, result, captured, suspect, suspect_host, started)
|
|
109
110
|
finally:
|
|
110
111
|
self._note_wait(result, f"the PDF step's {suspect[:120]}", started,
|
|
111
|
-
"pdf" if captured.get("bytes")
|
|
112
|
+
"pdf" if captured.get("bytes") or captured.get("unconfirmed_pdf")
|
|
113
|
+
else captured.get("block_reason") or "page changed")
|
|
112
114
|
|
|
113
115
|
def _wait_out_suspect_block(self, page: Any, result: DownloadResult, captured: dict[str, Any], suspect: str,
|
|
114
116
|
suspect_host: str, started: float) -> bool:
|
|
@@ -126,6 +128,7 @@ class UserWaitMixin:
|
|
|
126
128
|
reporter = None
|
|
127
129
|
shown = "" # "verification" | "login" | "unknown"
|
|
128
130
|
verification_tab = None
|
|
131
|
+
fallback = getattr(self, "_fallback_pdf", None)
|
|
129
132
|
try:
|
|
130
133
|
while time.time() < deadline:
|
|
131
134
|
self._check_user_decision(result, page)
|
|
@@ -133,6 +136,15 @@ class UserWaitMixin:
|
|
|
133
136
|
self._event(result, "challenge_resolved", "pdf captured while waiting")
|
|
134
137
|
captured["suspect_block"] = None
|
|
135
138
|
return True
|
|
139
|
+
if getattr(self, "_fallback_pdf", None) is not fallback:
|
|
140
|
+
# The verification let the PDF through as a download, and the tab
|
|
141
|
+
# stays on "Verification successful. Waiting for ..." (Science, a
|
|
142
|
+
# fresh profile, 2026-11-09). It names neither DOI nor title on its
|
|
143
|
+
# first pages: the capture ends here and saves it unconfirmed.
|
|
144
|
+
self._event(result, "challenge_resolved", "pdf arrived while waiting, unconfirmed")
|
|
145
|
+
captured["suspect_block"] = None
|
|
146
|
+
captured["unconfirmed_pdf"] = True
|
|
147
|
+
return False
|
|
136
148
|
try:
|
|
137
149
|
pages = [p for p in list(page.context.pages) if not p.is_closed()]
|
|
138
150
|
except Exception:
|
|
@@ -351,16 +363,25 @@ class UserWaitMixin:
|
|
|
351
363
|
return (getattr(self, "config", None) or {}).get("user_wait") == "short"
|
|
352
364
|
|
|
353
365
|
def _user_wait_deadline(self, result: DownloadResult) -> float:
|
|
354
|
-
"""One deadline for
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if wait is not None and wait.attribute == "_user_wait_deadline":
|
|
358
|
-
return wait.deadline
|
|
366
|
+
"""One deadline for the verification waits in this article (at the article,
|
|
367
|
+
the PDF step): ``login_timeout_sec`` from the first of them. The school
|
|
368
|
+
login has its own (``_school_login_deadline``)."""
|
|
359
369
|
deadline = getattr(result, "_user_wait_deadline", None)
|
|
360
370
|
if deadline is None:
|
|
361
371
|
deadline = result._user_wait_deadline = time.time() + self.login_timeout_sec
|
|
362
372
|
return deadline
|
|
363
373
|
|
|
374
|
+
def _school_login_deadline(self, result: DownloadResult) -> float:
|
|
375
|
+
"""The school login's own time: ``login_timeout_sec`` from when this article
|
|
376
|
+
first reaches it, however often it is entered. A verification and the
|
|
377
|
+
program's own steps before it never shorten it (Elsevier: a 22 s
|
|
378
|
+
verification and choosing the school left 1 s of 30 on the school's login
|
|
379
|
+
page, 2026-11-09; OUP's login has had its own since 2026-11-02)."""
|
|
380
|
+
deadline = getattr(result, "_school_login_deadline", None)
|
|
381
|
+
if deadline is None:
|
|
382
|
+
deadline = result._school_login_deadline = time.time() + self.login_timeout_sec
|
|
383
|
+
return deadline
|
|
384
|
+
|
|
364
385
|
def _wait_deadline(self, result: DownloadResult, deadline: float | None = None) -> float:
|
|
365
386
|
"""End of a wait on the user that starts now, off the school's login page
|
|
366
387
|
(verification pages): the caller's bound, the article's total, the page
|
|
@@ -13,6 +13,7 @@ from pathlib import Path
|
|
|
13
13
|
TABLE = Path(__file__).resolve().parent / "assets" / "capsule_en.json"
|
|
14
14
|
LANGUAGES = ("zh", "en")
|
|
15
15
|
_HAN = re.compile(r"[\u4e00-\u9fff]")
|
|
16
|
+
_BRACKETS = re.compile(r"^(.+?)((.+))$")
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
@lru_cache(maxsize=1)
|
|
@@ -36,6 +37,10 @@ def _one(text: str) -> str:
|
|
|
36
37
|
if pattern.search(core):
|
|
37
38
|
exact = pattern.sub(target, core)
|
|
38
39
|
break
|
|
40
|
+
parts = _BRACKETS.match(core) if exact is None else None
|
|
41
|
+
if parts:
|
|
42
|
+
# "开放下载 18(出版社 API 3、预印本 1)": the text and what its brackets list, each on its own.
|
|
43
|
+
exact = f"{_one(parts[1])} ({', '.join(_one(item) for item in parts[2].split('、'))})"
|
|
39
44
|
return text if exact is None else text.replace(core, exact)
|
|
40
45
|
|
|
41
46
|
|