papersearch 0.7.2 → 0.7.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.
Files changed (60) hide show
  1. package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
  2. package/dist/capabilities/download/batch/batch.js +297 -14
  3. package/dist/capabilities/download/batch/batch.js.map +1 -1
  4. package/dist/capabilities/download/batch/batchFolder.js +1 -1
  5. package/dist/capabilities/download/batch/batchFolder.js.map +1 -1
  6. package/dist/capabilities/download/batch/batchSummary.js +1 -1
  7. package/dist/capabilities/download/batch/batchSummary.js.map +1 -1
  8. package/dist/capabilities/download/batch/networkLoss.d.ts +1 -1
  9. package/dist/capabilities/download/batch/networkLoss.js +1 -1
  10. package/dist/capabilities/download/content/markdown/shortfall.js +5 -5
  11. package/dist/capabilities/download/content/markdown/shortfall.js.map +1 -1
  12. package/dist/infrastructure/runlog/failureClass.d.ts +16 -9
  13. package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
  14. package/dist/infrastructure/runlog/failureClass.js +64 -54
  15. package/dist/infrastructure/runlog/failureClass.js.map +1 -1
  16. package/dist/infrastructure/school/SchoolAttempt.d.ts.map +1 -1
  17. package/dist/infrastructure/school/SchoolAttempt.js +61 -56
  18. package/dist/infrastructure/school/SchoolAttempt.js.map +1 -1
  19. package/dist/infrastructure/school/SchoolMcpClient.d.ts +6 -2
  20. package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
  21. package/dist/infrastructure/school/SchoolMcpClient.js +14 -3
  22. package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
  23. package/dist/infrastructure/school/index.d.ts +1 -1
  24. package/dist/infrastructure/school/index.d.ts.map +1 -1
  25. package/dist/infrastructure/school/types.d.ts +10 -3
  26. package/dist/infrastructure/school/types.d.ts.map +1 -1
  27. package/dist/management/failures/index.d.ts +5 -2
  28. package/dist/management/failures/index.d.ts.map +1 -1
  29. package/dist/management/failures/index.js +21 -4
  30. package/dist/management/failures/index.js.map +1 -1
  31. package/package.json +1 -1
  32. package/school/paper_search_school/adapters/base.py +4 -0
  33. package/school/paper_search_school/adapters/oup/__init__.py +20 -0
  34. package/school/paper_search_school/adapters/sage/__init__.py +4 -1
  35. package/school/paper_search_school/adapters/taylor_francis/__init__.py +3 -0
  36. package/school/paper_search_school/adapters/thieme/__init__.py +4 -2
  37. package/school/paper_search_school/assets/capsule.html +125 -49
  38. package/school/paper_search_school/assets/capsule_en.json +32 -54
  39. package/school/paper_search_school/assets/capsule_fr.json +32 -54
  40. package/school/paper_search_school/assets/capsule_ja.json +32 -54
  41. package/school/paper_search_school/assets/capsule_ko.json +32 -54
  42. package/school/paper_search_school/assets/capsule_zh-Hant.json +27 -53
  43. package/school/paper_search_school/cold_start.py +22 -11
  44. package/school/paper_search_school/engine/access_rules.py +3 -2
  45. package/school/paper_search_school/engine/batch.py +12 -4
  46. package/school/paper_search_school/engine/batch_access.py +21 -9
  47. package/school/paper_search_school/engine/batch_capture.py +1 -1
  48. package/school/paper_search_school/engine/batch_institution.py +130 -29
  49. package/school/paper_search_school/engine/bridge.py +16 -3
  50. package/school/paper_search_school/engine/router.py +2 -1
  51. package/school/paper_search_school/orchestrator.py +44 -18
  52. package/school/paper_search_school/progress_reporter.py +17 -8
  53. package/school/paper_search_school/progress_view.py +1 -1
  54. package/school/paper_search_school/publishers/builtin/sage.json +4 -2
  55. package/school/paper_search_school/publishers/builtin/thieme.json +3 -1
  56. package/school/paper_search_school/school_switch.py +34 -52
  57. package/school/paper_search_school/server.py +10 -8
  58. package/skills/paper-search/SKILL.md +1 -1
  59. package/skills/paper-search/references/browser-download.md +7 -9
  60. package/skills/paper-search/references/publisher-support.md +2 -2
