papersearch 0.6.6 → 0.6.7

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 (75) hide show
  1. package/dist/capabilities/pdf-discovery/batch.d.ts +6 -0
  2. package/dist/capabilities/pdf-discovery/batch.d.ts.map +1 -1
  3. package/dist/capabilities/pdf-discovery/batch.js +201 -17
  4. package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
  5. package/dist/capabilities/pdf-discovery/handler.d.ts +3 -1
  6. package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
  7. package/dist/capabilities/pdf-discovery/handler.js +27 -1
  8. package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
  9. package/dist/capabilities/pdf-discovery/resume.d.ts +22 -0
  10. package/dist/capabilities/pdf-discovery/resume.d.ts.map +1 -0
  11. package/dist/capabilities/pdf-discovery/resume.js +114 -0
  12. package/dist/capabilities/pdf-discovery/resume.js.map +1 -0
  13. package/dist/capabilities/pdf-discovery/schemas.d.ts +34 -3
  14. package/dist/capabilities/pdf-discovery/schemas.d.ts.map +1 -1
  15. package/dist/capabilities/pdf-discovery/schemas.js +6 -3
  16. package/dist/capabilities/pdf-discovery/schemas.js.map +1 -1
  17. package/dist/capabilities/pdf-discovery/school/SchoolAttempt.d.ts.map +1 -1
  18. package/dist/capabilities/pdf-discovery/school/SchoolAttempt.js +2 -0
  19. package/dist/capabilities/pdf-discovery/school/SchoolAttempt.js.map +1 -1
  20. package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts +15 -1
  21. package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts.map +1 -1
  22. package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js +42 -7
  23. package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js.map +1 -1
  24. package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts +4 -0
  25. package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts.map +1 -1
  26. package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js +4 -0
  27. package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js.map +1 -1
  28. package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.js +7 -1
  29. package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.js.map +1 -1
  30. package/dist/capabilities/pdf-discovery/school/index.d.ts +2 -2
  31. package/dist/capabilities/pdf-discovery/school/index.d.ts.map +1 -1
  32. package/dist/capabilities/pdf-discovery/school/index.js +1 -1
  33. package/dist/capabilities/pdf-discovery/school/index.js.map +1 -1
  34. package/dist/capabilities/pdf-discovery/school/types.d.ts +35 -0
  35. package/dist/capabilities/pdf-discovery/school/types.d.ts.map +1 -1
  36. package/dist/capabilities/pdf-discovery/tools.d.ts +8 -4
  37. package/dist/capabilities/pdf-discovery/tools.d.ts.map +1 -1
  38. package/dist/capabilities/pdf-discovery/tools.js +5 -3
  39. package/dist/capabilities/pdf-discovery/tools.js.map +1 -1
  40. package/dist/infrastructure/runlog/RunLedger.d.ts +4 -0
  41. package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
  42. package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
  43. package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
  44. package/dist/infrastructure/runlog/failureClass.js +3 -0
  45. package/dist/infrastructure/runlog/failureClass.js.map +1 -1
  46. package/dist/management/failures/exportReport.d.ts.map +1 -1
  47. package/dist/management/failures/exportReport.js +3 -1
  48. package/dist/management/failures/exportReport.js.map +1 -1
  49. package/dist/management/school/autoUpdate.d.ts.map +1 -1
  50. package/dist/management/school/autoUpdate.js +8 -0
  51. package/dist/management/school/autoUpdate.js.map +1 -1
  52. package/dist/management/school/cliProgress.d.ts.map +1 -1
  53. package/dist/management/school/cliProgress.js +2 -0
  54. package/dist/management/school/cliProgress.js.map +1 -1
  55. package/dist/management/school/host.d.ts.map +1 -1
  56. package/dist/management/school/host.js +3 -1
  57. package/dist/management/school/host.js.map +1 -1
  58. package/dist/management/school/settingsWindow.d.ts +1 -1
  59. package/dist/management/school/settingsWindow.d.ts.map +1 -1
  60. package/dist/management/school/settingsWindow.js +4 -2
  61. package/dist/management/school/settingsWindow.js.map +1 -1
  62. package/package.json +1 -1
  63. package/school/paper_search_school/assets/capsule.html +73 -2
  64. package/school/paper_search_school/assets/capsule_en.json +33 -1
  65. package/school/paper_search_school/cli.py +15 -0
  66. package/school/paper_search_school/engine/batch_capture.py +10 -2
  67. package/school/paper_search_school/engine/batch_institution.py +20 -3
  68. package/school/paper_search_school/engine/bridge.py +19 -1
  69. package/school/paper_search_school/entitlements.py +27 -0
  70. package/school/paper_search_school/progress_capsule.py +10 -1
  71. package/school/paper_search_school/progress_reporter.py +29 -2
  72. package/school/paper_search_school/progress_view.py +17 -2
  73. package/school/paper_search_school/server.py +15 -3
  74. package/skills/paper-search/SKILL.md +1 -1
  75. package/skills/paper-search/references/browser-download.md +12 -1
