argo-search 2.9.8 → 2.10.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 (110) hide show
  1. package/README.en.md +48 -35
  2. package/README.es.md +48 -35
  3. package/README.ja.md +47 -34
  4. package/README.ko.md +47 -34
  5. package/README.md +50 -35
  6. package/SKILL.md +5 -5
  7. package/backends/domain_profiles.json +76 -0
  8. package/backends/engine_registry.yaml +161 -5
  9. package/backends/quota_profiles.json +122 -2
  10. package/bin/argo +26 -1
  11. package/bin/argo.js +3 -3
  12. package/config.yaml +180 -26
  13. package/docs/ARGO_INTRO.md +7 -5
  14. package/docs/ENGINE_CATALOG.md +64 -44
  15. package/docs/MCP_SETUP.md +1 -1
  16. package/docs/RELEASE_NOTES_v2.10.0.md +85 -0
  17. package/docs/RELEASE_NOTES_v2.9.8.md +1 -1
  18. package/docs/RELEASE_NOTES_v2.9.9.md +78 -0
  19. package/docs//344/270/272/344/273/200/344/271/210/351/200/211/346/213/251argo.md +9 -9
  20. package/engines/specs/clawhub.yaml +16 -15
  21. package/engines/specs/deepseek1024.yaml +46 -0
  22. package/engines/specs/dsh_hub.yaml +44 -0
  23. package/engines/specs/dshopen.yaml +32 -0
  24. package/engines/specs/explainx.yaml +32 -0
  25. package/engines/specs/gbfs_nyc.yaml +6 -1
  26. package/engines/specs/metaso_doc.yaml +49 -0
  27. package/engines/specs/metaso_image.yaml +65 -0
  28. package/engines/specs/metaso_podcast.yaml +60 -0
  29. package/engines/specs/metaso_scholar.yaml +57 -0
  30. package/engines/specs/metaso_video.yaml +62 -0
  31. package/engines/specs/ncpssd.yaml +41 -0
  32. package/engines/specs/sciverse.yaml +72 -0
  33. package/engines/specs/skills_sh.yaml +32 -0
  34. package/engines/specs/skillsmp.yaml +18 -16
  35. package/package.json +4 -2
  36. package/packages/dsh-plugin/README.md +4 -2
  37. package/packages/dsh-plugin/dsh/client.js +98 -32
  38. package/packages/dsh-plugin/dsh/diagnostics.js +43 -0
  39. package/packages/dsh-plugin/dsh/index.js +23 -1
  40. package/packages/dsh-plugin/package.json +2 -2
  41. package/packages/dsh-plugin/test/client.test.js +2 -1
  42. package/packages/dsh-plugin/test/size-gate.test.js +113 -0
  43. package/scripts/adaptive.py +135 -48
  44. package/scripts/article.py +6 -1
  45. package/scripts/article_meta.py +151 -2
  46. package/scripts/bench_general_pool.py +145 -0
  47. package/scripts/bench_tail_ab.py +281 -0
  48. package/scripts/bounded_run.py +91 -49
  49. package/scripts/candidate_envelope.py +45 -4
  50. package/scripts/charset_decode.py +127 -0
  51. package/scripts/clock_bridge.py +22 -0
  52. package/scripts/content_security.py +119 -4
  53. package/scripts/crawl.py +240 -74
  54. package/scripts/crawl_frontier.py +217 -0
  55. package/scripts/crawl_policy.py +174 -0
  56. package/scripts/dispatch_result.py +9 -2
  57. package/scripts/engine_add.py +602 -0
  58. package/scripts/engine_dispatch.py +31 -15
  59. package/scripts/engine_failure.py +15 -0
  60. package/scripts/engine_validate.py +8 -0
  61. package/scripts/engines.py +10 -0
  62. package/scripts/engines_base.py +12 -0
  63. package/scripts/engines_builders.py +14 -0
  64. package/scripts/engines_builders_dsh.py +330 -0
  65. package/scripts/engines_builders_skill.py +314 -0
  66. package/scripts/evidence_loop.py +4 -0
  67. package/scripts/fetch_quality.py +13 -0
  68. package/scripts/fetch_v3.py +39 -7
  69. package/scripts/gen_engine_catalog.py +218 -2
  70. package/scripts/general_pool.py +162 -0
  71. package/scripts/http_client.py +62 -80
  72. package/scripts/image_ops.py +4 -0
  73. package/scripts/image_vision/vision_probe +0 -0
  74. package/scripts/install.ps1 +47 -19
  75. package/scripts/install.sh +45 -20
  76. package/scripts/matrix_search_eval.py +128 -2
  77. package/scripts/mcp_transport.py +1 -1
  78. package/scripts/ncpssd_bridge.py +123 -0
  79. package/scripts/net_proxy.py +27 -0
  80. package/scripts/paid_policy.py +109 -13
  81. package/scripts/pre-commit +19 -4
  82. package/scripts/query_signals.py +156 -3
  83. package/scripts/recovery.py +7 -3
  84. package/scripts/redskill/redskill_engine.py +29 -2
  85. package/scripts/release_check.py +209 -0
  86. package/scripts/retry_policy.py +22 -1
  87. package/scripts/robots_guard.py +26 -0
  88. package/scripts/route.py +11 -8
  89. package/scripts/route_cache.py +6 -0
  90. package/scripts/route_combo.py +56 -64
  91. package/scripts/route_domains.py +142 -13
  92. package/scripts/route_policy.py +6 -0
  93. package/scripts/safe_conn.py +52 -0
  94. package/scripts/search.py +9 -1
  95. package/scripts/search_cli.py +27 -0
  96. package/scripts/search_entry.py +10 -0
  97. package/scripts/search_output.py +29 -0
  98. package/scripts/search_pipeline.py +59 -3
  99. package/scripts/search_rank.py +7 -0
  100. package/scripts/serp_guard.py +23 -0
  101. package/scripts/social_engines/bilibili_engine.py +163 -26
  102. package/scripts/social_engines/reddit_engine.py +52 -51
  103. package/scripts/source_selection.py +302 -0
  104. package/scripts/tail_completion.py +212 -0
  105. package/scripts/url_safety.py +126 -3
  106. package/scripts/usage_log.py +45 -0
  107. package/scripts/video_fetch.py +303 -0
  108. package/scripts/video_meta.py +225 -0
  109. package/scripts/video_route.py +65 -0
  110. package/scripts/watch.py +123 -0
