papersearch 0.7.3 → 0.8.0

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 (170) hide show
  1. package/LICENSE-paper-search-mcp-nodejs +24 -0
  2. package/NOTICE +8 -37
  3. package/README.en.md +7 -3
  4. package/README.fr.md +268 -0
  5. package/README.ja.md +268 -0
  6. package/README.ko.md +268 -0
  7. package/README.md +7 -3
  8. package/README.zh-Hant.md +268 -0
  9. package/dist/capabilities/download/batch/batch.d.ts +16 -1
  10. package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
  11. package/dist/capabilities/download/batch/batch.js +389 -56
  12. package/dist/capabilities/download/batch/batch.js.map +1 -1
  13. package/dist/capabilities/download/batch/batchFolder.d.ts.map +1 -1
  14. package/dist/capabilities/download/batch/batchFolder.js +3 -2
  15. package/dist/capabilities/download/batch/batchFolder.js.map +1 -1
  16. package/dist/capabilities/download/batch/networkLoss.d.ts +11 -2
  17. package/dist/capabilities/download/batch/networkLoss.d.ts.map +1 -1
  18. package/dist/capabilities/download/batch/networkLoss.js +24 -3
  19. package/dist/capabilities/download/batch/networkLoss.js.map +1 -1
  20. package/dist/capabilities/download/batch/resume.d.ts +7 -0
  21. package/dist/capabilities/download/batch/resume.d.ts.map +1 -1
  22. package/dist/capabilities/download/batch/resume.js +50 -9
  23. package/dist/capabilities/download/batch/resume.js.map +1 -1
  24. package/dist/capabilities/download/content/markdown/pro.d.ts +6 -0
  25. package/dist/capabilities/download/content/markdown/pro.d.ts.map +1 -1
  26. package/dist/capabilities/download/content/markdown/pro.js.map +1 -1
  27. package/dist/capabilities/download/content/markdown/shortfall.d.ts +8 -5
  28. package/dist/capabilities/download/content/markdown/shortfall.d.ts.map +1 -1
  29. package/dist/capabilities/download/content/markdown/shortfall.js +22 -10
  30. package/dist/capabilities/download/content/markdown/shortfall.js.map +1 -1
  31. package/dist/capabilities/download/content/markdown/step.d.ts +9 -0
  32. package/dist/capabilities/download/content/markdown/step.d.ts.map +1 -1
  33. package/dist/capabilities/download/content/markdown/step.js +42 -2
  34. package/dist/capabilities/download/content/markdown/step.js.map +1 -1
  35. package/dist/capabilities/download/content/markdown/types.d.ts +10 -1
  36. package/dist/capabilities/download/content/markdown/types.d.ts.map +1 -1
  37. package/dist/capabilities/download/handler.d.ts.map +1 -1
  38. package/dist/capabilities/download/handler.js +13 -5
  39. package/dist/capabilities/download/handler.js.map +1 -1
  40. package/dist/capabilities/download/outputLayout.d.ts.map +1 -1
  41. package/dist/capabilities/download/outputLayout.js +3 -1
  42. package/dist/capabilities/download/outputLayout.js.map +1 -1
  43. package/dist/capabilities/download/tools.js +2 -2
  44. package/dist/capabilities/download/tools.js.map +1 -1
  45. package/dist/capabilities/download/types.d.ts +9 -1
  46. package/dist/capabilities/download/types.d.ts.map +1 -1
  47. package/dist/cli.js +3 -1
  48. package/dist/cli.js.map +1 -1
  49. package/dist/infrastructure/runlog/RunLedger.d.ts +7 -0
  50. package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
  51. package/dist/infrastructure/runlog/RunLedger.js +13 -0
  52. package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
  53. package/dist/infrastructure/runlog/failureClass.d.ts +2 -1
  54. package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
  55. package/dist/infrastructure/runlog/failureClass.js +27 -4
  56. package/dist/infrastructure/runlog/failureClass.js.map +1 -1
  57. package/dist/infrastructure/school/SchoolAttempt.d.ts +11 -0
  58. package/dist/infrastructure/school/SchoolAttempt.d.ts.map +1 -1
  59. package/dist/infrastructure/school/SchoolAttempt.js +48 -5
  60. package/dist/infrastructure/school/SchoolAttempt.js.map +1 -1
  61. package/dist/infrastructure/school/SchoolMcpClient.d.ts +1 -0
  62. package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
  63. package/dist/infrastructure/school/SchoolMcpClient.js +18 -6
  64. package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
  65. package/dist/infrastructure/school/SchoolProgress.d.ts +2 -0
  66. package/dist/infrastructure/school/SchoolProgress.d.ts.map +1 -1
  67. package/dist/infrastructure/school/SchoolProgress.js +2 -0
  68. package/dist/infrastructure/school/SchoolProgress.js.map +1 -1
  69. package/dist/infrastructure/school/SchoolReadiness.d.ts +2 -0
  70. package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
  71. package/dist/infrastructure/school/SchoolReadiness.js +2 -0
  72. package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
  73. package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -1
  74. package/dist/infrastructure/school/SchoolResultNormalizer.js +4 -0
  75. package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -1
  76. package/dist/infrastructure/school/index.d.ts +2 -2
  77. package/dist/infrastructure/school/index.d.ts.map +1 -1
  78. package/dist/infrastructure/school/index.js +1 -1
  79. package/dist/infrastructure/school/index.js.map +1 -1
  80. package/dist/infrastructure/school/types.d.ts +42 -0
  81. package/dist/infrastructure/school/types.d.ts.map +1 -1
  82. package/dist/infrastructure/school/types.js.map +1 -1
  83. package/dist/management/failures/index.d.ts +23 -0
  84. package/dist/management/failures/index.d.ts.map +1 -1
  85. package/dist/management/failures/index.js +63 -18
  86. package/dist/management/failures/index.js.map +1 -1
  87. package/package.json +7 -2
  88. package/school/NOTICE +3 -2
  89. package/school/paper_search_school/adapters/__init__.py +2 -0
  90. package/school/paper_search_school/adapters/aps/__init__.py +3 -6
  91. package/school/paper_search_school/adapters/base.py +16 -2
  92. package/school/paper_search_school/adapters/copernicus/__init__.py +2 -7
  93. package/school/paper_search_school/adapters/elsevier/__init__.py +50 -1
  94. package/school/paper_search_school/adapters/frontiers/__init__.py +41 -2
  95. package/school/paper_search_school/adapters/ieee/__init__.py +6 -4
  96. package/school/paper_search_school/adapters/iop/__init__.py +8 -0
  97. package/school/paper_search_school/adapters/jama/__init__.py +8 -0
  98. package/school/paper_search_school/adapters/lww/__init__.py +14 -6
  99. package/school/paper_search_school/adapters/mdpi/__init__.py +12 -7
  100. package/school/paper_search_school/adapters/neurology/__init__.py +5 -2
  101. package/school/paper_search_school/adapters/optica/__init__.py +2 -9
  102. package/school/paper_search_school/adapters/oup/__init__.py +7 -4
  103. package/school/paper_search_school/adapters/platforms/__init__.py +4 -1
  104. package/school/paper_search_school/adapters/platforms/atypon/__init__.py +8 -0
  105. package/school/paper_search_school/adapters/platforms/jstage/__init__.py +64 -0
  106. package/school/paper_search_school/adapters/taylor_francis/__init__.py +0 -3
  107. package/school/paper_search_school/adapters/thieme/__init__.py +2 -9
  108. package/school/paper_search_school/api_keys.py +63 -13
  109. package/school/paper_search_school/assets/api_keys.json +14 -0
  110. package/school/paper_search_school/assets/capsule.html +156 -116
  111. package/school/paper_search_school/assets/capsule_en.json +69 -46
  112. package/school/paper_search_school/assets/capsule_fr.json +70 -47
  113. package/school/paper_search_school/assets/capsule_ja.json +69 -46
  114. package/school/paper_search_school/assets/capsule_ko.json +69 -46
  115. package/school/paper_search_school/assets/capsule_zh-Hant.json +68 -45
  116. package/school/paper_search_school/browser/batch_session.py +1 -1
  117. package/school/paper_search_school/browser/challenge/__init__.py +12 -9
  118. package/school/paper_search_school/browser/challenge/continuation.py +65 -0
  119. package/school/paper_search_school/browser/challenge/handlers/__init__.py +1 -0
  120. package/school/paper_search_school/browser/challenge/handlers/aws_waf.py +260 -0
  121. package/school/paper_search_school/browser/challenge/handlers/recaptcha_hcaptcha.py +167 -0
  122. package/school/paper_search_school/browser/challenge/handlers/text_captcha.py +100 -0
  123. package/school/paper_search_school/browser/challenge/handlers/turnstile.py +174 -0
  124. package/school/paper_search_school/browser/challenge/kinds.py +203 -0
  125. package/school/paper_search_school/browser/challenge/local/__init__.py +1 -0
  126. package/school/paper_search_school/browser/challenge/{interaction.py → local/interaction.py} +94 -13
  127. package/school/paper_search_school/browser/challenge/{pointer.py → local/pointer.py} +2 -2
  128. package/school/paper_search_school/browser/challenge/local/prompt.py +283 -0
  129. package/school/paper_search_school/browser/challenge/local/submission.py +33 -0
  130. package/school/paper_search_school/browser/challenge/services/__init__.py +1 -0
  131. package/school/paper_search_school/browser/challenge/services/solver.py +272 -0
  132. package/school/paper_search_school/cli_config.py +10 -5
  133. package/school/paper_search_school/config.py +11 -10
  134. package/school/paper_search_school/download_diagnostics.py +7 -2
  135. package/school/paper_search_school/engine/access_rules.py +12 -3
  136. package/school/paper_search_school/engine/batch.py +43 -11
  137. package/school/paper_search_school/engine/batch_access.py +38 -12
  138. package/school/paper_search_school/engine/batch_capture.py +215 -18
  139. package/school/paper_search_school/engine/batch_common.py +3 -0
  140. package/school/paper_search_school/engine/batch_diagnostics.py +25 -5
  141. package/school/paper_search_school/engine/batch_institution.py +38 -3
  142. package/school/paper_search_school/engine/batch_login.py +223 -16
  143. package/school/paper_search_school/engine/batch_pdf_urls.py +38 -7
  144. package/school/paper_search_school/engine/batch_waits.py +179 -12
  145. package/school/paper_search_school/engine/bridge.py +28 -4
  146. package/school/paper_search_school/engine/fulltext_page.py +45 -7
  147. package/school/paper_search_school/engine/router.py +16 -1
  148. package/school/paper_search_school/entitlements.py +1 -1
  149. package/school/paper_search_school/pdf_utils.py +25 -16
  150. package/school/paper_search_school/progress_capsule.py +36 -6
  151. package/school/paper_search_school/progress_reporter.py +54 -5
  152. package/school/paper_search_school/progress_view.py +63 -43
  153. package/school/paper_search_school/publishers/builtin/iop.json +2 -1
  154. package/school/paper_search_school/publishers/builtin/neurology.json +4 -2
  155. package/school/paper_search_school/publishers/site.py +12 -4
  156. package/school/paper_search_school/school_test.py +1 -1
  157. package/school/paper_search_school/server.py +17 -6
  158. package/school/paper_search_school/user_settings.py +13 -0
  159. package/school/pyproject.toml +1 -0
  160. package/skills/paper-search/SKILL.md +107 -107
  161. package/skills/paper-search/references/browser-download.md +102 -99
  162. package/skills/paper-search/references/capability-routing.md +89 -89
  163. package/skills/paper-search/references/cli-contract.md +78 -78
  164. package/skills/paper-search/references/federation-support.md +172 -172
  165. package/skills/paper-search/references/management-layer.md +78 -78
  166. package/skills/paper-search/references/publisher-support.md +38 -38
  167. package/skills/paper-search/references/school-setup.md +56 -55
  168. package/skills/paper-search/references/setup.md +20 -20
  169. package/skills/paper-search/references/troubleshooting.md +12 -12
  170. package/school/paper_search_school/browser/challenge/prompt.py +0 -154