@@ -36,6 +36,12 @@ from .batch_common import (
36
36
  )
37
37
 
38
38
 
39
+ def _sent_as_attachment(headers: dict[str, str]) -> bool:
40
+ """The site sends the PDF to be saved, not shown (Content-Disposition: attachment):
41
+ Chrome downloads it besides the capture, which holds it already."""
42
+ return headers.get("content-disposition", "").strip().lower().startswith("attachment")
43
+
44
+
39
45
  class CaptureMixin:
40
46
  """Getting the PDF: the article's PDF control, the browser's viewer and downloads, fetching again."""
41
47
 
@@ -508,10 +514,12 @@ class CaptureMixin:
508
514
  else payload["body"].encode("latin-1")
509
515
  )
510
516
  if self._accept_pdf_body(body, url):
511
- if self.adapter.keeps_pdf_out_of_downloads:
517
+ if self.adapter.keeps_pdf_out_of_downloads or _sent_as_attachment(headers):
512
518
  # We own the validated bytes and save them under the
513
519
  # DOI below. Do not also hand the response to Chrome's
514
- # download manager, which exposes a UUID temp file.
520
+ # download manager, which exposes a UUID temp file and,
521
+ # for a PDF sent as an attachment, a full second copy in
522
+ # its download list (Science's ?download=true, 2026-11-15).
515
523
  cdp_session.send("Fetch.fulfillRequest", {
516
524
  "requestId": request_id, "responseCode": 204,
517
525
  "responseHeaders": [], "body": "",
@@ -649,8 +649,14 @@ class InstitutionMixin:
649
649
  where = str(event.get("detail", "")).split(" @ ", 1)[-1]
650
650
  return event["state"] == "auto_institution_search" and self._same_address(where, url)
651
651
 
652
- if not any(searched_here(e) for e in result.events):
652
+ searches = [index for index, e in enumerate(result.events) if searched_here(e)]
653
+ if not searches:
653
654
  return False # nothing searched here: a page's other lists say nothing
655
+ if any(e["state"] == "institution_selected" for e in result.events[searches[-1]:]):
656
+ # Its entry was chosen after that search: the list has the school, and the
657
+ # page is on its way to the school's login (Science sent its login page back,
658
+ # the second choice was still leaving it, 2026-11-15).
659
+ return False
654
660
  others = sorted({str(it.get("t") or "")[:80] for score, it in scored if score == 1})
655
661
  # A unit of the school (its library, campus, a faculty) may be its way in,
656
662
  # unless its publisher marks it as signing in no one (IP, VPN, email).
@@ -781,10 +787,21 @@ class InstitutionMixin:
781
787
  raise
782
788
  return True # not readable now: nothing concluded from it
783
789
 
790
+ # The site's own line naming the institution it serves the reader for ("brought to
791
+ # you by <school>" in Science's header, 2026-11-15) is no entry of a list.
792
+ _SESSION_BANNER = re.compile(r"\s*(?:brought to you by|access (?:provided|funded) by)", re.I)
793
+
794
+ def _listed_entries(self, page: Any) -> Any:
795
+ """The entries a page lists now (``_ENTRIES_JS``), the site's session banner aside."""
796
+ items = page.evaluate(self._ENTRIES_JS, self._ENTRY_SELECTOR)
797
+ if not isinstance(items, list):
798
+ return items
799
+ return [it for it in items if not (isinstance(it, dict) and self._SESSION_BANNER.match(str(it.get("t") or "")))]
800
+
784
801
  def _entry_texts(self, page: Any) -> set[str]:
785
802
  """The entries a page lists now, by their text (``_ENTRIES_JS``)."""
786
803
  try:
787
- items = page.evaluate(self._ENTRIES_JS, self._ENTRY_SELECTOR)
804
+ items = self._listed_entries(page)
788
805
  except Exception as exc:
789
806
  if not _is_browser_error(exc):
790
807
  raise
@@ -803,7 +820,7 @@ class InstitutionMixin:
803
820
  list, 2026-11-01).
804
821
  """
805
822
  try:
806
- items = page.evaluate(self._ENTRIES_JS, self._ENTRY_SELECTOR)
823
+ items = self._listed_entries(page)
807
824
  except Exception:
808
825
  return False
809
826
  if not isinstance(items, list):
@@ -376,7 +376,8 @@ def _try_builtin_institutional(
376
376
  "action": primary["action"], "source_failures": failures}
377
377
  if primary["error_type"] == "access_blocked":
378
378
  _remember_blocked_journal(doi, identity)
379
- if primary["error_type"] == "institution_federation_unavailable" and manual_school:
379
+ if (primary["error_type"] == "institution_federation_unavailable" and manual_school
380
+ and (primary.get("artifacts") or {}).get("route_missing")):
380
381
  _remember_missing_route(publisher_name, config, doi)
381
382
  if "reason_code" in primary:
382
383
  result["reason_code"] = primary["reason_code"]
@@ -711,6 +712,11 @@ def _write_exception_diagnostic(run_dir: Path, doi: str, exc: Exception, *,
711
712
  return str(path)
712
713
 
713
714
 
715
+ #: Where a wait on a school login can end (``BatchLoginMixin._login_wait_page``).
716
+ LOGIN_WAIT_PAGES = ("school_login", "school_choice", "institution_chooser", "authentication_redirect",
717
+ "publisher", "other", "closed")
718
+
719
+
714
720
  def _browser_artifacts(result: Any, profile: Any) -> dict[str, str]:
715
721
  """Where the browser run left its record (success) or diagnostic packet (failure).
716
722
 
@@ -725,6 +731,18 @@ def _browser_artifacts(result: Any, profile: Any) -> dict[str, str]:
725
731
  "diagnostic": str(getattr(result, "diagnostic_path", "") or ""),
726
732
  "state": state if re.fullmatch(r"[a-z0-9_]{1,64}", state) else "",
727
733
  }
