argo-search 2.12.0 → 2.14.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 (371) hide show
  1. package/AGENTS.md +93 -0
  2. package/README.en.md +35 -12
  3. package/README.es.md +35 -12
  4. package/README.ja.md +38 -13
  5. package/README.ko.md +35 -12
  6. package/README.md +69 -42
  7. package/SKILL.md +4 -4
  8. package/assets/readme/counts.json +1 -0
  9. package/assets/readme/hero.svg +1 -1
  10. package/backends/domain_profiles.json +78 -6
  11. package/backends/engine_registry.yaml +188 -22
  12. package/backends/env_passthrough.txt +75 -0
  13. package/backends/quota_profiles.json +132 -12
  14. package/bin/argo +3 -0
  15. package/config.yaml +34 -3524
  16. package/docs/ARGO_INTRO.md +4 -3
  17. package/docs/CHANGELOG.md +337 -0
  18. package/docs/COMMIT_STANDARD.md +98 -0
  19. package/docs/ENGINE_CATALOG.md +65 -48
  20. package/docs/QUALITY_OF_SLOW_SOURCES.md +115 -0
  21. package/docs/RELEASE_NOTES_v2.13.0.md +66 -0
  22. package/docs/RELEASE_NOTES_v2.14.0.md +77 -0
  23. package/docs/RELEASING.md +47 -0
  24. package/docs//344/270/272/344/273/200/344/271/210/351/200/211/346/213/251argo.md +7 -7
  25. package/engines/specs/anysearch.yaml +33 -0
  26. package/engines/specs/archive_org.yaml +31 -0
  27. package/engines/specs/arxiv.yaml +18 -0
  28. package/engines/specs/baidu_baike.yaml +16 -0
  29. package/engines/specs/baidu_hot.yaml +19 -0
  30. package/engines/specs/bilibili.yaml +33 -0
  31. package/engines/specs/bilibili_hot.yaml +19 -0
  32. package/engines/specs/bing_rss.yaml +17 -0
  33. package/engines/specs/biorxiv.yaml +2 -0
  34. package/engines/specs/bocha.yaml +26 -0
  35. package/engines/specs/bocha_ai.yaml +27 -0
  36. package/engines/specs/brave.yaml +20 -0
  37. package/engines/specs/byted.yaml +33 -0
  38. package/engines/specs/clinicaltrials.yaml +23 -0
  39. package/engines/specs/cls_telegraph.yaml +19 -0
  40. package/engines/specs/cnii.yaml +21 -0
  41. package/engines/specs/cninfo.yaml +14 -0
  42. package/engines/specs/coingecko.yaml +33 -0
  43. package/engines/specs/courtlistener.yaml +15 -0
  44. package/engines/specs/crates.yaml +30 -0
  45. package/engines/specs/crossref.yaml +27 -0
  46. package/engines/specs/csdn.yaml +18 -0
  47. package/engines/specs/dblp.yaml +29 -0
  48. package/engines/specs/dbpedia.yaml +32 -0
  49. package/engines/specs/devto.yaml +26 -0
  50. package/engines/specs/dnb.yaml +17 -0
  51. package/engines/specs/doaj.yaml +17 -0
  52. package/engines/specs/docker_hub.yaml +30 -0
  53. package/engines/specs/douban_book.yaml +14 -0
  54. package/engines/specs/douyin_hot.yaml +21 -0
  55. package/engines/specs/eastmoney.yaml +16 -0
  56. package/engines/specs/ecosia.yaml +18 -0
  57. package/engines/specs/electricity_maps.yaml +17 -0
  58. package/engines/specs/em_flow.yaml +14 -0
  59. package/engines/specs/em_global_news.yaml +17 -0
  60. package/engines/specs/em_miaoxiang.yaml +14 -0
  61. package/engines/specs/eu_opendata.yaml +16 -0
  62. package/engines/specs/europeana.yaml +19 -0
  63. package/engines/specs/europepmc.yaml +29 -0
  64. package/engines/specs/eurostat.yaml +14 -0
  65. package/engines/specs/exa.yaml +20 -0
  66. package/engines/specs/felo.yaml +25 -0
  67. package/engines/specs/figshare.yaml +17 -0
  68. package/engines/specs/finviz.yaml +15 -0
  69. package/engines/specs/fourget.yaml +23 -0
  70. package/engines/specs/fr_opendata.yaml +28 -0
  71. package/engines/specs/frankfurter.yaml +21 -0
  72. package/engines/specs/fred.yaml +15 -0
  73. package/engines/specs/free_dictionary.yaml +16 -0
  74. package/engines/specs/fx_rate.yaml +14 -0
  75. package/engines/specs/gbfs_nyc.yaml +3 -0
  76. package/engines/specs/gbif.yaml +15 -0
  77. package/engines/specs/github.yaml +25 -0
  78. package/engines/specs/google_patents.yaml +16 -0
  79. package/engines/specs/google_scholar.yaml +16 -0
  80. package/engines/specs/gov_policy.yaml +31 -0
  81. package/engines/specs/grep_app.yaml +19 -0
  82. package/engines/specs/gutenberg.yaml +15 -0
  83. package/engines/specs/hackernews.yaml +18 -0
  84. package/engines/specs/hal.yaml +16 -0
  85. package/engines/specs/hatena_bookmark.yaml +20 -0
  86. package/engines/specs/hf_papers.yaml +26 -0
  87. package/engines/specs/huggingface.yaml +31 -0
  88. package/engines/specs/imdb.yaml +18 -0
  89. package/engines/specs/itotii.yaml +17 -0
  90. package/engines/specs/itunes.yaml +19 -0
  91. package/engines/specs/jin10.yaml +15 -0
  92. package/engines/specs/juejin.yaml +16 -0
  93. package/engines/specs/kaggle.yaml +44 -0
  94. package/engines/specs/know_your_meme.yaml +18 -0
  95. package/engines/specs/kor_law.yaml +17 -0
  96. package/engines/specs/lieu.yaml +18 -0
  97. package/engines/specs/listenbrainz.yaml +4 -0
  98. package/engines/specs/local_arxiv.yaml +18 -0
  99. package/engines/specs/local_baidu.yaml +35 -0
  100. package/engines/specs/local_bing.yaml +16 -0
  101. package/engines/specs/local_bing_news.yaml +22 -0
  102. package/engines/specs/local_crossref.yaml +23 -0
  103. package/engines/specs/local_github.yaml +27 -0
  104. package/engines/specs/local_gitlab.yaml +23 -0
  105. package/engines/specs/local_goodreads.yaml +16 -0
  106. package/engines/specs/local_google_news.yaml +15 -0
  107. package/engines/specs/local_imdb.yaml +17 -0
  108. package/engines/specs/local_npm.yaml +25 -0
  109. package/engines/specs/local_openstreetmap.yaml +36 -0
  110. package/engines/specs/local_pubmed.yaml +21 -0
  111. package/engines/specs/local_search.yaml +22 -0
  112. package/engines/specs/local_seek.yaml +34 -0
  113. package/engines/specs/local_semantic_scholar.yaml +23 -0
  114. package/engines/specs/local_sogou.yaml +15 -0
  115. package/engines/specs/local_stackoverflow.yaml +26 -0
  116. package/engines/specs/local_wikipedia.yaml +26 -0
  117. package/engines/specs/local_wikiquote.yaml +26 -0
  118. package/engines/specs/local_wiktionary.yaml +26 -0
  119. package/engines/specs/local_yandex.yaml +37 -0
  120. package/engines/specs/marginalia.yaml +22 -0
  121. package/engines/specs/mdn.yaml +32 -0
  122. package/engines/specs/met_museum.yaml +4 -2
  123. package/engines/specs/metaso.yaml +19 -0
  124. package/engines/specs/models_dev.yaml +16 -0
  125. package/engines/specs/moegirl.yaml +19 -0
  126. package/engines/specs/mojeek.yaml +31 -0
  127. package/engines/specs/musicbrainz.yaml +31 -0
  128. package/engines/specs/mwmbl.yaml +39 -0
  129. package/engines/specs/nasa_cmr.yaml +15 -0
  130. package/engines/specs/nbs_stats.yaml +16 -0
  131. package/engines/specs/ndl.yaml +17 -0
  132. package/engines/specs/noaa_swpc.yaml +3 -0
  133. package/engines/specs/npm.yaml +62 -0
  134. package/engines/specs/octen.yaml +16 -0
  135. package/engines/specs/open_library.yaml +15 -0
  136. package/engines/specs/open_meteo.yaml +17 -0
  137. package/engines/specs/openaire.yaml +34 -0
  138. package/engines/specs/openalex.yaml +27 -0
  139. package/engines/specs/opencitations.yaml +4 -1
  140. package/engines/specs/opencorporates.yaml +19 -0
  141. package/engines/specs/openfda.yaml +15 -0
  142. package/engines/specs/opensky.yaml +17 -0
  143. package/engines/specs/openverse.yaml +42 -0
  144. package/engines/specs/parallel.yaml +22 -0
  145. package/engines/specs/parallel_free.yaml +20 -0
  146. package/engines/specs/polymarket.yaml +26 -0
  147. package/engines/specs/pubchem.yaml +15 -0
  148. package/engines/specs/pypi.yaml +16 -0
  149. package/engines/specs/qiita.yaml +28 -0
  150. package/engines/specs/qq_music.yaml +17 -0
  151. package/engines/specs/qwant.yaml +19 -0
  152. package/engines/specs/qweather.yaml +14 -0
  153. package/engines/specs/rcsb_pdb.yaml +15 -0
  154. package/engines/specs/reddit.yaml +28 -0
  155. package/engines/specs/redskill.yaml +24 -0
  156. package/engines/specs/repology.yaml +18 -0
  157. package/engines/specs/rfc_editor.yaml +15 -0
  158. package/engines/specs/satnogs.yaml +5 -1
  159. package/engines/specs/searchmysite.yaml +18 -0
  160. package/engines/specs/searxng.yaml +18 -0
  161. package/engines/specs/sec_companyfacts.yaml +22 -0
  162. package/engines/specs/seeking_alpha.yaml +15 -0
  163. package/engines/specs/seltz.yaml +39 -0
  164. package/engines/specs/semantic_scholar.yaml +18 -0
  165. package/engines/specs/shenma.yaml +13 -0
  166. package/engines/specs/sina_quote.yaml +15 -0
  167. package/engines/specs/so.yaml +13 -0
  168. package/engines/specs/stackoverflow.yaml +18 -0
  169. package/engines/specs/steam.yaml +30 -0
  170. package/engines/specs/tatoeba.yaml +17 -0
  171. package/engines/specs/tavily.yaml +26 -0
  172. package/engines/specs/tencent_kline.yaml +18 -0
  173. package/engines/specs/tencent_quote.yaml +14 -0
  174. package/engines/specs/thesportsdb.yaml +18 -0
  175. package/engines/specs/ths_hot.yaml +19 -0
  176. package/engines/specs/tinyfish.yaml +36 -0
  177. package/engines/specs/tinyfish_news.yaml +34 -0
  178. package/engines/specs/tinyfish_paper.yaml +34 -0
  179. package/engines/specs/toutiao_hot.yaml +19 -0
  180. package/engines/specs/twitter.yaml +36 -0
  181. package/engines/specs/uapi.yaml +18 -0
  182. package/engines/specs/uniprot.yaml +16 -0
  183. package/engines/specs/urban_dictionary.yaml +25 -0
  184. package/engines/specs/usda.yaml +17 -0
  185. package/engines/specs/usgs.yaml +15 -0
  186. package/engines/specs/v2ex.yaml +33 -0
  187. package/engines/specs/vam.yaml +34 -0
  188. package/engines/specs/wallhaven.yaml +51 -0
  189. package/engines/specs/wallstreetcn.yaml +31 -0
  190. package/engines/specs/wayback_cdx.yaml +15 -0
  191. package/engines/specs/weather_cn.yaml +33 -0
  192. package/engines/specs/wechat_sogou.yaml +13 -0
  193. package/engines/specs/weibo.yaml +21 -0
  194. package/engines/specs/weibo_hot.yaml +21 -0
  195. package/engines/specs/wenshu.yaml +14 -0
  196. package/engines/specs/weread.yaml +14 -0
  197. package/engines/specs/wiby.yaml +18 -0
  198. package/engines/specs/wikidata.yaml +33 -0
  199. package/engines/specs/wikipedia.yaml +36 -0
  200. package/engines/specs/wolframalpha.yaml +18 -0
  201. package/engines/specs/worldbank.yaml +15 -0
  202. package/engines/specs/xiaohongshu.yaml +25 -0
  203. package/engines/specs/yahoo_finance.yaml +22 -0
  204. package/engines/specs/you.yaml +22 -0
  205. package/engines/specs/zh_wikipedia.yaml +35 -0
  206. package/engines/specs/zhihu.yaml +33 -0
  207. package/engines/specs/zhihu_global.yaml +18 -0
  208. package/engines/specs/zhihu_hot.yaml +36 -0
  209. package/engines/specs/zhihu_user.yaml +14 -0
  210. package/package.json +25 -22
  211. package/packages/dsh-plugin/README.md +11 -6
  212. package/packages/dsh-plugin/cordis.patch.yml +6 -2
  213. package/packages/dsh-plugin/dsh/client.js +65 -116
  214. package/packages/dsh-plugin/dsh/index.js +2 -2
  215. package/packages/dsh-plugin/dsh/native-tools.mjs +24 -3
  216. package/packages/dsh-plugin/dsh/runner.js +35 -1
  217. package/packages/dsh-plugin/dsh/specs.js +3 -1
  218. package/packages/dsh-plugin/dsh/wide-research.js +4 -2
  219. package/packages/dsh-plugin/package.json +1 -1
  220. package/packages/dsh-plugin/scripts/sync-local.sh +13 -11
  221. package/packages/dsh-plugin/test/client.test.js +22 -5
  222. package/packages/dsh-plugin/test/config.test.js +5 -1
  223. package/packages/dsh-plugin/test/index.test.js +3 -1
  224. package/packages/dsh-plugin/test/size-gate.test.js +2 -2
  225. package/scripts/ab_eval_p0p1.py +10 -4
  226. package/scripts/archive_run.py +4 -2
  227. package/scripts/badcase_causes.py +81 -0
  228. package/scripts/badcase_ledger.py +290 -15
  229. package/scripts/batch_probe.py +10 -8
  230. package/scripts/build_release_assets.sh +17 -5
  231. package/scripts/cache.py +8 -8
  232. package/scripts/cache_guard.py +10 -5
  233. package/scripts/candidate_envelope.py +7 -3
  234. package/scripts/check_commit_report.py +168 -0
  235. package/scripts/circuit_breaker.py +220 -36
  236. package/scripts/config.py +9 -10
  237. package/scripts/daemon.py +11 -2
  238. package/scripts/engine_add.py +32 -0
  239. package/scripts/engine_admission.py +9 -5
  240. package/scripts/engine_dispatch.py +49 -46
  241. package/scripts/engine_failure.py +14 -18
  242. package/scripts/engine_families.py +13 -2
  243. package/scripts/engine_health.py +184 -0
  244. package/scripts/engine_policy.py +1 -1
  245. package/scripts/engine_states.py +989 -0
  246. package/scripts/engine_status.py +49 -11
  247. package/scripts/engine_validate.py +47 -39
  248. package/scripts/engines.py +8 -0
  249. package/scripts/engines_base.py +34 -88
  250. package/scripts/engines_builders.py +36 -19
  251. package/scripts/engines_builders_archive.py +303 -0
  252. package/scripts/engines_builders_batch11.py +63 -1
  253. package/scripts/engines_builders_batch12.py +168 -0
  254. package/scripts/engines_builders_batch16.py +186 -0
  255. package/scripts/engines_builders_batch9.py +9 -1
  256. package/scripts/engines_builders_data.py +69 -2090
  257. package/scripts/engines_builders_finance.py +354 -0
  258. package/scripts/engines_builders_intl.py +4 -1
  259. package/scripts/engines_builders_media.py +724 -0
  260. package/scripts/engines_builders_science.py +784 -0
  261. package/scripts/engines_parsers.py +399 -0
  262. package/scripts/fetch_browser.py +4 -2
  263. package/scripts/fetch_jsrun.py +2 -1
  264. package/scripts/fetch_v3.py +38 -38
  265. package/scripts/gen_engine_catalog.py +58 -153
  266. package/scripts/gen_native_tools.py +44 -17
  267. package/scripts/gen_routing_snapshot.py +8 -6
  268. package/scripts/health_check.py +37 -4
  269. package/scripts/health_probe.py +28 -8
  270. package/scripts/install.ps1 +31 -15
  271. package/scripts/install.sh +266 -142
  272. package/scripts/job.py +8 -70
  273. package/scripts/lint_spec_contracts.py +7 -12
  274. package/scripts/local_intent.py +139 -0
  275. package/scripts/local_seek.py +223 -91
  276. package/scripts/local_seek_adapter.py +87 -0
  277. package/scripts/mcp_launch.sh +9 -17
  278. package/scripts/mcp_transport.py +1 -1
  279. package/scripts/net_proxy.py +47 -0
  280. package/scripts/numeric_verify.py +20 -9
  281. package/scripts/output_transparency.py +21 -13
  282. package/scripts/plan.py +8 -5
  283. package/scripts/pre-commit +93 -23
  284. package/scripts/quota.py +11 -7
  285. package/scripts/recovery.py +14 -5
  286. package/scripts/recovery_l0.py +5 -3
  287. package/scripts/redskill/redskill_engine.py +3 -9
  288. package/scripts/release.py +60 -24
  289. package/scripts/release_check.py +20 -3
  290. package/scripts/research.py +1 -1
  291. package/scripts/research_dossier.py +10 -5
  292. package/scripts/research_gates.py +8 -4
  293. package/scripts/retry_policy.py +8 -7
  294. package/scripts/route.py +2 -24
  295. package/scripts/route_combo.py +11 -26
  296. package/scripts/route_lang.py +6 -1
  297. package/scripts/route_policy.py +21 -14
  298. package/scripts/search.py +36 -35
  299. package/scripts/search_attribution.py +34 -3
  300. package/scripts/search_cli.py +22 -12
  301. package/scripts/search_entry.py +15 -3
  302. package/scripts/search_output.py +87 -18
  303. package/scripts/search_pipeline.py +14 -10
  304. package/scripts/search_rank.py +23 -62
  305. package/scripts/search_types.py +5 -0
  306. package/scripts/social_engines/bilibili_engine.py +2 -30
  307. package/scripts/social_engines/hackernews_engine.py +4 -12
  308. package/scripts/social_engines/reddit_engine.py +4 -13
  309. package/scripts/social_engines/v2ex_engine.py +3 -12
  310. package/scripts/social_engines/weibo_engine.py +2 -30
  311. package/scripts/social_engines/zhihu_engine.py +4 -5
  312. package/scripts/source_audit.py +331 -0
  313. package/scripts/stats_cli.py +17 -1
  314. package/scripts/sync_backends.py +241 -8
  315. package/scripts/sync_requirements.py +159 -0
  316. package/scripts/tweet.py +3 -6
  317. package/scripts/usage_log.py +28 -9
  318. package/scripts/video_fetch.py +2 -5
  319. package/scripts/watch.py +11 -6
  320. package/scripts/wechat_article.py +11 -12
  321. package/scripts/wide_research.py +4 -1
  322. package/scripts/wx.py +6 -13
  323. package/scripts/x_article_fetch.py +2 -1
  324. package/sub-skills/local-search/SKILL.md +2 -2
  325. package/sub-skills/local-search/config.yaml +2 -1
  326. package/sub-skills/local-search/parsers.py +6 -1
  327. package/sub-skills/local-seek/scripts/seek.py +390 -24
  328. package/sub-skills/local-seek/scripts/seek_fts.py +20 -9
  329. package/sub-skills/local-seek/scripts/seek_rank.py +64 -1
  330. package/docs/DATA_SOURCE_GAPS.md +0 -81
  331. package/docs/DESIGN_LOCAL_DATA_FUSION.md +0 -90
  332. package/docs/PLATFORM_PATHS.md +0 -111
  333. package/docs/engines/bangumi.md +0 -27
  334. package/docs/engines/biorxiv.md +0 -27
  335. package/docs/engines/clawhub.md +0 -27
  336. package/docs/engines/crt_sh.md +0 -27
  337. package/docs/engines/datacite.md +0 -27
  338. package/docs/engines/deps_dev.md +0 -27
  339. package/docs/engines/douban_movie.md +0 -27
  340. package/docs/engines/endoflife.md +0 -27
  341. package/docs/engines/flk_law.md +0 -27
  342. package/docs/engines/fxtwitter.md +0 -27
  343. package/docs/engines/google_news.md +0 -27
  344. package/docs/engines/gov_regulations.md +0 -27
  345. package/docs/engines/guqian.md +0 -27
  346. package/docs/engines/hackernews.md +0 -27
  347. package/docs/engines/iplant.md +0 -27
  348. package/docs/engines/keenable.md +0 -27
  349. package/docs/engines/met_museum.md +0 -27
  350. package/docs/engines/nasa_images.md +0 -27
  351. package/docs/engines/netease_music.md +0 -27
  352. package/docs/engines/npm.md +0 -27
  353. package/docs/engines/nvd.md +0 -27
  354. package/docs/engines/openreview.md +0 -27
  355. package/docs/engines/openstd.md +0 -27
  356. package/docs/engines/parallel_free.md +0 -27
  357. package/docs/engines/people_daily.md +0 -27
  358. package/docs/engines/pixiv.md +0 -27
  359. package/docs/engines/realtime_index.md +0 -27
  360. package/docs/engines/sec_edgar.md +0 -27
  361. package/docs/engines/seltz.md +0 -27
  362. package/docs/engines/skillsmp.md +0 -27
  363. package/docs/engines/sspai.md +0 -27
  364. package/docs/engines/std_samr.md +0 -27
  365. package/docs/engines/train.md +0 -27
  366. package/docs/engines/un_comtrade.md +0 -27
  367. package/docs/engines/wikisource.md +0 -27
  368. package/docs/engines/zdic.md +0 -27
  369. package/docs/engines/zenodo.md +0 -27
  370. package/docs/engines/zhihu_hot_app.md +0 -27
  371. package/engines/specs/cinii.yaml +0 -44