@@ -0,0 +1,314 @@
1
+ #!/usr/bin/env python3
2
+ """技能目录构建器 —— explainx 与 skills.sh 两个新源的接入实现。
3
+
4
+ 为什么这两个走 L3 而不是 L1 声明式:它们的核心价值是**安装量**,而 L1 的
5
+ `output_map` 只能把单个上游字段映射成 `item_summary`(不支持模板拼接)。
6
+ 把「安装 216877 次 · anthropics/skills」这样一行说清楚,只能自己拼——
7
+ 否则用户搜「pdf」看到的是干巴巴的仓库名,判断不出哪个值得装。
8
+
9
+ 两个源的口径不可比(跨源别混用):
10
+ · explainx totalInstalls/weeklyInstalls —— 平台统计的安装数
11
+ · skills.sh installs —— Vercel 官方安装遥测(头部技能 21 万+)
12
+ Argo 已有的 skillsmp(仓库星数)、clawhub(生态下载量)是另外两套口径。
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import json
18
+ import urllib.parse
19
+ import urllib.request
20
+ from typing import Any
21
+
22
+ from engines_base import safe_search, http_open, rank_score
23
+
24
+ # ── explainx.ai(12075 条,安装量 + 分类 + 官方标记)────────────────────────
25
+ _EXPLAINX_URL = "https://explainx.ai/api/skills"
26
+
27
+ # ── skills.sh(Vercel,57k+,官方安装遥测)──────────────────────────────────
28
+ _SKILLS_SH_URL = "https://www.skills.sh/api/search"
29
+ _SKILLS_SH_PAGE = "https://skills.sh/"
30
+
31
+ # ── SkillsMP(200 万+,仓库星数口径)────────────────────────────────────────
32
+ _SKILLSMP_URL = "https://skillsmp.com/api/v1/skills/search"
33
+
34
+ # ── ClawHub(OpenClaw 生态,下载量口径)─────────────────────────────────────
35
+ _CLAWHUB_URL = "https://clawhub.ai/api/search"
36
+ _CLAWHUB_PAGE = "https://clawhub.ai"
37
+
38
+
39
+ def _normalize_epoch(val: Any) -> str:
40
+ """epoch → ISO8601 日期。上游两种量级:SkillsMP/ClawHub 的 updatedAt 是
41
+ **毫秒**(13 位),skills.sh 系是秒——按位数归一,避免 1000 倍错位。"""
42
+ try:
43
+ n = int(val)
44
+ except (TypeError, ValueError):
45
+ return ""
46
+ if n <= 0:
47
+ return ""
48
+ # 13 位(毫秒)vs 10 位(秒):毫秒转秒
49
+ if n > 10_000_000_000:
50
+ n //= 1000
51
+ try:
52
+ import time as _t
53
+
54
+ return _t.strftime("%Y-%m-%d", _t.gmtime(n))
55
+ except (OverflowError, OSError, ValueError):
56
+ return ""
57
+
58
+
59
+ def _get_json(url: str, timeout: float, engine: str) -> Any:
60
+ req = urllib.request.Request(
61
+ url, headers={"User-Agent": "argo-search/1.0", "Accept": "application/json"}
62
+ )
63
+ with http_open(req, timeout=timeout, engine=engine) as resp:
64
+ return json.loads(resp.read())
65
+
66
+
67
+ def _build_explainx_engine(spec: dict[str, Any]) -> Any:
68
+ """explainx.ai —— 带安装量/分类/官方标记的技能目录。
69
+
70
+ 字段口径(跨源不可比):totalInstalls/weeklyInstalls 是平台安装统计;
71
+ isOfficial 标记官方出品;category 是平台分类(Productivity/Frontend/…)。
72
+ 条目只给 repoOwner/repoName(GitHub 仓),无技能在仓内的子路径,故 URL
73
+ 只能到仓级别——这是上游数据的边界,不是取舍。
74
+ """
75
+ timeout = float(spec.get("timeout", 15))
76
+
77
+ @safe_search
78
+ def _engine(
79
+ query: str, n: int = 5, _timeout: float | None = None, **kwargs: Any
80
+ ) -> list[dict[str, Any]]:
81
+ to = _timeout or timeout
82
+ q = (query or "").strip()
83
+ if not q:
84
+ return []
85
+ url = f"{_EXPLAINX_URL}?q={urllib.parse.quote(q)}&limit={max(1, n)}"
86
+ data = _get_json(url, to, "explainx")
87
+ skills = data.get("skills") if isinstance(data, dict) else None
88
+ if not isinstance(skills, list):
89
+ return []
90
+
91
+ results: list[dict[str, Any]] = []
92
+ for rank, s in enumerate(skills[: max(1, n)]):
93
+ if not isinstance(s, dict):
94
+ continue
95
+ owner = s.get("repoOwner") or ""
96
+ repo = s.get("repoName") or ""
97
+ if not owner or not repo:
98
+ continue
99
+ installs = s.get("totalInstalls") or 0
100
+ weekly = s.get("weeklyInstalls")
101
+ category = s.get("category") or ""
102
+ # 安装量是这一源的核心价值,必须出现在摘要里(L1 做不到)
103
+ bits = [f"安装 {installs}"]
104
+ if weekly is not None and weekly != installs:
105
+ bits.append(f"本周 +{weekly}")
106
+ if s.get("isOfficial"):
107
+ bits.append("官方")
108
+ summary = " · ".join(bits)
109
+ if category:
110
+ summary = f"{category}|{summary}"
111
+ results.append(
112
+ {
113
+ "title": s.get("name") or "",
114
+ "url": f"https://github.com/{owner}/{repo}",
115
+ "snippet": summary,
116
+ "source": "explainx",
117
+ "score": rank_score(0.75, rank),
118
+ # 可验证出处:owner/repo 是「装什么」的权威答案
119
+ "upstream": f"{owner}/{repo}",
120
+ "metadata": {
121
+ "category": category,
122
+ "totalInstalls": installs,
123
+ "weeklyInstalls": weekly,
124
+ "isOfficial": bool(s.get("isOfficial")),
125
+ },
126
+ }
127
+ )
128
+ return results
129
+
130
+ return _engine
131
+
132
+
133
+ def _build_skillsmp_engine(spec: dict[str, Any]) -> Any:
134
+ """SkillsMP —— 200 万+ 开源技能独立索引(原 L1 声明式,改 L3 补字段)。
135
+
136
+ 为什么改 L3:上游有 `stars`(源仓库星数)与 `githubUrl`(**能安装**的
137
+ GitHub 目录),而 L1 的 output_map 只能把单字段映射成 summary,透不出
138
+ 这两个维度。星数是「这个技能多受欢迎」的唯一硬指标,githubUrl 比市场页
139
+ 更接近「装什么」——两者都值得进结果。
140
+
141
+ 口径:stars 是**源仓库星数**(不是安装量),与 skills.sh 的 Vercel 遥测、
142
+ explainx 的平台统计互不可比。
143
+ """
144
+ timeout = float(spec.get("timeout", 15))
145
+
146
+ @safe_search
147
+ def _engine(
148
+ query: str, n: int = 5, _timeout: float | None = None, **kwargs: Any
149
+ ) -> list[dict[str, Any]]:
150
+ to = _timeout or timeout
151
+ q = (query or "").strip()
152
+ if not q:
153
+ return []
154
+ url = (
155
+ f"{_SKILLSMP_URL}?q={urllib.parse.quote(q)}"
156
+ f"&limit={max(1, n)}&sortBy=stars"
157
+ )
158
+ data = _get_json(url, to, "skillsmp")
159
+ skills = (data.get("data") or {}).get("skills") if isinstance(data, dict) else None
160
+ if not isinstance(skills, list):
161
+ return []
162
+
163
+ results: list[dict[str, Any]] = []
164
+ for rank, s in enumerate(skills[: max(1, n)]):
165
+ if not isinstance(s, dict):
166
+ continue
167
+ # 优先给「能装」的 GitHub 目录;上游缺失时回落市场页
168
+ github = s.get("githubUrl") or ""
169
+ market = s.get("skillUrl") or ""
170
+ url_final = github or market
171
+ if not url_final:
172
+ continue
173
+ stars = s.get("stars") or 0
174
+ summary = str(s.get("description") or "")
175
+ if stars:
176
+ summary = f"★ {stars}|{summary}" if summary else f"★ {stars}"
177
+ results.append(
178
+ {
179
+ "title": s.get("name") or "",
180
+ "url": url_final,
181
+ "snippet": summary[:400],
182
+ "source": "skillsmp",
183
+ "score": rank_score(0.75, rank),
184
+ "published_at": _normalize_epoch(s.get("updatedAt")),
185
+ "upstream": github or market,
186
+ "metadata": {
187
+ "stars": stars,
188
+ "author": s.get("author") or "",
189
+ "contentLanguage": s.get("contentLanguage") or "",
190
+ },
191
+ }
192
+ )
193
+ return results
194
+
195
+ return _engine
196
+
197
+
198
+ def _build_clawhub_engine(spec: dict[str, Any]) -> Any:
199
+ """ClawHub —— OpenClaw 技能生态聚合(原 L1 声明式,改 L3 补字段)。
200
+
201
+ 为什么改 L3:上游有 `downloads`(生态下载量)与 `official`(官方标记),
202
+ L1 透不出。下载量是这一源独有的口径(skills.sh 是 Vercel 遥测、
203
+ SkillsMP 是仓库星数),值得单列。
204
+
205
+ 口径:downloads 是 ClawHub 生态下载量,与其它源的安装量互不可比。
206
+ """
207
+ timeout = float(spec.get("timeout", 15))
208
+
209
+ @safe_search
210
+ def _engine(
211
+ query: str, n: int = 5, _timeout: float | None = None, **kwargs: Any
212
+ ) -> list[dict[str, Any]]:
213
+ to = _timeout or timeout
214
+ q = (query or "").strip()
215
+ if not q:
216
+ return []
217
+ url = f"{_CLAWHUB_URL}?q={urllib.parse.quote(q)}&limit={max(1, n)}"
218
+ data = _get_json(url, to, "clawhub")
219
+ items = data.get("results") if isinstance(data, dict) else None
220
+ if not isinstance(items, list):
221
+ return []
222
+
223
+ results: list[dict[str, Any]] = []
224
+ for rank, s in enumerate(items[: max(1, n)]):
225
+ if not isinstance(s, dict):
226
+ continue
227
+ canonical = s.get("canonicalUrl") or ""
228
+ if not canonical:
229
+ continue
230
+ downloads = s.get("downloads") or 0
231
+ official = bool(s.get("official"))
232
+ summary = str(s.get("summary") or "")
233
+ bits = [f"下载 {downloads}"]
234
+ if official:
235
+ bits.append("官方")
236
+ summary = f"{' · '.join(bits)}|{summary}" if summary else " · ".join(bits)
237
+ results.append(
238
+ {
239
+ "title": s.get("displayName") or "",
240
+ "url": f"https://clawhub.ai{canonical}",
241
+ "snippet": summary[:400],
242
+ "source": "clawhub",
243
+ "score": rank_score(0.75, rank),
244
+ "published_at": _normalize_epoch(s.get("updatedAt")),
245
+ # install.reference 是 owner/slug 形式的安装引用
246
+ "upstream": ((s.get("install") or {}).get("reference")) or "",
247
+ "metadata": {
248
+ "downloads": downloads,
249
+ "official": official,
250
+ "owner": s.get("owner") or "",
251
+ "slug": s.get("slug") or "",
252
+ "version": s.get("version") or "",
253
+ },
254
+ }
255
+ )
256
+ return results
257
+
258
+ return _engine
259
+
260
+
261
+ def _build_skills_sh_engine(spec: dict[str, Any]) -> Any:
262
+ """skills.sh(Vercel)—— 官方安装遥测口径的技能目录。
263
+
264
+ 为什么 clawhub 不够:clawhub 声称聚合了 skills.sh 条目,但**聚合时丢了
265
+ installs 字段**(实测 clawhub 返回里只有 title/url/snippet/score)。
266
+ 安装量是判断「这个技能有多少人在用」的唯一硬指标,故单列一源。
267
+
268
+ 字段口径:installs 是 Vercel 官方遥测(头部 pdf 技能 21 万+),与
269
+ explainx 的平台统计、skillsmp 的仓库星数互不可比。
270
+ """
271
+ timeout = float(spec.get("timeout", 15))
272
+
273
+ @safe_search
274
+ def _engine(
275
+ query: str, n: int = 5, _timeout: float | None = None, **kwargs: Any
276
+ ) -> list[dict[str, Any]]:
277
+ to = _timeout or timeout
278
+ q = (query or "").strip()
279
+ if not q:
280
+ return []
281
+ url = f"{_SKILLS_SH_URL}?q={urllib.parse.quote(q)}&limit={max(1, n)}"
282
+ data = _get_json(url, to, "skills_sh")
283
+ skills = data.get("skills") if isinstance(data, dict) else None
284
+ if not isinstance(skills, list):
285
+ return []
286
+
287
+ results: list[dict[str, Any]] = []
288
+ for rank, s in enumerate(skills[: max(1, n)]):
289
+ if not isinstance(s, dict):
290
+ continue
291
+ sid = s.get("id") or ""
292
+ if not sid:
293
+ continue
294
+ installs = s.get("installs") or 0
295
+ source = s.get("source") or ""
296
+ results.append(
297
+ {
298
+ "title": s.get("name") or "",
299
+ # id 是 owner/repo/skill 三段式,直接拼站内页(实测 200)
300
+ "url": f"{_SKILLS_SH_PAGE}{sid}",
301
+ "snippet": f"安装 {installs} · {source}",
302
+ "source": "skills_sh",
303
+ "score": rank_score(0.75, rank),
304
+ # 可验证出处:三段式 id 指向技能本身(比市场页更精确)
305
+ "upstream": sid,
306
+ "metadata": {
307
+ "installs": installs,
308
+ "source": source,
309
+ },
310
+ }
311
+ )
312
+ return results
313
+
314
+ return _engine
@@ -127,6 +127,10 @@ def extract_fetch_evidence(fetch_result: dict[str, Any]) -> Optional[dict[str, A
127
127
  content = fetch_result.get("content") or ""
128
128
  if not content.strip():
129
129
  return None
130
+ # 风险门禁(v2.9.8):被隔离的正文不进证据分——来源试图注入,其正文不该
131
+ # 拿到吸收分去影响排序(正文此时已被清洗,但来源可信度存疑)。
132
+ if fetch_result.get("content_quarantined"):
133
+ return None
130
134
  title = fetch_result.get("title") or ""
131
135
  url = fetch_result.get("url") or ""
132
136
  if not url:
@@ -53,6 +53,18 @@ def _assess_quality(result: dict) -> dict:
53
53
  except Exception:
54
54
  security = {}
55
55
 
56
+ # 风险门禁(v2.9.8):被隔离的内容用清洗后正文替换原始正文,使注入
57
+ # 污染的正文不进 Agent 上下文、不进证据分。正常内容零改动。
58
+ quarantined = bool(security.get("quarantined"))
59
+ if quarantined:
60
+ cleaned = security.get("cleaned_content")
61
+ if cleaned is not None:
62
+ content = cleaned
63
+ result["content"] = cleaned
64
+ result["length"] = len(cleaned)
65
+ # 隔离内容一律判否:来源试图注入,其正文不可信
66
+ content_ok = content_ok and not quarantined
67
+
56
68
  result.update({
57
69
  "quality_breakdown": quality_breakdown(content, html),
58
70
  "content_ok": content_ok,
@@ -63,6 +75,7 @@ def _assess_quality(result: dict) -> dict:
63
75
  "content_age_days": content_age_days,
64
76
  "quality_score": quality_score,
65
77
  "content_security": security,
78
+ "content_quarantined": quarantined,
66
79
  })
67
80
  return result
68
81
 
@@ -54,6 +54,14 @@ if SCRIPT_DIR not in sys.path:
54
54
  # 渲染层(第二级A):TinyFish 直连渲染,独立模块以保持本文件聚焦主链调度
55
55
  import fetch_render_tinyfish as _render_tinyfish
56
56
 
57
+ # 解码统一入口(2026-10-26,charset 是只依赖 re 的叶子模块,顶层导入无负担):
58
+ # urllib 兜底车道与主链共享「头声明 > meta 嗅探 > 猜测链」,GBK 老站不再满屏 U+FFFD
59
+ try:
60
+ from charset_decode import decode_response_body as _decode_charset
61
+ except ImportError:
62
+ def _decode_charset(raw: bytes, _ct: str) -> str:
63
+ return raw.decode("utf-8", errors="replace")
64
+ from clock_bridge import clock # 统一时钟(测试=虚拟;生产=monotonic)
57
65
  # 质量信号层(第三级):来源分类 / 页面类型 / 质量分 / 内容安全
58
66
  import fetch_quality as _quality
59
67
 
@@ -635,8 +643,8 @@ def _mobile_http_fetch(url: str, max_chars: int = 8000,
635
643
  req = urllib.request.Request(url, headers={"User-Agent": _MOBILE_UA})
636
644
  try:
637
645
  with open_url(req, timeout=timeout) as r:
638
- text = r.read().decode("utf-8", errors="replace")
639
- return _make_result(url, text, max_chars, "http_mobile")
646
+ return _make_result(url, _decode_charset(r.read(), r.headers.get("Content-Type", "")),
647
+ max_chars, "http_mobile")
640
648
  except Exception as e:
641
649
  return _make_result(url, "", 0, "http_mobile", ok=False,
642
650
  error=str(e)[:100])
@@ -703,8 +711,8 @@ def _http_fetch(url: str, max_chars: int = 8000, timeout: float = 8.0,
703
711
  })
704
712
  try:
705
713
  with open_url(req, timeout=timeout) as r:
706
- text = r.read().decode("utf-8", errors="replace")
707
- return _make_result(url, text, max_chars, "http")
714
+ return _make_result(url, _decode_charset(r.read(), r.headers.get("Content-Type", "")),
715
+ max_chars, "http")
708
716
  except Exception as e:
709
717
  return _make_result(url, "", 0, "http", ok=False, error=str(e)[:100])
710
718
 
@@ -1257,6 +1265,29 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
1257
1265
  # URL 优化(Reddit 重写、追踪参数清理)
1258
1266
  url = _optimize_url(url)
1259
1267
 
1268
+ # 视频页走平台 API,不走 HTML 正文链:B 站/YouTube 的播放页正文不在
1269
+ # HTML 里(实测只抓到推荐位/页脚),通用链会把「0 字正文」当抓取失败。
1270
+ # need_html/actions/force_browser 是调用方的显式抓取意图,出现时让路。
1271
+ if not need_html and not actions and not force_browser:
1272
+ try:
1273
+ from video_fetch import fetch_video
1274
+ _video = fetch_video(url, max_chars=max_chars, timeout=timeout)
1275
+ except Exception:
1276
+ _video = None
1277
+ if _video is not None:
1278
+ # quality 评估会按正文长度重算 content_ok;视频的「有内容」判据
1279
+ # 是简介/字幕,不是长度,故先存声明值再恢复。
1280
+ _declared_ok = _video.get("content_ok")
1281
+ try:
1282
+ _video = _assess_quality(_video)
1283
+ except Exception:
1284
+ pass
1285
+ _video["content_ok"] = bool(_declared_ok)
1286
+ _video["page_type"] = "video"
1287
+ _video["source_type"] = "video"
1288
+ _video["cached"] = False
1289
+ return _strip_html_unless_needed(_video, need_html)
1290
+
1260
1291
  # robots.txt 尊重(合规检查):被禁路径直接拒绝,抓取失败放行
1261
1292
  try:
1262
1293
  from robots_guard import robots_blocked
@@ -1353,14 +1384,14 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
1353
1384
  deadline_s = float(os.environ.get("ARGO_FETCH_DEADLINE_S", "60") or 60)
1354
1385
  except ValueError:
1355
1386
  deadline_s = 60.0
1356
- t_chain0 = time.monotonic()
1387
+ t_chain0 = clock()
1357
1388
  deadline_hit = {"flag": False}
1358
1389
 
1359
1390
  def _budget_left() -> float:
1360
1391
  """剩余降级预算;耗尽时置标记并返回 -1(调用方停止升级)。"""
1361
1392
  if deadline_s <= 0:
1362
1393
  return 1.0
1363
- left = deadline_s - (time.monotonic() - t_chain0)
1394
+ left = deadline_s - (clock() - t_chain0)
1364
1395
  if left <= 0:
1365
1396
  deadline_hit["flag"] = True
1366
1397
  return -1.0
@@ -1748,7 +1779,8 @@ if __name__ == "__main__":
1748
1779
  # 输出摘要
1749
1780
  summary = {k: r[k] for k in ("success", "fetch_method", "content_ok",
1750
1781
  "quality_score", "page_type", "source_type",
1751
- "is_official", "length", "url") if k in r}
1782
+ "is_official", "length", "url",
1783
+ "video_meta") if k in r}
1752
1784
  # 截断必须可见:只给 8,000 字却不说明「还有多少没给」,调用方会当全文用
1753
1785
  for k in ("truncated", "full_length", "full_text_path", "total_length",
1754
1786
  "offset", "full_source", "final_url",