734
+ # The publisher's list was seen without the school in this run, and the school was
735
+ # chosen nowhere in it: only this is remembered as no route (``login_routes``); an
736
+ # article that ended on the earlier finding, or whose school was chosen, is not.
737
+ events = getattr(result, "events", None) or []
738
+ if getattr(result, "_institution_not_listed", False) is True and not any(
739
+ isinstance(e, dict) and e.get("state") == "institution_selected" for e in events):
740
+ artifacts["route_missing"] = True
741
+ # Where a wait on a school login ended (``_login_wait_page``): a fixed word. The caller
742
+ # holds a publisher only on the school's own sign-in page (2026-11-15).
743
+ wait_page = str(getattr(result, "login_wait_page", "") or "")
744
+ if wait_page in LOGIN_WAIT_PAGES:
745
+ artifacts["login_wait_page"] = wait_page
728
746
  # The school's site the login stopped on: a host name only, for the message.
729
747
  host = str(getattr(result, "_stopped_host", "") or "").lower()
730
748
  if state == "idp_no_return_to_publisher" and re.fullmatch(r"[a-z0-9-]+(?:\.[a-z0-9-]+)+", host) and len(host) <= 253:
@@ -42,6 +42,8 @@ class UserStoppedBatch(UserMarkedNoEntitlement):
42
42
  # Not an entitlement decision: nothing is recorded, the batch ends.
43
43
  STOP_BATCH = "stop_batch"
44
44
  SHOW_BROWSER = "show_browser"
45
+ # The user is back: a publisher the batch held goes on (``resume_path``).
46
+ RESUME_HELD = "resume_held"
45
47
 
46
48
 
47
49
  SKIP = "skip"
@@ -204,6 +206,31 @@ def request_action(current: str, action: str, run_id: str = "") -> None:
204
206
  _write_json(control_path(), data)
205
207
 
206
208
 
