argo-search 2.14.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.es.md +18 -8
- package/README.ja.md +18 -8
- package/README.ko.md +18 -8
- package/README.md +511 -608
- package/README.zh.md +975 -0
- package/SKILL.md +1 -1
- package/assets/readme/counts.json +1 -1
- package/backends/domain_profiles.json +24 -0
- package/backends/engine_registry.yaml +69 -18
- package/backends/quota_profiles.json +40 -0
- package/config.yaml +23 -3
- package/docs/CHANGELOG.md +22 -0
- package/docs/ENGINE_CATALOG.md +41 -37
- package/docs/MCP_SETUP.md +1 -1
- package/docs/RELEASE_NOTES_v2.14.0.md +12 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +80 -0
- package/docs/RELEASING.md +52 -0
- package/engines/specs/artic.yaml +11 -1
- package/engines/specs/cleveland.yaml +15 -1
- package/engines/specs/clinicaltrials.yaml +16 -1
- package/engines/specs/cnii.yaml +15 -4
- package/engines/specs/deezer.yaml +12 -1
- package/engines/specs/doaj.yaml +14 -1
- package/engines/specs/endoflife.yaml +16 -1
- package/engines/specs/eu_opendata.yaml +11 -1
- package/engines/specs/europeana.yaml +19 -1
- package/engines/specs/feed.yaml +62 -0
- package/engines/specs/figshare.yaml +12 -1
- package/engines/specs/hackernews.yaml +17 -2
- package/engines/specs/hal.yaml +19 -1
- package/engines/specs/hf_datasets.yaml +59 -0
- package/engines/specs/hf_papers.yaml +17 -1
- package/engines/specs/jikan.yaml +12 -10
- package/engines/specs/kaggle.yaml +5 -3
- package/engines/specs/maven.yaml +61 -0
- package/engines/specs/nasa_cmr.yaml +12 -1
- package/engines/specs/nuget.yaml +57 -0
- package/engines/specs/tatoeba.yaml +14 -1
- package/engines/specs/tvmaze.yaml +5 -1
- package/engines/specs/usda.yaml +14 -1
- package/package.json +2 -1
- package/packages/dsh-plugin/dsh/native-tools.mjs +61 -113
- package/packages/dsh-plugin/dsh/wide-research.js +1 -1
- package/packages/dsh-plugin/package.json +1 -1
- package/scripts/badcase_ledger.py +49 -5
- package/scripts/build_release_assets.sh +43 -15
- package/scripts/dormant_ledger.py +225 -0
- package/scripts/engine_states.py +6 -1
- package/scripts/engine_validate.py +182 -6
- package/scripts/engines.py +0 -36
- package/scripts/engines_base.py +27 -67
- package/scripts/engines_builders.py +0 -36
- package/scripts/engines_builders_batch16.py +6 -179
- package/scripts/engines_builders_batch9.py +0 -204
- package/scripts/engines_builders_feeds.py +148 -30
- package/scripts/engines_builders_intl.py +0 -328
- package/scripts/engines_builders_science.py +0 -85
- package/scripts/engines_builders_tech.py +0 -98
- package/scripts/engines_parsers.py +534 -9
- package/scripts/evidence_loop.py +91 -4
- package/scripts/gen_engine_catalog.py +2 -2
- package/scripts/gen_native_tools.py +2 -1
- package/scripts/local_intent.py +51 -15
- package/scripts/local_seek.py +37 -4
- package/scripts/mcp_handlers.py +124 -72
- package/scripts/mcp_server.py +1 -1
- package/scripts/mcp_tools.py +143 -61
- package/scripts/mcp_transport.py +42 -10
- package/scripts/pre-commit +25 -1
- package/scripts/release.py +20 -11
- package/scripts/release_check.py +1 -1
- package/scripts/route_policy.py +6 -1
- package/scripts/search_cli.py +44 -7
- package/scripts/secret_guard.py +106 -0
- package/scripts/semantic_evidence.py +230 -15
- package/scripts/settings_page.py +80 -8
- package/scripts/source_audit.py +77 -0
- package/scripts/sync_backends.py +7 -0
- package/sub-skills/local-seek/scripts/seek_fts.py +9 -1
- package/README.en.md +0 -826
- package/scripts/image_vision/vision_probe +0 -0
|
@@ -80,46 +80,6 @@ def _http_text(url: str, timeout: float, engine: str = "") -> str:
|
|
|
80
80
|
return resp.read().decode("utf-8", "replace")
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
# ── CiNii Research ────────────────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
def _build_cnii_engine(spec: dict[str, Any]) -> Any:
|
|
86
|
-
"""CiNii Research 学术总库(cir.nii.ac.jp,OpenSearch JSON-LD,免认证)。"""
|
|
87
|
-
timeout = spec.get("timeout", 12)
|
|
88
|
-
|
|
89
|
-
@safe_search
|
|
90
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
91
|
-
to = _timeout or timeout
|
|
92
|
-
url = f"https://cir.nii.ac.jp/opensearch/all?q={urllib.parse.quote(query)}&format=json&count={min(n, 10)}"
|
|
93
|
-
try:
|
|
94
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
95
|
-
except Exception as e:
|
|
96
|
-
logger.warning(f"CiNii 失败: {e}")
|
|
97
|
-
return []
|
|
98
|
-
results = []
|
|
99
|
-
for _rk, it in enumerate((data.get("items") or [])[:n]):
|
|
100
|
-
if not isinstance(it, dict):
|
|
101
|
-
continue
|
|
102
|
-
title = it.get("title", "")
|
|
103
|
-
link = it.get("link")
|
|
104
|
-
url_ = link.get("@id", "") if isinstance(link, dict) else str(link or "")
|
|
105
|
-
creators = it.get("dc:creator") or []
|
|
106
|
-
if isinstance(creators, str):
|
|
107
|
-
creators = [creators]
|
|
108
|
-
year = it.get("prism:publicationDate", "")
|
|
109
|
-
parts = [p for p in (", ".join(str(c) for c in creators[:3]), str(year)) if p]
|
|
110
|
-
if not title and not url_:
|
|
111
|
-
continue
|
|
112
|
-
results.append({
|
|
113
|
-
"title": str(title)[:200],
|
|
114
|
-
"url": url_,
|
|
115
|
-
"snippet": (" · ".join(parts) + " · " + str(it.get("description", "")))[:300],
|
|
116
|
-
"source": "cnii",
|
|
117
|
-
"score": rank_score(0.7, _rk),
|
|
118
|
-
})
|
|
119
|
-
return results
|
|
120
|
-
return _engine
|
|
121
|
-
|
|
122
|
-
|
|
123
83
|
# ── NDL Search(OpenSearch RSS)───────────────────────────────────────────────
|
|
124
84
|
|
|
125
85
|
def _build_ndl_engine(spec: dict[str, Any]) -> Any:
|
|
@@ -318,178 +278,6 @@ def _build_dnb_engine(spec: dict[str, Any]) -> Any:
|
|
|
318
278
|
return _engine
|
|
319
279
|
|
|
320
280
|
|
|
321
|
-
# ── DOAJ 开放获取期刊 ─────────────────────────────────────────────────────────
|
|
322
|
-
|
|
323
|
-
def _build_doaj_engine(spec: dict[str, Any]) -> Any:
|
|
324
|
-
"""DOAJ 开放获取期刊全球总库(doaj.org/api,bibjson 嵌套结构)。"""
|
|
325
|
-
timeout = spec.get("timeout", 12)
|
|
326
|
-
|
|
327
|
-
@safe_search
|
|
328
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
329
|
-
to = _timeout or timeout
|
|
330
|
-
url = f"https://doaj.org/api/search/articles/{urllib.parse.quote(query)}?pageSize={min(n, 10)}"
|
|
331
|
-
try:
|
|
332
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
333
|
-
except Exception as e:
|
|
334
|
-
logger.warning(f"DOAJ 失败: {e}")
|
|
335
|
-
return []
|
|
336
|
-
results = []
|
|
337
|
-
for _rk5, r in enumerate((data.get("results") or [])[:n]):
|
|
338
|
-
bib = r.get("bibjson") or {}
|
|
339
|
-
title = bib.get("title", "")
|
|
340
|
-
# link 是 [{url, type}] 数组,取 fulltext/doi 优先
|
|
341
|
-
link = ""
|
|
342
|
-
for lk in (bib.get("link") or []):
|
|
343
|
-
if isinstance(lk, dict):
|
|
344
|
-
u = lk.get("url", "")
|
|
345
|
-
if u and (lk.get("type") in ("fulltext", "doi") or not link):
|
|
346
|
-
link = u
|
|
347
|
-
authors = bib.get("author") or []
|
|
348
|
-
if isinstance(authors, list):
|
|
349
|
-
names = [a.get("name", "") for a in authors[:3] if isinstance(a, dict)]
|
|
350
|
-
else:
|
|
351
|
-
names = []
|
|
352
|
-
year = bib.get("year", "")
|
|
353
|
-
parts = [p for p in (", ".join(names), str(year), bib.get("journal", {}).get("title", "") if isinstance(bib.get("journal"), dict) else "") if p]
|
|
354
|
-
if not title and not link:
|
|
355
|
-
continue
|
|
356
|
-
results.append({
|
|
357
|
-
"title": str(title)[:200],
|
|
358
|
-
"url": link,
|
|
359
|
-
"snippet": (" · ".join(parts) + " · " + str(bib.get("abstract", "")))[:300],
|
|
360
|
-
"source": "doaj",
|
|
361
|
-
"score": rank_score(0.7, _rk5),
|
|
362
|
-
})
|
|
363
|
-
return results
|
|
364
|
-
return _engine
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
# ── Europeana 欧洲文化遗产 ────────────────────────────────────────────────────
|
|
368
|
-
|
|
369
|
-
def _build_europeana_engine(spec: dict[str, Any]) -> Any:
|
|
370
|
-
"""Europeana 欧洲文化遗产聚合(api.europeana.eu,官方公开 demo key api2demo)。"""
|
|
371
|
-
timeout = spec.get("timeout", 12)
|
|
372
|
-
|
|
373
|
-
@safe_search
|
|
374
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
375
|
-
to = _timeout or timeout
|
|
376
|
-
url = (f"https://api.europeana.eu/record/v2/search.json?wskey=api2demo"
|
|
377
|
-
f"&query={urllib.parse.quote(query)}&rows={min(n, 10)}")
|
|
378
|
-
try:
|
|
379
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
380
|
-
except Exception as e:
|
|
381
|
-
logger.warning(f"Europeana 失败: {e}")
|
|
382
|
-
return []
|
|
383
|
-
results = []
|
|
384
|
-
for _rk6, it in enumerate((data.get("items") or [])[:n]):
|
|
385
|
-
if not isinstance(it, dict):
|
|
386
|
-
continue
|
|
387
|
-
title = it.get("title")
|
|
388
|
-
if isinstance(title, list):
|
|
389
|
-
title = title[0] if title else ""
|
|
390
|
-
link = it.get("link", "")
|
|
391
|
-
provider = it.get("dataProvider")
|
|
392
|
-
if isinstance(provider, list):
|
|
393
|
-
provider = provider[0] if provider else ""
|
|
394
|
-
if not title and not link:
|
|
395
|
-
continue
|
|
396
|
-
results.append({
|
|
397
|
-
"title": str(title)[:200],
|
|
398
|
-
"url": link,
|
|
399
|
-
"snippet": (f"provider: {provider}" if provider else "")[:300],
|
|
400
|
-
"source": "europeana",
|
|
401
|
-
"score": rank_score(0.7, _rk6),
|
|
402
|
-
})
|
|
403
|
-
return results
|
|
404
|
-
return _engine
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
# ── HAL 法国科研开放仓储 ──────────────────────────────────────────────────────
|
|
408
|
-
|
|
409
|
-
def _build_hal_engine(spec: dict[str, Any]) -> Any:
|
|
410
|
-
"""HAL 法国全国科研机构开放仓储(api.archives-ouvertes.fr Solr JSON)。"""
|
|
411
|
-
timeout = spec.get("timeout", 12)
|
|
412
|
-
|
|
413
|
-
@safe_search
|
|
414
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
415
|
-
to = _timeout or timeout
|
|
416
|
-
url = ("https://api.archives-ouvertes.fr/search/?wt=json"
|
|
417
|
-
f"&q={urllib.parse.quote(query)}&rows={min(n, 10)}"
|
|
418
|
-
"&fl=title_s,uri_s,abstract_s,authFullName_s,producedDate_s")
|
|
419
|
-
try:
|
|
420
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
421
|
-
except Exception as e:
|
|
422
|
-
logger.warning(f"HAL 失败: {e}")
|
|
423
|
-
return []
|
|
424
|
-
results = []
|
|
425
|
-
for _rk7, doc in enumerate((data.get("response", {}).get("docs") or [])[:n]):
|
|
426
|
-
title = doc.get("title_s")
|
|
427
|
-
if isinstance(title, list):
|
|
428
|
-
title = title[0] if title else ""
|
|
429
|
-
link = doc.get("uri_s", "")
|
|
430
|
-
authors = doc.get("authFullName_s") or []
|
|
431
|
-
date = doc.get("producedDate_s") or ""
|
|
432
|
-
parts = [p for p in (", ".join(str(a) for a in authors[:3]), str(date)) if p]
|
|
433
|
-
if not title and not link:
|
|
434
|
-
continue
|
|
435
|
-
results.append({
|
|
436
|
-
"title": str(title)[:200],
|
|
437
|
-
"url": link,
|
|
438
|
-
"snippet": (" · ".join(parts) + " · " + str(doc.get("abstract_s", "")))[:300],
|
|
439
|
-
"source": "hal",
|
|
440
|
-
"score": rank_score(0.7, _rk7),
|
|
441
|
-
})
|
|
442
|
-
return results
|
|
443
|
-
return _engine
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
# ── EU Open Data Portal ───────────────────────────────────────────────────────
|
|
447
|
-
|
|
448
|
-
def _build_eu_opendata_engine(spec: dict[str, Any]) -> Any:
|
|
449
|
-
"""EU Open Data Portal(data.europa.eu/api/hub,24 语言元数据)。"""
|
|
450
|
-
timeout = spec.get("timeout", 12)
|
|
451
|
-
|
|
452
|
-
@safe_search
|
|
453
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
454
|
-
to = _timeout or timeout
|
|
455
|
-
url = f"https://data.europa.eu/api/hub/search/search?q={urllib.parse.quote(query)}&pageSize={min(n, 10)}"
|
|
456
|
-
try:
|
|
457
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
458
|
-
except Exception as e:
|
|
459
|
-
logger.warning(f"EU ODP 失败: {e}")
|
|
460
|
-
return []
|
|
461
|
-
results = []
|
|
462
|
-
for _rk8, it in enumerate((data.get("result", {}).get("results") or [])[:n]):
|
|
463
|
-
if not isinstance(it, dict):
|
|
464
|
-
continue
|
|
465
|
-
# title 是 {语言code: 标题} 映射;优先 en/zh,否则取首个
|
|
466
|
-
title = ""
|
|
467
|
-
tl = it.get("title") or {}
|
|
468
|
-
if isinstance(tl, dict):
|
|
469
|
-
for lang in ("en", "zh", "fr", "de"):
|
|
470
|
-
if tl.get(lang):
|
|
471
|
-
title = tl[lang]
|
|
472
|
-
break
|
|
473
|
-
if not title and tl:
|
|
474
|
-
title = next(iter(tl.values()))
|
|
475
|
-
url_ = (it.get("landing_page") or it.get("resource")
|
|
476
|
-
or it.get("id") or "")
|
|
477
|
-
if isinstance(url_, list):
|
|
478
|
-
# landing_page 是 [{resource: url}] 数组
|
|
479
|
-
url_ = url_[0].get("resource", "") if url_ and isinstance(url_[0], dict) else ""
|
|
480
|
-
if not title and not url_:
|
|
481
|
-
continue
|
|
482
|
-
results.append({
|
|
483
|
-
"title": str(title)[:200],
|
|
484
|
-
"url": str(url_),
|
|
485
|
-
"snippet": "",
|
|
486
|
-
"source": "eu_opendata",
|
|
487
|
-
"score": rank_score(0.7, _rk8),
|
|
488
|
-
})
|
|
489
|
-
return results
|
|
490
|
-
return _engine
|
|
491
|
-
|
|
492
|
-
|
|
493
281
|
# ── Open-Meteo 全球天气 ───────────────────────────────────────────────────────
|
|
494
282
|
|
|
495
283
|
def _build_open_meteo_engine(spec: dict[str, Any]) -> Any:
|
|
@@ -740,122 +528,6 @@ def _build_electricity_maps_engine(spec: dict[str, Any]) -> Any:
|
|
|
740
528
|
return _engine
|
|
741
529
|
|
|
742
530
|
|
|
743
|
-
# ── USDA FoodData Central 营养成分 ────────────────────────────────────────────
|
|
744
|
-
|
|
745
|
-
def _build_usda_engine(spec: dict[str, Any]) -> Any:
|
|
746
|
-
"""USDA FoodData Central 营养成分(api.nal.usda.gov,官方 DEMO_KEY)。"""
|
|
747
|
-
timeout = spec.get("timeout", 12)
|
|
748
|
-
|
|
749
|
-
@safe_search
|
|
750
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
751
|
-
to = _timeout or timeout
|
|
752
|
-
url = (f"https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY"
|
|
753
|
-
f"&query={urllib.parse.quote(query)}&pageSize={min(n, 10)}")
|
|
754
|
-
try:
|
|
755
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
756
|
-
except Exception as e:
|
|
757
|
-
logger.warning(f"USDA 失败: {e}")
|
|
758
|
-
return []
|
|
759
|
-
results = []
|
|
760
|
-
for _rk14, food in enumerate((data.get("foods") or [])[:n]):
|
|
761
|
-
if not isinstance(food, dict):
|
|
762
|
-
continue
|
|
763
|
-
desc = food.get("description", "")
|
|
764
|
-
fdc = food.get("fdcId", "")
|
|
765
|
-
brand = food.get("brandOwner") or ""
|
|
766
|
-
parts = [p for p in (food.get("foodCategory", ""), brand) if p]
|
|
767
|
-
if not desc:
|
|
768
|
-
continue
|
|
769
|
-
results.append({
|
|
770
|
-
"title": desc[:200],
|
|
771
|
-
"url": f"https://fdc.nal.usda.gov/food-details/{fdc}/nutrients" if fdc else "",
|
|
772
|
-
"snippet": (" · ".join(parts) + f" · FDC {fdc}")[:300] if fdc else " · ".join(parts)[:300],
|
|
773
|
-
"source": "usda",
|
|
774
|
-
"score": rank_score(0.7, _rk14),
|
|
775
|
-
})
|
|
776
|
-
return results
|
|
777
|
-
return _engine
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
# ── Tatoeba 双语例句 ──────────────────────────────────────────────────────────
|
|
781
|
-
|
|
782
|
-
def _build_tatoeba_engine(spec: dict[str, Any]) -> Any:
|
|
783
|
-
"""Tatoeba 多语言例句库(tatoeba.org/api_v0,400+ 语言对)。"""
|
|
784
|
-
timeout = spec.get("timeout", 12)
|
|
785
|
-
|
|
786
|
-
@safe_search
|
|
787
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
788
|
-
to = _timeout or timeout
|
|
789
|
-
url = (f"https://tatoeba.org/en/api_v0/search?query={urllib.parse.quote(query)}"
|
|
790
|
-
f"&limit={min(n, 10)}")
|
|
791
|
-
try:
|
|
792
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
793
|
-
except Exception as e:
|
|
794
|
-
logger.warning(f"Tatoeba 失败: {e}")
|
|
795
|
-
return []
|
|
796
|
-
results = []
|
|
797
|
-
sentences = data.get("results")
|
|
798
|
-
if isinstance(sentences, dict):
|
|
799
|
-
sentences = sentences.get("Sentences") or []
|
|
800
|
-
for _rk15, s in enumerate((sentences or [])[:n]):
|
|
801
|
-
if not isinstance(s, dict):
|
|
802
|
-
continue
|
|
803
|
-
text = s.get("text", "")
|
|
804
|
-
lang = s.get("lang", "")
|
|
805
|
-
trans = s.get("translations") or []
|
|
806
|
-
t_texts = []
|
|
807
|
-
# translations 是 list of lists(每层一个目标语言数组)
|
|
808
|
-
for t in trans[:3]:
|
|
809
|
-
arr = t if isinstance(t, list) else []
|
|
810
|
-
t_texts.extend(str(x.get("text", "")) for x in arr[:2] if isinstance(x, dict))
|
|
811
|
-
snippet = " ⇄ ".join(t for t in t_texts if t)[:200] or f"({lang})"
|
|
812
|
-
if not text:
|
|
813
|
-
continue
|
|
814
|
-
results.append({
|
|
815
|
-
"title": text[:200],
|
|
816
|
-
"url": f"https://tatoeba.org/en/sentences/show/{s.get('id', '')}" if s.get("id") else "",
|
|
817
|
-
"snippet": snippet,
|
|
818
|
-
"source": "tatoeba",
|
|
819
|
-
"score": rank_score(0.7, _rk15),
|
|
820
|
-
})
|
|
821
|
-
return results
|
|
822
|
-
return _engine
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
# ── Figshare 科研数据集 ───────────────────────────────────────────────────────
|
|
826
|
-
|
|
827
|
-
def _build_figshare_engine(spec: dict[str, Any]) -> Any:
|
|
828
|
-
"""Figshare 科研数据集检索(api.figshare.com/v2/articles)。"""
|
|
829
|
-
timeout = spec.get("timeout", 12)
|
|
830
|
-
|
|
831
|
-
@safe_search
|
|
832
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
833
|
-
to = _timeout or timeout
|
|
834
|
-
url = (f"https://api.figshare.com/v2/articles?search_for={urllib.parse.quote(query)}"
|
|
835
|
-
f"&page_size={min(n, 10)}")
|
|
836
|
-
try:
|
|
837
|
-
data = _http_json(url, to, engine=spec.get("_name", ""))
|
|
838
|
-
except Exception as e:
|
|
839
|
-
logger.warning(f"Figshare 失败: {e}")
|
|
840
|
-
return []
|
|
841
|
-
results = []
|
|
842
|
-
for _rk16, art in enumerate((data if isinstance(data, list) else [])[:n]):
|
|
843
|
-
if not isinstance(art, dict):
|
|
844
|
-
continue
|
|
845
|
-
title = art.get("title", "")
|
|
846
|
-
if not title:
|
|
847
|
-
continue
|
|
848
|
-
results.append({
|
|
849
|
-
"title": str(title)[:200],
|
|
850
|
-
"url": art.get("url_public_api") or art.get("url_public_html") or "",
|
|
851
|
-
"snippet": f"DOI: {art.get('doi', '')}"[:300] if art.get("doi") else "",
|
|
852
|
-
"source": "figshare",
|
|
853
|
-
"score": rank_score(0.7, _rk16),
|
|
854
|
-
})
|
|
855
|
-
return results
|
|
856
|
-
return _engine
|
|
857
|
-
|
|
858
|
-
|
|
859
531
|
# ── 腾讯 K 线(前复权日 K)────────────────────────────────────────────────────
|
|
860
532
|
|
|
861
533
|
def _resolve_tencent_symbol(q: str, to: float, headers: dict, engine: str = "") -> str:
|
|
@@ -23,49 +23,6 @@ from engines_base import (
|
|
|
23
23
|
|
|
24
24
|
logger = logging.getLogger("unified_search.engines")
|
|
25
25
|
|
|
26
|
-
# ── ClinicalTrials.gov v2 ────────────────────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
def _build_clinicaltrials_engine(spec: dict[str, Any]) -> Any:
|
|
29
|
-
"""ClinicalTrials.gov API v2 试验检索(免认证)。"""
|
|
30
|
-
timeout = spec.get("timeout", 12)
|
|
31
|
-
|
|
32
|
-
@safe_search
|
|
33
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
34
|
-
import urllib.parse as up
|
|
35
|
-
q = " ".join(re.findall(r"[A-Za-z0-9][A-Za-z0-9._+-]*", query))
|
|
36
|
-
if not re.search(r"[A-Za-z]{2,}", q):
|
|
37
|
-
return []
|
|
38
|
-
to = _timeout or timeout
|
|
39
|
-
url = "https://clinicaltrials.gov/api/v2/studies?" + up.urlencode({
|
|
40
|
-
"query.term": q, "pageSize": min(n, 20), "format": "json"})
|
|
41
|
-
try:
|
|
42
|
-
with http_open(urllib.request.Request(
|
|
43
|
-
url, headers={"User-Agent": "argo-search/2.5", "Accept": "application/json"}), timeout=to, engine=spec.get("_name", "")) as resp:
|
|
44
|
-
data = json.loads(resp.read().decode("utf-8", "replace"))
|
|
45
|
-
except Exception as e:
|
|
46
|
-
logger.warning(f"clinicaltrials 失败: {e}")
|
|
47
|
-
return []
|
|
48
|
-
results = []
|
|
49
|
-
for _rk5, st in enumerate((data.get("studies") or [])[:n]):
|
|
50
|
-
ps = st.get("protocolSection") or {}
|
|
51
|
-
ident = ps.get("identificationModule") or {}
|
|
52
|
-
desc = ps.get("descriptionModule") or {}
|
|
53
|
-
status = (ps.get("statusModule") or {}).get("overallStatus") or ""
|
|
54
|
-
nct = ident.get("nctId") or ""
|
|
55
|
-
title = ident.get("briefTitle") or ident.get("officialTitle") or nct
|
|
56
|
-
summary = desc.get("briefSummary") or status
|
|
57
|
-
if not title and not nct:
|
|
58
|
-
continue
|
|
59
|
-
results.append({
|
|
60
|
-
"title": str(title)[:200],
|
|
61
|
-
"url": f"https://clinicaltrials.gov/study/{nct}" if nct else "",
|
|
62
|
-
"snippet": str(summary).replace("\n", " ")[:300],
|
|
63
|
-
"source": "clinicaltrials",
|
|
64
|
-
"score": rank_score(0.85, _rk5),
|
|
65
|
-
})
|
|
66
|
-
return results
|
|
67
|
-
return _engine
|
|
68
|
-
|
|
69
26
|
|
|
70
27
|
# ── openFDA 药品标签 ─────────────────────────────────────────────────────────
|
|
71
28
|
|
|
@@ -653,48 +610,6 @@ def _build_usgs_engine(spec: dict[str, Any]) -> Any:
|
|
|
653
610
|
return _engine
|
|
654
611
|
|
|
655
612
|
|
|
656
|
-
# ── NASA CMR 地球科学数据目录引擎 ────────────────────────────────────────────
|
|
657
|
-
|
|
658
|
-
_CMR_API = "https://cmr.earthdata.nasa.gov/search/collections.json"
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
def _build_nasa_cmr_engine(spec: dict[str, Any]) -> Any:
|
|
662
|
-
"""NASA CMR 地球科学数据目录检索(cmr.earthdata.nasa.gov,免认证)。
|
|
663
|
-
|
|
664
|
-
MODIS/卫星/遥感等关键词 → 数据集集合(含概念 ID,链接 Earthdata Search)。
|
|
665
|
-
"""
|
|
666
|
-
timeout = spec.get("timeout", 12)
|
|
667
|
-
_HEADERS = {"User-Agent": "argo-search/2.6 (unified-search@local)", "Accept": "application/json"}
|
|
668
|
-
|
|
669
|
-
@safe_search
|
|
670
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
671
|
-
q = _ascii_tokens(query)
|
|
672
|
-
if not q:
|
|
673
|
-
return []
|
|
674
|
-
to = _timeout or timeout
|
|
675
|
-
url = _CMR_API + "?" + urllib.parse.urlencode({"keyword": q, "page_size": min(n, 10)})
|
|
676
|
-
try:
|
|
677
|
-
with http_open(urllib.request.Request(url, headers=_HEADERS), timeout=to, engine=spec.get("_name", "")) as resp:
|
|
678
|
-
data = json.loads(resp.read().decode("utf-8", "replace"))
|
|
679
|
-
except Exception as e:
|
|
680
|
-
logger.warning(f"NASA CMR 失败: {e}")
|
|
681
|
-
return []
|
|
682
|
-
results = []
|
|
683
|
-
for _rk16, x in enumerate(((data.get("feed") or {}).get("entry") or [])[:n]):
|
|
684
|
-
title = x.get("title") or q
|
|
685
|
-
cid = x.get("id") or ""
|
|
686
|
-
summary = (x.get("summary") or "")[:200]
|
|
687
|
-
results.append({
|
|
688
|
-
"title": title,
|
|
689
|
-
"url": f"https://search.earthdata.nasa.gov/search/granules?p={cid}" if cid else "",
|
|
690
|
-
"snippet": summary[:300],
|
|
691
|
-
"source": "nasa_cmr",
|
|
692
|
-
"score": rank_score(0.8, _rk16),
|
|
693
|
-
})
|
|
694
|
-
return results
|
|
695
|
-
return _engine
|
|
696
|
-
|
|
697
|
-
|
|
698
613
|
# ── bioRxiv / medRxiv 预印本引擎 ─────────────────────────────────────────────
|
|
699
614
|
|
|
700
615
|
# DOI 提取:10. 开头的标准 DOI(bioRxiv DOI 形态 10.1101/2024.01.02.123456)
|
|
@@ -518,37 +518,6 @@ def _build_wechat_sogou_engine(spec: dict[str, Any]) -> Any:
|
|
|
518
518
|
return _engine
|
|
519
519
|
|
|
520
520
|
|
|
521
|
-
# ── Hacker News 搜索引擎 ──────────────────────────────────────────────────────
|
|
522
|
-
|
|
523
|
-
def _build_hackernews_engine(spec: dict[str, Any]) -> Any:
|
|
524
|
-
"""Hacker News 搜索(Algolia API)"""
|
|
525
|
-
timeout = spec.get("timeout", 8)
|
|
526
|
-
|
|
527
|
-
@safe_search
|
|
528
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
529
|
-
import urllib.parse as up
|
|
530
|
-
to = _timeout or timeout
|
|
531
|
-
url = f"https://hn.algolia.com/api/v1/search?query={up.quote(query)}&tags=story&hitsPerPage={min(n, 10)}"
|
|
532
|
-
headers = {"User-Agent": "argo-search/1.0"}
|
|
533
|
-
req = urllib.request.Request(url, headers=headers)
|
|
534
|
-
try:
|
|
535
|
-
with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
|
|
536
|
-
data = json.loads(resp.read())
|
|
537
|
-
results = []
|
|
538
|
-
for h in data.get("hits", []):
|
|
539
|
-
results.append({
|
|
540
|
-
"title": h.get("title", ""),
|
|
541
|
-
"url": h.get("url", f"https://news.ycombinator.com/item?id={h.get('objectID', '')}"),
|
|
542
|
-
"snippet": f"score: {h.get('points', 0)} | comments: {h.get('num_comments', 0)} | by: {h.get('author', '')}",
|
|
543
|
-
"source": "hackernews",
|
|
544
|
-
})
|
|
545
|
-
return results
|
|
546
|
-
except Exception as e:
|
|
547
|
-
logger.warning(f"HackerNews 引擎失败: {e}")
|
|
548
|
-
return []
|
|
549
|
-
return _engine
|
|
550
|
-
|
|
551
|
-
|
|
552
521
|
# ── Stack Overflow 搜索引擎 ───────────────────────────────────────────────────
|
|
553
522
|
|
|
554
523
|
# Stack Exchange 站点族:同一 API 换 site 参数覆盖 180+ 站点,
|
|
@@ -1164,73 +1133,6 @@ def _build_deps_dev_engine(spec: dict[str, Any]) -> Any:
|
|
|
1164
1133
|
return _engine
|
|
1165
1134
|
|
|
1166
1135
|
|
|
1167
|
-
# ── endoflife.date 产品生命周期引擎 ──────────────────────────────────────────
|
|
1168
|
-
|
|
1169
|
-
_EOL_TAIL_WORDS = ("生命周期", "支持到", "eol", "support", "lifecycle",
|
|
1170
|
-
"什么时候", "停更")
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
def _build_endoflife_engine(spec: dict[str, Any]) -> Any:
|
|
1174
|
-
"""endoflife.date 产品生命周期引擎(200+ 产品,免认证)。
|
|
1175
|
-
|
|
1176
|
-
查询词 = 产品 slug(python / nodejs / go / kubernetes / ubuntu…)。
|
|
1177
|
-
API 无搜索端点,slug 提取取查询里的第一个 ASCII 词并剥离「生命周期 /
|
|
1178
|
-
EOL / 支持」类尾词;未识别产品 404 → 诚实返回空,slug 模糊匹配交给
|
|
1179
|
-
通用搜索源。每条结果附 endoflife.date 产品页,可核验。
|
|
1180
|
-
"""
|
|
1181
|
-
timeout = spec.get("timeout", 10)
|
|
1182
|
-
|
|
1183
|
-
@safe_search
|
|
1184
|
-
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
1185
|
-
to = _timeout or timeout
|
|
1186
|
-
slug = ""
|
|
1187
|
-
for tok in re.split(r"[\s,,。/?]+", (query or "")):
|
|
1188
|
-
t = tok.strip().lower()
|
|
1189
|
-
if not t or not re.fullmatch(r"[a-z][a-z0-9.\-_]{1,30}", t):
|
|
1190
|
-
continue
|
|
1191
|
-
if any(w in t for w in _EOL_TAIL_WORDS):
|
|
1192
|
-
continue
|
|
1193
|
-
slug = t
|
|
1194
|
-
break
|
|
1195
|
-
if not slug:
|
|
1196
|
-
return []
|
|
1197
|
-
from engines_base import _http_get_raw
|
|
1198
|
-
raw = _http_get_raw(f"https://endoflife.date/api/{slug}.json",
|
|
1199
|
-
{"Accept": "application/json"}, to,
|
|
1200
|
-
engine="endoflife")
|
|
1201
|
-
if not raw:
|
|
1202
|
-
return []
|
|
1203
|
-
try:
|
|
1204
|
-
data = json.loads(raw)
|
|
1205
|
-
except json.JSONDecodeError:
|
|
1206
|
-
return []
|
|
1207
|
-
if not isinstance(data, list):
|
|
1208
|
-
return []
|
|
1209
|
-
web_url = f"https://endoflife.date/{slug}"
|
|
1210
|
-
results = []
|
|
1211
|
-
for i, cyc in enumerate(data[:n]):
|
|
1212
|
-
label = "(最新)" if i == 0 else ""
|
|
1213
|
-
snippet_parts = []
|
|
1214
|
-
if cyc.get("latest"):
|
|
1215
|
-
snippet_parts.append(f"最新 {cyc['latest']}")
|
|
1216
|
-
if cyc.get("releaseDate"):
|
|
1217
|
-
snippet_parts.append(f"发布 {cyc['releaseDate']}")
|
|
1218
|
-
if cyc.get("support"):
|
|
1219
|
-
snippet_parts.append(f"全支持至 {cyc['support']}")
|
|
1220
|
-
if cyc.get("eol"):
|
|
1221
|
-
snippet_parts.append(f"EOL {cyc['eol']}")
|
|
1222
|
-
results.append({
|
|
1223
|
-
"title": f"{slug} {cyc.get('cycle', '?')}{label}",
|
|
1224
|
-
"url": web_url,
|
|
1225
|
-
"snippet": " · ".join(snippet_parts),
|
|
1226
|
-
"source": "endoflife",
|
|
1227
|
-
"score": 0.9 if i == 0 else 0.7,
|
|
1228
|
-
"published_at": str(cyc.get("latestReleaseDate") or "")[:10],
|
|
1229
|
-
})
|
|
1230
|
-
return results
|
|
1231
|
-
return _engine
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
1136
|
# ── Bing RSS 通用网页搜索(免 key,稳定备胎)─────────────────────────────
|
|
1235
1137
|
|
|
1236
1138
|
def _build_bing_rss_engine(spec: dict[str, Any]) -> Any:
|