@@ -21,6 +21,8 @@ from engine_env import env_status_for, is_engine_allowed_by_env # noqa: E402
21
21
  from engine_requires import requires_status # noqa: E402
22
22
  from engine_admission import load_admission, is_blocked, is_admitted # noqa: E402
23
23
  from cli_io import dumps
24
+ # 状态词表唯一真源(2026-11-09 收口):engine status / breaker state
25
+ import engine_states
24
26
 
25
27
 
26
28
  def _cost_tier_of(engine_id: str, tiers: dict[str, list[str]]) -> str:
@@ -61,7 +63,7 @@ def _runtime_status(engine_id: str,
61
63
  from circuit_breaker import get_breaker
62
64
  st = get_breaker().status(engine_id)
63
65
  out["breaker"] = {
64
- "state": st.get("state", "closed"),
66
+ "state": st.get("state", engine_states.BREAKER_CLOSED),
65
67
  "failures": st.get("failures", 0),
66
68
  "cooldown_remain": st.get("cooldown_remain", 0),
67
69
  "last_kind": st.get("last_kind"),
@@ -143,27 +145,32 @@ def engine_detail(engine_id: str, spec: dict[str, Any] | None = None,
143
145
  and not quota_exhausted
144
146
  and not bool(spec.get("explicit_only"))
145
147
  )
146
- status = "ready"
148
+ # engine_detail 的 status 是「引擎清单展示态」,与调用结局 outcome.status
149
+ # 是两套词表:这里用下划线(quota_exhausted / missing_key)且带 missing_*
150
+ # 等展示专属值,outcome 用连字符(quota-exhausted)。两者不可混用,
151
+ # 混用会让 list-engines 的既有口径与下游测试同时失配(2026-11-09 实测)。
152
+ # 词表收在 engine_states 的 ENGINE_DETAIL_STATUSES,不在此写字面量。
153
+ status = engine_states.ENGINE_STATUS_READY
147
154
  if not known:
148
- status = "unknown"
155
+ status = engine_states.ENGINE_STATUS_UNKNOWN
149
156
  elif not config_enabled:
150
- status = "disabled"
157
+ status = engine_states.ENGINE_STATUS_DISABLED
151
158
  elif not allowed:
152
- status = "env_filtered"
159
+ status = engine_states.ENGINE_STATUS_ENV_FILTERED
153
160
  elif not env_ok:
154
- status = "missing_key"
161
+ status = engine_states.ENGINE_STATUS_MISSING_KEY
155
162
  elif not dep_ok:
156
163
  # 后端工具缺失:密钥齐全、脚本存在,但真正干活的外部命令没有。
157
164
  # 此前这类引擎一律显示 ready,调用后静默返回空,无从定位。
158
- status = "missing_dep"
165
+ status = engine_states.ENGINE_STATUS_MISSING_DEP
159
166
  elif quota_exhausted:
160
- status = "quota_exhausted"
167
+ status = engine_states.ENGINE_STATUS_QUOTA_EXHAUSTED
161
168
  elif blocked:
162
- status = "blocked"
169
+ status = engine_states.ENGINE_STATUS_BLOCKED
163
170
  elif admitted:
164
- status = "admitted"
171
+ status = engine_states.ENGINE_STATUS_ADMITTED
165
172
  else:
166
- status = "ready" # 未验证但可用(兼容)
173
+ status = engine_states.ENGINE_STATUS_READY # 未验证但可用(兼容)
167
174
 
168
175
  return {
169
176
  "engine_id": engine_id,
@@ -243,6 +250,37 @@ def compact_engine_row(row: dict[str, Any]) -> dict[str, Any]:
243
250
  return slim
244
251
 
245
252
 
253
+ # 列式投影的字段顺序(唯一真源):--all 的 JSON 输出按这个顺序给值,
254
+ # 消费方按 fields 解包。改动这里等于改输出契约,需同步测试与文档。
255
+ COMPACT_FIELDS: tuple[str, ...] = (
256
+ "engine_id", "enabled", "type", "cost_tier", "status", "explicit_only",
257
+ "env_ready", "routable", "quota_exhausted", "dep_ready",
258
+ "missing_env", "missing_deps", "disabled_reason",
259
+ "quota_exhausted_reason", "failure",
260
+ )
261
+
262
+
263
+ def compact_engine_table(rows: list[dict[str, Any]]) -> dict[str, Any]:
264
+ """把逐条投影打成**列式** JSON:{"fields": [...], "rows": [[...], ...]}。
265
+
266
+ 为什么必须列式(2026-11-10):compact_engine_row 逐条输出时,15 个字段名
267
+ 在 301 个引擎上各出现一次——键名占 70.7 KB,超过 64 KB 上限本身。引擎数
268
+ 随每次接入增长,而键名成本是 O(引擎数 × 字段数),注定持续膨胀。
269
+
270
+ 列式把键名从 N 次降到 1 次:实测 301 源 67.7 KB → 25.8 KB(-62%),且
271
+ 引擎再翻倍也不会顶到上限(行值本身很短:健康源一行约 60 B)。
272
+
273
+ 契约:字段顺序即 COMPACT_FIELDS,缺失键补 None(不省略列——省略会让
274
+ 列位错乱,消费方无法按 fields 对齐)。健康源的条件键为 None,非空值
275
+ 才占实际字节。
276
+ """
277
+ cols: list[list[Any]] = []
278
+ for r in rows:
279
+ slim = compact_engine_row(r)
280
+ cols.append([slim.get(f) for f in COMPACT_FIELDS])
281
+ return {"fields": list(COMPACT_FIELDS), "rows": cols}
282
+
283
+
246
284
  def list_engines_detail(
247
285
  *,
248
286
  routable_only: bool = False,
@@ -31,6 +31,7 @@ if str(SCRIPT_DIR) not in sys.path:
31
31
  sys.path.insert(0, str(SCRIPT_DIR))
32
32
 
33
33
  from config import load_config # noqa: E402
34
+ import engine_states # noqa: E402
34
35
  from engine_env import missing_env_for, env_ready # noqa: E402
35
36
  from engine_admission import record_validation, load_admission # noqa: E402
36
37
  from engine_status import engine_detail # noqa: E402
@@ -214,21 +215,21 @@ def run_health(engine_id: str, *, query: str | None = None, n: int = 3,
214
215
  if not spec:
215
216
  return {
216
217
  "ok": False,
217
- "status": "error",
218
+ "status": engine_states.VALIDATION_STATUS_ERROR,
218
219
  "engine": engine_id,
219
220
  "error": "engine_not_in_config",
220
221
  }
221
222
  if not spec.get("enabled", True):
222
223
  return {
223
224
  "ok": False,
224
- "status": "skipped",
225
+ "status": engine_states.VALIDATION_STATUS_SKIPPED,
225
226
  "engine": engine_id,
226
227
  "error": "disabled_in_config",
227
228
  }
228
229
  if not env_ready(engine_id, spec):
229
230
  return {
230
231
  "ok": False,
231
- "status": "skipped",
232
+ "status": engine_states.VALIDATION_STATUS_SKIPPED,
232
233
  "engine": engine_id,
233
234
  "error": "missing_env",
234
235
  "missing_env": missing_env_for(engine_id, spec),
@@ -239,7 +240,7 @@ def run_health(engine_id: str, *, query: str | None = None, n: int = 3,
239
240
  if engine_id not in reg:
240
241
  return {
241
242
  "ok": False,
242
- "status": "error",
243
+ "status": engine_states.VALIDATION_STATUS_ERROR,
243
244
  "engine": engine_id,
244
245
  "error": "no_builder_or_not_registered",
245
246
  "type": spec.get("type"),
@@ -259,7 +260,7 @@ def run_health(engine_id: str, *, query: str | None = None, n: int = 3,
259
260
  except Exception as e:
260
261
  return {
261
262
  "ok": False,
262
- "status": "error",
263
+ "status": engine_states.VALIDATION_STATUS_ERROR,
263
264
  "engine": engine_id,
264
265
  "error": f"{type(e).__name__}: {e}",
265
266
  "latency_ms": round((time.time() - t0) * 1000, 1),
@@ -284,7 +285,8 @@ def run_health(engine_id: str, *, query: str | None = None, n: int = 3,
284
285
  ok = False
285
286
  return {
286
287
  "ok": ok,
287
- "status": "pass" if ok else "fail",
288
+ "status": (engine_states.VALIDATION_STATUS_PASS if ok
289
+ else engine_states.VALIDATION_STATUS_FAIL),
288
290
  "engine": engine_id,
289
291
  "query": query,
290
292
  "count": len(results),
@@ -313,11 +315,11 @@ def run_quality(engine_id: str, *, queries: list[dict[str, str]] | None = None,
313
315
  """质量基准:多 query 空结果率、平均延迟、字段完整率。"""
314
316
  spec = _get_spec(engine_id)
315
317
  if not spec or not spec.get("enabled", True):
316
- return {"ok": False, "status": "skipped", "engine": engine_id, "error": "disabled_or_missing"}
318
+ return {"ok": False, "status": engine_states.VALIDATION_STATUS_SKIPPED, "engine": engine_id, "error": "disabled_or_missing"}
317
319
  if not env_ready(engine_id, spec):
318
320
  return {
319
321
  "ok": False,
320
- "status": "skipped",
322
+ "status": engine_states.VALIDATION_STATUS_SKIPPED,
321
323
  "engine": engine_id,
322
324
  "error": "missing_env",
323
325
  "missing_env": missing_env_for(engine_id, spec),
@@ -392,7 +394,8 @@ def run_quality(engine_id: str, *, queries: list[dict[str, str]] | None = None,
392
394
 
393
395
  return {
394
396
  "ok": ok,
395
- "status": "pass" if ok else "fail",
397
+ "status": (engine_states.VALIDATION_STATUS_PASS if ok
398
+ else engine_states.VALIDATION_STATUS_FAIL),
396
399
  "engine": engine_id,
397
400
  "quality_score": quality_score,
398
401
  "pass_rate": round(pass_rate, 3),
@@ -410,7 +413,7 @@ def run_quality(engine_id: str, *, queries: list[dict[str, str]] | None = None,
410
413
  def validate_engine(
411
414
  engine_id: str,
412
415
  *,
413
- stage: str = "health",
416
+ stage: str = engine_states.VALIDATION_STAGE_HEALTH,
414
417
  admit: bool = False,
415
418
  timeout: float = 10.0,
416
419
  write_doc: bool = False,
@@ -419,8 +422,9 @@ def validate_engine(
419
422
  """执行验证并可选写入 admission。"""
420
423
  stages = []
421
424
  if stage == "all":
422
- stages = ["health", "quality"]
423
- elif stage in ("health", "quality"):
425
+ stages = [engine_states.VALIDATION_STAGE_HEALTH,
426
+ engine_states.VALIDATION_STAGE_QUALITY]
427
+ elif stage in engine_states.VALIDATION_STAGES:
424
428
  stages = [stage]
425
429
  else:
426
430
  return {"ok": False, "error": f"unknown stage: {stage}"}
@@ -430,43 +434,44 @@ def validate_engine(
430
434
  "stage_requested": stage,
431
435
  "stages": {},
432
436
  "ok": True,
433
- "status": "pass",
437
+ "status": engine_states.VALIDATION_STATUS_PASS,
434
438
  "profile": profile,
435
439
  }
436
440
  passed: list[str] = []
437
441
  health_res = None
438
442
  quality_res = None
439
443
 
440
- if "health" in stages:
444
+ if engine_states.VALIDATION_STAGE_HEALTH in stages:
441
445
  health_res = run_health(engine_id, timeout=timeout)
442
446
  report["stages"]["health"] = health_res
443
- if health_res.get("status") == "skipped":
447
+ if health_res.get("status") == engine_states.VALIDATION_STATUS_SKIPPED:
444
448
  report["ok"] = False
445
- report["status"] = "skipped"
449
+ report["status"] = engine_states.VALIDATION_STATUS_SKIPPED
446
450
  report["skip_reason"] = health_res.get("error")
447
451
  elif health_res.get("ok"):
448
- passed.append("health")
452
+ passed.append(engine_states.VALIDATION_STAGE_HEALTH)
449
453
  else:
450
454
  report["ok"] = False
451
- report["status"] = "fail"
455
+ report["status"] = engine_states.VALIDATION_STATUS_FAIL
452
456
 
453
- if "quality" in stages and report.get("status") != "skipped":
457
+ if ("quality" in stages and report.get("status")
458
+ != engine_states.VALIDATION_STATUS_SKIPPED):
454
459
  quality_res = run_quality(engine_id, timeout=timeout, profile=profile)
455
460
  report["stages"]["quality"] = quality_res
456
- if quality_res.get("status") == "skipped":
461
+ if quality_res.get("status") == engine_states.VALIDATION_STATUS_SKIPPED:
457
462
  report["ok"] = False
458
- report["status"] = "skipped"
463
+ report["status"] = engine_states.VALIDATION_STATUS_SKIPPED
459
464
  report["skip_reason"] = quality_res.get("error")
460
465
  elif quality_res.get("ok"):
461
- passed.append("quality")
466
+ passed.append(engine_states.VALIDATION_STAGE_QUALITY)
462
467
  else:
463
468
  report["ok"] = False
464
- if report["status"] != "skipped":
465
- report["status"] = "fail"
469
+ if report["status"] != engine_states.VALIDATION_STATUS_SKIPPED:
470
+ report["status"] = engine_states.VALIDATION_STATUS_FAIL
466
471
 
467
472
  # 写 admission
468
- if report.get("status") != "skipped":
469
- blocked = not ("health" in passed)
473
+ if report.get("status") != engine_states.VALIDATION_STATUS_SKIPPED:
474
+ blocked = not (engine_states.VALIDATION_STAGE_HEALTH in passed)
470
475
  # reason 只在**被 block** 时写:它表达「为什么不能用」。
471
476
  # 未 block 时留空——`record_validation` 的不变式是
472
477
  # 「blocked=False ⇒ reason 为空」,成功路径上写
@@ -474,7 +479,8 @@ def validate_engine(
474
479
  # blocked=false/reason=validation_passed,与注释宣称的语义矛盾)。
475
480
  # 成功与否由 blocked/admitted_at/stages_passed 表达,不需要 reason。
476
481
  if blocked:
477
- reason = (health_res or {}).get("error") or "health_failed"
482
+ reason = ((health_res or {}).get("error")
483
+ or engine_states.ADMISSION_REASON_HEALTH_FAILED)
478
484
  else:
479
485
  reason = ""
480
486
  avg_lat = None
@@ -489,17 +495,17 @@ def validate_engine(
489
495
  stages_passed=passed,
490
496
  quality_score=qscore,
491
497
  avg_latency_ms=avg_lat,
492
- blocked=blocked if ("health" in stages) else None,
498
+ blocked=blocked if (engine_states.VALIDATION_STAGE_HEALTH in stages) else None,
493
499
  reason=reason,
494
500
  health=health_res,
495
501
  quality=quality_res,
496
- admit=admit and ("health" in passed),
502
+ admit=admit and (engine_states.VALIDATION_STAGE_HEALTH in passed),
497
503
  )
498
504
  report["admission"] = adm
499
505
  else:
500
506
  report["admission"] = load_admission(engine_id)
501
507
 
502
- if write_doc and report.get("status") == "pass":
508
+ if write_doc and report.get("status") == engine_states.VALIDATION_STATUS_PASS:
503
509
  path = _write_engine_doc(engine_id, report)
504
510
  report["doc_path"] = str(path)
505
511
 
@@ -514,8 +520,8 @@ def _write_engine_doc(engine_id: str, report: dict[str, Any]) -> Path:
514
520
  path = docs / f"{engine_id}.md"
515
521
  detail = report.get("detail") or engine_detail(engine_id)
516
522
  adm = report.get("admission") or {}
517
- health = (report.get("stages") or {}).get("health") or {}
518
- quality = (report.get("stages") or {}).get("quality") or {}
523
+ health = (report.get("stages") or {}).get(engine_states.VALIDATION_STAGE_HEALTH) or {}
524
+ quality = (report.get("stages") or {}).get(engine_states.VALIDATION_STAGE_QUALITY) or {}
519
525
  lines = [
520
526
  f"# 引擎:`{engine_id}`",
521
527
  "",
@@ -576,7 +582,8 @@ def _free_engine_ids() -> list[str]:
576
582
  def main() -> int:
577
583
  parser = argparse.ArgumentParser(description="Argo 引擎标准化验证")
578
584
  parser.add_argument("--engine", "-e", help="引擎 ID")
579
- parser.add_argument("--stage", default="health", choices=["health", "quality", "all"])
585
+ parser.add_argument("--stage", default=engine_states.VALIDATION_STAGE_HEALTH,
586
+ choices=[*sorted(engine_states.VALIDATION_STAGES), "all"])
580
587
  parser.add_argument("--admit", action="store_true", help="通过后写入准入状态")
581
588
  parser.add_argument("--write-doc", action="store_true", help="通过后生成 docs/engines/<id>.md")
582
589
  parser.add_argument("--timeout", type=float, default=10.0)
@@ -608,30 +615,31 @@ def main() -> int:
608
615
  stage = args.stage
609
616
  admit = args.admit
610
617
  if args.all_free and args.stage == "all" and len(targets) > 3:
611
- stage = "health"
618
+ stage = engine_states.VALIDATION_STAGE_HEALTH
612
619
  rep = validate_engine(
613
620
  eng, stage=stage, admit=admit, timeout=args.timeout,
614
621
  write_doc=args.write_doc, profile=args.profile,
615
622
  )
616
623
  reports.append(rep)
617
- if rep.get("status") == "fail":
624
+ if rep.get("status") == engine_states.VALIDATION_STATUS_FAIL:
618
625
  exit_ok = False
619
- elif args.strict and rep.get("status") != "pass":
626
+ elif (args.strict and rep.get("status")
627
+ != engine_states.VALIDATION_STATUS_PASS):
620
628
  # skipped 也是「这个源没证明自己能交付」:夜间门禁要的是
621
629
  # 11 个关键源全部 pass,缺 key/改名/禁用都不该静默全绿。
622
630
  exit_ok = False
623
631
  if not args.json:
624
632
  st = rep.get("status")
625
633
  lat = ""
626
- h = (rep.get("stages") or {}).get("health") or {}
634
+ h = (rep.get("stages") or {}).get(engine_states.VALIDATION_STAGE_HEALTH) or {}
627
635
  if h.get("latency_ms") is not None:
628
636
  lat = f" {h['latency_ms']}ms"
629
- q = (rep.get("stages") or {}).get("quality") or {}
637
+ q = (rep.get("stages") or {}).get(engine_states.VALIDATION_STAGE_QUALITY) or {}
630
638
  qnote = f" q={q.get('quality_score')}" if q else ""
631
639
  print(f"[{st}] {eng}{lat}{qnote} stages_passed={ (rep.get('admission') or {}).get('stages_passed')}")
632
640
  if rep.get("skip_reason"):
633
641
  print(f" skip: {rep['skip_reason']}")
634
- if st == "fail":
642
+ if st == engine_states.VALIDATION_STATUS_FAIL:
635
643
  err = h.get("error") or q.get("error") or rep.get("error")
636
644
  print(f" error: {err}")
637
645
 
@@ -104,6 +104,9 @@ from engines_builders import (
104
104
  _build_google_scholar_engine,
105
105
  _build_v2ex_engine,
106
106
  _build_bing_rss_engine,
107
+ _build_repology_engine,
108
+ _build_grep_app_engine,
109
+ _build_hf_papers_engine,
107
110
  _build_ths_hot_engine,
108
111
  _build_cls_telegraph_engine,
109
112
  _build_em_global_news_engine,
@@ -136,6 +139,7 @@ from engines_builders import (
136
139
  _build_weather_cn_engine,
137
140
  _build_google_news_engine,
138
141
  _build_met_museum_engine, _build_open_library_engine,
142
+ _build_vam_engine,
139
143
  _build_weread_engine,
140
144
  _build_douban_book_engine,
141
145
  _build_fred_engine,
@@ -439,6 +443,7 @@ _BUILDERS = {
439
443
  "weather_cn": _build_weather_cn_engine,
440
444
  "google_news": _build_google_news_engine,
441
445
  "met_museum": _build_met_museum_engine,
446
+ "vam": _build_vam_engine,
442
447
  "github": _build_github_engine,
443
448
  "dshopen": _build_dshopen_engine,
444
449
  "explainx": _build_explainx_engine,
@@ -453,6 +458,9 @@ _BUILDERS = {
453
458
  "tracemoe": _build_tracemoe_engine,
454
459
  "pixiv": _build_pixiv_engine,
455
460
  "bing_rss": _build_bing_rss_engine,
461
+ "repology": _build_repology_engine,
462
+ "grep_app": _build_grep_app_engine,
463
+ "hf_papers": _build_hf_papers_engine,
456
464
  "ths_hot": _build_ths_hot_engine,
457
465
  "cls_telegraph": _build_cls_telegraph_engine,
458
466
  "twitter_syndication": _build_twitter_syndication_engine,
@@ -13,6 +13,7 @@ import re
13
13
  import subprocess
14
14
  import sys
15
15
  import threading
16
+ import engine_states as _st # 失败归因词表唯一真源
16
17
 
17
18
  import serp_kill_log # noqa: E402 守卫接线+误杀账本(2026-10-10 拆出,stdlib 级轻量)
18
19
  import time
@@ -564,8 +565,7 @@ def _http_get_raw(url: str, headers: dict, timeout: float,
564
565
  return None
565
566
  except Exception as e:
566
567
  _get_logger().warning(f"HTTP 引擎失败(HttpClient): {type(e).__name__} {e}")
567
- note_failure(engine, "network", "exception",
568
- f"{type(e).__name__}: {e}")
568
+ note_failure(engine, _st.FAILURE_NETWORK, "exception", f"{type(e).__name__}: {e}")
569
569
  return None
570
570
  # 回退 urllib(原行为)。出口仍须经 net_proxy——否则设
571
571
  # ARGO_ENGINE_HTTP_CLIENT=0 就顺带关掉了代理支持,在必须走代理的环境里
@@ -588,7 +588,7 @@ def _http_get_raw(url: str, headers: dict, timeout: float,
588
588
  return None
589
589
  except Exception as e:
590
590
  _get_logger().warning(f"HTTP 引擎失败: {e}")
591
- note_failure(engine, "network", "exception", str(e))
591
+ note_failure(engine, _st.FAILURE_NETWORK, "exception", str(e))
592
592
  return None
593
593
 
594
594
 
@@ -602,7 +602,7 @@ def _note_http_failure(engine: str, status: int, body: str) -> None:
602
602
  try:
603
603
  from engine_failure import classify
604
604
  except ImportError: # 模块缺失时退化为最小事实,不猜类别
605
- note_failure(engine, "unknown", f"http-{status}", (body or "")[:120])
605
+ note_failure(engine, _st.FAILURE_UNKNOWN, f"http-{status}", (body or "")[:120])
606
606
  return
607
607
  res = classify(status_code=status, output=(body or "")[:2000])
608
608
  note_failure(engine, res["category"], res["reason"],
@@ -664,11 +664,11 @@ def http_open(req: Any, timeout: float = 10.0, engine: str = ""):
664
664
  raise
665
665
  except urllib.error.URLError as e:
666
666
  _get_logger().warning(f"HTTP 引擎失败: {e}")
667
- note_failure(engine, "network", "urlopen", str(e)[:160])
667
+ note_failure(engine, _st.FAILURE_NETWORK, "urlopen", str(e)[:160])
668
668
  raise
669
669
  except OSError as e:
670
670
  _get_logger().warning(f"HTTP 引擎失败: {e}")
671
- note_failure(engine, "network", "exception",
671
+ note_failure(engine, _st.FAILURE_NETWORK, "exception",
672
672
  f"{type(e).__name__}: {e}")
673
673
  raise
674
674
  except Exception as e:
@@ -676,7 +676,7 @@ def http_open(req: Any, timeout: float = 10.0, engine: str = ""):
676
676
  # ValueError 既不是 URLError 也不是 OSError,不兜这一层就会穿透归因,
677
677
  # 与该函数的契约不符,也比 _http_get_raw 的保底更窄。归因后原样抛出。
678
678
  _get_logger().warning(f"HTTP 引擎失败: {type(e).__name__} {e}")
679
- note_failure(engine, "network", "exception",
679
+ note_failure(engine, _st.FAILURE_NETWORK, "exception",
680
680
  f"{type(e).__name__}: {e}")
681
681
  raise
682
682
  with resp:
@@ -800,7 +800,18 @@ def _parse_http_payload(raw: str, fmt: str, eng: str, n: int,
800
800
  _get_logger().warning(f"HTTP 引擎业务错误: {eng} {env_err[:120]}")
801
801
  return [{"error": f"{eng} {env_err}", "source": eng}]
802
802
  limit = max(1, int(n or 5))
803
- # 专用 JSON 解析器优先(DDG Instant Answer / UAPI / Semantic Scholar 等)
803
+ # 0. 注册响应解析器优先(spec.response.parser 显式声明,P1-2)
804
+ try:
805
+ from engines_parsers import resolve as _resolve_parsers
806
+ _parsers = _resolve_parsers(spec)
807
+ if _parsers:
808
+ _cur = data
809
+ for _p in _parsers:
810
+ _cur = _p(_cur, spec)
811
+ return _apply_url_kind(_ensure_engine_source(_cur, eng)[:limit], spec)
812
+ except Exception as _pe:
813
+ _get_logger().warning(f"注册解析器失败: {eng} {_pe}")
814
+ # 1. 专用 JSON 解析器兜底(DDG Instant Answer / UAPI / Semantic Scholar 等)
804
815
  custom = _CUSTOM_JSON_PARSERS.get(eng)
805
816
  if custom:
806
817
  return _apply_url_kind(_ensure_engine_source(custom(data), eng)[:limit], spec)
@@ -860,11 +871,10 @@ def _parse_http_payload(raw: str, fmt: str, eng: str, n: int,
860
871
  parsed, eng, preserve=bool(spec.get("preserve_source"))
861
872
  )[:limit],
862
873
  spec)
863
- if isinstance(data, list):
864
- return _ensure_engine_source(
865
- _parse_generic({"results": data}, eng, limit), eng
866
- )[:limit]
867
- return _ensure_engine_source(_parse_generic(data, eng, limit), eng)[:limit]
874
+ parsed = _parse_generic(data, eng, limit, spec)
875
+ return _apply_url_kind(_ensure_engine_source(
876
+ parsed, eng, preserve=bool(spec.get("preserve_source"))
877
+ )[:limit], spec)
868
878
 
869
879
 
870
880
  # ── HTML 网页解析引擎 ─────────────────────────────────────────────────────────
@@ -1013,7 +1023,7 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
1013
1023
  if _detect_anti_bot(html):
1014
1024
  # 命中拦截页:归因为封锁而非空结果。不记这条,封锁会在聚合层
1015
1025
  # 伪装成「无结果」,被封引擎会被当故障累计进熔断。
1016
- note_failure(engine_name, "blocked", "anti-bot-page", full_url)
1026
+ note_failure(engine_name, _st.FAILURE_BLOCKED, "anti-bot-page", full_url)
1017
1027
  return []
1018
1028
  maps = _get_parse_maps()
1019
1029
  html_maps = maps.get("html", {})
@@ -1032,7 +1042,7 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
1032
1042
  containers = soup.select(container_sel)
1033
1043
  except Exception:
1034
1044
  return []
1035
- from bs4 import NavigableString
1045
+ from bs4 import Comment, NavigableString
1036
1046
 
1037
1047
  def _el_text(el) -> str:
1038
1048
  """提取元素文本。兼容 bs4 4.13+ 将页面文本标记为 TemplateString、
@@ -1046,7 +1056,10 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
1046
1056
  while stack:
1047
1057
  node = stack.pop(0)
1048
1058
  if isinstance(node, NavigableString):
1049
- parts.append(str(node))
1059
+ # Comment 是 NavigableString 子类:搜狗把内部标记写成
1060
+ # <!--awbg0--> 混进结果标题(实测 2026-11-10),剥离。
1061
+ if not isinstance(node, Comment):
1062
+ parts.append(str(node))
1050
1063
  elif hasattr(node, "contents"):
1051
1064
  stack = node.contents + stack
1052
1065
  return "".join(parts)
@@ -1248,78 +1261,11 @@ def _parse_xml(text: str, engine_name: str) -> list[dict[str, Any]]:
1248
1261
  return results
1249
1262
 
1250
1263
 
1251
- def _parse_generic(data: dict[str, Any], engine_name: str = "?",
1252
- limit: int = 10) -> list[dict[str, Any]]:
1253
- """通用 JSON 解析:自动探测常见列表路径与字段别名。
1254
-
1255
- 列表探测(最多 3 层,只走已知键):
1256
- - 顶层 results/items/data/works/search 等
1257
- - 一层嵌套(data.results / data.value)
1258
- - 二层嵌套(data.webPages.value —— 博查等 AI 搜索 API)
1259
-
1260
- 字段别名:title|name|heading;url|URL|html_url|link|href;
1261
- snippet|summary|content|description|abstract。
1262
- """
1263
- list_keys = (
1264
- "results", "items", "value", "works", "search", "data",
1265
- "organic", "webPages", "hits", "documents", "entries",
1266
- )
1267
-
1268
- def _find_items(obj: Any, depth: int = 0) -> list | None:
1269
- if depth > 3 or obj is None:
1270
- return None
1271
- if isinstance(obj, list):
1272
- # 空列表或 dict 元素列表视为结果集;纯标量列表跳过
1273
- if not obj or isinstance(obj[0], dict):
1274
- return obj
1275
- return None
1276
- if not isinstance(obj, dict):
1277
- return None
1278
- for key in list_keys:
1279
- if key not in obj:
1280
- continue
1281
- found = _find_items(obj[key], depth + 1)
1282
- if found is not None:
1283
- return found
1284
- # 浅层扫描嵌套 dict(避免深扫整棵树误抓无关数组)
1285
- if depth < 2:
1286
- for v in obj.values():
1287
- if isinstance(v, dict):
1288
- found = _find_items(v, depth + 1)
1289
- if found is not None:
1290
- return found
1291
- return None
1292
-
1293
- items = _find_items(data) if isinstance(data, (dict, list)) else None
1294
- if not items or not isinstance(items, list):
1295
- return []
1296
-
1297
- results: list[dict[str, Any]] = []
1298
- for i in items:
1299
- if not isinstance(i, dict):
1300
- continue
1301
- title = i.get("title") or i.get("name") or i.get("heading") or i.get("Title") or ""
1302
- if isinstance(title, list):
1303
- title = title[0] if title else ""
1304
- url = (
1305
- i.get("url") or i.get("URL") or i.get("html_url")
1306
- or i.get("link") or i.get("href") or ""
1307
- )
1308
- snippet = (
1309
- i.get("snippet") or i.get("summary") or i.get("content")
1310
- or i.get("description") or i.get("abstract") or ""
1311
- )
1312
- if isinstance(snippet, list):
1313
- snippet = snippet[0] if snippet else ""
1314
- score = rank_score(next((v for v in (i.get("score"), i.get("relevance_score")) if v not in (None, "")), 0.5), len(results)) # 哨兵判空:显式 0 分不得膨胀成 0.5
1315
- results.append({
1316
- "title": str(title)[:200],
1317
- "url": str(url),
1318
- "snippet": str(snippet)[:300],
1319
- "score": score,
1320
- "source": engine_name,
1321
- })
1322
- return results[:limit]
1264
+ def _parse_generic(data: dict[str, Any] | list, engine_name: str = "?",
1265
+ limit: int = 10, spec: dict[str, Any] | None = None) -> list[dict[str, Any]]:
1266
+ """通用智能推断 JSON 解析(委托 engines_parsers.parse_smart_generic)。"""
1267
+ from engines_parsers import parse_smart_generic
1268
+ return parse_smart_generic(data, engine_name, limit, spec)
1323
1269
 
1324
1270
 
1325
1271
  def _ensure_engine_source(