209
+ def resume_path() -> Path:
210
+ return control_path().with_name("resume.json")
211
+
212
+
213
+ def request_resume(key: str, batch_id: str) -> None:
214
+ """The user asked the batch to go on with a publisher it holds (a DOI prefix)."""
215
+ data = _read_json(resume_path())
216
+ keys = list(data.get("keys") or []) if data.get("batch_id") == batch_id else []
217
+ if key not in keys:
218
+ keys.append(key)
219
+ _write_json(resume_path(), {"batch_id": batch_id, "keys": keys, "at": time.time()})
220
+
221
+
222
+ def take_resumes(batch_id: str) -> list[str]:
223
+ """The publishers the user asked this batch to go on with, once (the caller's next report)."""
224
+ data = _read_json(resume_path())
225
+ if not batch_id or data.get("batch_id") != batch_id:
226
+ return []
227
+ try:
228
+ resume_path().unlink()
229
+ except OSError:
230
+ pass
231
+ return [str(key) for key in data.get("keys") or [] if isinstance(key, str)]
232
+
233
+
207
234
  def batch_stop_requested() -> bool:
208
235
  """A durable stop for the current run, including the gap between papers."""
209
236
  stop = _read_json(control_path().with_name("stop.json"))
@@ -225,8 +225,17 @@ class Api:
225
225
  def act(self, action: str, current: str, run_id: str = "") -> str:
226
226
  """Control the running download, including showing its browser on request."""
227
227
  try:
228
- from .entitlements import SHOW_BROWSER, request_action
228
+ from .entitlements import RESUME_HELD, SHOW_BROWSER, request_action, request_resume
229
229
 
230
+ if action == RESUME_HELD:
231
+ # The user is back: every publisher the batch holds goes on.
232
+ state = read_state() or {}
233
+ held = [str(entry["key"]) for entry in state.get("held") or [] if isinstance(entry, dict) and entry.get("key")]
234
+ if state.get("status") != "running" or str(state.get("run_id") or "") != run_id or not held:
235
+ return "这批下载已没有暂停的篇目"
236
+ for key in held:
237
+ request_resume(key, str(state.get("batch_id") or ""))
238
+ return progress_view.ACTION_FEEDBACK[RESUME_HELD]
230
239
  if action == SHOW_BROWSER:
231
240
  # Asked for from a reminder, or from the paper on the card at any
232
241
  # time while it has a browser (user request, 2026-11-08).