@@ -1,11 +1,13 @@
1
1
  """没权限时换下一所学校 (PaperSearch Pro; user, 2026-11-21).
2
2
 
3
- An article the school signed in to but has no access to (its publisher says so) is tried with the next saved school:
3
+ A paper the school has no access to, failed under 没权限 (signed in and refused, the school's sign-in not enabled for
4
+ the publisher, no route for it there, or marked by the user as without access), is tried with the next saved school:
4
5
  one Pro fills the sign-in of, its account saved and its auto sign-in on; the default school first, then the list's
5
- order. A journal one of them got is remembered for the rest of the download task (a batch; a single download is a task
6
- of its own) and tried with it first; a task starts again from the default school. Only "no access" switches: a sign-in
7
- that failed (a wrong password, a code to type, a page that stopped it) is the user's to see, not another account's.
8
- Each switch forgets the sign-in before it (cold_start.before_sign_in), the batch's browser closed first to let go of it.
6
+ order. A download on its own switches at once. A batch switches once at its end (download/batch/batch.ts): its papers
7
+ all with the default school, then those without access together with the next school, and so on (user, 2026-11-22:
8
+ switching to and fro at each paper had a school's login ask for a picture code). Only 没权限 switches: a sign-in that
9
+ failed (a wrong password, a code to type, a page that stopped it) is the user's to see, not another account's. Each
10
+ switch forgets the sign-in before it (cold_start.before_sign_in), the batch's browser closed first to let go of it.
9
11
  """
10
12
  from __future__ import annotations
11
13
 
@@ -14,8 +16,15 @@ from typing import Any
14
16
  #: The switch on the sign-in page (config), on unless turned off.
15
17
  SETTING = "school_switch"
16
18
 
17
- #: (task, journal) -> the entityID of the school that got the journal's article in that task.
18
- _GOT: dict[tuple[str, str], str] = {}
19
+ #: 没权限 besides a refusal after the sign-in (failureClass.ts): the school's sign-in not enabled for the publisher (IEEE
20
+ #: "Your institution may not be enabled", AHA's OpenAthens "restricted by your organization"), the publisher with no route
21
+ #: for it, or the user's mark, made with the default school. Another school may have it (user, 2026-11-22: IEEE was not
22
+ #: tried with the second school; every paper under 没权限 is).
23
+ NOT_THIS_SCHOOL = ("institution_not_registered", "institution_federation_unavailable", "no_entitlement")
24
+
25
+ #: Set on a download's config when its school is not the default one: the user's 没权限 marks were made with the
26
+ #: default school and do not skip another's visit (engine/bridge.py).
27
+ MARKS_OFF = "no_access_marks_off"
19
28
 
20
29
 
21
30
  def enabled(config: dict[str, Any]) -> bool:
@@ -23,9 +32,24 @@ def enabled(config: dict[str, Any]) -> bool:
23
32
 
24
33
 
25
34
  def no_access(result: dict[str, Any] | None) -> bool:
26
- """Signed in, and the publisher has no access for the school to this article (not a sign-in that failed)."""
27
- return bool(result) and not result.get("success") and result.get("error_type") == "paywall" \
28
- and result.get("reason_code") == "institution_pdf_entitlement_missing"
35
+ """The school has no access to this article, a 没权限 failure (not a sign-in that failed)."""
36
+ if not result or result.get("success"):
37
+ return False
38
+ if result.get("error_type") in NOT_THIS_SCHOOL:
39
+ return True
40
+ return result.get("error_type") == "paywall" and result.get("reason_code") == "institution_pdf_entitlement_missing"
41
+
42
+
43
+ #: A failure after one of the school's entries by one name, its next entry to be tried (user, 2026-11-22: "同名学校的话,
44
+ #: 那就直接选一个……如果这个不行的话,再向下一个"): 没权限, or the login not reached or not finished (JAMA's first
45
+ #: entry of a test school was its library proxy, whose sign-in asks for a picture code).
46
+ ENTRY_DID_NOT_DO = ("login_not_reached", "login_timeout", "idp_no_return_to_publisher")
47
+
48
+
49
+ def entry_did_not_do(result: dict[str, Any] | None) -> bool:
50
+ """The download failed after one of several entries by the school's name: the next one may do."""
51
+ return bool(result) and not result.get("success") and int(result.get("same_name_entries") or 0) > 1 and (
52
+ no_access(result) or result.get("error_type") in ENTRY_DID_NOT_DO)
29
53
 
30
54
 
31
55
  def schools(config: dict[str, Any]) -> list[dict[str, Any]]:
@@ -56,47 +80,5 @@ def grouping(config: dict[str, Any]) -> bool:
56
80
  return enabled(config) and len(schools(config)) > 1
57
81
 
58
82
 
59
- def _task() -> str:
60
- from . import progress_reporter
61
-
62
- return progress_reporter.batch_id()
63
-
64
-
65
- def journal(doi: str) -> str:
66
- """The journal's key: its ISSNs (Crossref, kept), else its title; "" when not known."""
67
- from .entitlements import journal_identity
68
-
69
- try:
70
- identity = journal_identity(doi)
71
- except Exception:
72
- return ""
73
- issns = identity.get("issn") or []
74
- return "issn:" + ",".join(sorted(issns)) if issns else str(identity.get("journal") or "").strip().lower()
75
-
76
-
77
- def remembered(doi: str) -> str:
78
- """The school (entityID) that got this article's journal earlier in this task; "" when none or not in a task."""
79
- task = _task()
80
- key = journal(doi) if task else ""
81
- return _GOT.get((task, key), "") if key else ""
82
-
83
-
84
- def remember(doi: str, entity: str) -> None:
85
- task = _task()
86
- key = journal(doi) if task and entity else ""
87
- if key:
88
- _GOT[(task, key)] = entity
89
-
90
-
91
- def order_for(config: dict[str, Any], doi: str) -> list[dict[str, Any]]:
92
- """The schools to try for this article, in turn: its journal's school of this task first, then the default one
93
- and the rest."""
94
- listed = schools(config)
95
- if len(listed) < 2:
96
- return listed # nothing to switch to: no journal looked up
97
- first = remembered(doi)
98
- return sorted(listed, key=lambda entry: str(entry.get("idp_entity_id") or "").strip() != first) if first else listed
99
-
100
-
101
83
  def name(entry: dict[str, Any]) -> str:
102
84
  return str(entry.get("school_name") or entry.get("school_name_en") or entry.get("idp_entity_id") or "")
@@ -244,15 +244,18 @@ async def school_keep_session() -> str:
244
244
 
245
245
  @mcp_app.tool()
246
246
  def school_switch_state() -> str:
247
- """Whether a batch takes one journal's papers one after another (没权限时换下一所学校, school_switch.py): the switch
248
- on and more than one school taking part, so that a school switched to for a journal is not switched away from and
249
- back. Opens no browser. Answers {"on": bool, "schools": n, "group": bool}."""
247
+ """The schools a batch's papers without access (没权限) are tried with at its end, one after another
248
+ (没权限时换下一所学校, school_switch.py): the default one first, each named as ``school_download``'s ``school``
249
+ takes it (its entityID); none while the switch is off; and whether the batch takes one journal's papers one after
250
+ another (``group``: on and more than one school). Opens no browser. Answers
251
+ {"on": bool, "schools": [{"name": ..., "entity_id": ...}, ...], "group": bool}."""
250
252
  from . import school_switch
251
253
 
252
254
  config = load_config()
253
- count = len(school_switch.schools(config))
254
255
  on = school_switch.enabled(config)
255
- return json.dumps({"on": on, "schools": count, "group": on and count > 1})
256
+ schools = [{"name": school_switch.name(entry), "entity_id": str(entry.get("idp_entity_id") or "").strip()}
257
+ for entry in school_switch.schools(config)] if on else []
258
+ return json.dumps({"on": on, "schools": schools, "group": on and len(schools) > 1}, ensure_ascii=False)
256
259
 
257
260
 
258
261
  @mcp_app.tool()
@@ -334,9 +337,8 @@ def school_batch_papers(batch_id: str, folder: str, papers: list[dict[str, Any]]
334
337
  doi, title, journal, state ("open": open access not checked yet, "school": waiting
335
338
  for or in the institutional download, "ok", "failed"); a saved one adds via
336
339
  (开放下载 or 机构下载), detail (出版社 API, Sci-Hub, 预印本) and path (the PDF,
337
- absolute); a failed one cls (no_access, user_side, school_side, publisher_or_network,
338
- article_or_site, unsupported, unexplained)
339
- and reason}]. folder: the batch's download folder (absolute); the window opens
340
+ absolute); a failed one cls (no_access, user_side, external, unsupported, unexplained; the
341
+ classes before 2026-11-22 are taken as these) and reason}]. folder: the batch's download folder (absolute); the window opens
340
342
  a PDF only from inside it. Never touches the running download's progress.