@@ -1,100 +1,101 @@
1
- # 机构下载:安装扩展、配置学校、选择浏览器
1
+ # School download: install the extension, set the school, choose the browser
2
2
 
3
- 学校订阅下载(经学校所属的学术身份联盟或 OpenAthens 登录)让 PaperSearch 用用户学校的权限,在浏览器里下载需要订阅的论文。在有图形界面的电脑上,用户同意后才装:用户说“请开始配置”或第一次要下订阅文章时问一次;用户说过不要(`PAPER_SEARCH_SCHOOL_DECLINED=true`)或没有图形界面的服务器上不装、不问。检索和开放下载不需要它。
3
+ School subscription downloads (signing in through the school's academic identity federation or OpenAthens) let PaperSearch use the user's school access to download subscription papers in a browser. On a computer with a graphical interface it is installed only after the user agrees: ask once when the user says "start setup" or first wants a subscription article; when the user said no (`PAPER_SEARCH_SCHOOL_DECLINED=true`), or on a server without a graphical interface, do not install it and do not ask. Search and open download do not need it.
4
4
 
5
- ## 查看与安装
5
+ ## Check and install
6
6
 
7
7
  ```bash
8
8
  paper-search school status --format text
9
9
  ```
10
10
 
11
- 显示是否已装、安装目录、所用浏览器(Google Chrome 的路径和版本、驱动版本)、学校、PaperSearch 是否已启用它。Chrome 低于测试过的版本时会提示先更新 Chrome。
11
+ Shows whether it is installed, the install directory, the browser used (Google Chrome's path and version, the driver version), the school, and whether PaperSearch has it enabled. When Chrome is older than the tested version, it says to update Chrome first.
12
12
 
13
- 用户同意后运行(Agent 代装时加 `--yes --skip-school`):
13
+ After the user agrees, run (when the agent installs it for the user, add `--yes --skip-school`):
14
14
 
15
15
  ```bash
16
16
  paper-search school install
17
17
  ```
18
18
 
19
- - 需要图形界面:学校登录要在看得见的浏览器里完成。没有图形界面的 Linux(服务器,没有 `DISPLAY` 或 `WAYLAND_DISPLAY`)上安装会在第一步停下,`paper-search setup` 也不再问是否安装;这类机器用 `paper-search setup <KEY>` 配 key,检索和开放获取下载照常可用。
20
- - 需要本机已装 Google Chrome;没有时安装会停下。这时告诉用户要先装 Chrome,用户同意后替用户装:macOS 有 Homebrew 时运行 `brew install --cask google-chrome`,Windows 运行 `winget install -e --id Google.Chrome`;装好后再运行同一条 `school install`。没有 Homebrew 或 winget、或安装失败时,请用户从 https://www.google.com/chrome/ 下载安装。`--browser ego` 改用用户自己的 ego lite(仅 macOS)。
21
- - 安装前会列出安装位置和下载量(约 0.5 GB,不另下载浏览器),用户确认后才开始。`--yes` 跳过确认,只在用户已经同意后使用。
22
- - 用户不需要先装 Python;中途失败时,处理提示的问题后再运行同一命令,会从失败的那一步接着装。
23
- - 装完会打开设置窗口的 API key 页,用户填好或不需要时点右上角 × 关闭。
24
- - 装完会自动启用(`PAPER_SEARCH_SCHOOL_ENABLED=true`、`PAPER_SEARCH_SCHOOL_EXECUTABLE` 指向新装的后端)。原来配置了别的后端时,会先问用户是否替换。
25
- - 安装时会问学校;`--skip-school` 跳过,之后再配置。
26
- - 首次配置扩展时会询问是否开启系统通知。新配置默认关闭,回车保留当前选择;`--yes` 不代表同意开启通知。Agent 代为配置时先问用户要开启还是关闭,再通过同一后端的 `config set progress_notify true` 或 `false` 保存,已有明确选择不重复询问。以后可在胶囊齿轮 → 等待和提醒里点“系统通知”开关立即修改;关闭不影响琥珀色呼吸和点击唤回浏览器。
27
- - 进度窗口的设置(下载文件夹、等待和提醒、API key):点胶囊齿轮,或运行 `paper-search settings [about|download|wait|keys|<KEY>]`(about:版本和更新)。没有下载时它单独打开窗口,关掉设置窗口就消失。
28
- - `paper-search setup` 最后也会问是否安装扩展;`--skip-school` 不问,`--install-school` 直接安装。
19
+ - Needs a graphical interface: the school login must happen in a visible browser. On Linux without a graphical interface (a server, with no `DISPLAY` or `WAYLAND_DISPLAY`) installation stops at the first step, and `paper-search setup` no longer asks whether to install it; on such machines use `paper-search setup <KEY>` for keys; search and open-access download work as usual.
20
+ - Needs Google Chrome on this computer; without it, installation stops. Then tell the user that Chrome must be installed first; after the user agrees, install it for them: on macOS with Homebrew run `brew install --cask google-chrome`, on Windows run `winget install -e --id Google.Chrome`; then run the same `school install` again. Without Homebrew or winget, or when the installation fails, ask the user to download and install it from https://www.google.com/chrome/. `--browser ego` uses the user's own ego lite instead (macOS only).
21
+ - Before installing, it lists the install location and the download size (about 0.5 GB; no browser is downloaded), and starts only after the user confirms. `--yes` skips the confirmation; use it only after the user has agreed.
22
+ - The user does not need to install Python first; when it fails midway, fix the reported problem and run the same command again: it continues from the step that failed.
23
+ - When done, it opens the settings window on the API key page; the user closes it with the × at the top right after filling it in, or when nothing is needed.
24
+ - In development builds with YesCaptcha, the user enters ClientKey in Settings → API key → YesCaptcha, presses "测试" (Test) to check the balance, then "保存" (Save). Supported challenges send only puzzle images and the question; the local browser applies the answer. School sign-in pages are excluded. The test checks the key, not whether a website will accept an answer.
25
+ - It enables itself when done (`PAPER_SEARCH_SCHOOL_ENABLED=true`, `PAPER_SEARCH_SCHOOL_EXECUTABLE` pointing at the new backend). When another backend was configured, it first asks the user whether to replace it.
26
+ - Installation asks for the school; `--skip-school` skips that, to configure it later.
27
+ - The first time the extension is configured, it asks whether to turn on system notifications. New configurations default to off, and Enter keeps the current choice; `--yes` does not mean consent to turning notifications on. When the agent configures it for the user, first ask the user whether to turn them on or off, then save the answer with the same backend's `config set progress_notify true` or `false`; when there is already a clear choice, do not ask again. Later the user can change it at once with the "系统通知" (Notifications) switch under the capsule's gear → "等待和提醒" (Waits & alerts); turning it off does not affect the amber breathing or clicking to bring back the browser.
28
+ - The progress window's settings (download folder, waits and alerts, API keys): click the capsule's gear, or run `paper-search settings [about|download|wait|keys|<KEY>]` (about: version and updates). When no download is running, it opens a window of its own, which goes away when the settings window is closed.
29
+ - `paper-search setup` also asks at the end whether to install the extension; `--skip-school` does not ask, `--install-school` installs it directly.
29
30
 
30
- 用户自己维护的后端(例如仓库里的开发版)用 `paper-search config set PAPER_SEARCH_SCHOOL_EXECUTABLE <路径>` 指定;不要擅自改用户已配置的路径。
31
+ A backend the user maintains (such as the development build in the repository) is set with `paper-search config set PAPER_SEARCH_SCHOOL_EXECUTABLE <path>`; do not change a path the user configured on your own.
31
32
 
32
- ## 先登录学校(可选)
33
+ ## Sign in to the school first (optional)
33
34
 
34
35
  ```bash
35
- paper-search school login --doi <学校订阅的一篇文章的 DOI>
36
+ paper-search school login --doi <DOI of an article the school subscribes to>
36
37
  ```
37
38
 
38
- - 用在用户想在批量下载前先登录、或想试试登录是否正常时;平时不需要,下载遇到登录会自己停下等用户。
39
- - 它打开下载用的浏览器,自动过网站验证、选学校,停在学校登录页等用户登录(最多等 `browser_login_timeout` 秒,`--max-wait <秒>` 只改这一次);登录后核对这篇文章能看全文,不下载 PDF,登录状态留给之后的下载。
40
- - 只有 `success: true`(`state: signed_in`)才算登录成功。`access_without_login`:这篇不用登录就能看(开放获取或校园网),换一篇需要订阅的文章再试;`login_timeout`、`browser_closed`、`institution_pdf_entitlement_missing` 等按回复里的 `message` 告诉用户。
41
- - 下载浏览器和它的资料目录由程序管理,登录用这条命令或直接下载;不要翻源码另找登录办法。没装学校订阅下载或没配置学校时,按回复里的提示处理。
39
+ - Use it when the user wants to sign in before a batch download, or to try whether sign-in works; normally it is not needed: a download that meets a login stops and waits for the user.
40
+ - It opens the download browser, passes the site checks automatically, chooses the school, and stops at the school login page for the user to sign in (waiting at most `browser_login_timeout` seconds; `--max-wait <seconds>` changes it for this run only); after sign-in it checks that the full text of this article is visible, does not download the PDF, and keeps the sign-in for later downloads.
41
+ - Only `success: true` (`state: signed_in`) means sign-in succeeded. `access_without_login`: this article needs no sign-in (open access or campus network); try again with another article that needs a subscription; for `login_timeout`, `browser_closed`, `institution_pdf_entitlement_missing` and others, tell the user what the reply's `message` says.
42
+ - The program manages the download browser and its profile directory; sign in with this command or simply by downloading; do not dig through the source code for another way to sign in. When school subscription downloads are not installed or no school is configured, follow the hint in the reply.
42
43
 
43
- ## 更新与卸载
44
+ ## Update and uninstall
44
45
 
45
- - PaperSearch 升级后,第一次用到学校订阅下载时会自动做同样的更新(stderr 一行说明);用户关掉了自动更新(`PAPER_SEARCH_SCHOOL_AUTO_UPDATE=false`)或自动更新没成功时,`status` 提示扩展落后,运行 `paper-search school update`:重装后端和依赖,检查 Chrome;学校配置、登录会话、Chrome 和 ego lite 不动。以前用 Camoufox 的安装会改用 Chrome,并写明旧 Camoufox 浏览器所在的目录,由用户决定是否手动删除。已是最新时不做任何事;`--force` 强制重装。
46
- - 卸载:`paper-search school uninstall`。先列出要删和保留的内容,用户确认后删除安装目录;PaperSearch 配置指向这次安装的后端时,关闭机构下载并清除后端路径,指向别处时不改。学校配置和登录会话默认保留,会询问;`--yes` 时保留,除非另加 `--remove-data`。Google Chrome 和 ego lite 不受影响。
46
+ - After PaperSearch is upgraded, the first use of school subscription downloads makes the same update automatically (one line on stderr); when the user turned off automatic updates (`PAPER_SEARCH_SCHOOL_AUTO_UPDATE=false`) or the automatic update failed, `status` says the extension is behind; run `paper-search school update`: it reinstalls the backend and dependencies and checks Chrome; the school settings, sign-in sessions, Chrome and ego lite are left alone. An installation that used Camoufox switches to Chrome and states the directory of the old Camoufox browser; the user decides whether to delete it by hand. When it is already up to date it does nothing; `--force` forces a reinstall.
47
+ - Uninstall: `paper-search school uninstall`. It first lists what will be deleted and what kept, and deletes the install directory after the user confirms; when the PaperSearch config points at this installation's backend, it turns off the school download and clears the backend path; when it points elsewhere, it is left unchanged. School settings and sign-in sessions are kept by default, and it asks about them; with `--yes` they are kept unless `--remove-data` is also given. Google Chrome and ego lite are not affected.
47
48
 
48
- ## 学校
49
+ ## School
49
50
 
50
- 用户的学校写在后端配置里,由用户提供,不预设、不替换。用户只需说出学校名,所属联盟由后端判断,不要问用户是哪个联盟:
51
+ The user's school is stored in the backend configuration, as the user gives it; never preset or replace it. The user only needs to name the school; the backend works out its federation; do not ask the user which federation it is:
51
52
 
52
53
  ```bash
53
- paper-search-school setup --institution "用户说的校名" [--also-name "学校的英文正式名称"]
54
+ paper-search-school setup --institution "School name the user gave" [--also-name "The school's official English name"]
54
55
  ```
55
56
 
56
- - 目前支持中国内地和澳门(CARSI)、香港(HKAF)、新加坡(SGAF)、日本(GakuNin)、韩国(KAFE)、马来西亚(SIFULAN)、印度(INFED)、土耳其(YETKİM)、斯里兰卡(LIAF)、孟加拉(TIGERfed)、巴基斯坦(PKIFED)、阿曼(OMREN)、中国内地科研机构(CSTCloud)、沙特阿拉伯(Maeen)、塞浦路斯(CyNet)、以色列(IUCC)、伊朗(IRFED)、阿塞拜疆(AzScienceNet)、英国(UK federation)、爱尔兰(Edugate)、法国(RENATER)、荷兰(SURFconext)、比利时(Belnet)、卢森堡(eduID Luxembourg)、北欧、中欧、南欧和东欧各国,以及美洲、大洋洲和非洲各国(各联盟见 `federation-support.md`)的学术身份联盟,以及只经 OpenAthens 登录的学校。`--institution` 可以是校名(任何语言)、学校域名或 entityID;后端在各联盟的学校名单里查,确定是哪一所才保存,并保存它所属的联盟。
57
- - 联盟名单里的校名是当地语言和英文(中国内地、澳门有中文,日本有日文,土耳其有土耳其文,欧洲和拉丁美洲各国多有当地语言名,香港、韩国、新加坡、马来西亚、南亚、北美洲、大洋洲和非洲多只有英文)。用户说的校名不是英文时,加 `--also-name` 给出学校的英文正式名称(出版社多按英文名列学校);不确定英文名就不加。
58
- - 有些学校经多校共用的登录入口登录(如以色列、挪威、克罗地亚的大学,中国内地的科研院所,巴基斯坦、拉脱维亚的部分学校),联盟名单里只有它们的域名:按校名查不到时,用 `--institution <校名> --also-name <学校官网域名>` 再查一次,程序会按域名找到入口,并按所给校名在出版社搜索。
59
- - 返回 `school_ambiguous` 时,把 `candidates`(含学校名、联盟、域名)列给用户选,再用所选学校的 `entity_id` 作为 `--institution` 重新运行;只有一个候选也要问,那是名字不完全一致的学校。`school_not_found` 时请用户换成学校正式名称、英文名或学校域名,仍找不到就按回复里的 `reasons` 如实说明:这所学校可能没有接入学术身份联盟或 OpenAthens,学校订阅下载无法为它登录;`federation_not_supported` 是找到了学校但它所属的联盟还不支持,如实告诉用户;`school_list_unavailable` 是名单取不到,稍后重试。需要请用户反馈时,见 `federation-support.md`“学校登录不上时”。
60
- - `--carsi --institution` 只在 CARSI 名单里查(错误码 `carsi_school_*`);查 CARSI 名单:`paper-search-school setup --list-carsi-schools 关键词`。
61
- - `setup --check` 的 `school` 项为 `missing` 时,说明只存了学校名,按提示重新运行上面的命令。
62
- - 配置后,选联盟、选学校、点继续由程序完成;用户只在学校登录页输入账号密码、完成人机验证。
63
- - 没有配置学校时(`setup --carsi`),CARSI 照样开启,由用户在选校页自己选。
64
- - 出版社列表里找不到用户的学校时,报告找不到,不改选别的学校。
65
- - 后端命令要和下载使用同一个数据目录(PaperSearch 默认 `${XDG_DATA_HOME:-~/.local/share}/paper-search-cli/school`);需要时在命令前加 `SCHOOL_DATA_DIR=<该目录>`。登录状态保存在这个目录的下载浏览器里。
57
+ - Supported now: the academic identity federations of China mainland and Macao (CARSI), Hong Kong (HKAF), Singapore (SGAF), Japan (GakuNin), South Korea (KAFE), Malaysia (SIFULAN), India (INFED), Turkey (YETKİM), Sri Lanka (LIAF), Bangladesh (TIGERfed), Pakistan (PKIFED), Oman (OMREN), research institutes in China mainland (CSTCloud), Saudi Arabia (Maeen), Cyprus (CyNet), Israel (IUCC), Iran (IRFED), Azerbaijan (AzScienceNet), the United Kingdom (UK federation), Ireland (Edugate), France (RENATER), the Netherlands (SURFconext), Belgium (Belnet), Luxembourg (eduID Luxembourg), the countries of Northern, Central, Southern and Eastern Europe, and countries in the Americas, Oceania and Africa (each federation in `federation-support.md`), plus schools that sign in only through OpenAthens. `--institution` can be a school name (in any language), the school's domain or an entityID; the backend searches each federation's school list, saves only once it knows which school it is, and saves the federation it belongs to.
58
+ - Federation lists give school names in the local language and in English (China mainland and Macao have Chinese, Japan Japanese, Turkey Turkish, most European and Latin American countries local-language names; Hong Kong, South Korea, Singapore, Malaysia, South Asia, North America, Oceania and Africa mostly English only). When the school name the user gave is not English, add `--also-name` with the school's official English name (publishers mostly list schools by their English names); when you are unsure of the English name, leave it out.
59
+ - Some schools sign in through a login entry shared by several schools (universities in Israel, Norway and Croatia, research institutes in China mainland, some schools in Pakistan and Latvia), and the federation list has only their domains: when the school name finds nothing, search again with `--institution <school name> --also-name <school website domain>`; the program finds the entry by the domain and searches publishers by the given school name.
60
+ - On `school_ambiguous`, list the `candidates` (school name, federation, domain) for the user to choose, then rerun with the chosen school's `entity_id` as `--institution`; ask even when there is only one candidate: it is a school whose name does not quite match. On `school_not_found`, ask the user for the school's official name, English name or domain; when it is still not found, explain truthfully as the reply's `reasons` say: this school may not be connected to an academic identity federation or OpenAthens, and school subscription downloads cannot sign in for it; `federation_not_supported` means the school was found but its federation is not supported yet: tell the user so truthfully; `school_list_unavailable` means the list could not be fetched: retry later. When the user should send feedback, see "When school login fails" in `federation-support.md`.
61
+ - `--carsi --institution` searches only the CARSI list (error codes `carsi_school_*`); to look up the CARSI list: `paper-search-school setup --list-carsi-schools <keyword>`.
62
+ - When the `school` item of `setup --check` is `missing`, only the school name was saved; rerun the command above as the hint says.
63
+ - Once configured, the program chooses the federation and the school and presses continue; the user only enters the account and password on the school login page and completes human verification.
64
+ - With no school configured (`setup --carsi`), CARSI is still on, and the user chooses on the school-selection page.
65
+ - When the user's school is not in the publisher's list, report that it was not found; do not choose another school instead.
66
+ - Backend commands must use the same data directory as the downloads (PaperSearch's default is `${XDG_DATA_HOME:-~/.local/share}/paper-search-cli/school`); when needed, put `SCHOOL_DATA_DIR=<that directory>` before the command. The sign-in state is kept in the download browser in this directory.
66
67
 
67
- ### 几所学校
68
+ ### Several schools
68
69
 
69
- 可以存几所学校,其中一所是当前学校,下载默认用它。**只在用户明确要求时切换或指定学校,不要自己换,也不要建议换哪所。**
70
+ Several schools can be saved; one of them is the current school, which downloads use by default. **Switch or name a school only when the user clearly asks; never switch on your own, and do not suggest which one to switch to.**
70
71
 
71
72
  ```bash
72
- paper-search-school schools # 列出存过的学校,current 为当前学校
73
- paper-search-school use "学校名" # 切换当前学校;没存过就像 setup --institution 那样查到后存下
74
- paper-search-school forget "学校名" # 从列表删掉(不能删当前学校)
73
+ paper-search-school schools # list saved schools; current is the current school
74
+ paper-search-school use "School name" # switch the current school; when not saved yet, look it up and save it as setup --institution does
75
+ paper-search-school forget "School name" # remove it from the list (the current school cannot be removed)
75
76
  ```
76
77
 
77
- - 用 `setup --institution` 换学校时,原来的学校也会留在列表里。`use` 可以用校名、英文名、域名或 entityID;返回 `school_ambiguous` 时把 `candidates` 列给用户选。没存过的学校,`use` 的查找和报错同上(`--also-name` 也一样)。
78
- - 只这一批用另一所已存的学校(用户说“这几篇用某某学校下”):`download_batch` 加 `school`(校名等),当前学校不变,这一批的“接着下”也用它。扩展太旧不认得时报“需要更新”(`school_update_needed`),运行 `paper-search school update`。
79
- - 各校的登录都在同一个下载浏览器里,切换不会登出别的学校;账号密码仍由用户在学校登录页输入。
78
+ - When `setup --institution` changes the school, the old school stays in the list too. `use` accepts a school name, English name, domain or entityID; on `school_ambiguous`, list the `candidates` for the user to choose. For a school not saved yet, `use` looks it up and reports errors as above (`--also-name` too).
79
+ - To use another saved school only for this batch (the user says "download these with school X"): add `school` (the school name, etc.) to `download_batch`; the current school does not change, and this batch's "go on" (接着下) uses it too. When the extension is too old to know it, it reports "需要更新" (update needed, `school_update_needed`); run `paper-search school update`.
80
+ - Every school's sign-in is in the same download browser; switching does not sign out of the others; the user still enters the account and password on the school login page.
80
81
 
81
- ## 浏览器
82
+ ## Browser
82
83
 
83
- 后端配置键 `browser_backend` 二选一:
84
+ The backend setting `browser_backend` takes one of two values:
84
85
 
85
- - `chrome`(默认):用户本机的 Google Chrome,由后端用单独的浏览器资料启动,不动用户日常 Chrome 的资料和标签页。第一次下载时用户在它的窗口里登录一次学校,之后保留。日常和批量下载用它。Chrome 装在别处时:`paper-search-school config set chrome_executable <Chrome 程序路径>`。旧值 `camoufox` 按 `chrome` 处理。
86
- - `ego`:需要沿用用户 ego lite 里已有的登录时选用(Chromium 内核,用户和 agent 看的是同一个浏览器,仅 macOS)。用户须在 ego 打开 `chrome://inspect/#remote-debugging`,勾选一次 “Allow remote debugging for this browser instance”。每次连接(例如 ego 重启后)ego 会弹出一次“允许连接”,由用户确认;ego 窗口在后台时常被直接拒绝,下载会立即报错并写明原因,请用户把 ego 放到前台、点“允许”后重试。
86
+ - `chrome` (default): the user's own Google Chrome, started by the backend with a separate browser profile, not touching the profile and tabs of the user's everyday Chrome. At the first download the user signs in to the school once in its window, and the sign-in is kept afterwards. Use it for everyday and batch downloads. When Chrome is installed elsewhere: `paper-search-school config set chrome_executable <Chrome program path>`. The old value `camoufox` is treated as `chrome`.
87
+ - `ego`: choose it to reuse sign-ins already in the user's ego lite (Chromium-based; the user and the agent look at the same browser; macOS only). The user must open `chrome://inspect/#remote-debugging` in ego and tick "Allow remote debugging for this browser instance" once. On each connection (for example after ego restarts) ego shows an "允许连接" (allow connection) prompt once, for the user to confirm; when the ego window is in the background the connection is often refused outright, and the download reports an error at once with the reason: ask the user to bring ego to the front, press "允许" (Allow), and retry.
87
88
 
88
- 查看或切换:
89
+ Check or switch:
89
90
 
90
91
  ```bash
91
92
  paper-search-school config get browser_backend
92
93
  paper-search-school config set browser_backend chrome
93
94
  ```
94
95
 
95
- 两套浏览器资料互不影响,切换不会删除另一套。用户没有要求时不擅自切换;也可以用 `paper-search school install --browser ego` 切换安装。
96
+ The two browser profiles do not affect each other; switching does not delete the other one. Do not switch unless the user asks; `paper-search school install --browser ego` also switches the installation.
96
97
 
97
- ## 边界
98
+ ## Boundaries
98
99
 
99
- - 账号、密码、验证码只由用户在浏览器里输入;不在聊天、命令参数、配置或日志里出现。
100
- - `doctor` 显示 `entitled_access` 为 `available`,只说明后端能连上,不代表已登录或对某篇有权限。
100
+ - The account, password and verification codes are entered only by the user in the browser; they never appear in the chat, command arguments, configuration or logs.
101
+ - `entitled_access` as `available` in `doctor` only means the backend can be reached; it does not mean signed in, or access to any paper.
@@ -1,39 +1,39 @@
1
- # 配置:请开始配置
1
+ # Setup: "start setup" (请开始配置)
2
2
 
3
- 用户说“请开始配置”(或“配置 PaperSearch”“start setup”)时,按下面固定的流程做。一次只问一个问题,等用户回答了再往下走;不要把所有配置项一起列出来让用户填。
3
+ When the user says "start setup" (or "请开始配置", "配置 PaperSearch", "set up PaperSearch"), follow the fixed flow below. Ask one question at a time and wait for the answer before going on; do not list all the settings for the user to fill in at once.
4
4
 
5
- 1. 运行 `paper-search doctor --format text`,先看清哪些已经配好;这一步不用问用户。找不到 `paper-search` 命令时,先按 `management-layer.md` 的“只装了 Skill 时”征得同意装好,再运行它。
6
- 2. 只问一个问题:要不要用学校订阅下载(机构配置)。问的时候说明它用学校账号下载非 OA 文章的全文和补充材料,需要 Google Chrome(没有时一起装)。以下情况不问:已经装好(`doctor` 的 `entitled_access` 是 `available`)直接走 A;这台机器没有图形界面,或用户说过不要(`PAPER_SEARCH_SCHOOL_DECLINED` 为 `true`),直接走 B。用户说不要时运行 `paper-search config set PAPER_SEARCH_SCHOOL_DECLINED true` 记下来,再走 B。
5
+ 1. Run `paper-search doctor --format text` to see what is already set up; this step needs no question to the user. When there is no `paper-search` command, first install it with the user's consent as "When only the Skill is installed" in `management-layer.md` says, then run it.
6
+ 2. Ask only one question: whether to use school subscription downloads (school setup). When asking, explain that it downloads the full texts and supplementary files of non-OA articles with the school account, and needs Google Chrome (installed too if missing). Do not ask in these cases: already installed (`entitled_access` in `doctor` is `available`): go straight to A; this computer has no graphical interface, or the user said no before (`PAPER_SEARCH_SCHOOL_DECLINED` is `true`): go straight to B. When the user says no, run `paper-search config set PAPER_SEARCH_SCHOOL_DECLINED true` to record it, then go to B.
7
7
 
8
- A. 机构配置(用户同意用学校订阅下载)
8
+ A. School setup (the user agrees to use school subscription downloads)
9
9
 
10
- 1. 没装时安装(见 `school-setup.md`):`paper-search school install --yes --skip-school`,没有 Chrome 时先装 Chrome。
11
- 2. 直接问用户的学校并设好:运行 `paper-search-school setup --institution "学校名"`(见 `school-setup.md` 的“学校”一节)。只有用户主动说跳过时才跳过,那样第一次下载时在选校页选。
12
- 3. 其余配置都在设置窗口里做:装完设置窗口会自己打开;没打开或早已装好时,直接运行 `paper-search settings` 打开设置窗口。告诉用户在窗口里填要用的 API key、改下载文件夹和等待时间,每个 key 可以点“测试”,填完点右上角 × 关闭。推荐先填 EasyScholar(影响因子和分区)和 Semantic Scholar(正文片段),其余 key 非必须。不在对话里逐项问 key 或下载文件夹。
13
- 4. 用户说填好了,运行 `paper-search doctor --format text`,告诉用户现在能用哪些功能。
10
+ 1. When it is not installed, install it (see `school-setup.md`): `paper-search school install --yes --skip-school`; when there is no Chrome, install Chrome first.
11
+ 2. Ask the user for their school right away and set it: run `paper-search-school setup --institution "School name"` (see "School" in `school-setup.md`). Skip this only when the user says to skip it; then they choose on the school-selection page at the first download.
12
+ 3. Everything else is set in the settings window: it opens by itself after installation; when it did not open, or it was installed long ago, run `paper-search settings` directly to open the settings window. Tell the user to enter the API keys they want and change the download folder and wait times in the window; each key has a "测试" (Test) button; when done, close it with the × at the top right. Recommend EasyScholar (impact factors and quartiles) and Semantic Scholar (body snippets) first; the other keys are optional. Do not ask for keys or the download folder one by one in the chat.
13
+ 4. When the user says they are done, run `paper-search doctor --format text` and tell the user what they can use now.
14
14
 
15
- B. 不用机构配置
15
+ B. No school setup
16
16
 
17
- 1. 只推荐两个 key:`EASYSCHOLAR_KEY`(影响因子和分区)、`SEMANTIC_SCHOLAR_API_KEY`(正文片段),给出申请入口(`doctor` 的 To enable 一行);其余 key 都非必须,用户问起再说。用户说都不需要就跳到第 4 步。
18
- 2. 请用户在自己的终端运行 `paper-search setup --skip-school` 填 key(输入时不显示),填完告诉你。
19
- 3. 用户说填好了,对填了的每个 key 运行 `paper-search config test <KEY>` 确认能用。
20
- 4. 设好默认下载文件夹(见下面“默认下载文件夹”)。
21
- 5. 运行 `paper-search doctor --format text`,告诉用户现在能用哪些功能。
17
+ 1. Recommend only two keys: `EASYSCHOLAR_KEY` (impact factors and quartiles) and `SEMANTIC_SCHOLAR_API_KEY` (body snippets), with where to apply (the To enable line in `doctor`); all other keys are optional; mention them only when the user asks. When the user needs neither, skip to step 4.
18
+ 2. Ask the user to run `paper-search setup --skip-school` in their own terminal to enter the keys (the input is hidden), and to tell you when done.
19
+ 3. When the user says they are done, run `paper-search config test <KEY>` for each key they entered to confirm it works.
20
+ 4. Set the default download folder (see "Default download folder" below).
21
+ 5. Run `paper-search doctor --format text` and tell the user what they can use now.
22
22
 
23
- 不在“请开始配置”里时:用户第一次要下订阅文章、学校订阅下载还没装、用户没说过不要、这台机器有图形界面,也问一次要不要装(说明同第 2 步),同意后按 A 的 1–3 做。用户只问某个功能缺什么时,只提这个功能要的 key 和申请入口,填法按 A 的第 3 步(设置窗口)或 B 的第 2 步(终端)。
23
+ Outside "start setup": when the user first wants a subscription article, school subscription downloads are not installed, the user has not said no, and this computer has a graphical interface, also ask once whether to install it (explained as in step 2); when they agree, do steps 1–3 of A. When the user only asks what a capability lacks, mention only the key it needs and where to apply; for entering it, use step 3 of A (the settings window) or step 2 of B (the terminal).
24
24
 
25
- ## 默认下载文件夹
25
+ ## Default download folder
26
26
 
27
- 配置时,或第一次要下载而还没设过时,先看有没有设好:
27
+ During setup, or at the first download when it has not been set, first check whether it is set:
28
28
 
29
29
  ```bash
30
30
  paper-search config get DEFAULT_DOWNLOAD_PATH
31
31
  ```
32
32
 
33
- 没有设置(返回的 `configured` 为 `false`)时问用户:“下载的论文默认放到哪个文件夹?”用户给出位置后保存为完整路径(`~` 表示用户目录):
33
+ When it is not set (`configured` is `false`), ask the user: "Which folder should downloaded papers go to by default?" When the user gives a place, save it as a full path (`~` means the home folder):
34
34
 
35
35
  ```bash
36
36
  paper-search config set DEFAULT_DOWNLOAD_PATH "~/Documents/Papers"
37
37
  ```
38
38
 
39
- 之后下载不传 `savePath` / `--save-path`,文件自动存到这个文件夹里每次新建的 `<年月日-时分秒>_PaperSearchDownload` 文件夹;只有用户这一次指定了别的位置才传。没有设置时,文件会存到命令当前所在目录下的 `./downloads`,位置不固定,用户很难找到。用户也可以在进度胶囊的设置里改这个文件夹。
39
+ After that, do not pass `savePath` / `--save-path` when downloading: files go into a new `<YYYYMMDD-HHmmss>_PaperSearchDownload` folder created in this folder each time; pass it only when the user names another place for this download. When it is not set, files go to `./downloads` under the command's current directory, a place that changes and that users find hard to locate. Users can also change this folder in the settings of the progress capsule.
@@ -1,15 +1,15 @@
1
- # 检索类命令出错时
1
+ # When search commands fail
2
2
 
3
- | 场景 | 处理 |
3
+ | Situation | What to do |
4
4
  | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
5
- | 命令不存在 | 按 `management-layer.md` 的“只装了 Skill 时”,征得用户同意后安装 |
6
- | Windows 的 PowerShell 拦住 `paper-search`、`npm`(脚本执行策略) | 改用 `paper-search.cmd`、`npm.cmd`;不改执行策略 |
7
- | Windows 上 `--json-args` 报 `is not valid JSON` | PowerShell 去掉了参数里的双引号:把 JSON 写进文件,传 `--json-args '@<文件路径>'` |
8
- | API key 或 email 缺失 | 告诉用户三件事:这个功能要哪个 key;去哪里申请(报错或 `paper-search doctor --format text` 里给的网址);申请后在自己的终端运行 `paper-search setup <KEY>` 填入,再用 `paper-search config test <KEY>` 确认能用;装了学校订阅下载、用户就在这台电脑前时,也可以运行 `paper-search settings <KEY>` 打开设置窗口让用户填(没装或没有图形界面时它返回错误并给出终端命令)。填好后重跑原来的命令。 |
9
- | Google Scholar 返回 CAPTCHA/429 或异常流量页 | Scholar 是尽力而为的来源,默认 `0.5 RPS`、缓存成功结果,遇到验证页立即停止。等一段时间后用 `--platform googlescholar --max-results 1` 重试;必要时配置有授权的 `GOOGLE_SCHOLAR_PROXY_URL`。它不在 `--sources all` 默认列表中 |
10
- | Google Scholar 仍不可用、又不想配置 key | 用 `paper-search search "<检索词>" --sources no-key --max-results 5 --pretty`(Crossref、PubMed、Europe PMC、arXiv、OpenReview) |
11
- | 429 限流 | 降低 `--max-results`,换平台,或提示配置可选 key |
12
- | 0 结果 | 放宽关键词,换英文同义词,换平台,或用 `--sources` 扩展 |
13
- | 下载失败 | 用统一的 `download_with_fallback` 并报告各 attempt;涉及学校权限的失败按 `browser-download.md` 的失败分类处理 |
5
+ | Command not found | Install it with the user's consent, as "When only the Skill is installed" in `management-layer.md` says |
6
+ | Windows PowerShell blocks `paper-search` or `npm` (script execution policy) | Use `paper-search.cmd` and `npm.cmd` instead; do not change the execution policy |
7
+ | On Windows, `--json-args` reports `is not valid JSON` | PowerShell removed the double quotes in the argument: write the JSON to a file and pass `--json-args '@<file path>'` |
8
+ | API key or email missing | Tell the user three things: which key this capability needs; where to apply (the address in the error or in `paper-search doctor --format text`); after applying, run `paper-search setup <KEY>` in their own terminal to enter it, then `paper-search config test <KEY>` to confirm it works. When school subscription downloads are installed and the user is at this computer, you can also run `paper-search settings <KEY>` to open the settings window for the user to fill in (when it is not installed or there is no graphical interface, it returns an error with the terminal command). Once the key is entered, rerun the original command. |
9
+ | Google Scholar returns CAPTCHA/429 or an unusual-traffic page | Scholar is a best-effort source: `0.5 RPS` by default, successful results cached, stops at once on a verification page. Wait a while, then retry with `--platform googlescholar --max-results 1`; if needed, configure an authorized `GOOGLE_SCHOLAR_PROXY_URL`. It is not in the default `--sources all` list |
10
+ | Google Scholar still unavailable, and no key wanted | Use `paper-search search "<search terms>" --sources no-key --max-results 5 --pretty` (Crossref, PubMed, Europe PMC, arXiv, OpenReview) |
11
+ | 429 rate limit | Lower `--max-results`, switch platform, or suggest configuring an optional key |
12
+ | 0 results | Broaden the keywords, use English synonyms, switch platform, or widen with `--sources` |
13
+ | Download failed | Use the unified `download_with_fallback` and report each attempt; failures involving the school's access are handled by the failure classes in `browser-download.md` |
14
14
 
15
- Scholar 相关配置:`SCHOLAR_RATE_LIMIT_RPS`(默认 `0.5`)、`SCHOLAR_MAX_RETRIES`(默认 `2`)、`SCHOLAR_TIMEOUT_MS`(默认 `15000`)。只往更保守的方向调。Scholar 用于找个别论文、补充少量检索;成批检索用 PubMed、Crossref、OpenAlex。遇到验证页就停下,过一段时间再试。
15
+ Scholar settings: `SCHOLAR_RATE_LIMIT_RPS` (default `0.5`), `SCHOLAR_MAX_RETRIES` (default `2`), `SCHOLAR_TIMEOUT_MS` (default `15000`). Only adjust them in the more conservative direction. Scholar is for finding individual papers and topping up small searches; for batch searches use PubMed, Crossref and OpenAlex. Stop at a verification page and try again after a while.
@@ -1,154 +0,0 @@
1
- """One bounded press on another provider's own confirmation control.
2
-
3
- Turnstile's checkbox has its own module (``challenge_interaction``). The same
4
- kind of control on the other providers' interstitials — reCAPTCHA v2's "I'm not
5
- a robot", hCaptcha's checkbox, AWS WAF's "Verify you are human" button — is a
6
- press the program can make as well: it starts the provider's own check and
7
- answers no puzzle. A puzzle that follows is the user's, and
8
- ``needs_manual_verification`` hands the page over as before.
9
-
10
- Off unless ``PAPER_SEARCH_AUTO_CONFIRM`` is ``0`` (user, 2026-11-18: the
11
- control is pressed as well; only the puzzle behind it stays the user's). On a
12
- page the user is watching, a press can still turn a short wait into an image
13
- challenge, so the switch exists to turn it off per run. Turnstile is unaffected:
14
- the program clicks its box either way.
15
-
16
- Nothing here solves a puzzle, reads a response token, navigates, or decides
17
- that verification passed.
18
- """
19
- from __future__ import annotations
20
-
21
- import os
22
- import re
23
- import time
24
- from typing import Any, Literal
25
- from urllib.parse import urlsplit
26
-
27
- from . import pointer
28
-
29
- #: Provider frames and the one control each shows before any puzzle.
30
- _FRAMES: tuple[tuple[str, re.Pattern[str], str], ...] = (
31
- ("reCAPTCHA", re.compile(r"^https://(?:www\.)?(?:google\.com|recaptcha\.net)/recaptcha/"
32
- r"(?:api2|enterprise)/anchor"), "#recaptcha-anchor, .recaptcha-checkbox"),
33
- ("hCaptcha", re.compile(r"^https://(?:[a-z0-9-]+\.)*hcaptcha\.com/captcha/"), "#checkbox"),
34
- )
35
- #: AWS WAF's own button: the only control on its interstitial, and its puzzle
36
- #: follows a press on it.
37
- _AWS_WAF = re.compile(r"^https://[^/]*\.captcha\.awswaf\.com/")
38
- _AWS_BUTTONS = ("button:has-text('Verify you are human')",
39
- "button:has-text('Verify you are a human')",
40
- "button:has-text('verify you are human')")
41
- #: The longest one press may take, including its approach.
42
- PRESS_LIMIT_SEC = 3.0
43
-
44
-
45
- def enabled() -> bool:
46
- """Whether pressing another provider's own confirmation control is allowed.
47
-
48
- On unless ``PAPER_SEARCH_AUTO_CONFIRM`` is 0 (user, 2026-11-18: these
49
- controls are pressed as well). Only the confirmation control is pressed —
50
- the puzzle behind it stays the user's, and ``needs_manual_verification``
51
- hands that over as before.
52
- """
53
- value = os.environ.get("PAPER_SEARCH_AUTO_CONFIRM", "").strip().lower()
54
- return value not in {"0", "false", "no", "off"}
55
-
56
-
57
- def _unchecked(control: Any) -> bool:
58
- """Not already pressed: ``aria-checked`` false, or no such attribute."""
59
- try:
60
- state = (control.get_attribute("aria-checked") or "").strip().lower()
61
- except Exception: # noqa: BLE001 - a read that fails leaves the control alone
62
- state = "true"
63
- return state in {"false", ""}
64
-
65
-
66
- def _press(page: Any, control: Any, *, box: dict[str, Any] | None,
67
- remaining_ms: int) -> bool:
68
- """Approach the control, then let its own actionable click press it."""
69
- if box:
70
- pointer.approach(page, box, limit_sec=pointer.budget_for(remaining_ms))
71
- control.click(timeout=remaining_ms, no_wait_after=True)
72
- return True
73
-
74
-
75
- def click_confirm_control(page: Any, *, timeout_ms: int, checkpoint: Any = None,
76
- observation: Any = None) -> Literal["absent", "clicked", "unavailable"]:
77
- """One press on the first visible confirmation control of a known provider."""
78
- from ..driver import Error, TimeoutError
79
-
80
- def note(reason: str) -> None:
81
- if observation is not None:
82
- observation(reason)
83
-
84
- until = time.monotonic() + max(0.0, timeout_ms) / 1000
85
- unavailable = False
86
- frames = getattr(page, "frames", ())
87
- frames = frames if isinstance(frames, (list, tuple)) else ()
88
- for frame in frames:
89
- if checkpoint is not None:
90
- checkpoint()
91
- if time.monotonic() >= until:
92
- return "unavailable" if unavailable else "absent"
93
- url = str(getattr(frame, "url", "") or "")
94
- for name, pattern, selector in _FRAMES:
95
- if not pattern.search(url):
96
- continue
97
- try:
98
- controls = frame.locator(selector)
99
- count = controls.count()
100
- if not count:
101
- continue
102
- control = controls.first
103
- if not control.is_visible() or not control.is_enabled() or not _unchecked(control):
104
- note(f"{name}: not actionable")
105
- unavailable = True
106
- continue
107
- remaining_ms = int((until - time.monotonic()) * 1000)
108
- if remaining_ms <= 0:
109
- return "unavailable"
110
- _press(page, control, box=control.bounding_box(), remaining_ms=remaining_ms)
111
- note(f"{name}: control pressed")
112
- return "clicked"
113
- except TimeoutError:
114
- note(f"{name}: actionability timeout")
115
- unavailable = True
116
- except Error as exc:
117
- if any(text in str(exc).lower() for text in (
118
- "frame was detached", "frame has been detached", "element is not attached",
119
- "execution context was destroyed")):
120
- unavailable = True
121
- continue
122
- raise
123
-
124
- # AWS WAF puts its button on the outer page, not in a provider frame.
125
- try:
126
- on_aws = any(_AWS_WAF.match(str(script.get_attribute("src") or ""))
127
- for script in page.locator("script[src]").all())
128
- except (Error, AttributeError, TypeError):
129
- on_aws = False
130
- if not on_aws:
131
- return "unavailable" if unavailable else "absent"
132
- for selector in _AWS_BUTTONS:
133
- if time.monotonic() >= until:
134
- return "unavailable"
135
- try:
136
- buttons = page.locator(selector)
137
- if not buttons.count():
138
- continue
139
- button = buttons.first
140
- if not button.is_visible() or not button.is_enabled():
141
- continue
142
- remaining_ms = int((until - time.monotonic()) * 1000)
143
- if remaining_ms <= 0:
144
- return "unavailable"
145
- _press(page, button, box=button.bounding_box(), remaining_ms=remaining_ms)
146
- note("AWS WAF: control pressed")
147
- return "clicked"
148
- except TimeoutError:
149
- unavailable = True
150
- except Error as exc:
151
- if not any(text in str(exc).lower() for text in ("element is not attached",)):
152
- raise
153
- unavailable = True
154
- return "unavailable" if unavailable else "absent"