@@ -295,6 +295,8 @@ def _adopt_batch(batch_id: str, total: int, counts: tuple[int | None, int | None
295
295
  and not _STATE.get("awaiting_next")):
296
296
  done, succeeded, failed = counts
297
297
  _STATE.update(total=int(total), lanes=fields.get("lanes", ""),
298
+ **({"held": fields["held"]} if "held" in fields else {}),
299
+ **({"held_wait": fields["held_wait"]} if "held_wait" in fields else {}),
298
300
  **({"done": done} if done is not None else {}),
299
301
  **({"success": succeeded} if succeeded is not None else {}),
300
302
  **({"failed": failed} if failed is not None else {}))
@@ -335,9 +337,28 @@ def _adopt_batch(batch_id: str, total: int, counts: tuple[int | None, int | None
335
337
  return True
336
338
 
337
339
 
340
+ _HELD_KEY = re.compile(r"10\.\d{4,9}/")
341
+
342
+
343
+ def _held(raw: Any) -> list[dict[str, Any]]:
344
+ """The publishers whose papers the caller holds (their school login stopped working
345
+ mid-batch): [{key (a DOI prefix), name, count}], at most four, checked for the window."""
346
+ held: list[dict[str, Any]] = []
347
+ for entry in raw if isinstance(raw, list) else []:
348
+ if not isinstance(entry, dict) or not _HELD_KEY.fullmatch(str(entry.get("key") or "")):
349
+ continue
350
+ count = entry.get("count")
351
+ if not isinstance(count, int) or isinstance(count, bool) or not 0 < count <= 1_000_000:
352
+ continue
353
+ name = _short_line(entry.get("name"), 40) or entry["key"]
354
+ held.append({"key": entry["key"], "name": name, "count": count})
355
+ return held[:4]
356
+
357
+
338
358
  def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int, *,
339
359
  current: str = "", finished: bool = False, results: Any = None,
340
- phase: str = "", channel: str = "", lanes: str = "") -> bool:
360
+ phase: str = "", channel: str = "", lanes: str = "", held: Any = None,
361
+ held_wait: bool = False) -> bool:
341
362
  """Record batch totals for items finished without the backend, or the batch end.
342
363
 
343
364
  ``results`` (the batch end only) is the caller's summary of every item,
@@ -348,7 +369,10 @@ def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int
348
369
  short single lines and are dropped at the batch end. ``lanes`` is one line on
349
370
  what each lane got in a batch whose open-access checks run beside its downloads;
350
371
  it may come while a download of the batch runs, which then keeps its paper,
351
- stage and prompts (``_adopt_batch``)."""
372
+ stage and prompts (``_adopt_batch``). ``held``: the publishers the caller holds
373
+ (``_held``), each with a button to go on with them; an empty list clears them.
374
+ ``held_wait``: nothing else is left and the batch waits for the user to go on with
375
+ them or end it (each report says it again; any other report, or a download, ends it)."""
352
376
  ctx = BatchContext.from_args(batch_id, max(1, min(done, total)), total, done, succeeded, failed)
353
377
  if ctx is None or done > total:
354
378
  return False
@@ -361,6 +385,8 @@ def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int
361
385
  beside_download=bool(lanes) and not finished,
362
386
  **({"current": current} if current else {}),
363
387
  **({"lanes": lanes} if lanes or finished else {}),
388
+ **({"held": [] if finished else _held(held)} if held is not None or finished else {}),
389
+ held_wait=bool(held_wait) and not finished,
364
390
  stage="saved_pending_verification" if finished else "starting",
365
391
  channel="" if finished else channel,
366
392
  phase=(f"批量下载结束:成功 {succeeded},失败 {failed}" if finished
@@ -572,6 +598,7 @@ def tracked_download(current: str, output_dir: Any = None, batch: BatchContext |
572
598
  _notify_stage("starting", current)
573
599
  with _LOCK:
574
600
  _STATE.pop("hourly_wait", None) # this article runs: no longer held by the hourly limit
601
+ _STATE.pop("held_wait", None) # nor waiting for the user to go on with held publishers
575
602
  update(content=content if content in ("main", "supplements", "both") else "main")
576
603
  if output_dir:
577
604
  set_output_dir(output_dir)
@@ -34,6 +34,7 @@ STAGE_STEP = {
34
34
  # The answer a button gets in the window, before the download confirms it.
35
35
  ACTION_FEEDBACK = {
36
36
  "show_browser": "正在切到下载浏览器",
37
+ "resume_held": "已收到:这一篇下完后接着下暂停的篇目",
37
38
  "stop_batch": "已终止任务:这一篇结束,剩下的不再下载",
38
39
  "skip_item": "已跳过本篇,进入下一篇",
39
40
  "skip_journal": "已记住:本刊无权限,以后自动跳过(可用 entitlements 撤销)",
@@ -316,9 +317,20 @@ def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
316
317
  done = min(total, done) if total else done
317
318
  ok, bad = _count(state.get("success")), _count(state.get("failed"))
318
319
  attention = attention_items(state) if running else []
320
+ awaiting = bool(state.get("awaiting_next"))
321
+ # Publishers whose school login stopped working mid-batch, held by the caller:
322
+ # a line and a button to go on with them once the user is back (2026-11-15).
323
+ held = [{"key": str(entry.get("key")), "name": str(entry.get("name") or entry.get("key")),
324
+ "count": int(entry.get("count") or 0)}
325
+ for entry in (state.get("held") or []) if running and isinstance(entry, dict) and entry.get("key")]
326
+ # Nothing else left: the batch waits for the user, which the collapsed capsule says
327
+ # too, not the last paper as if it still ran (user, 2026-11-15).
328
+ held_wait = bool(held) and awaiting and not attention and bool(state.get("held_wait"))
319
329
 
320
330
  if attention:
321
331
  mode, tone, headline = "attention", "warn", "需要你操作"
332
+ elif held_wait:
333
+ mode, tone, headline = "running", "warn", "需要你操作"
322
334
  elif running:
323
335
  mode, tone, headline = "running", "accent", "下载中"
324
336
  elif status == "cancelled":
@@ -332,7 +344,6 @@ def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
332
344
  else:
333
345
  mode, tone, headline = "done", "ok", "下载完成"
334
346
 
335
- awaiting = bool(state.get("awaiting_next"))
336
347
  part_key = str(state.get("part") or "")
337
348
  if running and not awaiting and part_key in ("main", "supplements"):
338
349
  part = CONTENT_LABELS[part_key]
@@ -342,6 +353,9 @@ def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
342
353
  publisher = str(state.get("publisher") or "") or str(state.get("channel") or "")
343
354
  journal = str(state.get("journal") or "")
344
355
  current = str((attention[-1].get("current") if attention else "") or state.get("current") or "")
356
+ title = str(state.get("title") or "")
357
+ if held_wait:
358
+ publisher = journal = current = title = "" # the last paper is over
345
359
 
346
360
  step = None
347
361
  if running and not attention and not awaiting:
@@ -410,7 +424,7 @@ def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
410
424
  "ok": ok, "bad": bad, "left": max(0, total - done) if running and total else None,
411
425
  "part": part, "publisher": publisher,
412
426
  "where": " · ".join(v for v in (journal, publisher) if v),
413
- "title": str(state.get("title") or ""), "current": current,
427
+ "title": title, "current": current,
414
428
  "run_id": str(state.get("run_id") or ""),
415
429
  "step": step, "steps": list(STEPS), "line": line,
416
430
  "elapsed": elapsed, "attention": prompt, "notice": notice, "hold": bool(hold),
@@ -422,6 +436,7 @@ def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
422
436
  # the caller's open-access stretch (its channel), which opens none.
423
437
  "browser": running and bool(current) and not awaiting and not state.get("channel"),
424
438
  "stop_left": max(0, total - done - 1),
439
+ "held": held, "held_wait": held_wait,
425
440
  "folder": bool(state.get("output_dir")),
426
441
  }
427
442
 
@@ -229,6 +229,8 @@ def school_batch_progress(
229
229
  phase: str = "",
230
230
  channel: str = "",
231
231
  lanes: str = "",
232
+ held: list[dict[str, Any]] | None = None,
233
+ held_wait: bool = False,
232
234
  ) -> str:
233
235
  """Update the progress window of a serial batch without downloading.
234
236
 
@@ -244,14 +246,24 @@ def school_batch_progress(
244
246
  lanes: one line on the papers each lane got in a batch whose open-access checks run
245
247
  beside its institutional downloads ("开放下载 15 篇 · 机构下载 9 篇"). Sent beside a
246
248
  running download of the batch too: then only the counts and this line change.
249
+
250
+ held: the publishers whose papers the caller holds because their school login stopped
251
+ working mid-batch, [{key (DOI prefix), name, count}]; the window shows them with a
252
+ button to go on. The answer's "resume" lists those the user asked to go on with since
253
+ the last report (each once), and "stop" whether the user ended the batch in the window
254
+ (a batch waiting for the user downloads nothing that would hear of it).
255
+ held_wait: nothing is left but the held publishers' papers and the batch waits for the
256
+ user (登录并继续 or 终止); the window says so, collapsed too.
247
257
  """
248
- from . import progress_reporter
258
+ from . import entitlements, progress_reporter
249
259
 
250
260
  label = current if _DOI_RE.fullmatch(current or "") else ""
251
261
  updated = progress_reporter.sync_batch(batch_id, total, done, succeeded, failed,
252
262
  current=label, finished=finished, results=results,
253
- phase=phase, channel=channel, lanes=lanes)
254
- return json.dumps({"updated": updated})
263
+ phase=phase, channel=channel, lanes=lanes, held=held,
264
+ held_wait=held_wait)
265
+ stop = entitlements.batch_stop_requested() and (progress_reporter.read_state() or {}).get("batch_id") == batch_id
266
+ return json.dumps({"updated": updated, "resume": entitlements.take_resumes(batch_id), "stop": bool(stop)})
255
267
 
256
268
 
257
269
  @mcp_app.tool()
@@ -4,7 +4,7 @@ description: |
4
4
  用本机 paper-search 命令做文献工作:检索论文、核对 DOI/PMID、搜正文片段(找方法和结果的原文)、查期刊影响因子与分区、查施引和参考文献、下载全文和补充材料。
5
5
  用户要找文献、查期刊、下载论文,或说“请开始配置”时使用;英文请求(literature search、journal metrics、paper download、start setup)同样适用。
6
6
  metadata:
7
- version: "0.6.6"
7
+ version: "0.6.7"
8
8
  ---
9
9
 
10
10
  # 文献检索与下载(paper-search)
@@ -90,12 +90,23 @@ paper-search failures --format text
90
90
  | 类别 | 常见 code | 怎么说、怎么做 |
91
91
  | --- | --- | --- |
92
92
  | 没权限(有依据) | `entitlement_missing`、`institution_federation_unavailable`、`no_entitlement` | 附上汇总里的依据(页面原话或决定性的一步)。只说本篇、当前学校没有权限,不推断整个平台。出版社没有学校所在联盟的登录路线时,建议在校园网或学校 VPN 下下载。 |
93
- | 用户或外部原因 | `login_timeout`(停在学校登录页)、`login_page_closed`、`login_credentials_rejected`、`captcha_required`、`idp_login_error`、`institution_not_registered`(认证应用或入口未注册,不代表没有订阅)、`user_skipped`、`cancelled`、`access_blocked`、`cloudflare_blocked`、`publisher_content_error`、`article_not_yet_published`(论文已录用,出版社还没上线全文)、`rate_limited`、`batch_stopped`、`profile_busy` | 说明需要用户做什么(登录、验证、等待、联系图书馆),原调用结束、资源释放后再决定是否重试;不连续重新提交登录。 |
93
+ | 用户或外部原因 | `login_timeout`(停在学校登录页)、`login_paused`(这家出版社的学校登录在本批中途失效,这篇暂停、没试;不代表没有权限)、`login_page_closed`、`login_credentials_rejected`、`captcha_required`、`idp_login_error`、`institution_not_registered`(认证应用或入口未注册,不代表没有订阅)、`user_skipped`、`cancelled`、`access_blocked`、`cloudflare_blocked`、`publisher_content_error`、`article_not_yet_published`(论文已录用,出版社还没上线全文)、`rate_limited`、`batch_stopped`、`profile_busy` | 说明需要用户做什么(登录、验证、等待、联系图书馆),原调用结束、资源释放后再决定是否重试;不连续重新提交登录。 |
94
94
  | 暂不支持的网站 | `unsupported_platform`(如只在 ClinicalKey 上的内容)、`unsupported_publisher`(DOI 没有指向能登录的出版社网站,没有打开浏览器)、`generic_institution_entry_missing`(这家出版社还没有专门的规则,按通用规则没找到机构登录入口) | 说明这类网站还不支持,不说成没有权限;后者可以建议用户把这篇报告给维护者补规则,或在校园网下下载。 |
95
95
  | 原因不明(需排查) | `download_failed`、`download_timeout`、`login_not_reached`(程序没进入学校登录页)、`login_required`、`source_exception`、`browser_unresponsive`、`pdf_identity_unverified`、`pdf_identity_mismatch`、`pdf_wrong_article` 等 | 不说成没有权限;说明原因待查,给出汇总里的“停在哪一步”和诊断文件位置。 |
96
96
 
97
97
  `pdf_identity_unverified` / `pdf_identity_mismatch`:不能报成功,`review.path` 只是待核查的文件。
98
98
 
99
+ ## 学校登录中途失效、接着下
100
+
101
+ - 批量下载中,一家出版社前面的篇目经学校登录下到了,之后有一篇停在学校自己的登录页、没有完成登录(登录过期;跳转卡住、网络慢、人机验证这类没到学校登录页的失败都不算),程序把这家出版社的篇目暂停:PDF 和补充材料都先不下,其他出版社照常下载。收起的进度窗口在进度旁挂“已暂停 N 篇”,展开后有“学校登录中途失败,已暂停 N 篇”和“登录并继续”;用户随时可以点,其他篇目还在下载时也行,这一篇下完暂停的篇目就接着下,需要时会打开学校登录页。其他篇目都完成后,整批一直等用户点“登录并继续”或“终止”;这时命令还在运行,告诉用户回到进度窗口处理,不要另开下载。终止后这些篇目记为 `login_paused`。
102
+ - 用户说“接着下”“继续下载”“重试失败的”时,不要自己从失败列表里挑 DOI,运行:
103
+
104
+ ```bash
105
+ paper-search run download_batch --json-args '{"resume":"latest"}'
106
+ ```
107
+
108
+ 它读上一批的运行记录:没下到的篇目按原来的内容重下,PDF 已有但补充材料没下全的只补补充材料,都放进原来那批的下载文件夹。要接着下更早的一批,把 `latest` 换成 `paper-search failures` 给出的运行 ID。原来那批设过环境变量(如 `XDG_DATA_HOME`,换学校的单独数据目录)时,用同样的环境变量运行。
109
+
99
110
  ## 导出失败记录
100
111
 
101
112
  ```bash