341
343
  """
342
344
  from . import progress_reporter
@@ -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.7.2"
7
+ version: "0.7.3"
8
8
  ---
9
9
 
10
10
  # 文献检索与下载(paper-search)
@@ -86,17 +86,15 @@ SCHOOL_DATA_DIR="<数据目录>" paper-search-school preview --run-id "<本次 r
86
86
  paper-search failures --format text
87
87
  ```
88
88
 
89
- (默认最近一批;`--since YYYY-MM-DD`、`--runs N`、`--all`)。它把失败分成七类;向用户说明时按类别说:
89
+ (默认最近一批;`--since YYYY-MM-DD`、`--runs N`、`--all`)。它把失败分成五类,每种原因有固定的说法(进度窗口、批量最后一行和汇总里都一样);向用户说明时用这些类名和说法,不另起说法:
90
90
 
91
- | 类别 | 常见 code | 怎么说、怎么做 |
91
+ | 类别 | 说法(常见 code) | 怎么说、怎么做 |
92
92
  | --- | --- | --- |
93
- | 没权限(有依据) | `entitlement_missing`、`institution_federation_unavailable`、`institution_not_registered`(学校的这个登录入口和这家出版社之间没有开通)、`no_entitlement` | 附上汇总里的依据(页面原话或决定性的一步)。只说本篇、当前学校没有权限,不推断整个平台。出版社没有学校所在联盟的登录路线、或学校的这个入口和出版社之间没有开通时,不说成学校没有订阅,建议在校园网或学校 VPN 下下载。 |
94
- | 你这边 | `login_timeout`(停在学校登录页,没在等待时间内登录完)、`login_page_closed`、`browser_closed`、`user_skipped`、`cancelled`、`batch_stopped`、`profile_busy`(另一个下载任务正占着下载浏览器) | 说明需要用户做什么(登录、等另一个任务结束),原调用结束、资源释放后再决定是否重试;不连续重新提交登录。 |
95
- | 学校那边 | `login_credentials_rejected`、`idp_login_error`、`idp_account_locked`、`idp_password_expired`、`idp_no_return_to_publisher`(学校登录后停在学校自己的网站,没回到出版社)、`login_paused`(这家出版社的学校登录在本批中途失效,这篇暂停、没试;不代表没有权限) | 说明是学校登录这一步的问题;账号锁定、密码过期请用户联系学校;中途失效的请用户重新登录后说“接着下”。 |
96
- | 出版社或网络 | `access_blocked`、`cloudflare_blocked`、`captcha_required`、`publisher_content_error`、`publisher_unreachable`、`network_unavailable`(网络中断:doi.org 和 PubMed 都连不上,不是 DOI 不存在;批量下载会等网络恢复后重下,单篇联网后再试)、`rate_limited` | 说明是出版社网站或网络的问题;建议稍后再试、换网络,或在校园网或学校 VPN 下下载。 |
97
- | 文章或网站本身 | `article_not_yet_published`(论文已录用,出版社还没上线全文)、`doi_not_resolved`(doi.org 还查不到这个 DOI,常见于刚上线几天的文章;过几天再下)、`doi_not_registered`(文章已发表一个多月,DOI 从没在 doi.org 登记,PubMed 也没有出版社的其他链接;重下也查不到,请用户在出版社网站按标题找到后自己下载)、`no_institution_entry`(网站没有学校登录入口:只有网站自己的个人账户登录,或是开放获取的网站;程序没有去登录。开放获取的文章到网站上直接下载,订阅内容在校园网或学校 VPN 下下载) | 说明是文章或网站本身的情况,不说成没有权限,也不说成程序出错。 |
98
- | 暂不支持的网站 | `unsupported_platform`(如只在 ClinicalKey 上的内容)、`unsupported_publisher`(DOI 没有指向能登录的出版社网站,没有打开浏览器)、`generic_institution_entry_missing`(这家出版社还没有专门的规则,按通用规则没找到机构登录入口) | 说明这类网站还不支持,不说成没有权限;后者可以建议用户把这篇报告给维护者补规则,或在校园网下下载。 |
99
- | 原因不明(需排查) | `download_failed`、`download_timeout`、`login_not_reached`(程序没进入学校登录页)、`login_required`、`source_exception`、`browser_unresponsive`、`browser_connection_lost`(浏览器连接断了,批量已换新浏览器)、`pdf_identity_unverified`、`pdf_identity_mismatch`、`pdf_wrong_article` 等 | 不说成没有权限;说明原因待查,给出汇总里的“停在哪一步”和诊断文件位置。 |
93
+ | 没权限 | 学校没有订阅(`entitlement_missing`);出版社没开通本校(`institution_federation_unavailable`、`institution_not_registered`);你标记过没权限(`no_entitlement`);换过学校的写“N 所学校都没有权限” | 附上汇总里的依据(页面原话或决定性的一步)。只说本篇、这几所学校用不了,不推断整个平台;出版社没开通本校时不说成学校没有订阅,建议在校园网或学校 VPN 下下载。批量已在最后换过保存的其他学校。 |
94
+ | 要你处理 | 等你登录超时;你跳过或终止了;浏览器被关闭;浏览器被占用;密码被学校拒绝;账号被锁或密码过期 | 说明需要用户做什么(登录、等另一个任务结束、在设置里更新密码、按学校说明解锁),处理后说“接着下”;不连续重新提交登录。 |
95
+ | 外部原因 | 被网站拦截;出版社网站出错;学校登录系统出错;学校登录中途失效;网络中断;达到每小时下载上限;全文还没上线;DOI 查不到;网站没有学校登录 | 说明是对方的问题,不说成没有权限,也不说成程序出错;建议过会儿说“接着下”,或换网络、在校园网或学校 VPN 下下载。全文还没上线的等正式发表;DOI 查不到的过几天再试,一直查不到的请用户在出版社网站按标题自己下载;网站没有学校登录的,开放获取的文章到网站上直接下载。 |
96
+ | 暂不支持 | 只在其他平台提供;网站暂未适配;附录暂未适配 | 说明这个网站 PaperSearch 还没适配,不说成没有权限;给出汇总里的诊断文件和截图位置,建议用 `paper-search failures --export <文件.zip>` 导出记录发给维护者,急用可在校园网下自己下载。 |
97
+ | 原因不明 | 没取到 PDF;拿错 PDF;没法确认 PDF;页面或浏览器卡住;没进入学校登录页;文章页没存下来 | 不说成没有权限;批量已在最后用同一所学校再试过一次。说明原因待查,给出汇总里的“停在哪一步”和诊断文件位置。 |
100
98
 
101
99
  `pdf_identity_unverified` / `pdf_identity_mismatch`:不能报成功,`review.path` 只是待核查的文件。
102
100
 
@@ -60,7 +60,7 @@ DOI 跳转到表外的网站时,程序按通用规则尝试:找机构登录
60
60
  | 机构列表里没有 CARSI | AACR(aacrjournals.org) |
61
61
  | 找不到机构登录入口(`generic_institution_entry_missing`) | Emerald(emerald.com) |
62
62
 
63
- `generic_institution_entry_missing` 归“暂不支持的网站”:告诉用户这类网站还没有规则,可以把这篇报告给维护者补规则,或在校园网下下载。
63
+ `generic_institution_entry_missing` 归“暂不支持”(说法“网站暂未适配”):告诉用户这类网站还没有规则,可以把这篇报告给维护者补规则,或在校园网下下载。
64
64
 
65
65
  ## 不支持的平台
66
66
 
@@ -70,7 +70,7 @@ DOI 跳转到表外的网站时,程序按通用规则尝试:找机构登录
70
70
 
71
71
  这些结果说明的是“用户学校在这家出版社的情况”,不是程序故障:
72
72
 
73
- - `institution_federation_unavailable`:出版社的机构列表里找不到用户学校所属的联盟或这所学校,即这家出版社没有这所学校的登录路线。AMS(journals.ametsoc.org)只有会员登录、机构靠学校网络地址访问,也按这条结束。程序立即结束;建议在校园网或学校 VPN 下下载。
73
+ - `institution_federation_unavailable`:出版社的机构列表里找不到用户学校所属的联盟或这所学校,即这家出版社没开通本校路线。AMS(journals.ametsoc.org)只有会员登录、机构靠学校网络地址访问,也按这条结束。程序立即结束;建议在校园网或学校 VPN 下下载。
74
74
  - `institution_not_registered`:学校的这个登录入口和这家出版社之间没有开通(出版社或学校的登录系统这样说),经这个入口没有权限,归入“没权限”;学校的其他入口、校园网或 VPN 可能仍可访问,不把它当作学校没有论文订阅。
75
75
  - `idp_no_return_to_publisher`:学校登录后停在学校自己的网站,没回到出版社,通常也是学校没开通。
76
76
  - `entitlement_missing`:出版社认出了学校,判定本篇不在订阅内。只说本篇、当前学校没有权限,不推断整个出版社。