argo-search 2.14.1 → 2.15.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.
- package/AGENTS.md +8 -6
- package/README.es.md +54 -832
- package/README.ja.md +53 -833
- package/README.ko.md +53 -831
- package/README.md +126 -769
- package/README.zh.md +124 -893
- package/SKILL.md +17 -18
- package/assets/readme/counts.json +1 -1
- package/assets/readme/hero.svg +23 -23
- package/backends/concept_vectors.bin +0 -0
- package/backends/domain_profiles.json +42 -0
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +124 -28
- package/backends/quota_profiles.json +70 -0
- package/bin/argo +30 -17
- package/config.yaml +173 -33
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +23 -0
- package/docs/ENGINE_CATALOG.md +97 -85
- package/docs/MCP_SETUP.md +1 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASING.md +1 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cn_ai_news.yaml +10 -8
- package/engines/specs/digup.yaml +11 -6
- package/engines/specs/douyin_hot.yaml +11 -1
- package/engines/specs/dw_news.yaml +4 -2
- package/engines/specs/eng_blogs.yaml +63 -0
- package/engines/specs/europeana.yaml +3 -4
- package/engines/specs/felo.yaml +3 -3
- package/engines/specs/firecrawl.yaml +3 -0
- package/engines/specs/fourget.yaml +5 -2
- package/engines/specs/france24.yaml +6 -4
- package/engines/specs/fxtwitter.yaml +29 -6
- package/engines/specs/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/lobsters.yaml +41 -0
- package/engines/specs/local_seek.yaml +6 -0
- package/engines/specs/open_meteo.yaml +1 -1
- package/engines/specs/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +8 -3
- package/engines/specs/tinyfish.yaml +2 -0
- package/engines/specs/tinyfish_news.yaml +2 -0
- package/engines/specs/tinyfish_paper.yaml +2 -0
- package/engines/specs/toutiao_hot.yaml +11 -1
- package/engines/specs/train.yaml +3 -0
- package/engines/specs/twitter.yaml +4 -0
- package/engines/specs/unpaywall.yaml +6 -0
- package/engines/specs/vam.yaml +17 -3
- package/engines/specs/weibo_hot.yaml +11 -1
- package/engines/specs/wolframalpha.yaml +3 -3
- package/engines/specs/xiaohongshu.yaml +2 -0
- package/engines/specs/zhihu.yaml +3 -18
- package/engines/specs/zhihu_kb.yaml +18 -0
- package/engines/specs/zhihu_questions.yaml +19 -0
- package/package.json +3 -2
- package/packages/dsh-plugin/README.md +9 -14
- package/packages/dsh-plugin/dsh/client.js +467 -1024
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/runner.js +2 -0
- package/packages/dsh-plugin/package.json +8 -3
- package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
- package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
- package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
- package/packages/dsh-plugin/test/size-gate.test.js +2 -9
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +40 -3
- package/scripts/badcase_ledger.py +108 -9
- package/scripts/build_concept_table.py +112 -55
- package/scripts/cache.py +5 -1
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +56 -8
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +31 -0
- package/scripts/daemon.py +146 -51
- package/scripts/dormant_ledger.py +23 -9
- package/scripts/engine_dispatch.py +3 -3
- package/scripts/engine_env.py +182 -1
- package/scripts/engine_families.py +50 -7
- package/scripts/engine_states.py +3 -50
- package/scripts/engine_validate.py +13 -45
- package/scripts/engines.py +15 -31
- package/scripts/engines_base.py +42 -58
- package/scripts/engines_builders.py +0 -15
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +2 -75
- package/scripts/engines_builders_batch9.py +15 -24
- package/scripts/engines_builders_cn.py +0 -194
- package/scripts/engines_builders_feeds.py +55 -5
- package/scripts/engines_builders_intl.py +15 -115
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_tech.py +5 -14
- package/scripts/engines_builders_weather.py +236 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +135 -0
- package/scripts/engines_mcp.py +383 -0
- package/scripts/engines_parsers.py +13 -369
- package/scripts/engines_schema_drift.py +260 -0
- package/scripts/evidence.py +13 -0
- package/scripts/evidence_loop.py +4 -3
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +28 -28
- package/scripts/fulltext_store.py +42 -1
- package/scripts/fxtwitter_api.py +8 -7
- package/scripts/gen_engine_catalog.py +2 -2
- package/scripts/general_pool.py +15 -4
- package/scripts/health_check.py +1 -1
- package/scripts/link_source.py +65 -24
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/mcp_handlers.py +53 -31
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_transport.py +1 -1
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/pre-commit +45 -43
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +6 -1
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +21 -15
- package/scripts/release.py +14 -26
- package/scripts/release_check.py +5 -25
- package/scripts/replay_eval.py +2 -2
- package/scripts/research_cli.py +40 -0
- package/scripts/research_notes.py +368 -0
- package/scripts/route.py +32 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +10 -4
- package/scripts/route_domains.py +150 -23
- package/scripts/route_lang.py +20 -7
- package/scripts/route_log.py +26 -9
- package/scripts/route_policy.py +85 -6
- package/scripts/route_telemetry_export.py +199 -0
- package/scripts/rrf_classic.py +5 -22
- package/scripts/search.py +2 -1
- package/scripts/search_attribution.py +33 -10
- package/scripts/search_entry.py +5 -1
- package/scripts/search_output.py +5 -4
- package/scripts/search_pipeline.py +12 -0
- package/scripts/search_rank.py +21 -11
- package/scripts/semantic_evidence.py +375 -168
- package/scripts/settings_page.py +3 -3
- package/scripts/social_engines/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +251 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +2 -2
- package/scripts/source_ledger.py +2 -15
- package/scripts/source_selection.py +45 -20
- package/scripts/straggler_policy.py +1 -2
- package/scripts/sync_backends.py +17 -0
- package/scripts/tfidf_router.py +23 -11
- package/scripts/time_utils.py +54 -1
- package/scripts/train.py +68 -2
- package/scripts/usage_log.py +26 -1
- package/sub-skills/argo-wide-research/SKILL.md +68 -0
- package/sub-skills/ego-search/SKILL.md +1 -1
- package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
- package/scripts/caliber_dedupe.py +0 -66
- package/scripts/engines_builders_batch16.py +0 -13
- package/scripts/health_probe.py +0 -253
- package/scripts/social_engines/twitter_engine.py +0 -514
- package/scripts/sync_installs.py +0 -29
package/scripts/evidence.py
CHANGED
|
@@ -696,6 +696,17 @@ def compute_credibility(
|
|
|
696
696
|
snippet = r.get("snippet", "") or ""
|
|
697
697
|
|
|
698
698
|
auth = score_authority(url, source, query)
|
|
699
|
+
# 方案C(upstream_authority 只透传不赋权):排序层已拿到的上游权威档
|
|
700
|
+
# (zhihu builder 解析 AuthorityLevel / spec output_map 的
|
|
701
|
+
# item_upstream_authority)原样挂到 credibility.authority.upstream_level,
|
|
702
|
+
# 供取证侧与研报引用;不参与 selection/final 计算——上游档只补充
|
|
703
|
+
# 上下文,不替代本仓基于 URL/域名的评分。无上游档则不加键(不编造)。
|
|
704
|
+
_upstream = r.get("upstream_authority")
|
|
705
|
+
if _upstream is None or _upstream == "":
|
|
706
|
+
_upstream = r.get("authority_level")
|
|
707
|
+
if _upstream is not None and _upstream != "":
|
|
708
|
+
auth = dict(auth)
|
|
709
|
+
auth["upstream_level"] = _upstream
|
|
699
710
|
fresh = score_freshness(r, query_time)
|
|
700
711
|
density = score_evidence_density(snippet, title)
|
|
701
712
|
|
|
@@ -838,6 +849,8 @@ def main():
|
|
|
838
849
|
flag_s = ",".join(flags) if flags else "-"
|
|
839
850
|
print(f"{level} [{c['final']:.2f}] sel={c['selection']:.2f} abs={c['absorption']:.2f} [{flag_s}] {r['title'][:48]}")
|
|
840
851
|
print(f" 权威:{c['authority']['score']:.2f} ({c['authority']['reason']})")
|
|
852
|
+
if c["authority"].get("upstream_level") is not None:
|
|
853
|
+
print(f" 上游档:{c['authority']['upstream_level']}(upstream_authority 只透传)")
|
|
841
854
|
print(f" 时效:{c['freshness']['score']:.2f} ({c['freshness']['reason']})")
|
|
842
855
|
print()
|
|
843
856
|
|
package/scripts/evidence_loop.py
CHANGED
|
@@ -588,9 +588,10 @@ def verify_results(results: list[dict[str, Any]],
|
|
|
588
588
|
assess_substantive_discussion, enabled as _semantic_enabled,
|
|
589
589
|
)
|
|
590
590
|
if _semantic_enabled():
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
591
|
+
# 三级阶梯兜底:Gemini 默认 → JEV 备用 → 本地启发式最终兜底
|
|
592
|
+
support = assess_support(query, scored_inputs, allow_heuristic=True)
|
|
593
|
+
source_types = assess_source_types(scored_inputs, allow_heuristic=True)
|
|
594
|
+
substantive_map = assess_substantive_discussion(query, scored_inputs, allow_heuristic=True)
|
|
594
595
|
primary_count = 0
|
|
595
596
|
substantive_count = 0
|
|
596
597
|
passing_count = 0
|
package/scripts/fetch_jsrun.py
CHANGED
|
@@ -21,20 +21,24 @@ def _jsrun_enabled() -> bool:
|
|
|
21
21
|
return env_flag("ARGO_FETCH_JSRUN")
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
_MINI_RACER_OK: bool | None = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _mini_racer_available() -> bool:
|
|
28
|
+
"""一次性探测 py_mini_racer 是否就绪,缺依赖时 O(1) 短路。"""
|
|
29
|
+
global _MINI_RACER_OK
|
|
30
|
+
if _MINI_RACER_OK is None:
|
|
31
|
+
import importlib.util
|
|
32
|
+
_MINI_RACER_OK = importlib.util.find_spec("py_mini_racer") is not None
|
|
33
|
+
return _MINI_RACER_OK
|
|
34
|
+
|
|
35
|
+
|
|
24
36
|
def _jsrun_challenge_fetch(url: str, html: str, max_chars: int = 8000,
|
|
25
37
|
timeout: float = 8.0,
|
|
26
38
|
backoff_budget_s: float | None = None) -> dict:
|
|
27
|
-
"""用 js-run 执行挑战页 JS,尝试获取 clearance cookie 后重试请求。
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
由调用方降级到 tinyfish/CDP。
|
|
31
|
-
|
|
32
|
-
重试请求用 curl_cffi Chrome 指纹 impersonate(站点按 TLS 指纹风控,
|
|
33
|
-
裸 Python 指纹被静默拦截)。退避重试 3 次(间隔 5s/10s)。
|
|
34
|
-
`backoff_budget_s`(秒)给整段重试设墙钟上界:传入时退避睡眠与后续
|
|
35
|
-
尝试都不得越过它——此前 sleep(5)+sleep(10) 不受链级预算约束,cookie
|
|
36
|
-
拿到而三连败时可在 fetch 链内部多耗 ~30s(2026-10-06 审查定位)。
|
|
37
|
-
"""
|
|
39
|
+
"""用 js-run 执行挑战页 JS,尝试获取 clearance cookie 后重试请求。"""
|
|
40
|
+
if not html or not _mini_racer_available():
|
|
41
|
+
return {}
|
|
38
42
|
import re as _re
|
|
39
43
|
import time as _time
|
|
40
44
|
|
package/scripts/fetch_v3.py
CHANGED
|
@@ -55,6 +55,7 @@ if SCRIPT_DIR not in sys.path:
|
|
|
55
55
|
# engine_states 是状态词表唯一真源(2026-11-09 收口)
|
|
56
56
|
import fetch_render_tinyfish as _render_tinyfish
|
|
57
57
|
import engine_states
|
|
58
|
+
from except_sets import IO_BENIGN, OPT_IMPORT, SHAPE_BENIGN # 收窄词汇表(2026-11-13 裸吞收口)
|
|
58
59
|
|
|
59
60
|
# 解码统一入口(2026-10-26,charset 是只依赖 re 的叶子模块,顶层导入无负担):
|
|
60
61
|
# urllib 兜底车道与主链共享「头声明 > meta 嗅探 > 猜测链」,GBK 老站不再满屏 U+FFFD
|
|
@@ -134,12 +135,12 @@ def extract_content(html: str, max_chars: int = 8000) -> tuple[str, str]:
|
|
|
134
135
|
content, title = extract_readability(html, max_chars=max_chars)
|
|
135
136
|
if content.strip():
|
|
136
137
|
return _cut(content, max_chars), title.strip()
|
|
137
|
-
except
|
|
138
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
138
139
|
pass
|
|
139
140
|
ext = ContentExtractor()
|
|
140
141
|
try:
|
|
141
142
|
ext.feed(html)
|
|
142
|
-
except
|
|
143
|
+
except SHAPE_BENIGN:
|
|
143
144
|
pass
|
|
144
145
|
ext._blocks.sort(key=lambda x: x[0], reverse=True)
|
|
145
146
|
content = "\n\n".join(text for _, text in ext._blocks[:10])
|
|
@@ -499,7 +500,7 @@ def _md_variant_fetch(url: str, max_chars: int = 8000,
|
|
|
499
500
|
"User-Agent": "argo-fetch-v3/1.0 (+local-research; md-variant)",
|
|
500
501
|
"Accept": "text/markdown, text/plain;q=0.9, */*;q=0.8",
|
|
501
502
|
})
|
|
502
|
-
except
|
|
503
|
+
except OPT_IMPORT + IO_BENIGN:
|
|
503
504
|
continue
|
|
504
505
|
if resp.get("status", 0) != 200 or not resp.get("text"):
|
|
505
506
|
continue
|
|
@@ -625,7 +626,7 @@ def _identity_remember_mobile(host: str) -> None:
|
|
|
625
626
|
# 并发抓取进程会互相搬走临时文件,身份记忆静默丢失。
|
|
626
627
|
_paths.atomic_write_json(Path(_identity_path()), _identity_mem, indent=None)
|
|
627
628
|
_identity_dirty = False
|
|
628
|
-
except
|
|
629
|
+
except IO_BENIGN:
|
|
629
630
|
pass
|
|
630
631
|
|
|
631
632
|
|
|
@@ -858,7 +859,7 @@ def _archive_truncated(url: str, text: str, delivered: str, kind: str,
|
|
|
858
859
|
extra[f"full_{kind}_path"] = path
|
|
859
860
|
if primary:
|
|
860
861
|
extra["full_text_path"] = path
|
|
861
|
-
except
|
|
862
|
+
except OPT_IMPORT + IO_BENIGN:
|
|
862
863
|
pass
|
|
863
864
|
|
|
864
865
|
|
|
@@ -899,7 +900,7 @@ def _make_result(url: str, html: str, max_chars: int,
|
|
|
899
900
|
try:
|
|
900
901
|
from article_meta import extract_article_meta
|
|
901
902
|
result.update(extract_article_meta(html, url))
|
|
902
|
-
except
|
|
903
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
903
904
|
pass
|
|
904
905
|
result.update(extra)
|
|
905
906
|
return result
|
|
@@ -1306,7 +1307,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1306
1307
|
_declared_ok = _video.get("content_ok")
|
|
1307
1308
|
try:
|
|
1308
1309
|
_video = _assess_quality(_video)
|
|
1309
|
-
except
|
|
1310
|
+
except SHAPE_BENIGN:
|
|
1310
1311
|
pass
|
|
1311
1312
|
_video["content_ok"] = bool(_declared_ok)
|
|
1312
1313
|
_video["page_type"] = "video"
|
|
@@ -1314,22 +1315,9 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1314
1315
|
_video["cached"] = False
|
|
1315
1316
|
return _strip_html_unless_needed(_video, need_html)
|
|
1316
1317
|
|
|
1317
|
-
#
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
if robots_blocked(url, timeout=min(timeout, 5.0)):
|
|
1321
|
-
result = _make_result(url, "", 0, engine_states.FETCH_ROBOTS_BLOCKED, ok=False,
|
|
1322
|
-
error="robots.txt 禁止抓取")
|
|
1323
|
-
result = _assess_quality(result)
|
|
1324
|
-
result["cached"] = False
|
|
1325
|
-
return _strip_html_unless_needed(result, need_html)
|
|
1326
|
-
except ImportError:
|
|
1327
|
-
pass
|
|
1328
|
-
|
|
1329
|
-
# 微信公众号文章走专用降级链(HTTP→CDP→搜狗,唯一来源 wechat_article.py,
|
|
1330
|
-
# 即 `argo wx` 同一实现):通用 HTML 链对 mp.weixin 只能拿到 JS 骨架,
|
|
1331
|
-
# 正文全空(2026-11-01 实测缺口:fetch 对 mp.weixin 零处理)。robots 已在
|
|
1332
|
-
# 上方拦截,这里只做域名分流;need_html/actions/force_browser 同视频分支让路。
|
|
1318
|
+
# 微信专用降级链(HTTP→CDP→搜狗,wechat_article.py,`argo wx` 同实现——用户
|
|
1319
|
+
# 显式取文不走匿名爬虫 robots 口径)【必须在 robots 闸前】mp.weixin/robots.txt
|
|
1320
|
+
# 是 Disallow: /(11-15 实测),闸先跑分支永不可达(6ebb625 实跑复现)。让路同前。
|
|
1333
1321
|
if (_is_wechat_article_url(url) and not need_html and not actions
|
|
1334
1322
|
and not force_browser):
|
|
1335
1323
|
try:
|
|
@@ -1352,7 +1340,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1352
1340
|
}
|
|
1353
1341
|
try:
|
|
1354
1342
|
_wx_result = _assess_quality(_wx_result)
|
|
1355
|
-
except
|
|
1343
|
+
except SHAPE_BENIGN:
|
|
1356
1344
|
pass
|
|
1357
1345
|
_wx_result["cached"] = False
|
|
1358
1346
|
return _strip_html_unless_needed(_wx_result, need_html)
|
|
@@ -1368,6 +1356,18 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1368
1356
|
"cached": False,
|
|
1369
1357
|
}, need_html)
|
|
1370
1358
|
|
|
1359
|
+
# robots.txt 尊重(合规检查):被禁路径直接拒绝,抓取失败放行
|
|
1360
|
+
try:
|
|
1361
|
+
from robots_guard import robots_blocked
|
|
1362
|
+
if robots_blocked(url, timeout=min(timeout, 5.0)):
|
|
1363
|
+
result = _make_result(url, "", 0, engine_states.FETCH_ROBOTS_BLOCKED, ok=False,
|
|
1364
|
+
error="robots.txt 禁止抓取")
|
|
1365
|
+
result = _assess_quality(result)
|
|
1366
|
+
result["cached"] = False
|
|
1367
|
+
return _strip_html_unless_needed(result, need_html)
|
|
1368
|
+
except ImportError:
|
|
1369
|
+
pass
|
|
1370
|
+
|
|
1371
1371
|
# 登录态车道(A2):站点有 argo auth 持久 profile → 跳过匿名链直进浏览器。
|
|
1372
1372
|
# 匿名 HTTP 对已登录站只会拿到「登出态」内容——那是成功的假象,比失败更糟。
|
|
1373
1373
|
# 判断本体在 browser_auth(含开关与 use_browser_fallback=False 让路);
|
|
@@ -1419,7 +1419,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1419
1419
|
if (out.get("quality_breakdown") or {}).get("version") != _v:
|
|
1420
1420
|
out = _quality.assess(out)
|
|
1421
1421
|
out["quality_basis"] = "rescored"
|
|
1422
|
-
except
|
|
1422
|
+
except SHAPE_BENIGN:
|
|
1423
1423
|
pass
|
|
1424
1424
|
out["cached"] = True
|
|
1425
1425
|
out["cache_level"] = hit.get("_cache_level", engine_states.CACHE_LEVEL_UNKNOWN)
|
|
@@ -1624,7 +1624,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1624
1624
|
result = tf
|
|
1625
1625
|
# tinyfish 未命中(关闭/缺 key/失败/短内容)才起本地 Chrome——
|
|
1626
1626
|
# 内容过短的成功响应与失败同样需要继续降级
|
|
1627
|
-
if result.get("fetch_method")
|
|
1627
|
+
if result.get("fetch_method") not in (_render_tinyfish.TINYFISH_METHOD, engine_states.FETCH_JSRUN_CHALLENGE):
|
|
1628
1628
|
browser_result = _browser_fetch(
|
|
1629
1629
|
url, max_chars, timeout=_level_timeout(15.0))
|
|
1630
1630
|
if browser_result.get("success") or not result.get("success"):
|
|
@@ -1645,7 +1645,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1645
1645
|
from article_meta import extract_article_meta
|
|
1646
1646
|
for _mk, _mv in extract_article_meta(result["html"], url).items():
|
|
1647
1647
|
result.setdefault(_mk, _mv)
|
|
1648
|
-
except
|
|
1648
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
1649
1649
|
pass
|
|
1650
1650
|
|
|
1651
1651
|
# 写 URL 缓存(不存大块 html,省空间)
|
|
@@ -1677,7 +1677,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1677
1677
|
if ev:
|
|
1678
1678
|
to_store[FETCH_EVIDENCE_KEY] = {
|
|
1679
1679
|
k: v for k, v in ev.items() if k != "url"}
|
|
1680
|
-
except
|
|
1680
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
1681
1681
|
pass
|
|
1682
1682
|
SearchCache().set_fetch(url, to_store, ttl=ttl)
|
|
1683
1683
|
except Exception:
|
|
@@ -153,13 +153,15 @@ def _evict() -> None:
|
|
|
153
153
|
"""
|
|
154
154
|
items = entries()
|
|
155
155
|
total = sum(e["bytes"] for e in items)
|
|
156
|
+
dropped = 0
|
|
156
157
|
|
|
157
158
|
def _drop(seq: list) -> int:
|
|
158
|
-
|
|
159
|
+
nonlocal dropped
|
|
159
160
|
try:
|
|
160
161
|
os.unlink(seq["path"])
|
|
161
162
|
except Exception:
|
|
162
163
|
return 0
|
|
164
|
+
dropped += 1
|
|
163
165
|
return seq["bytes"]
|
|
164
166
|
|
|
165
167
|
while len(items) > MAX_FILES:
|
|
@@ -167,3 +169,42 @@ def _evict() -> None:
|
|
|
167
169
|
while items and total > MAX_TOTAL_BYTES:
|
|
168
170
|
total -= _drop(items.pop())
|
|
169
171
|
|
|
172
|
+
# 淘汰发生了才对账:台账与正文同生命周期。追加式台账曾只写不截断,
|
|
173
|
+
# 正文有 MAX_FILES/MAX_TOTAL 淘汰而台账没有——生产库实测 688 行里
|
|
174
|
+
# 386 行(56%)指向已淘汰文件,纯死行。
|
|
175
|
+
if dropped:
|
|
176
|
+
_reconcile_index()
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _reconcile_index() -> None:
|
|
180
|
+
"""把 index.jsonl 重写为与现存正文对齐的最小台账;失败不影响主流程。
|
|
181
|
+
|
|
182
|
+
回读只按 URL 哈希定位(见模块头),台账只是给人看的列举台账——重写
|
|
183
|
+
坏了最多丢列举能力,不丢回读能力。同一文件多次存档的记录保留最后一条
|
|
184
|
+
(追加序里最后出现的行元数据最新)。
|
|
185
|
+
"""
|
|
186
|
+
try:
|
|
187
|
+
d = store_dir()
|
|
188
|
+
idx = d / "index.jsonl"
|
|
189
|
+
if not idx.is_file():
|
|
190
|
+
return
|
|
191
|
+
alive = {e["path"] for e in entries()}
|
|
192
|
+
last: dict[str, str] = {}
|
|
193
|
+
with idx.open(encoding="utf-8") as f:
|
|
194
|
+
for raw in f:
|
|
195
|
+
line = raw.strip()
|
|
196
|
+
if not line:
|
|
197
|
+
continue
|
|
198
|
+
try:
|
|
199
|
+
rec = json.loads(line)
|
|
200
|
+
except Exception:
|
|
201
|
+
continue # 坏行丢弃,不让一行脏数据卡住整个台账
|
|
202
|
+
p = rec.get("path")
|
|
203
|
+
if isinstance(p, str):
|
|
204
|
+
last[p] = line
|
|
205
|
+
kept = [last[p] for p in last if p in alive]
|
|
206
|
+
import argo_paths
|
|
207
|
+
argo_paths.atomic_write_text(idx, "".join(l + "\n" for l in kept))
|
|
208
|
+
except Exception:
|
|
209
|
+
pass
|
|
210
|
+
|
package/scripts/fxtwitter_api.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""FxTwitter / FxEmbed 原始客户端(零 Key,只读)。
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
本模块是**原始接口层**,原样返回上游 JSON 的各端点(status / thread /
|
|
5
|
+
conversation / quotes / reposts),供 `argo tweet` 做完整打包用。搜索结果
|
|
6
|
+
的归一 schema 由声明式 `fxtwitter` 引擎(engines/specs/fxtwitter.yaml)
|
|
7
|
+
承担;关键词搜索走 `twitter` 引擎的 `scripts/x_search.py`。旧
|
|
8
|
+
`social_engines/twitter_engine.py` 已删(2026-11-15:三个通道全失效、零生产
|
|
9
|
+
调用者);公共出口纪律不变——都走 net_proxy + url_safety。
|
|
9
10
|
|
|
10
11
|
公共实例:api.fxtwitter.com(备镜像 api.fixupx.com)
|
|
11
12
|
文档:https://docs.fxembed.com/api/twitter/
|
|
@@ -76,8 +77,8 @@ def http_get(url: str, *, headers: dict[str, str] | None = None,
|
|
|
76
77
|
max_retries: int = 2) -> tuple[bytes, int]:
|
|
77
78
|
"""GET 一个 URL,带 429/网络重试。发请求前过 SSRF 守卫。
|
|
78
79
|
|
|
79
|
-
FxTwitter 侧**唯一**的 HTTP
|
|
80
|
-
|
|
80
|
+
FxTwitter 侧**唯一**的 HTTP 出口:打包器(tweet.py)与需要原始响应的
|
|
81
|
+
抓取处都走这里,不再各写一份重试与代理处理。
|
|
81
82
|
"""
|
|
82
83
|
ok, reason = check_url(url)
|
|
83
84
|
if not ok:
|
|
@@ -203,8 +203,8 @@ def render() -> str:
|
|
|
203
203
|
L.append("## 一、总量与口径")
|
|
204
204
|
L.append("")
|
|
205
205
|
L.append(f"- **收录 {len(rows)} 个源**(`engines/specs/*.yaml` 声明总数)")
|
|
206
|
-
L.append(f"- **开箱可用 {len(usable)}
|
|
207
|
-
"
|
|
206
|
+
L.append(f"- **开箱可用 {len(usable)} 个**:不需要你配任何密钥或装额外工具"
|
|
207
|
+
"(其中显式专用源需 `--engine` 调用,见下方「显式专用」清单)")
|
|
208
208
|
L.append(f"- **需自备密钥 {len(keyed)} 个**:{_names(keyed)}"
|
|
209
209
|
"(没配也不影响搜索,路由会跳过)")
|
|
210
210
|
L.append(f"- **需装后端工具 {len(needs_dep)} 个**:{_names(needs_dep)}"
|
package/scripts/general_pool.py
CHANGED
|
@@ -62,9 +62,17 @@ def general_kwargs(features: dict | None, mode: str, depth: str,
|
|
|
62
62
|
选源按用途(日常/研究)与语言排序;把四个参数散在各调用点复制,既容易
|
|
63
63
|
漏传,也把 route.py 顶过行数门禁。放在池模块,因为它只服务选源。
|
|
64
64
|
"""
|
|
65
|
+
feats = features or {}
|
|
66
|
+
lang = str(
|
|
67
|
+
feats.get("lang_override")
|
|
68
|
+
or feats.get("effective_lang")
|
|
69
|
+
or feats.get("primary_lang")
|
|
70
|
+
or ""
|
|
71
|
+
)
|
|
65
72
|
return {
|
|
66
73
|
"mode": mode, "depth": depth, "context": context,
|
|
67
|
-
"lang":
|
|
74
|
+
"lang": lang,
|
|
75
|
+
"intents": tuple(feats.get("intents") or ()),
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
|
|
@@ -112,6 +120,7 @@ def general_order() -> tuple[list[str], bool]:
|
|
|
112
120
|
def ranked_general(enabled: set[str], *, mode: str = "auto",
|
|
113
121
|
depth: str = "fast", context: str = "search",
|
|
114
122
|
lang: str = "",
|
|
123
|
+
intents: tuple[str, ...] | list[str] | None = None,
|
|
115
124
|
score_fn: Callable[[str, str, str, str],
|
|
116
125
|
tuple[float, int]] | None = None
|
|
117
126
|
) -> list[str]:
|
|
@@ -126,7 +135,7 @@ def ranked_general(enabled: set[str], *, mode: str = "auto",
|
|
|
126
135
|
from source_selection import rank_general_candidates
|
|
127
136
|
ranked = rank_general_candidates(
|
|
128
137
|
order, enabled=enabled, mode=mode, depth=depth,
|
|
129
|
-
context=context, lang=lang, score_fn=score_fn)
|
|
138
|
+
context=context, lang=lang, intents=intents, score_fn=score_fn)
|
|
130
139
|
if ranked:
|
|
131
140
|
return ranked
|
|
132
141
|
except Exception as exc:
|
|
@@ -144,7 +153,8 @@ def ranked_general(enabled: set[str], *, mode: str = "auto",
|
|
|
144
153
|
|
|
145
154
|
def general_fallback(enabled: set[str], *, mode: str = "auto",
|
|
146
155
|
depth: str = "fast", context: str = "search",
|
|
147
|
-
lang: str = ""
|
|
156
|
+
lang: str = "",
|
|
157
|
+
intents: tuple[str, ...] | list[str] | None = None) -> list[str]:
|
|
148
158
|
"""通用候选池排序 + local_search 殿后。
|
|
149
159
|
|
|
150
160
|
local_search 殿后(2026-10-15 实测定案):日常档 combo_budget=2,它一旦
|
|
@@ -152,7 +162,8 @@ def general_fallback(enabled: set[str], *, mode: str = "auto",
|
|
|
152
162
|
独跑 109 次、中位 2.9s、占墙钟 369s,82% 是纯英文技术查询)。
|
|
153
163
|
"""
|
|
154
164
|
order = ranked_general(
|
|
155
|
-
enabled, mode=mode, depth=depth, context=context, lang=lang
|
|
165
|
+
enabled, mode=mode, depth=depth, context=context, lang=lang,
|
|
166
|
+
intents=intents)
|
|
156
167
|
if not order:
|
|
157
168
|
# 最后一道 fail-open:池子与本轮 enabled 完全无交集时,任取两个
|
|
158
169
|
# 可用源也比空 combo 好(执行层至少能暴露真实错误)。
|
package/scripts/health_check.py
CHANGED
|
@@ -39,7 +39,7 @@ if not logger.handlers:
|
|
|
39
39
|
PROBE_TIMEOUT = 5.0
|
|
40
40
|
# 本文件不实现失败阈值:它写注册表的布尔 available,连续失败计数由
|
|
41
41
|
# argo_engine_registry.update_health 累加但无人按阈值读。阈值的唯一
|
|
42
|
-
#
|
|
42
|
+
# 此前这里
|
|
43
43
|
# 另有一个 MAX_FAILURES = 2 却没有任何读取点,看着像有门限其实没有。
|
|
44
44
|
HEALTH_TTL = 300 # 5 分钟
|
|
45
45
|
|
package/scripts/link_source.py
CHANGED
|
@@ -63,6 +63,37 @@ def _load_local_targets() -> list[Path]:
|
|
|
63
63
|
return out
|
|
64
64
|
|
|
65
65
|
|
|
66
|
+
def _load_local_sub_links() -> list[tuple[Path, Path]]:
|
|
67
|
+
"""读取 installs.local.yaml 的 sub_links(目标 -> 仓内子目录)。"""
|
|
68
|
+
if not LOCAL_INSTALLS.exists():
|
|
69
|
+
return []
|
|
70
|
+
try:
|
|
71
|
+
from yaml_load import load as _yaml_load
|
|
72
|
+
except ImportError:
|
|
73
|
+
return []
|
|
74
|
+
data = _yaml_load(LOCAL_INSTALLS) or {}
|
|
75
|
+
raw = data.get("sub_links") or {}
|
|
76
|
+
if not isinstance(raw, dict):
|
|
77
|
+
return []
|
|
78
|
+
root = SOURCE.resolve()
|
|
79
|
+
out: list[tuple[Path, Path]] = []
|
|
80
|
+
for dst, rel_src in raw.items():
|
|
81
|
+
if not dst or not rel_src:
|
|
82
|
+
continue
|
|
83
|
+
rel_path = Path(str(rel_src))
|
|
84
|
+
if rel_path.is_absolute():
|
|
85
|
+
print(f"[warn] sub_links 源路径必须相对仓库根,已跳过: {rel_src}", file=sys.stderr)
|
|
86
|
+
continue
|
|
87
|
+
src = (root / rel_path).resolve()
|
|
88
|
+
try:
|
|
89
|
+
src.relative_to(root)
|
|
90
|
+
except ValueError:
|
|
91
|
+
print(f"[warn] sub_links 源路径越界出仓库根,已跳过: {rel_src}", file=sys.stderr)
|
|
92
|
+
continue
|
|
93
|
+
out.append((_normalize_target(Path(str(dst))), src))
|
|
94
|
+
return out
|
|
95
|
+
|
|
96
|
+
|
|
66
97
|
def _normalize_target(p: Path) -> Path:
|
|
67
98
|
"""规范化目标路径:展开 ~、补成绝对路径、消掉 . 与 ..,**但不跟随符号链接**。
|
|
68
99
|
|
|
@@ -77,13 +108,13 @@ def _normalize_target(p: Path) -> Path:
|
|
|
77
108
|
return Path(os.path.normpath(str(p)))
|
|
78
109
|
|
|
79
110
|
|
|
80
|
-
def _hops_to_source(target: Path) -> int:
|
|
111
|
+
def _hops_to_source(target: Path, source: Path | None = None) -> int:
|
|
81
112
|
"""目标到来源的符号链接跳数。
|
|
82
113
|
|
|
83
114
|
0 = 目标就是来源本体;1 = 直连;>1 = 间接链接(可解析但多一跳依赖);
|
|
84
115
|
-1 = 未指向来源 / 断链 / 成环(超过 8 跳按未指向处理,避免死循环)。
|
|
85
116
|
"""
|
|
86
|
-
src = SOURCE.resolve()
|
|
117
|
+
src = (source or SOURCE).resolve()
|
|
87
118
|
cur = target
|
|
88
119
|
for hops in range(8):
|
|
89
120
|
try:
|
|
@@ -139,17 +170,20 @@ def _looks_like_argo_copy(path: Path) -> bool:
|
|
|
139
170
|
return any((path / marker).exists() for marker in _ARGO_MARKERS)
|
|
140
171
|
|
|
141
172
|
|
|
142
|
-
def link_one(target: Path, *, dry_run: bool, force: bool) -> int:
|
|
143
|
-
"""将 target 设为指向 SOURCE
|
|
144
|
-
|
|
145
|
-
|
|
173
|
+
def link_one(target: Path, *, dry_run: bool, force: bool, source: Path | None = None) -> int:
|
|
174
|
+
"""将 target 设为指向 source(默认 SOURCE)的 symlink(间接链接会被重建为直连)。"""
|
|
175
|
+
src = (source or SOURCE).resolve()
|
|
176
|
+
if not src.is_dir():
|
|
177
|
+
print(f"[fail] 来源目录不存在: {src}", file=sys.stderr)
|
|
178
|
+
return 1
|
|
179
|
+
depth = _hops_to_source(target, src)
|
|
146
180
|
|
|
147
181
|
if depth == 0:
|
|
148
182
|
print(f"[skip] 目标就是真源本体: {target}")
|
|
149
183
|
return 0
|
|
150
184
|
|
|
151
185
|
if depth == 1:
|
|
152
|
-
print(f"[ok] 已指向真源: {target} -> {
|
|
186
|
+
print(f"[ok] 已指向真源: {target} -> {src}")
|
|
153
187
|
return 0
|
|
154
188
|
|
|
155
189
|
if depth > 1:
|
|
@@ -164,7 +198,7 @@ def link_one(target: Path, *, dry_run: bool, force: bool) -> int:
|
|
|
164
198
|
try:
|
|
165
199
|
if tmp.is_symlink() or tmp.exists():
|
|
166
200
|
tmp.unlink()
|
|
167
|
-
os.symlink(
|
|
201
|
+
os.symlink(src, tmp, target_is_directory=True)
|
|
168
202
|
os.replace(tmp, target)
|
|
169
203
|
except OSError as e:
|
|
170
204
|
try:
|
|
@@ -174,7 +208,7 @@ def link_one(target: Path, *, dry_run: bool, force: bool) -> int:
|
|
|
174
208
|
pass
|
|
175
209
|
print(f"[fail] 重建直连失败: {target} ({e})", file=sys.stderr)
|
|
176
210
|
return 1
|
|
177
|
-
print(f"[relink] {target} -> {
|
|
211
|
+
print(f"[relink] {target} -> {src}(原为 {depth} 跳间接链接,已重建为直连)")
|
|
178
212
|
return 0
|
|
179
213
|
|
|
180
214
|
if target.exists() or target.is_symlink():
|
|
@@ -212,49 +246,53 @@ def link_one(target: Path, *, dry_run: bool, force: bool) -> int:
|
|
|
212
246
|
|
|
213
247
|
parent = target.parent
|
|
214
248
|
if dry_run:
|
|
215
|
-
print(f"[dry] ln -sfn {
|
|
249
|
+
print(f"[dry] ln -sfn {src} {target}")
|
|
216
250
|
return 0
|
|
217
251
|
parent.mkdir(parents=True, exist_ok=True)
|
|
218
252
|
# atomic-ish: symlink in place
|
|
219
253
|
try:
|
|
220
|
-
os.symlink(
|
|
254
|
+
os.symlink(src, target, target_is_directory=True)
|
|
221
255
|
except OSError:
|
|
222
256
|
# Windows 无开发者模式/管理员权限时 symlink 会失败:
|
|
223
257
|
# 目录链接退化为 junction(mklink /J,不需要管理员权限),
|
|
224
258
|
# 语义与 symlink 基本一致(resolve() 同样指向来源)。
|
|
225
259
|
if os.name == "nt":
|
|
226
260
|
r = subprocess.run(
|
|
227
|
-
["cmd", "/c", "mklink", "/J", str(target), str(
|
|
261
|
+
["cmd", "/c", "mklink", "/J", str(target), str(src)],
|
|
228
262
|
capture_output=True, text=True,
|
|
229
263
|
encoding="utf-8", errors="replace", timeout=30,
|
|
230
264
|
)
|
|
231
265
|
# junction 不是 symlink(is_symlink() 为 False,_hops_to_source 会
|
|
232
266
|
# 把它当普通目录),此处按「解析后是否等于来源」独立判定。
|
|
233
267
|
try:
|
|
234
|
-
linked = target.resolve() ==
|
|
268
|
+
linked = target.resolve() == src
|
|
235
269
|
except OSError:
|
|
236
270
|
linked = False
|
|
237
271
|
if r.returncode == 0 and linked:
|
|
238
|
-
print(f"[link] {target} -> {
|
|
272
|
+
print(f"[link] {target} -> {src} (junction)")
|
|
239
273
|
return 0
|
|
240
|
-
print(f"[fail] 创建链接失败: {target} -> {
|
|
274
|
+
print(f"[fail] 创建链接失败: {target} -> {src}", file=sys.stderr)
|
|
241
275
|
return 1
|
|
242
|
-
print(f"[link] {target} -> {
|
|
276
|
+
print(f"[link] {target} -> {src}")
|
|
243
277
|
return 0
|
|
244
278
|
|
|
245
279
|
|
|
246
|
-
def check_targets(
|
|
280
|
+
def check_targets(
|
|
281
|
+
targets: list[Path],
|
|
282
|
+
sub_links: list[tuple[Path, Path]] | None = None,
|
|
283
|
+
) -> int:
|
|
247
284
|
bad = 0
|
|
248
285
|
print(f"真源: {SOURCE.resolve()}")
|
|
249
|
-
if not targets:
|
|
286
|
+
if not targets and not sub_links:
|
|
250
287
|
print("[fail] 无校验目标(请 --to / ARGO_LINK_TARGETS / installs.local.yaml)")
|
|
251
288
|
return 1
|
|
252
|
-
for t in targets
|
|
253
|
-
|
|
289
|
+
pairs = [(t, SOURCE.resolve()) for t in targets] + list(sub_links or [])
|
|
290
|
+
for t, src in pairs:
|
|
291
|
+
depth = _hops_to_source(t, src)
|
|
254
292
|
if depth == 0:
|
|
255
293
|
print(f"[ok] {t} 即真源本体")
|
|
256
294
|
elif depth == 1:
|
|
257
|
-
print(f"[ok] {t} -> {
|
|
295
|
+
print(f"[ok] {t} -> {src}")
|
|
258
296
|
elif depth > 1:
|
|
259
297
|
# 间接链接仍能解析到来源,但多了一环依赖——按「校验不一致」计失败,
|
|
260
298
|
# 提示直接重跑(不带 --check)即可重建为直连。
|
|
@@ -308,7 +346,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
308
346
|
args = p.parse_args(argv)
|
|
309
347
|
|
|
310
348
|
targets = resolve_targets(args.to)
|
|
311
|
-
if
|
|
349
|
+
sub_links = _load_local_sub_links() if args.to is None else []
|
|
350
|
+
if not targets and not sub_links:
|
|
312
351
|
print(
|
|
313
352
|
"未指定任何链接目标。\n"
|
|
314
353
|
" 方式 1: python3 scripts/link_source.py --to <path> [--to <path2>]\n"
|
|
@@ -320,7 +359,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
320
359
|
return 1
|
|
321
360
|
|
|
322
361
|
if args.check:
|
|
323
|
-
return check_targets(targets)
|
|
362
|
+
return check_targets(targets, sub_links)
|
|
324
363
|
|
|
325
364
|
if args.with_backends:
|
|
326
365
|
print(f"== sync_backends @ {SOURCE} ==")
|
|
@@ -331,9 +370,11 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
331
370
|
code = 0
|
|
332
371
|
for t in targets:
|
|
333
372
|
code = link_one(t, dry_run=args.dry_run, force=args.force) or code
|
|
373
|
+
for t, src in sub_links:
|
|
374
|
+
code = link_one(t, dry_run=args.dry_run, force=args.force, source=src) or code
|
|
334
375
|
if args.dry_run:
|
|
335
376
|
return code
|
|
336
|
-
return check_targets(targets) if code == 0 else code
|
|
377
|
+
return check_targets(targets, sub_links) if code == 0 else code
|
|
337
378
|
|
|
338
379
|
|
|
339
380
|
if __name__ == "__main__":
|